1 //********************************************************************
2 // Example of the reconstruction that generates the ESD
4 // a) file containing the ITS clusters
5 // (the AliITSFindClustersV2.C macro can be used to generate it)
6 // b) file containing the TPC clusters
7 // (the AliTPCFindClusters.C macro can be used to generate it)
8 // c) file containing the TRD clusters
9 // (the AliTRDdigits2cluster.C macro can be used to generate it)
10 // d) file containing the TOF digits
11 // (the AliTOFSDigits2Digits.C macro can be used to generate it)
13 // AliESDs.root containing the ESD events
15 // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
16 //********************************************************************
18 #if !defined(__CINT__) || defined(__MAKECINT__)
19 #include <Riostream.h>
22 #include "TStopwatch.h"
27 #include "AliRunLoader.h"
28 #include "AliLoader.h"
29 #include "AliHeader.h"
30 #include "AliGenEventHeader.h"
33 #include "AliESDpid.h"
36 #include "AliITSgeom.h"
37 #include "AliITStrackerV2.h"
38 #include "AliV0vertexer.h"
39 #include "AliCascadeVertexer.h"
40 #include "AliITSpidESD.h"
41 #include "AliITSLoader.h"
43 #include "AliTPCParam.h"
44 #include "AliTPCtracker.h"
45 #include "AliTPCpidESD.h"
46 #include "AliTPCLoader.h"
48 #include "AliTRDtracker.h"
49 #include "AliTRDPartID.h"
51 #include "AliTOFpidESD.h"
53 #include "AliTOFGeometry.h"
56 extern AliRun *gAlice;
59 Int_t AliESDtest(Int_t nev=1,Int_t run=0) {
61 /**** Initialization of the NewIO *******/
64 delete gAlice->GetRunLoader();
69 AliRunLoader *rl = AliRunLoader::Open("galice.root");
71 cerr<<"Can not open session"<<endl;
74 Int_t retval = rl->LoadgAlice();
76 cerr<<"AliESDtest.C : LoadgAlice returned error"<<endl;
80 retval = rl->LoadHeader();
82 cerr<<"AliESDtest.C : LoadHeader returned error"<<endl;
86 gAlice=rl->GetAliRun();
89 AliKalmanTrack::SetConvConst(
90 1000/0.299792458/gAlice->Field()->SolenoidField()
94 /**** The ITS corner ********************/
96 AliITSLoader* itsl = (AliITSLoader*)rl->GetLoader("ITSLoader");
98 cerr<<"AliESDtest.C : Can not get the ITS loader"<<endl;
101 itsl->LoadRecPoints("read");
103 AliITS *dITS = (AliITS*)gAlice->GetDetector("ITS");
105 cerr<<"AliESDtest.C : Can not find the ITS detector !"<<endl;
108 AliITSgeom *geom = dITS->GetITSgeom();
110 //An instance of the ITS tracker
111 AliITStrackerV2 itsTracker(geom);
113 //An instance of the ITS PID maker
114 Double_t parITS[]={35.5,0.11,10.};
115 AliITSpidESD itsPID(parITS);
117 //An instance of the V0 finder
118 Double_t cuts[]={33, // max. allowed chi2
119 0.16,// min. allowed negative daughter's impact parameter
120 0.05,// min. allowed positive daughter's impact parameter
121 0.080,// max. allowed DCA between the daughter tracks
122 0.998,// max. allowed cosine of V0's pointing angle
123 0.9, // min. radius of the fiducial volume
124 2.9 // max. radius of the fiducial volume
126 AliV0vertexer vtxer(cuts);
128 Double_t cts[]={33., // max. allowed chi2
129 0.05, // min. allowed V0 impact parameter
130 0.008, // window around the Lambda mass
131 0.035, // min. allowed bachelor's impact parameter
132 0.10, // max. allowed DCA between a V0 and a track
133 0.9985, //max. allowed cosine of the cascade pointing angle
134 0.9, // min. radius of the fiducial volume
135 2.9 // max. radius of the fiducial volume
137 AliCascadeVertexer cvtxer=AliCascadeVertexer(cts);
139 /**** The TPC corner ********************/
141 AliTPCLoader* tpcl = (AliTPCLoader*)rl->GetLoader("TPCLoader");
143 cerr<<"AliESDtest.C : can not get the TPC loader"<<endl;
146 tpcl->LoadRecPoints("read");
149 AliTPCParam *par=(AliTPCParam *)gDirectory->Get("75x40_100x60_150x60");
151 cerr<<"TPC parameters have not been found !\n";
155 //An instance of the TPC tracker
156 AliTPCtracker tpcTracker(par);
158 //An instance of the TPC PID maker
159 Double_t parTPC[]={45.0,0.08,10.};
160 AliTPCpidESD tpcPID(parTPC);
163 /**** The TRD corner ********************/
165 AliLoader* trdl = rl->GetLoader("TRDLoader");
167 cerr<<"AliESDtest.C : can not get the TRD loader"<<endl;
170 trdl->LoadRecPoints("read");
172 //An instance of the TRD tracker
174 AliTRDtracker trdTracker(gFile); //galice.root file
177 //An instance of the TRD PID maker
178 TFile* pidFile = TFile::Open("pid.root");
179 if (!pidFile->IsOpen()) {
180 cerr << "Can't get pid.root !\n";
183 AliTRDPartID* trdPID = (AliTRDPartID*) pidFile->Get("AliTRDPartID");
185 cerr << "Can't get PID object !\n";
191 /**** The TOF corner ********************/
192 AliTOF *dTOF = (AliTOF*)gAlice->GetDetector("TOF");
194 cerr<<"AliESDtest.C : Can not find the TOF detector !"<<endl;
197 AliTOFGeometry *tofGeo = dTOF->GetGeometry();
199 cerr<<"AliESDtest.C : Can not find the TOF geometry !"<<endl;
203 AliLoader* tofl = rl->GetLoader("TOFLoader");
205 cerr<<"AliESDtest.C : can not get the TOF loader"<<endl;
208 tofl->LoadDigits("read");
210 //Instance of the TOF PID maker
211 Double_t parTOF[]={130.,5.};
212 AliTOFtracker tofTracker(tofGeo,parTOF) ;
215 //rl->UnloadgAlice();
218 TFile *bf=TFile::Open("AliESDcheck.root","RECREATE");
219 if (!bf || !bf->IsOpen()) {
220 cerr<<"Can't open AliESDcheck.root !\n"; return 1;
222 TFile *ef=TFile::Open("AliESDs.root","RECREATE");
223 if (!ef || !ef->IsOpen()) {cerr<<"Can't open AliESDs.root !\n"; return 2;}
227 if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
228 //The loop over events
229 for (Int_t i=0; i<nev; i++) {
232 cerr<<"\n\nProcessing event number : "<<i<<endl;
233 AliESD *event=new AliESD();
234 event->SetRunNumber(run);
235 event->SetEventNumber(i);
236 event->SetMagneticField(gAlice->Field()->SolenoidField());
240 //***** Primary vertex reconstruction (MC vertex position, for the moment)
242 rl->GetHeader()->GenEventHeader()->PrimaryVertex(v);
243 Double_t vtx[3]={v[0],v[1],v[2]};
244 Double_t cvtx[3]={0.005,0.005,0.010};
245 AliESDVertex vertex(vtx,cvtx);
246 event->SetVertex(&vertex);
248 //***** Initial path towards the primary vertex
249 tpcTracker.SetVertex(vtx,cvtx);
250 TTree *tpcTree=tpcl->TreeR();
252 cerr<<"Can't get the TPC cluster tree !\n";
255 tpcTracker.LoadClusters(tpcTree);
256 rc+=tpcTracker.Clusters2Tracks(event);
257 tpcPID.MakePID(event); // preliminary PID
258 AliESDpid::MakePID(event); // for the ITS tracker
260 itsTracker.SetVertex(vtx,cvtx);
261 TTree *itsTree=itsl->TreeR();
263 cerr<<"Can't get the ITS cluster tree !\n";
266 itsTracker.LoadClusters(itsTree);
267 rc+=itsTracker.Clusters2Tracks(event);
271 sprintf(ename,"in%d",i);
272 event->Write(ename); bf->Flush();
275 //***** Back propagation towards the outer barrel detectors
276 rc+=itsTracker.PropagateBack(event);
278 rc+=tpcTracker.PropagateBack(event);
280 TTree *trdTree=trdl->TreeR();
282 cerr<<"Can't get the TRD cluster tree !\n";
285 trdTracker.LoadClusters(trdTree);
286 rc+=trdTracker.PropagateBack(event);
289 for (Int_t iTrack = 0; iTrack < event->GetNumberOfTracks(); iTrack++) {
290 AliESDtrack* track = event->GetTrack(iTrack);
291 trdPID->MakePID(track);
295 TTree *tofTree=tofl->TreeD();
297 cerr<<"Can't get the TOF cluster tree !\n";
300 tofTracker.LoadClusters(tofTree);
301 rc+=tofTracker.PropagateBack(event);
302 tofTracker.UnloadClusters();
306 strcat(ename,";*"); bf->Delete(ename);
307 sprintf(ename,"out%d",i);
308 event->Write(ename); bf->Flush();
312 //***** Now the final refit at the primary vertex...
313 rc+=trdTracker.RefitInward(event);
314 trdTracker.UnloadClusters();
316 rc+=tpcTracker.RefitInward(event);
317 tpcTracker.UnloadClusters();
318 tpcPID.MakePID(event);
320 rc+=itsTracker.RefitInward(event);
321 itsTracker.UnloadClusters();
322 itsPID.MakePID(event);
325 //***** Here is the combined PID
326 AliESDpid::MakePID(event);
331 strcat(ename,";*"); bf->Delete(ename);
332 sprintf(ename,"refit%d",i);
333 event->Write(ename); bf->Flush();
338 //***** Hyperon reconstruction
339 vtxer.SetVertex(vtx);
340 rc+=vtxer.Tracks2V0vertices(event); // V0 finding
341 rc+=cvtxer.V0sTracks2CascadeVertices(event); // cascade finding
344 //***** Some final manipulations with this event
346 sprintf(ename,"%d",i);
348 if (!event->Write(ename)) rc++; ef->Flush();
349 bf=TFile::Open("AliESDcheck.root","RECREATE");
352 cerr<<"Something bad happened...\n";
353 bf=TFile::Open("AliESDcheck.root","UPDATE");
357 timer.Stop(); timer.Print();