FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
create_digis_mixed.C
Go to the documentation of this file.
2 {
3 
4  TStopwatch timer;
5  timer.Start();
6 
7  gDebug = 0;
8 
9  TString dir = getenv("VMCWORKDIR");
10  TString tutdir = dir + "/simulation/Tutorial2";
11 
12  TString BGinFile = "./tutorial2_pions.mc_p2.000_t0_n130.bg.root";
13  TString SG1inFile = "./tutorial2_pions.mc_p2.000_t0_n10.sg1.root";
14  TString SG2inFile = "./tutorial2_pions.mc_p2.000_t0_n20.sg2.root";
15 
19  TString parFile = "./tutorial2_pions.params_p2.000_t0_n10.root";
20 
21  TString outFile = "./digis.mix.mc.root";
22 
23  cout << "******************************" << endl;
24  cout << "Background File: " << BGinFile << endl;
25  cout << "First Signal File: " << SG1inFile << endl;
26  cout << "Second signal File: " << SG2inFile << endl;
27  cout << "ParamFile: " << parFile << endl;
28  cout << "OutFile: " << outFile << endl;
29  cout << "******************************" << endl;
30 
31  FairRunAna* fRun = new FairRunAna();
32 
33  //** Create a mixed source and set BG file *//
34  FairMixedSource* fMixedSource = new FairMixedSource(BGinFile.Data(), 0);
35 
36  //** Set first signal file */
37  fMixedSource->AddSignalFile(SG1inFile, 1);
38  //** Set second signal file */
39  fMixedSource->AddSignalFile(SG2inFile, 2);
40 
41  // fMixedSource->UseRunIdFromBG();
42 
43  fMixedSource->UseRunIdfromSG(1);
44 
45  fRun->SetSource(fMixedSource);
46 
47  fRun->SetSink(new FairRootFileSink(outFile));
48 
49  //----- Mix using entries ----------------------------------------
50 
52  // fMixedSource->BGWindowWidthNo(20,1);
54  // fMixedSource->BGWindowWidthNo(30,2);
55 
56  //----- Mix using time ----------------------------------------
57 
59  fMixedSource->SetEventMeanTime(10);
60 
62  fMixedSource->BGWindowWidthTime(100, 1);
64  fMixedSource->BGWindowWidthTime(60, 2);
65 
66  // Init Simulation Parameters from Root File
67  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
69  io1->open(parFile.Data(), "UPDATE");
70 
71  FairParAsciiFileIo* parInput2 = new FairParAsciiFileIo();
72  TString tutDetDigiFile = gSystem->Getenv("VMCWORKDIR");
73  tutDetDigiFile += "/simulation/Tutorial2/parameters/tutdet.digi.par";
74  parInput2->open(tutDetDigiFile.Data(), "in");
75 
76  rtdb->setFirstInput(io1);
77  rtdb->setSecondInput(parInput2);
78 
79  rtdb->print();
80 
81  //** TUt Det Digi Producer **//
82 
83  FairTutorialDet2Digitizer* digi = new FairTutorialDet2Digitizer("tutdet", "tut det task");
84 
85  // add the task
86  fRun->AddTask(digi);
87 
88  fRun->Init();
89 
90  rtdb->getContainer("FairTutorialDet2DigiPar")->print();
91 
92  FairTutorialDet2DigiPar* DigiPar = (FairTutorialDet2DigiPar*)rtdb->getContainer("FairTutorialDet2DigiPar");
93 
94  DigiPar->setChanged();
95  DigiPar->setInputVersion(fRun->GetRunId(), 1);
96  rtdb->setOutput(io1);
97  rtdb->saveOutput();
98  rtdb->print();
99 
100  fRun->Run();
101 
102  // ----- Finish -------------------------------------------------------
103 
104  cout << endl << endl;
105 
106  // Extract the maximal used memory an add is as Dart measurement
107  // This line is filtered by CTest and the value send to CDash
108  FairSystemInfo sysInfo;
109  Float_t maxMemory = sysInfo.GetMaxMemory();
110  cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">";
111  cout << maxMemory;
112  cout << "</DartMeasurement>" << endl;
113 
114  timer.Stop();
115  Double_t rtime = timer.RealTime();
116  Double_t ctime = timer.CpuTime();
117 
118  Float_t cpuUsage = ctime / rtime;
119  cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">";
120  cout << cpuUsage;
121  cout << "</DartMeasurement>" << endl;
122 
123  cout << endl << endl;
124  cout << "Output file is " << outFile << endl;
125  cout << "Parameter file is " << parFile << endl;
126  cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl;
127  cout << "Macro finished successfully." << endl;
128 }
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 UseRunIdfromSG(UInt_t identifier=1)
void setChanged(Bool_t flag=kTRUE)
Definition: FairParSet.h:72
virtual void print()
Definition: FairParSet.cxx:94
Bool_t setSecondInput(FairParIo *)
void create_digis_mixed()
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 AddSignalFile(TString name, UInt_t identifier)
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
void BGWindowWidthTime(Double_t background, UInt_t Signalid)
Bool_t setFirstInput(FairParIo *)
Int_t GetRunId()
Definition: FairRun.h:97
void SetEventMeanTime(Double_t mean)
void saveOutput(void)