]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliESDtest.C
TRD PID included in the ESD schema (T.Kuhr)
[u/mrichter/AliRoot.git] / STEER / AliESDtest.C
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"
20   #include "AliESDpid.h"
21   #include "AliTPCpidESD.h"
22   #include "AliTPCParam.h"
23   #include "AliTPCtracker.h"
24   #include "AliITSgeom.h"
25   #include "AliITStrackerV2.h"
26   #include "AliTRDtracker.h"
27   #include "AliTRDPartID.h"
28   #include "AliITSpidESD.h"
29 #endif
30
31 Int_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
36    //File with the TPC clusters
37    TFile *tpccf=TFile::Open(fileNameTPCClusters);
38    if (!tpccf->IsOpen()) {
39       cerr<<"Can't open "<<fileNameTPCClusters<<" !\n"; 
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
48    //An instance of the TPC PID maker
49    Double_t parTPC[]={47.,0.1,3.};
50    AliTPCpidESD tpcPID(parTPC);
51
52    //File with the ITS clusters
53    TFile *itscf=TFile::Open(fileNameITSClusters);
54    if (!itscf->IsOpen()) {
55       cerr<<"Can't open "<<fileNameITSClusters<<".root !\n"; 
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);
63    
64    //An instance of the ITS PID maker
65    Double_t parITS[]={34.,0.12,3.};
66    AliITSpidESD itsPID(parITS);
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
79    TFile* pidFile = TFile::Open("pid.root");
80    if (!pidFile->IsOpen()) {
81      cerr << "Can't get pid.root !\n";
82      return 7;
83    }
84    AliTRDPartID* trdPID = (AliTRDPartID*) pidFile->Get("AliTRDPartID");
85    if (!trdPID) {
86      cerr << "Can't get PID object !\n";
87      return 8;
88    }
89
90    TFile *ef=TFile::Open("AliESDs.root","RECREATE");
91    if (!ef->IsOpen()) {cerr<<"Can't AliESDs.root !\n"; return 1;}
92
93    TStopwatch timer;
94    Int_t rc=0;
95    //The loop over events
96    for (Int_t i=0; i<nev; i++) {
97      cerr<<"\n\nProcessing event number : "<<i<<endl;
98      AliESD *event=new AliESD(); 
99  
100      tpcTracker.SetEventNumber(i); 
101      tpcTracker.LoadClusters(tpccf);
102
103      itsTracker.SetEventNumber(i); 
104      itsTracker.LoadClusters(itscf);
105
106      rc+=tpcTracker.Clusters2Tracks(event);
107
108      rc+=itsTracker.Clusters2Tracks(event);
109
110      rc+=itsTracker.PropagateBack(event); 
111      itsTracker.UnloadClusters();
112
113      itsPID.MakePID(event);
114      
115      rc+=tpcTracker.PropagateBack(event);
116      tpcTracker.UnloadClusters();
117
118      tpcPID.MakePID(event);
119
120      trdTracker.SetEventNumber(i);
121      trdcf->cd();
122      trdTracker.LoadClusters();
123
124      rc+=trdTracker.PropagateBack(event);
125      trdTracker.UnloadClusters();
126
127      for (Int_t iTrack = 0; iTrack < event->GetNumberOfTracks(); iTrack++) {
128        AliESDtrack* track = event->GetTrack(iTrack);
129        trdPID->MakePID(track);
130      }
131
132     //Here is the combined PID
133      AliESDpid::MakePID(event);
134
135      if (rc==0) {
136         Char_t ename[100]; 
137         sprintf(ename,"%d",i);
138         ef->cd();
139         if (!event->Write(ename)) rc++;
140      } 
141      if (rc) {
142         cerr<<"Something bad happened...\n";
143      }
144      delete event;
145    }
146    timer.Stop(); timer.Print();
147
148    pidFile->Close();
149    trdcf->Close();
150    delete geom;
151    itscf->Close();
152    delete par;
153    tpccf->Close();
154    ef->Close();
155
156    return rc;
157 }