FairRoot/PandaRoot
runLumi4KalmanFitter.C
Go to the documentation of this file.
1 int runLumi4KalmanFitter(const int nEvents=100000, const int startEvent=0, TString storePath="tmpOutput", const int verboseLevel=0, const int senstype=0, const bool mergedHits=false, TString trkRep="GEANE", double scaleP=1, double scaleM=1)
2 {
3  // ========================================================================
4  // Input file (MC events)
5  TString MCFile = storePath+"/Lumi_MC_";
6  MCFile += startEvent;
7  MCFile += ".root";
8  TString DigiFile = storePath+"/Lumi_digi_";
9  DigiFile += startEvent;
10  DigiFile += ".root";
11  // Digi file
13  if(senstype>0 && mergedHits) RecoFile +="/Lumi_recoMerged_";
14  else RecoFile +="/Lumi_reco_";
15  RecoFile += startEvent;
16  RecoFile += ".root";
17  // TCand file
18  TString CandFile = storePath+"/Lumi_TCand_";
19  CandFile += startEvent;
20  CandFile += ".root";
21  // Parameter file
22  TString parFile = storePath+"/Lumi_Params_";
23  parFile += startEvent;
24  parFile += ".root";
25 
26  // ---- Load libraries -------------------------------------------------
27  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
28  gSystem->Load("libSds");
29  gSystem->Load("libSdsReco");
30  gSystem->Load("libLmd");
31  gSystem->Load("libLmdReco");
32  gSystem->Load("libLmdTrk");
33  // ------------------------------------------------------------------------
34  // Output file
35  TString outFile = storePath+"/Lumi_Track_";
36  outFile += startEvent;
37  outFile += ".root";
38 
39  // TString outFile = storePath+"/Lumi_Geane_";
40  // outFile += startEvent;
41  // outFile += ".root";
42 
43  std::cout << "MCFile : " << MCFile.Data()<< std::endl;
44  std::cout << "DigiFile: " << DigiFile.Data()<< std::endl;
45  std::cout << "RecoFile: " << RecoFile.Data()<< std::endl;
46  std::cout << "TCandFile: " << CandFile.Data()<< std::endl;
47  // std::cout << "GFTrackFile: " << gfTrkFile.Data()<< std::endl;
48  // std::cout << "(GFfitted+BackPropagation)TrackFile: " << outFile.Data()<< std::endl;
49  std::cout << "TrackFile: " << outFile.Data()<< std::endl;
50 
51  // --- Now choose concrete engines for the different tasks -------------
52  // ------------------------------------------------------------------------
53 
54 
55  // In general, the following parts need not be touched
56  // ========================================================================
57 
58  // ----- Timer --------------------------------------------------------
59  TStopwatch timer;
60  timer.Start();
61  // ------------------------------------------------------------------------
62 
63 
64  // ----- Reconstruction run -------------------------------------------
65  FairRunAna *fRun= new FairRunAna();
66  fRun->SetInputFile(MCFile);
67  fRun->AddFriend(DigiFile);
68  fRun->AddFriend(RecoFile);
69  fRun->AddFriend(CandFile);
70  fRun->SetOutputFile(outFile);
71  // ------------------------------------------------------------------------
72 
73  // ----- Prepare GEANE --------------------------------------------
74  // this will load Geant3 and execute setup macros to initialize geometry:
75  FairGeane *Geane = new FairGeane();
76  fRun->AddTask(Geane);
77  // ------------------------------------------------------------------------
78 
79  // ----- Parameter database --------------------------------------------
80  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
81  FairParRootFileIo* parInput1 = new FairParRootFileIo(kTRUE);
82  parInput1->open(parFile.Data(),"UPDATE");
83  rtdb->setFirstInput(parInput1);
84 
85 
86  // =========================================================================
87  // ====== Track fitter ======
88  // =========================================================================
89  TString HitNames,TrackNames;
90  TrackNames = "LMDTrackCand";
91  if(senstype>0){
92  if(mergedHits)
93  HitNames = "LMDHitsMerged";
94  else HitNames = "LMDHitsPixel";
95  }
96  else HitNames = "LMDHitsStrip";
97 
98  PndLmdKalmanTask* lmdkalmanfitter = new PndLmdKalmanTask(HitNames, TrackNames);
99  lmdkalmanfitter->SetVerbose(verboseLevel);
100  lmdkalmanfitter->SetScalePError(scaleP);
101  lmdkalmanfitter->SetScaleMError(scaleM);
102  if(trkRep=="GEANE"){
103  lmdkalmanfitter->SetGeaneTrkRep();
104  }
105  else{
106  if(trkRep=="RK"){
107  lmdkalmanfitter->SetRKTrkRep();
108  }
109  else{
110  cout<<"Please, set correct track representation for Kalman Filter task (GEANE or Runge-Kutta). "<<trkRep.Data()<<" is none of them!"<<endl;
111  }
112  }
113  fRun->AddTask(lmdkalmanfitter);
114 
115  rtdb->setOutput(parInput1);
116  rtdb->print();
117  // ===== End of Track fitter =====
118  // =========================================================================
119 
120 
121  // ----- Intialise and run --------------------------------------------
122  fRun->Init();
123 
124  fRun->Run(0,nEvents);
125  cout<<"fRun->Run(0, "<<nEvents<<") was done!"<<endl;
126  // ------------------------------------------------------------------------
127 
128  rtdb->saveOutput();
129  rtdb->print();
130  // ----- Finish -------------------------------------------------------
131  timer.Stop();
132  Double_t rtime = timer.RealTime();
133  Double_t ctime = timer.CpuTime();
134  cout << endl << endl;
135  cout << "Macro finished succesfully." << endl;
136  cout << "Output file is " << outFile << endl;
137  cout << "Parameter file is " << parFile << endl;
138  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
139  cout << endl;
140  // ------------------------------------------------------------------------
141 
142 
143  return 0;
144 }
int verboseLevel
Definition: Lars/runMvdSim.C:7
TString RecoFile
TString outFile
Definition: hit_dirc.C:17
Int_t startEvent
TString storePath
void SetGeaneTrkRep(Bool_t val=kTRUE)
FairGeane * Geane
FairRunAna * fRun
Definition: hit_dirc.C:58
TString DigiFile
Double_t
TString parFile
Definition: hit_dirc.C:14
void SetRKTrkRep(Bool_t val=kTRUE)
Int_t nEvents
Definition: hit_dirc.C:11
TStopwatch timer
Definition: hit_dirc.C:51
void SetScalePError(double sc)
void SetScaleMError(double sc)
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
FairParRootFileIo * parInput1
Definition: hit_dirc.C:67
Double_t ctime
Definition: hit_dirc.C:114
int runLumi4KalmanFitter(const int nEvents=100000, const int startEvent=0, TString storePath="tmpOutput", const int verboseLevel=0, const int senstype=0, const bool mergedHits=false, TString trkRep="GEANE", double scaleP=1, double scaleM=1)
TString MCFile
Double_t rtime
Definition: hit_dirc.C:113