FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
run_digi.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_digi(TString mcEngine = "TGeant3", Int_t fileId = 0)
9 {
10  // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug)
11  Int_t iVerbose = 0; // just forget about it, for the moment
12 
13  // Input file (MC events)
14  TString inFile = "pixel_";
15  if (fileId == 0)
16  inFile = inFile + mcEngine + ".mc.root";
17  else
18  inFile = Form("%s%s.mc.f%d.root", inFile.Data(), mcEngine.Data(), fileId);
19 
20  // Parameter file
21  TString parFile = "pixel_";
22  parFile = parFile + mcEngine + ".params.root";
23 
24  // Digitization parameter file
25  TString dir = getenv("VMCWORKDIR");
26  TString tutdir = dir + "/MQ/pixelDetector";
27  TString digParFile = tutdir + "/param/pixel_digi.par";
28 
29  // Output file
30  TString outFile = "pixel_";
31  if (fileId == 0)
32  outFile = outFile + mcEngine + ".digi.root";
33  else
34  outFile = Form("%s%s.digi.f%d.root", outFile.Data(), mcEngine.Data(), fileId);
35 
36  // ----- Timer --------------------------------------------------------
37  TStopwatch timer;
38 
39  // ----- Reconstruction run -------------------------------------------
40  FairRunAna* fRun = new FairRunAna();
41  FairFileSource* fFileSource = new FairFileSource(inFile);
42  fRun->SetSource(fFileSource);
43  fRun->SetSink(new FairRootFileSink(outFile));
44 
45  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
46  FairParRootFileIo* parInput1 = new FairParRootFileIo();
47  parInput1->open(parFile.Data());
48 
49  FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo();
50  parIo1->open(digParFile.Data(), "in");
51 
52  rtdb->setFirstInput(parInput1);
53  rtdb->setSecondInput(parIo1);
54 
55  // ----- TorinoDetector hit producers ---------------------------------
56  PixelDigitize* digiTask = new PixelDigitize();
57  fRun->AddTask(digiTask);
58 
59  fRun->Init();
60 
61  timer.Start();
62  fRun->Run();
63 
64  // ----- Finish -------------------------------------------------------
65 
66  cout << endl << endl;
67 
68  // Extract the maximal used memory an add is as Dart measurement
69  // This line is filtered by CTest and the value send to CDash
70  FairSystemInfo sysInfo;
71  Float_t maxMemory = sysInfo.GetMaxMemory();
72  cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">";
73  cout << maxMemory;
74  cout << "</DartMeasurement>" << endl;
75 
76  timer.Stop();
77  Double_t rtime = timer.RealTime();
78  Double_t ctime = timer.CpuTime();
79 
80  Float_t cpuUsage = ctime / rtime;
81  cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">";
82  cout << cpuUsage;
83  cout << "</DartMeasurement>" << endl;
84 
85  cout << endl << endl;
86  cout << "Output file is " << outFile << endl;
87  cout << "Parameter file is " << parFile << endl;
88  cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl;
89  cout << "Macro finished successfully." << endl;
90 
91  // ------------------------------------------------------------------------
92 }
list of container factories
Definition: FairRuntimeDb.h:24
Bool_t open(const Text_t *fname, const Text_t *status="in")
void Init()
Definition: FairRunAna.cxx:127
Bool_t setSecondInput(FairParIo *)
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 run_digi(TString mcEngine="TGeant3")
Definition: run_digi.C:8
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)
virtual void SetSource(FairSource *tempSource)
Definition: FairRunAna.h:70
Bool_t setFirstInput(FairParIo *)