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