diff --git a/fairroot/base/sim/FairDetector.cxx b/fairroot/base/sim/FairDetector.cxx index e8642ca45d..b251d09db5 100644 --- a/fairroot/base/sim/FairDetector.cxx +++ b/fairroot/base/sim/FairDetector.cxx @@ -14,6 +14,7 @@ #include "FairGeoNode.h" // for FairGeoNode #include "FairRootManager.h" +#include "FairRunSim.h" #include "FairVolume.h" // for FairVolume #include // for TFolder @@ -97,7 +98,7 @@ void FairDetector::Initialize() FairGeoNode* fN; TString cutName; TString copysign = "#"; - for (auto aVol : fAllSensitiveVolumes) { + for (auto aVol : FairRunSim::Instance()->fAllSensitiveVolumes) { cutName = aVol->GetName(); Ssiz_t pos = cutName.Index(copysign, 1); if (pos > 1) { diff --git a/fairroot/base/sim/FairMCApplication.cxx b/fairroot/base/sim/FairMCApplication.cxx index 5b64d01a13..1520290bce 100644 --- a/fairroot/base/sim/FairMCApplication.cxx +++ b/fairroot/base/sim/FairMCApplication.cxx @@ -887,7 +887,7 @@ void FairMCApplication::InitGeometry() fMCEventHeader->SetRunID(runId); // Fill sensitive volumes in fVolMap - for (auto fv : FairModule::fAllSensitiveVolumes) { + for (auto fv : fRun->fAllSensitiveVolumes) { if (!fv) { continue; } diff --git a/fairroot/base/sim/FairModule.cxx b/fairroot/base/sim/FairModule.cxx index acf2856efd..cd34d45eea 100644 --- a/fairroot/base/sim/FairModule.cxx +++ b/fairroot/base/sim/FairModule.cxx @@ -20,7 +20,7 @@ #include "FairGeoNode.h" // for FairGeoNode #include "FairGeoParSet.h" // for FairBaseParSet #include "FairMCApplication.h" -#include "FairRun.h" // for FairRun +#include "FairRunSim.h" // for FairRun, FairRunSim #include "FairRuntimeDb.h" // for FairRuntimeDb #include "FairVolume.h" // for FairVolume #include "FairVolumeList.h" // for FairVolumeList @@ -50,8 +50,6 @@ #include #include // for std::ignore -thread_local std::vector FairModule::fAllSensitiveVolumes; - void FairModule::ConstructGeometry() { LOG(warn) @@ -200,11 +198,11 @@ void FairModule::SetGeometryFileName(TString fname, TString) fgeoName = ""; } -void FairModule::RegisterSensitiveVolume(FairVolume& vol) +void FairModule::RegisterSensitiveVolume(FairRunSim& run, FairVolume& vol) { vol.setModId(fModId); vol.SetModule(this); - fAllSensitiveVolumes.push_back(&vol); + run.fAllSensitiveVolumes.push_back(&vol); ++fNbOfSensitiveVol; } @@ -221,7 +219,8 @@ void FairModule::ProcessNodes(TList* nodes) vList = new FairVolumeList(); } - auto rtdb = FairRun::Instance()->GetRuntimeDb(); + auto& run = *(FairRunSim::Instance()); + auto rtdb = run.GetRuntimeDb(); auto par = static_cast(rtdb->getContainer("FairGeoParSet")); TSeqCollection* parNodes = par->GetGeoNodes(); for (auto node : TRangeDynCast(nodes)) { @@ -251,7 +250,7 @@ void FairModule::ProcessNodes(TList* nodes) } if (node->isSensitive() && fActive) { - RegisterSensitiveVolume(*addedVol); + RegisterSensitiveVolume(run, *addedVol); parNodes->AddLast(node); } } @@ -267,7 +266,7 @@ void FairModule::AddSensitiveVolume(TGeoVolume* vol) return; } ++fNbOfVolumes; - RegisterSensitiveVolume(*addedVol); + RegisterSensitiveVolume(*FairRunSim::Instance(), *addedVol); } FairVolume* FairModule::getFairVolume(FairGeoNode* fN) diff --git a/fairroot/base/sim/FairModule.h b/fairroot/base/sim/FairModule.h index 4e4c6180ab..04eb244418 100644 --- a/fairroot/base/sim/FairModule.h +++ b/fairroot/base/sim/FairModule.h @@ -23,12 +23,11 @@ #include // for TList (ptr only), TListIter #include // for TNamed #include // for TObjArray -#include // for TRefArray #include // for TString, operator!= #include #include -#include +class FairRunSim; class FairVolumeList; class FairVolume; @@ -140,8 +139,6 @@ class FairModule : public TNamed static thread_local inline FairVolumeList* vList{nullptr}; //! /**total number of volumes in a simulaion session*/ static thread_local inline Int_t fNbOfVolumes{0}; //! - /**list of all sensitive volumes in a simulaion session*/ - static thread_local std::vector fAllSensitiveVolumes; //! TString fMotherVolumeName{""}; //! /** @@ -159,7 +156,7 @@ class FairModule : public TNamed void ReAssignMediaId(); void swap(FairModule& other) throw(); - void RegisterSensitiveVolume(FairVolume&); + void RegisterSensitiveVolume(FairRunSim& run, FairVolume&); protected: FairModule(const FairModule&); diff --git a/fairroot/base/steer/FairRunSim.h b/fairroot/base/steer/FairRunSim.h index 47f3de63d5..815514efd3 100644 --- a/fairroot/base/steer/FairRunSim.h +++ b/fairroot/base/steer/FairRunSim.h @@ -21,6 +21,7 @@ #include #include #include +#include class FairField; class FairGeoLoader; @@ -28,6 +29,7 @@ class FairMCEventHeader; class FairMesh; class FairModule; class FairPrimaryGenerator; +class FairVolume; /** * \brief Configure the Simulation session @@ -38,6 +40,10 @@ class FairPrimaryGenerator; */ class FairRunSim : public FairRun { + friend class FairModule; + friend class FairDetector; + friend class FairMCApplication; + public: /** default ctor*/ FairRunSim(Bool_t isMaster = kTRUE); @@ -226,6 +232,9 @@ class FairRunSim : public FairRun std::unique_ptr fGeoLoader; //! + /**list of all sensitive volumes in a simulaion session*/ + std::vector fAllSensitiveVolumes; //! + protected: Int_t count{0}; //!< Internal counter FairMCApplication* fApp{nullptr}; //!< Main VMC application