FairRoot/PandaRoot
runLumiPixel3Finder.C
Go to the documentation of this file.
1 int runLumiPixel3Finder(const int nEvents = 1000, const int startEvent = 0,
4  TString storePath = "tmpOutput", const int verboseLevel = 5,
5  TString Method = "Follow", const bool missPl = true, const bool mergedHits =
6  true, const bool trkcuts = true, double mom = 1.5) {
7  // ========================================================================
8  TString RecoMergedFile = storePath + "/Lumi_recoMerged_";
9  RecoMergedFile += startEvent;
10  RecoMergedFile += ".root";
11  TString RecoFile = storePath + "/Lumi_reco_";
12  RecoFile += startEvent;
13  RecoFile += ".root";
14  // Parameter file
15  TString parFile = storePath + "/Lumi_Params_";
16  parFile += startEvent;
17  parFile += ".root";
18 
19  // Output file
20  TString outFile = storePath + "/Lumi_TCand_";
21  outFile += startEvent;
22  outFile += ".root";
23 
24  std::cout << "RecoFile: " << RecoFile.Data() << std::endl;
25  std::cout << "TCandFile: " << outFile.Data() << std::endl;
26 
27  // ----- Timer --------------------------------------------------------
28  TStopwatch timer;
29  timer.Start();
30  // ------------------------------------------------------------------------
31 
32  // ----- Reconstruction run -------------------------------------------
33  FairRunAna *fRun = new FairRunAna();
34  FairFileSource input_source(RecoFile);
35  if (mergedHits)
36  input_source.AddFriend(RecoMergedFile);
37  fRun->SetSource(&input_source);
38  fRun->SetOutputFile(outFile);
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 
48  // =========================================================================
49  // ====== Track Finder ======
50  // =========================================================================
51 
52  // ----- LMD collections names & importain parameters --------------------------------------------
53  TString inHits = "LMDHitsPixel";
54  int nsensors = 100;
55  int nplanes = 8;
56  double accurF = 0.01; //parameter for trk-finder corridor
57  double accurCA; //parameter for CA neigboring search (breaking angle)
58  // //set accurCA for diff Pbeam cases ---------------------------------------------
59  double accCAv[5] = { 5e-6, 1e-6, 9e-7, 8e-7, 8e-7 }; //1.5, 4.06, 8.9, 11.91, 15
60  double delta_mom(0.1);
61  if (1.5 - delta_mom < mom && mom < 1.5 + delta_mom)
62  accurCA = accCAv[0];
63  else if (4.06 - delta_mom < mom && mom < 4.06 + delta_mom)
64  accurCA = accCAv[1];
65  else if (8.9 - delta_mom < mom && mom < 8.9 + delta_mom)
66  accurCA = accCAv[2];
67  else if (11.91 - delta_mom < mom && mom < 11.91 + delta_mom)
68  accurCA = accCAv[3];
69  else if (15.0 - delta_mom < mom && mom < 15.0 + delta_mom)
70  accurCA = accCAv[4];
71  else {
72  accurCA = 1e-5;
73  cout
74  << "! CA algorithm needs to know beam momentum for choose of proper cut !";
75  }
76  // //------------------------------------------------------------------------------------------
77  if (trkcuts != true)
78  accurCA = 1e-3; //misalignment sensors case (TODO: study it in multiple trks case)
79  if (mergedHits) {
80  inHits = "LMDHitsMerged";
81  nplanes = 4;
82  }
83 
84  if (Method == "Follow") {
85  PndLmdTrackFinderTask* lmdfinder = new PndLmdTrackFinderTask(missPl, inHits,
86  nsensors);
87  lmdfinder->SetInaccuracy(accurF);
88  lmdfinder->SetSensPixelFlag(true);
89 
90  lmdfinder->SetVerbose(verboseLevel);
91  fRun->AddTask(lmdfinder);
92  } else {
93  if (Method == "CA") {
94  cout << "CA is going to use cut=" << accurCA << endl;
95  PndLmdTrackFinderCATask* lmdfinder = new PndLmdTrackFinderCATask(missPl,
96  accurCA, nsensors, nplanes, inHits); //for merged hits
97  lmdfinder->SetSensPixelFlag(true);
98  lmdfinder->SetTrkCandCutsFlag(trkcuts); //value=false for misaligned sensors only
99  // lmdfinder->SetTrkCandCutsFlag(true);
100 
101  lmdfinder->SetVerbose(verboseLevel);
102  fRun->AddTask(lmdfinder);
103  } else {
104  cout << "Method " << Method.Data() << " doesn't exist!" << endl;
105  }
106  }
107 
108  rtdb->setOutput(parInput1);
109  rtdb->print();
110  // ===== End of TrackFinding =====
111  // =========================================================================
112 
113  // ----- Intialise and run --------------------------------------------
114  fRun->Init();
115 
116  fRun->Run(0, nEvents);
117  // ------------------------------------------------------------------------
118 
119  rtdb->saveOutput();
120  rtdb->print();
121  // ----- Finish -------------------------------------------------------
122  timer.Stop();
123  Double_t rtime = timer.RealTime();
124  Double_t ctime = timer.CpuTime();
125  cout << endl << endl;
126  cout << "Macro finished succesfully." << endl;
127  cout << "Output file is " << outFile << endl;
128  cout << "Parameter file is " << parFile << endl;
129  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
130  cout << endl;
131  // ------------------------------------------------------------------------
132 
133  // temporary fix to avoid double frees at the destruction of te program for pandaroot/fairroot with root6
134  gGeoManager->GetListOfVolumes()->Delete();
135  gGeoManager->GetListOfShapes()->Delete();
136  delete gGeoManager;
137 
138  return 0;
139 }
const int nplanes(120)
int verboseLevel
Definition: Lars/runMvdSim.C:7
TString RecoFile
TString outFile
Definition: hit_dirc.C:17
Int_t startEvent
TString storePath
Double_t mom
Definition: plot_dirc.C:14
TGeoManager * gGeoManager
FairRunAna * fRun
Definition: hit_dirc.C:58
void SetInaccuracy(Double_t accu)
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
int runLumiPixel3Finder(const int nEvents=1000, const int startEvent=0, TString storePath="tmpOutput", const int verboseLevel=5, TString Method="Follow", const bool missPl=true, const bool mergedHits=true, const bool trkcuts=true, double mom=1.5)
void SetVerbose(Int_t verbose)
void SetVerbose(Int_t verbose)
Double_t rtime
Definition: hit_dirc.C:113