Skip to content

Commit 850f7aa

Browse files
feat: Start with FairRunSim::ls()
Allow to list the object hierarchy under a FairRunSim.
1 parent bb27f0c commit 850f7aa

17 files changed

Lines changed: 177 additions & 4 deletions

examples/advanced/Tutorial3/macro/run_sim.C

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@
66
* copied verbatim in the file "LICENSE" *
77
********************************************************************************/
88

9+
#if !defined(__CLING__) || defined(__ROOTCLING__)
10+
#include "FairBoxGenerator.h"
11+
#include "FairCave.h"
12+
#include "FairConstField.h"
13+
#include "FairMagnet.h"
14+
#include "FairParRootFileIo.h"
15+
#include "FairPrimaryGenerator.h"
16+
#include "FairRootFileSink.h"
17+
#include "FairRunSim.h"
18+
#include "FairSystemInfo.h"
19+
#include "FairTestDetector.h"
20+
#endif
21+
922
#include <TStopwatch.h>
1023
#include <TString.h>
1124
#include <TSystem.h>
@@ -132,6 +145,7 @@ void run_sim(Int_t nEvents = 100, TString mcEngine = "TGeant4")
132145
run.CreateGeometryFile(geoFile);
133146

134147
// ----- Finish -------------------------------------------------------
148+
run.ls();
135149

136150
cout << endl << endl;
137151

fairroot/base/sim/FairMCApplication.cxx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,3 +1311,20 @@ void FairMCApplication::UndoGeometryModifications()
13111311

13121312
gGeoManager->ClearPhysicalNodes(kFALSE);
13131313
}
1314+
1315+
void FairMCApplication::ls(Option_t* option) const
1316+
{
1317+
TVirtualMCApplication::ls(option);
1318+
TROOT::IncreaseDirLevel();
1319+
if (fMC) {
1320+
fMC->ls(option);
1321+
}
1322+
if (fStack) {
1323+
fStack->ls(option);
1324+
}
1325+
// fTrajFilter->ls(option);
1326+
// fRadLenMan->ls(option);
1327+
// fRadMapMan->ls(option);
1328+
// fRadGridMan->ls(option);
1329+
TROOT::DecreaseDirLevel();
1330+
}

fairroot/base/sim/FairMCApplication.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ class FairMCApplication : public TVirtualMCApplication
233233
*/
234234
auto GetIsMT() { return fMC ? fMC->IsMT() : false; }
235235

236+
void ls(Option_t* option = "") const override;
237+
236238
private:
237239
// methods
238240
Int_t GetIonPdg(Int_t z, Int_t a) const;

fairroot/base/sim/FairPrimaryGenerator.cxx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <TMath.h> // for Sqrt
1919
#include <TObject.h> // for TObject
2020
#include <TParticlePDG.h> // for TParticlePDG
21+
#include <TROOT.h> //
2122
#include <TRandom.h> // for TRandom, gRandom
2223
#include <iostream> // for operator<<, basic_ostream, etc
2324

@@ -63,6 +64,7 @@ FairPrimaryGenerator::FairPrimaryGenerator()
6364
, fEventNr(0)
6465
{
6566
fTargetZ[0] = 0.;
67+
fGenList->SetName("fGenList");
6668
}
6769

6870
FairPrimaryGenerator::FairPrimaryGenerator(const char *name, const char *title)
@@ -101,6 +103,7 @@ FairPrimaryGenerator::FairPrimaryGenerator(const char *name, const char *title)
101103
, fEventNr(0)
102104
{
103105
fTargetZ[0] = 0.;
106+
fGenList->SetName("fGenList");
104107
}
105108

106109
FairPrimaryGenerator::FairPrimaryGenerator(const FairPrimaryGenerator &rhs)
@@ -139,6 +142,7 @@ FairPrimaryGenerator::FairPrimaryGenerator(const FairPrimaryGenerator &rhs)
139142
, fEventNr(rhs.fEventNr)
140143
{
141144
fTargetZ[0] = rhs.fTargetZ[0];
145+
fGenList->SetName("fGenList");
142146
}
143147

144148
Bool_t FairPrimaryGenerator::Init()
@@ -549,3 +553,11 @@ void FairPrimaryGenerator::SmearGausVertexXY(Bool_t flag)
549553
fSmearVertexXY = kFALSE;
550554
}
551555
}
556+
557+
void FairPrimaryGenerator::ls(Option_t* option) const
558+
{
559+
TNamed::ls(option);
560+
TROOT::IncreaseDirLevel();
561+
fGenList->ls();
562+
TROOT::DecreaseDirLevel();
563+
}

