Update of combined PID (T.Kuhr)
[u/mrichter/AliRoot.git] / STEER / AliESDtest.C
CommitLineData
ae982df3 1//********************************************************************
2// Example of the reconstruction that generates the ESD
3// Input files:
4// a) AliTPCclusters.root containing the TPC clusters
5// (the AliTPCFindClusters.C macro can be used to generate it)
6// b) AliITSclustersV2.root containing the ITS clusters
7// (the AliITSFindClustersV2.C macro can be used to generate it)
8// Ouput file:
9// AliESDs.root containing the ESD events
10//
11// Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
12//********************************************************************
13
14#ifndef __CINT__
15 #include <Riostream.h>
16 #include "TFile.h"
17 #include "TStopwatch.h"
18
19 #include "AliESD.h"
8c6a71ab 20 #include "AliESDpid.h"
21 #include "AliTPCpidESD.h"
ae982df3 22 #include "AliTPCParam.h"
23 #include "AliTPCtracker.h"
24 #include "AliITSgeom.h"
25 #include "AliITStrackerV2.h"
79e94bf8 26 #include "AliTRDtracker.h"
27 #include "AliTRDPartID.h"
8c6a71ab 28 #include "AliITSpidESD.h"
ae982df3 29#endif
30
79e94bf8 31Int_t AliESDtest(Int_t nev=1,
32 const char* fileNameITSClusters = "its.clusters.root",
33 const char* fileNameTPCClusters = "tpc.clusters.root",
34 const char* fileNameTRDClusters = "trd.clusters.root") {
35
ae982df3 36 //File with the TPC clusters
79e94bf8 37 TFile *tpccf=TFile::Open(fileNameTPCClusters);
ae982df3 38 if (!tpccf->IsOpen()) {
79e94bf8 39 cerr<<"Can't open "<<fileNameTPCClusters<<" !\n";
ae982df3 40 return 2;
41 }
42 AliTPCParam *par=(AliTPCParam*)tpccf->Get("75x40_100x60_150x60");
43 if (!par) {cerr<<"Can't get TPC parameters !\n"; return 3;}
44
45 //An instance of the TPC tracker
46 AliTPCtracker tpcTracker(par);
47
8c6a71ab 48 //An instance of the TPC PID maker
49 Double_t parTPC[]={47.,0.1,3.};
50 AliTPCpidESD tpcPID(parTPC);
ae982df3 51
52 //File with the ITS clusters
79e94bf8 53 TFile *itscf=TFile::Open(fileNameITSClusters);
ae982df3 54 if (!itscf->IsOpen()) {
79e94bf8 55 cerr<<"Can't open "<<fileNameITSClusters<<".root !\n";
ae982df3 56 return 4;
57 }
58 AliITSgeom *geom=(AliITSgeom*)itscf->Get("AliITSgeom");
59 if (!geom) {cerr<<"Can't get AliITSgeom !\n"; return 5;}
60
61 //An instance of the ITS tracker
62 AliITStrackerV2 itsTracker(geom);
8c6a71ab 63
64 //An instance of the ITS PID maker
65 Double_t parITS[]={34.,0.12,3.};
66 AliITSpidESD itsPID(parITS);
79e94bf8 67
68 //File with the TRD clusters
69 TFile *trdcf=TFile::Open(fileNameTRDClusters);
70 if (!trdcf->IsOpen()) {
71 cerr<<"Can't open "<<fileNameTRDClusters<<".root !\n";
72 return 6;
73 }
74
75 //An instance of the TRD tracker
76 AliTRDtracker trdTracker(trdcf);
77
78 //An instance of the TRD PID maker
4db7f8b6 79 AliTRDPartID* trdPID = AliTRDPartID::GetFromFile();
80 if (!trdPID) return 7;
79e94bf8 81
82 TFile *ef=TFile::Open("AliESDs.root","RECREATE");
ae982df3 83 if (!ef->IsOpen()) {cerr<<"Can't AliESDs.root !\n"; return 1;}
84
85 TStopwatch timer;
86 Int_t rc=0;
87 //The loop over events
88 for (Int_t i=0; i<nev; i++) {
89 cerr<<"\n\nProcessing event number : "<<i<<endl;
90 AliESD *event=new AliESD();
91
92 tpcTracker.SetEventNumber(i);
93 tpcTracker.LoadClusters(tpccf);
94
95 itsTracker.SetEventNumber(i);
96 itsTracker.LoadClusters(itscf);
97
98 rc+=tpcTracker.Clusters2Tracks(event);
99
100 rc+=itsTracker.Clusters2Tracks(event);
101
102 rc+=itsTracker.PropagateBack(event);
103 itsTracker.UnloadClusters();
79e94bf8 104
8c6a71ab 105 itsPID.MakePID(event);
ae982df3 106
107 rc+=tpcTracker.PropagateBack(event);
108 tpcTracker.UnloadClusters();
79e94bf8 109
8c6a71ab 110 tpcPID.MakePID(event);
111
79e94bf8 112 trdTracker.SetEventNumber(i);
113 trdcf->cd();
114 trdTracker.LoadClusters();
115
116 rc+=trdTracker.PropagateBack(event);
117 trdTracker.UnloadClusters();
118
119 for (Int_t iTrack = 0; iTrack < event->GetNumberOfTracks(); iTrack++) {
120 AliESDtrack* track = event->GetTrack(iTrack);
121 trdPID->MakePID(track);
122 }
123
8c6a71ab 124 //Here is the combined PID
125 AliESDpid::MakePID(event);
ae982df3 126
127 if (rc==0) {
128 Char_t ename[100];
129 sprintf(ename,"%d",i);
79e94bf8 130 ef->cd();
ae982df3 131 if (!event->Write(ename)) rc++;
132 }
133 if (rc) {
134 cerr<<"Something bad happened...\n";
135 }
136 delete event;
137 }
138 timer.Stop(); timer.Print();
139
79e94bf8 140 trdcf->Close();
ae982df3 141 delete geom;
142 itscf->Close();
143 delete par;
144 tpccf->Close();
145 ef->Close();
146
147 return rc;
148}