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),
54 fTracks("AliESDtrack",15000),
55 fHLTConfMapTracks("AliESDHLTtrack",25000),
56 fHLTHoughTracks("AliESDHLTtrack",15000),
57 fMuonTracks("AliESDMuonTrack",30),
58 fPmdTracks("AliESDPmdTrack",3000),
59 fTrdTracks("AliESDTrdTrack",300),
61 fCascades("AliESDcascade",20),
62 fKinks("AliESDkink",4000),
63 fCaloClusters("AliESDCaloCluster",10000),
65 fFirstEMCALCluster(-1),
66 fEMCALTriggerPosition(0x0),
67 fEMCALTriggerAmplitudes(0x0),
69 fFirstPHOSCluster(-1),
70 fPHOSTriggerPosition(0x0),
71 fPHOSTriggerAmplitudes(0x0),
75 fErrorLogs("AliRawDataErrorLog",5)
78 // Standar constructor
81 for (Int_t i=0; i<24; i++) {
85 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
86 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=0.;
89 //______________________________________________________________________________
90 AliESD::AliESD(const AliESD& esd):
92 fEventNumberInFile(esd.fEventNumberInFile),
93 fBunchCrossNumber(esd.fBunchCrossNumber),
94 fOrbitNumber(esd.fOrbitNumber),
95 fPeriodNumber(esd.fPeriodNumber),
96 fRunNumber(esd.fRunNumber),
97 fTimeStamp(esd.fTimeStamp),
98 fEventType(esd.fEventType),
99 fTriggerMask(esd.fTriggerMask),
100 fTriggerCluster(esd.fTriggerCluster),
101 fRecoVersion(esd.fRecoVersion),
102 fMagneticField(esd.fMagneticField),
103 fZDCN1Energy(esd.fZDCN1Energy),
104 fZDCP1Energy(esd.fZDCP1Energy),
105 fZDCN2Energy(esd.fZDCN2Energy),
106 fZDCP2Energy(esd.fZDCP2Energy),
107 fZDCEMEnergy(esd.fZDCEMEnergy),
108 fZDCParticipants(esd.fZDCParticipants),
109 fT0zVertex(esd.fT0zVertex),
110 fSPDVertex(esd.fSPDVertex),
111 fPrimaryVertex(esd.fPrimaryVertex),
112 fSPDMult(esd.fSPDMult),
113 fT0timeStart(esd.fT0timeStart),
114 fTracks(*((TClonesArray*)esd.fTracks.Clone())),
115 fHLTConfMapTracks(*((TClonesArray*)esd.fHLTConfMapTracks.Clone())),
116 fHLTHoughTracks(*((TClonesArray*)esd.fHLTHoughTracks.Clone())),
117 fMuonTracks(*((TClonesArray*)esd.fMuonTracks.Clone())),
118 fPmdTracks(*((TClonesArray*)esd.fPmdTracks.Clone())),
119 fTrdTracks(*((TClonesArray*)esd.fTrdTracks.Clone())),
120 fV0s(*((TClonesArray*)esd.fV0s.Clone())),
121 fCascades(*((TClonesArray*)esd.fCascades.Clone())),
122 fKinks(*((TClonesArray*)esd.fKinks.Clone())),
123 fCaloClusters(*((TClonesArray*)esd.fCaloClusters.Clone())),
124 fEMCALClusters(esd.fEMCALClusters),
125 fFirstEMCALCluster(esd.fFirstEMCALCluster),
126 fEMCALTriggerPosition(esd. fEMCALTriggerPosition),
127 fEMCALTriggerAmplitudes(esd.fEMCALTriggerAmplitudes),
128 fPHOSClusters(esd.fPHOSClusters),
129 fFirstPHOSCluster(esd.fFirstPHOSCluster),
130 fPHOSTriggerPosition(esd.fPHOSTriggerPosition),
131 fPHOSTriggerAmplitudes(esd.fPHOSTriggerAmplitudes),
132 fESDFMD(esd.fESDFMD),
133 fESDVZERO(esd.fESDVZERO),
134 fESDACORDE(esd.fESDACORDE),
135 fErrorLogs(*((TClonesArray*)esd.fErrorLogs.Clone()))
140 for (Int_t i=0; i<24; i++) {
141 fT0time[i] = esd.fT0time[i];
142 fT0amplitude[i] = esd.fT0amplitude[i];
144 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
145 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
148 //______________________________________________________________________________
152 // Standard destructor
155 fHLTConfMapTracks.Delete();
156 fHLTHoughTracks.Delete();
157 fMuonTracks.Delete();
163 fCaloClusters.Delete();
166 delete fEMCALTriggerPosition;
167 delete fEMCALTriggerAmplitudes;
168 delete fPHOSTriggerPosition;
169 delete fPHOSTriggerAmplitudes;
176 //______________________________________________________________________________
180 // Reset the contents and delete the entries in TClonesArrays
183 fEventNumberInFile=0;
202 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
203 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=0.;
205 for (Int_t i=0; i<24; i++) {
211 fSPDMult.~AliMultiplicity();
212 new (&fSPDMult) AliMultiplicity();
213 fSPDVertex.~AliESDVertex();
214 new (&fSPDVertex) AliESDVertex();
215 fPrimaryVertex.~AliESDVertex();
216 new (&fPrimaryVertex) AliESDVertex();
219 fHLTConfMapTracks.Delete();
220 fHLTHoughTracks.Delete();
221 fMuonTracks.Delete();
227 fCaloClusters.Delete();
230 fFirstEMCALCluster=-1;
232 fFirstPHOSCluster=-1;
234 if (fEMCALTriggerPosition) fEMCALTriggerPosition ->Reset();
235 if (fEMCALTriggerAmplitudes) fEMCALTriggerAmplitudes->Reset();
236 if (fPHOSTriggerPosition) fPHOSTriggerPosition ->Reset();
237 if (fPHOSTriggerAmplitudes) fPHOSTriggerAmplitudes ->Reset();
239 if (fESDFMD) fESDFMD->Clear();
242 fESDVZERO->~AliESDVZERO();
243 new (fESDVZERO) AliESDVZERO();
247 fESDACORDE->~AliESDACORDE();
248 new (fESDACORDE) AliESDACORDE();
255 Bool_t AliESD::RemoveKink(Int_t rm) {
256 // ---------------------------------------------------------
257 // Remove a kink candidate and references to it from ESD,
258 // if this candidate does not come from a reconstructed decay
259 // Not yet implemented...
260 // ---------------------------------------------------------
261 Int_t last=GetNumberOfKinks()-1;
262 if ((rm<0)||(rm>last)) return kFALSE;
267 Bool_t AliESD::RemoveV0(Int_t rm) {
268 // ---------------------------------------------------------
269 // Remove a V0 candidate and references to it from ESD,
270 // if this candidate does not come from a reconstructed decay
271 // ---------------------------------------------------------
272 Int_t last=GetNumberOfV0s()-1;
273 if ((rm<0)||(rm>last)) return kFALSE;
275 AliESDv0 *v0=GetV0(rm);
276 Int_t idxP=v0->GetPindex(), idxN=v0->GetNindex();
279 Int_t lastIdxP=v0->GetPindex(), lastIdxN=v0->GetNindex();
283 // Check if this V0 comes from a reconstructed decay
284 Int_t ncs=GetNumberOfCascades();
285 for (Int_t n=0; n<ncs; n++) {
286 AliESDcascade *cs=GetCascade(n);
288 Int_t csIdxP=cs->GetPindex();
289 Int_t csIdxN=cs->GetNindex();
292 if (idxN==csIdxN) return kFALSE;
294 if (csIdxP==lastIdxP)
295 if (csIdxN==lastIdxN) used++;
298 //Replace the removed V0 with the last V0
299 TClonesArray &a=fV0s;
300 delete a.RemoveAt(rm);
302 if (rm==last) return kTRUE;
304 //v0 is pointing to the last V0 candidate...
305 new (a[rm]) AliESDv0(*v0);
306 delete a.RemoveAt(last);
308 if (!used) return kTRUE;
311 // Remap the indices of the daughters of reconstructed decays
312 for (Int_t n=0; n<ncs; n++) {
313 AliESDcascade *cs=GetCascade(n);
316 Int_t csIdxP=cs->GetPindex();
317 Int_t csIdxN=cs->GetNindex();
319 if (csIdxP==lastIdxP)
320 if (csIdxN==lastIdxN) {
321 cs->AliESDv0::SetIndex(1,idxP);
322 cs->AliESDv0::SetIndex(0,idxN);
324 if (!used) return kTRUE;
331 Bool_t AliESD::RemoveTrack(Int_t rm) {
332 // ---------------------------------------------------------
333 // Remove a track and references to it from ESD,
334 // if this track does not come from a reconstructed decay
335 // ---------------------------------------------------------
336 Int_t last=GetNumberOfTracks()-1;
337 if ((rm<0)||(rm>last)) return kFALSE;
341 // Check if this track comes from the reconstructed primary vertex
342 if (fPrimaryVertex.GetStatus()) {
343 UShort_t *primIdx=fPrimaryVertex.GetIndices();
344 Int_t n=fPrimaryVertex.GetNIndices();
346 Int_t idx=Int_t(primIdx[n]);
347 if (rm==idx) return kFALSE;
348 if (idx==last) used++;
352 // Check if this track comes from a reconstructed decay
353 Int_t nv0=GetNumberOfV0s();
354 for (Int_t n=0; n<nv0; n++) {
355 AliESDv0 *v0=GetV0(n);
357 Int_t idx=v0->GetNindex();
358 if (rm==idx) return kFALSE;
359 if (idx==last) used++;
362 if (rm==idx) return kFALSE;
363 if (idx==last) used++;
366 Int_t ncs=GetNumberOfCascades();
367 for (Int_t n=0; n<ncs; n++) {
368 AliESDcascade *cs=GetCascade(n);
370 Int_t idx=cs->GetIndex();
371 if (rm==idx) return kFALSE;
372 if (idx==last) used++;
375 Int_t nkn=GetNumberOfKinks();
376 for (Int_t n=0; n<nkn; n++) {
377 AliESDkink *kn=GetKink(n);
379 Int_t idx=kn->GetIndex(0);
380 if (rm==idx) return kFALSE;
381 if (idx==last) used++;
384 if (rm==idx) return kFALSE;
385 if (idx==last) used++;
389 //Replace the removed track with the last track
390 TClonesArray &a=fTracks;
391 delete a.RemoveAt(rm);
393 if (rm==last) return kTRUE;
395 AliESDtrack *t=GetTrack(last);
397 new (a[rm]) AliESDtrack(*t);
398 delete a.RemoveAt(last);
401 if (!used) return kTRUE;
404 // Remap the indices of the tracks used for the primary vertex reconstruction
405 if (fPrimaryVertex.GetStatus()) {
406 UShort_t *primIdx=fPrimaryVertex.GetIndices();
407 Int_t n=fPrimaryVertex.GetNIndices();
409 Int_t idx=Int_t(primIdx[n]);
411 primIdx[n]=Short_t(rm);
413 if (!used) return kTRUE;
418 // Remap the indices of the daughters of reconstructed decays
419 for (Int_t n=0; n<nv0; n++) {
420 AliESDv0 *v0=GetV0(n);
421 if (v0->GetIndex(0)==last) {
424 if (!used) return kTRUE;
426 if (v0->GetIndex(1)==last) {
429 if (!used) return kTRUE;
433 for (Int_t n=0; n<ncs; n++) {
434 AliESDcascade *cs=GetCascade(n);
435 if (cs->GetIndex()==last) {
438 if (!used) return kTRUE;
442 for (Int_t n=0; n<nkn; n++) {
443 AliESDkink *kn=GetKink(n);
444 if (kn->GetIndex(0)==last) {
447 if (!used) return kTRUE;
449 if (kn->GetIndex(1)==last) {
452 if (!used) return kTRUE;
460 Bool_t AliESD::Clean(Float_t *cleanPars) {
462 // Remove the data which are not needed for the physics analysis.
464 // 1) Cleaning the V0 candidates
465 // ---------------------------
466 // If the cosine of the V0 pointing angle "csp" and
467 // the DCA between the daughter tracks "dca" does not satisfy
470 // csp > cleanPars[1] + dca/cleanPars[0]*(1.- cleanPars[1])
472 // an attempt to remove this V0 candidate from ESD is made.
474 // The V0 candidate gets removed if it does not belong to any
475 // recosntructed cascade decay
477 // 12.11.2007, optimal values: cleanPars[0]=0.5, cleanPars[1]=0.999
479 // 2) Cleaning the tracks
480 // ----------------------
481 // If track's transverse parameter is larger than cleanPars[2]
483 // track's longitudinal parameter is larger than cleanPars[3]
484 // an attempt to remove this track from ESD is made.
486 // The track gets removed if it does not come
487 // from a reconstructed decay
491 Float_t dcaMax=cleanPars[0];
492 Float_t cspMin=cleanPars[1];
494 Int_t nV0s=GetNumberOfV0s();
495 for (Int_t i=nV0s-1; i>=0; i--) {
496 AliESDv0 *v0=GetV0(i);
498 Float_t dca=v0->GetDcaV0Daughters();
499 Float_t csp=v0->GetV0CosineOfPointingAngle();
500 Float_t cspcut=cspMin + dca/dcaMax*(1.-cspMin);
501 if (csp > cspcut) continue;
503 if (RemoveV0(i)) rc=kTRUE;
507 Float_t dmax=cleanPars[2], zmax=cleanPars[3];
509 const AliESDVertex *vertex=GetVertex();
510 Bool_t vtxOK=vertex->GetStatus();
512 Int_t nTracks=GetNumberOfTracks();
513 for (Int_t i=nTracks-1; i>=0; i--) {
514 AliESDtrack *track=GetTrack(i);
515 Float_t xy,z; track->GetImpactParameters(xy,z);
516 if ((TMath::Abs(xy) > dmax) || (vtxOK && (TMath::Abs(z) > zmax))) {
517 if (RemoveTrack(i)) rc=kTRUE;
524 Int_t AliESD::AddV0(const AliESDv0 *v) {
528 Int_t idx=fV0s.GetEntriesFast();
529 new(fV0s[idx]) AliESDv0(*v);
533 //______________________________________________________________________________
534 void AliESD::Print(Option_t *) const
537 // Print header information of the event
539 printf("ESD run information\n");
540 printf("Event # in file %d Bunch crossing # %d Orbit # %d Period # %d Run # %d Trigger %lld Magnetic field %f \n",
541 GetEventNumberInFile(),
542 GetBunchCrossNumber(),
547 GetMagneticField() );
548 printf("Vertex: (%.4f +- %.4f, %.4f +- %.4f, %.4f +- %.4f) cm\n",
549 fPrimaryVertex.GetXv(), fPrimaryVertex.GetXRes(),
550 fPrimaryVertex.GetYv(), fPrimaryVertex.GetYRes(),
551 fPrimaryVertex.GetZv(), fPrimaryVertex.GetZRes());
552 printf("Mean vertex in RUN: X=%.4f Y=%.4f cm\n",
553 GetDiamondX(),GetDiamondY());
554 printf("SPD Multiplicity. Number of tracklets %d \n",
555 fSPDMult.GetNumberOfTracklets());
556 printf("Event from reconstruction version %d \n",fRecoVersion);
557 printf("Number of tracks: \n");
558 printf(" charged %d\n", GetNumberOfTracks());
559 printf(" hlt CF %d\n", GetNumberOfHLTConfMapTracks());
560 printf(" hlt HT %d\n", GetNumberOfHLTHoughTracks());
561 printf(" muon %d\n", GetNumberOfMuonTracks());
562 printf(" pmd %d\n", GetNumberOfPmdTracks());
563 printf(" trd %d\n", GetNumberOfTrdTracks());
564 printf(" v0 %d\n", GetNumberOfV0s());
565 printf(" cascades %d\n", GetNumberOfCascades());
566 printf(" kinks %d\n", GetNumberOfKinks());
567 printf(" CaloClusters %d\n", GetNumberOfCaloClusters());
568 printf(" phos %d\n", GetNumberOfPHOSClusters());
569 printf(" emcal %d\n", GetNumberOfEMCALClusters());
570 printf(" FMD %s\n", (fESDFMD ? "yes" : "no"));
571 printf(" VZERO %s\n", (fESDVZERO ? "yes" : "no"));
574 void AliESD::SetESDfriend(const AliESDfriend *ev) {
576 // Attaches the complementary info to the ESD
580 Int_t ntrk=ev->GetNumberOfTracks();
582 for (Int_t i=0; i<ntrk; i++) {
583 const AliESDfriendTrack *f=ev->GetTrack(i);
584 GetTrack(i)->SetFriendTrack(f);
588 void AliESD::GetESDfriend(AliESDfriend *ev) const {
590 // Extracts the complementary info from the ESD
594 Int_t ntrk=GetNumberOfTracks();
596 for (Int_t i=0; i<ntrk; i++) {
597 AliESDtrack *t=GetTrack(i);
598 const AliESDfriendTrack *f=t->GetFriendTrack();
601 t->ReleaseESDfriendTrack();// Not to have two copies of "friendTrack"
606 void AliESD::SetDiamond(const AliESDVertex *vertex)
609 // Set the interaction diamond
611 fDiamondXY[0]=vertex->GetXv();
612 fDiamondXY[1]=vertex->GetYv();
614 vertex->GetCovMatrix(cov);
615 fDiamondCovXY[0]=cov[0];
616 fDiamondCovXY[1]=cov[1];
617 fDiamondCovXY[2]=cov[2];