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