]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliESDtest.C
SetCaller() calls added to identify the routine that calls stpping. (E. Futo)
[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    AliTRDPartID* trdPID = AliTRDPartID::GetFromFile();
80    if (!trdPID) return 7;
81
82    TFile *ef=TFile::Open("AliESDs.root","RECREATE");
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();
104
105      itsPID.MakePID(event);
106      
107      rc+=tpcTracker.PropagateBack(event);
108      tpcTracker.UnloadClusters();
109
110      tpcPID.MakePID(event);
111
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
124     //Here is the combined PID
125      AliESDpid::MakePID(event);
126
127      if (rc==0) {
128         Char_t ename[100]; 
129         sprintf(ename,"%d",i);
130         ef->cd();
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
140    trdcf->Close();
141    delete geom;
142    itscf->Close();
143    delete par;
144    tpccf->Close();
145    ef->Close();
146
147    return rc;
148 }