forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathO2RunSim.h
More file actions
159 lines (136 loc) · 4.93 KB
/
Copy pathO2RunSim.h
File metadata and controls
159 lines (136 loc) · 4.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
// This file is an adaption of FairRoot::FairRunAna commit a6c5cfbe143d3391e (dev branch)
// created 28.9.2017 by S. Wenzel
#ifndef O2_O2RUNSIM_H
#define O2_O2RUNSIM_H
#include "FairRunSim.h" // for FairRunSim
#include "Rtypes.h" // for Bool_t, Double_t, UInt_t, etc
#include <iostream>
#include "FairBaseParSet.h" // for FairBaseParSet
#include "FairGeoParSet.h" // for FairGeoParSet
#include "FairField.h" // for FairField
#include "FairFileHeader.h" // for FairFileHeader
#include "FairGeoInterface.h" // for FairGeoInterface
#include "FairGeoLoader.h" // for FairGeoLoader
#include <fairlogger/Logger.h> // for FairLogger, MESSAGE_ORIGIN
#include "FairMCEventHeader.h" // for FairMCEventHeader
#include "FairMesh.h" // for FairMesh
#include "FairModule.h" // for FairModule
#include "FairParSet.h" // for FairParSet
#include "FairPrimaryGenerator.h" // for FairPrimaryGenerator
#include "FairRootManager.h" // for FairRootManager
#include "FairRunIdGenerator.h" // for FairRunIdGenerator
#include "FairRuntimeDb.h" // for FairRuntimeDb
#include "FairTask.h" // for FairTask
#include "FairTrajFilter.h" // for FairTrajFilter
#include "TRandom.h"
#include <TObjString.h>
#include <Steer/O2MCApplication.h>
#include <Steer/O2MCApplicationEvalMat.h>
namespace o2
{
namespace steer
{
class O2RunSim : public FairRunSim
{
public:
O2RunSim(bool devicemode, bool evalmat) : FairRunSim(), mDeviceMode(devicemode), mEvalMat(evalmat) {}
~O2RunSim() override = default;
void Init() final
{
LOG(info) << "O2RUNSIM SPECIFIC INIT CALLED";
fRootManager->InitSink();
// original FairRunSim follows
FairGeoLoader* loader = new FairGeoLoader(fLoaderName->Data(), "Geo Loader");
FairGeoInterface* GeoInterFace = loader->getGeoInterface();
GeoInterFace->SetNoOfSets(ListOfModules->GetEntries());
GeoInterFace->setMediaFile(MatFname.Data());
GeoInterFace->readMedia();
if (mDeviceMode) {
fApp = new O2MCApplication("Fair", "The Fair VMC App", ListOfModules, MatFname);
} else {
if (!mEvalMat) {
fApp = new O2MCApplicationBase("Fair", "The Fair VMC App", ListOfModules, MatFname);
} else {
fApp = new O2MCApplicationEvalMat("Fair", "The Fair VMC App", ListOfModules, MatFname);
}
}
fApp->SetGenerator(fGen);
// Add a Generated run ID to the FairRunTimeDb
FairRunIdGenerator genid;
// FairRuntimeDb *rtdb= GetRuntimeDb();
fRunId = genid.generateId();
fRtdb->addRun(fRunId);
fFileHeader->SetRunId(fRunId);
/** This call will create the container if it does not exist*/
FairBaseParSet* par = dynamic_cast<FairBaseParSet*>(fRtdb->getContainer("FairBaseParSet"));
if (par) {
par->SetDetList(GetListOfModules());
par->SetGen(GetPrimaryGenerator());
par->SetBeamMom(fBeamMom);
}
/** This call will create the container if it does not exist*/
FairGeoParSet* geopar = dynamic_cast<FairGeoParSet*>(fRtdb->getContainer("FairGeoParSet"));
if (geopar) {
geopar->SetGeometry(gGeoManager);
}
// Set global Parameter Info
if (fPythiaDecayer) {
fApp->SetPythiaDecayer(fPythiaDecayer);
if (fPythiaDecayerConfig) {
fApp->SetPythiaDecayerConfig(fPythiaDecayerConfig);
}
}
if (fUserDecay) {
fApp->SetUserDecay(fUserDecay);
if (fUserDecayConfig) {
fApp->SetUserDecayConfig(fUserDecayConfig);
}
}
if (fField) {
fField->Init();
}
fApp->SetField(fField);
SetFieldContainer();
TList* containerList = fRtdb->getListOfContainers();
TIter next(containerList);
FairParSet* cont;
TObjArray* ContList = new TObjArray();
while ((cont = dynamic_cast<FairParSet*>(next()))) {
ContList->Add(new TObjString(cont->GetName()));
}
if (par) {
par->SetContListStr(ContList);
par->SetRndSeed(gRandom->GetSeed());
par->setChanged();
par->setInputVersion(fRunId, 1);
}
if (geopar) {
geopar->setChanged();
geopar->setInputVersion(fRunId, 1);
}
fSimSetup();
fApp->InitMC("foo", "bar");
fRootManager->WriteFileHeader(fFileHeader);
}
void Run(int n = 0, int b = 0) final
{
FairRunSim::Run(n, b);
}
private:
bool mDeviceMode{false};
bool mEvalMat{false};
ClassDefOverride(O2RunSim, 0);
};
} // namespace steer
} // namespace o2
#endif //O2_O2RUNANA_H