1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 /* $Id: AliESD.cxx 54579 2012-02-14 12:22:34Z shahoian $ */
18 //-----------------------------------------------------------------
19 // Implementation of the ESD class
20 // This is the class to deal with during the phisical analysis of data
21 // This class is generated directly by the reconstruction methods
22 // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
23 //-----------------------------------------------------------------
26 #include "AliESDfriend.h"
30 //______________________________________________________________________________
32 fEventNumberInFile(0),
40 fTriggerMaskNext50(0),
57 fTracks("AliESDtrack",15000),
58 fHLTConfMapTracks("AliESDHLTtrack",25000),
59 fHLTHoughTracks("AliESDHLTtrack",15000),
60 fMuonTracks("AliESDMuonTrack",30),
61 fPmdTracks("AliESDPmdTrack",3000),
62 fTrdTracks("AliESDTrdTrack",300),
64 fCascades("AliESDcascade",20),
65 fKinks("AliESDkink",4000),
66 fCaloClusters("AliESDCaloCluster",10000),
68 fFirstEMCALCluster(-1),
69 fEMCALTriggerPosition(0x0),
70 fEMCALTriggerAmplitudes(0x0),
72 fFirstPHOSCluster(-1),
73 fPHOSTriggerPosition(0x0),
74 fPHOSTriggerAmplitudes(0x0),
79 fErrorLogs("AliRawDataErrorLog",5)
82 // Standar constructor
85 for (Int_t i=0; i<3; i++) fT0TOF[i] = 0;
86 for (Int_t i=0; i<24; i++) {
90 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
91 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=0.;
94 //______________________________________________________________________________
95 AliESD::AliESD(const AliESD& esd):
97 fEventNumberInFile(esd.fEventNumberInFile),
98 fBunchCrossNumber(esd.fBunchCrossNumber),
99 fOrbitNumber(esd.fOrbitNumber),
100 fPeriodNumber(esd.fPeriodNumber),
101 fRunNumber(esd.fRunNumber),
102 fTimeStamp(esd.fTimeStamp),
103 fEventType(esd.fEventType),
104 fTriggerMask(esd.fTriggerMask),
105 fTriggerMaskNext50(esd.fTriggerMaskNext50),
106 fTriggerCluster(esd.fTriggerCluster),
107 fRecoVersion(esd.fRecoVersion),
108 fMagneticField(esd.fMagneticField),
109 fZDCN1Energy(esd.fZDCN1Energy),
110 fZDCP1Energy(esd.fZDCP1Energy),
111 fZDCN2Energy(esd.fZDCN2Energy),
112 fZDCP2Energy(esd.fZDCP2Energy),
113 fZDCEMEnergy(esd.fZDCEMEnergy),
114 fZDCParticipants(esd.fZDCParticipants),
115 fT0zVertex(esd.fT0zVertex),
116 fSPDVertex(esd.fSPDVertex),
117 fPrimaryVertex(esd.fPrimaryVertex),
118 fSPDMult(esd.fSPDMult),
119 fT0clock(esd.fT0clock),
120 fT0timeStart(esd.fT0timeStart),
121 fT0trig(esd.fT0trig),
122 fTracks(*((TClonesArray*)esd.fTracks.Clone())),
123 fHLTConfMapTracks(*((TClonesArray*)esd.fHLTConfMapTracks.Clone())),
124 fHLTHoughTracks(*((TClonesArray*)esd.fHLTHoughTracks.Clone())),
125 fMuonTracks(*((TClonesArray*)esd.fMuonTracks.Clone())),
126 fPmdTracks(*((TClonesArray*)esd.fPmdTracks.Clone())),
127 fTrdTracks(*((TClonesArray*)esd.fTrdTracks.Clone())),
128 fV0s(*((TClonesArray*)esd.fV0s.Clone())),
129 fCascades(*((TClonesArray*)esd.fCascades.Clone())),
130 fKinks(*((TClonesArray*)esd.fKinks.Clone())),
131 fCaloClusters(*((TClonesArray*)esd.fCaloClusters.Clone())),
132 fEMCALClusters(esd.fEMCALClusters),
133 fFirstEMCALCluster(esd.fFirstEMCALCluster),
134 fEMCALTriggerPosition(esd. fEMCALTriggerPosition),
135 fEMCALTriggerAmplitudes(esd.fEMCALTriggerAmplitudes),
136 fPHOSClusters(esd.fPHOSClusters),
137 fFirstPHOSCluster(esd.fFirstPHOSCluster),
138 fPHOSTriggerPosition(esd.fPHOSTriggerPosition),
139 fPHOSTriggerAmplitudes(esd.fPHOSTriggerAmplitudes),
140 fESDFMD(esd.fESDFMD),
141 fESDVZERO(esd.fESDVZERO),
142 fESDACORDE(esd.fESDACORDE),
144 fErrorLogs(*((TClonesArray*)esd.fErrorLogs.Clone()))
149 for (Int_t i=0; i<3; i++)fT0TOF[i] = esd.fT0TOF[i];
150 for (Int_t i=0; i<24; i++) {
151 fT0time[i] = esd.fT0time[i];
152 fT0amplitude[i] = esd.fT0amplitude[i];
154 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
155 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
158 //______________________________________________________________________________
162 // Standard destructor
165 fHLTConfMapTracks.Delete();
166 fHLTHoughTracks.Delete();
167 fMuonTracks.Delete();
173 fCaloClusters.Delete();
176 delete fEMCALTriggerPosition;
177 delete fEMCALTriggerAmplitudes;
178 delete fPHOSTriggerPosition;
179 delete fPHOSTriggerAmplitudes;
186 //______________________________________________________________________________
190 // Reset the contents and delete the entries in TClonesArrays
193 fEventNumberInFile=0;
201 fTriggerMaskNext50=0;
213 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
214 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=0.;
216 for (Int_t i=0; i<24; i++) {
222 for (Int_t i=0; i<3; i++) fT0TOF[i] = 0;
224 fSPDMult.~AliMultiplicity();
225 new (&fSPDMult) AliMultiplicity();
226 fSPDVertex.~AliESDVertex();
227 new (&fSPDVertex) AliESDVertex();
228 fPrimaryVertex.~AliESDVertex();
229 new (&fPrimaryVertex) AliESDVertex();
232 fHLTConfMapTracks.Delete();
233 fHLTHoughTracks.Delete();
234 fMuonTracks.Delete();
240 fCaloClusters.Delete();
243 fFirstEMCALCluster=-1;
245 fFirstPHOSCluster=-1;
247 if (fEMCALTriggerPosition) fEMCALTriggerPosition ->Reset();
248 if (fEMCALTriggerAmplitudes) fEMCALTriggerAmplitudes->Reset();
249 if (fPHOSTriggerPosition) fPHOSTriggerPosition ->Reset();
250 if (fPHOSTriggerAmplitudes) fPHOSTriggerAmplitudes ->Reset();
252 if (fESDFMD) fESDFMD->Clear();
255 fESDVZERO->~AliESDVZERO();
256 new (fESDVZERO) AliESDVZERO();
260 fESDACORDE->~AliESDACORDE();
261 new (fESDACORDE) AliESDACORDE();
266 new (fESDAD) AliESDAD();
275 Bool_t AliESD::RemoveKink(Int_t rm) {
276 // ---------------------------------------------------------
277 // Remove a kink candidate and references to it from ESD,
278 // if this candidate does not come from a reconstructed decay
279 // Not yet implemented...
280 // ---------------------------------------------------------
281 Int_t last=GetNumberOfKinks()-1;
282 if ((rm<0)||(rm>last)) return kFALSE;
287 Bool_t AliESD::RemoveV0(Int_t rm) {
288 // ---------------------------------------------------------
289 // Remove a V0 candidate and references to it from ESD,
290 // if this candidate does not come from a reconstructed decay
291 // ---------------------------------------------------------
292 Int_t last=GetNumberOfV0s()-1;
293 if ((rm<0)||(rm>last)) return kFALSE;
295 AliESDv0 *v0=GetV0(rm);
296 Int_t idxP=v0->GetPindex(), idxN=v0->GetNindex();
299 Int_t lastIdxP=v0->GetPindex(), lastIdxN=v0->GetNindex();
303 // Check if this V0 comes from a reconstructed decay
304 Int_t ncs=GetNumberOfCascades();
305 for (Int_t n=0; n<ncs; n++) {
306 AliESDcascade *cs=GetCascade(n);
308 Int_t csIdxP=cs->GetPindex();
309 Int_t csIdxN=cs->GetNindex();
312 if (idxN==csIdxN) return kFALSE;
314 if (csIdxP==lastIdxP)
315 if (csIdxN==lastIdxN) used++;
318 //Replace the removed V0 with the last V0
319 TClonesArray &a=fV0s;
320 delete a.RemoveAt(rm);
322 if (rm==last) return kTRUE;
324 //v0 is pointing to the last V0 candidate...
325 new (a[rm]) AliESDv0(*v0);
326 delete a.RemoveAt(last);
328 if (!used) return kTRUE;
331 // Remap the indices of the daughters of reconstructed decays
332 for (Int_t n=0; n<ncs; n++) {
333 AliESDcascade *cs=GetCascade(n);
336 Int_t csIdxP=cs->GetPindex();
337 Int_t csIdxN=cs->GetNindex();
339 if (csIdxP==lastIdxP)
340 if (csIdxN==lastIdxN) {
341 cs->AliESDv0::SetIndex(1,idxP);
342 cs->AliESDv0::SetIndex(0,idxN);
344 if (!used) return kTRUE;
351 Bool_t AliESD::RemoveTrack(Int_t rm) {
352 // ---------------------------------------------------------
353 // Remove a track and references to it from ESD,
354 // if this track does not come from a reconstructed decay
355 // ---------------------------------------------------------
356 Int_t last=GetNumberOfTracks()-1;
357 if ((rm<0)||(rm>last)) return kFALSE;
361 // Check if this track comes from the reconstructed primary vertex
362 if (fPrimaryVertex.GetStatus()) {
363 UShort_t *primIdx=fPrimaryVertex.GetIndices();
364 Int_t n=fPrimaryVertex.GetNIndices();
366 Int_t idx=Int_t(primIdx[n]);
367 if (rm==idx) return kFALSE;
368 if (idx==last) used++;
372 // Check if this track comes from a reconstructed decay
373 Int_t nv0=GetNumberOfV0s();
374 for (Int_t n=0; n<nv0; n++) {
375 AliESDv0 *v0=GetV0(n);
377 Int_t idx=v0->GetNindex();
378 if (rm==idx) return kFALSE;
379 if (idx==last) used++;
382 if (rm==idx) return kFALSE;
383 if (idx==last) used++;
386 Int_t ncs=GetNumberOfCascades();
387 for (Int_t n=0; n<ncs; n++) {
388 AliESDcascade *cs=GetCascade(n);
390 Int_t idx=cs->GetIndex();
391 if (rm==idx) return kFALSE;
392 if (idx==last) used++;
395 Int_t nkn=GetNumberOfKinks();
396 for (Int_t n=0; n<nkn; n++) {
397 AliESDkink *kn=GetKink(n);
399 Int_t idx=kn->GetIndex(0);
400 if (rm==idx) return kFALSE;
401 if (idx==last) used++;
404 if (rm==idx) return kFALSE;
405 if (idx==last) used++;
409 //Replace the removed track with the last track
410 TClonesArray &a=fTracks;
411 delete a.RemoveAt(rm);
413 if (rm==last) return kTRUE;
415 AliESDtrack *t=GetTrack(last);
416 if (!t) {AliFatal(Form("NULL pointer for ESD track %d",last)); return kFALSE;}
418 new (a[rm]) AliESDtrack(*t);
419 delete a.RemoveAt(last);
422 if (!used) return kTRUE;
425 // Remap the indices of the tracks used for the primary vertex reconstruction
426 if (fPrimaryVertex.GetStatus()) {
427 UShort_t *primIdx=fPrimaryVertex.GetIndices();
428 Int_t n=fPrimaryVertex.GetNIndices();
430 Int_t idx=Int_t(primIdx[n]);
432 primIdx[n]=Short_t(rm);
434 if (!used) return kTRUE;
439 // Remap the indices of the daughters of reconstructed decays
440 for (Int_t n=0; n<nv0; n++) {
441 AliESDv0 *v0=GetV0(n);
442 if (v0->GetIndex(0)==last) {
445 if (!used) return kTRUE;
447 if (v0->GetIndex(1)==last) {
450 if (!used) return kTRUE;
454 for (Int_t n=0; n<ncs; n++) {
455 AliESDcascade *cs=GetCascade(n);
456 if (cs->GetIndex()==last) {
459 if (!used) return kTRUE;
463 for (Int_t n=0; n<nkn; n++) {
464 AliESDkink *kn=GetKink(n);
465 if (kn->GetIndex(0)==last) {
468 if (!used) return kTRUE;
470 if (kn->GetIndex(1)==last) {
473 if (!used) return kTRUE;
481 Bool_t AliESD::Clean(Float_t *cleanPars) {
483 // Remove the data which are not needed for the physics analysis.
485 // 1) Cleaning the V0 candidates
486 // ---------------------------
487 // If the cosine of the V0 pointing angle "csp" and
488 // the DCA between the daughter tracks "dca" does not satisfy
491 // csp > cleanPars[1] + dca/cleanPars[0]*(1.- cleanPars[1])
493 // an attempt to remove this V0 candidate from ESD is made.
495 // The V0 candidate gets removed if it does not belong to any
496 // recosntructed cascade decay
498 // 12.11.2007, optimal values: cleanPars[0]=0.5, cleanPars[1]=0.999
500 // 2) Cleaning the tracks
501 // ----------------------
502 // If track's transverse parameter is larger than cleanPars[2]
504 // track's longitudinal parameter is larger than cleanPars[3]
505 // an attempt to remove this track from ESD is made.
507 // The track gets removed if it does not come
508 // from a reconstructed decay
512 Float_t dcaMax=cleanPars[0];
513 Float_t cspMin=cleanPars[1];
515 Int_t nV0s=GetNumberOfV0s();
516 for (Int_t i=nV0s-1; i>=0; i--) {
517 AliESDv0 *v0=GetV0(i);
519 Float_t dca=v0->GetDcaV0Daughters();
520 Float_t csp=v0->GetV0CosineOfPointingAngle();
521 Float_t cspcut=cspMin + dca/dcaMax*(1.-cspMin);
522 if (csp > cspcut) continue;
524 if (RemoveV0(i)) rc=kTRUE;
528 Float_t dmax=cleanPars[2], zmax=cleanPars[3];
530 const AliESDVertex *vertex=GetVertex();
531 Bool_t vtxOK=vertex->GetStatus();
533 Int_t nTracks=GetNumberOfTracks();
534 for (Int_t i=nTracks-1; i>=0; i--) {
535 AliESDtrack *track=GetTrack(i);
536 if (!track) {AliFatal(Form("NULL pointer for ESD track %d",i)); return kFALSE;}
537 Float_t xy,z; track->GetImpactParameters(xy,z);
538 if ((TMath::Abs(xy) > dmax) || (vtxOK && (TMath::Abs(z) > zmax))) {
539 if (RemoveTrack(i)) rc=kTRUE;
546 Int_t AliESD::AddV0(const AliESDv0 *v) {
550 Int_t idx=fV0s.GetEntriesFast();
551 new(fV0s[idx]) AliESDv0(*v);
555 //______________________________________________________________________________
556 void AliESD::Print(Option_t *) const
559 // Print header information of the event
561 printf("ESD run information\n");
562 printf("Event # in file %d Bunch crossing # %d Orbit # %d Period # %d Run # %d Trigger %lld %lld Magnetic field %f \n",
563 GetEventNumberInFile(),
564 GetBunchCrossNumber(),
569 GetTriggerMaskNext50(),
570 GetMagneticField() );
571 printf("Vertex: (%.4f +- %.4f, %.4f +- %.4f, %.4f +- %.4f) cm\n",
572 fPrimaryVertex.GetX(), fPrimaryVertex.GetXRes(),
573 fPrimaryVertex.GetY(), fPrimaryVertex.GetYRes(),
574 fPrimaryVertex.GetZ(), fPrimaryVertex.GetZRes());
575 printf("Mean vertex in RUN: X=%.4f Y=%.4f cm\n",
576 GetDiamondX(),GetDiamondY());
577 printf("SPD Multiplicity. Number of tracklets %d \n",
578 fSPDMult.GetNumberOfTracklets());
579 printf("Event from reconstruction version %d \n",fRecoVersion);
580 printf("Number of tracks: \n");
581 printf(" charged %d\n", GetNumberOfTracks());
582 printf(" hlt CF %d\n", GetNumberOfHLTConfMapTracks());
583 printf(" hlt HT %d\n", GetNumberOfHLTHoughTracks());
584 printf(" muon %d\n", GetNumberOfMuonTracks());
585 printf(" pmd %d\n", GetNumberOfPmdTracks());
586 printf(" trd %d\n", GetNumberOfTrdTracks());
587 printf(" v0 %d\n", GetNumberOfV0s());
588 printf(" cascades %d\n", GetNumberOfCascades());
589 printf(" kinks %d\n", GetNumberOfKinks());
590 printf(" CaloClusters %d\n", GetNumberOfCaloClusters());
591 printf(" phos %d\n", GetNumberOfPHOSClusters());
592 printf(" emcal %d\n", GetNumberOfEMCALClusters());
593 printf(" FMD %s\n", (fESDFMD ? "yes" : "no"));
594 printf(" VZERO %s\n", (fESDVZERO ? "yes" : "no"));
597 void AliESD::SetESDfriend(const AliESDfriend *ev) {
599 // Attaches the complementary info to the ESD
603 Int_t ntrk=ev->GetNumberOfTracks();
605 for (Int_t i=0; i<ntrk; i++) {
606 const AliESDfriendTrack *f=ev->GetTrack(i);
607 if (!f) {AliFatal(Form("NULL pointer for ESD track %d",i));}
608 GetTrack(i)->SetFriendTrack(f);
612 void AliESD::GetESDfriend(AliESDfriend *ev) const {
614 // Extracts the complementary info from the ESD
618 Int_t ntrk=GetNumberOfTracks();
620 for (Int_t i=0; i<ntrk; i++) {
621 AliESDtrack *t=GetTrack(i);
622 if (!t) {AliFatal(Form("NULL pointer for ESD track %d",i));}
623 const AliESDfriendTrack *f=t->GetFriendTrack();
626 t->ReleaseESDfriendTrack();// Not to have two copies of "friendTrack"
631 void AliESD::SetDiamond(const AliESDVertex *vertex)
634 // Set the interaction diamond
636 fDiamondXY[0]=vertex->GetX();
637 fDiamondXY[1]=vertex->GetY();
639 vertex->GetCovMatrix(cov);
640 fDiamondCovXY[0]=cov[0];
641 fDiamondCovXY[1]=cov[1];
642 fDiamondCovXY[2]=cov[2];