FairRoot/PandaRoot
npipi/run_reco_tpc_evt.C
Go to the documentation of this file.
1 {
2  // ========================================================================
3  // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug)
4  Int_t iVerbose = 0;
5 
6  // Input file
7  TString inDigiFile = "evt_digi_tpc.root";
8  TString inSimFile = "evt_points_tpc.root";
9 
10  // Parameter file
11  TString parFile = "evt_params_tpc.root";
12 
13  // Output file
14  TString outFile = "evt_reco_tpc.root";
15 
16  // Number of events to process
17  Int_t nEvents = 0;
18 
19  // ---- Load libraries -------------------------------------------------
20  gROOT->LoadMacro("$VMCWORKDIR/gconfig/rootlogon.C");
21  rootlogon();
22  TString sysFile = gSystem->Getenv("VMCWORKDIR");
23  // ------------------------------------------------------------------------
24  // In general, the following parts need not be touched
25  // ========================================================================
26 
27  // ----- Timer --------------------------------------------------------
28  TStopwatch timer;
29  timer.Start();
30  // ------------------------------------------------------------------------
31 
32  // ----- Digitization run -------------------------------------------
33  FairRunAna *fRun= new FairRunAna();
34  fRun->SetInputFile(inDigiFile);
35  fRun->AddFriend(inSimFile);
36  fRun->SetOutputFile(outFile);
37  FairGeane *Geane = new FairGeane();
38  fRun->AddTask(Geane);
39  // ------------------------------------------------------------------------
40 
41  // ----- Parameter database --------------------------------------------
42  TString allDigiFile = sysFile+"/macro/params/all.par";
43 
44  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
45  FairParRootFileIo* parInput1 = new FairParRootFileIo();
46  parInput1->open(parFile.Data());
47 
48  FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo();
49  parIo1->open(allDigiFile.Data(),"in");
50 
51  rtdb->setFirstInput(parInput1);
52  rtdb->setSecondInput(parIo1);
54  // ------------------------------------------------------------------------
55 
56  // ------- RECO procedure ------------------------------------------------
57 
58  //correct for unfortunate shift in TPC digi
59  //PndTpcRoughAlignmentTask* align = new PndTpcRoughAlignmentTask();
60  //align->SetShift(TVector3(0.,0.,-3.71357e-01)); //old PSA
61  //align->SetShift(TVector3(0.,0.,5.6E-2)); //new PSA
62  //fRun->AddTask(align);
63 
64 
65  //find PndTpcRiemannTracks in the TPC alone
66  PndTpcRiemannTrackingTask* tpcSPR = new PndTpcRiemannTrackingTask();
67  //tpcSPR->SetPersistence();
68  //tpcSPR->SetVerbose(1);
69  fRun->AddTask(tpcSPR);
70 
71  //build GFTracks from PndTpcRiemannTracks
72  PndTpcTrackInitTask* trackInit=new PndTpcTrackInitTask();
73  trackInit->SetPersistence();
74  //trackInit->SetVerbose(1);
75  trackInit->SetMCPid(); // use ideal particle identification
76  //trackInit->SetPDG(211);
77  //trackInit->useGeane(); // uses RKTrackrep and GeaneTrackrep
78  trackInit->SetSmoothing(true);
79  fRun->AddTask(trackInit);
80 
81  KalmanTask* kalman =new KalmanTask();
82  kalman->SetPersistence();
83  kalman->SetNumIterations(3); // number of fitting iterations (back and forth)
84  fRun->AddTask(kalman); // creates TrackPostFit branch
85 
86  //correlate fitted track with MVD pixels and strips
87  PndTpcMVDCorrelatorTask* corr = new PndTpcMVDCorrelatorTask();
88  corr->SetMatchDistance(0.18); //cm
89  corr->SetMinMVDHits(1);
90  corr->SetOutTrackBranchName("TrackPreFitMVD");
91  corr->SetPersistence(true);
92  fRun->AddTask(corr);
93 
94 
95  //fit after MVD corr
96  KalmanTask* kalman2 =new KalmanTask();
97  kalman2->SetPersistence();
98  kalman2->SetNumIterations(3); // number of fitting iterations (back and forth)
99  kalman2->SetTrackBranchName("TrackPreFitMVD");
100  kalman2->SetOutBranchName("TrackPostFitMVD");
101  fRun->AddTask(kalman2);
102 
103  PndTpcGEMCorrelatorTask* corrG = new PndTpcGEMCorrelatorTask();
104  corrG->SetMatchDistance(0.5); //cm
105  corrG->SetMinGEMHits(2);
106  corrG->SetTrackBranchName("TrackPostFitMVD");
107  corrG->SetOutTrackBranchName("TrackPreFitGEM");
108  corrG->SetPersistence(true);
109  fRun->AddTask(corrG);
110 
111  //final fit
112  KalmanTask* kalman3 =new KalmanTask();
113  kalman3->SetPersistence();
114  kalman3->SetNumIterations(3); // number of fitting iterations (back and forth)
115  kalman3->SetTrackBranchName("TrackPreFitGEM");
116  kalman3->SetOutBranchName("TrackPostFitComplete");
117  fRun->AddTask(kalman3);
118 
119  PndGFTrackToPndTrackConvertorTask* converter =new PndGFTrackToPndTrackConvertorTask();
120  converter->SetTrackInBranchName("TrackPostFitComplete");
121  converter->SetTrackOutBranchName("PndTrackPostFitComplete");
122  fRun->AddTask(converter);
123 
124  PndMCTrackAssociator* trackMC = new PndMCTrackAssociator();
125  trackMC->SetTrackInBranchName("PndTrackPostFitComplete");
126  trackMC->SetTrackOutBranchName("TrackPostFitCompleteID");
127  fRun->AddTask(trackMC);
128 
129  // ----- Intialise and run --------------------------------------------
131  fRun->Init();
132  fRun->Run(0, nEvents);
133 
134  rtdb->saveOutput();
135  rtdb->print();
136 
137  corr->WriteHistograms("MVDRes.root");
138  corrG->WriteHistograms("GEMRes.root");
139 
140  // ------------------------------------------------------------------------
141 
142  // ----- Finish -------------------------------------------------------
143 
144  timer.Stop();
145  Double_t rtime = timer.RealTime();
146  Double_t ctime = timer.CpuTime();
147  cout << endl << endl;
148  cout << "Macro finished succesfully." << endl;
149  cout << "Output file is " << outFile << endl;
150  cout << "Parameter file is " << parFile << endl;
151  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
152  cout << endl;
153  // ------------------------------------------------------------------------
154 
155 
156 }
TString inSimFile
Double_t rtime
KalmanTask * kalman2
TString sysFile
FairGeane * Geane
Int_t nEvents
PndMCTrackAssociator * trackMC
TStopwatch timer
PndGFTrackToPndTrackConvertorTask * converter
TString outFile
FairRunAna * fRun
FairParRootFileIo * parInput1
FairRuntimeDb * rtdb
Class to access the naming information of the MVD.
Double_t ctime
TString inDigiFile
TString parFile
Double_t
PndTpcGEMCorrelatorTask * corrG
PndGeoHandling * geoH
PndTpcMVDCorrelatorTask * corr
static void Init(Int_t MapVersion)
PndTpcRiemannTrackingTask * tpcSPR
FairParAsciiFileIo * parIo1
static PndGeoHandling * Instance()
TString allDigiFile
KalmanTask * kalman3
PndTpcTrackInitTask * trackInit
KalmanTask * kalman
Int_t iVerbose