FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
runProp.C
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2019 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 int runProp(std::string propName = "rk")
9 {
10  if (propName != "geane" && propName != "rk") {
11  cout << "Choose either \"geane\" or \"rk\"." << endl;
12  return 1;
13  }
14 
15  TString dir = getenv("VMCWORKDIR");
16 
17  TString tut_geomdir = dir + "/common/geometry";
18  gSystem->Setenv("GEOMPATH", tut_geomdir.Data());
19 
20  TString tut_configdir = dir + "/common/gconfig";
21  gSystem->Setenv("CONFIG_DIR", tut_configdir.Data());
22 
23  // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug)
24  Int_t iVerbose = 0; // just forget about it, for the moment
25 
26  // Input file (MC events)
27  TString inFile = "prop.mc.root";
28 
29  // Parameter file
30  TString parFile = "prop.par.root";
31 
32  // Output file
33  TString outFile = Form("prop.%s.cal.root", propName.data());
34 
35  // ----- Timer --------------------------------------------------------
36  TStopwatch timer;
37 
38  // ----- Reconstruction run -------------------------------------------
39  FairRunAna* fRun = new FairRunAna();
40  fRun->SetSource(new FairFileSource(inFile));
41  fRun->SetSink(new FairRootFileSink(outFile));
42 
43  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
44  FairParRootFileIo* parInput1 = new FairParRootFileIo();
45  parInput1->open(parFile.Data());
46 
47  rtdb->setFirstInput(parInput1);
48 
49  FairConstField* fMagField = new FairConstField();
50  fMagField->SetField(0., 0., 20.); // values are in kG
51  fMagField->SetFieldRegion(-150, 150, -150, 150, -250, 250); // values are in cm (xmin,xmax,ymin,ymax,zmin,zmax)
52  fRun->SetField(fMagField);
53 
54  // ----- Set propagator and run ---------------------------------------
55  if (propName == "geane") {
56  FairGeane* Geane = new FairGeane();
57  fRun->AddTask(Geane);
58  }
59 
60  FairTutPropTr* propTask = new FairTutPropTr();
61  if (propName == "rk") {
62  FairRKPropagator* propagator = new FairRKPropagator(fMagField);
63  propTask->SetPropagator(propagator);
64  }
65  fRun->AddTask(propTask);
66 
67  fRun->Init();
68 
69  if (propName == "geane") {
70  FairGeanePro* GeaneProp = new FairGeanePro();
71  propTask->SetPropagator(GeaneProp);
72  }
73 
74  timer.Start();
75  fRun->Run();
76 
77  // ----- Finish -------------------------------------------------------
78 
79  cout << endl << endl;
80 
81  // Extract the maximal used memory an add is as Dart measurement
82  // This line is filtered by CTest and the value send to CDash
83  FairSystemInfo sysInfo;
84  Float_t maxMemory = sysInfo.GetMaxMemory();
85  cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">";
86  cout << maxMemory;
87  cout << "</DartMeasurement>" << endl;
88 
89  timer.Stop();
90  Double_t rtime = timer.RealTime();
91  Double_t ctime = timer.CpuTime();
92 
93  Float_t cpuUsage = ctime / rtime;
94  cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">";
95  cout << cpuUsage;
96  cout << "</DartMeasurement>" << endl;
97 
98  cout << endl << endl;
99  cout << "Output file is " << outFile << endl;
100  cout << "Parameter file is " << parFile << endl;
101  cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl;
102  cout << "Macro finished successfully." << endl;
103 
104  // ------------------------------------------------------------------------
105  return 0;
106 }
list of container factories
Definition: FairRuntimeDb.h:24
int runProp(std::string propName="rk")
Definition: runProp.C:8
void Init()
Definition: FairRunAna.cxx:127
void SetField(Double_t bX, Double_t bY, Double_t bZ)
void Run(Int_t NStart=0, Int_t NStop=0)
Definition: FairRunAna.cxx:275
void SetSink(FairSink *tempSink)
Definition: FairRun.h:84
Float_t GetMaxMemory()
void SetFieldRegion(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax)
FairRuntimeDb * GetRuntimeDb(void)
Definition: FairRun.h:80
virtual void AddTask(FairTask *t)
Definition: FairRun.cxx:70
Bool_t open(const Text_t *fname, Option_t *option="READ", const Text_t *ftitle="", Int_t compress=1)
void SetPropagator(FairPropagator *prop)
Definition: FairTutPropTr.h:39
virtual void SetSource(FairSource *tempSource)
Definition: FairRunAna.h:70
Bool_t setFirstInput(FairParIo *)
void SetField(FairField *ffield)
Definition: FairRunAna.h:80