FairRoot/PandaRoot
runrecoMix.C
Go to the documentation of this file.
1 // Example of Macro showing how to do the mixing of the physical event with
2 // background events.
3 // This is the equivalent of the runreco.C Macro.
4 //
5 // Updated 22.3.2011
6 // Gianluigi Boca
7 {
8  // ========================================================================
9  // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug)
10  Int_t iVerbose = 0;
11  TString MCFile = "MvdStt_Test.root"; // name of the 'normal' MC physics event digi file.
12  TString parFile = "MvdStt_Params.root";// name of the 'normal' MC physics event Param input file.
13  Int_t nEvents = 0;
14  // ---- Load libraries -------------------------------------------------
15  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
16  rootlogon();
17  gSystem->Load("libSttMvdTracking");
18 
19  // ------------------------------------------------------------------------
20  // Output file
21  TString DigiFile = "MvdStt_Test_digi.root" ; // output, digi file;
22  TString outFile = "MvdStt_Test_reco.root"; // output, reco file.
23 
24  std::cout << "MCFile : " << MCFile.Data()<< std::endl;
25  std::cout << "DigiFile: " << DigiFile.Data()<< std::endl;
26  std::cout << "RecoFile: " << outFile.Data()<< std::endl;
27 
28  // ----- Timer --------------------------------------------------------
29  TStopwatch timer;
30  timer.Start();
31  // ------------------------------------------------------------------------
32 
33  // ----- Reconstruction run -------------------------------------------
34  FairRunAna *fRun= new FairRunAna();
35  fRun->SetInputFile(MCFile);
36  fRun->AddFriend(DigiFile);
37  fRun->SetOutputFile(outFile);
38  // ------------------------------------------------------------------------
39 
40 
41 
42  // ----- Parameter database --------------------------------------------
43  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
44  FairParRootFileIo* parInput1 = new FairParRootFileIo(kTRUE);
45  parInput1->open(parFile.Data(),"UPDATE");
46  rtdb->setFirstInput(parInput1);
47 
49 
50 
51 
52 
53 // ----- Default MVD hit producer --------------------------------------------
55  mvdmccls->SetVerbose(iVerbose);
56  fRun->AddTask(mvdmccls);
57 // =========================================================================
58 
59 
60 
61 
62  // =========================================================================
63  //-------------------------- MixBackgroundEvents task ----------------------------------
64 // The following is the task that mixes physics evt and "bkg events". The latter
65 // are already digitized and for them also the MVD hit producer PndMvdClusterTask
66 // must already have been run in the digitization Macro.
68  // here two Background input files are given :
69  // 1) the DIGI file of the bkg, to extract the Stt bkg hits;
70  // 2) the reconstructed bkg file ( necessary for extracting the Mvd bkg hits)
71  // previously produced by the Macro runPreliminaryMvdReco.C (Mix_Generation_reco.root)
72  // The user must change the filenames here obviously!
73  mix->SetInputBkgFilesName("../dpm/MvdStt_Test_digi.root");// Mvd and Stt DPM background file.
74  fRun->AddTask(mix);
75  // =========================================================================
76 
77 
78 
79 // in the following there is an example of Mvd and Stt Pattern Recognition tasks.
80 
81 
82 
83 
84  // =========================================================================
85  // ====== Riemann finder MVD ======
86  // =========================================================================
88  mvdTrackFinder->AddHitBranch("MVDHitsPixelMix");
89  mvdTrackFinder->AddHitBranch("MVDHitsStripMix");
90  mvdTrackFinder->SetVerbose(iVerbose);
91  mvdTrackFinder->SetMaxDist(0.05);
92  fRun->AddTask(mvdTrackFinder);
93  // ----- end MVD Rieman finder --------------------------------------------
94 
95 
96 
97  // Stt TRACK FINDING =======================================================
98  // OUTPUT: PndTrackCand -> STTTrackCand
99 // use the constructor with input :
100 // printout flag (int) , plotting flag (bool), MC comparison flag (bool).
102 
103  PndSttFindTracks* sttFindTracks = new PndSttFindTracks("Track Finder", "FairTask", sttTrackFinder, iVerbose);
104  sttFindTracks->AddHitCollectionName("STTHitMix", "STTPoint");
105  fRun->AddTask(sttFindTracks);
106  // =========================================================================
107 
108 
109 
110  // =========================================================================
111  //-------------------------- stt-mvd task ----------------------------------
112 // use the constructor with input :
113 // printout flag (int) , plotting flag (bool), MC comparison flag (bool).
114  PndSttMvdTracking* sttmvd = new PndSttMvdTracking(0,false,false);
115  sttmvd->SetInputBranchName("STTHitMix","MVDHitsPixelMix","MVDHitsStripMix");
116  fRun->AddTask(sttmvd);
117  // =========================================================================
118 
119 
120 
121 
122 
123 
124  rtdb->setOutput(parInput1);
125  // rtdb->print();
126 
127  // ----- Intialise and run --------------------------------------------
128  fRun->Init();
129 
130  fRun->Run(0,nEvents);
131  // ------------------------------------------------------------------------
132 
133 // SttMvdTracking->WriteHistograms();
134 
135  rtdb->saveOutput();
136  rtdb->print();
137  // ----- Finish -------------------------------------------------------
138  timer.Stop();
139  Double_t rtime = timer.RealTime();
140  Double_t ctime = timer.CpuTime();
141  cout << endl << endl;
142  cout << "Macro finished successfully." << endl;
143  cout << "Output file is " << outFile << endl;
144  cout << "Parameter file is " << parFile << endl;
145  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
146  cout << endl;
147  // ------------------------------------------------------------------------
148 
149 
150 }
TString parFile
Definition: runrecoMix.C:12
PndMvdClusterTask * mvdmccls
Definition: runrecoMix.C:54
TString DigiFile
Definition: runrecoMix.C:21
Double_t rtime
Definition: runrecoMix.C:139
FairRunAna * fRun
Definition: hit_dirc.C:58
FairRuntimeDb * rtdb
Definition: runrecoMix.C:43
Double_t ctime
Definition: runrecoMix.C:140
TString outFile
Definition: runrecoMix.C:22
Double_t
TStopwatch timer
Definition: hit_dirc.C:51
TString MCFile
Definition: runrecoMix.C:11
PndMixBackgroundEvents * mix
Definition: runrecoMix.C:67
PndMvdRiemannTrackFinderTask * mvdTrackFinder
Definition: runrecoMix.C:87
void SetVerbose(Int_t iVerbose)
PndSttFindTracks * sttFindTracks
Definition: runrecoMix.C:103
void SetInputBkgFilesName(char *string1)
PndSttMvdTracking * sttmvd
Definition: runrecoMix.C:114
FairParRootFileIo * parInput1
Definition: runrecoMix.C:44
Int_t iVerbose
PndSttTrackFinderReal * sttTrackFinder
Definition: runrecoMix.C:101
Bool_t kParameterMerged
Definition: runrecoMix.C:48
void AddHitCollectionName(char *hitCollectionName, char *pointCollectionName)
Int_t nEvents
Definition: runrecoMix.C:13