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