fairroot/base/sim/FairPrimaryGenerator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ class FairPrimaryGenerator : public TNamed
158158

159159
Int_t GetTotPrimary() { return fTotPrim; }
160160

161+
void ls(Option_t* option = "") const override;
162+
161163
protected:
162164
/** Copy constructor */
163165
FairPrimaryGenerator(const FairPrimaryGenerator &);

fairroot/base/sink/FairSink.cxx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
#include "FairSink.h"
1616

1717
#include <TFolder.h>
18+
#include <TROOT.h>
1819
#include <TTree.h>
20+
#include <iostream>
1921

2022
FairSink::FairSink()
2123
: fRunId(0)
@@ -28,3 +30,14 @@ FairSink::FairSink(const FairSink& sink)
2830
{}
2931

3032
FairSink::~FairSink() {}
33+
34+
void FairSink::ls(Option_t*) const
35+
{
36+
TROOT::IndentLevel();
37+
std::cout << "OBJ: " << IsA()->GetName() << "\n";
38+
TROOT::IncreaseDirLevel();
39+
if (fOutFolder) {
40+
fOutFolder->ls();
41+
}
42+
TROOT::DecreaseDirLevel();
43+
}

fairroot/base/sink/FairSink.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
@@ -66,6 +66,8 @@ class FairSink
6666

6767
virtual FairSink* CloneSink() = 0;
6868

69+
virtual void ls(Option_t* option = "") const;
70+
6971
protected:
7072
struct TypeAddressPair
7173
{

fairroot/base/steer/FairRun.cxx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,25 @@ void FairRun::SetSource(FairSource* othersource)
259259
fRootManager->SetSource(othersource);
260260
fSource.reset(othersource);
261261
}
262+
263+
void FairRun::ls(Option_t* option) const
264+
{
265+
TNamed::ls(option);
266+
TROOT::IncreaseDirLevel();
267+
fRootManager->ls(option);
268+
fRtdb->ls(option);
269+
if (fSource) {
270+
fSource->ls(option);
271+
}
272+
if (fSink) {
273+
fSink->ls(option);
274+
}
275+
if (fEvtHeader) {
276+
fEvtHeader->ls(option);
277+
}
278+
if (fTask) {
279+
fTask->ls();
280+
}
281+
fLinkManager.ls(option);
282+
TROOT::DecreaseDirLevel();
283+
}

fairroot/base/steer/FairRun.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ class FairRun : public TNamed
204204
FairRootManager& GetRootManager() { return *fRootManager; }
205205
FairRootManager const& GetRootManager() const { return *fRootManager; }
206206

207+
void ls(Option_t* option = "") const override;
208+
207209
private:
208210
FairRun(const FairRun& M);
209211
FairRun& operator=(const FairRun&) { return *this; }

fairroot/base/steer/FairRunSim.cxx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <TList.h> // for TList
3535
#include <TObjString.h> // for TObjString
3636
#include <TObject.h> // for TObject
37+
#include <TROOT.h> //
3738
#include <TRandom.h> // for gRandom
3839
#include <TSystem.h> // for TSystem, gSystem
3940
#include <iostream> // for cout, endl, ostream
@@ -72,6 +73,9 @@ FairRunSim::FairRunSim(Bool_t isMaster)
7273
fginstance = this;
7374
fRunId = 0;
7475
fAna = kFALSE;
76+
fIons->SetName("fIons");
77+
fParticles->SetName("fParticles");
78+
ListOfModules->SetName("ListOfModules");
7579
}
7680
#pragma GCC diagnostic pop
7781

@@ -381,4 +385,32 @@ FairMCEventHeader* FairRunSim::GetMCEventHeader()
381385
return fMCEvHead;
382386
}
383387

388+
void FairRunSim::ls(Option_t* option) const
389+
{
390+
FairRun::ls(option);
391+
TROOT::IncreaseDirLevel();
392+
#pragma GCC diagnostic push
393+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
394+
if (fGen) {
395+
fGen->ls(option);
396+
}
397+
#pragma GCC diagnostic pop
398+
if (fField) {
399+
fField->ls(option);
400+
}
401+
// if (fSimulationConfig) {
402+
// fSimulationConfig->ls(option);
403+
// }
404+
ListOfModules->ls();
405+
fParticles->ls();
406+
fIons->ls();
407+
if (fMCEvHead) {
408+
fMCEvHead->ls(option);
409+
}
410+
if (fApp) {
411+
fApp->ls(option);
412+
}
413+
TROOT::DecreaseDirLevel();
414+
}
415+
384416
TMCThreadLocal FairRunSim* FairRunSim::fginstance = nullptr;

0 commit comments

Comments
 (0)