]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCtrackingParamDB.C
null alignment file
[u/mrichter/AliRoot.git] / TPC / AliTPCtrackingParamDB.C
1 /****************************************************************************
2  * This macro is used to create a DataBase for the TPC tracking             *
3  * parameterization.                                                        * 
4  * 1) the function CreateAllGeantTracks gives all tracks at the 1st hit of  *
5  *    the TPC                                                               *
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.                                      *
17  *                                                                          *
18  *  Origin: A.Dainese, Padova, andrea.dainese@pd,infn.it                    * 
19  *                                                                          *
20  ****************************************************************************/
21
22 #ifndef __CINT__
23 #include "Riostream.h"
24 #include <TFile.h>
25 #include <TTree.h>
26 #include <TStopwatch.h>
27 #include <TObject.h>
28 #include "alles.h"
29 #include "AliRun.h"
30 #include "AliHeader.h"
31 #include "AliGenEventHeader.h"
32 #include "AliMagF.h"
33 #include "AliModule.h"
34 #include "AliArrayI.h"
35 #include "AliDigits.h"
36 #include "AliITS.h"
37 #include "AliTPC.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"
46 #include "AliESD.h"
47 #include "AliRun.h"
48 #include "AliRunLoader.h"
49 #endif
50
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);
55
56 //_____________________________________________________________________________
57 Int_t TPCParamTracks(const Int_t coll,Int_t firstEvent,Int_t lastEvent) {
58 //
59 // Ordinary TPC tracking parameterization
60 //
61
62    /**** Initialization of the NewIO *******/
63
64    if (gAlice) {
65       delete gAlice->GetRunLoader();
66       delete gAlice; 
67       gAlice=0;
68    }
69
70    AliRunLoader *rl = AliRunLoader::Open("galice.root");
71    if (rl == 0x0) {
72       cerr<<"Can not open session"<<endl;
73       return;
74    }
75    Int_t retval = rl->LoadgAlice();
76    if (retval) {
77       cerr<<"LoadgAlice returned error"<<endl;
78       delete rl;
79       return;
80    }
81    retval = rl->LoadHeader();
82    if (retval) {
83       cerr<<"LoadHeader returned error"<<endl;
84       delete rl;
85       return;
86    }
87    gAlice=rl->GetAliRun();
88        
89
90    TDatabasePDG *DataBase = TDatabasePDG::Instance();
91
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);
97
98    /**** The TPC corner ********************/
99
100    AliTPCtrackerParam tpcTrackerPar(coll,fieval);
101    tpcTrackerPar.Init();
102
103    /***** The TREE is born *****/
104    
105    TTree *esdTree=new TTree("esdTree","Tree with ESD objects");
106    AliESD *event=0;
107    esdTree->Branch("ESD","AliESD",&event);
108    
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;
112    
113    //<----------------------------------The Loop over events begins
114    TStopwatch timer;
115    Int_t trc;
116    for(Int_t i=firstEvent; i<=lastEvent; i++) { 
117      
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());
123      rl->GetEvent(i);
124
125      if ( (trc=tpcTrackerPar.BuildTPCtracks(event)) ) {
126        printf("exiting tracker with code %d in event %d\n",trc,i);
127        esdTree->Fill(); delete event;
128        continue;
129      }
130
131      esdTree->Fill();
132      delete event;
133
134    }//<-----------------------------------The Loop over events ends here
135    timer.Stop(); timer.Print();
136
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;}
140
141    esdTree->Write(); //Write the TREE and close everything
142    delete esdTree;
143    ef->Close();
144
145    delete rl;
146
147    return;
148 }
149 //_____________________________________________________________________________
150 void CreateAllGeantTracks(const Int_t coll,Int_t nev) {
151 //
152 // Get all tracks at TPC 1st hit w/o selection and smearing
153 //
154   cerr<<"\n*******************************************************************\n";
155
156   const Char_t *name="CreateAllGeantTracks";
157   cerr<<'\n'<<name<<"...\n";
158   gBenchmark->Start(name);
159
160   TFile *outfile=TFile::Open(outname,"recreate");
161   TFile *infile =TFile::Open(galice);
162
163   AliTPCtrackerParam tracker(coll,Bfield,n);
164   tracker.AllGeantTracks(); // this is to switch-off selection and smearing
165   tracker.BuildTPCtracks(infile,outfile);
166
167   delete gAlice; gAlice=0;
168
169   infile->Close();
170   outfile->Close();
171
172   gBenchmark->Stop(name);
173   gBenchmark->Show(name);
174
175   return;
176 }
177 //_____________________________________________________________________________
178 void TrackCompare(const Int_t coll,const Double_t Bfield,Int_t n) {
179 //
180 // Compare Kalman tracks with tracks at TPC 1st hit
181 //
182   cerr<<"\n*******************************************************************\n";
183
184   const Char_t *name="TrackCompare";
185   cerr<<'\n'<<name<<"...\n";
186   gBenchmark->Start(name);
187
188   AliTPCtrackerParam tracker(coll,Bfield,n);
189   tracker.CompareTPCtracks();
190
191   gBenchmark->Stop(name);
192   gBenchmark->Show(name);
193
194   return;
195 }
196 //_____________________________________________________________________________
197 void BuildDataBase(const Int_t coll,const Double_t Bfield) {
198 //
199 //
200 //
201   cerr<<"\n*******************************************************************\n";
202
203   AliTPCtrackerParam tracker(coll,Bfield);
204
205   // Merge files with cov. matrix and compute average efficiencies
206   cerr<<"\n   --- Merging Events ---\n\n";
207   tracker.MergeEvents(1,5);
208  
209   // Compute the pulls for pions, kaons, electrons
210   cerr<<"\n   --- Analyzing Pulls ---\n\n";
211   tracker.AnalyzePulls("pulls.root");
212
213   // Draw pulls and efficiencies  
214   tracker.DrawPulls("CovMatrixDB_PbPb6000_B0.4T.root",211,0);
215   tracker.DrawEffs("CovMatrixDB_PbPb6000_B0.4T.root",13);
216
217   // Regularize the covariance matrix
218   tracker.RegularizeCovMatrix("regPi.root",211);
219
220   // Analyze the dE/dx
221   tracker.AnalyzedEdx("dEdxPi.root",211);
222
223
224   // Put everything together and create the DB file
225   tracker.MakeDataBase();
226
227   return;
228 }
229
230
231
232
233
234
235