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"
31 #include "AliESDpid.h"
34 #include "AliITSgeom.h"
35 #include "AliITStrackerV2.h"
36 #include "AliITSpidESD.h"
37 #include "AliITSLoader.h"
39 #include "AliTPCParam.h"
40 #include "AliTPCtracker.h"
41 #include "AliTPCpidESD.h"
42 #include "AliTPCLoader.h"
44 #include "AliTRDtracker.h"
45 #include "AliTRDPartID.h"
47 #include "AliTOFpidESD.h"
50 extern TSystem *gSystem;
51 extern AliRun *gAlice;
54 Int_t AliESDtest(Int_t nev=1) {
56 /**** Initialization of the NewIO *******/
59 delete gAlice->GetRunLoader();
64 gSystem->Load("libgeant321"); // needed for the PID in TOF
65 new TGeant3(""); // must be re-done !
67 AliRunLoader *rl = AliRunLoader::Open("galice.root");
69 cerr<<"Can not open session"<<endl;
72 Int_t retval = rl->LoadgAlice();
74 cerr<<"AliESDtest.C : LoadgAlice returned error"<<endl;
78 retval = rl->LoadHeader();
80 cerr<<"AliESDtest.C : LoadHeader returned error"<<endl;
84 gAlice=rl->GetAliRun();
87 AliKalmanTrack::SetConvConst(
88 1000/0.299792458/gAlice->Field()->SolenoidField()
93 /**** The ITS corner ********************/
95 AliITSLoader* itsl = (AliITSLoader*)rl->GetLoader("ITSLoader");
97 cerr<<"AliESDtest.C : Can not get the ITS loader"<<endl;
100 itsl->LoadRecPoints("read");
102 AliITS *dITS = (AliITS*)gAlice->GetDetector("ITS");
104 cerr<<"AliESDtest.C : Can not find the ITS detector !"<<endl;
107 AliITSgeom *geom = dITS->GetITSgeom();
109 //An instance of the ITS tracker
110 AliITStrackerV2 itsTracker(geom);
112 //An instance of the ITS PID maker
113 Double_t parITS[]={34.,0.15,10.};
114 AliITSpidESD itsPID(parITS);
117 /**** The TPC corner ********************/
119 AliTPCLoader* tpcl = (AliTPCLoader*)rl->GetLoader("TPCLoader");
121 cerr<<"AliESDtest.C : can not get the TPC loader"<<endl;
124 tpcl->LoadRecPoints("read");
127 AliTPCParam *par=(AliTPCParam *)gDirectory->Get("75x40_100x60_150x60");
129 cerr<<"TPC parameters have not been found !\n";
133 //An instance of the TPC tracker
134 AliTPCtracker tpcTracker(par);
136 //An instance of the TPC PID maker
137 Double_t parTPC[]={47.,0.10,10.};
138 AliTPCpidESD tpcPID(parTPC);
141 /**** The TRD corner ********************/
143 AliLoader* trdl = rl->GetLoader("TRDLoader");
145 cerr<<"AliESDtest.C : can not get the TRD loader"<<endl;
148 trdl->LoadRecPoints("read");
150 //An instance of the TRD tracker
152 AliTRDtracker trdTracker(gFile); //galice.root file
155 //An instance of the TRD PID maker
156 TFile* pidFile = TFile::Open("pid.root");
157 if (!pidFile->IsOpen()) {
158 cerr << "Can't get pid.root !\n";
161 AliTRDPartID* trdPID = (AliTRDPartID*) pidFile->Get("AliTRDPartID");
163 cerr << "Can't get PID object !\n";
169 /**** The TOF corner ********************/
171 AliLoader* tofl = rl->GetLoader("TOFLoader");
173 cerr<<"AliESDtest.C : can not get the TOF loader"<<endl;
176 tofl->LoadDigits("read");
179 //Instance of the TOF PID maker
180 Double_t parTOF[]={130.,5.};
181 AliTOFpidESD tofPID(parTOF);
184 //rl->UnloadgAlice();
187 TFile *ef=TFile::Open("AliESDs.root","RECREATE");
188 if (!ef->IsOpen()) {cerr<<"Can't AliESDs.root !\n"; return 1;}
192 if (nev>rl->GetNumberOfEvents()) nev=rl->GetNumberOfEvents();
193 //The loop over events
194 for (Int_t i=0; i<nev; i++) {
195 cerr<<"\n\nProcessing event number : "<<i<<endl;
196 AliESD *event=new AliESD();
200 TTree *tpcTree=tpcl->TreeR();
202 cerr<<"Can't get the TPC cluster tree !\n";
205 tpcTracker.LoadClusters(tpcTree);
206 rc+=tpcTracker.Clusters2Tracks(event);
209 TTree *itsTree=itsl->TreeR();
211 cerr<<"Can't get the TPC cluster tree !\n";
214 itsTracker.LoadClusters(itsTree);
215 rc+=itsTracker.Clusters2Tracks(event);
217 rc+=itsTracker.PropagateBack(event);
218 itsTracker.UnloadClusters();
219 itsPID.MakePID(event);
221 rc+=tpcTracker.PropagateBack(event);
222 tpcTracker.UnloadClusters();
223 tpcPID.MakePID(event);
226 TTree *trdTree=trdl->TreeR();
228 cerr<<"Can't get the TPC cluster tree !\n";
231 trdTracker.LoadClusters(trdTree);
232 rc+=trdTracker.PropagateBack(event);
233 trdTracker.UnloadClusters();
236 for (Int_t iTrack = 0; iTrack < event->GetNumberOfTracks(); iTrack++) {
237 AliESDtrack* track = event->GetTrack(iTrack);
238 trdPID->MakePID(track);
242 TTree *tofTree=tofl->TreeD();
244 cerr<<"Can't get the TOF cluster tree !\n";
247 tofPID.LoadClusters(tofTree);
248 tofPID.MakePID(event);
249 tofPID.UnloadClusters();
252 //Here is the combined PID
253 AliESDpid::MakePID(event);
257 sprintf(ename,"%d",i);
259 if (!event->Write(ename)) rc++;
262 cerr<<"Something bad happened...\n";
266 timer.Stop(); timer.Print();