First version of combined PID (Yu.Belikov)
[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"
8c6a71ab 26 #include "AliITSpidESD.h"
ae982df3 27#endif
28
29Int_t AliESDtest(Int_t nev=1) {
30 //File with the TPC clusters
31 TFile *tpccf=TFile::Open("AliTPCclusters.root");
32 if (!tpccf->IsOpen()) {
33 cerr<<"Can't open AliTPCclusters.root !\n";
34 return 2;
35 }
36 AliTPCParam *par=(AliTPCParam*)tpccf->Get("75x40_100x60_150x60");
37 if (!par) {cerr<<"Can't get TPC parameters !\n"; return 3;}
38
39 //An instance of the TPC tracker
40 AliTPCtracker tpcTracker(par);
41
8c6a71ab 42 //An instance of the TPC PID maker
43 Double_t parTPC[]={47.,0.1,3.};
44 AliTPCpidESD tpcPID(parTPC);
ae982df3 45
46 //File with the ITS clusters
47 TFile *itscf=TFile::Open("AliITSclustersV2.root");
48 if (!itscf->IsOpen()) {
49 cerr<<"Can't open AliITSclustersV2.root !\n";
50 return 4;
51 }
52 AliITSgeom *geom=(AliITSgeom*)itscf->Get("AliITSgeom");
53 if (!geom) {cerr<<"Can't get AliITSgeom !\n"; return 5;}
54
55 //An instance of the ITS tracker
56 AliITStrackerV2 itsTracker(geom);
8c6a71ab 57
58 //An instance of the ITS PID maker
59 Double_t parITS[]={34.,0.12,3.};
60 AliITSpidESD itsPID(parITS);
61
ae982df3 62 TFile *ef=TFile::Open("AliESDs.root","new");
63 if (!ef->IsOpen()) {cerr<<"Can't AliESDs.root !\n"; return 1;}
64
65 TStopwatch timer;
66 Int_t rc=0;
67 //The loop over events
68 for (Int_t i=0; i<nev; i++) {
69 cerr<<"\n\nProcessing event number : "<<i<<endl;
70 AliESD *event=new AliESD();
71
72 tpcTracker.SetEventNumber(i);
73 tpcTracker.LoadClusters(tpccf);
74
75 itsTracker.SetEventNumber(i);
76 itsTracker.LoadClusters(itscf);
77
78 rc+=tpcTracker.Clusters2Tracks(event);
79
80 rc+=itsTracker.Clusters2Tracks(event);
81
82 rc+=itsTracker.PropagateBack(event);
83 itsTracker.UnloadClusters();
8c6a71ab 84 itsPID.MakePID(event);
ae982df3 85
86 rc+=tpcTracker.PropagateBack(event);
87 tpcTracker.UnloadClusters();
8c6a71ab 88 tpcPID.MakePID(event);
89
90 //Here is the combined PID
91 AliESDpid::MakePID(event);
ae982df3 92
93 if (rc==0) {
94 Char_t ename[100];
95 sprintf(ename,"%d",i);
96 if (!event->Write(ename)) rc++;
97 }
98 if (rc) {
99 cerr<<"Something bad happened...\n";
100 }
101 delete event;
102 }
103 timer.Stop(); timer.Print();
104
105 delete geom;
106 itscf->Close();
107 delete par;
108 tpccf->Close();
109 ef->Close();
110
111 return rc;
112}