From 203a76933a6f54d154a24622d6d9b4605f93b2da Mon Sep 17 00:00:00 2001 From: Marilena Bandieramonte <marilena.bandieramonte@cern.ch> Date: Tue, 21 Jun 2022 16:54:51 +0200 Subject: [PATCH 01/14] Add UserActions plugins interfaces --- FullSimLight/CMakeLists.txt | 7 +++++- .../include/FSLUserEventActionPlugin.h | 24 +++++++++++++++++++ FullSimLight/include/FSLUserRunActionPlugin.h | 24 +++++++++++++++++++ .../include/FSLUserStackingActionPlugin.h | 24 +++++++++++++++++++ .../include/FSLUserSteppingActionPlugin.h | 24 +++++++++++++++++++ .../include/FSLUserTrackingActionPlugin.h | 24 +++++++++++++++++++ 6 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 FullSimLight/include/FSLUserEventActionPlugin.h create mode 100644 FullSimLight/include/FSLUserRunActionPlugin.h create mode 100644 FullSimLight/include/FSLUserStackingActionPlugin.h create mode 100644 FullSimLight/include/FSLUserSteppingActionPlugin.h create mode 100644 FullSimLight/include/FSLUserTrackingActionPlugin.h diff --git a/FullSimLight/CMakeLists.txt b/FullSimLight/CMakeLists.txt index 5d3624d97..5689c483a 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/include/FSLUserEventActionPlugin.h b/FullSimLight/include/FSLUserEventActionPlugin.h new file mode 100644 index 000000000..6e115304e --- /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 000000000..e7627e26f --- /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 000000000..f0088121b --- /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 000000000..90292df8d --- /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 000000000..51a8bd0ed --- /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 -- GitLab From eaa3a2d9c4bd58c28601fa1db4a73e55dc1c55de Mon Sep 17 00:00:00 2001 From: Raees Khan <rak177@pitt.edu> Date: Tue, 21 Jun 2022 10:57:01 -0400 Subject: [PATCH 02/14] Adding user actions --- FullSimLight/fullSimLight.cc | 8 +++ .../include/FSLActionInitialization.hh | 28 +++++++- FullSimLight/src/FSLActionInitialization.cc | 72 +++++++++++++++++-- 3 files changed, 99 insertions(+), 9 deletions(-) diff --git a/FullSimLight/fullSimLight.cc b/FullSimLight/fullSimLight.cc index 8dd2f4e74..d014d2540 100644 --- a/FullSimLight/fullSimLight.cc +++ b/FullSimLight/fullSimLight.cc @@ -209,6 +209,14 @@ int main(int argc, char** argv) { // 3. User action FSLActionInitialization* actInit = new FSLActionInitialization(parIsPerformance); + actInit->SetActions( + simConfig::jf["Event Actions"], + simConfig::jf["Run Actions"], + simConfig::jf["Tracking Actions"], + simConfig::jf["Stepping Actions"], + simConfig::jf["Stacking Actions"] + ); + // 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) diff --git a/FullSimLight/include/FSLActionInitialization.hh b/FullSimLight/include/FSLActionInitialization.hh index 8a072abe5..0d042396f 100644 --- a/FullSimLight/include/FSLActionInitialization.hh +++ b/FullSimLight/include/FSLActionInitialization.hh @@ -10,19 +10,41 @@ 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> &evtActions, + std::vector<std::string> &rActions, + std::vector<std::string> &trActions, + std::vector<std::string> &steActions, + std::vector<std::string> &staActions) + { + eventActions = evtActions; + runActions = rActions; + trackingActions = trActions; + steppingActions = steActions; + stackingActions = staActions; + }; + private: GeantinoMapsConfigurator* fGeantinoMapsConfig; bool fIsPerformance; + bool fCustomUserActions; G4String fSpecialScoringRegionName; + + + std::vector<std::string> eventActions; + std::vector<std::string> runActions; + std::vector<std::string> trackingActions; + std::vector<std::string> steppingActions; + std::vector<std::string> stackingActions; + }; diff --git a/FullSimLight/src/FSLActionInitialization.cc b/FullSimLight/src/FSLActionInitialization.cc index ac6c7117e..84a51686f 100644 --- a/FullSimLight/src/FSLActionInitialization.cc +++ b/FullSimLight/src/FSLActionInitialization.cc @@ -1,6 +1,6 @@ #include "FSLActionInitialization.hh" - +#include "GeoModelKernel/GeoPluginLoader.h" #include "FSLPrimaryGeneratorAction.hh" #include "FSLRunAction.hh" #include "FSLEventAction.hh" @@ -22,8 +22,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,10 +35,12 @@ FSLActionInitialization::~FSLActionInitialization() {} // called in case of MT void FSLActionInitialization::BuildForMaster() const { - FSLRunAction* masterRunAct = new FSLRunAction(); + if(fCustomUserActions){}/*set run action from config file*/ + else + {FSLRunAction* masterRunAct = new FSLRunAction(); masterRunAct->SetPerformanceFlag(fIsPerformance); masterRunAct->SetSpecialScoringRegionName(fSpecialScoringRegionName); - + #if USE_PYTHIA if (use_pythia()) { G4String str(get_pythia_config()); @@ -47,6 +49,7 @@ void FSLActionInitialization::BuildForMaster() const { #endif SetUserAction(masterRunAct); } +} void FSLActionInitialization::Build() const { @@ -81,7 +84,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 +116,61 @@ void FSLActionInitialization::Build() const { #endif //MultiEventActions?? TO DO? } + + else if(fCustomUserActions) + { + for (const auto& element : runActions) + { + GeoPluginLoader<FSLUserRunActionPlugin> loader; + const FSLUserRunActionPlugin * plugin = loader.load(element); + G4UserRunAction* runAct = plugin->getRunAction(); + SetUserAction(runAct); + + } + + for (const auto& element : eventActions) + { + GeoPluginLoader<FSLUserEventActionPlugin> loader; + const FSLUserEventActionPlugin * plugin = loader.load(element); + G4UserEventAction* evtAct = plugin->getEventAction(); + SetUserAction(evtAct); + + } + + for (const auto& element : steppingActions) + { + GeoPluginLoader<FSLUserSteppingActionPlugin> loader; + const FSLUserSteppingActionPlugin * plugin = loader.load(element); + G4UserSteppingAction* steAct = plugin->getSteppingAction(); + SetUserAction(steAct); + + } + + + for (const auto& element : trackingActions) + { + GeoPluginLoader<FSLUserTrackingActionPlugin> loader; + const FSLUserTrackingActionPlugin * plugin = loader.load(element); + G4UserTrackingAction* traAct = plugin->getTrackingAction(); + SetUserAction(traAct); + + } + + for (const auto& element : stackingActions) + { + GeoPluginLoader<FSLUserStackingActionPlugin> loader; + const FSLUserStackingActionPlugin * plugin = loader.load(element); + G4UserStackingAction* staAct = plugin->getStackingAction(); + SetUserAction(staAct); + + } + + + + + + + + } + } -- GitLab From ef224ce8d4e01ba33fbf52c2e8cfba9b52f57372 Mon Sep 17 00:00:00 2001 From: Raees Khan <rak177@pitt.edu> Date: Tue, 21 Jun 2022 11:08:44 -0400 Subject: [PATCH 03/14] User actions --- FSL/src/fsl_mainwindow.cpp | 2 +- FullSimLight/fullSimLight.cc | 10 +++++----- FullSimLight/src/FSLActionInitialization.cc | 17 ++++++++++++----- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/FSL/src/fsl_mainwindow.cpp b/FSL/src/fsl_mainwindow.cpp index 506601d10..c45b8f522 100644 --- a/FSL/src/fsl_mainwindow.cpp +++ b/FSL/src/fsl_mainwindow.cpp @@ -139,7 +139,7 @@ FSLMainWindow::FSLMainWindow(QWidget *parent) ui->tab->setEnabled(false);//Shape tab (Change name on UI) ui->Region->setEnabled(false); - ui->User_Actions->setEnabled(false); + // ui->User_Actions->setEnabled(false); diff --git a/FullSimLight/fullSimLight.cc b/FullSimLight/fullSimLight.cc index d014d2540..23b9930ff 100644 --- a/FullSimLight/fullSimLight.cc +++ b/FullSimLight/fullSimLight.cc @@ -210,11 +210,11 @@ int main(int argc, char** argv) { // 3. User action FSLActionInitialization* actInit = new FSLActionInitialization(parIsPerformance); actInit->SetActions( - simConfig::jf["Event Actions"], - simConfig::jf["Run Actions"], - simConfig::jf["Tracking Actions"], - simConfig::jf["Stepping Actions"], - simConfig::jf["Stacking Actions"] + simConfig::fsl.eventActions, + simConfig::fsl.runActions, + simConfig::fsl.trackingActions, + simConfig::fsl.steppingActions, + simConfig::fsl.stackingActions ); // set the name of a region in which we are interested to see a very basic simulation diff --git a/FullSimLight/src/FSLActionInitialization.cc b/FullSimLight/src/FSLActionInitialization.cc index 84a51686f..8028853d2 100644 --- a/FullSimLight/src/FSLActionInitialization.cc +++ b/FullSimLight/src/FSLActionInitialization.cc @@ -8,6 +8,13 @@ #include "FSLTrackingAction.hh" #include "PythiaPrimaryGeneratorAction.hh" +#include "FSLUserRunActionPlugin.h" +#include "FSLUserEventActionPlugin.h" +#include "FSLUserStackingActionPlugin.h" +#include "FSLUserTrackingActionPlugin.h" +#include "FSLUserSteppingActionPlugin.h" + + #include "G4Version.hh" #if G4VERSION_NUMBER>=1040 #include "G4MultiRunAction.hh" @@ -123,7 +130,7 @@ void FSLActionInitialization::Build() const { { GeoPluginLoader<FSLUserRunActionPlugin> loader; const FSLUserRunActionPlugin * plugin = loader.load(element); - G4UserRunAction* runAct = plugin->getRunAction(); + G4UserRunAction* runAct = plugin->getUserRunAction(); SetUserAction(runAct); } @@ -132,7 +139,7 @@ void FSLActionInitialization::Build() const { { GeoPluginLoader<FSLUserEventActionPlugin> loader; const FSLUserEventActionPlugin * plugin = loader.load(element); - G4UserEventAction* evtAct = plugin->getEventAction(); + G4UserEventAction* evtAct = plugin->getUserEventAction(); SetUserAction(evtAct); } @@ -141,7 +148,7 @@ void FSLActionInitialization::Build() const { { GeoPluginLoader<FSLUserSteppingActionPlugin> loader; const FSLUserSteppingActionPlugin * plugin = loader.load(element); - G4UserSteppingAction* steAct = plugin->getSteppingAction(); + G4UserSteppingAction* steAct = plugin->getUserSteppingAction(); SetUserAction(steAct); } @@ -151,7 +158,7 @@ void FSLActionInitialization::Build() const { { GeoPluginLoader<FSLUserTrackingActionPlugin> loader; const FSLUserTrackingActionPlugin * plugin = loader.load(element); - G4UserTrackingAction* traAct = plugin->getTrackingAction(); + G4UserTrackingAction* traAct = plugin->getUserTrackingAction(); SetUserAction(traAct); } @@ -160,7 +167,7 @@ void FSLActionInitialization::Build() const { { GeoPluginLoader<FSLUserStackingActionPlugin> loader; const FSLUserStackingActionPlugin * plugin = loader.load(element); - G4UserStackingAction* staAct = plugin->getStackingAction(); + G4UserStackingAction* staAct = plugin->getUserStackingAction(); SetUserAction(staAct); } -- GitLab From 069d141ef4777727de9dcc637734ebf3737972cb Mon Sep 17 00:00:00 2001 From: Raees Khan <rak177@pitt.edu> Date: Tue, 21 Jun 2022 11:31:31 -0400 Subject: [PATCH 04/14] fixing user actions --- FullSimLight/fullSimLight.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/FullSimLight/fullSimLight.cc b/FullSimLight/fullSimLight.cc index 23b9930ff..41e998e11 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,16 @@ int main(int argc, char** argv) { if (activateRegions) detector->SetAddRegions(true); // 3. User action - FSLActionInitialization* actInit = new FSLActionInitialization(parIsPerformance); + if(!isBatch) + { + if(simConfig::fsl.eventActions.size()>0 || simConfig::fsl.runActions.size()>0 || + simConfig::fsl.trackingActions.size()>0 || simConfig::fsl.steppingActions.size()>0 || + simConfig::fsl.stackingActions.size()>0) parIsCustomUserActions = true; + } + + FSLActionInitialization* actInit = new FSLActionInitialization(parIsPerformance,parIsCustomUserActions); + + if(parIsCustomUserActions){ actInit->SetActions( simConfig::fsl.eventActions, simConfig::fsl.runActions, @@ -216,7 +226,9 @@ int main(int argc, char** argv) { simConfig::fsl.steppingActions, simConfig::fsl.stackingActions ); - + + } + // 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) -- GitLab From 19ff663436a62c6a6486919940fb52067236099d Mon Sep 17 00:00:00 2001 From: Raees Khan <rak177@pitt.edu> Date: Thu, 23 Jun 2022 05:35:03 -0400 Subject: [PATCH 05/14] Getting rid of Shape extensions tab and adding mag field map browse button --- FSL/src/fsl_mainwindow.cpp | 53 ++++++++++------- FSL/src/fsl_mainwindow.h | 17 +++--- FSL/src/fsl_mainwindow.ui | 117 ++++++++----------------------------- 3 files changed, 63 insertions(+), 124 deletions(-) diff --git a/FSL/src/fsl_mainwindow.cpp b/FSL/src/fsl_mainwindow.cpp index c45b8f522..a6152abe0 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); @@ -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,8 +81,8 @@ 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); @@ -105,7 +106,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,7 +138,7 @@ FSLMainWindow::FSLMainWindow(QWidget *parent) ui->lE_histo->setEnabled(false); - ui->tab->setEnabled(false);//Shape tab (Change name on UI) + // ui->tab->setEnabled(false);//Shape tab (Change name on UI) ui->Region->setEnabled(false); // ui->User_Actions->setEnabled(false); @@ -151,7 +152,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 +174,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 +229,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 +262,7 @@ void FSLMainWindow::configure_shape_ext() index( i, 0 ).data( Qt::DisplayRole ).toString()).toStdString()); } -} +}*/ //Get index of row in g4ui display when clicked @@ -652,6 +653,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 +745,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 +756,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 +1125,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(); @@ -1267,7 +1276,7 @@ void FSLMainWindow::load_configuration() } - 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,7 +1284,7 @@ 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); - } + }*/ } @@ -1331,8 +1340,8 @@ void FSLMainWindow::create_configuration() 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 aca7f1cd7..7fef95ec7 100644 --- a/FSL/src/fsl_mainwindow.h +++ b/FSL/src/fsl_mainwindow.h @@ -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; @@ -149,14 +149,15 @@ public: 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(); @@ -184,7 +185,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 +206,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 0907291f7..38ef789c5 100644 --- a/FSL/src/fsl_mainwindow.ui +++ b/FSL/src/fsl_mainwindow.ui @@ -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> @@ -1469,85 +1477,6 @@ </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> - <widget class="QPushButton" name="pB_add_shape_ext_file"> - <property name="text"> - <string>+</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="pB_del_shape_ext_file"> - <property name="text"> - <string>−</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="3" column="1" colspan="3"> - <spacer name="horizontalSpacer_10"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>546</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> </widget> </item> </layout> @@ -1558,7 +1487,7 @@ <x>0</x> <y>0</y> <width>1261</width> - <height>22</height> + <height>24</height> </rect> </property> <widget class="QMenu" name="menuFile"> -- GitLab From 40ba156e0e337b3283647ba90891c0b5e1b46b5f Mon Sep 17 00:00:00 2001 From: atlas <boudreau@pitt.edu> Date: Mon, 27 Jun 2022 12:59:38 +0200 Subject: [PATCH 06/14] user plugin reform --- FullSimLight/fullSimLight.cc | 2 +- FullSimLight/include/FSLUserActionPlugin.h | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/FullSimLight/fullSimLight.cc b/FullSimLight/fullSimLight.cc index 41e998e11..e5a7737c1 100644 --- a/FullSimLight/fullSimLight.cc +++ b/FullSimLight/fullSimLight.cc @@ -295,7 +295,7 @@ int main(int argc, char** argv) { for (const auto& element : simConfig::jf["User Action Extensions"]){ GeoPluginLoader<FSLUserActionPlugin> loader; const FSLUserActionPlugin * plugin = loader.load(element); - runManager->SetUserInitialization(plugin->getUserActionInitialization()); + // runManager->SetUserInitialization(plugin->getUserActionInitialization()); } G4bool initialized=false; diff --git a/FullSimLight/include/FSLUserActionPlugin.h b/FullSimLight/include/FSLUserActionPlugin.h index 603cfbde8..729c260e5 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; + }; -- GitLab From 5c40c4c8e8c2b6f7e40d2202612266e771f416ad Mon Sep 17 00:00:00 2001 From: Raees Khan <rak177@pitt.edu> Date: Mon, 27 Jun 2022 07:57:04 -0400 Subject: [PATCH 07/14] user action changes --- FSL/src/fsl_mainwindow.cpp | 75 +++++--- FSL/src/fsl_mainwindow.h | 33 ++-- FSL/src/fsl_mainwindow.ui | 176 +++--------------- FullSimLight/fullSimLight.cc | 14 +- .../include/FSLActionInitialization.hh | 18 +- FullSimLight/include/FSLConfigurator.hh | 6 +- FullSimLight/src/FSLActionInitialization.cc | 48 ----- 7 files changed, 107 insertions(+), 263 deletions(-) diff --git a/FSL/src/fsl_mainwindow.cpp b/FSL/src/fsl_mainwindow.cpp index a6152abe0..f0f07fb8a 100644 --- a/FSL/src/fsl_mainwindow.cpp +++ b/FSL/src/fsl_mainwindow.cpp @@ -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); @@ -85,11 +85,12 @@ FSLMainWindow::FSLMainWindow(QWidget *parent) // 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); @@ -442,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() { @@ -511,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() @@ -526,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); } @@ -562,6 +578,9 @@ void FSLMainWindow::configure_actions() { tracking_actions.push_back(associated_file); } + */ + + user_action_extensions.push_back(associated_file); } @@ -1220,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; @@ -1275,6 +1294,7 @@ 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()); for(const auto& element : j_load["Shape Extensions"] ) @@ -1285,9 +1305,20 @@ void FSLMainWindow::load_configuration() 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); + } +} } @@ -1329,13 +1360,13 @@ 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; diff --git a/FSL/src/fsl_mainwindow.h b/FSL/src/fsl_mainwindow.h index 7fef95ec7..cc0b284ef 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 @@ -145,6 +145,7 @@ 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(); @@ -159,17 +160,17 @@ public: 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 run_actions_file(); - void event_actions_file(); - void stepping_actions_file(); - void stacking_actions_file(); - void 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 configure_magnetic_field(); diff --git a/FSL/src/fsl_mainwindow.ui b/FSL/src/fsl_mainwindow.ui index 38ef789c5..b2b042003 100644 --- a/FSL/src/fsl_mainwindow.ui +++ b/FSL/src/fsl_mainwindow.ui @@ -1278,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> @@ -1292,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> @@ -1304,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> @@ -1317,163 +1317,39 @@ </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 row="2" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_12"> + <item> + <widget class="QPushButton" name="pB_add_user_action"> + <property name="text"> + <string>+</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="pB_del_user_action"> + <property name="text"> + <string>−</string> + </property> + </widget> + </item> + </layout> </item> - <item row="2" column="3"> - <spacer name="horizontalSpacer"> + <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>144</width> + <width>1077</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 row="1" column="0" colspan="4"> + <widget class="QTableView" name="user_action_table"/> </item> </layout> </widget> diff --git a/FullSimLight/fullSimLight.cc b/FullSimLight/fullSimLight.cc index e5a7737c1..3d80abab7 100644 --- a/FullSimLight/fullSimLight.cc +++ b/FullSimLight/fullSimLight.cc @@ -209,22 +209,14 @@ int main(int argc, char** argv) { if (activateRegions) detector->SetAddRegions(true); // 3. User action - if(!isBatch) - { - if(simConfig::fsl.eventActions.size()>0 || simConfig::fsl.runActions.size()>0 || - simConfig::fsl.trackingActions.size()>0 || simConfig::fsl.steppingActions.size()>0 || - simConfig::fsl.stackingActions.size()>0) parIsCustomUserActions = true; - } + if(!isBatch && simConfig::fsl.userActions.size()>0) parIsCustomUserActions = true; + FSLActionInitialization* actInit = new FSLActionInitialization(parIsPerformance,parIsCustomUserActions); if(parIsCustomUserActions){ actInit->SetActions( - simConfig::fsl.eventActions, - simConfig::fsl.runActions, - simConfig::fsl.trackingActions, - simConfig::fsl.steppingActions, - simConfig::fsl.stackingActions + simConfig::fsl.userActions ); } diff --git a/FullSimLight/include/FSLActionInitialization.hh b/FullSimLight/include/FSLActionInitialization.hh index 0d042396f..a0de04222 100644 --- a/FullSimLight/include/FSLActionInitialization.hh +++ b/FullSimLight/include/FSLActionInitialization.hh @@ -19,17 +19,9 @@ public: void SetPerformanceModeFlag(bool val) { fIsPerformance = val; } void SetSpecialScoringRegionName(const G4String& rname) { fSpecialScoringRegionName = rname; } - void SetActions(std::vector<std::string> &evtActions, - std::vector<std::string> &rActions, - std::vector<std::string> &trActions, - std::vector<std::string> &steActions, - std::vector<std::string> &staActions) + void SetActions(std::vector<std::string> &usrActions) { - eventActions = evtActions; - runActions = rActions; - trackingActions = trActions; - steppingActions = steActions; - stackingActions = staActions; + userActions = usrActions; }; private: @@ -39,11 +31,7 @@ private: G4String fSpecialScoringRegionName; - std::vector<std::string> eventActions; - std::vector<std::string> runActions; - std::vector<std::string> trackingActions; - std::vector<std::string> steppingActions; - std::vector<std::string> stackingActions; + std::vector<std::string> userActions; diff --git a/FullSimLight/include/FSLConfigurator.hh b/FullSimLight/include/FSLConfigurator.hh index 5bc22fc95..150f673b5 100644 --- a/FullSimLight/include/FSLConfigurator.hh +++ b/FullSimLight/include/FSLConfigurator.hh @@ -66,6 +66,8 @@ struct fslConfig{ 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 +77,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},{"Run Actions", p.runActions},{"Event Actions", p.eventActions},{"Stepping Actions", p.steppingActions},{"Stacking Actions", p.stackingActions},{"Tracking Actions", p.trackingActions},{"User Action Extensions", p.userActions},{"g4ui_commands", p.g4UiCommands}}; } inline void to_json(json& j, const regionConfig& r) { @@ -100,6 +102,8 @@ inline void from_json(const json& j, fslConfig& p) { 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>>(); } diff --git a/FullSimLight/src/FSLActionInitialization.cc b/FullSimLight/src/FSLActionInitialization.cc index 8028853d2..4476321e4 100644 --- a/FullSimLight/src/FSLActionInitialization.cc +++ b/FullSimLight/src/FSLActionInitialization.cc @@ -126,54 +126,6 @@ void FSLActionInitialization::Build() const { else if(fCustomUserActions) { - for (const auto& element : runActions) - { - GeoPluginLoader<FSLUserRunActionPlugin> loader; - const FSLUserRunActionPlugin * plugin = loader.load(element); - G4UserRunAction* runAct = plugin->getUserRunAction(); - SetUserAction(runAct); - - } - - for (const auto& element : eventActions) - { - GeoPluginLoader<FSLUserEventActionPlugin> loader; - const FSLUserEventActionPlugin * plugin = loader.load(element); - G4UserEventAction* evtAct = plugin->getUserEventAction(); - SetUserAction(evtAct); - - } - - for (const auto& element : steppingActions) - { - GeoPluginLoader<FSLUserSteppingActionPlugin> loader; - const FSLUserSteppingActionPlugin * plugin = loader.load(element); - G4UserSteppingAction* steAct = plugin->getUserSteppingAction(); - SetUserAction(steAct); - - } - - - for (const auto& element : trackingActions) - { - GeoPluginLoader<FSLUserTrackingActionPlugin> loader; - const FSLUserTrackingActionPlugin * plugin = loader.load(element); - G4UserTrackingAction* traAct = plugin->getUserTrackingAction(); - SetUserAction(traAct); - - } - - for (const auto& element : stackingActions) - { - GeoPluginLoader<FSLUserStackingActionPlugin> loader; - const FSLUserStackingActionPlugin * plugin = loader.load(element); - G4UserStackingAction* staAct = plugin->getUserStackingAction(); - SetUserAction(staAct); - - } - - - -- GitLab From bb8b6d6e126ac3d36d028f792a2d6a08c8e2e5b3 Mon Sep 17 00:00:00 2001 From: atlas <boudreau@pitt.edu> Date: Mon, 27 Jun 2022 14:12:41 +0200 Subject: [PATCH 08/14] Universal action bundle implemented in fullSimLight and fsl --- FullSimLight/fullSimLight.cc | 7 ------- FullSimLight/include/FSLActionInitialization.hh | 2 +- FullSimLight/src/FSLActionInitialization.cc | 16 +++++++++++----- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/FullSimLight/fullSimLight.cc b/FullSimLight/fullSimLight.cc index 3d80abab7..83f9d3383 100644 --- a/FullSimLight/fullSimLight.cc +++ b/FullSimLight/fullSimLight.cc @@ -283,13 +283,6 @@ int main(int argc, char** argv) { } - // 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 a0de04222..08675e504 100644 --- a/FullSimLight/include/FSLActionInitialization.hh +++ b/FullSimLight/include/FSLActionInitialization.hh @@ -31,7 +31,7 @@ private: G4String fSpecialScoringRegionName; - std::vector<std::string> userActions; + std::vector<std::string> userActions; diff --git a/FullSimLight/src/FSLActionInitialization.cc b/FullSimLight/src/FSLActionInitialization.cc index 4476321e4..443eeca8e 100644 --- a/FullSimLight/src/FSLActionInitialization.cc +++ b/FullSimLight/src/FSLActionInitialization.cc @@ -7,7 +7,7 @@ #include "FSLSteppingAction.hh" #include "FSLTrackingAction.hh" #include "PythiaPrimaryGeneratorAction.hh" - +#include "FSLUserActionPlugin.h" #include "FSLUserRunActionPlugin.h" #include "FSLUserEventActionPlugin.h" #include "FSLUserStackingActionPlugin.h" @@ -126,10 +126,16 @@ void FSLActionInitialization::Build() const { 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()); + + } } - } -- GitLab From 9a5df1693de249f0335e4d608c7050d302507233 Mon Sep 17 00:00:00 2001 From: atlas <boudreau@pitt.edu> Date: Mon, 27 Jun 2022 15:08:55 +0200 Subject: [PATCH 09/14] bugfix --- FullSimLight/include/FSLConfigurator.hh | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/FullSimLight/include/FSLConfigurator.hh b/FullSimLight/include/FSLConfigurator.hh index 150f673b5..f5fcae1ce 100644 --- a/FullSimLight/include/FSLConfigurator.hh +++ b/FullSimLight/include/FSLConfigurator.hh @@ -61,11 +61,6 @@ 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; @@ -77,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},{"User Action Extensions", p.userActions},{"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) { @@ -97,11 +92,6 @@ 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>>(); -- GitLab From 9df6e52bcd54099f2753335747b1708ad2c79bfe Mon Sep 17 00:00:00 2001 From: Raees Khan <rak177@pitt.edu> Date: Tue, 28 Jun 2022 06:48:00 -0400 Subject: [PATCH 10/14] Removing lines causing excessive Verbosity --- FSL/src/fsl_mainwindow.cpp | 2 +- FullSimLight/src/FSLPrimaryGeneratorAction.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/FSL/src/fsl_mainwindow.cpp b/FSL/src/fsl_mainwindow.cpp index f0f07fb8a..5ef93ab25 100644 --- a/FSL/src/fsl_mainwindow.cpp +++ b/FSL/src/fsl_mainwindow.cpp @@ -356,7 +356,7 @@ void FSLMainWindow::configure_g4ui_command() } - g4ui_commands.push_back("/process/list"); + // g4ui_commands.push_back("/process/list"); diff --git a/FullSimLight/src/FSLPrimaryGeneratorAction.cc b/FullSimLight/src/FSLPrimaryGeneratorAction.cc index 041b63a19..f6bbc0d89 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) { -- GitLab From a3dc8a27d5bf16fedfcdde2c0822676a1c00ccd3 Mon Sep 17 00:00:00 2001 From: Raees Khan <rak177@pitt.edu> Date: Thu, 30 Jun 2022 10:58:44 -0400 Subject: [PATCH 11/14] Allowing for Regions configuration from FSL --- FSL/src/fsl_mainwindow.cpp | 2 +- FullSimLight/fullSimLight.cc | 18 ++++++++ FullSimLight/include/FSLConfigurator.hh | 6 +-- .../include/FSLDetectorConstruction.hh | 24 +++++++++- FullSimLight/include/RegionConfigurator.hh | 17 ++++++- FullSimLight/src/FSLDetectorConstruction.cc | 8 +++- FullSimLight/src/RegionConfigurator.cc | 44 ++++++++++++++++--- 7 files changed, 104 insertions(+), 15 deletions(-) diff --git a/FSL/src/fsl_mainwindow.cpp b/FSL/src/fsl_mainwindow.cpp index 5ef93ab25..e12b23d63 100644 --- a/FSL/src/fsl_mainwindow.cpp +++ b/FSL/src/fsl_mainwindow.cpp @@ -140,7 +140,7 @@ FSLMainWindow::FSLMainWindow(QWidget *parent) // ui->tab->setEnabled(false);//Shape tab (Change name on UI) - ui->Region->setEnabled(false); + // ui->Region->setEnabled(false); // ui->User_Actions->setEnabled(false); diff --git a/FullSimLight/fullSimLight.cc b/FullSimLight/fullSimLight.cc index 83f9d3383..f46261ece 100644 --- a/FullSimLight/fullSimLight.cc +++ b/FullSimLight/fullSimLight.cc @@ -255,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; @@ -267,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; @@ -277,6 +293,8 @@ 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); diff --git a/FullSimLight/include/FSLConfigurator.hh b/FullSimLight/include/FSLConfigurator.hh index f5fcae1ce..bc678af60 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; @@ -100,7 +100,7 @@ inline void from_json(const json& j, fslConfig& p) { 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>(); @@ -115,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 ce05d528f..cdc727f3d 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/RegionConfigurator.hh b/FullSimLight/include/RegionConfigurator.hh index 0491f5778..af7b0623f 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/FSLDetectorConstruction.cc b/FullSimLight/src/FSLDetectorConstruction.cc index 04149594f..377126b0d 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/RegionConfigurator.cc b/FullSimLight/src/RegionConfigurator.cc index bed030eba..4d2dab4c4 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"}; + */ + } -- GitLab From 7756a1257f060be2a4c28ccb9e8d5759c557f574 Mon Sep 17 00:00:00 2001 From: Raees Khan <rak177@pitt.edu> Date: Fri, 1 Jul 2022 09:18:54 -0400 Subject: [PATCH 12/14] Making text in FSL viewer selectable --- FSL/src/fsl_mainwindow.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FSL/src/fsl_mainwindow.ui b/FSL/src/fsl_mainwindow.ui index b2b042003..cdfe65a92 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> -- GitLab From 64c9bc06da9f0620b0c5cbeb363db72d2b159766 Mon Sep 17 00:00:00 2001 From: Raees Khan <rak177@pitt.edu> Date: Mon, 4 Jul 2022 17:40:27 -0400 Subject: [PATCH 13/14] Adding units of GeV to cuts in Regions table --- FSL/src/configregions.ui | 10 +++++----- FSL/src/fsl_mainwindow.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/FSL/src/configregions.ui b/FSL/src/configregions.ui index bfb56197a..024730178 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 e12b23d63..dfa18d7ea 100644 --- a/FSL/src/fsl_mainwindow.cpp +++ b/FSL/src/fsl_mainwindow.cpp @@ -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); -- GitLab From efa2cca740d6d67608af0ba6389303a99fa8bb1c Mon Sep 17 00:00:00 2001 From: Marilena Bandieramonte <marilena.bandieramonte@cern.ch> Date: Wed, 6 Jul 2022 16:29:59 +0200 Subject: [PATCH 14/14] Correctly set the user run action for the master in case of MT execution --- FullSimLight/src/FSLActionInitialization.cc | 31 +++++++++++++-------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/FullSimLight/src/FSLActionInitialization.cc b/FullSimLight/src/FSLActionInitialization.cc index 443eeca8e..a7a8c9943 100644 --- a/FullSimLight/src/FSLActionInitialization.cc +++ b/FullSimLight/src/FSLActionInitialization.cc @@ -42,20 +42,29 @@ FSLActionInitialization::~FSLActionInitialization() {} // called in case of MT void FSLActionInitialization::BuildForMaster() const { - if(fCustomUserActions){}/*set run action from config file*/ + //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); - + { + FSLRunAction* masterRunAct = new FSLRunAction(); + masterRunAct->SetPerformanceFlag(fIsPerformance); + masterRunAct->SetSpecialScoringRegionName(fSpecialScoringRegionName); + #if USE_PYTHIA - if (use_pythia()) { - G4String str(get_pythia_config()); - masterRunAct->SetPythiaConfig(str); - } + if (use_pythia()) { + G4String str(get_pythia_config()); + masterRunAct->SetPythiaConfig(str); + } #endif - SetUserAction(masterRunAct); -} + SetUserAction(masterRunAct); + } } -- GitLab