]>
Commit | Line | Data |
---|---|---|
96b85d73 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id: AliAnalysisTaskESDfilter.cxx 24535 2008-03-16 22:43:30Z fca $ */ | |
17 | ||
18 | #include <TChain.h> | |
7b4cee8d | 19 | #include <TTree.h> |
ec6465fe | 20 | #include <TList.h> |
e6500713 | 21 | #include <TArrayI.h> |
d7bdc804 | 22 | #include <TRandom.h> |
da97a08a | 23 | #include <TParticle.h> |
96b85d73 | 24 | |
25 | #include "AliAnalysisTaskESDfilter.h" | |
26 | #include "AliAnalysisManager.h" | |
27 | #include "AliESDEvent.h" | |
da97a08a | 28 | #include "AliStack.h" |
96b85d73 | 29 | #include "AliAODEvent.h" |
da97a08a | 30 | #include "AliMCEvent.h" |
31 | #include "AliMCEventHandler.h" | |
96b85d73 | 32 | #include "AliESDInputHandler.h" |
33 | #include "AliAODHandler.h" | |
da97a08a | 34 | #include "AliAODMCParticle.h" |
96b85d73 | 35 | #include "AliAnalysisFilter.h" |
96b85d73 | 36 | #include "AliESDMuonTrack.h" |
37 | #include "AliESDVertex.h" | |
38 | #include "AliESDv0.h" | |
39 | #include "AliESDkink.h" | |
40 | #include "AliESDcascade.h" | |
41 | #include "AliESDPmdTrack.h" | |
42 | #include "AliESDCaloCluster.h" | |
43 | #include "AliESDCaloCells.h" | |
44 | #include "AliMultiplicity.h" | |
45 | #include "AliLog.h" | |
46 | ||
47 | ClassImp(AliAnalysisTaskESDfilter) | |
48 | ||
49 | //////////////////////////////////////////////////////////////////////// | |
50 | ||
51 | AliAnalysisTaskESDfilter::AliAnalysisTaskESDfilter(): | |
52 | AliAnalysisTaskSE(), | |
53 | fTrackFilter(0x0), | |
54 | fKinkFilter(0x0), | |
d7bdc804 | 55 | fV0Filter(0x0), |
56 | fHighPthreshold(0), | |
980e4563 | 57 | fPtshape(0x0) |
96b85d73 | 58 | { |
59 | // Default constructor | |
60 | } | |
61 | ||
980e4563 | 62 | AliAnalysisTaskESDfilter::AliAnalysisTaskESDfilter(const char* name): |
96b85d73 | 63 | AliAnalysisTaskSE(name), |
64 | fTrackFilter(0x0), | |
65 | fKinkFilter(0x0), | |
d7bdc804 | 66 | fV0Filter(0x0), |
67 | fHighPthreshold(0), | |
980e4563 | 68 | fPtshape(0x0) |
96b85d73 | 69 | { |
70 | // Constructor | |
71 | } | |
72 | ||
73 | void AliAnalysisTaskESDfilter::UserCreateOutputObjects() | |
74 | { | |
75 | // Create the output container | |
76 | OutputTree()->GetUserInfo()->Add(fTrackFilter); | |
77 | } | |
78 | ||
79 | void AliAnalysisTaskESDfilter::Init() | |
80 | { | |
81 | // Initialization | |
82 | if (fDebug > 1) AliInfo("Init() \n"); | |
83 | // Call configuration file | |
84 | } | |
85 | ||
86 | ||
87 | void AliAnalysisTaskESDfilter::UserExec(Option_t */*option*/) | |
88 | { | |
89 | // Execute analysis for current event | |
90 | // | |
91 | ||
92 | Long64_t ientry = Entry(); | |
2827d046 | 93 | if (fDebug > 0) printf("Filter: Analysing event # %5d\n", (Int_t) ientry); |
d7bdc804 | 94 | if (fHighPthreshold == 0) AliInfo("detector PID signals are stored in each track"); |
95 | if (!fPtshape) AliInfo("detector PID signals are not stored below the pt threshold"); | |
da97a08a | 96 | |
96b85d73 | 97 | ConvertESDtoAOD(); |
98 | } | |
99 | ||
100 | void AliAnalysisTaskESDfilter::ConvertESDtoAOD() { | |
101 | // ESD Filter analysis task executed for each event | |
da97a08a | 102 | |
96b85d73 | 103 | AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent()); |
104 | AliESD* old = esd->GetAliESDOld(); | |
da97a08a | 105 | |
106 | // Fetch Stack for debuggging if available | |
107 | AliStack *pStack = 0; | |
108 | AliMCEventHandler *mcH = 0; | |
109 | if(MCEvent()){ | |
110 | pStack = MCEvent()->Stack(); | |
111 | mcH = (AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler()); | |
112 | } | |
96b85d73 | 113 | // set arrays and pointers |
114 | Float_t posF[3]; | |
115 | Double_t pos[3]; | |
116 | Double_t p[3]; | |
117 | Double_t p_pos[3]; | |
118 | Double_t p_neg[3]; | |
8d69965b | 119 | Double_t p_pos_atv0[3]; |
120 | Double_t p_neg_atv0[3]; | |
96b85d73 | 121 | Double_t covVtx[6]; |
122 | Double_t covTr[21]; | |
123 | Double_t pid[10]; | |
124 | ||
125 | for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.; | |
126 | for (Int_t i = 0; i < 21; i++) covTr [i] = 0.; | |
127 | ||
128 | ||
da97a08a | 129 | // loop over events and fill them |
130 | ||
131 | // Multiplicity information needed by the header (to be revised!) | |
96b85d73 | 132 | Int_t nTracks = esd->GetNumberOfTracks(); |
8d69965b | 133 | // if (fDebug > 0) printf("-------------------Bo: Number of ESD tracks %d \n",nTracks); |
134 | ||
96b85d73 | 135 | Int_t nPosTracks = 0; |
3e492e99 | 136 | // for (Int_t iTrack = 0; iTrack < nTracks; ++iTrack) |
137 | // if (esd->GetTrack(iTrack)->GetSign()> 0) nPosTracks++; | |
96b85d73 | 138 | |
139 | // Update the header | |
140 | ||
141 | AliAODHeader* header = AODEvent()->GetHeader(); | |
142 | header->SetRunNumber(esd->GetRunNumber()); | |
143 | if (old) { | |
144 | header->SetBunchCrossNumber(0); | |
145 | header->SetOrbitNumber(0); | |
146 | header->SetPeriodNumber(0); | |
147 | header->SetEventType(0); | |
148 | header->SetMuonMagFieldScale(-999.); // FIXME | |
149 | header->SetCentrality(-999.); // FIXME | |
150 | } else { | |
151 | header->SetBunchCrossNumber(esd->GetBunchCrossNumber()); | |
152 | header->SetOrbitNumber(esd->GetOrbitNumber()); | |
153 | header->SetPeriodNumber(esd->GetPeriodNumber()); | |
154 | header->SetEventType(esd->GetEventType()); | |
155 | header->SetMuonMagFieldScale(-999.); // FIXME | |
156 | header->SetCentrality(-999.); // FIXME | |
157 | } | |
158 | ||
159 | header->SetTriggerMask(esd->GetTriggerMask()); | |
160 | header->SetTriggerCluster(esd->GetTriggerCluster()); | |
161 | header->SetMagneticField(esd->GetMagneticField()); | |
162 | header->SetZDCN1Energy(esd->GetZDCN1Energy()); | |
163 | header->SetZDCP1Energy(esd->GetZDCP1Energy()); | |
164 | header->SetZDCN2Energy(esd->GetZDCN2Energy()); | |
165 | header->SetZDCP2Energy(esd->GetZDCP2Energy()); | |
166 | header->SetZDCEMEnergy(esd->GetZDCEMEnergy(0),esd->GetZDCEMEnergy(1)); | |
96b85d73 | 167 | // |
168 | // | |
169 | Int_t nV0s = esd->GetNumberOfV0s(); | |
170 | Int_t nCascades = esd->GetNumberOfCascades(); | |
171 | Int_t nKinks = esd->GetNumberOfKinks(); | |
172 | Int_t nVertices = nV0s + 2*nCascades /*could lead to two vertices, one V0 and the Xi */+ nKinks + 1 /* = prim. vtx*/; | |
173 | Int_t nJets = 0; | |
174 | Int_t nCaloClus = esd->GetNumberOfCaloClusters(); | |
175 | Int_t nFmdClus = 0; | |
176 | Int_t nPmdClus = esd->GetNumberOfPmdTracks(); | |
177 | ||
2827d046 | 178 | if (fDebug > 0) |
179 | printf(" NV0=%d NCASCADES=%d NKINKS=%d\n", nV0s, nCascades, nKinks); | |
96b85d73 | 180 | |
181 | AODEvent()->ResetStd(nTracks, nVertices, nV0s+nCascades, nJets, nCaloClus, nFmdClus, nPmdClus); | |
182 | ||
183 | AliAODTrack *aodTrack = 0x0; | |
d7bdc804 | 184 | AliAODPid *detpid = 0x0; |
185 | Double_t timezero = 0; //TO BE FIXED | |
7dd90a3c | 186 | AliAODv0 *aodV0 = 0x0; |
187 | ||
d3fc6709 | 188 | // RefArray to store the mapping between esd track number and newly created AOD-Track |
189 | TRefArray *aodRefs = NULL; | |
190 | if (nTracks > 0) aodRefs = new TRefArray(nTracks); | |
8d69965b | 191 | |
96b85d73 | 192 | // Array to take into account the tracks already added to the AOD |
193 | Bool_t * usedTrack = NULL; | |
194 | if (nTracks>0) { | |
195 | usedTrack = new Bool_t[nTracks]; | |
196 | for (Int_t iTrack=0; iTrack<nTracks; ++iTrack) usedTrack[iTrack]=kFALSE; | |
197 | } | |
198 | // Array to take into account the V0s already added to the AOD | |
199 | Bool_t * usedV0 = NULL; | |
200 | if (nV0s>0) { | |
201 | usedV0 = new Bool_t[nV0s]; | |
202 | for (Int_t iV0=0; iV0<nV0s; ++iV0) usedV0[iV0]=kFALSE; | |
203 | } | |
204 | // Array to take into account the kinks already added to the AOD | |
205 | Bool_t * usedKink = NULL; | |
206 | if (nKinks>0) { | |
207 | usedKink = new Bool_t[nKinks]; | |
208 | for (Int_t iKink=0; iKink<nKinks; ++iKink) usedKink[iKink]=kFALSE; | |
209 | } | |
210 | ||
211 | // Access to the AOD container of vertices | |
212 | TClonesArray &vertices = *(AODEvent()->GetVertices()); | |
213 | Int_t jVertices=0; | |
214 | ||
215 | // Access to the AOD container of tracks | |
216 | TClonesArray &tracks = *(AODEvent()->GetTracks()); | |
217 | Int_t jTracks=0; | |
218 | ||
219 | // Access to the AOD container of V0s | |
220 | TClonesArray &V0s = *(AODEvent()->GetV0s()); | |
221 | Int_t jV0s=0; | |
222 | ||
223 | // Add primary vertex. The primary tracks will be defined | |
224 | // after the loops on the composite objects (V0, cascades, kinks) | |
225 | const AliESDVertex *vtx = esd->GetPrimaryVertex(); | |
226 | ||
227 | vtx->GetXYZ(pos); // position | |
228 | vtx->GetCovMatrix(covVtx); //covariance matrix | |
229 | ||
230 | AliAODVertex * primary = new(vertices[jVertices++]) | |
c06d243f | 231 | AliAODVertex(pos, covVtx, vtx->GetChi2toNDF(), NULL, -1, AliAODVertex::kPrimary); |
2827d046 | 232 | if (fDebug > 0) primary->Print(); |
96b85d73 | 233 | |
234 | // Create vertices starting from the most complex objects | |
235 | Double_t chi2 = 0.; | |
236 | ||
237 | // Cascades | |
238 | for (Int_t nCascade = 0; nCascade < nCascades; ++nCascade) { | |
239 | AliESDcascade *cascade = esd->GetCascade(nCascade); | |
240 | ||
241 | cascade->GetXYZ(pos[0], pos[1], pos[2]); | |
242 | ||
243 | if (!old) { | |
244 | chi2 = cascade->GetChi2Xi(); // = chi2/NDF since NDF = 2*2-3 | |
245 | cascade->GetPosCovXi(covVtx); | |
246 | } else { | |
247 | chi2 = -999.; | |
248 | for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.; | |
249 | } | |
250 | // Add the cascade vertex | |
251 | AliAODVertex * vcascade = new(vertices[jVertices++]) AliAODVertex(pos, | |
252 | covVtx, | |
253 | chi2, | |
254 | primary, | |
255 | nCascade, | |
256 | AliAODVertex::kCascade); | |
257 | ||
258 | primary->AddDaughter(vcascade); | |
259 | ||
260 | // Add the V0 from the cascade. The ESD class have to be optimized... | |
261 | // Now we have to search for the corresponding Vo in the list of V0s | |
262 | // using the indeces of the positive and negative tracks | |
263 | ||
264 | Int_t posFromV0 = cascade->GetPindex(); | |
265 | Int_t negFromV0 = cascade->GetNindex(); | |
266 | ||
267 | ||
268 | AliESDv0 * v0 = 0x0; | |
269 | Int_t indV0 = -1; | |
270 | ||
271 | for (Int_t iV0=0; iV0<nV0s; ++iV0) { | |
272 | ||
273 | v0 = esd->GetV0(iV0); | |
274 | Int_t posV0 = v0->GetPindex(); | |
275 | Int_t negV0 = v0->GetNindex(); | |
276 | ||
277 | if (posV0==posFromV0 && negV0==negFromV0) { | |
278 | indV0 = iV0; | |
279 | break; | |
280 | } | |
281 | } | |
282 | ||
283 | AliAODVertex * vV0FromCascade = 0x0; | |
284 | ||
285 | if (indV0>-1 && !usedV0[indV0] ) { | |
286 | ||
287 | // the V0 exists in the array of V0s and is not used | |
288 | ||
289 | usedV0[indV0] = kTRUE; | |
290 | ||
291 | v0->GetXYZ(pos[0], pos[1], pos[2]); | |
292 | if (!old) { | |
293 | chi2 = v0->GetChi2V0(); // = chi2/NDF since NDF = 2*2-3 | |
294 | v0->GetPosCov(covVtx); | |
295 | } else { | |
296 | chi2 = -999.; | |
297 | for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.; | |
298 | } | |
299 | ||
300 | vV0FromCascade = new(vertices[jVertices++]) AliAODVertex(pos, | |
301 | covVtx, | |
302 | chi2, | |
303 | vcascade, | |
304 | indV0, | |
305 | AliAODVertex::kV0); | |
306 | } else { | |
307 | ||
308 | // the V0 doesn't exist in the array of V0s or was used | |
309 | // cerr << "Error: event " << esd->GetEventNumberInFile() << " cascade " << nCascade | |
310 | // << " The V0 " << indV0 | |
311 | // << " doesn't exist in the array of V0s or was used!" << endl; | |
312 | ||
313 | cascade->GetXYZ(pos[0], pos[1], pos[2]); | |
314 | ||
315 | if (!old) { | |
316 | chi2 = v0->GetChi2V0(); | |
317 | cascade->GetPosCov(covVtx); | |
318 | } else { | |
319 | chi2 = -999.; | |
320 | for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.; | |
321 | } | |
322 | ||
323 | vV0FromCascade = new(vertices[jVertices++]) AliAODVertex(pos, | |
324 | covVtx, | |
325 | chi2, // = chi2/NDF since NDF = 2*2-3 (AM) | |
326 | vcascade, | |
327 | indV0, | |
328 | AliAODVertex::kV0); | |
329 | vcascade->AddDaughter(vV0FromCascade); | |
330 | } | |
331 | ||
332 | // Add the positive tracks from the V0 | |
333 | ||
334 | if (posFromV0>-1 && !usedTrack[posFromV0]) { | |
335 | ||
336 | usedTrack[posFromV0] = kTRUE; | |
337 | ||
338 | AliESDtrack *esdTrack = esd->GetTrack(posFromV0); | |
339 | esdTrack->GetPxPyPz(p_pos); | |
340 | esdTrack->GetXYZ(pos); | |
341 | esdTrack->GetCovarianceXYZPxPyPz(covTr); | |
342 | esdTrack->GetESDpid(pid); | |
fae68d32 | 343 | UInt_t selectInfo = 0; |
344 | if (fTrackFilter) { | |
345 | selectInfo = fTrackFilter->IsSelected(esdTrack); | |
346 | } | |
96b85d73 | 347 | |
da97a08a | 348 | if(mcH)mcH->SelectParticle(esdTrack->GetLabel()); |
96b85d73 | 349 | vV0FromCascade->AddDaughter(aodTrack = |
350 | new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), | |
351 | esdTrack->GetLabel(), | |
352 | p_pos, | |
353 | kTRUE, | |
354 | pos, | |
355 | kFALSE, | |
356 | covTr, | |
357 | (Short_t)esdTrack->GetSign(), | |
358 | esdTrack->GetITSClusterMap(), | |
359 | pid, | |
360 | vV0FromCascade, | |
361 | kTRUE, // check if this is right | |
362 | kFALSE, // check if this is right | |
3de26c63 | 363 | AliAODTrack::kSecondary, |
364 | selectInfo) | |
365 | ); | |
d3fc6709 | 366 | aodRefs->AddAt(aodTrack, posFromV0); |
367 | ||
3e492e99 | 368 | if (esdTrack->GetSign() > 0) nPosTracks++; |
96b85d73 | 369 | aodTrack->ConvertAliPIDtoAODPID(); |
4fcd837c | 370 | aodTrack->SetFlags(esdTrack->GetStatus()); |
d7bdc804 | 371 | SetAODPID(esdTrack,aodTrack,detpid,timezero); |
96b85d73 | 372 | } |
373 | else { | |
374 | // cerr << "Error: event " << esd->GetEventNumberInFile() << " cascade " << nCascade | |
375 | // << " track " << posFromV0 << " has already been used!" << endl; | |
376 | } | |
377 | ||
378 | // Add the negative tracks from the V0 | |
379 | ||
380 | if (negFromV0>-1 && !usedTrack[negFromV0]) { | |
381 | ||
382 | usedTrack[negFromV0] = kTRUE; | |
383 | ||
384 | AliESDtrack *esdTrack = esd->GetTrack(negFromV0); | |
385 | esdTrack->GetPxPyPz(p_neg); | |
386 | esdTrack->GetXYZ(pos); | |
387 | esdTrack->GetCovarianceXYZPxPyPz(covTr); | |
388 | esdTrack->GetESDpid(pid); | |
fae68d32 | 389 | UInt_t selectInfo = 0; |
390 | if (fTrackFilter) selectInfo = fTrackFilter->IsSelected(esdTrack); | |
da97a08a | 391 | if(mcH)mcH->SelectParticle(esdTrack->GetLabel()); |
96b85d73 | 392 | vV0FromCascade->AddDaughter(aodTrack = |
393 | new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), | |
394 | esdTrack->GetLabel(), | |
395 | p_neg, | |
396 | kTRUE, | |
397 | pos, | |
398 | kFALSE, | |
399 | covTr, | |
400 | (Short_t)esdTrack->GetSign(), | |
401 | esdTrack->GetITSClusterMap(), | |
402 | pid, | |
403 | vV0FromCascade, | |
404 | kTRUE, // check if this is right | |
405 | kFALSE, // check if this is right | |
3de26c63 | 406 | AliAODTrack::kSecondary, |
407 | selectInfo) | |
408 | ); | |
d3fc6709 | 409 | aodRefs->AddAt(aodTrack, negFromV0); |
3de26c63 | 410 | |
3e492e99 | 411 | if (esdTrack->GetSign() > 0) nPosTracks++; |
96b85d73 | 412 | aodTrack->ConvertAliPIDtoAODPID(); |
4fcd837c | 413 | aodTrack->SetFlags(esdTrack->GetStatus()); |
d7bdc804 | 414 | SetAODPID(esdTrack,aodTrack,detpid,timezero); |
96b85d73 | 415 | } |
416 | else { | |
417 | // cerr << "Error: event " << esd->GetEventNumberInFile() << " cascade " << nCascade | |
418 | // << " track " << negFromV0 << " has already been used!" << endl; | |
419 | } | |
420 | ||
421 | // add it to the V0 array as well | |
422 | Double_t d0[2] = { -999., -99.}; | |
423 | // counting is probably wrong | |
424 | new(V0s[jV0s++]) AliAODv0(vV0FromCascade, -999., -99., p_pos, p_neg, d0); // to be refined | |
425 | ||
426 | // Add the bachelor track from the cascade | |
427 | ||
428 | Int_t bachelor = cascade->GetBindex(); | |
429 | ||
430 | if(bachelor>-1 && !usedTrack[bachelor]) { | |
431 | ||
432 | usedTrack[bachelor] = kTRUE; | |
433 | ||
434 | AliESDtrack *esdTrack = esd->GetTrack(bachelor); | |
435 | esdTrack->GetPxPyPz(p); | |
436 | esdTrack->GetXYZ(pos); | |
437 | esdTrack->GetCovarianceXYZPxPyPz(covTr); | |
438 | esdTrack->GetESDpid(pid); | |
fae68d32 | 439 | UInt_t selectInfo = 0; |
440 | if (fTrackFilter) selectInfo = fTrackFilter->IsSelected(esdTrack); | |
da97a08a | 441 | |
442 | if(mcH)mcH->SelectParticle(esdTrack->GetLabel()); | |
96b85d73 | 443 | vcascade->AddDaughter(aodTrack = |
444 | new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), | |
445 | esdTrack->GetLabel(), | |
446 | p, | |
447 | kTRUE, | |
448 | pos, | |
449 | kFALSE, | |
450 | covTr, | |
451 | (Short_t)esdTrack->GetSign(), | |
452 | esdTrack->GetITSClusterMap(), | |
453 | pid, | |
454 | vcascade, | |
455 | kTRUE, // check if this is right | |
456 | kFALSE, // check if this is right | |
3de26c63 | 457 | AliAODTrack::kSecondary, |
458 | selectInfo) | |
459 | ); | |
d3fc6709 | 460 | aodRefs->AddAt(aodTrack, bachelor); |
3e492e99 | 461 | if (esdTrack->GetSign() > 0) nPosTracks++; |
96b85d73 | 462 | aodTrack->ConvertAliPIDtoAODPID(); |
4fcd837c | 463 | aodTrack->SetFlags(esdTrack->GetStatus()); |
d7bdc804 | 464 | SetAODPID(esdTrack,aodTrack,detpid,timezero); |
96b85d73 | 465 | } |
466 | else { | |
467 | // cerr << "Error: event " << esd->GetEventNumberInFile() << " cascade " << nCascade | |
468 | // << " track " << bachelor << " has already been used!" << endl; | |
469 | } | |
470 | ||
471 | // Add the primary track of the cascade (if any) | |
472 | ||
473 | } // end of the loop on cascades | |
ec6465fe | 474 | |
475 | // | |
96b85d73 | 476 | // V0s |
ec6465fe | 477 | // |
96b85d73 | 478 | |
479 | for (Int_t nV0 = 0; nV0 < nV0s; ++nV0) { | |
480 | ||
7dd90a3c | 481 | if (usedV0[nV0]) continue; // skip if already added to the AOD |
96b85d73 | 482 | |
483 | AliESDv0 *v0 = esd->GetV0(nV0); | |
ec6465fe | 484 | Int_t posFromV0 = v0->GetPindex(); |
485 | Int_t negFromV0 = v0->GetNindex(); | |
486 | if (posFromV0 < 0 || negFromV0 < 0) continue; | |
487 | ||
488 | // V0 selection | |
489 | // | |
c12f1b16 | 490 | AliESDVertex *esdVtx = new AliESDVertex(*(esd->GetPrimaryVertex())); |
96b85d73 | 491 | |
ec6465fe | 492 | AliESDtrack *esdV0Pos = esd->GetTrack(posFromV0); |
493 | AliESDtrack *esdV0Neg = esd->GetTrack(negFromV0); | |
c12f1b16 | 494 | TList v0objects; |
ec6465fe | 495 | v0objects.AddAt(v0, 0); |
496 | v0objects.AddAt(esdV0Pos, 1); | |
497 | v0objects.AddAt(esdV0Neg, 2); | |
498 | v0objects.AddAt(esdVtx, 3); | |
499 | UInt_t selectV0 = 0; | |
500 | if (fV0Filter) { | |
396d2b33 | 501 | selectV0 = fV0Filter->IsSelected(&v0objects); |
c12f1b16 | 502 | // this is a little awkward but otherwise the |
503 | // list wants to access the pointer again when going out of scope | |
504 | delete v0objects.RemoveAt(3); | |
396d2b33 | 505 | if (!selectV0) |
506 | continue; | |
507 | } | |
508 | else{ | |
c12f1b16 | 509 | delete v0objects.RemoveAt(3); |
ec6465fe | 510 | } |
ec6465fe | 511 | |
96b85d73 | 512 | v0->GetXYZ(pos[0], pos[1], pos[2]); |
513 | ||
514 | if (!old) { | |
515 | chi2 = v0->GetChi2V0(); // = chi2/NDF since NDF = 2*2-3 | |
516 | v0->GetPosCov(covVtx); | |
517 | } else { | |
518 | chi2 = -999.; | |
519 | for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.; | |
520 | } | |
521 | ||
522 | ||
523 | AliAODVertex * vV0 = | |
524 | new(vertices[jVertices++]) AliAODVertex(pos, | |
525 | covVtx, | |
526 | chi2, | |
527 | primary, | |
528 | nV0, | |
529 | AliAODVertex::kV0); | |
530 | primary->AddDaughter(vV0); | |
531 | ||
7dd90a3c | 532 | |
533 | Float_t dcaPosToPrimVertexXYZ[2] = { 999., 999.}; // ..[0] = in XY plane and ..[1] = in Z | |
534 | Float_t dcaNegToPrimVertexXYZ[2] = { 999., 999.}; // ..[0] = in XY plane and ..[1] = in Z | |
535 | Double_t dcaDaughterToPrimVertex[2] = { 999., 999.}; // ..[0] = Pos and ..[1] = Neg | |
96b85d73 | 536 | |
7dd90a3c | 537 | Double_t dcaV0Daughters = v0->GetDcaV0Daughters(); |
538 | Double_t dcaV0ToPrimVertex = v0->GetD(); | |
539 | ||
8d69965b | 540 | v0->GetPPxPyPz(p_pos_atv0[0],p_pos_atv0[1],p_pos_atv0[2]); |
541 | v0->GetNPxPyPz(p_neg_atv0[0],p_neg_atv0[1],p_neg_atv0[2]); | |
7dd90a3c | 542 | |
96b85d73 | 543 | // Add the positive tracks from the V0 |
544 | ||
ec6465fe | 545 | |
546 | esdV0Pos->GetPxPyPz(p_pos); | |
547 | esdV0Pos->GetXYZ(pos); | |
548 | esdV0Pos->GetCovarianceXYZPxPyPz(covTr); | |
549 | esdV0Pos->GetESDpid(pid); | |
550 | esdV0Pos->GetImpactParameters(dcaPosToPrimVertexXYZ[0],dcaPosToPrimVertexXYZ[1]); | |
551 | if (!usedTrack[posFromV0]) { | |
96b85d73 | 552 | usedTrack[posFromV0] = kTRUE; |
fae68d32 | 553 | UInt_t selectInfo = 0; |
ec6465fe | 554 | if (fTrackFilter) selectInfo = fTrackFilter->IsSelected(esdV0Pos); |
da97a08a | 555 | if(mcH)mcH->SelectParticle(esdV0Pos->GetLabel()); |
ec6465fe | 556 | aodTrack = new(tracks[jTracks++]) AliAODTrack(esdV0Pos->GetID(), |
557 | esdV0Pos->GetLabel(), | |
8d69965b | 558 | p_pos, |
559 | kTRUE, | |
560 | pos, | |
561 | kFALSE, | |
562 | covTr, | |
ec6465fe | 563 | (Short_t)esdV0Pos->GetSign(), |
564 | esdV0Pos->GetITSClusterMap(), | |
8d69965b | 565 | pid, |
566 | vV0, | |
567 | kTRUE, // check if this is right | |
568 | kFALSE, // check if this is right | |
3de26c63 | 569 | AliAODTrack::kSecondary, |
570 | selectInfo); | |
d3fc6709 | 571 | aodRefs->AddAt(aodTrack,posFromV0); |
8d69965b | 572 | // if (fDebug > 0) printf("-------------------Bo: pos track from original pt %.3f \n",aodTrack->Pt()); |
ec6465fe | 573 | if (esdV0Pos->GetSign() > 0) nPosTracks++; |
96b85d73 | 574 | aodTrack->ConvertAliPIDtoAODPID(); |
ec6465fe | 575 | aodTrack->SetFlags(esdV0Pos->GetStatus()); |
576 | SetAODPID(esdV0Pos,aodTrack,detpid,timezero); | |
577 | } | |
578 | else { | |
d3fc6709 | 579 | aodTrack = dynamic_cast<AliAODTrack*>(aodRefs->At(posFromV0)); |
8d69965b | 580 | // if (fDebug > 0) printf("-------------------Bo pos track from refArray pt %.3f \n",aodTrack->Pt()); |
96b85d73 | 581 | } |
ec6465fe | 582 | vV0->AddDaughter(aodTrack); |
583 | ||
96b85d73 | 584 | // Add the negative tracks from the V0 |
585 | ||
ec6465fe | 586 | esdV0Neg->GetPxPyPz(p_neg); |
587 | esdV0Neg->GetXYZ(pos); | |
588 | esdV0Neg->GetCovarianceXYZPxPyPz(covTr); | |
589 | esdV0Neg->GetESDpid(pid); | |
590 | esdV0Neg->GetImpactParameters(dcaNegToPrimVertexXYZ[0],dcaNegToPrimVertexXYZ[1]); | |
591 | ||
592 | if (!usedTrack[negFromV0]) { | |
96b85d73 | 593 | usedTrack[negFromV0] = kTRUE; |
fae68d32 | 594 | UInt_t selectInfo = 0; |
ec6465fe | 595 | if (fTrackFilter) selectInfo = fTrackFilter->IsSelected(esdV0Neg); |
da97a08a | 596 | if(mcH)mcH->SelectParticle(esdV0Neg->GetLabel()); |
ec6465fe | 597 | aodTrack = new(tracks[jTracks++]) AliAODTrack(esdV0Neg->GetID(), |
598 | esdV0Neg->GetLabel(), | |
8d69965b | 599 | p_neg, |
600 | kTRUE, | |
601 | pos, | |
602 | kFALSE, | |
603 | covTr, | |
ec6465fe | 604 | (Short_t)esdV0Neg->GetSign(), |
605 | esdV0Neg->GetITSClusterMap(), | |
8d69965b | 606 | pid, |
607 | vV0, | |
608 | kTRUE, // check if this is right | |
609 | kFALSE, // check if this is right | |
3de26c63 | 610 | AliAODTrack::kSecondary, |
611 | selectInfo); | |
ec6465fe | 612 | |
d3fc6709 | 613 | aodRefs->AddAt(aodTrack,negFromV0); |
8d69965b | 614 | // if (fDebug > 0) printf("-------------------Bo: neg track from original pt %.3f \n",aodTrack->Pt()); |
ec6465fe | 615 | if (esdV0Neg->GetSign() > 0) nPosTracks++; |
96b85d73 | 616 | aodTrack->ConvertAliPIDtoAODPID(); |
ec6465fe | 617 | aodTrack->SetFlags(esdV0Neg->GetStatus()); |
618 | SetAODPID(esdV0Neg,aodTrack,detpid,timezero); | |
619 | } | |
620 | else { | |
d3fc6709 | 621 | aodTrack = dynamic_cast<AliAODTrack*>(aodRefs->At(negFromV0)); |
8d69965b | 622 | // if (fDebug > 0) printf("-------------------Bo neg track from refArray pt %.3f \n",aodTrack->Pt()); |
96b85d73 | 623 | } |
ec6465fe | 624 | vV0->AddDaughter(aodTrack); |
625 | dcaDaughterToPrimVertex[0] = | |
626 | TMath::Sqrt(dcaPosToPrimVertexXYZ[0]*dcaPosToPrimVertexXYZ[0] | |
627 | +dcaPosToPrimVertexXYZ[1]*dcaPosToPrimVertexXYZ[1]); | |
7dd90a3c | 628 | dcaDaughterToPrimVertex[1] = |
ec6465fe | 629 | TMath::Sqrt(dcaNegToPrimVertexXYZ[0]*dcaNegToPrimVertexXYZ[0] |
630 | +dcaNegToPrimVertexXYZ[1]*dcaNegToPrimVertexXYZ[1]); | |
96b85d73 | 631 | // add it to the V0 array as well |
7dd90a3c | 632 | aodV0 = new(V0s[jV0s++]) |
ec6465fe | 633 | AliAODv0(vV0, dcaV0Daughters, dcaV0ToPrimVertex, p_pos_atv0, p_neg_atv0, dcaDaughterToPrimVertex); // to be refined |
7dd90a3c | 634 | // set the aod v0 on-the-fly status |
635 | aodV0->SetOnFlyStatus(v0->GetOnFlyStatus()); | |
96b85d73 | 636 | } |
637 | V0s.Expand(jV0s); | |
638 | // end of the loop on V0s | |
639 | ||
640 | // Kinks: it is a big mess the access to the information in the kinks | |
641 | // The loop is on the tracks in order to find the mother and daugther of each kink | |
642 | ||
643 | ||
644 | for (Int_t iTrack=0; iTrack<nTracks; ++iTrack) { | |
645 | ||
646 | AliESDtrack * esdTrack = esd->GetTrack(iTrack); | |
647 | ||
648 | Int_t ikink = esdTrack->GetKinkIndex(0); | |
649 | ||
650 | if (ikink && nKinks) { | |
651 | // Negative kink index: mother, positive: daughter | |
652 | ||
653 | // Search for the second track of the kink | |
654 | ||
655 | for (Int_t jTrack = iTrack+1; jTrack<nTracks; ++jTrack) { | |
656 | ||
657 | AliESDtrack * esdTrack1 = esd->GetTrack(jTrack); | |
658 | ||
659 | Int_t jkink = esdTrack1->GetKinkIndex(0); | |
660 | ||
661 | if ( TMath::Abs(ikink)==TMath::Abs(jkink) ) { | |
662 | ||
663 | // The two tracks are from the same kink | |
664 | ||
665 | if (usedKink[TMath::Abs(ikink)-1]) continue; // skip used kinks | |
666 | ||
667 | Int_t imother = -1; | |
668 | Int_t idaughter = -1; | |
669 | ||
670 | if (ikink<0 && jkink>0) { | |
671 | ||
672 | imother = iTrack; | |
673 | idaughter = jTrack; | |
674 | } | |
675 | else if (ikink>0 && jkink<0) { | |
676 | ||
677 | imother = jTrack; | |
678 | idaughter = iTrack; | |
679 | } | |
680 | else { | |
681 | // cerr << "Error: Wrong combination of kink indexes: " | |
682 | // << ikink << " " << jkink << endl; | |
683 | continue; | |
684 | } | |
685 | ||
5dddb02b | 686 | // Add the mother track if it passed primary track selection cuts |
96b85d73 | 687 | |
688 | AliAODTrack * mother = NULL; | |
689 | ||
fae68d32 | 690 | UInt_t selectInfo = 0; |
691 | if (fTrackFilter) { | |
692 | selectInfo = fTrackFilter->IsSelected(esd->GetTrack(imother)); | |
693 | if (!selectInfo) continue; | |
694 | } | |
5dddb02b | 695 | |
96b85d73 | 696 | if (!usedTrack[imother]) { |
697 | ||
698 | usedTrack[imother] = kTRUE; | |
699 | ||
03a5cc9f | 700 | AliESDtrack *esdTrackM = esd->GetTrack(imother); |
701 | esdTrackM->GetPxPyPz(p); | |
702 | esdTrackM->GetXYZ(pos); | |
703 | esdTrackM->GetCovarianceXYZPxPyPz(covTr); | |
704 | esdTrackM->GetESDpid(pid); | |
da97a08a | 705 | if(mcH)mcH->SelectParticle(esdTrackM->GetLabel()); |
96b85d73 | 706 | mother = |
03a5cc9f | 707 | new(tracks[jTracks++]) AliAODTrack(esdTrackM->GetID(), |
708 | esdTrackM->GetLabel(), | |
96b85d73 | 709 | p, |
710 | kTRUE, | |
711 | pos, | |
712 | kFALSE, | |
713 | covTr, | |
03a5cc9f | 714 | (Short_t)esdTrackM->GetSign(), |
715 | esdTrackM->GetITSClusterMap(), | |
96b85d73 | 716 | pid, |
717 | primary, | |
718 | kTRUE, // check if this is right | |
719 | kTRUE, // check if this is right | |
3de26c63 | 720 | AliAODTrack::kPrimary, |
721 | selectInfo); | |
d3fc6709 | 722 | aodRefs->AddAt(mother, imother); |
723 | ||
03a5cc9f | 724 | if (esdTrackM->GetSign() > 0) nPosTracks++; |
725 | mother->SetFlags(esdTrackM->GetStatus()); | |
635ef56c | 726 | mother->ConvertAliPIDtoAODPID(); |
96b85d73 | 727 | primary->AddDaughter(mother); |
728 | mother->ConvertAliPIDtoAODPID(); | |
d7bdc804 | 729 | SetAODPID(esdTrackM,mother,detpid,timezero); |
96b85d73 | 730 | } |
731 | else { | |
732 | // cerr << "Error: event " << esd->GetEventNumberInFile() << " kink " << TMath::Abs(ikink)-1 | |
733 | // << " track " << imother << " has already been used!" << endl; | |
734 | } | |
735 | ||
736 | // Add the kink vertex | |
737 | AliESDkink * kink = esd->GetKink(TMath::Abs(ikink)-1); | |
738 | ||
739 | AliAODVertex * vkink = | |
740 | new(vertices[jVertices++]) AliAODVertex(kink->GetPosition(), | |
741 | NULL, | |
742 | 0., | |
743 | mother, | |
744 | esdTrack->GetID(), // This is the track ID of the mother's track! | |
745 | AliAODVertex::kKink); | |
746 | // Add the daughter track | |
747 | ||
748 | AliAODTrack * daughter = NULL; | |
749 | ||
750 | if (!usedTrack[idaughter]) { | |
751 | ||
752 | usedTrack[idaughter] = kTRUE; | |
753 | ||
03a5cc9f | 754 | AliESDtrack *esdTrackD = esd->GetTrack(idaughter); |
755 | esdTrackD->GetPxPyPz(p); | |
756 | esdTrackD->GetXYZ(pos); | |
757 | esdTrackD->GetCovarianceXYZPxPyPz(covTr); | |
758 | esdTrackD->GetESDpid(pid); | |
c12f1b16 | 759 | selectInfo = 0; |
fae68d32 | 760 | if (fTrackFilter) selectInfo = fTrackFilter->IsSelected(esdTrackD); |
da97a08a | 761 | if(mcH)mcH->SelectParticle(esdTrackD->GetLabel()); |
96b85d73 | 762 | daughter = |
03a5cc9f | 763 | new(tracks[jTracks++]) AliAODTrack(esdTrackD->GetID(), |
764 | esdTrackD->GetLabel(), | |
96b85d73 | 765 | p, |
766 | kTRUE, | |
767 | pos, | |
768 | kFALSE, | |
769 | covTr, | |
03a5cc9f | 770 | (Short_t)esdTrackD->GetSign(), |
771 | esdTrackD->GetITSClusterMap(), | |
96b85d73 | 772 | pid, |
773 | vkink, | |
774 | kTRUE, // check if this is right | |
775 | kTRUE, // check if this is right | |
3de26c63 | 776 | AliAODTrack::kSecondary, |
777 | selectInfo); | |
d3fc6709 | 778 | |
779 | aodRefs->AddAt(daughter, idaughter); | |
780 | ||
03a5cc9f | 781 | if (esdTrackD->GetSign() > 0) nPosTracks++; |
782 | daughter->SetFlags(esdTrackD->GetStatus()); | |
635ef56c | 783 | daughter->ConvertAliPIDtoAODPID(); |
96b85d73 | 784 | vkink->AddDaughter(daughter); |
785 | daughter->ConvertAliPIDtoAODPID(); | |
d7bdc804 | 786 | SetAODPID(esdTrackD,daughter,detpid,timezero); |
96b85d73 | 787 | } |
788 | else { | |
789 | // cerr << "Error: event " << esd->GetEventNumberInFile() << " kink " << TMath::Abs(ikink)-1 | |
790 | // << " track " << idaughter << " has already been used!" << endl; | |
791 | } | |
792 | } | |
793 | } | |
794 | } | |
795 | } | |
796 | ||
797 | ||
798 | // Tracks (primary and orphan) | |
799 | ||
3e492e99 | 800 | if (fDebug > 0) printf("NUMBER OF ESD TRACKS %5d\n", nTracks); |
96b85d73 | 801 | |
802 | for (Int_t nTrack = 0; nTrack < nTracks; ++nTrack) { | |
803 | ||
804 | ||
805 | if (usedTrack[nTrack]) continue; | |
806 | ||
807 | AliESDtrack *esdTrack = esd->GetTrack(nTrack); | |
808 | UInt_t selectInfo = 0; | |
809 | // | |
810 | // Track selection | |
811 | if (fTrackFilter) { | |
812 | selectInfo = fTrackFilter->IsSelected(esdTrack); | |
813 | if (!selectInfo) continue; | |
814 | } | |
815 | ||
816 | // | |
817 | esdTrack->GetPxPyPz(p); | |
818 | esdTrack->GetXYZ(pos); | |
819 | esdTrack->GetCovarianceXYZPxPyPz(covTr); | |
820 | esdTrack->GetESDpid(pid); | |
da97a08a | 821 | if(mcH)mcH->SelectParticle(esdTrack->GetLabel()); |
fae68d32 | 822 | primary->AddDaughter(aodTrack = |
823 | new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), | |
824 | esdTrack->GetLabel(), | |
825 | p, | |
826 | kTRUE, | |
827 | pos, | |
828 | kFALSE, | |
829 | covTr, | |
830 | (Short_t)esdTrack->GetSign(), | |
831 | esdTrack->GetITSClusterMap(), | |
832 | pid, | |
833 | primary, | |
834 | kTRUE, // check if this is right | |
835 | kTRUE, // check if this is right | |
836 | AliAODTrack::kPrimary, | |
837 | selectInfo) | |
da97a08a | 838 | ); |
d3fc6709 | 839 | aodRefs->AddAt(aodTrack, nTrack); |
840 | ||
fae68d32 | 841 | if (esdTrack->GetSign() > 0) nPosTracks++; |
842 | aodTrack->SetFlags(esdTrack->GetStatus()); | |
843 | aodTrack->ConvertAliPIDtoAODPID(); | |
844 | SetAODPID(esdTrack,aodTrack,detpid,timezero); | |
96b85d73 | 845 | } // end of loop on tracks |
846 | ||
3e492e99 | 847 | // Update number of AOD tracks in header at the end of track loop (M.G.) |
848 | header->SetRefMultiplicity(jTracks); | |
849 | header->SetRefMultiplicityPos(nPosTracks); | |
850 | header->SetRefMultiplicityNeg(jTracks - nPosTracks); | |
851 | if (fDebug > 0) | |
852 | printf(" NAODTRACKS=%d NPOS=%d NNEG=%d\n", jTracks, nPosTracks, jTracks - nPosTracks); | |
853 | // Do not shrink the array of tracks - other filters may add to it (M.G) | |
854 | // tracks.Expand(jTracks); // remove 'empty slots' due to unwritten tracks | |
96b85d73 | 855 | |
856 | // Access to the AOD container of PMD clusters | |
857 | TClonesArray &pmdClusters = *(AODEvent()->GetPmdClusters()); | |
858 | Int_t jPmdClusters=0; | |
859 | ||
860 | for (Int_t iPmd = 0; iPmd < nPmdClus; ++iPmd) { | |
861 | // file pmd clusters, to be revised! | |
862 | AliESDPmdTrack *pmdTrack = esd->GetPmdTrack(iPmd); | |
863 | Int_t nLabel = 0; | |
864 | Int_t *label = 0x0; | |
03a5cc9f | 865 | Double_t posPmd[3] = { pmdTrack->GetClusterX(), pmdTrack->GetClusterY(), pmdTrack->GetClusterZ()}; |
866 | Double_t pidPmd[9] = { 0., 0., 0., 0., 0., 0., 0., 0., 0. }; // to be revised! | |
96b85d73 | 867 | // type not set! |
868 | // assoc cluster not set | |
03a5cc9f | 869 | new(pmdClusters[jPmdClusters++]) AliAODPmdCluster(iPmd, nLabel, label, pmdTrack->GetClusterADC(), posPmd, pidPmd); |
96b85d73 | 870 | } |
871 | ||
872 | // Access to the AOD container of clusters | |
873 | TClonesArray &caloClusters = *(AODEvent()->GetCaloClusters()); | |
874 | Int_t jClusters=0; | |
875 | ||
876 | for (Int_t iClust=0; iClust<nCaloClus; ++iClust) { | |
877 | ||
878 | AliESDCaloCluster * cluster = esd->GetCaloCluster(iClust); | |
879 | ||
e6500713 | 880 | Int_t id = cluster->GetID(); |
881 | Int_t nLabel = cluster->GetNLabels(); | |
882 | TArrayI* labels = cluster->GetLabels(); | |
883 | Int_t *label = 0; | |
da97a08a | 884 | if (labels){ |
885 | label = (cluster->GetLabels())->GetArray(); | |
886 | for(int i = 0;i < labels->GetSize();++i){ | |
887 | if(mcH)mcH->SelectParticle(label[i]); | |
888 | } | |
889 | } | |
e6500713 | 890 | |
96b85d73 | 891 | Float_t energy = cluster->E(); |
892 | cluster->GetPosition(posF); | |
e6500713 | 893 | Char_t ttype = AliAODCluster::kUndef; |
96b85d73 | 894 | |
895 | if (cluster->GetClusterType() == AliESDCaloCluster::kPHOSCluster) { | |
896 | ttype=AliAODCluster::kPHOSNeutral; | |
897 | } | |
898 | else if (cluster->GetClusterType() == AliESDCaloCluster::kEMCALClusterv1) { | |
899 | ttype = AliAODCluster::kEMCALClusterv1; | |
900 | } | |
901 | ||
902 | ||
903 | AliAODCaloCluster *caloCluster = new(caloClusters[jClusters++]) AliAODCaloCluster(id, | |
904 | nLabel, | |
905 | label, | |
906 | energy, | |
636555d2 | 907 | posF, |
96b85d73 | 908 | NULL, |
909 | ttype); | |
910 | ||
e6500713 | 911 | caloCluster->SetCaloCluster(cluster->GetDistanceToBadChannel(), |
912 | cluster->GetClusterDisp(), | |
78902954 | 913 | cluster->GetM20(), cluster->GetM02(), |
914 | cluster->GetEmcCpvDistance(), | |
915 | cluster->GetNExMax(),cluster->GetTOF()) ; | |
e6500713 | 916 | |
3cbe9a4d | 917 | caloCluster->SetPIDFromESD(cluster->GetPid()); |
e6500713 | 918 | caloCluster->SetNCells(cluster->GetNCells()); |
919 | caloCluster->SetCellsAbsId(cluster->GetCellsAbsId()); | |
920 | caloCluster->SetCellsAmplitudeFraction(cluster->GetCellsAmplitudeFraction()); | |
78902954 | 921 | |
922 | TArrayI* matchedT = cluster->GetTracksMatched(); | |
cb234979 | 923 | if (matchedT && cluster->GetTrackMatched() >= 0) { |
78902954 | 924 | for (Int_t im = 0; im < matchedT->GetSize(); im++) { |
d3fc6709 | 925 | Int_t iESDtrack = matchedT->At(im);; |
926 | if (aodRefs->At(iESDtrack) != 0) { | |
927 | caloCluster->AddTrackMatched((AliAODTrack*)aodRefs->At(iESDtrack)); | |
928 | } | |
78902954 | 929 | } |
930 | } | |
d3fc6709 | 931 | |
96b85d73 | 932 | } |
933 | caloClusters.Expand(jClusters); // resize TObjArray to 'remove' slots for pseudo clusters | |
934 | // end of loop on calo clusters | |
935 | ||
936 | // fill EMCAL cell info | |
937 | if (esd->GetEMCALCells()) { // protection against missing ESD information | |
938 | AliESDCaloCells &esdEMcells = *(esd->GetEMCALCells()); | |
939 | Int_t nEMcell = esdEMcells.GetNumberOfCells() ; | |
940 | ||
941 | AliAODCaloCells &aodEMcells = *(AODEvent()->GetEMCALCells()); | |
942 | aodEMcells.CreateContainer(nEMcell); | |
943 | aodEMcells.SetType(AliAODCaloCells::kEMCAL); | |
944 | for (Int_t iCell = 0; iCell < nEMcell; iCell++) { | |
945 | aodEMcells.SetCell(iCell,esdEMcells.GetCellNumber(iCell),esdEMcells.GetAmplitude(iCell)); | |
946 | } | |
947 | aodEMcells.Sort(); | |
948 | } | |
949 | ||
950 | // fill PHOS cell info | |
951 | if (esd->GetPHOSCells()) { // protection against missing ESD information | |
952 | AliESDCaloCells &esdPHcells = *(esd->GetPHOSCells()); | |
953 | Int_t nPHcell = esdPHcells.GetNumberOfCells() ; | |
954 | ||
955 | AliAODCaloCells &aodPHcells = *(AODEvent()->GetPHOSCells()); | |
956 | aodPHcells.CreateContainer(nPHcell); | |
957 | aodPHcells.SetType(AliAODCaloCells::kPHOS); | |
958 | for (Int_t iCell = 0; iCell < nPHcell; iCell++) { | |
959 | aodPHcells.SetCell(iCell,esdPHcells.GetCellNumber(iCell),esdPHcells.GetAmplitude(iCell)); | |
960 | } | |
961 | aodPHcells.Sort(); | |
962 | } | |
963 | ||
964 | // tracklets | |
965 | AliAODTracklets &SPDTracklets = *(AODEvent()->GetTracklets()); | |
966 | const AliMultiplicity *mult = esd->GetMultiplicity(); | |
967 | if (mult) { | |
968 | if (mult->GetNumberOfTracklets()>0) { | |
969 | SPDTracklets.CreateContainer(mult->GetNumberOfTracklets()); | |
970 | ||
971 | for (Int_t n=0; n<mult->GetNumberOfTracklets(); n++) { | |
da97a08a | 972 | if(mcH){ |
973 | mcH->SelectParticle(mult->GetLabel(n, 0)); | |
974 | mcH->SelectParticle(mult->GetLabel(n, 1)); | |
975 | } | |
976 | SPDTracklets.SetTracklet(n, mult->GetTheta(n), mult->GetPhi(n), mult->GetDeltaPhi(n), mult->GetLabel(n, 0),mult->GetLabel(n, 1)); | |
96b85d73 | 977 | } |
978 | } | |
979 | } else { | |
980 | //Printf("ERROR: AliMultiplicity could not be retrieved from ESD"); | |
981 | } | |
982 | ||
983 | delete [] usedTrack; | |
984 | delete [] usedV0; | |
985 | delete [] usedKink; | |
d3fc6709 | 986 | delete aodRefs; |
96b85d73 | 987 | |
988 | return; | |
989 | } | |
990 | ||
7b4cee8d | 991 | |
d7bdc804 | 992 | void AliAnalysisTaskESDfilter::SetAODPID(AliESDtrack *esdtrack, AliAODTrack *aodtrack, AliAODPid *detpid, Double_t timezero) |
993 | { | |
994 | // | |
995 | // Setter for the raw PID detector signals | |
996 | // | |
997 | ||
998 | if(esdtrack->Pt()>fHighPthreshold) { | |
999 | detpid = new AliAODPid(); | |
373fc041 | 1000 | SetDetectorRawSignals(detpid,esdtrack,timezero); |
d7bdc804 | 1001 | aodtrack->SetDetPID(detpid); |
1002 | } else { | |
1003 | if(fPtshape){ | |
1004 | if(esdtrack->Pt()> fPtshape->GetXmin()){ | |
1005 | Double_t y = fPtshape->Eval(esdtrack->Pt())/fPtshape->Eval(fHighPthreshold); | |
1006 | if(gRandom->Rndm(0)<1./y){ | |
1007 | detpid = new AliAODPid(); | |
373fc041 | 1008 | SetDetectorRawSignals(detpid,esdtrack,timezero); |
d7bdc804 | 1009 | aodtrack->SetDetPID(detpid); |
1010 | }//end rndm | |
1011 | }//end if p < pmin | |
1012 | }//end if p function | |
1013 | }// end else | |
1014 | } | |
1015 | ||
373fc041 | 1016 | void AliAnalysisTaskESDfilter::SetDetectorRawSignals(AliAODPid *aodpid, AliESDtrack *track, Double_t timezero) |
1017 | { | |
1018 | // | |
1019 | //assignment of the detector signals (AliXXXesdPID inspired) | |
1020 | // | |
1021 | if(!track){ | |
1022 | AliInfo("no ESD track found. .....exiting"); | |
1023 | return; | |
1024 | } | |
1025 | ||
1026 | aodpid->SetITSsignal(track->GetITSsignal()); | |
1027 | aodpid->SetTPCsignal(track->GetTPCsignal()); | |
1028 | //n TRD planes = 6 | |
1029 | ||
1030 | Int_t nslices = track->GetNumberOfTRDslices()*6; | |
1031 | Double_t *trdslices = new Double_t[nslices]; | |
1032 | for(Int_t iSl =0; iSl < track->GetNumberOfTRDslices(); iSl++) { | |
1033 | for(Int_t iPl =0; iPl<6; iPl++) trdslices[iPl*track->GetNumberOfTRDslices()+iSl] = track->GetTRDslice(iPl,iSl); | |
1034 | } | |
d7bdc804 | 1035 | |
373fc041 | 1036 | |
1037 | aodpid->SetTRDsignal(track->GetNumberOfTRDslices()*6,trdslices); | |
1038 | Double_t times[AliAODPid::kSPECIES]; track->GetIntegratedTimes(times); | |
1039 | aodpid->SetIntegratedTimes(times); | |
1040 | ||
1041 | aodpid->SetTOFsignal(track->GetTOFsignal()-timezero); // to be fixed | |
1042 | aodpid->SetHMPIDsignal(track->GetHMPIDsignal()); | |
1043 | ||
1044 | } | |
7b4cee8d | 1045 | |
96b85d73 | 1046 | void AliAnalysisTaskESDfilter::Terminate(Option_t */*option*/) |
1047 | { | |
1048 | // Terminate analysis | |
1049 | // | |
1050 | if (fDebug > 1) printf("AnalysisESDfilter: Terminate() \n"); | |
1051 | } | |
1052 | ||
da97a08a | 1053 | void AliAnalysisTaskESDfilter::PrintMCInfo(AliStack *pStack,Int_t label){ |
1054 | if(!pStack)return; | |
1055 | label = TMath::Abs(label); | |
1056 | TParticle *part = pStack->Particle(label); | |
1057 | Printf("########################"); | |
1058 | Printf("%s:%d %d UniqueID %d PDG %d P %3.3f",(char*)__FILE__,__LINE__,label,part->GetUniqueID(),part->GetPdgCode(),part->P()); | |
1059 | part->Print(); | |
1060 | TParticle* mother = part; | |
1061 | Int_t imo = part->GetFirstMother(); | |
1062 | Int_t nprim = pStack->GetNprimary(); | |
1063 | // while((imo >= nprim) && (mother->GetUniqueID() == 4)) { | |
1064 | while((imo >= nprim)) { | |
1065 | mother = pStack->Particle(imo); | |
1066 | Printf("Mother %s:%d Label %d UniqueID %d PDG %d P %3.3f",(char*)__FILE__,__LINE__,imo,mother->GetUniqueID(),mother->GetPdgCode(),mother->P()); | |
1067 | mother->Print(); | |
1068 | imo = mother->GetFirstMother(); | |
1069 | } | |
1070 | Printf("########################"); | |
1071 | } |