Added methods for finding a given module in the DDL map (F. Prino)
[u/mrichter/AliRoot.git] / STEER / AliESD.cxx
CommitLineData
8a8d023f 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
acd84897 16/* $Id$ */
8a8d023f 17
ae982df3 18//-----------------------------------------------------------------
19// Implementation of the ESD class
20// This is the class to deal with during the phisical analysis of data
af7ba10c 21// This class is generated directly by the reconstruction methods
ae982df3 22// Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
23//-----------------------------------------------------------------
8a8d023f 24
b545009a 25#include "AliESD.h"
26#include "AliESDfriend.h"
53203d32 27
28ClassImp(AliESD)
29
30//______________________________________________________________________________
31AliESD::AliESD():
af885e0f 32 fEventNumberInFile(0),
33 fBunchCrossNumber(0),
34 fOrbitNumber(0),
35 fPeriodNumber(0),
36 fRunNumber(0),
37 fTimeStamp(0),
38 fEventType(0),
39 fTriggerMask(0),
40 fTriggerCluster(0),
41 fRecoVersion(0),
42 fMagneticField(0),
43 fZDCN1Energy(0),
44 fZDCP1Energy(0),
45 fZDCN2Energy(0),
46 fZDCP2Energy(0),
47 fZDCEMEnergy(0),
48 fZDCParticipants(0),
49 fT0zVertex(0),
50 fSPDVertex(),
51 fPrimaryVertex(),
52 fSPDMult(),
53 fT0timeStart(0),
54 fTracks("AliESDtrack",15000),
55 fHLTConfMapTracks("AliESDHLTtrack",25000),
56 fHLTHoughTracks("AliESDHLTtrack",15000),
57 fMuonTracks("AliESDMuonTrack",30),
58 fPmdTracks("AliESDPmdTrack",3000),
59 fTrdTracks("AliESDTrdTrack",300),
60 fV0s("AliESDv0",200),
61 fCascades("AliESDcascade",20),
62 fKinks("AliESDkink",4000),
63 fCaloClusters("AliESDCaloCluster",10000),
85c60a8e 64 fEMCALClusters(0),
65 fFirstEMCALCluster(-1),
af885e0f 66 fEMCALTriggerPosition(0x0),
67 fEMCALTriggerAmplitudes(0x0),
85c60a8e 68 fPHOSClusters(0),
af885e0f 69 fFirstPHOSCluster(-1),
70 fPHOSTriggerPosition(0x0),
71 fPHOSTriggerAmplitudes(0x0),
72 fESDFMD(0x0),
73 fESDVZERO(0x0),
74 fErrorLogs("AliRawDataErrorLog",5)
9da38871 75{
6989bff3 76 //
77 // Standar constructor
78 //
79
af885e0f 80 for (Int_t i=0; i<24; i++) {
81 fT0time[i] = 0;
82 fT0amplitude[i] = 0;
83 }
84 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
85 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=0.;
873f1f73 86}
e149da78 87
c028b974 88//______________________________________________________________________________
89AliESD::AliESD(const AliESD& esd):
90 TObject(esd),
af885e0f 91 fEventNumberInFile(esd.fEventNumberInFile),
92 fBunchCrossNumber(esd.fBunchCrossNumber),
93 fOrbitNumber(esd.fOrbitNumber),
94 fPeriodNumber(esd.fPeriodNumber),
95 fRunNumber(esd.fRunNumber),
96 fTimeStamp(esd.fTimeStamp),
97 fEventType(esd.fEventType),
98 fTriggerMask(esd.fTriggerMask),
99 fTriggerCluster(esd.fTriggerCluster),
100 fRecoVersion(esd.fRecoVersion),
101 fMagneticField(esd.fMagneticField),
102 fZDCN1Energy(esd.fZDCN1Energy),
103 fZDCP1Energy(esd.fZDCP1Energy),
104 fZDCN2Energy(esd.fZDCN2Energy),
105 fZDCP2Energy(esd.fZDCP2Energy),
106 fZDCEMEnergy(esd.fZDCEMEnergy),
107 fZDCParticipants(esd.fZDCParticipants),
108 fT0zVertex(esd.fT0zVertex),
109 fSPDVertex(esd.fSPDVertex),
110 fPrimaryVertex(esd.fPrimaryVertex),
111 fSPDMult(esd.fSPDMult),
112 fT0timeStart(esd.fT0timeStart),
113 fTracks(*((TClonesArray*)esd.fTracks.Clone())),
114 fHLTConfMapTracks(*((TClonesArray*)esd.fHLTConfMapTracks.Clone())),
115 fHLTHoughTracks(*((TClonesArray*)esd.fHLTHoughTracks.Clone())),
116 fMuonTracks(*((TClonesArray*)esd.fMuonTracks.Clone())),
117 fPmdTracks(*((TClonesArray*)esd.fPmdTracks.Clone())),
118 fTrdTracks(*((TClonesArray*)esd.fTrdTracks.Clone())),
119 fV0s(*((TClonesArray*)esd.fV0s.Clone())),
120 fCascades(*((TClonesArray*)esd.fCascades.Clone())),
121 fKinks(*((TClonesArray*)esd.fKinks.Clone())),
122 fCaloClusters(*((TClonesArray*)esd.fCaloClusters.Clone())),
c028b974 123 fEMCALClusters(esd.fEMCALClusters),
124 fFirstEMCALCluster(esd.fFirstEMCALCluster),
af885e0f 125 fEMCALTriggerPosition(esd. fEMCALTriggerPosition),
126 fEMCALTriggerAmplitudes(esd.fEMCALTriggerAmplitudes),
c028b974 127 fPHOSClusters(esd.fPHOSClusters),
af885e0f 128 fFirstPHOSCluster(esd.fFirstPHOSCluster),
129 fPHOSTriggerPosition(esd.fPHOSTriggerPosition),
130 fPHOSTriggerAmplitudes(esd.fPHOSTriggerAmplitudes),
131 fESDFMD(esd.fESDFMD),
132 fESDVZERO(esd.fESDVZERO),
133 fErrorLogs(*((TClonesArray*)esd.fErrorLogs.Clone()))
c028b974 134{
6989bff3 135 //
136 // copy constructor
137 //
af885e0f 138 for (Int_t i=0; i<24; i++) {
139 fT0time[i] = esd.fT0time[i];
140 fT0amplitude[i] = esd.fT0amplitude[i];
141 }
142 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
143 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
c028b974 144}
145
fe12e09c 146//______________________________________________________________________________
af7ba10c 147AliESD::~AliESD()
148{
149 //
150 // Standard destructor
151 //
af885e0f 152 fTracks.Delete();
8bbc564d 153 fHLTConfMapTracks.Delete();
154 fHLTHoughTracks.Delete();
af885e0f 155 fMuonTracks.Delete();
af7ba10c 156 fPmdTracks.Delete();
0ee00e25 157 fTrdTracks.Delete();
af7ba10c 158 fV0s.Delete();
159 fCascades.Delete();
51ad6848 160 fKinks.Delete();
85c60a8e 161 fCaloClusters.Delete();
af885e0f 162 delete fESDFMD;
163 delete fESDVZERO;
6989bff3 164 delete fEMCALTriggerPosition;
165 delete fEMCALTriggerAmplitudes;
166 delete fPHOSTriggerPosition;
167 delete fPHOSTriggerAmplitudes;
168
af885e0f 169 fErrorLogs.Delete();
64df000d 170
51ad6848 171}
172
bf25155c 173//______________________________________________________________________________
174void AliESD::Reset()
175{
6989bff3 176 //
177 // Reset the contents and delete the entries in TClonesArrays
178 //
179
af885e0f 180 fEventNumberInFile=0;
181 fBunchCrossNumber=0;
182 fOrbitNumber=0;
183 fPeriodNumber=0;
184 fRunNumber=0;
185 fTimeStamp = 0;
186 fEventType = 0;
187 fTriggerMask=0;
188 fTriggerCluster=0;
189 fRecoVersion=0;
190 fMagneticField=0;
191 fZDCN1Energy=0;
192 fZDCP1Energy=0;
193 fZDCN2Energy=0;
194 fZDCP2Energy=0;
195 fZDCEMEnergy=0;
196 fZDCParticipants=0;
197 fT0zVertex=0;
5a2b4ee8 198
6989bff3 199 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
200 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=0.;
5a2b4ee8 201
6989bff3 202 for (Int_t i=0; i<24; i++) {
203 fT0time[i] = 0;
204 fT0amplitude[i] = 0;
205 }
206 fT0timeStart = 0;
5a2b4ee8 207//
208 fSPDMult.~AliMultiplicity();
209 new (&fSPDMult) AliMultiplicity();
210 fSPDVertex.~AliESDVertex();
211 new (&fSPDVertex) AliESDVertex();
212 fPrimaryVertex.~AliESDVertex();
213 new (&fPrimaryVertex) AliESDVertex();
214//
6989bff3 215 fTracks.Delete();
216 fHLTConfMapTracks.Delete();
217 fHLTHoughTracks.Delete();
218 fMuonTracks.Delete();
219 fPmdTracks.Delete();
220 fTrdTracks.Delete();
221 fV0s.Delete();
222 fCascades.Delete();
5a2b4ee8 223 fKinks.Delete();
6989bff3 224 fCaloClusters.Delete();
5a2b4ee8 225//
85c60a8e 226 fEMCALClusters=0;
227 fFirstEMCALCluster=-1;
228 fPHOSClusters=0;
229 fFirstPHOSCluster=-1;
5a2b4ee8 230//
231 if (fEMCALTriggerPosition) fEMCALTriggerPosition ->Reset();
232 if (fEMCALTriggerAmplitudes) fEMCALTriggerAmplitudes->Reset();
233 if (fPHOSTriggerPosition) fPHOSTriggerPosition ->Reset();
234 if (fPHOSTriggerAmplitudes) fPHOSTriggerAmplitudes ->Reset();
235//
af885e0f 236 if (fESDFMD) fESDFMD->Clear();
5a2b4ee8 237//
6989bff3 238 if (fESDVZERO){
5a2b4ee8 239 fESDVZERO->~AliESDVZERO();
240 new (fESDVZERO) AliESDVZERO();
6989bff3 241 }
5a2b4ee8 242//
6989bff3 243 fErrorLogs.Delete();
bf25155c 244}
af7ba10c 245
a023d8d8 246
247Bool_t AliESD::RemoveKink(Int_t rm) {
248 // ---------------------------------------------------------
249 // Remove a kink candidate and references to it from ESD,
250 // if this candidate does not come from a reconstructed decay
251 // Not yet implemented...
252 // ---------------------------------------------------------
253 Int_t last=GetNumberOfKinks()-1;
254 if ((rm<0)||(rm>last)) return kFALSE;
255
256 return kTRUE;
257}
258
259Bool_t AliESD::RemoveV0(Int_t rm) {
260 // ---------------------------------------------------------
261 // Remove a V0 candidate and references to it from ESD,
262 // if this candidate does not come from a reconstructed decay
263 // ---------------------------------------------------------
264 Int_t last=GetNumberOfV0s()-1;
265 if ((rm<0)||(rm>last)) return kFALSE;
266
267 AliESDv0 *v0=GetV0(rm);
268 Int_t idxP=v0->GetPindex(), idxN=v0->GetNindex();
269
270 v0=GetV0(last);
271 Int_t lastIdxP=v0->GetPindex(), lastIdxN=v0->GetNindex();
272
273 Int_t used=0;
274
275 // Check if this V0 comes from a reconstructed decay
276 Int_t ncs=GetNumberOfCascades();
277 for (Int_t n=0; n<ncs; n++) {
278 AliESDcascade *cs=GetCascade(n);
279
280 Int_t csIdxP=cs->GetPindex();
281 Int_t csIdxN=cs->GetNindex();
282
283 if (idxP==csIdxP)
284 if (idxN==csIdxN) return kFALSE;
285
286 if (csIdxP==lastIdxP)
287 if (csIdxN==lastIdxN) used++;
288 }
289
290 //Replace the removed V0 with the last V0
291 TClonesArray &a=fV0s;
292 delete a.RemoveAt(rm);
293
294 if (rm==last) return kTRUE;
295
296 //v0 is pointing to the last V0 candidate...
297 new (a[rm]) AliESDv0(*v0);
298 delete a.RemoveAt(last);
299
300 if (!used) return kTRUE;
301
302
303 // Remap the indices of the daughters of reconstructed decays
304 for (Int_t n=0; n<ncs; n++) {
305 AliESDcascade *cs=GetCascade(n);
306
307
308 Int_t csIdxP=cs->GetPindex();
309 Int_t csIdxN=cs->GetNindex();
310
311 if (csIdxP==lastIdxP)
312 if (csIdxN==lastIdxN) {
313 cs->AliESDv0::SetIndex(1,idxP);
314 cs->AliESDv0::SetIndex(0,idxN);
315 used--;
316 if (!used) return kTRUE;
317 }
318 }
319
320 return kTRUE;
321}
322
7f68891d 323Bool_t AliESD::RemoveTrack(Int_t rm) {
d64bd07d 324 // ---------------------------------------------------------
7f68891d 325 // Remove a track and references to it from ESD,
326 // if this track does not come from a reconstructed decay
d64bd07d 327 // ---------------------------------------------------------
7f68891d 328 Int_t last=GetNumberOfTracks()-1;
329 if ((rm<0)||(rm>last)) return kFALSE;
330
331 Int_t used=0;
d64bd07d 332
333 // Check if this track comes from a reconstructed decay
7f68891d 334 Int_t nv0=GetNumberOfV0s();
335 for (Int_t n=0; n<nv0; n++) {
336 AliESDv0 *v0=GetV0(n);
337
338 Int_t idx=v0->GetNindex();
339 if (rm==idx) return kFALSE;
340 if (idx==last) used++;
341
342 idx=v0->GetPindex();
343 if (rm==idx) return kFALSE;
344 if (idx==last) used++;
345 }
d64bd07d 346
7f68891d 347 Int_t ncs=GetNumberOfCascades();
348 for (Int_t n=0; n<ncs; n++) {
349 AliESDcascade *cs=GetCascade(n);
d64bd07d 350
7f68891d 351 Int_t idx=cs->GetIndex();
352 if (rm==idx) return kFALSE;
353 if (idx==last) used++;
354 }
355
356 Int_t nkn=GetNumberOfKinks();
357 for (Int_t n=0; n<nkn; n++) {
358 AliESDkink *kn=GetKink(n);
d64bd07d 359
7f68891d 360 Int_t idx=kn->GetIndex(0);
361 if (rm==idx) return kFALSE;
362 if (idx==last) used++;
363
364 idx=kn->GetIndex(1);
365 if (rm==idx) return kFALSE;
366 if (idx==last) used++;
367 }
368
369
370 //Replace the removed track with the last track
371 TClonesArray &a=fTracks;
372 delete a.RemoveAt(rm);
373
374 if (rm==last) return kTRUE;
375
376 AliESDtrack *t=GetTrack(last);
377 t->SetID(rm);
378 new (a[rm]) AliESDtrack(*t);
379 delete a.RemoveAt(last);
380
381 if (!used) return kTRUE;
7f68891d 382
a023d8d8 383
7f68891d 384 // Remap the indices of the daughters of reconstructed decays
385 for (Int_t n=0; n<nv0; n++) {
386 AliESDv0 *v0=GetV0(n);
387 if (v0->GetIndex(0)==last) {
388 v0->SetIndex(0,rm);
389 used--;
390 if (!used) return kTRUE;
391 }
392 if (v0->GetIndex(1)==last) {
393 v0->SetIndex(1,rm);
394 used--;
395 if (!used) return kTRUE;
396 }
397 }
398
399 for (Int_t n=0; n<ncs; n++) {
400 AliESDcascade *cs=GetCascade(n);
401 if (cs->GetIndex()==last) {
402 cs->SetIndex(rm);
403 used--;
404 if (!used) return kTRUE;
405 }
406 }
407
408 for (Int_t n=0; n<nkn; n++) {
409 AliESDkink *kn=GetKink(n);
410 if (kn->GetIndex(0)==last) {
411 kn->SetIndex(rm,0);
412 used--;
413 if (!used) return kTRUE;
414 }
415 if (kn->GetIndex(1)==last) {
416 kn->SetIndex(rm,1);
417 used--;
418 if (!used) return kTRUE;
419 }
420 }
d64bd07d 421
422 return kTRUE;
423}
424
a023d8d8 425
7f68891d 426Bool_t AliESD::Clean(Float_t *cleanPars) {
427 //
428 // Remove the data which are not needed for the physics analysis.
429 //
a023d8d8 430 // 1) Cleaning the V0 candidates
431 // ---------------------------
432 // If the cosine of the V0 pointing angle "csp" and
433 // the DCA between the daughter tracks "dca" does not satisfy
434 // the conditions
435 //
436 // csp > cleanPars[1] + dca/cleanPars[0]*(1.- cleanPars[1])
437 //
438 // an attempt to remove this V0 candidate from ESD is made.
439 //
440 // The V0 candidate gets removed if it does not belong to any
441 // recosntructed cascade decay
442 //
443 // 12.11.2007, optimal values: cleanPars[0]=0.5, cleanPars[1]=0.999
444 //
445 // 2) Cleaning the tracks
446 // ----------------------
447 // If track's transverse parameter is larger than cleanPars[2]
7f68891d 448 // OR
a023d8d8 449 // track's longitudinal parameter is larger than cleanPars[3]
450 // an attempt to remove this track from ESD is made.
7f68891d 451 //
a023d8d8 452 // The track gets removed if it does not come
453 // from a reconstructed decay
7f68891d 454 //
a023d8d8 455 Bool_t rc=kFALSE;
456
457 Float_t dcaMax=cleanPars[0];
458 Float_t cspMin=cleanPars[1];
459
460 Int_t nV0s=GetNumberOfV0s();
461 for (Int_t i=nV0s-1; i>=0; i--) {
462 AliESDv0 *v0=GetV0(i);
463
464 Float_t dca=v0->GetDcaV0Daughters();
465 Float_t csp=v0->GetV0CosineOfPointingAngle();
466 Float_t cspcut=cspMin + dca/dcaMax*(1.-cspMin);
467 if (csp > cspcut) continue;
468
469 if (RemoveV0(i)) rc=kTRUE;
470 }
471
7f68891d 472
a023d8d8 473 Float_t dmax=cleanPars[2], zmax=cleanPars[3];
7f68891d 474
475 const AliESDVertex *vertex=GetVertex();
a023d8d8 476 Bool_t vtxOK=vertex->GetStatus();
7f68891d 477
478 Int_t nTracks=GetNumberOfTracks();
479 for (Int_t i=nTracks-1; i>=0; i--) {
480 AliESDtrack *track=GetTrack(i);
481 Float_t xy,z; track->GetImpactParameters(xy,z);
482 if ((TMath::Abs(xy) > dmax) || (vtxOK && (TMath::Abs(z) > zmax))) {
483 if (RemoveTrack(i)) rc=kTRUE;
484 }
485 }
486
487 return rc;
488}
489
d6a49f20 490Int_t AliESD::AddV0(const AliESDv0 *v) {
491 //
492 // Add V0
493 //
af885e0f 494 Int_t idx=fV0s.GetEntriesFast();
495 new(fV0s[idx]) AliESDv0(*v);
496 return idx;
d6a49f20 497}
498
af7ba10c 499//______________________________________________________________________________
500void AliESD::Print(Option_t *) const
501{
502 //
503 // Print header information of the event
504 //
5f7789fc 505 printf("ESD run information\n");
4d422cad 506 printf("Event # in file %d Bunch crossing # %d Orbit # %d Period # %d Run # %d Trigger %lld Magnetic field %f \n",
31fd97b2 507 GetEventNumberInFile(),
508 GetBunchCrossNumber(),
509 GetOrbitNumber(),
4d422cad 510 GetPeriodNumber(),
ef278eae 511 GetRunNumber(),
b647652d 512 GetTriggerMask(),
ef278eae 513 GetMagneticField() );
af885e0f 514 printf("Vertex: (%.4f +- %.4f, %.4f +- %.4f, %.4f +- %.4f) cm\n",
515 fPrimaryVertex.GetXv(), fPrimaryVertex.GetXRes(),
516 fPrimaryVertex.GetYv(), fPrimaryVertex.GetYRes(),
517 fPrimaryVertex.GetZv(), fPrimaryVertex.GetZRes());
9f57c1aa 518 printf("Mean vertex in RUN: X=%.4f Y=%.4f cm\n",
519 GetDiamondX(),GetDiamondY());
32e449be 520 printf("SPD Multiplicity. Number of tracklets %d \n",
af885e0f 521 fSPDMult.GetNumberOfTracklets());
522 printf("Event from reconstruction version %d \n",fRecoVersion);
ef278eae 523 printf("Number of tracks: \n");
85c60a8e 524 printf(" charged %d\n", GetNumberOfTracks());
af885e0f 525 printf(" hlt CF %d\n", GetNumberOfHLTConfMapTracks());
526 printf(" hlt HT %d\n", GetNumberOfHLTHoughTracks());
ef278eae 527 printf(" muon %d\n", GetNumberOfMuonTracks());
a2882fb4 528 printf(" pmd %d\n", GetNumberOfPmdTracks());
0ee00e25 529 printf(" trd %d\n", GetNumberOfTrdTracks());
ef278eae 530 printf(" v0 %d\n", GetNumberOfV0s());
667ee8bf 531 printf(" cascades %d\n", GetNumberOfCascades());
532 printf(" kinks %d\n", GetNumberOfKinks());
667ee8bf 533 printf(" CaloClusters %d\n", GetNumberOfCaloClusters());
534 printf(" phos %d\n", GetNumberOfPHOSClusters());
535 printf(" emcal %d\n", GetNumberOfEMCALClusters());
536 printf(" FMD %s\n", (fESDFMD ? "yes" : "no"));
dd735cf0 537 printf(" VZERO %s\n", (fESDVZERO ? "yes" : "no"));
ef278eae 538}
d75007f6 539
540void AliESD::SetESDfriend(const AliESDfriend *ev) {
541 //
542 // Attaches the complementary info to the ESD
543 //
544 if (!ev) return;
545
546 Int_t ntrk=ev->GetNumberOfTracks();
af885e0f 547
d75007f6 548 for (Int_t i=0; i<ntrk; i++) {
549 const AliESDfriendTrack *f=ev->GetTrack(i);
550 GetTrack(i)->SetFriendTrack(f);
551 }
552}
553
554void AliESD::GetESDfriend(AliESDfriend *ev) const {
555 //
556 // Extracts the complementary info from the ESD
557 //
558 if (!ev) return;
559
560 Int_t ntrk=GetNumberOfTracks();
561
562 for (Int_t i=0; i<ntrk; i++) {
80799a5f 563 AliESDtrack *t=GetTrack(i);
d75007f6 564 const AliESDfriendTrack *f=t->GetFriendTrack();
565 ev->AddTrack(f);
80799a5f 566
567 t->ReleaseESDfriendTrack();// Not to have two copies of "friendTrack"
568
d75007f6 569 }
570}
6989bff3 571
572void AliESD::SetDiamond(const AliESDVertex *vertex)
573{
574 //
575 // Set the interaction diamond
576 //
577 fDiamondXY[0]=vertex->GetXv();
578 fDiamondXY[1]=vertex->GetYv();
579 Double_t cov[6];
580 vertex->GetCovMatrix(cov);
581 fDiamondCovXY[0]=cov[0];
582 fDiamondCovXY[1]=cov[1];
583 fDiamondCovXY[2]=cov[2];
584 }