diff --git a/FSL/src/fsl_mainwindow.cpp b/FSL/src/fsl_mainwindow.cpp index 5ef93ab252d2a9bf103724bd2009de124cd16545..e12b23d630056bb7a33ee2029dd05be7a50db829 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 83f9d3383e9a4d303336390a7f0e52bb3a1fef0f..f46261ece2401a677c44d4a91cfe238c5321d122 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 f5fcae1ce882a87716b5ee77c61e016366fa3a23..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; @@ -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 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/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/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/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"}; + */ + }