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),
56 fTracks("AliESDtrack",15000),
57 fHLTConfMapTracks("AliESDHLTtrack",25000),
58 fHLTHoughTracks("AliESDHLTtrack",15000),
59 fMuonTracks("AliESDMuonTrack",30),
60 fPmdTracks("AliESDPmdTrack",3000),
61 fTrdTracks("AliESDTrdTrack",300),
63 fCascades("AliESDcascade",20),
64 fKinks("AliESDkink",4000),
65 fCaloClusters("AliESDCaloCluster",10000),
67 fFirstEMCALCluster(-1),
68 fEMCALTriggerPosition(0x0),
69 fEMCALTriggerAmplitudes(0x0),
71 fFirstPHOSCluster(-1),
72 fPHOSTriggerPosition(0x0),
73 fPHOSTriggerAmplitudes(0x0),
78 fErrorLogs("AliRawDataErrorLog",5)
81 // Standar constructor
84 for (Int_t i=0; i<3; i++) fT0TOF[i] = 0;
85 for (Int_t i=0; i<24; i++) {
89 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
90 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=0.;
93 //______________________________________________________________________________
94 AliESD::AliESD(const AliESD& esd):
96 fEventNumberInFile(esd.fEventNumberInFile),
97 fBunchCrossNumber(esd.fBunchCrossNumber),
98 fOrbitNumber(esd.fOrbitNumber),
99 fPeriodNumber(esd.fPeriodNumber),
100 fRunNumber(esd.fRunNumber),
101 fTimeStamp(esd.fTimeStamp),
102 fEventType(esd.fEventType),
103 fTriggerMask(esd.fTriggerMask),
104 fTriggerCluster(esd.fTriggerCluster),
105 fRecoVersion(esd.fRecoVersion),
106 fMagneticField(esd.fMagneticField),
107 fZDCN1Energy(esd.fZDCN1Energy),
108 fZDCP1Energy(esd.fZDCP1Energy),
109 fZDCN2Energy(esd.fZDCN2Energy),
110 fZDCP2Energy(esd.fZDCP2Energy),
111 fZDCEMEnergy(esd.fZDCEMEnergy),
112 fZDCParticipants(esd.fZDCParticipants),
113 fT0zVertex(esd.fT0zVertex),
114 fSPDVertex(esd.fSPDVertex),
115 fPrimaryVertex(esd.fPrimaryVertex),
116 fSPDMult(esd.fSPDMult),
117 fT0clock(esd.fT0clock),
118 fT0timeStart(esd.fT0timeStart),
119 fT0trig(esd.fT0trig),
120 fTracks(*((TClonesArray*)esd.fTracks.Clone())),
121 fHLTConfMapTracks(*((TClonesArray*)esd.fHLTConfMapTracks.Clone())),
122 fHLTHoughTracks(*((TClonesArray*)esd.fHLTHoughTracks.Clone())),
123 fMuonTracks(*((TClonesArray*)esd.fMuonTracks.Clone())),
124 fPmdTracks(*((TClonesArray*)esd.fPmdTracks.Clone())),
125 fTrdTracks(*((TClonesArray*)esd.fTrdTracks.Clone())),
126 fV0s(*((TClonesArray*)esd.fV0s.Clone())),
127 fCascades(*((TClonesArray*)esd.fCascades.Clone())),
128 fKinks(*((TClonesArray*)esd.fKinks.Clone())),
129 fCaloClusters(*((TClonesArray*)esd.fCaloClusters.Clone())),
130 fEMCALClusters(esd.fEMCALClusters),
131 fFirstEMCALCluster(esd.fFirstEMCALCluster),
132 fEMCALTriggerPosition(esd. fEMCALTriggerPosition),
133 fEMCALTriggerAmplitudes(esd.fEMCALTriggerAmplitudes),
134 fPHOSClusters(esd.fPHOSClusters),
135 fFirstPHOSCluster(esd.fFirstPHOSCluster),
136 fPHOSTriggerPosition(esd.fPHOSTriggerPosition),
137 fPHOSTriggerAmplitudes(esd.fPHOSTriggerAmplitudes),
138 fESDFMD(esd.fESDFMD),
139 fESDVZERO(esd.fESDVZERO),
140 fESDACORDE(esd.fESDACORDE),
142 fErrorLogs(*((TClonesArray*)esd.fErrorLogs.Clone()))
147 for (Int_t i=0; i<3; i++)fT0TOF[i] = esd.fT0TOF[i];
148 for (Int_t i=0; i<24; i++) {
149 fT0time[i] = esd.fT0time[i];
150 fT0amplitude[i] = esd.fT0amplitude[i];
152 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
153 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
156 //______________________________________________________________________________
160 // Standard destructor
163 fHLTConfMapTracks.Delete();
164 fHLTHoughTracks.Delete();
165 fMuonTracks.Delete();
171 fCaloClusters.Delete();
174 delete fEMCALTriggerPosition;
175 delete fEMCALTriggerAmplitudes;
176 delete fPHOSTriggerPosition;
177 delete fPHOSTriggerAmplitudes;
184 //______________________________________________________________________________
188 // Reset the contents and delete the entries in TClonesArrays
191 fEventNumberInFile=0;
210 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
211 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=0.;
213 for (Int_t i=0; i<24; i++) {
219 for (Int_t i=0; i<3; i++) fT0TOF[i] = 0;
221 fSPDMult.~AliMultiplicity();
222 new (&fSPDMult) AliMultiplicity();
223 fSPDVertex.~AliESDVertex();
224 new (&fSPDVertex) AliESDVertex();
225 fPrimaryVertex.~AliESDVertex();
226 new (&fPrimaryVertex) AliESDVertex();
229 fHLTConfMapTracks.Delete();
230 fHLTHoughTracks.Delete();
231 fMuonTracks.Delete();
237 fCaloClusters.Delete();
240 fFirstEMCALCluster=-1;
242 fFirstPHOSCluster=-1;
244 if (fEMCALTriggerPosition) fEMCALTriggerPosition ->Reset();
245 if (fEMCALTriggerAmplitudes) fEMCALTriggerAmplitudes->Reset();
246 if (fPHOSTriggerPosition) fPHOSTriggerPosition ->Reset();
247 if (fPHOSTriggerAmplitudes) fPHOSTriggerAmplitudes ->Reset();
249 if (fESDFMD) fESDFMD->Clear();
252 fESDVZERO->~AliESDVZERO();
253 new (fESDVZERO) AliESDVZERO();
257 fESDACORDE->~AliESDACORDE();
258 new (fESDACORDE) AliESDACORDE();
263 new (fESDAD) AliESDAD();
272 Bool_t AliESD::RemoveKink(Int_t rm) {
273 // ---------------------------------------------------------
274 // Remove a kink candidate and references to it from ESD,
275 // if this candidate does not come from a reconstructed decay
276 // Not yet implemented...
277 // ---------------------------------------------------------
278 Int_t last=GetNumberOfKinks()-1;
279 if ((rm<0)||(rm>last)) return kFALSE;
284 Bool_t AliESD::RemoveV0(Int_t rm) {
285 // ---------------------------------------------------------
286 // Remove a V0 candidate and references to it from ESD,
287 // if this candidate does not come from a reconstructed decay
288 // ---------------------------------------------------------
289 Int_t last=GetNumberOfV0s()-1;
290 if ((rm<0)||(rm>last)) return kFALSE;
292 AliESDv0 *v0=GetV0(rm);
293 Int_t idxP=v0->GetPindex(), idxN=v0->GetNindex();
296 Int_t lastIdxP=v0->GetPindex(), lastIdxN=v0->GetNindex();
300 // Check if this V0 comes from a reconstructed decay
301 Int_t ncs=GetNumberOfCascades();
302 for (Int_t n=0; n<ncs; n++) {
303 AliESDcascade *cs=GetCascade(n);
305 Int_t csIdxP=cs->GetPindex();
306 Int_t csIdxN=cs->GetNindex();
309 if (idxN==csIdxN) return kFALSE;
311 if (csIdxP==lastIdxP)
312 if (csIdxN==lastIdxN) used++;
315 //Replace the removed V0 with the last V0
316 TClonesArray &a=fV0s;
317 delete a.RemoveAt(rm);
319 if (rm==last) return kTRUE;
321 //v0 is pointing to the last V0 candidate...
322 new (a[rm]) AliESDv0(*v0);
323 delete a.RemoveAt(last);
325 if (!used) return kTRUE;
328 // Remap the indices of the daughters of reconstructed decays
329 for (Int_t n=0; n<ncs; n++) {
330 AliESDcascade *cs=GetCascade(n);
333 Int_t csIdxP=cs->GetPindex();
334 Int_t csIdxN=cs->GetNindex();
336 if (csIdxP==lastIdxP)
337 if (csIdxN==lastIdxN) {
338 cs->AliESDv0::SetIndex(1,idxP);
339 cs->AliESDv0::SetIndex(0,idxN);
341 if (!used) return kTRUE;
348 Bool_t AliESD::RemoveTrack(Int_t rm) {
349 // ---------------------------------------------------------
350 // Remove a track and references to it from ESD,
351 // if this track does not come from a reconstructed decay
352 // ---------------------------------------------------------
353 Int_t last=GetNumberOfTracks()-1;
354 if ((rm<0)||(rm>last)) return kFALSE;
358 // Check if this track comes from the reconstructed primary vertex
359 if (fPrimaryVertex.GetStatus()) {
360 UShort_t *primIdx=fPrimaryVertex.GetIndices();
361 Int_t n=fPrimaryVertex.GetNIndices();
363 Int_t idx=Int_t(primIdx[n]);
364 if (rm==idx) return kFALSE;
365 if (idx==last) used++;
369 // Check if this track comes from a reconstructed decay
370 Int_t nv0=GetNumberOfV0s();
371 for (Int_t n=0; n<nv0; n++) {
372 AliESDv0 *v0=GetV0(n);
374 Int_t idx=v0->GetNindex();
375 if (rm==idx) return kFALSE;
376 if (idx==last) used++;
379 if (rm==idx) return kFALSE;
380 if (idx==last) used++;
383 Int_t ncs=GetNumberOfCascades();
384 for (Int_t n=0; n<ncs; n++) {
385 AliESDcascade *cs=GetCascade(n);
387 Int_t idx=cs->GetIndex();
388 if (rm==idx) return kFALSE;
389 if (idx==last) used++;
392 Int_t nkn=GetNumberOfKinks();
393 for (Int_t n=0; n<nkn; n++) {
394 AliESDkink *kn=GetKink(n);
396 Int_t idx=kn->GetIndex(0);
397 if (rm==idx) return kFALSE;
398 if (idx==last) used++;
401 if (rm==idx) return kFALSE;
402 if (idx==last) used++;
406 //Replace the removed track with the last track
407 TClonesArray &a=fTracks;
408 delete a.RemoveAt(rm);
410 if (rm==last) return kTRUE;
412 AliESDtrack *t=GetTrack(last);
413 if (!t) {AliFatal(Form("NULL pointer for ESD track %d",last)); return kFALSE;}
415 new (a[rm]) AliESDtrack(*t);
416 delete a.RemoveAt(last);
419 if (!used) return kTRUE;
422 // Remap the indices of the tracks used for the primary vertex reconstruction
423 if (fPrimaryVertex.GetStatus()) {
424 UShort_t *primIdx=fPrimaryVertex.GetIndices();
425 Int_t n=fPrimaryVertex.GetNIndices();
427 Int_t idx=Int_t(primIdx[n]);
429 primIdx[n]=Short_t(rm);
431 if (!used) return kTRUE;
436 // Remap the indices of the daughters of reconstructed decays
437 for (Int_t n=0; n<nv0; n++) {
438 AliESDv0 *v0=GetV0(n);
439 if (v0->GetIndex(0)==last) {
442 if (!used) return kTRUE;
444 if (v0->GetIndex(1)==last) {
447 if (!used) return kTRUE;
451 for (Int_t n=0; n<ncs; n++) {
452 AliESDcascade *cs=GetCascade(n);
453 if (cs->GetIndex()==last) {
456 if (!used) return kTRUE;
460 for (Int_t n=0; n<nkn; n++) {
461 AliESDkink *kn=GetKink(n);
462 if (kn->GetIndex(0)==last) {
465 if (!used) return kTRUE;
467 if (kn->GetIndex(1)==last) {
470 if (!used) return kTRUE;
478 Bool_t AliESD::Clean(Float_t *cleanPars) {
480 // Remove the data which are not needed for the physics analysis.
482 // 1) Cleaning the V0 candidates
483 // ---------------------------
484 // If the cosine of the V0 pointing angle "csp" and
485 // the DCA between the daughter tracks "dca" does not satisfy
488 // csp > cleanPars[1] + dca/cleanPars[0]*(1.- cleanPars[1])
490 // an attempt to remove this V0 candidate from ESD is made.
492 // The V0 candidate gets removed if it does not belong to any
493 // recosntructed cascade decay
495 // 12.11.2007, optimal values: cleanPars[0]=0.5, cleanPars[1]=0.999
497 // 2) Cleaning the tracks
498 // ----------------------
499 // If track's transverse parameter is larger than cleanPars[2]
501 // track's longitudinal parameter is larger than cleanPars[3]
502 // an attempt to remove this track from ESD is made.
504 // The track gets removed if it does not come
505 // from a reconstructed decay
509 Float_t dcaMax=cleanPars[0];
510 Float_t cspMin=cleanPars[1];
512 Int_t nV0s=GetNumberOfV0s();
513 for (Int_t i=nV0s-1; i>=0; i--) {
514 AliESDv0 *v0=GetV0(i);
516 Float_t dca=v0->GetDcaV0Daughters();
517 Float_t csp=v0->GetV0CosineOfPointingAngle();
518 Float_t cspcut=cspMin + dca/dcaMax*(1.-cspMin);
519 if (csp > cspcut) continue;
521 if (RemoveV0(i)) rc=kTRUE;
525 Float_t dmax=cleanPars[2], zmax=cleanPars[3];
527 const AliESDVertex *vertex=GetVertex();
528 Bool_t vtxOK=vertex->GetStatus();
530 Int_t nTracks=GetNumberOfTracks();
531 for (Int_t i=nTracks-1; i>=0; i--) {
532 AliESDtrack *track=GetTrack(i);
533 if (!track) {AliFatal(Form("NULL pointer for ESD track %d",i)); return kFALSE;}
534 Float_t xy,z; track->GetImpactParameters(xy,z);
535 if ((TMath::Abs(xy) > dmax) || (vtxOK && (TMath::Abs(z) > zmax))) {
536 if (RemoveTrack(i)) rc=kTRUE;
543 Int_t AliESD::AddV0(const AliESDv0 *v) {
547 Int_t idx=fV0s.GetEntriesFast();
548 new(fV0s[idx]) AliESDv0(*v);
552 //______________________________________________________________________________
553 void AliESD::Print(Option_t *) const
556 // Print header information of the event
558 printf("ESD run information\n");
559 printf("Event # in file %d Bunch crossing # %d Orbit # %d Period # %d Run # %d Trigger %lld Magnetic field %f \n",
560 GetEventNumberInFile(),
561 GetBunchCrossNumber(),
566 GetMagneticField() );
567 printf("Vertex: (%.4f +- %.4f, %.4f +- %.4f, %.4f +- %.4f) cm\n",
568 fPrimaryVertex.GetXv(), fPrimaryVertex.GetXRes(),
569 fPrimaryVertex.GetYv(), fPrimaryVertex.GetYRes(),
570 fPrimaryVertex.GetZv(), fPrimaryVertex.GetZRes());
571 printf("Mean vertex in RUN: X=%.4f Y=%.4f cm\n",
572 GetDiamondX(),GetDiamondY());
573 printf("SPD Multiplicity. Number of tracklets %d \n",
574 fSPDMult.GetNumberOfTracklets());
575 printf("Event from reconstruction version %d \n",fRecoVersion);
576 printf("Number of tracks: \n");
577 printf(" charged %d\n", GetNumberOfTracks());
578 printf(" hlt CF %d\n", GetNumberOfHLTConfMapTracks());
579 printf(" hlt HT %d\n", GetNumberOfHLTHoughTracks());
580 printf(" muon %d\n", GetNumberOfMuonTracks());
581 printf(" pmd %d\n", GetNumberOfPmdTracks());
582 printf(" trd %d\n", GetNumberOfTrdTracks());
583 printf(" v0 %d\n", GetNumberOfV0s());
584 printf(" cascades %d\n", GetNumberOfCascades());
585 printf(" kinks %d\n", GetNumberOfKinks());
586 printf(" CaloClusters %d\n", GetNumberOfCaloClusters());
587 printf(" phos %d\n", GetNumberOfPHOSClusters());
588 printf(" emcal %d\n", GetNumberOfEMCALClusters());
589 printf(" FMD %s\n", (fESDFMD ? "yes" : "no"));
590 printf(" VZERO %s\n", (fESDVZERO ? "yes" : "no"));
593 void AliESD::SetESDfriend(const AliESDfriend *ev) {
595 // Attaches the complementary info to the ESD
599 Int_t ntrk=ev->GetNumberOfTracks();
601 for (Int_t i=0; i<ntrk; i++) {
602 const AliESDfriendTrack *f=ev->GetTrack(i);
603 if (!f) {AliFatal(Form("NULL pointer for ESD track %d",i));}
604 GetTrack(i)->SetFriendTrack(f);
608 void AliESD::GetESDfriend(AliESDfriend *ev) const {
610 // Extracts the complementary info from the ESD
614 Int_t ntrk=GetNumberOfTracks();
616 for (Int_t i=0; i<ntrk; i++) {
617 AliESDtrack *t=GetTrack(i);
618 if (!t) {AliFatal(Form("NULL pointer for ESD track %d",i));}
619 const AliESDfriendTrack *f=t->GetFriendTrack();
622 t->ReleaseESDfriendTrack();// Not to have two copies of "friendTrack"
627 void AliESD::SetDiamond(const AliESDVertex *vertex)
630 // Set the interaction diamond
632 fDiamondXY[0]=vertex->GetXv();
633 fDiamondXY[1]=vertex->GetYv();
635 vertex->GetCovMatrix(cov);
636 fDiamondCovXY[0]=cov[0];
637 fDiamondCovXY[1]=cov[1];
638 fDiamondCovXY[2]=cov[2];