Added loop for extraction of clusters really attached to its track.
[u/mrichter/AliRoot.git] / ANALYSIS / WriteAOD.C
CommitLineData
dd2b6810 1#if 0
2 #include "$(ALICE_ROOT)/TPC/alles.h"
3 #include "AliReader.h"
4 #include "AliReaderKineTree.h"
0317f8c1 5 #include "AliReaderESDTree.h"
dd2b6810 6 #include "AliAODParticleCut.h"
7 #include "AliAOD.h"
8 #include "AliAODPairCut.h"
9 #include "TSystem.h"
10 #include "TObjString.h"
11 #include "TString.h"
12 #include "AliPDG.h"
13#endif
14
15
efdb0cc9 16void WriteAOD(Option_t* datatype, Int_t first = -1,Int_t last = -1,
17 Option_t* processopt="TracksAndParticles",
dd2b6810 18 char *outfile = "AOD.root")
19 {
20//datatype defines type of data to be read
21// Kine - analyzes Kine Tree: simulated particles
22// ESD
23// AOD
24
25// default: TracksAndParticles - process both recontructed tracks and sim. particles corresponding to them
26// Tracks - process only recontructed tracks
27// Particles - process only simulated particles
28
29//Reads data from diroctories from first to last(including)
30// For examples if first=3 and last=5 it reads from
31// ./3/
32// ./4/
33// ./5/
34//if first or last is negative (or both), it reads from current directory
35//
36//these names I use when analysis is done directly from CASTOR files via RFIO
37
d9122a01 38 Bool_t multcheck = kTRUE;
39
dd2b6810 40 const char* basedir=".";
41 const char* serie="";
42 const char* field = "";
43 cout<<"WriteAOD.C: datatype is "<<datatype<<" dir is basedir"<<endl;
44 // Dynamically link some shared libs
45
46 cout<<"WriteAOD.C: Loading ANALYSIS .....\n";
47 gSystem->Load("$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET)/libANALYSIS");
48 cout<<"WriteAOD.C: ..... Loaded\n";
49
d9122a01 50 Int_t PID[11];
56849d99 51
d9122a01 52 PID[0]=kProton;
53 PID[1]=kProtonBar;
54 PID[2]=kKPlus;
55 PID[3]=kKMinus;
56 PID[4]=kPiPlus;
57 PID[5]=kPiMinus;
58 PID[6]=kElectron;
59 PID[7]=kPositron;
60 PID[8]=kMuonMinus;
61 PID[9]=kMuonPlus;
62 PID[10]=0;//Last must be 0!!!!!!!!!!!!!!!!!!
63
64 Float_t PIDprob[11];
65 PIDprob[0] = 0.5;
66 PIDprob[1] = 0.5;
67 PIDprob[2] = 0.5;
68 PIDprob[3] = 0.5;
69 PIDprob[4] = 0.5;
70 PIDprob[5] = 0.5;
71 PIDprob[6] = 0.5;
72 PIDprob[7] = 0.5;
73 PIDprob[8] = 0.5;
74 PIDprob[9] = 0.5;
75 PIDprob[10] = 0.5;
dd2b6810 76 /***********************************************************/
77
78 AliReader* reader;
79 Int_t kine = strcmp(datatype,"Kine");
80 Int_t ESD = strcmp(datatype,"ESD");
0317f8c1 81 Int_t ESDMuon = strcmp(datatype,"ESDMuon");
dd2b6810 82 Int_t intern = strcmp(datatype,"AOD");
83
84 if(!kine)
85 {
86 reader = new AliReaderKineTree();
87 processopt="Particles"; //this reader by definition reads only simulated particles
88 multcheck = kFALSE;
89 }
90 else if(!ESD)
91 {
92 AliReaderESD* esdreader = new AliReaderESD();
93 esdreader->ReadSimulatedData(kTRUE);
d9122a01 94 esdreader->SetNumberOfTrackPoints(5,30.);//5 points every 30 cm
95 esdreader->SetITSTrackPoints(kTRUE);
96 esdreader->SetClusterMap(kTRUE);
97
dd2b6810 98 reader = esdreader;
99 multcheck = kTRUE;
100 }
101
102 else if(!intern)
103 {
56849d99 104 AliReaderAOD* aodreader = new AliReaderAOD("AOD.root");
105 if (strstr(processopt,"Particles"))
106 aodreader->ReadSimulatedData(kTRUE);
107 else
108 aodreader->ReadSimulatedData(kFALSE);
109
110 reader = aodreader;
111
dd2b6810 112 multcheck = kTRUE;
113 }
0317f8c1 114
115 else if (!ESDMuon)
116 {
117 // set reader for ESD
118 AliReaderESDTree* muonreader = new AliReaderESDTree("AliESDs.root");
119 // active muon ESD reader
120 muonreader->SetReadMuon(kTRUE);
121 // disable central barrel (default = kTRUE)
122 muonreader->SetReadCentralBarrel(kFALSE);
123 // disable simulated data (not implemented yet)
124 muonreader->ReadSimulatedData(kFALSE);
125
126 reader = muonreader;
127 multcheck = kFALSE;
128 }
dd2b6810 129 else
130 {
131 cerr<<"Option "<<datatype<<" not recognized. Exiting"<<endl;
132 return;
133 }
134
135 TObjArray* dirs=0;
136 if ( (first >= 0) && (last>=0) && ( (last-first)>=0 ) )
137 {//read from many dirs dirs
138 cout<<"WriteAOD.C: ..... Setting dirs first="<<first<<" last="<<last<<"\n";
139 char buff[50];
140 dirs = new TObjArray(last-first+1);
141 dirs->SetOwner();
142 for (Int_t i = first; i<=last; i++)
143 {
144 sprintf(buff,"%s/%s/%s/%d",basedir,field,serie,i);
145 TObjString *odir= new TObjString(buff);
146 dirs->Add(odir);
147 }
148 }
149
2e8abbcc 150 reader->SetDirs(dirs);
d9122a01 151
152 AliAODParticleCut* readerpartcut= new AliAODParticleCut();
153
154 Int_t l = 0;
155 while (PID[l] != 0)
156 {
157 cout<<"WriteAOD.C: Adding PID = "<<PID[l]<<" l = "<<l<<endl;
158 readerpartcut->SetPID(PID[l]);
159 AliAODParticleCut * pcut = (AliAODParticleCut*)readerpartcut->Clone();
160 AliAODPIDCut* pidcut = new AliAODPIDCut(PID[l],PIDprob[l]);
161 pcut->AddBasePartCut(pidcut);
162 reader->AddParticleCut(pcut);//read this particle type with this cut
163 delete pcut;
164 l++;
165 }
166
167// readerpartcut->SetPtRange(0.0,1.2);
dd2b6810 168
169 cout<<"WriteAOD.C: P R O C S E S S I N G .....\n\n";
beb1c41d 170 AliReaderAOD::WriteAOD(reader,outfile,"AliAODParticle",multcheck);
dd2b6810 171 cout<<"\n\nWriteAOD.C: F I N I S H E D\n";
172
173 if (dirs) delete dirs;
174 delete reader;
175 }
176