1 /****************************************************************************
2 * This macro is used to create a DataBase for the TPC tracking *
4 * 1) the function CreateAllGeantTracks gives all tracks at the 1st hit of *
6 * 2) the function TrackCompare compares them with track found by the *
7 * Kalman filter for the same event and computes efficiency and *
8 * resolution on the track parameters for the Kalman filter. *
9 * 3) the function BuildDataBase calls many functions of AliTPCtrackerParam:*
10 * - merge results from TrackCompare for many events and compute *
11 * average efficiency. *
12 * - analyze the pulls of the covariance matrix *
13 * - analyze the dE/dx *
14 * - regularize the covariance matrix as a function of the momentum *
15 * - write all the informations and the trees with regularized cov. *
16 * matrices in the DataBase file. *
18 * Origin: A.Dainese, Padova, andrea.dainese@pd,infn.it *
20 ****************************************************************************/
23 #include "Riostream.h"
26 #include <TStopwatch.h>
30 #include "AliHeader.h"
31 #include "AliGenEventHeader.h"
33 #include "AliModule.h"
34 #include "AliArrayI.h"
35 #include "AliDigits.h"
38 #include "AliITSgeom.h"
39 #include "AliITSRecPoint.h"
40 #include "AliITSclusterV2.h"
41 #include "AliITSsimulationFastPoints.h"
42 #include "AliITStrackerV2.h"
43 #include "AliKalmanTrack.h"
44 #include "AliTPCtrackerParam.h"
45 #include "AliTracker.h"
48 #include "AliRunLoader.h"
51 Int_t TPCParamTracks(const Int_t coll=1,Int_t firstEvent=0,Int_t lastEvent=0);
52 void CreateAllGeantTracks(const Int_t coll=1,Int_t nev=1);
53 void TrackCompare(const Int_t coll,const Double_t Bfield,Int_t n);
54 void BuildDataBase(const Int_t coll,const Double_t Bfield);
56 //_____________________________________________________________________________
57 Int_t TPCParamTracks(const Int_t coll,Int_t firstEvent,Int_t lastEvent) {
59 // Ordinary TPC tracking parameterization
62 /**** Initialization of the NewIO *******/
65 delete gAlice->GetRunLoader();
70 AliRunLoader *rl = AliRunLoader::Open("galice.root");
72 cerr<<"Can not open session"<<endl;
75 Int_t retval = rl->LoadgAlice();
77 cerr<<"LoadgAlice returned error"<<endl;
81 retval = rl->LoadHeader();
83 cerr<<"LoadHeader returned error"<<endl;
87 gAlice=rl->GetAliRun();
90 TDatabasePDG *DataBase = TDatabasePDG::Instance();
92 // Get field from galice.root
93 AliMagF *fiel = (AliMagF*)gAlice->Field();
94 Double_t fieval=TMath::Abs((Double_t)fiel->SolenoidField()/10.);
95 // Set the conversion constant between curvature and Pt
96 AliTracker::SetFieldMap(fiel,kTRUE);
98 /**** The TPC corner ********************/
100 AliTPCtrackerParam tpcTrackerPar(coll,fieval);
101 tpcTrackerPar.Init();
103 /***** The TREE is born *****/
105 TTree *esdTree=new TTree("esdTree","Tree with ESD objects");
107 esdTree->Branch("ESD","AliESD",&event);
109 if(firstEvent>rl->GetNumberOfEvents()) firstEvent=rl->GetNumberOfEvents()-1;
110 if(lastEvent>rl->GetNumberOfEvents()) lastEvent=rl->GetNumberOfEvents()-1;
111 cout<<" Number of events: "<<1+lastEvent-firstEvent<<endl;
113 //<----------------------------------The Loop over events begins
116 for(Int_t i=firstEvent; i<=lastEvent; i++) {
118 cerr<<" Processing event number : "<<i<<endl;
119 AliESD *event = new AliESD();
120 event->SetRunNumber(gAlice->GetRunNumber());
121 event->SetEventNumber(i);
122 event->SetMagneticField(gAlice->Field()->SolenoidField());
125 if ( (trc=tpcTrackerPar.BuildTPCtracks(event)) ) {
126 printf("exiting tracker with code %d in event %d\n",trc,i);
127 esdTree->Fill(); delete event;
134 }//<-----------------------------------The Loop over events ends here
135 timer.Stop(); timer.Print();
137 // The AliESDs.root is born
138 TFile *ef = TFile::Open("AliESDs.root","RECREATE");
139 if (!ef || !ef->IsOpen()) {cerr<<"Can't open AliESDs.root !\n"; return;}
141 esdTree->Write(); //Write the TREE and close everything
149 //_____________________________________________________________________________
150 void CreateAllGeantTracks(const Int_t coll,Int_t nev) {
152 // Get all tracks at TPC 1st hit w/o selection and smearing
154 cerr<<"\n*******************************************************************\n";
156 const Char_t *name="CreateAllGeantTracks";
157 cerr<<'\n'<<name<<"...\n";
158 gBenchmark->Start(name);
160 TFile *outfile=TFile::Open(outname,"recreate");
161 TFile *infile =TFile::Open(galice);
163 AliTPCtrackerParam tracker(coll,Bfield,n);
164 tracker.AllGeantTracks(); // this is to switch-off selection and smearing
165 tracker.BuildTPCtracks(infile,outfile);
167 delete gAlice; gAlice=0;
172 gBenchmark->Stop(name);
173 gBenchmark->Show(name);
177 //_____________________________________________________________________________
178 void TrackCompare(const Int_t coll,const Double_t Bfield,Int_t n) {
180 // Compare Kalman tracks with tracks at TPC 1st hit
182 cerr<<"\n*******************************************************************\n";
184 const Char_t *name="TrackCompare";
185 cerr<<'\n'<<name<<"...\n";
186 gBenchmark->Start(name);
188 AliTPCtrackerParam tracker(coll,Bfield,n);
189 tracker.CompareTPCtracks();
191 gBenchmark->Stop(name);
192 gBenchmark->Show(name);
196 //_____________________________________________________________________________
197 void BuildDataBase(const Int_t coll,const Double_t Bfield) {
201 cerr<<"\n*******************************************************************\n";
203 AliTPCtrackerParam tracker(coll,Bfield);
205 // Merge files with cov. matrix and compute average efficiencies
206 cerr<<"\n --- Merging Events ---\n\n";
207 tracker.MergeEvents(1,5);
209 // Compute the pulls for pions, kaons, electrons
210 cerr<<"\n --- Analyzing Pulls ---\n\n";
211 tracker.AnalyzePulls("pulls.root");
213 // Draw pulls and efficiencies
214 tracker.DrawPulls("CovMatrixDB_PbPb6000_B0.4T.root",211,0);
215 tracker.DrawEffs("CovMatrixDB_PbPb6000_B0.4T.root",13);
217 // Regularize the covariance matrix
218 tracker.RegularizeCovMatrix("regPi.root",211);
221 tracker.AnalyzedEdx("dEdxPi.root",211);
224 // Put everything together and create the DB file
225 tracker.MakeDataBase();