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 **************************************************************************/
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),
55 fTracks("AliESDtrack",15000),
56 fHLTConfMapTracks("AliESDHLTtrack",25000),
57 fHLTHoughTracks("AliESDHLTtrack",15000),
58 fMuonTracks("AliESDMuonTrack",30),
59 fPmdTracks("AliESDPmdTrack",3000),
60 fTrdTracks("AliESDTrdTrack",300),
62 fCascades("AliESDcascade",20),
63 fKinks("AliESDkink",4000),
64 fCaloClusters("AliESDCaloCluster",10000),
66 fFirstEMCALCluster(-1),
67 fEMCALTriggerPosition(0x0),
68 fEMCALTriggerAmplitudes(0x0),
70 fFirstPHOSCluster(-1),
71 fPHOSTriggerPosition(0x0),
72 fPHOSTriggerAmplitudes(0x0),
76 fErrorLogs("AliRawDataErrorLog",5)
79 // Standar constructor
82 for (Int_t i=0; i<24; i++) {
86 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
87 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=0.;
90 //______________________________________________________________________________
91 AliESD::AliESD(const AliESD& esd):
93 fEventNumberInFile(esd.fEventNumberInFile),
94 fBunchCrossNumber(esd.fBunchCrossNumber),
95 fOrbitNumber(esd.fOrbitNumber),
96 fPeriodNumber(esd.fPeriodNumber),
97 fRunNumber(esd.fRunNumber),
98 fTimeStamp(esd.fTimeStamp),
99 fEventType(esd.fEventType),
100 fTriggerMask(esd.fTriggerMask),
101 fTriggerCluster(esd.fTriggerCluster),
102 fRecoVersion(esd.fRecoVersion),
103 fMagneticField(esd.fMagneticField),
104 fZDCN1Energy(esd.fZDCN1Energy),
105 fZDCP1Energy(esd.fZDCP1Energy),
106 fZDCN2Energy(esd.fZDCN2Energy),
107 fZDCP2Energy(esd.fZDCP2Energy),
108 fZDCEMEnergy(esd.fZDCEMEnergy),
109 fZDCParticipants(esd.fZDCParticipants),
110 fT0zVertex(esd.fT0zVertex),
111 fSPDVertex(esd.fSPDVertex),
112 fPrimaryVertex(esd.fPrimaryVertex),
113 fSPDMult(esd.fSPDMult),
114 fT0timeStart(esd.fT0timeStart),
115 fT0clock(esd.fT0clock),
116 fTracks(*((TClonesArray*)esd.fTracks.Clone())),
117 fHLTConfMapTracks(*((TClonesArray*)esd.fHLTConfMapTracks.Clone())),
118 fHLTHoughTracks(*((TClonesArray*)esd.fHLTHoughTracks.Clone())),
119 fMuonTracks(*((TClonesArray*)esd.fMuonTracks.Clone())),
120 fPmdTracks(*((TClonesArray*)esd.fPmdTracks.Clone())),
121 fTrdTracks(*((TClonesArray*)esd.fTrdTracks.Clone())),
122 fV0s(*((TClonesArray*)esd.fV0s.Clone())),
123 fCascades(*((TClonesArray*)esd.fCascades.Clone())),
124 fKinks(*((TClonesArray*)esd.fKinks.Clone())),
125 fCaloClusters(*((TClonesArray*)esd.fCaloClusters.Clone())),
126 fEMCALClusters(esd.fEMCALClusters),
127 fFirstEMCALCluster(esd.fFirstEMCALCluster),
128 fEMCALTriggerPosition(esd. fEMCALTriggerPosition),
129 fEMCALTriggerAmplitudes(esd.fEMCALTriggerAmplitudes),
130 fPHOSClusters(esd.fPHOSClusters),
131 fFirstPHOSCluster(esd.fFirstPHOSCluster),
132 fPHOSTriggerPosition(esd.fPHOSTriggerPosition),
133 fPHOSTriggerAmplitudes(esd.fPHOSTriggerAmplitudes),
134 fESDFMD(esd.fESDFMD),
135 fESDVZERO(esd.fESDVZERO),
136 fESDACORDE(esd.fESDACORDE),
137 fErrorLogs(*((TClonesArray*)esd.fErrorLogs.Clone()))
142 for (Int_t i=0; i<24; i++) {
143 fT0time[i] = esd.fT0time[i];
144 fT0amplitude[i] = esd.fT0amplitude[i];
146 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
147 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
150 //______________________________________________________________________________
154 // Standard destructor
157 fHLTConfMapTracks.Delete();
158 fHLTHoughTracks.Delete();
159 fMuonTracks.Delete();
165 fCaloClusters.Delete();
168 delete fEMCALTriggerPosition;
169 delete fEMCALTriggerAmplitudes;
170 delete fPHOSTriggerPosition;
171 delete fPHOSTriggerAmplitudes;
178 //______________________________________________________________________________
182 // Reset the contents and delete the entries in TClonesArrays
185 fEventNumberInFile=0;
204 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
205 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=0.;
207 for (Int_t i=0; i<24; i++) {
214 fSPDMult.~AliMultiplicity();
215 new (&fSPDMult) AliMultiplicity();
216 fSPDVertex.~AliESDVertex();
217 new (&fSPDVertex) AliESDVertex();
218 fPrimaryVertex.~AliESDVertex();
219 new (&fPrimaryVertex) AliESDVertex();
222 fHLTConfMapTracks.Delete();
223 fHLTHoughTracks.Delete();
224 fMuonTracks.Delete();
230 fCaloClusters.Delete();
233 fFirstEMCALCluster=-1;
235 fFirstPHOSCluster=-1;
237 if (fEMCALTriggerPosition) fEMCALTriggerPosition ->Reset();
238 if (fEMCALTriggerAmplitudes) fEMCALTriggerAmplitudes->Reset();
239 if (fPHOSTriggerPosition) fPHOSTriggerPosition ->Reset();
240 if (fPHOSTriggerAmplitudes) fPHOSTriggerAmplitudes ->Reset();
242 if (fESDFMD) fESDFMD->Clear();
245 fESDVZERO->~AliESDVZERO();
246 new (fESDVZERO) AliESDVZERO();
250 fESDACORDE->~AliESDACORDE();
251 new (fESDACORDE) AliESDACORDE();
258 Bool_t AliESD::RemoveKink(Int_t rm) {
259 // ---------------------------------------------------------
260 // Remove a kink candidate and references to it from ESD,
261 // if this candidate does not come from a reconstructed decay
262 // Not yet implemented...
263 // ---------------------------------------------------------
264 Int_t last=GetNumberOfKinks()-1;
265 if ((rm<0)||(rm>last)) return kFALSE;
270 Bool_t AliESD::RemoveV0(Int_t rm) {
271 // ---------------------------------------------------------
272 // Remove a V0 candidate and references to it from ESD,
273 // if this candidate does not come from a reconstructed decay
274 // ---------------------------------------------------------
275 Int_t last=GetNumberOfV0s()-1;
276 if ((rm<0)||(rm>last)) return kFALSE;
278 AliESDv0 *v0=GetV0(rm);
279 Int_t idxP=v0->GetPindex(), idxN=v0->GetNindex();
282 Int_t lastIdxP=v0->GetPindex(), lastIdxN=v0->GetNindex();
286 // Check if this V0 comes from a reconstructed decay
287 Int_t ncs=GetNumberOfCascades();
288 for (Int_t n=0; n<ncs; n++) {
289 AliESDcascade *cs=GetCascade(n);
291 Int_t csIdxP=cs->GetPindex();
292 Int_t csIdxN=cs->GetNindex();
295 if (idxN==csIdxN) return kFALSE;
297 if (csIdxP==lastIdxP)
298 if (csIdxN==lastIdxN) used++;
301 //Replace the removed V0 with the last V0
302 TClonesArray &a=fV0s;
303 delete a.RemoveAt(rm);
305 if (rm==last) return kTRUE;
307 //v0 is pointing to the last V0 candidate...
308 new (a[rm]) AliESDv0(*v0);
309 delete a.RemoveAt(last);
311 if (!used) return kTRUE;
314 // Remap the indices of the daughters of reconstructed decays
315 for (Int_t n=0; n<ncs; n++) {
316 AliESDcascade *cs=GetCascade(n);
319 Int_t csIdxP=cs->GetPindex();
320 Int_t csIdxN=cs->GetNindex();
322 if (csIdxP==lastIdxP)
323 if (csIdxN==lastIdxN) {
324 cs->AliESDv0::SetIndex(1,idxP);
325 cs->AliESDv0::SetIndex(0,idxN);
327 if (!used) return kTRUE;
334 Bool_t AliESD::RemoveTrack(Int_t rm) {
335 // ---------------------------------------------------------
336 // Remove a track and references to it from ESD,
337 // if this track does not come from a reconstructed decay
338 // ---------------------------------------------------------
339 Int_t last=GetNumberOfTracks()-1;
340 if ((rm<0)||(rm>last)) return kFALSE;
344 // Check if this track comes from the reconstructed primary vertex
345 if (fPrimaryVertex.GetStatus()) {
346 UShort_t *primIdx=fPrimaryVertex.GetIndices();
347 Int_t n=fPrimaryVertex.GetNIndices();
349 Int_t idx=Int_t(primIdx[n]);
350 if (rm==idx) return kFALSE;
351 if (idx==last) used++;
355 // Check if this track comes from a reconstructed decay
356 Int_t nv0=GetNumberOfV0s();
357 for (Int_t n=0; n<nv0; n++) {
358 AliESDv0 *v0=GetV0(n);
360 Int_t idx=v0->GetNindex();
361 if (rm==idx) return kFALSE;
362 if (idx==last) used++;
365 if (rm==idx) return kFALSE;
366 if (idx==last) used++;
369 Int_t ncs=GetNumberOfCascades();
370 for (Int_t n=0; n<ncs; n++) {
371 AliESDcascade *cs=GetCascade(n);
373 Int_t idx=cs->GetIndex();
374 if (rm==idx) return kFALSE;
375 if (idx==last) used++;
378 Int_t nkn=GetNumberOfKinks();
379 for (Int_t n=0; n<nkn; n++) {
380 AliESDkink *kn=GetKink(n);
382 Int_t idx=kn->GetIndex(0);
383 if (rm==idx) return kFALSE;
384 if (idx==last) used++;
387 if (rm==idx) return kFALSE;
388 if (idx==last) used++;
392 //Replace the removed track with the last track
393 TClonesArray &a=fTracks;
394 delete a.RemoveAt(rm);
396 if (rm==last) return kTRUE;
398 AliESDtrack *t=GetTrack(last);
400 new (a[rm]) AliESDtrack(*t);
401 delete a.RemoveAt(last);
404 if (!used) return kTRUE;
407 // Remap the indices of the tracks used for the primary vertex reconstruction
408 if (fPrimaryVertex.GetStatus()) {
409 UShort_t *primIdx=fPrimaryVertex.GetIndices();
410 Int_t n=fPrimaryVertex.GetNIndices();
412 Int_t idx=Int_t(primIdx[n]);
414 primIdx[n]=Short_t(rm);
416 if (!used) return kTRUE;
421 // Remap the indices of the daughters of reconstructed decays
422 for (Int_t n=0; n<nv0; n++) {
423 AliESDv0 *v0=GetV0(n);
424 if (v0->GetIndex(0)==last) {
427 if (!used) return kTRUE;
429 if (v0->GetIndex(1)==last) {
432 if (!used) return kTRUE;
436 for (Int_t n=0; n<ncs; n++) {
437 AliESDcascade *cs=GetCascade(n);
438 if (cs->GetIndex()==last) {
441 if (!used) return kTRUE;
445 for (Int_t n=0; n<nkn; n++) {
446 AliESDkink *kn=GetKink(n);
447 if (kn->GetIndex(0)==last) {
450 if (!used) return kTRUE;
452 if (kn->GetIndex(1)==last) {
455 if (!used) return kTRUE;
463 Bool_t AliESD::Clean(Float_t *cleanPars) {
465 // Remove the data which are not needed for the physics analysis.
467 // 1) Cleaning the V0 candidates
468 // ---------------------------
469 // If the cosine of the V0 pointing angle "csp" and
470 // the DCA between the daughter tracks "dca" does not satisfy
473 // csp > cleanPars[1] + dca/cleanPars[0]*(1.- cleanPars[1])
475 // an attempt to remove this V0 candidate from ESD is made.
477 // The V0 candidate gets removed if it does not belong to any
478 // recosntructed cascade decay
480 // 12.11.2007, optimal values: cleanPars[0]=0.5, cleanPars[1]=0.999
482 // 2) Cleaning the tracks
483 // ----------------------
484 // If track's transverse parameter is larger than cleanPars[2]
486 // track's longitudinal parameter is larger than cleanPars[3]
487 // an attempt to remove this track from ESD is made.
489 // The track gets removed if it does not come
490 // from a reconstructed decay
494 Float_t dcaMax=cleanPars[0];
495 Float_t cspMin=cleanPars[1];
497 Int_t nV0s=GetNumberOfV0s();
498 for (Int_t i=nV0s-1; i>=0; i--) {
499 AliESDv0 *v0=GetV0(i);
501 Float_t dca=v0->GetDcaV0Daughters();
502 Float_t csp=v0->GetV0CosineOfPointingAngle();
503 Float_t cspcut=cspMin + dca/dcaMax*(1.-cspMin);
504 if (csp > cspcut) continue;
506 if (RemoveV0(i)) rc=kTRUE;
510 Float_t dmax=cleanPars[2], zmax=cleanPars[3];
512 const AliESDVertex *vertex=GetVertex();
513 Bool_t vtxOK=vertex->GetStatus();
515 Int_t nTracks=GetNumberOfTracks();
516 for (Int_t i=nTracks-1; i>=0; i--) {
517 AliESDtrack *track=GetTrack(i);
518 Float_t xy,z; track->GetImpactParameters(xy,z);
519 if ((TMath::Abs(xy) > dmax) || (vtxOK && (TMath::Abs(z) > zmax))) {
520 if (RemoveTrack(i)) rc=kTRUE;
527 Int_t AliESD::AddV0(const AliESDv0 *v) {
531 Int_t idx=fV0s.GetEntriesFast();
532 new(fV0s[idx]) AliESDv0(*v);
536 //______________________________________________________________________________
537 void AliESD::Print(Option_t *) const
540 // Print header information of the event
542 printf("ESD run information\n");
543 printf("Event # in file %d Bunch crossing # %d Orbit # %d Period # %d Run # %d Trigger %lld Magnetic field %f \n",
544 GetEventNumberInFile(),
545 GetBunchCrossNumber(),
550 GetMagneticField() );
551 printf("Vertex: (%.4f +- %.4f, %.4f +- %.4f, %.4f +- %.4f) cm\n",
552 fPrimaryVertex.GetXv(), fPrimaryVertex.GetXRes(),
553 fPrimaryVertex.GetYv(), fPrimaryVertex.GetYRes(),
554 fPrimaryVertex.GetZv(), fPrimaryVertex.GetZRes());
555 printf("Mean vertex in RUN: X=%.4f Y=%.4f cm\n",
556 GetDiamondX(),GetDiamondY());
557 printf("SPD Multiplicity. Number of tracklets %d \n",
558 fSPDMult.GetNumberOfTracklets());
559 printf("Event from reconstruction version %d \n",fRecoVersion);
560 printf("Number of tracks: \n");
561 printf(" charged %d\n", GetNumberOfTracks());
562 printf(" hlt CF %d\n", GetNumberOfHLTConfMapTracks());
563 printf(" hlt HT %d\n", GetNumberOfHLTHoughTracks());
564 printf(" muon %d\n", GetNumberOfMuonTracks());
565 printf(" pmd %d\n", GetNumberOfPmdTracks());
566 printf(" trd %d\n", GetNumberOfTrdTracks());
567 printf(" v0 %d\n", GetNumberOfV0s());
568 printf(" cascades %d\n", GetNumberOfCascades());
569 printf(" kinks %d\n", GetNumberOfKinks());
570 printf(" CaloClusters %d\n", GetNumberOfCaloClusters());
571 printf(" phos %d\n", GetNumberOfPHOSClusters());
572 printf(" emcal %d\n", GetNumberOfEMCALClusters());
573 printf(" FMD %s\n", (fESDFMD ? "yes" : "no"));
574 printf(" VZERO %s\n", (fESDVZERO ? "yes" : "no"));
577 void AliESD::SetESDfriend(const AliESDfriend *ev) {
579 // Attaches the complementary info to the ESD
583 Int_t ntrk=ev->GetNumberOfTracks();
585 for (Int_t i=0; i<ntrk; i++) {
586 const AliESDfriendTrack *f=ev->GetTrack(i);
587 GetTrack(i)->SetFriendTrack(f);
591 void AliESD::GetESDfriend(AliESDfriend *ev) const {
593 // Extracts the complementary info from the ESD
597 Int_t ntrk=GetNumberOfTracks();
599 for (Int_t i=0; i<ntrk; i++) {
600 AliESDtrack *t=GetTrack(i);
601 const AliESDfriendTrack *f=t->GetFriendTrack();
604 t->ReleaseESDfriendTrack();// Not to have two copies of "friendTrack"
609 void AliESD::SetDiamond(const AliESDVertex *vertex)
612 // Set the interaction diamond
614 fDiamondXY[0]=vertex->GetXv();
615 fDiamondXY[1]=vertex->GetYv();
617 vertex->GetCovMatrix(cov);
618 fDiamondCovXY[0]=cov[0];
619 fDiamondCovXY[1]=cov[1];
620 fDiamondCovXY[2]=cov[2];