Skip to content

Commit 5268bc9

Browse files
ChristianTackeGSIkarabowi
authored andcommitted
refactor(Base): Move GetRootManager to FairModule
... and simplify by using the already existing `fRunSim`.
1 parent 7dfdc9d commit 5268bc9

4 files changed

Lines changed: 14 additions & 21 deletions

File tree

fairroot/base/sim/FairDetector.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -105,25 +105,7 @@ class FairDetector : public FairModule
105105
void SaveGeoParams();
106106
Int_t GetDetId() { return fDetId; }
107107

108-
/**
109-
* \brief For internal use: Set the manager
110-
*
111-
* \note Usually called from FairMCApplication::RegisterOutput()
112-
*/
113-
void SetRootManager(FairRootManager* rm) { fRootManager = rm; }
114-
115108
protected:
116-
/**
117-
* \brief Get the FairRootManager for this Detector
118-
*
119-
* \note Only valid during \ref Initialize() and Register()
120-
*/
121-
FairRootManager& GetRootManager()
122-
{
123-
assert(fRootManager);
124-
return *fRootManager;
125-
}
126-
127109
/** Copy constructor */
128110
FairDetector(const FairDetector&);
129111
/** Assignment operator */
@@ -134,8 +116,6 @@ class FairDetector : public FairModule
134116
Int_t fDetId; // Detector Id has to be set from ctr.
135117

136118
private:
137-
FairRootManager* fRootManager{nullptr}; //!
138-
139119
ClassDefOverride(FairDetector, 1);
140120
};
141121
#endif // FAIRDETECTOR_H

fairroot/base/sim/FairMCApplication.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ FairMCApplication::FairMCApplication(const FairMCApplication& rhs, std::unique_p
177177
auto& clone = fOwnedModules.emplace_back(module->CloneModule());
178178
fListModules.emplace_back(clone.get());
179179
fModules->Add(clone.get());
180+
clone->SetRunSim(fRun);
180181
}
181182

182183
// Create and fill a list of active detectors
@@ -943,7 +944,6 @@ void FairMCApplication::RegisterOutput()
943944
}
944945
if (detector) {
945946
// check whether detector is active
946-
detector->SetRootManager(fRootManager);
947947
if (detector->IsActive()) {
948948
detector->Initialize();
949949
detector->Register();

fairroot/base/sim/FairModule.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ void FairModule::Streamer(TBuffer& b)
159159
}
160160
}
161161

162+
FairRootManager& FairModule::GetRootManager()
163+
{
164+
assert(fRunSim);
165+
return fRunSim->GetRootManager();
166+
}
167+
162168
FairGeoLoader& FairModule::GetGeometryLoader()
163169
{
164170
assert(fRunSim);

fairroot/base/sim/FairModule.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@ class FairModule : public TNamed
188188
Bool_t fGeoSaved{kFALSE}; //! flag for initialisation
189189
TVirtualMC* fMC{nullptr}; //! cahed pointer to MC (available only after initialization)
190190

191+
/**
192+
* \brief Get the FairRootManager for this Module
193+
*
194+
* \note Only valid after being added to a FairRunSim
195+
*/
196+
FairRootManager& GetRootManager();
197+
191198
/**
192199
* \brief Get Geometry Loader
193200
* \note Only valid during ConstructGeometry

0 commit comments

Comments
 (0)