FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
run_tutorial1_urqmd.C
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 void run_tutorial1_urqmd(Int_t nEvents = 2, TString mcEngine = "TGeant3")
9 {
10 
11  TString dir = getenv("VMCWORKDIR");
12  TString tutdir = dir + "/simulation//Tutorial1";
13 
14  TString inFile = dir + "/common/input/urqmd.ftn14";
15 
16  TString Urqmd_Conversion_table = dir + "/common/input/urqmd_pdg.dat";
17 
18  TString tut_geomdir = dir + "/common/geometry";
19  gSystem->Setenv("GEOMPATH", tut_geomdir.Data());
20 
21  TString tut_configdir = dir + "/common/gconfig";
22  gSystem->Setenv("CONFIG_DIR", tut_configdir.Data());
23 
24  TString outDir = "./";
25 
26  // Output file name
27  TString outFile = Form("%s/tutorial1_urqmd_%s.mc.root", outDir.Data(), mcEngine.Data());
28 
29  // Parameter file name
30  TString parFile = Form("%s/tutorial1_urqmd_%s.params.root", outDir.Data(), mcEngine.Data());
31 
32  TString geoFile = outDir + "geofile_urqmd_" + mcEngine + "_full.root";
33 
34  // In general, the following parts need not be touched
35  // ========================================================================
36 
37  // ---- Debug option -------------------------------------------------
38  gDebug = 0;
39  // ------------------------------------------------------------------------
40 
41  // ----- Timer --------------------------------------------------------
42  TStopwatch timer;
43  timer.Start();
44  // ------------------------------------------------------------------------
45 
46  // ----- Create simulation run ----------------------------------------
47  FairRunSim* run = new FairRunSim();
48  run->SetName(mcEngine); // Transport engine
49  run->SetSink(new FairRootFileSink(outFile)); // Output file
50  FairRuntimeDb* rtdb = run->GetRuntimeDb();
51  // ------------------------------------------------------------------------
52 
53  // ----- Create media -------------------------------------------------
54  run->SetMaterials("media.geo"); // Materials
55  // ------------------------------------------------------------------------
56 
57  // ----- Create geometry ----------------------------------------------
58 
59  FairModule* cave = new FairCave("CAVE");
60  cave->SetGeometryFileName("cave_vacuum.geo");
61  run->AddModule(cave);
62 
63  FairDetector* tutdet = new FairTutorialDet1("TUTDET", kTRUE);
64  tutdet->SetGeometryFileName("double_sector.geo");
65  run->AddModule(tutdet);
66  // ------------------------------------------------------------------------
67 
68  // ----- Create PrimaryGenerator --------------------------------------
70 
71  FairUrqmdGenerator* urqmdGen = new FairUrqmdGenerator(inFile.Data(), Urqmd_Conversion_table.Data());
72  primGen->AddGenerator(urqmdGen);
73 
74  run->SetGenerator(primGen);
75  // ------------------------------------------------------------------------
76 
77  // ----- Initialize simulation run ------------------------------------
78  run->Init();
79  // ------------------------------------------------------------------------
80 
81  // ----- Runtime database ---------------------------------------------
82 
83  Bool_t kParameterMerged = kTRUE;
84  FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged);
85  parOut->open(parFile.Data());
86  rtdb->setOutput(parOut);
87  rtdb->saveOutput();
88  rtdb->print();
89  // ------------------------------------------------------------------------
90 
91  // ----- Start run ----------------------------------------------------
92  run->Run(nEvents);
93  run->CreateGeometryFile(geoFile);
94  // ------------------------------------------------------------------------
95 
96  // ----- Finish -------------------------------------------------------
97 
98  cout << endl << endl;
99 
100  // Extract the maximal used memory an add is as Dart measurement
101  // This line is filtered by CTest and the value send to CDash
102  FairSystemInfo sysInfo;
103  Float_t maxMemory = sysInfo.GetMaxMemory();
104  cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">";
105  cout << maxMemory;
106  cout << "</DartMeasurement>" << endl;
107 
108  timer.Stop();
109  Double_t rtime = timer.RealTime();
110  Double_t ctime = timer.CpuTime();
111 
112  Float_t cpuUsage = ctime / rtime;
113  cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">";
114  cout << cpuUsage;
115  cout << "</DartMeasurement>" << endl;
116 
117  cout << endl << endl;
118  cout << "Output file is " << outFile << endl;
119  cout << "Parameter file is " << parFile << endl;
120  cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl;
121  cout << "Macro finished successfully." << endl;
122 
123  // ------------------------------------------------------------------------
124 }
Bool_t kParameterMerged
virtual void SetGeometryFileName(TString fname, TString geoVer="0")
Definition: FairModule.cxx:199
void CreateGeometryFile(const char *geofile)
Definition: FairRun.cxx:103
list of container factories
Definition: FairRuntimeDb.h:24
void AddGenerator(FairGenerator *generator)
void run_tutorial1_urqmd(Int_t nEvents=2, TString mcEngine="TGeant3")
void SetGenerator(FairPrimaryGenerator *Gen)
Definition: FairRunSim.cxx:310
void print(void)
void SetSink(FairSink *tempSink)
Definition: FairRun.h:84
Float_t GetMaxMemory()
FairParRootFileIo * parOut
virtual void Init()
Definition: FairRunSim.cxx:143
FairRuntimeDb * GetRuntimeDb(void)
Definition: FairRun.h:80
void SetMaterials(const char *MatFileName)
Definition: FairRunSim.cxx:312
Bool_t setOutput(FairParIo *)
Bool_t open(const Text_t *fname, Option_t *option="READ", const Text_t *ftitle="", Int_t compress=1)
virtual void Run(Int_t NEvents=0, Int_t NotUsed=0)
Definition: FairRunSim.cxx:306
void AddModule(FairModule *Mod)
Definition: FairRunSim.cxx:118
void saveOutput(void)