diff --git a/FSL/src/configregions.ui b/FSL/src/configregions.ui index bfb56197a199c4a24b2a08a13702d8eb278e22b5..024730178d0ef6663f71d4d54e9a4097c4211c30 100644 --- a/FSL/src/configregions.ui +++ b/FSL/src/configregions.ui @@ -37,7 +37,7 @@ </font> </property> <property name="text"> - <string>fRootLV Names</string> + <string>RootLV Names</string> </property> </widget> </item> @@ -52,7 +52,7 @@ </font> </property> <property name="text"> - <string>Electron Cut</string> + <string>Electron Cut (GeV)</string> </property> </widget> </item> @@ -67,7 +67,7 @@ </font> </property> <property name="text"> - <string>Proton Cut</string> + <string>Proton Cut (GeV)</string> </property> </widget> </item> @@ -82,7 +82,7 @@ </font> </property> <property name="text"> - <string>Positron Cut</string> + <string>Positron Cut (GeV)</string> </property> </widget> </item> @@ -97,7 +97,7 @@ </font> </property> <property name="text"> - <string>Gamma Cut</string> + <string>Gamma Cut (GeV)</string> </property> </widget> </item> diff --git a/FSL/src/fsl_mainwindow.cpp b/FSL/src/fsl_mainwindow.cpp index 506601d1003af416f639c373402efdcf004bafe6..dfa18d7ea986e8f18a2bd86bc201ad33e7c7eb46 100644 --- a/FSL/src/fsl_mainwindow.cpp +++ b/FSL/src/fsl_mainwindow.cpp @@ -25,11 +25,11 @@ FSLMainWindow::FSLMainWindow(QWidget *parent) //Setting up Models sens_det_model = new QStringListModel(this); g4ui_model = new QStringListModel(this); - shape_model = new QStringListModel(this); - ui->shape_view->setEditTriggers(QAbstractItemView::DoubleClicked); + // shape_model = new QStringListModel(this); + // ui->shape_view->setEditTriggers(QAbstractItemView::DoubleClicked); ui->sens_det_view->setModel(sens_det_model); ui->g4ui_view->setModel(g4ui_model); - ui->shape_view->setModel(shape_model); + // ui->shape_view->setModel(shape_model); ui->sens_det_view->setEditTriggers(QAbstractItemView::DoubleClicked); ui->g4ui_view->setEditTriggers(QAbstractItemView::DoubleClicked); @@ -39,10 +39,10 @@ FSLMainWindow::FSLMainWindow(QWidget *parent) region_model = new QStandardItemModel(this); region_horizontalHeader.append("Region Name"); region_horizontalHeader.append("RootLV Names"); - region_horizontalHeader.append("Electron Cut"); - region_horizontalHeader.append("Proton Cut"); - region_horizontalHeader.append("Positron Cut"); - region_horizontalHeader.append("Gamma Cut"); + region_horizontalHeader.append("Electron Cut (GeV)"); + region_horizontalHeader.append("Proton Cut (GeV)"); + region_horizontalHeader.append("Positron Cut (GeV)"); + region_horizontalHeader.append("Gamma Cut (GeV)"); region_model->setHorizontalHeaderLabels(region_horizontalHeader); ui->regions_table->setModel(region_model); ui->regions_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); @@ -52,7 +52,7 @@ FSLMainWindow::FSLMainWindow(QWidget *parent) //Setting up the User Actions Display user_action_model = new QStandardItemModel(this); - user_action_horizontalHeader.append("Type of Action"); + // user_action_horizontalHeader.append("Type of Action"); user_action_horizontalHeader.append("File"); user_action_model->setHorizontalHeaderLabels(user_action_horizontalHeader); ui->user_action_table->setModel(user_action_model); @@ -73,6 +73,7 @@ FSLMainWindow::FSLMainWindow(QWidget *parent) connect(ui->pB_main_clear, &QPushButton::released, this, &FSLMainWindow::clear_main_status); connect(ui->pB_pythia_browse, &QPushButton::released, this, &FSLMainWindow::assign_pythia_file); connect(ui->pB_magnetic_field_plugin, &QPushButton::released, this, &FSLMainWindow::assign_magnetic_field_plugin_file); + connect(ui->pB_magnetic_field_map, &QPushButton::released, this, &FSLMainWindow::assign_magnetic_field_map); connect(ui->pB_add_sens_det, &QPushButton::released, this, &FSLMainWindow::add_sens_det); connect(ui->pB_del_sens_det, &QPushButton::released, this, &FSLMainWindow::del_sens_det); @@ -80,15 +81,16 @@ FSLMainWindow::FSLMainWindow(QWidget *parent) connect(ui->pB_del_region, &QPushButton::released, this, &FSLMainWindow::del_region); connect(ui->pB_add_g4ui, &QPushButton::released, this, &FSLMainWindow::add_g4ui); connect(ui->pB_del_g4ui, &QPushButton::released, this, &FSLMainWindow::del_g4ui); - connect(ui->pB_add_shape_ext_file, &QPushButton::released, this, &FSLMainWindow::add_shape_ext); - connect(ui->pB_del_shape_ext_file, &QPushButton::released, this, &FSLMainWindow::del_shape_ext); + // connect(ui->pB_add_shape_ext_file, &QPushButton::released, this, &FSLMainWindow::add_shape_ext); + // connect(ui->pB_del_shape_ext_file, &QPushButton::released, this, &FSLMainWindow::del_shape_ext); - connect(ui->pB_run_actions, &QPushButton::released, this, &FSLMainWindow::assign_run_actions_file); - connect(ui->pB_event_actions, &QPushButton::released, this, &FSLMainWindow::assign_event_actions_file); - connect(ui->pB_stepping_actions, &QPushButton::released, this, &FSLMainWindow::assign_stepping_actions_file); - connect(ui->pB_stacking_actions, &QPushButton::released, this, &FSLMainWindow::assign_stacking_actions_file); - connect(ui->pB_tracking_actions, &QPushButton::released, this, &FSLMainWindow::assign_tracking_actions_file); + // connect(ui->pB_run_actions, &QPushButton::released, this, &FSLMainWindow::assign_run_actions_file); + // connect(ui->pB_event_actions, &QPushButton::released, this, &FSLMainWindow::assign_event_actions_file); + // connect(ui->pB_stepping_actions, &QPushButton::released, this, &FSLMainWindow::assign_stepping_actions_file); + // connect(ui->pB_stacking_actions, &QPushButton::released, this, &FSLMainWindow::assign_stacking_actions_file); + // connect(ui->pB_tracking_actions, &QPushButton::released, this, &FSLMainWindow::assign_tracking_actions_file); + connect(ui->pB_add_user_action, &QPushButton::released, this, &FSLMainWindow::add_user_action); connect(ui->pB_del_user_action, &QPushButton::released, this, &FSLMainWindow::del_user_action); connect(ui->actionQuit, &QAction::triggered, qApp, &QApplication::quit); @@ -105,7 +107,7 @@ FSLMainWindow::FSLMainWindow(QWidget *parent) ui->cB_particle->setCurrentIndex(0); ui->pB_pythia_browse->setEnabled(false); ui->cB_pythia_type_of_eve->setEnabled(false); - ui->lE_magnetic_field_map->setEnabled(false); + ui->pB_magnetic_field_map->setEnabled(false); ui->pB_magnetic_field_plugin->setEnabled(false); ui->cB_particle->setCurrentIndex(0); ui->lE_px->setText("0"); @@ -137,9 +139,9 @@ FSLMainWindow::FSLMainWindow(QWidget *parent) ui->lE_histo->setEnabled(false); - ui->tab->setEnabled(false);//Shape tab (Change name on UI) - ui->Region->setEnabled(false); - ui->User_Actions->setEnabled(false); + // ui->tab->setEnabled(false);//Shape tab (Change name on UI) + // ui->Region->setEnabled(false); + // ui->User_Actions->setEnabled(false); @@ -151,7 +153,7 @@ FSLMainWindow::FSLMainWindow(QWidget *parent) connect(this, &FSLMainWindow::send_error_message, this, &FSLMainWindow::catch_error_message); connect(ui->sens_det_view, SIGNAL(clicked(QModelIndex)), this, SLOT(get_sens_det_index(QModelIndex))); connect(ui->g4ui_view, SIGNAL(clicked(QModelIndex)), this, SLOT(get_g4ui_index(QModelIndex))); - connect(ui->shape_view, SIGNAL(clicked(QModelIndex)), this, SLOT(get_shape_index(QModelIndex))); + // connect(ui->shape_view, SIGNAL(clicked(QModelIndex)), this, SLOT(get_shape_index(QModelIndex))); connect(region,&ConfigRegions::send_config,this,&FSLMainWindow::add_region); connect(&fullSimLight_process,SIGNAL(readyReadStandardOutput()),this,SLOT(fsmlreadyReadStandardOutput())); connect(&fullSimLight_process,SIGNAL(readyReadStandardError()),this,SLOT(fsmlreadyReadStandardError())); @@ -173,7 +175,7 @@ FSLMainWindow::~FSLMainWindow() delete region; delete region_model; delete user_action_model; - delete shape_model; + // delete shape_model; delete p_x_validator; delete p_y_validator; delete p_z_validator; @@ -228,7 +230,7 @@ void FSLMainWindow::configure_sens_det_actions() //Get index of the row in the Shape extensions display when clicked -void FSLMainWindow::get_shape_index(QModelIndex shape_index) +/*void FSLMainWindow::get_shape_index(QModelIndex shape_index) { shape_number = shape_index.row(); } @@ -261,7 +263,7 @@ void FSLMainWindow::configure_shape_ext() index( i, 0 ).data( Qt::DisplayRole ).toString()).toStdString()); } -} +}*/ //Get index of row in g4ui display when clicked @@ -354,7 +356,7 @@ void FSLMainWindow::configure_g4ui_command() } - g4ui_commands.push_back("/process/list"); + // g4ui_commands.push_back("/process/list"); @@ -441,6 +443,7 @@ std::vector<std::string> FSLMainWindow::parse_froot_string(std::string input_fro } +/* //Function to add a Run actions file void FSLMainWindow::assign_run_actions_file() { @@ -510,6 +513,20 @@ void FSLMainWindow::assign_tracking_actions_file() ui->user_action_table->model()->setData(ui->user_action_table->model()->index(rows,1),q_tracking_file_name); } } +*/ + +//Function to add a user action file +void FSLMainWindow::add_user_action() +{ + QString q_user_file_name = QString::fromUtf8((this->get_file_name()).c_str()); + + if(q_user_file_name!="") + { + int rows = ui->user_action_table->model()->rowCount(); + ui->user_action_table->model()->insertRows(rows,1); + ui->user_action_table->model()->setData(ui->user_action_table->model()->index(rows,0),q_user_file_name); + } +} //Function to add a delete a user actions file void FSLMainWindow::del_user_action() @@ -525,19 +542,19 @@ void FSLMainWindow::del_user_action() //Function to add user actions to respective lists. void FSLMainWindow::configure_actions() { - run_actions.clear(); - event_actions.clear(); - stepping_actions.clear(); - stacking_actions.clear(); - tracking_actions.clear(); + // run_actions.clear(); + // event_actions.clear(); + // stepping_actions.clear(); + // stacking_actions.clear(); + // tracking_actions.clear(); user_action_extensions.clear(); for(int row = 0 ; row < ui->user_action_table->model()->rowCount(); ++row ) { - std::string type_of_action = ((ui->user_action_table->model()->index(row,0)).data().toString()).toStdString(); - std::string associated_file = ((ui->user_action_table->model()->index(row,1)).data().toString()).toStdString(); + // std::string type_of_action = ((ui->user_action_table->model()->index(row,0)).data().toString()).toStdString(); + std::string associated_file = ((ui->user_action_table->model()->index(row,0)).data().toString()).toStdString(); - if(type_of_action == "Run") + /* if(type_of_action == "Run") { run_actions.push_back(associated_file); } @@ -561,6 +578,9 @@ void FSLMainWindow::configure_actions() { tracking_actions.push_back(associated_file); } + */ + + user_action_extensions.push_back(associated_file); } @@ -652,6 +672,12 @@ void FSLMainWindow::assign_magnetic_field_plugin_file() magnetic_field_plugin_file = this->get_file_name(); } +//Function to assign magnetic field map +void FSLMainWindow::assign_magnetic_field_map() +{ + magnetic_field_map = this->get_file_name(); +} + //Function to configure particle energy and direction void FSLMainWindow::configure_energy_direction() { @@ -738,7 +764,7 @@ void FSLMainWindow::configure_magnetic_field() magnetic_field = (ui->lE_fixed_MF->text()).toStdString(); magnetic_field_plugin_file = ""; magnetic_field_map = ""; - ui->lE_magnetic_field_map->setEnabled(false); + ui->pB_magnetic_field_map->setEnabled(false); ui->pB_magnetic_field_plugin->setEnabled(false); ui->lE_fixed_MF->setEnabled(true); @@ -749,11 +775,11 @@ void FSLMainWindow::configure_magnetic_field() else { - magnetic_field_map = (ui->lE_magnetic_field_map->text()).toStdString(); + // magnetic_field_map = (ui->lE_magnetic_field_map->text()).toStdString(); magnetic_field = ""; ui->lE_fixed_MF->setEnabled(false); - ui->lE_magnetic_field_map->setEnabled(true); + ui->pB_magnetic_field_map->setEnabled(true); ui->pB_magnetic_field_plugin->setEnabled(true); } } @@ -1118,19 +1144,21 @@ void FSLMainWindow::load_configuration() magnetic_field_plugin_file = ""; - ui->lE_magnetic_field_map->clear(); - ui->lE_magnetic_field_map->setEnabled(false); + // ui->lE_magnetic_field_map->clear(); + // ui->lE_magnetic_field_map->setEnabled(false); + magnetic_field_map = ""; + ui->pB_magnetic_field_map->setEnabled(false); ui->pB_magnetic_field_plugin->setEnabled(false); } else{ - ui->lE_magnetic_field_map->setEnabled(true); + ui->pB_magnetic_field_map->setEnabled(true); ui->pB_magnetic_field_plugin->setEnabled(true); ui->cB_magnetic_field->setCurrentIndex(1); magnetic_field_plugin_file = j_load["Magnetic Field Plugin"]; magnetic_field_map = j_load["Magnetic Field Map"]; - ui->lE_magnetic_field_map->setText(QString::fromUtf8(magnetic_field_map.c_str())); + // ui->lE_magnetic_field_map->setText(QString::fromUtf8(magnetic_field_map.c_str())); magnetic_field = ""; ui->lE_fixed_MF->clear(); @@ -1211,7 +1239,7 @@ void FSLMainWindow::load_configuration() } - user_action_model->removeRows(0,user_action_model->rowCount()); + /* user_action_model->removeRows(0,user_action_model->rowCount()); for(const auto& element : j_load["Run Actions"]) { std::string run_file = element; @@ -1266,8 +1294,9 @@ void FSLMainWindow::load_configuration() ui->user_action_table->model()->setData(ui->user_action_table->model()->index(rows,1),q_tracking_file); } + */ - shape_model->removeRows(0,shape_model->rowCount()); + /* shape_model->removeRows(0,shape_model->rowCount()); for(const auto& element : j_load["Shape Extensions"] ) { std::string ele = element; @@ -1275,10 +1304,21 @@ void FSLMainWindow::load_configuration() shape_model->insertRow(shape_model->rowCount()); QModelIndex shape_index = shape_model->index(shape_model->rowCount()-1); shape_model->setData(shape_index, q_element); - } - } + }*/ + + user_action_model->removeRows(0,user_action_model->rowCount()); + for(const auto& element : j_load["User Action Extensions"]) + { + std::string run_file = element; + QString q_run_file = QString::fromUtf8(run_file.c_str()); + int rows = ui->user_action_table->model()->rowCount(); + ui->user_action_table->model()->insertRows(rows,1); + ui->user_action_table->model()->setData(ui->user_action_table->model()->index(rows,0),q_run_file); + } + +} } @@ -1320,19 +1360,19 @@ void FSLMainWindow::create_configuration() j["Magnetic Field Plugin"] = magnetic_field_plugin_file; this->configure_actions(); - j["Run Actions"] = run_actions; - j["Event Actions"] = event_actions; - j["Stepping Actions"] = stepping_actions; - j["Stacking Actions"] = stacking_actions; - j["Tracking Actions"] = tracking_actions; + // j["Run Actions"] = run_actions; + // j["Event Actions"] = event_actions; + // j["Stepping Actions"] = stepping_actions; + // j["Stacking Actions"] = stacking_actions; + // j["Tracking Actions"] = tracking_actions; - // j["User Action Extensions"] = user_action_extensions; + j["User Action Extensions"] = user_action_extensions; this->configure_regions(); j["Regions data"] = regions; - this->configure_shape_ext(); - j["Shape Extensions"] = shape_extensions; + // this->configure_shape_ext(); + // j["Shape Extensions"] = shape_extensions; this->configure_g4ui_command(); j["g4ui_commands"] = g4ui_commands; diff --git a/FSL/src/fsl_mainwindow.h b/FSL/src/fsl_mainwindow.h index aca7f1cd7979f7000f9883779a13fd426075ba2b..cc0b284ef226b2e29bb4ffa37fd8787d3e177afd 100644 --- a/FSL/src/fsl_mainwindow.h +++ b/FSL/src/fsl_mainwindow.h @@ -91,11 +91,11 @@ public: std::string magnetic_field_map = ""; //Parameters associated with the User Actions tab - std::vector<std::string> run_actions; - std::vector<std::string> event_actions; - std::vector<std::string> stepping_actions; - std::vector<std::string> stacking_actions; - std::vector<std::string> tracking_actions; + // std::vector<std::string> run_actions; + // std::vector<std::string> event_actions; + // std::vector<std::string> stepping_actions; + // std::vector<std::string> stacking_actions; + // std::vector<std::string> tracking_actions; std::vector<std::string> user_action_extensions; //Parameters associated with the g4ui commands tab @@ -103,8 +103,8 @@ public: int g4ui_number; //Parameters associated with the shape commands tab - int shape_number; - std::vector<std::string> shape_extensions; + // int shape_number; + // std::vector<std::string> shape_extensions; //Parameters associated with the Region tab std::vector<Region> regions; @@ -145,30 +145,32 @@ public: std::vector<std::string> parse_froot_string(std::string input_froot_string); void configure_regions(); + void add_user_action(); void del_user_action(); void configure_actions(); - void del_shape_ext(); - void add_shape_ext(); - void configure_shape_ext(); + // void del_shape_ext(); + // void add_shape_ext(); + // void configure_shape_ext(); void assign_geom_file(); void assign_pythia_file(); void assign_magnetic_field_plugin_file(); - void assign_shape_ext_file(); + void assign_magnetic_field_map(); + //void assign_shape_ext_file(); - void assign_run_actions_file(); - void assign_event_actions_file(); - void assign_stepping_actions_file(); - void assign_stacking_actions_file(); - void assign_tracking_actions_file(); + // void assign_run_actions_file(); + // void assign_event_actions_file(); + // void assign_stepping_actions_file(); + // void assign_stacking_actions_file(); + // void assign_tracking_actions_file(); - void run_actions_file(); - void event_actions_file(); - void stepping_actions_file(); - void stacking_actions_file(); - void tracking_actions_file(); + // void run_actions_file(); + // void event_actions_file(); + // void stepping_actions_file(); + // void stacking_actions_file(); + // void tracking_actions_file(); void configure_magnetic_field(); @@ -184,7 +186,7 @@ private slots: void catch_error_message(std::string info); void get_sens_det_index(QModelIndex region_index); void get_g4ui_index(QModelIndex g4ui_index); - void get_shape_index(QModelIndex g4ui_index); + // void get_shape_index(QModelIndex g4ui_index); void add_region(std::string region_name, std::string frootLV_names ,double electron_cut , double proton_cut ,double positron_cut , double gamma_cut); @@ -205,7 +207,7 @@ private: Ui::FSLMainWindow *ui; QStringListModel *sens_det_model; QStringListModel *g4ui_model; - QStringListModel *shape_model; + // QStringListModel *shape_model; ConfigRegions *region; QStandardItemModel *region_model; QStandardItemModel *user_action_model; diff --git a/FSL/src/fsl_mainwindow.ui b/FSL/src/fsl_mainwindow.ui index 0907291f77b72515390284ee42ab17c9f0d80f76..cdfe65a92fbf2fa200996073a66a4fbe6c09ad26 100644 --- a/FSL/src/fsl_mainwindow.ui +++ b/FSL/src/fsl_mainwindow.ui @@ -39,7 +39,7 @@ <item row="1" column="0" colspan="2"> <widget class="QTextBrowser" name="tB_view_config"> <property name="textInteractionFlags"> - <set>Qt::NoTextInteraction</set> + <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> </property> </widget> </item> @@ -995,40 +995,48 @@ <property name="title"> <string>Map</string> </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="0" column="1" colspan="2"> - <widget class="QLineEdit" name="lE_magnetic_field_map"/> - </item> - <item row="1" column="0" colspan="2"> - <widget class="QLabel" name="label_21"> + <layout class="QGridLayout" name="gridLayout_3"> + <item row="0" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_7"> + <item> + <widget class="QLabel" name="label_7"> <property name="font"> <font> <pointsize>15</pointsize> </font> </property> <property name="text"> - <string>Magnetic Field Plugin</string> + <string>Magnetic Field Map</string> </property> </widget> </item> - <item row="1" column="2"> - <widget class="QPushButton" name="pB_magnetic_field_plugin"> + <item> + <widget class="QPushButton" name="pB_magnetic_field_map"> <property name="text"> <string>Browse Files</string> </property> </widget> </item> - <item row="0" column="0"> - <widget class="QLabel" name="label_7"> + </layout> + </item> + <item row="1" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_10"> + <item> + <widget class="QLabel" name="label_21"> <property name="font"> <font> <pointsize>15</pointsize> </font> </property> <property name="text"> - <string>Magnetic Field Map</string> + <string>Magnetic Field Plugin</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="pB_magnetic_field_plugin"> + <property name="text"> + <string>Browse Files</string> </property> </widget> </item> @@ -1270,8 +1278,8 @@ <attribute name="title"> <string>User Actions</string> </attribute> - <layout class="QGridLayout" name="gridLayout_6"> - <item row="0" column="0"> + <layout class="QGridLayout" name="gridLayout_4"> + <item row="0" column="1"> <spacer name="horizontalSpacer_2"> <property name="orientation"> <enum>Qt::Horizontal</enum> @@ -1284,7 +1292,7 @@ </property> </spacer> </item> - <item row="0" column="1"> + <item row="0" column="2"> <widget class="QLabel" name="label_25"> <property name="font"> <font> @@ -1296,7 +1304,7 @@ </property> </widget> </item> - <item row="0" column="2"> + <item row="0" column="3"> <spacer name="horizontalSpacer_3"> <property name="orientation"> <enum>Qt::Horizontal</enum> @@ -1309,223 +1317,17 @@ </property> </spacer> </item> - <item row="1" column="0" colspan="5"> - <widget class="QTableView" name="user_action_table"/> - </item> - <item row="2" column="0" rowspan="2" colspan="2"> - <widget class="QGroupBox" name="groupBox"> - <property name="font"> - <font> - <pointsize>15</pointsize> - </font> - </property> - <property name="title"> - <string/> - </property> - <layout class="QGridLayout" name="gridLayout_11"> - <item row="0" column="0"> - <widget class="QLabel" name="label_37"> - <property name="font"> - <font> - <pointsize>16</pointsize> - </font> - </property> - <property name="text"> - <string>Run Actions</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QPushButton" name="pB_run_actions"> - <property name="text"> - <string>Browse Files</string> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QLabel" name="label_38"> - <property name="font"> - <font> - <pointsize>16</pointsize> - </font> - </property> - <property name="text"> - <string>Event Actions</string> - </property> - </widget> - </item> - <item row="0" column="3"> - <widget class="QPushButton" name="pB_event_actions"> - <property name="text"> - <string>Browse Files</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_39"> - <property name="font"> - <font> - <pointsize>16</pointsize> - </font> - </property> - <property name="text"> - <string>Stepping Actions</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QPushButton" name="pB_stepping_actions"> - <property name="text"> - <string>Browse Files</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QLabel" name="label_40"> - <property name="font"> - <font> - <pointsize>16</pointsize> - </font> - </property> - <property name="text"> - <string>Stacking Actions</string> - </property> - </widget> - </item> - <item row="1" column="3"> - <widget class="QPushButton" name="pB_stacking_actions"> - <property name="text"> - <string>Browse Files</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_41"> - <property name="font"> - <font> - <pointsize>16</pointsize> - </font> - </property> - <property name="text"> - <string>Tracking Actions</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QPushButton" name="pB_tracking_actions"> - <property name="text"> - <string>Browse Files</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="2" column="2" rowspan="2"> - <spacer name="verticalSpacer_2"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>225</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="3"> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>144</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="4"> - <widget class="QPushButton" name="pB_del_user_action"> - <property name="text"> - <string>Delete</string> - </property> - </widget> - </item> - <item row="3" column="4"> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>188</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <widget class="QWidget" name="tab"> - <attribute name="title"> - <string>Shape </string> - </attribute> - <layout class="QGridLayout" name="gridLayout_4"> - <item row="0" column="0" colspan="2"> - <spacer name="horizontalSpacer_15"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>387</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="0" column="2"> - <widget class="QLabel" name="label_28"> - <property name="font"> - <font> - <pointsize>16</pointsize> - </font> - </property> - <property name="text"> - <string>Shape Extensions</string> - </property> - </widget> - </item> - <item row="0" column="3"> - <spacer name="horizontalSpacer_16"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>406</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="0" colspan="4"> - <widget class="QListView" name="shape_view"/> - </item> - <item row="2" column="0" rowspan="2"> - <layout class="QHBoxLayout" name="horizontalLayout_7"> + <item row="2" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_12"> <item> - <widget class="QPushButton" name="pB_add_shape_ext_file"> + <widget class="QPushButton" name="pB_add_user_action"> <property name="text"> <string>+</string> </property> </widget> </item> <item> - <widget class="QPushButton" name="pB_del_shape_ext_file"> + <widget class="QPushButton" name="pB_del_user_action"> <property name="text"> <string>−</string> </property> @@ -1533,19 +1335,22 @@ </item> </layout> </item> - <item row="3" column="1" colspan="3"> - <spacer name="horizontalSpacer_10"> + <item row="2" column="1" colspan="3"> + <spacer name="horizontalSpacer_24"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> - <width>546</width> + <width>1077</width> <height>20</height> </size> </property> </spacer> </item> + <item row="1" column="0" colspan="4"> + <widget class="QTableView" name="user_action_table"/> + </item> </layout> </widget> </widget> @@ -1558,7 +1363,7 @@ <x>0</x> <y>0</y> <width>1261</width> - <height>22</height> + <height>24</height> </rect> </property> <widget class="QMenu" name="menuFile"> diff --git a/FullSimLight/CMakeLists.txt b/FullSimLight/CMakeLists.txt index 5d3624d9720ad98eb7cd5aa31560b802950f5cae..5689c483a9f5db8bd814c7bf5930e46e35d48d7e 100644 --- a/FullSimLight/CMakeLists.txt +++ b/FullSimLight/CMakeLists.txt @@ -295,7 +295,12 @@ install( TARGETS FullSimLight install(FILES include/FSLSensitiveDetectorPlugin.h include/MagFieldPlugin.h include/FSLUserActionPlugin.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/FullSimLight + include/FSLUserRunActionPlugin.h + include/FSLUserEventActionPlugin.h + include/FSLUserSteppingActionPlugin.h + include/FSLUserTrackingActionPlugin.h + include/FSLUserStackingActionPlugin.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/FullSimLight COMPONENT Development ) diff --git a/FullSimLight/fullSimLight.cc b/FullSimLight/fullSimLight.cc index 8dd2f4e745980ff19145c36d378558c08a62e73f..f46261ece2401a677c44d4a91cfe238c5321d122 100644 --- a/FullSimLight/fullSimLight.cc +++ b/FullSimLight/fullSimLight.cc @@ -45,6 +45,7 @@ static const std::string fullSimLightShareDir=FULLSIMLIGHTSHAREDIR; static std::string parMacroFileName = fullSimLightShareDir+"/macro.g4"; static bool parIsPerformance = false; +static bool parIsCustomUserActions = false; static G4String geometryFileName ; static std::string parPhysListName = "FTFP_BERT"; static bool parRunOverlapCheck = false; @@ -208,7 +209,18 @@ int main(int argc, char** argv) { if (activateRegions) detector->SetAddRegions(true); // 3. User action - FSLActionInitialization* actInit = new FSLActionInitialization(parIsPerformance); + if(!isBatch && simConfig::fsl.userActions.size()>0) parIsCustomUserActions = true; + + + FSLActionInitialization* actInit = new FSLActionInitialization(parIsPerformance,parIsCustomUserActions); + + if(parIsCustomUserActions){ + actInit->SetActions( + simConfig::fsl.userActions + ); + + } + // set the name of a region in which we are interested to see a very basic simulation // stat e.g. "EMEC" (NOTE: only if the given region can be found and executed in // non-perfomance mode) @@ -243,8 +255,16 @@ int main(int argc, char** argv) { detector->SetGeometryFileName (simConfig::fsl.geometry); runManager->SetUserInitialization(detector); + //parse RegionsData + std::vector<std::string> Regions; + std::vector<std::vector<G4String>> RootLVNames; + std::vector<double> electron_cut; + std::vector<double> proton_cut; + std::vector<double> positron_cut; + std::vector<double> gamma_cut; + for (const auto& element : simConfig::jf["Regions data"]){ // std::cout<<"RegionName: "<<element["RegionName"]<<std::endl; @@ -255,7 +275,15 @@ int main(int argc, char** argv) { // std::cout<<"ProtonCut: "<<element["ProtonCut"]<<std::endl; //actually read the data and save them in a simConfig::regionConfig object (might be useful for the configuration later on) + simConfig::from_json(element, simConfig::rc); + Regions.push_back(simConfig::rc.regionName); + RootLVNames.push_back(simConfig::rc.rootLVNames); + electron_cut.push_back(simConfig::rc.electronCut); + proton_cut.push_back(simConfig::rc.protonCut); + positron_cut.push_back(simConfig::rc.positronCut); + gamma_cut.push_back(simConfig::rc.gammaCut); + // std::cout<<"RegionName: "<<rc.regionName<<std::endl; // std::cout<<"RootLVNames size: "<<rc.rootLVNames.size()<<std::endl; // std::cout<<"GammaCut: "<<rc.gammaCut<<std::endl; @@ -265,19 +293,14 @@ int main(int argc, char** argv) { // std::cout<<"------------------------------------------------"<<std::endl; } + detector->ConfigureRegionsFSL(Regions, RootLVNames, electron_cut, proton_cut, positron_cut, gamma_cut); + for (const auto& element : simConfig::jf["Sensitive Detector Extensions"]){ detector->AddSensitiveDetectorPlugin(element); } - // Set extra user actions: - for (const auto& element : simConfig::jf["User Action Extensions"]){ - GeoPluginLoader<FSLUserActionPlugin> loader; - const FSLUserActionPlugin * plugin = loader.load(element); - runManager->SetUserInitialization(plugin->getUserActionInitialization()); - } - G4bool initialized=false; //parse and apply G4Commands for (G4String element : simConfig::jf["g4ui_commands"]){ diff --git a/FullSimLight/include/FSLActionInitialization.hh b/FullSimLight/include/FSLActionInitialization.hh index 8a072abe578641b73f951cf1d3ce44a70dff0e44..08675e5047380fa180993b5f66410e6a8483ca05 100644 --- a/FullSimLight/include/FSLActionInitialization.hh +++ b/FullSimLight/include/FSLActionInitialization.hh @@ -10,19 +10,29 @@ class FSLActionInitialization : public G4VUserActionInitialization { public: - FSLActionInitialization(bool isperformance=false); + FSLActionInitialization(bool isperformance=false, bool customUserActions = false); ~FSLActionInitialization() override; void BuildForMaster() const override; void Build() const override; void SetPerformanceModeFlag(bool val) { fIsPerformance = val; } - void SetSpecialScoringRegionName(const G4String& rname) { fSpecialScoringRegionName = rname; } - + void SetSpecialScoringRegionName(const G4String& rname) { fSpecialScoringRegionName = rname; } + + void SetActions(std::vector<std::string> &usrActions) + { + userActions = usrActions; + }; + private: GeantinoMapsConfigurator* fGeantinoMapsConfig; bool fIsPerformance; + bool fCustomUserActions; G4String fSpecialScoringRegionName; + + + std::vector<std::string> userActions; + }; diff --git a/FullSimLight/include/FSLConfigurator.hh b/FullSimLight/include/FSLConfigurator.hh index 5bc22fc95382f34468fa721915fa1ee70a8996ef..bc678af605db6c47fcfae46360a3c41da9fa9ce9 100644 --- a/FullSimLight/include/FSLConfigurator.hh +++ b/FullSimLight/include/FSLConfigurator.hh @@ -33,7 +33,7 @@ namespace simConfig { struct regionConfig { std::string regionName; - std::vector<std::string> rootLVNames; + std::vector<G4String> rootLVNames; double gammaCut; double electronCut; double positronCut; @@ -61,11 +61,8 @@ struct fslConfig{ std::string magFieldMap; std::string magFieldPlugin; - std::vector<std::string> runActions; - std::vector<std::string> eventActions; - std::vector<std::string> steppingActions; - std::vector<std::string> stackingActions; - std::vector<std::string> trackingActions; + std::vector<std::string> userActions; + std::vector<std::string> g4UiCommands; }; @@ -75,7 +72,7 @@ regionConfig rc; json jf; inline void to_json(json& j, const fslConfig& p) { - j = json{{"Geometry", p.geometry},{"Physics list name", p.physicsList},{"Number of events", p.nEvents},{"Magnetic Field Intensity", p.magFieldIntensity},{"Generator", p.eventGeneratorName},{"Event input file", p.eventInputFile},{"Type of event", p.typeOfEvent},{"Sensitive Detector Extensions", p.sensitiveDetectors},{"Output Hits file", p.outputHitsFile},{"Output Histo file", p.outputHistoFile},{"Magnetic Field Type", p.magFieldType},{"Magnetic Field Map", p.magFieldMap},{"Magnetic Field Plugin", p.magFieldPlugin},{"Run Actions", p.runActions},{"Event Actions", p.eventActions},{"Stepping Actions", p.steppingActions},{"Stacking Actions", p.stackingActions},{"Tracking Actions", p.trackingActions},{"g4ui_commands", p.g4UiCommands}}; + j = json{{"Geometry", p.geometry},{"Physics list name", p.physicsList},{"Number of events", p.nEvents},{"Magnetic Field Intensity", p.magFieldIntensity},{"Generator", p.eventGeneratorName},{"Event input file", p.eventInputFile},{"Type of event", p.typeOfEvent},{"Sensitive Detector Extensions", p.sensitiveDetectors},{"Output Hits file", p.outputHitsFile},{"Output Histo file", p.outputHistoFile},{"Magnetic Field Type", p.magFieldType},{"Magnetic Field Map", p.magFieldMap},{"Magnetic Field Plugin", p.magFieldPlugin},{"User Action Extensions", p.userActions},{"g4ui_commands", p.g4UiCommands}}; } inline void to_json(json& j, const regionConfig& r) { @@ -95,18 +92,15 @@ inline void from_json(const json& j, fslConfig& p) { p.outputHistoFile=j.at("Output Histo file").get<std::string>(); p.magFieldMap=j.at("Magnetic Field Map").get<std::string>(); p.magFieldPlugin=j.at("Magnetic Field Plugin").get<std::string>(); - p.runActions=j.at("Run Actions").get<std::vector<std::string>>(); - p.eventActions=j.at("Event Actions").get<std::vector<std::string>>(); - p.steppingActions=j.at("Stepping Actions").get<std::vector<std::string>>(); - p.stackingActions=j.at("Stacking Actions").get<std::vector<std::string>>(); - p.trackingActions=j.at("Tracking Actions").get<std::vector<std::string>>(); + p.userActions=j.at("User Action Extensions").get<std::vector<std::string>>(); + p.g4UiCommands=j.at("g4ui_commands").get<std::vector<std::string>>(); } inline void from_json(const json& j, regionConfig& r) { r.regionName=j.at("RegionName").get<std::string>(); - r.rootLVNames=j.at("RootLVNames").get<std::vector<std::string>>(); + r.rootLVNames=j.at("RootLVNames").get<std::vector<G4String>>(); r.gammaCut=j.at("GammaCut").get<double>(); r.electronCut=j.at("ElectronCut").get<double>(); r.positronCut=j.at("PositronCut").get<double>(); @@ -121,8 +115,6 @@ auto parse_json_file(std::string config_file_name) //read and store the configuration into the fslConfig struct simConfig::from_json(jf, fsl); - - } diff --git a/FullSimLight/include/FSLDetectorConstruction.hh b/FullSimLight/include/FSLDetectorConstruction.hh index ce05d528f28dc9970cecd1a7dc4f6e4228735f02..cdc727f3d504a05af38fa79a6b853230f0e36231 100644 --- a/FullSimLight/include/FSLDetectorConstruction.hh +++ b/FullSimLight/include/FSLDetectorConstruction.hh @@ -65,6 +65,22 @@ public: } void AddSensitiveDetectorPlugin(const std::string & SDPluginName) { sensitiveDetectorPluginName.push_back(SDPluginName);} + + void ConfigureRegionsFSL(std::vector<std::string> reg, + std::vector<std::vector<G4String>> root_lv_names, + std::vector<double> ele_cut, + std::vector<double> pro_cut, + std::vector<double> pos_cut, + std::vector<double> gam_cut) + { + Regions = reg; + RootLVNames = root_lv_names; + electron_cut = ele_cut; + proton_cut = pro_cut; + positron_cut = pos_cut; + gamma_cut = gam_cut; + } + static G4double GetFieldValue() { return gFieldValue; } G4double GetTolerance (){return fTolerance;} @@ -103,8 +119,14 @@ private: std::vector<std::string> sensitiveDetectorPluginName; - + //Regions Data + std::vector<std::string> Regions; + std::vector<std::vector<G4String>> RootLVNames; + std::vector<double> electron_cut; + std::vector<double> proton_cut; + std::vector<double> positron_cut; + std::vector<double> gamma_cut; }; diff --git a/FullSimLight/include/FSLUserActionPlugin.h b/FullSimLight/include/FSLUserActionPlugin.h index 603cfbde872e6e9f8af3d0fd7b9e5f68479ee0c2..729c260e5acc3d98af8bf29b3cab2abcc6cbf3a2 100644 --- a/FullSimLight/include/FSLUserActionPlugin.h +++ b/FullSimLight/include/FSLUserActionPlugin.h @@ -1,6 +1,11 @@ #ifndef _FSLUSERACTIONPLUGIN_H_ #define _FSLUSERACTIONPLUGIN_H_ -class G4VUserActionInitialization; +class G4UserEventAction; +class G4UserRunAction; +class G4UserSteppingAction; +class G4UserTrackingAction; +class G4UserStackingAction; + class FSLUserActionPlugin { public: @@ -11,13 +16,20 @@ class FSLUserActionPlugin { // Destructor virtual ~FSLUserActionPlugin()=default; - virtual G4VUserActionInitialization *getUserActionInitialization() const=0; + // Typically a user action may inherit one or more of the five action + // types. These routines should be overriden for each one. + virtual G4UserEventAction *getEventAction() const { return nullptr;} + virtual G4UserRunAction *getRunAction() const { return nullptr;} + virtual G4UserSteppingAction *getSteppingAction() const { return nullptr;} + virtual G4UserTrackingAction *getTrackingAction() const { return nullptr;} + virtual G4UserStackingAction *getStackingAction() const { return nullptr;} + private: FSLUserActionPlugin (const FSLUserActionPlugin &)=delete; - FSLUserActionPlugin & operator=(const FSLUserActionPlugin &)=delete; + }; diff --git a/FullSimLight/include/FSLUserEventActionPlugin.h b/FullSimLight/include/FSLUserEventActionPlugin.h new file mode 100644 index 0000000000000000000000000000000000000000..6e115304e7282cac93bdb1588e761cfd7ce11fd3 --- /dev/null +++ b/FullSimLight/include/FSLUserEventActionPlugin.h @@ -0,0 +1,24 @@ +#ifndef _FSLUSEREVENTACTIONPLUGIN_H_ +#define _FSLUSEREVENTACTIONPLUGIN_H_ +class G4UserEventAction; +class FSLUserEventActionPlugin { + + public: + + // Constructor + FSLUserEventActionPlugin()=default; + + // Destructor + virtual ~FSLUserEventActionPlugin()=default; + + virtual G4UserEventAction *getUserEventAction() const=0; + + private: + + FSLUserEventActionPlugin (const FSLUserEventActionPlugin &)=delete; + + FSLUserEventActionPlugin & operator=(const FSLUserEventActionPlugin &)=delete; +}; + + +#endif diff --git a/FullSimLight/include/FSLUserRunActionPlugin.h b/FullSimLight/include/FSLUserRunActionPlugin.h new file mode 100644 index 0000000000000000000000000000000000000000..e7627e26f57e7f0f2011e0e73fe195c6f4b2027a --- /dev/null +++ b/FullSimLight/include/FSLUserRunActionPlugin.h @@ -0,0 +1,24 @@ +#ifndef _FSLUSERRUNACTIONPLUGIN_H_ +#define _FSLUSERRUNACTIONPLUGIN_H_ +class G4UserRunAction; +class FSLUserRunActionPlugin { + + public: + + // Constructor + FSLUserRunActionPlugin()=default; + + // Destructor + virtual ~FSLUserRunActionPlugin()=default; + + virtual G4UserRunAction *getUserRunAction() const=0; + + private: + + FSLUserRunActionPlugin (const FSLUserRunActionPlugin &)=delete; + + FSLUserRunActionPlugin & operator=(const FSLUserRunActionPlugin &)=delete; +}; + + +#endif diff --git a/FullSimLight/include/FSLUserStackingActionPlugin.h b/FullSimLight/include/FSLUserStackingActionPlugin.h new file mode 100644 index 0000000000000000000000000000000000000000..f0088121b7666468a8a29e8dad2814931353b632 --- /dev/null +++ b/FullSimLight/include/FSLUserStackingActionPlugin.h @@ -0,0 +1,24 @@ +#ifndef _FSLUSERSTACKINGACTIONPLUGIN_H_ +#define _FSLUSERSTACKINGACTIONPLUGIN_H_ +class G4UserStackingAction; +class FSLUserStackingActionPlugin { + + public: + + // Constructor + FSLUserStackingActionPlugin()=default; + + // Destructor + virtual ~FSLUserStackingActionPlugin()=default; + + virtual G4UserStackingAction *getUserStackingAction() const=0; + + private: + + FSLUserStackingActionPlugin (const FSLUserStackingActionPlugin &)=delete; + + FSLUserStackingActionPlugin & operator=(const FSLUserStackingActionPlugin &)=delete; +}; + + +#endif diff --git a/FullSimLight/include/FSLUserSteppingActionPlugin.h b/FullSimLight/include/FSLUserSteppingActionPlugin.h new file mode 100644 index 0000000000000000000000000000000000000000..90292df8d541af5400931f2edcfb44d4d286a149 --- /dev/null +++ b/FullSimLight/include/FSLUserSteppingActionPlugin.h @@ -0,0 +1,24 @@ +#ifndef _FSLUSERSTEPPINGACTIONPLUGIN_H_ +#define _FSLUSERSTEPPINGACTIONPLUGIN_H_ +class G4UserSteppingAction; +class FSLUserSteppingActionPlugin { + + public: + + // Constructor + FSLUserSteppingActionPlugin()=default; + + // Destructor + virtual ~FSLUserSteppingActionPlugin()=default; + + virtual G4UserSteppingAction *getUserSteppingAction() const=0; + + private: + + FSLUserSteppingActionPlugin (const FSLUserSteppingActionPlugin &)=delete; + + FSLUserSteppingActionPlugin & operator=(const FSLUserSteppingActionPlugin &)=delete; +}; + + +#endif diff --git a/FullSimLight/include/FSLUserTrackingActionPlugin.h b/FullSimLight/include/FSLUserTrackingActionPlugin.h new file mode 100644 index 0000000000000000000000000000000000000000..51a8bd0ed51ff73c764878db53c310684b5a9745 --- /dev/null +++ b/FullSimLight/include/FSLUserTrackingActionPlugin.h @@ -0,0 +1,24 @@ +#ifndef _FSLUSERTRACKINGACTIONPLUGIN_H_ +#define _FSLUSERTRACKINGACTIONPLUGIN_H_ +class G4UserTrackingAction; +class FSLUserTrackingActionPlugin { + + public: + + // Constructor + FSLUserTrackingActionPlugin()=default; + + // Destructor + virtual ~FSLUserTrackingActionPlugin()=default; + + virtual G4UserTrackingAction *getUserTrackingAction() const=0; + + private: + + FSLUserTrackingActionPlugin (const FSLUserTrackingActionPlugin &)=delete; + + FSLUserTrackingActionPlugin & operator=(const FSLUserTrackingActionPlugin &)=delete; +}; + + +#endif diff --git a/FullSimLight/include/RegionConfigurator.hh b/FullSimLight/include/RegionConfigurator.hh index 0491f57784f70fd765656708b6621d7b65a5f680..af7b0623fc9aa97671ea1496a2bdf3ef9c9b3706 100644 --- a/FullSimLight/include/RegionConfigurator.hh +++ b/FullSimLight/include/RegionConfigurator.hh @@ -30,7 +30,14 @@ public: RegionConfigurator(const RegionConfigurator&) = delete; RegionConfigurator& operator=(const RegionConfigurator&) = delete; - void CreateRegions(int verbose=0); + void CreateRegions(std::vector<std::string> Regions, + std::vector<std::vector<G4String>> RootLVNames, + std::vector<double> electronCut, + std::vector<double> protonCut, + std::vector<double> positronCut, + std::vector<double> gammaCut, + int verbose=0 + ); private: @@ -45,7 +52,13 @@ private: G4double fProtonCut; }; - void InitRegionData(); + void InitRegionData(std::vector<std::string> Regions, + std::vector<std::vector<G4String>> RootLVNames, + std::vector<double> electronCut, + std::vector<double> protonCut, + std::vector<double> positronCut, + std::vector<double> gammaCut + ); private: diff --git a/FullSimLight/src/FSLActionInitialization.cc b/FullSimLight/src/FSLActionInitialization.cc index ac6c7117e8ad70137b78caff3d79d3b8a459696e..a7a8c9943af116e9dd3971325b54bbb7f4e587a7 100644 --- a/FullSimLight/src/FSLActionInitialization.cc +++ b/FullSimLight/src/FSLActionInitialization.cc @@ -1,12 +1,19 @@ #include "FSLActionInitialization.hh" - +#include "GeoModelKernel/GeoPluginLoader.h" #include "FSLPrimaryGeneratorAction.hh" #include "FSLRunAction.hh" #include "FSLEventAction.hh" #include "FSLSteppingAction.hh" #include "FSLTrackingAction.hh" #include "PythiaPrimaryGeneratorAction.hh" +#include "FSLUserActionPlugin.h" +#include "FSLUserRunActionPlugin.h" +#include "FSLUserEventActionPlugin.h" +#include "FSLUserStackingActionPlugin.h" +#include "FSLUserTrackingActionPlugin.h" +#include "FSLUserSteppingActionPlugin.h" + #include "G4Version.hh" #if G4VERSION_NUMBER>=1040 @@ -22,8 +29,8 @@ //const G4AnalysisManager* FSLActionInitialization::fMasterAnalysisManager = nullptr; -FSLActionInitialization::FSLActionInitialization(bool isperformance) -: G4VUserActionInitialization(), fIsPerformance(isperformance), +FSLActionInitialization::FSLActionInitialization(bool isperformance, bool customuseractions) +: G4VUserActionInitialization(), fIsPerformance(isperformance),fCustomUserActions(customuseractions), fSpecialScoringRegionName("") { fGeantinoMapsConfig = GeantinoMapsConfigurator::getGeantinoMapsConf(); @@ -35,17 +42,29 @@ FSLActionInitialization::~FSLActionInitialization() {} // called in case of MT void FSLActionInitialization::BuildForMaster() const { - FSLRunAction* masterRunAct = new FSLRunAction(); - masterRunAct->SetPerformanceFlag(fIsPerformance); - masterRunAct->SetSpecialScoringRegionName(fSpecialScoringRegionName); - -#if USE_PYTHIA - if (use_pythia()) { - G4String str(get_pythia_config()); - masterRunAct->SetPythiaConfig(str); + //set run action from config file + if(fCustomUserActions){ + for (const std::string & element: userActions) { + GeoPluginLoader<FSLUserActionPlugin> loader; + const FSLUserActionPlugin * plugin = loader.load(element); + if (plugin->getRunAction()) SetUserAction(plugin->getRunAction()); + } + } + else + { + FSLRunAction* masterRunAct = new FSLRunAction(); + masterRunAct->SetPerformanceFlag(fIsPerformance); + masterRunAct->SetSpecialScoringRegionName(fSpecialScoringRegionName); + +#if USE_PYTHIA + if (use_pythia()) { + G4String str(get_pythia_config()); + masterRunAct->SetPythiaConfig(str); + } #endif - SetUserAction(masterRunAct); + SetUserAction(masterRunAct); + } } @@ -81,7 +100,7 @@ void FSLActionInitialization::Build() const { } #endif // do not create Run,Event,Stepping and Tracking actions in case of perfomance mode - if (!fIsPerformance) { + if (!fIsPerformance && !fCustomUserActions) { FSLRunAction* runact = new FSLRunAction(); SetUserAction(runact); runact->SetSpecialScoringRegionName(fSpecialScoringRegionName); @@ -113,4 +132,19 @@ void FSLActionInitialization::Build() const { #endif //MultiEventActions?? TO DO? } + + else if(fCustomUserActions) + { + for (const std::string & element: userActions) { + GeoPluginLoader<FSLUserActionPlugin> loader; + const FSLUserActionPlugin * plugin = loader.load(element); + + if (plugin->getEventAction()) SetUserAction(plugin->getEventAction()); + if (plugin->getRunAction()) SetUserAction(plugin->getRunAction()); + if (plugin->getTrackingAction()) SetUserAction(plugin->getTrackingAction()); + if (plugin->getStackingAction()) SetUserAction(plugin->getStackingAction()); + if (plugin->getSteppingAction()) SetUserAction(plugin->getSteppingAction()); + + } + } } diff --git a/FullSimLight/src/FSLDetectorConstruction.cc b/FullSimLight/src/FSLDetectorConstruction.cc index 04149594f1ae9f31a391511fa31887e48a75fa9c..377126b0d4bb6bc288342d837a52f9f0f62adacf 100644 --- a/FullSimLight/src/FSLDetectorConstruction.cc +++ b/FullSimLight/src/FSLDetectorConstruction.cc @@ -340,9 +340,15 @@ G4VPhysicalVolume *FSLDetectorConstruction::Construct() } // trying to add detector regions with the configurations given in the RegionConfigurator + if(Regions.size()>0) + { + fAddRegions = true; + } + if (fAddRegions) { G4cout << "\n =================== Trying to add detector regions ... ================== \n" << G4endl; - RegionConfigurator::Instance().CreateRegions(1); + RegionConfigurator::Instance().CreateRegions(Regions, RootLVNames, electron_cut, + proton_cut, positron_cut, gamma_cut,1); G4cout << "\n =================== Adding detector regions is DONE! ================== \n" << G4endl; } diff --git a/FullSimLight/src/FSLPrimaryGeneratorAction.cc b/FullSimLight/src/FSLPrimaryGeneratorAction.cc index 041b63a193d19305000785cda2ed386a75367b66..f6bbc0d89a8e1126a6cfcc36f6662e7ce29d2fe0 100644 --- a/FullSimLight/src/FSLPrimaryGeneratorAction.cc +++ b/FullSimLight/src/FSLPrimaryGeneratorAction.cc @@ -144,7 +144,7 @@ void FSLPrimaryGeneratorAction::SetPrimaryName(const G4String& pname) { fPrimaryParticleName = pname; gPrimaryType = fPrimaryParticleName; fIsUserPrimaryType = true; - std::cout<<"Primary name: "<<pname<<std::endl; + //std::cout<<"Primary name: "<<pname<<std::endl; } void FSLPrimaryGeneratorAction::SetPrimaryDirection(const G4ThreeVector &pdir) { diff --git a/FullSimLight/src/RegionConfigurator.cc b/FullSimLight/src/RegionConfigurator.cc index bed030ebaf93ca3af365bf5aa958afaec365224f..4d2dab4c41e70f77c9a2222ca2eee833945f733c 100644 --- a/FullSimLight/src/RegionConfigurator.cc +++ b/FullSimLight/src/RegionConfigurator.cc @@ -13,7 +13,15 @@ RegionConfigurator& RegionConfigurator::Instance() { // loop over all RegionData and create a region for each if any of the listed // root logical volumes can be found -void RegionConfigurator::CreateRegions(int verbose) { +void RegionConfigurator::CreateRegions(std::vector<std::string> Regions, + std::vector<std::vector<G4String>> RootLVNames, + std::vector<double> electronCut, + std::vector<double> protonCut, + std::vector<double> positronCut, + std::vector<double> gammaCut, + int verbose) +{ + InitRegionData(Regions,RootLVNames,electronCut,protonCut,positronCut,gammaCut); std::vector<G4LogicalVolume*>* lvStore = G4LogicalVolumeStore::GetInstance(); std::vector<G4LogicalVolume*> lvList; for(const RegionData& aRegionData: fRegionData) { @@ -69,14 +77,36 @@ void RegionConfigurator::CreateRegions(int verbose) { RegionConfigurator::RegionConfigurator() { - InitRegionData(); + // InitRegionData(); Adding this in the Create Regions Method Instead } -// One regin configuration, taken from Athena by using `G4PhysicsRegionConfigNew.py` -// and `G4GeomtryToolConfig.py` with a configuration setting that can produce regions -// and secondary production thresholds similar to that used in production. -void RegionConfigurator::InitRegionData() { + +void RegionConfigurator::InitRegionData(std::vector<std::string> Regions, + std::vector<std::vector<G4String>> RootLVNames, + std::vector<double> electronCut, + std::vector<double> protonCut, + std::vector<double> positronCut, + std::vector<double> gammaCut + ) +{ + fRegionData.resize(Regions.size()); + for(unsigned int i=0;i<=Regions.size()-1;++i) + { + fRegionData[i].fRegionName = Regions[i]; + fRegionData[i].fGammaCut = gammaCut[i]; + fRegionData[i].fElectronCut = electronCut[i]; + fRegionData[i].fPositronCut = positronCut[i]; + fRegionData[i].fProtonCut = protonCut[i]; + fRegionData[i].fRootLVNames = RootLVNames[i]; + + } + + // One region configuration, taken from Athena by using `G4PhysicsRegionConfigNew.py` + // and `G4GeomtryToolConfig.py` with a configuration setting that can produce regions + // and secondary production thresholds similar to that used in production. + + /* fRegionData.resize(11); // // Region: Pixel @@ -166,4 +196,6 @@ void RegionConfigurator::InitRegionData() { fRegionData[10].fPositronCut = 1.0; fRegionData[10].fProtonCut = 1.0; fRegionData[10].fRootLVNames = {"SensitiveGas"}; + */ + }