FairRoot/PandaRoot
runLumiPixel4Fitter.C
Go to the documentation of this file.
1 int runLumiPixel4Fitter(const int nEvents = 100000, const int startEvent = 0,
2  TString storePath = "tmpOutput", const int verboseLevel = 0,
3  const TString Method = "KalmanGeane", const bool mergedHits = true,
4  const double radlen = 0.31) {
5  // ========================================================================
7  if (mergedHits)
8  RecoFile += "/Lumi_recoMerged_";
9  else
10  RecoFile += "/Lumi_reco_";
11  RecoFile += startEvent;
12  RecoFile += ".root";
13  // TCand file
14  TString CandFile = storePath + "/Lumi_TCand_";
15  CandFile += startEvent;
16  CandFile += ".root";
17  // Parameter file
18  TString parFile = storePath + "/Lumi_Params_";
19  parFile += startEvent;
20  parFile += ".root";
21 
22  // Output file
23  TString outFile = storePath + "/Lumi_Track_";
24  outFile += startEvent;
25  outFile += ".root";
26 
27  std::cout << "RecoFile: " << RecoFile.Data() << std::endl;
28  std::cout << "TCandFile: " << CandFile.Data() << std::endl;
29  std::cout << "TrackFile: " << outFile.Data() << std::endl;
30 
31  // ----- Timer --------------------------------------------------------
32  TStopwatch timer;
33  timer.Start();
34  // ------------------------------------------------------------------------
35 
36  // ----- Reconstruction run -------------------------------------------
37  FairRunAna *fRun = new FairRunAna();
38  FairFileSource input_source(RecoFile);
39  input_source.AddFriend(CandFile);
40  fRun->SetSource(&input_source);
41  fRun->SetOutputFile(outFile);
42  // ------------------------------------------------------------------------
43 
44  // ----- Parameter database --------------------------------------------
45  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
46  FairParRootFileIo* parInput1 = new FairParRootFileIo(kTRUE);
47  parInput1->open(parFile.Data(), "UPDATE");
48  rtdb->setFirstInput(parInput1);
49 
50  // =========================================================================
51  // ====== Track Fitter ======
52  // =========================================================================
53 
54  // ----- LMD collections names & importain parameters --------------------------------------------
55  TString inTrks = "LMDTrackCand";
56  TString inHits = "LMDHitsPixel";
57  if (mergedHits) {
58  inHits = "LMDHitsMerged";
59  }
60  if (Method == "Minuit") {
61  PndLmdLinFitTask* lmdfit = new PndLmdLinFitTask(inTrks, inHits);
62  // TString tTCandBranchName, TString tRecoBranchName
63  lmdfit->SetRadLen(1e-2 * radlen);
64  lmdfit->SetVerbose(verboseLevel);
65  // lmdfit->SetFilterFlag(false);
66  fRun->AddTask(lmdfit);
67  } else {
68  cout
69  << "I'm very sorry, but Kalman-Filter option for LMD is currently switched off :("
70  << endl;
71  // // ----- Prepare GEANE --------------------------------------------
72  // // this will load Geant3 and execute setup macros to initialize geometry:
73  // FairGeane *Geane = new FairGeane();
74  // fRun->AddTask(Geane);
75  // // ------------------------------------------------------------------------
76  // double scaleP=1;
77  // double scaleM=1;
78  // PndLmdKalmanTask* lmdkalmanfitter = new PndLmdKalmanTask(inHits,inTrks);
79  // lmdkalmanfitter->SetVerbose(verboseLevel);
80  // lmdkalmanfitter->SetScalePError(scaleP);
81  // lmdkalmanfitter->SetScaleMError(scaleM);
82  // lmdkalmanfitter->SetFilterFlag(false);
83  // if(Method=="KalmanGeane"){
84 
85  // lmdkalmanfitter->SetGeaneTrkRep();
86  // fRun->AddTask(lmdkalmanfitter);
87  // }
88  // else{
89  // if(Method=="KalmanRK"){
90  // lmdkalmanfitter->SetRKTrkRep();
91  // fRun->AddTask(lmdkalmanfitter);
92  // }
93  // else{
94  // cout<<"Method "<<Method.Data()<<" doesn't exist!"<<endl;
95  // break;
96  // }
97  // }
98  }
99 
100  rtdb->setOutput(parInput1);
101  rtdb->print();
102  // ===== End of TrackFinding =====
103  // =========================================================================
104 
105  // ----- Intialise and run --------------------------------------------
106  fRun->Init();
107 
108  fRun->Run(0, nEvents);
109  cout << "fRun->Run(0, " << nEvents << ") was done!" << endl;
110  // ------------------------------------------------------------------------
111 
112  rtdb->saveOutput();
113  rtdb->print();
114  // ----- Finish -------------------------------------------------------
115  timer.Stop();
116  Double_t rtime = timer.RealTime();
117  Double_t ctime = timer.CpuTime();
118  cout << endl << endl;
119  cout << "Macro finished succesfully." << endl;
120  cout << "Output file is " << outFile << endl;
121  cout << "Parameter file is " << parFile << endl;
122  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
123  cout << endl;
124  // ------------------------------------------------------------------------
125 
126  // temporary fix to avoid double frees at the destruction of te program for pandaroot/fairroot with root6
127  gGeoManager->GetListOfVolumes()->Delete();
128  gGeoManager->GetListOfShapes()->Delete();
129  delete gGeoManager;
130 
131  return 0;
132 }
int verboseLevel
Definition: Lars/runMvdSim.C:7
TString RecoFile
TString outFile
Definition: hit_dirc.C:17
int runLumiPixel4Fitter(const int nEvents=100000, const int startEvent=0, TString storePath="tmpOutput", const int verboseLevel=0, const TString Method="KalmanGeane", const bool mergedHits=true, const double radlen=0.31)
Int_t startEvent
TString storePath
void SetRadLen(double x)
TGeoManager * gGeoManager
FairRunAna * fRun
Definition: hit_dirc.C:58
Double_t
TString parFile
Definition: hit_dirc.C:14
Int_t nEvents
Definition: hit_dirc.C:11
TStopwatch timer
Definition: hit_dirc.C:51
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
FairParRootFileIo * parInput1
Definition: hit_dirc.C:67
Double_t ctime
Definition: hit_dirc.C:114
PndLmdLinFitTask * lmdfit
Double_t rtime
Definition: hit_dirc.C:113
virtual InitStatus Init()