]>
Commit | Line | Data |
---|---|---|
de568db1 | 1 | //////////////////////////////////////////////////////////////////////////////// |
2 | // // | |
3 | // AliFemtoEventReaderAOD - the reader class for the Alice AOD // | |
4 | // Reads in AOD information and converts it into internal AliFemtoEvent // | |
5 | // Authors: Marek Chojnacki mchojnacki@knf.pw.edu.pl // | |
6 | // Adam Kisiel kisiel@mps.ohio-state.edu // | |
7 | // // | |
8 | //////////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | #include "AliFemtoEventReaderAOD.h" | |
11 | ||
12 | #include "TFile.h" | |
13 | #include "TTree.h" | |
14 | #include "AliAODEvent.h" | |
15 | #include "AliAODTrack.h" | |
16 | #include "AliAODVertex.h" | |
17 | ||
18 | #include "AliFmPhysicalHelixD.h" | |
19 | #include "AliFmThreeVectorF.h" | |
20 | ||
21 | #include "SystemOfUnits.h" | |
22 | ||
23 | #include "AliFemtoEvent.h" | |
24 | #include "AliFemtoModelHiddenInfo.h" | |
25 | ||
26 | ClassImp(AliFemtoEventReaderAOD) | |
27 | ||
28 | #if !(ST_NO_NAMESPACES) | |
29 | using namespace units; | |
30 | #endif | |
31 | ||
32 | using namespace std; | |
33 | //____________________________ | |
34 | //constructor with 0 parameters , look at default settings | |
35 | AliFemtoEventReaderAOD::AliFemtoEventReaderAOD(): | |
36 | fInputFile(" "), | |
37 | fFileName(" "), | |
38 | fNumberofEvent(0), | |
39 | fCurEvent(0), | |
40 | fTree(0x0), | |
41 | fAodFile(0x0), | |
42 | fEvent(0x0), | |
43 | fAllTrue(160), | |
44 | fAllFalse(160), | |
45 | fFilterBit(0), | |
46 | fPWG2AODTracks(0x0) | |
47 | { | |
48 | // default constructor | |
49 | fAllTrue.ResetAllBits(kTRUE); | |
50 | fAllFalse.ResetAllBits(kFALSE); | |
51 | } | |
52 | ||
53 | AliFemtoEventReaderAOD::AliFemtoEventReaderAOD(const AliFemtoEventReaderAOD &aReader) : | |
54 | fInputFile(" "), | |
55 | fFileName(" "), | |
56 | fNumberofEvent(0), | |
57 | fCurEvent(0), | |
58 | fTree(0x0), | |
59 | fAodFile(0x0), | |
60 | fEvent(0x0), | |
61 | fAllTrue(160), | |
62 | fAllFalse(160), | |
63 | fFilterBit(0), | |
64 | fPWG2AODTracks(0x0) | |
65 | { | |
66 | // copy constructor | |
67 | fInputFile = aReader.fInputFile; | |
68 | fFileName = aReader.fFileName; | |
69 | fNumberofEvent = aReader.fNumberofEvent; | |
70 | fCurEvent = aReader.fCurEvent; | |
71 | fEvent = new AliAODEvent(); | |
72 | fAodFile = new TFile(aReader.fAodFile->GetName()); | |
73 | fAllTrue.ResetAllBits(kTRUE); | |
74 | fAllFalse.ResetAllBits(kFALSE); | |
75 | fFilterBit = aReader.fFilterBit; | |
76 | fPWG2AODTracks = aReader.fPWG2AODTracks; | |
77 | } | |
78 | //__________________ | |
79 | //Destructor | |
80 | AliFemtoEventReaderAOD::~AliFemtoEventReaderAOD() | |
81 | { | |
82 | // destructor | |
83 | delete fTree; | |
84 | delete fEvent; | |
85 | delete fAodFile; | |
86 | if (fPWG2AODTracks) { | |
87 | fPWG2AODTracks->Delete(); | |
88 | delete fPWG2AODTracks; | |
89 | } | |
90 | } | |
91 | ||
92 | //__________________ | |
93 | AliFemtoEventReaderAOD& AliFemtoEventReaderAOD::operator=(const AliFemtoEventReaderAOD& aReader) | |
94 | { | |
95 | // assignment operator | |
96 | if (this == &aReader) | |
97 | return *this; | |
98 | ||
99 | fInputFile = aReader.fInputFile; | |
100 | fFileName = aReader.fFileName; | |
101 | fNumberofEvent = aReader.fNumberofEvent; | |
102 | fCurEvent = aReader.fCurEvent; | |
103 | if (fTree) delete fTree; | |
104 | if (fEvent) delete fEvent; | |
105 | fEvent = new AliAODEvent(); | |
106 | if (fAodFile) delete fAodFile; | |
107 | fAodFile = new TFile(aReader.fAodFile->GetName()); | |
108 | fAllTrue.ResetAllBits(kTRUE); | |
109 | fAllFalse.ResetAllBits(kFALSE); | |
110 | fFilterBit = aReader.fFilterBit; | |
111 | fPWG2AODTracks = aReader.fPWG2AODTracks; | |
112 | ||
113 | return *this; | |
114 | } | |
115 | //__________________ | |
116 | AliFemtoString AliFemtoEventReaderAOD::Report() | |
117 | { | |
118 | // create reader report | |
119 | AliFemtoString temp = "\n This is the AliFemtoEventReaderAOD\n"; | |
120 | return temp; | |
121 | } | |
122 | ||
123 | //__________________ | |
124 | void AliFemtoEventReaderAOD::SetInputFile(const char* inputFile) | |
125 | { | |
126 | //setting the name of file where names of AOD file are written | |
127 | //it takes only this files which have good trees | |
128 | char buffer[256]; | |
129 | fInputFile=string(inputFile); | |
130 | cout<<"Input File set on "<<fInputFile<<endl; | |
131 | ifstream infile(inputFile); | |
132 | ||
133 | fTree = new TChain("aodTree"); | |
134 | ||
135 | if(infile.good()==true) | |
136 | { | |
137 | //checking if all give files have good tree inside | |
138 | while (infile.eof()==false) | |
139 | { | |
140 | infile.getline(buffer,256); | |
141 | TFile *aodFile=TFile::Open(buffer,"READ"); | |
142 | if (aodFile!=0x0) | |
143 | { | |
144 | TTree* tree = (TTree*) aodFile->Get("aodTree"); | |
145 | if (tree!=0x0) | |
146 | { | |
147 | cout<<"putting file "<<string(buffer)<<" into analysis"<<endl; | |
148 | fTree->AddFile(buffer); | |
149 | delete tree; | |
150 | } | |
151 | aodFile->Close(); | |
152 | } | |
153 | delete aodFile; | |
154 | } | |
155 | } | |
156 | } | |
157 | ||
158 | AliFemtoEvent* AliFemtoEventReaderAOD::ReturnHbtEvent() | |
159 | { | |
160 | // read in a next hbt event from the chain | |
161 | // convert it to AliFemtoEvent and return | |
162 | // for further analysis | |
163 | AliFemtoEvent *hbtEvent = 0; | |
164 | ||
165 | if (fCurEvent==fNumberofEvent)//open next file | |
166 | { | |
167 | if(fNumberofEvent==0) | |
168 | { | |
169 | fEvent=new AliAODEvent(); | |
170 | fEvent->ReadFromTree(fTree); | |
171 | ||
172 | // Check for the existence of the additional information | |
173 | fPWG2AODTracks = (TClonesArray *) fEvent->GetList()->FindObject("pwg2aodtracks"); | |
174 | ||
175 | if (fPWG2AODTracks) { | |
176 | cout << "Found additional PWG2 specific information in the AOD!" << endl; | |
177 | cout << "Reading only tracks with the additional information" << endl; | |
178 | } | |
179 | ||
180 | fNumberofEvent=fTree->GetEntries(); | |
181 | cout<<"Number of Entries in file "<<fNumberofEvent<<endl; | |
182 | fCurEvent=0; | |
183 | } | |
184 | else //no more data to read | |
185 | { | |
186 | cout<<"no more files "<<hbtEvent<<endl; | |
187 | fReaderStatus=1; | |
188 | return hbtEvent; | |
189 | } | |
190 | } | |
191 | ||
192 | cout<<"starting to read event "<<fCurEvent<<endl; | |
193 | fTree->GetEvent(fCurEvent);//getting next event | |
194 | cout << "Read event " << fEvent << " from file " << fTree << endl; | |
195 | ||
196 | hbtEvent = new AliFemtoEvent; | |
197 | ||
198 | CopyAODtoFemtoEvent(hbtEvent); | |
199 | ||
200 | fCurEvent++; | |
201 | ||
202 | return hbtEvent; | |
203 | } | |
204 | ||
205 | void AliFemtoEventReaderAOD::CopyAODtoFemtoEvent(AliFemtoEvent *tEvent) | |
206 | { | |
207 | // A function that reads in the AOD event | |
208 | // and transfers the neccessary information into | |
209 | // the internal AliFemtoEvent | |
210 | ||
211 | // setting global event characteristics | |
212 | tEvent->SetRunNumber(fEvent->GetRunNumber()); | |
213 | tEvent->SetMagneticField(fEvent->GetMagneticField()*kilogauss);//to check if here is ok | |
214 | tEvent->SetZDCN1Energy(fEvent->GetZDCN1Energy()); | |
215 | tEvent->SetZDCP1Energy(fEvent->GetZDCP1Energy()); | |
216 | tEvent->SetZDCN2Energy(fEvent->GetZDCN2Energy()); | |
217 | tEvent->SetZDCP2Energy(fEvent->GetZDCP2Energy()); | |
218 | tEvent->SetZDCEMEnergy(fEvent->GetZDCEMEnergy(0)); | |
219 | tEvent->SetZDCParticipants(-1); | |
220 | tEvent->SetTriggerMask(fEvent->GetTriggerMask()); | |
221 | tEvent->SetTriggerCluster(fEvent->GetTriggerCluster()); | |
222 | ||
223 | // Primary Vertex position | |
224 | double fV1[3]; | |
225 | fEvent->GetPrimaryVertex()->GetPosition(fV1); | |
226 | ||
227 | AliFmThreeVectorF vertex(fV1[0],fV1[1],fV1[2]); | |
228 | tEvent->SetPrimVertPos(vertex); | |
229 | ||
230 | //starting to reading tracks | |
231 | int nofTracks=0; //number of reconstructed tracks in event | |
232 | ||
233 | // Check to see whether the additional info exists | |
234 | if (fPWG2AODTracks) | |
235 | nofTracks=fPWG2AODTracks->GetEntries(); | |
236 | else | |
237 | nofTracks=fEvent->GetNumberOfTracks(); | |
238 | ||
239 | int realnofTracks=0; // number of track which we use in a analysis | |
240 | cout << "Event has " << nofTracks << " tracks " << endl; | |
241 | ||
242 | for (int i=0;i<nofTracks;i++) | |
243 | { | |
244 | AliFemtoTrack* trackCopy = new AliFemtoTrack(); | |
245 | ||
246 | if (fPWG2AODTracks) { | |
247 | // Read tracks from the additional pwg2 specific AOD part | |
248 | // if they exist | |
249 | // Note that in that case all the AOD tracks without the | |
250 | // additional information will be ignored ! | |
251 | AliPWG2AODTrack *pwg2aodtrack = (AliPWG2AODTrack *) fPWG2AODTracks->At(i); | |
252 | ||
253 | // Getting the AOD track through the ref of the additional info | |
254 | AliAODTrack *aodtrack = pwg2aodtrack->GetRefAODTrack(); | |
255 | if (!aodtrack->TestFilterBit(fFilterBit)) | |
256 | continue; | |
257 | ||
258 | CopyAODtoFemtoTrack(aodtrack, trackCopy, pwg2aodtrack); | |
259 | ||
260 | double pxyz[3]; | |
261 | aodtrack->PxPyPz(pxyz);//reading noconstarined momentum | |
262 | const AliFmThreeVectorD ktP(pxyz[0],pxyz[1],pxyz[2]); | |
263 | // Check the sanity of the tracks - reject zero momentum tracks | |
264 | if (ktP.mag() == 0) { | |
265 | delete trackCopy; | |
266 | continue; | |
267 | } | |
268 | } | |
269 | else { | |
270 | // No additional information exists | |
271 | // Read in the normal AliAODTracks | |
272 | const AliAODTrack *aodtrack=fEvent->GetTrack(i); // getting the AODtrack directly | |
273 | ||
274 | if (!aodtrack->TestFilterBit(fFilterBit)) | |
275 | continue; | |
276 | ||
277 | CopyAODtoFemtoTrack(aodtrack, trackCopy, 0); | |
278 | ||
279 | double pxyz[3]; | |
280 | aodtrack->PxPyPz(pxyz);//reading noconstarined momentum | |
281 | const AliFmThreeVectorD ktP(pxyz[0],pxyz[1],pxyz[2]); | |
282 | // Check the sanity of the tracks - reject zero momentum tracks | |
283 | if (ktP.mag() == 0) { | |
284 | delete trackCopy; | |
285 | continue; | |
286 | } | |
287 | } | |
288 | ||
289 | ||
290 | tEvent->TrackCollection()->push_back(trackCopy);//adding track to analysis | |
291 | realnofTracks++;//real number of tracks | |
292 | } | |
293 | ||
294 | tEvent->SetNumberOfTracks(realnofTracks);//setting number of track which we read in event | |
295 | ||
296 | cout<<"end of reading nt "<<nofTracks<<" real number "<<realnofTracks<<endl; | |
297 | } | |
298 | ||
299 | void AliFemtoEventReaderAOD::CopyAODtoFemtoTrack(const AliAODTrack *tAodTrack, | |
300 | AliFemtoTrack *tFemtoTrack, | |
301 | AliPWG2AODTrack *tPWG2AODTrack) | |
302 | { | |
303 | // Copy the track information from the AOD into the internal AliFemtoTrack | |
304 | // If it exists, use the additional information from the PWG2 AOD | |
305 | ||
306 | // Primary Vertex position | |
307 | double fV1[3]; | |
308 | fEvent->GetPrimaryVertex()->GetPosition(fV1); | |
309 | ||
310 | tFemtoTrack->SetCharge(tAodTrack->Charge()); | |
311 | ||
312 | //in aliroot we have AliPID | |
313 | //0-electron 1-muon 2-pion 3-kaon 4-proton 5-photon 6-pi0 7-neutron 8-kaon0 9-eleCon | |
314 | //we use only 5 first | |
315 | ||
316 | // AOD pid has 10 components | |
317 | double aodpid[10]; | |
318 | tAodTrack->GetPID(aodpid); | |
319 | tFemtoTrack->SetPidProbElectron(aodpid[0]); | |
320 | tFemtoTrack->SetPidProbMuon(aodpid[1]); | |
321 | tFemtoTrack->SetPidProbPion(aodpid[2]); | |
322 | tFemtoTrack->SetPidProbKaon(aodpid[3]); | |
323 | tFemtoTrack->SetPidProbProton(aodpid[4]); | |
324 | ||
325 | double pxyz[3]; | |
326 | tAodTrack->PxPyPz(pxyz);//reading noconstrained momentum | |
327 | AliFemtoThreeVector v(pxyz[0],pxyz[1],pxyz[2]); | |
328 | tFemtoTrack->SetP(v);//setting momentum | |
329 | tFemtoTrack->SetPt(sqrt(pxyz[0]*pxyz[0]+pxyz[1]*pxyz[1])); | |
330 | const AliFmThreeVectorD kOrigin(fV1[0],fV1[1],fV1[2]); | |
331 | //setting track helix | |
332 | const AliFmThreeVectorD ktP(pxyz[0],pxyz[1],pxyz[2]); | |
333 | AliFmPhysicalHelixD helix(ktP,kOrigin,(double)(fEvent->GetMagneticField())*kilogauss,(double)(tFemtoTrack->Charge())); | |
334 | tFemtoTrack->SetHelix(helix); | |
335 | ||
336 | // Flags | |
337 | tFemtoTrack->SetTrackId(tAodTrack->GetID()); | |
338 | tFemtoTrack->SetFlags(1); | |
339 | tFemtoTrack->SetLabel(tAodTrack->GetLabel()); | |
340 | ||
341 | // Track quality information | |
342 | float covmat[6]; | |
343 | tAodTrack->GetCovMatrix(covmat); | |
344 | tFemtoTrack->SetImpactD(covmat[0]); | |
345 | tFemtoTrack->SetImpactZ(covmat[2]); | |
346 | tFemtoTrack->SetCdd(covmat[3]); | |
347 | tFemtoTrack->SetCdz(covmat[4]); | |
348 | tFemtoTrack->SetCzz(covmat[5]); | |
349 | // This information is only available in the ESD | |
350 | // We put in fake values or reasonable estimates | |
351 | tFemtoTrack->SetITSchi2(tAodTrack->Chi2perNDF()); | |
352 | tFemtoTrack->SetITSncls(1); | |
353 | tFemtoTrack->SetTPCchi2(tAodTrack->Chi2perNDF()); | |
354 | tFemtoTrack->SetTPCncls(1); | |
355 | tFemtoTrack->SetTPCnclsF(-1); | |
356 | tFemtoTrack->SetTPCsignalN(-1); | |
357 | tFemtoTrack->SetTPCsignalS(-1); | |
358 | ||
359 | if (tPWG2AODTrack) { | |
360 | // Copy the PWG2 specific information if it exists | |
361 | tFemtoTrack->SetTPCClusterMap(tPWG2AODTrack->GetTPCClusterMap()); | |
362 | tFemtoTrack->SetTPCSharedMap(tPWG2AODTrack->GetTPCSharedMap()); | |
363 | ||
364 | double xtpc[3] = {0,0,0}; | |
365 | tPWG2AODTrack->GetTPCNominalEntrancePoint(xtpc); | |
366 | tFemtoTrack->SetNominalTPCEntrancePoint(xtpc); | |
367 | tPWG2AODTrack->GetTPCNominalExitPoint(xtpc); | |
368 | tFemtoTrack->SetNominalTPCExitPoint(xtpc); | |
369 | } | |
370 | else { | |
371 | // If not use dummy values | |
372 | tFemtoTrack->SetTPCClusterMap(fAllTrue); | |
373 | tFemtoTrack->SetTPCSharedMap(fAllFalse); | |
374 | ||
375 | double xtpc[3] = {0,0,0}; | |
376 | tFemtoTrack->SetNominalTPCEntrancePoint(xtpc); | |
377 | tFemtoTrack->SetNominalTPCExitPoint(xtpc); | |
378 | } | |
379 | ||
380 | int indexes[3]; | |
381 | for (int ik=0; ik<3; ik++) { | |
382 | indexes[ik] = 0; | |
383 | } | |
384 | tFemtoTrack->SetKinkIndexes(indexes); | |
385 | } | |
386 | ||
387 | void AliFemtoEventReaderAOD::SetFilterBit(UInt_t ibit) | |
388 | { | |
389 | fFilterBit = (1 << (ibit)); | |
390 | } | |
391 | ||
392 | ||
393 | ||
394 | ||
395 | ||
396 |