3 #include "FairBaseParSet.h" 4 #include "FairGeoParSet.h" 6 #include "FairFileHeader.h" 7 #include "FairGeoInterface.h" 8 #include "FairGeoLoader.h" 10 #include "FairMCEventHeader.h" 12 #include "FairModule.h" 13 #include "FairParSet.h" 14 #include "FairPrimaryGenerator.h" 15 #include "FairRootManager.h" 16 #include "FairRunIdGenerator.h" 17 #include "FairRuntimeDb.h" 19 #include "FairTrajFilter.h" 22 #include "TCollection.h" 23 #include "TGeoManager.h" 25 #include "TObjString.h" 56 std::cout <<
"============== FairRunSim: Initialising simulation run ==============" << std::endl;
58 FairGeoLoader* loader=
new FairGeoLoader(fLoaderName->Data(),
"Geo Loader");
59 FairGeoInterface* GeoInterFace=loader->getGeoInterface();
60 GeoInterFace->SetNoOfSets(ListOfModules->GetEntries());
61 GeoInterFace->setMediaFile(MatFname.Data());
62 GeoInterFace->readMedia();
66 fApp=
new ERMCApplication(
"Fair",
"The Fair VMC App",ListOfModules, MatFname);
67 fApp->SetGenerator(fGen);
70 FairRunIdGenerator genid;
72 fRunId = genid.generateId();
73 fRtdb->addRun(fRunId);
75 fFileHeader->SetRunId(fRunId);
79 FairBaseParSet* par=
dynamic_cast<FairBaseParSet*
>(fRtdb->getContainer(
"FairBaseParSet"));
81 par->SetDetList(GetListOfModules());
82 par->SetGen(GetPrimaryGenerator());
83 par->SetBeamMom(fBeamMom);
86 FairGeoParSet* geopar=
dynamic_cast<FairGeoParSet*
>(fRtdb->getContainer(
"FairGeoParSet"));
88 geopar->SetGeometry(gGeoManager);
94 fApp->SetPythiaDecayer(fPythiaDecayer);
95 if (fPythiaDecayerConfig) {
96 fApp->SetPythiaDecayerConfig(fPythiaDecayerConfig);
100 fApp->SetUserDecay(fUserDecay);
101 if (fUserDecayConfig) {
102 fApp->SetUserDecayConfig(fUserDecayConfig);
107 std::cout <<
"Create visualisation manager " << std::endl;
108 new FairTrajFilter();
111 fApp->SetRadiationLengthReg(fRadLength);
114 fApp->SetRadiationMapReg(fRadMap);
117 fApp->AddMeshList(fMeshList);
120 fApp->SetField(fField);
123 TList* containerList=fRtdb->getListOfContainers();
124 TIter next(containerList);
126 TObjArray* ContList=
new TObjArray();
127 while ((cont=dynamic_cast<FairParSet*>(next()))) {
128 ContList->Add(
new TObjString(cont->GetName()));
131 par->SetContListStr(ContList);
133 par->setInputVersion(fRunId,1);
135 geopar->setChanged();
136 geopar->setInputVersion(fRunId,1);
140 fRootManager->WriteFileHeader(fFileHeader);
144 if (!fDecayer->Init())
145 Fatal(
"ERRunSim::Init",
"Decayer init problem");
156 TString work = getenv(
"VMCWORKDIR");
157 TString work_config=work+
"/gconfig/";
158 work_config.ReplaceAll(
"//",
"/");
160 TString Lib_config= getenv(
"GEANT4VMC_MACRO_DIR");
161 Lib_config.ReplaceAll(
"//",
"/");
162 if (!Lib_config.EndsWith(
"/")) { Lib_config+=
"/"; }
164 TString config_dir= getenv(
"CONFIG_DIR");
165 config_dir.ReplaceAll(
"//",
"/");
167 Bool_t AbsPath=kFALSE;
172 TString cuts=fUserCuts;
174 if(strcmp(GetName(),
"TGeant4") == 0 ) {
175 TString g4LibMacro=
"g4libs.C";
177 if(fUserConfig.IsNull()) {
178 g4Macro=
"g4Config.C";
179 fUserConfig = g4Macro;
181 if (fUserConfig.Contains(
"/")) { AbsPath=kTRUE; }
182 g4Macro = fUserConfig;
183 std::cout <<
"---------------User config is used: " 184 << g4Macro.Data() << std::endl;
186 if (TString(gSystem->FindFile(config_dir.Data(),g4LibMacro)) != TString(
"")) {
187 std::cout <<
"---User path for Configuration (g4libs.C) is used: " 188 << config_dir.Data() << std::endl;
190 g4LibMacro=Lib_config+
"g4libs.C";
193 LibFunction=
"g4libs()";
194 if (!AbsPath && TString(gSystem->FindFile(config_dir.Data(),g4Macro)) != TString(
"")) {
195 std::cout <<
"---User path for Configuration (g4Config.C) is used: " 196 << config_dir.Data() << std::endl;
199 if(AbsPath) { ConfigMacro = fUserConfig; }
200 else { ConfigMacro =work_config+fUserConfig; }
203 }
else if(strcmp(GetName(),
"TGeant3") == 0 ) {
204 TString g3LibMacro=
"g3libs.C";
205 TString g3Macro=
"g3Config.C";
206 if(fUserConfig.IsNull()) {
207 g3Macro=
"g3Config.C";
208 fUserConfig = g3Macro;
209 std::cout <<
"-------------- Standard Config is called ------------------------------------" << std::endl;
211 if (fUserConfig.Contains(
"/")) { AbsPath=kTRUE; }
212 g3Macro = fUserConfig;
213 std::cout <<
"---------------User config is used: " 214 << g3Macro.Data() << std::endl;
216 if (TString(gSystem->FindFile(config_dir.Data(),g3LibMacro)) != TString(
"")) {
217 std::cout <<
"---User path for Configuration (g3libs.C) is used: " 218 << config_dir.Data() << std::endl;
220 g3LibMacro=work_config+
"g3libs.C";
223 LibFunction=
"g3libs()";
224 if (!AbsPath && TString(gSystem->FindFile(config_dir.Data(),g3Macro)) != TString(
"")) {
225 std::cout <<
"---User path for Configuration (g3Config.C) is used: " 226 << config_dir.Data() << std::endl;
229 if(AbsPath) { ConfigMacro = fUserConfig; }
230 else { ConfigMacro =work_config+fUserConfig; }
233 }
else if(strcmp(GetName(),
"TFluka") == 0 ) {
234 TString flLibMacro=
"fllibs.C";
235 TString flMacro=
"flConfig.C";
236 if(fUserConfig.IsNull()) {
237 flMacro=
"flConfig.C";
240 if (fUserConfig.Contains(
"/")) { AbsPath=kTRUE; }
241 flMacro = fUserConfig;
242 std::cout <<
"---------------User config is used: " 243 << flMacro.Data() << std::endl;
245 if (TString(gSystem->FindFile(config_dir.Data(), flLibMacro)) != TString(
"")) {
246 std::cout <<
"---User path for Configuration (fllibs.C) is used: " 247 << config_dir.Data() << std::endl;
249 flLibMacro=work_config+
"fllibs.C";
252 LibFunction=
"fllibs()";
253 if (!AbsPath && TString(gSystem->FindFile(config_dir.Data(),flMacro)) != TString(
"")) {
254 std::cout <<
"---User path for Configuration (flConfig.C) is used: " 255 << config_dir.Data() << std::endl;
258 if(AbsPath) { ConfigMacro = fUserConfig; }
259 else { ConfigMacro =work_config+fUserConfig; }
263 if (TString(gSystem->FindFile(config_dir.Data(),cuts)) != TString(
"")) {
264 std::cout <<
"---User path for Cuts and Processes (SetCuts.C) is used: " 265 << config_dir.Data() << std::endl;
267 cuts =work_config+ fUserCuts;
270 gROOT->LoadMacro(LibMacro.Data());
271 gROOT->ProcessLine(LibFunction.Data());
273 gROOT->LoadMacro(ConfigMacro.Data());
274 gROOT->ProcessLine(
"Config()");
276 gROOT->LoadMacro(cuts);
277 gROOT->ProcessLine(
"SetCuts()");
ERRunSim(Bool_t isMaster=kTRUE)