FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
create_digis.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  ********************************************************************************/
9 {
10 
11  TStopwatch timer;
12  timer.Start();
13 
14  gDebug = 0;
15 
16  TString dir = getenv("VMCWORKDIR");
17  TString tutdir = dir + "/simulation/Tutorial2";
18 
19  TString inFile = "./tutorial2_pions.mc_p2.000_t0_n10.root";
20  TString parFile = "./tutorial2_pions.params_p2.000_t0_n10.root";
21  TString outFile = "./digis.mc.root";
22 
23  cout << "******************************" << endl;
24  cout << "InFile: " << inFile << endl;
25  cout << "ParamFile: " << parFile << endl;
26  cout << "OutFile: " << outFile << endl;
27  cout << "******************************" << endl;
28 
29  FairRunAna* fRun = new FairRunAna();
30  FairFileSource* fFileSource = new FairFileSource(inFile);
31  fRun->SetSource(fFileSource);
32 
33  fRun->SetSink(new FairRootFileSink(outFile));
34 
35  // Init Simulation Parameters from Root File
36  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
38  io1->open(parFile.Data(), "UPDATE");
39 
40  FairParAsciiFileIo* parInput2 = new FairParAsciiFileIo();
41  TString tutDetDigiFile = gSystem->Getenv("VMCWORKDIR");
42  tutDetDigiFile += "/simulation/Tutorial2/parameters/tutdet.digi.par";
43  parInput2->open(tutDetDigiFile.Data(), "in");
44 
45  rtdb->setFirstInput(io1);
46  rtdb->setSecondInput(parInput2);
47 
48  rtdb->print();
49 
50  //** TUt Det Digi Producer **//
51 
52  FairTutorialDet2Digitizer* digi = new FairTutorialDet2Digitizer("tutdet", "tut det task");
53 
54  // add the task
55  fRun->AddTask(digi);
56  // add another task (to test reading data from in memory branches)
58 
59  fRun->Init();
60 
61  rtdb->getContainer("FairTutorialDet2DigiPar")->print();
62 
63  FairTutorialDet2DigiPar* DigiPar = (FairTutorialDet2DigiPar*)rtdb->getContainer("FairTutorialDet2DigiPar");
64 
65  DigiPar->setChanged();
66  DigiPar->setInputVersion(fRun->GetRunId(), 1);
67  rtdb->setOutput(io1);
68  rtdb->saveOutput();
69  rtdb->print();
70 
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 setChanged(Bool_t flag=kTRUE)
Definition: FairParSet.h:72
virtual void print()
Definition: FairParSet.cxx:94
Bool_t setSecondInput(FairParIo *)
void print(void)
void Run(Int_t NStart=0, Int_t NStop=0)
Definition: FairRunAna.cxx:275
void SetSink(FairSink *tempSink)
Definition: FairRun.h:84
FairParSet * getContainer(const Text_t *)
Float_t GetMaxMemory()
void create_digis()
Definition: create_digis.C:8
void setInputVersion(Int_t v=-1, Int_t i=0)
Definition: FairParSet.h:51
FairRuntimeDb * GetRuntimeDb(void)
Definition: FairRun.h:80
Bool_t setOutput(FairParIo *)
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 *)
Int_t GetRunId()
Definition: FairRun.h:97
void saveOutput(void)