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),
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),
77 fErrorLogs("AliRawDataErrorLog",5)
80 // Standar constructor
83 for (Int_t i=0; i<3; i++) fT0TOF[i] = 0;
84 for (Int_t i=0; i<24; i++) {
88 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
89 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=0.;
92 //______________________________________________________________________________
93 AliESD::AliESD(const AliESD& esd):
95 fEventNumberInFile(esd.fEventNumberInFile),
96 fBunchCrossNumber(esd.fBunchCrossNumber),
97 fOrbitNumber(esd.fOrbitNumber),
98 fPeriodNumber(esd.fPeriodNumber),
99 fRunNumber(esd.fRunNumber),
100 fTimeStamp(esd.fTimeStamp),
101 fEventType(esd.fEventType),
102 fTriggerMask(esd.fTriggerMask),
103 fTriggerCluster(esd.fTriggerCluster),
104 fRecoVersion(esd.fRecoVersion),
105 fMagneticField(esd.fMagneticField),
106 fZDCN1Energy(esd.fZDCN1Energy),
107 fZDCP1Energy(esd.fZDCP1Energy),
108 fZDCN2Energy(esd.fZDCN2Energy),
109 fZDCP2Energy(esd.fZDCP2Energy),
110 fZDCEMEnergy(esd.fZDCEMEnergy),
111 fZDCParticipants(esd.fZDCParticipants),
112 fT0zVertex(esd.fT0zVertex),
113 fSPDVertex(esd.fSPDVertex),
114 fPrimaryVertex(esd.fPrimaryVertex),
115 fSPDMult(esd.fSPDMult),
116 fT0clock(esd.fT0clock),
117 fT0timeStart(esd.fT0timeStart),
118 fT0trig(esd.fT0trig),
119 fTracks(*((TClonesArray*)esd.fTracks.Clone())),
120 fHLTConfMapTracks(*((TClonesArray*)esd.fHLTConfMapTracks.Clone())),
121 fHLTHoughTracks(*((TClonesArray*)esd.fHLTHoughTracks.Clone())),
122 fMuonTracks(*((TClonesArray*)esd.fMuonTracks.Clone())),
123 fPmdTracks(*((TClonesArray*)esd.fPmdTracks.Clone())),
124 fTrdTracks(*((TClonesArray*)esd.fTrdTracks.Clone())),
125 fV0s(*((TClonesArray*)esd.fV0s.Clone())),
126 fCascades(*((TClonesArray*)esd.fCascades.Clone())),
127 fKinks(*((TClonesArray*)esd.fKinks.Clone())),
128 fCaloClusters(*((TClonesArray*)esd.fCaloClusters.Clone())),
129 fEMCALClusters(esd.fEMCALClusters),
130 fFirstEMCALCluster(esd.fFirstEMCALCluster),
131 fEMCALTriggerPosition(esd. fEMCALTriggerPosition),
132 fEMCALTriggerAmplitudes(esd.fEMCALTriggerAmplitudes),
133 fPHOSClusters(esd.fPHOSClusters),
134 fFirstPHOSCluster(esd.fFirstPHOSCluster),
135 fPHOSTriggerPosition(esd.fPHOSTriggerPosition),
136 fPHOSTriggerAmplitudes(esd.fPHOSTriggerAmplitudes),
137 fESDFMD(esd.fESDFMD),
138 fESDVZERO(esd.fESDVZERO),
139 fESDACORDE(esd.fESDACORDE),
140 fErrorLogs(*((TClonesArray*)esd.fErrorLogs.Clone()))
145 for (Int_t i=0; i<3; i++)fT0TOF[i] = esd.fT0TOF[i];
146 for (Int_t i=0; i<24; i++) {
147 fT0time[i] = esd.fT0time[i];
148 fT0amplitude[i] = esd.fT0amplitude[i];
150 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
151 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
154 //______________________________________________________________________________
158 // Standard destructor
161 fHLTConfMapTracks.Delete();
162 fHLTHoughTracks.Delete();
163 fMuonTracks.Delete();
169 fCaloClusters.Delete();
172 delete fEMCALTriggerPosition;
173 delete fEMCALTriggerAmplitudes;
174 delete fPHOSTriggerPosition;
175 delete fPHOSTriggerAmplitudes;
182 //______________________________________________________________________________
186 // Reset the contents and delete the entries in TClonesArrays
189 fEventNumberInFile=0;
208 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
209 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=0.;
211 for (Int_t i=0; i<24; i++) {
217 for (Int_t i=0; i<3; i++) fT0TOF[i] = 0;
219 fSPDMult.~AliMultiplicity();
220 new (&fSPDMult) AliMultiplicity();
221 fSPDVertex.~AliESDVertex();
222 new (&fSPDVertex) AliESDVertex();
223 fPrimaryVertex.~AliESDVertex();
224 new (&fPrimaryVertex) AliESDVertex();
227 fHLTConfMapTracks.Delete();
228 fHLTHoughTracks.Delete();
229 fMuonTracks.Delete();
235 fCaloClusters.Delete();
238 fFirstEMCALCluster=-1;
240 fFirstPHOSCluster=-1;
242 if (fEMCALTriggerPosition) fEMCALTriggerPosition ->Reset();
243 if (fEMCALTriggerAmplitudes) fEMCALTriggerAmplitudes->Reset();
244 if (fPHOSTriggerPosition) fPHOSTriggerPosition ->Reset();
245 if (fPHOSTriggerAmplitudes) fPHOSTriggerAmplitudes ->Reset();
247 if (fESDFMD) fESDFMD->Clear();
250 fESDVZERO->~AliESDVZERO();
251 new (fESDVZERO) AliESDVZERO();
255 fESDACORDE->~AliESDACORDE();
256 new (fESDACORDE) AliESDACORDE();
263 Bool_t AliESD::RemoveKink(Int_t rm) {
264 // ---------------------------------------------------------
265 // Remove a kink candidate and references to it from ESD,
266 // if this candidate does not come from a reconstructed decay
267 // Not yet implemented...
268 // ---------------------------------------------------------
269 Int_t last=GetNumberOfKinks()-1;
270 if ((rm<0)||(rm>last)) return kFALSE;
275 Bool_t AliESD::RemoveV0(Int_t rm) {
276 // ---------------------------------------------------------
277 // Remove a V0 candidate and references to it from ESD,
278 // if this candidate does not come from a reconstructed decay
279 // ---------------------------------------------------------
280 Int_t last=GetNumberOfV0s()-1;
281 if ((rm<0)||(rm>last)) return kFALSE;
283 AliESDv0 *v0=GetV0(rm);
284 Int_t idxP=v0->GetPindex(), idxN=v0->GetNindex();
287 Int_t lastIdxP=v0->GetPindex(), lastIdxN=v0->GetNindex();
291 // Check if this V0 comes from a reconstructed decay
292 Int_t ncs=GetNumberOfCascades();
293 for (Int_t n=0; n<ncs; n++) {
294 AliESDcascade *cs=GetCascade(n);
296 Int_t csIdxP=cs->GetPindex();
297 Int_t csIdxN=cs->GetNindex();
300 if (idxN==csIdxN) return kFALSE;
302 if (csIdxP==lastIdxP)
303 if (csIdxN==lastIdxN) used++;
306 //Replace the removed V0 with the last V0
307 TClonesArray &a=fV0s;
308 delete a.RemoveAt(rm);
310 if (rm==last) return kTRUE;
312 //v0 is pointing to the last V0 candidate...
313 new (a[rm]) AliESDv0(*v0);
314 delete a.RemoveAt(last);
316 if (!used) return kTRUE;
319 // Remap the indices of the daughters of reconstructed decays
320 for (Int_t n=0; n<ncs; n++) {
321 AliESDcascade *cs=GetCascade(n);
324 Int_t csIdxP=cs->GetPindex();
325 Int_t csIdxN=cs->GetNindex();
327 if (csIdxP==lastIdxP)
328 if (csIdxN==lastIdxN) {
329 cs->AliESDv0::SetIndex(1,idxP);
330 cs->AliESDv0::SetIndex(0,idxN);
332 if (!used) return kTRUE;
339 Bool_t AliESD::RemoveTrack(Int_t rm) {
340 // ---------------------------------------------------------
341 // Remove a track and references to it from ESD,
342 // if this track does not come from a reconstructed decay
343 // ---------------------------------------------------------
344 Int_t last=GetNumberOfTracks()-1;
345 if ((rm<0)||(rm>last)) return kFALSE;
349 // Check if this track comes from the reconstructed primary vertex
350 if (fPrimaryVertex.GetStatus()) {
351 UShort_t *primIdx=fPrimaryVertex.GetIndices();
352 Int_t n=fPrimaryVertex.GetNIndices();
354 Int_t idx=Int_t(primIdx[n]);
355 if (rm==idx) return kFALSE;
356 if (idx==last) used++;
360 // Check if this track comes from a reconstructed decay
361 Int_t nv0=GetNumberOfV0s();
362 for (Int_t n=0; n<nv0; n++) {
363 AliESDv0 *v0=GetV0(n);
365 Int_t idx=v0->GetNindex();
366 if (rm==idx) return kFALSE;
367 if (idx==last) used++;
370 if (rm==idx) return kFALSE;
371 if (idx==last) used++;
374 Int_t ncs=GetNumberOfCascades();
375 for (Int_t n=0; n<ncs; n++) {
376 AliESDcascade *cs=GetCascade(n);
378 Int_t idx=cs->GetIndex();
379 if (rm==idx) return kFALSE;
380 if (idx==last) used++;
383 Int_t nkn=GetNumberOfKinks();
384 for (Int_t n=0; n<nkn; n++) {
385 AliESDkink *kn=GetKink(n);
387 Int_t idx=kn->GetIndex(0);
388 if (rm==idx) return kFALSE;
389 if (idx==last) used++;
392 if (rm==idx) return kFALSE;
393 if (idx==last) used++;
397 //Replace the removed track with the last track
398 TClonesArray &a=fTracks;
399 delete a.RemoveAt(rm);
401 if (rm==last) return kTRUE;
403 AliESDtrack *t=GetTrack(last);
405 new (a[rm]) AliESDtrack(*t);
406 delete a.RemoveAt(last);
409 if (!used) return kTRUE;
412 // Remap the indices of the tracks used for the primary vertex reconstruction
413 if (fPrimaryVertex.GetStatus()) {
414 UShort_t *primIdx=fPrimaryVertex.GetIndices();
415 Int_t n=fPrimaryVertex.GetNIndices();
417 Int_t idx=Int_t(primIdx[n]);
419 primIdx[n]=Short_t(rm);
421 if (!used) return kTRUE;
426 // Remap the indices of the daughters of reconstructed decays
427 for (Int_t n=0; n<nv0; n++) {
428 AliESDv0 *v0=GetV0(n);
429 if (v0->GetIndex(0)==last) {
432 if (!used) return kTRUE;
434 if (v0->GetIndex(1)==last) {
437 if (!used) return kTRUE;
441 for (Int_t n=0; n<ncs; n++) {
442 AliESDcascade *cs=GetCascade(n);
443 if (cs->GetIndex()==last) {
446 if (!used) return kTRUE;
450 for (Int_t n=0; n<nkn; n++) {
451 AliESDkink *kn=GetKink(n);
452 if (kn->GetIndex(0)==last) {
455 if (!used) return kTRUE;
457 if (kn->GetIndex(1)==last) {
460 if (!used) return kTRUE;
468 Bool_t AliESD::Clean(Float_t *cleanPars) {
470 // Remove the data which are not needed for the physics analysis.
472 // 1) Cleaning the V0 candidates
473 // ---------------------------
474 // If the cosine of the V0 pointing angle "csp" and
475 // the DCA between the daughter tracks "dca" does not satisfy
478 // csp > cleanPars[1] + dca/cleanPars[0]*(1.- cleanPars[1])
480 // an attempt to remove this V0 candidate from ESD is made.
482 // The V0 candidate gets removed if it does not belong to any
483 // recosntructed cascade decay
485 // 12.11.2007, optimal values: cleanPars[0]=0.5, cleanPars[1]=0.999
487 // 2) Cleaning the tracks
488 // ----------------------
489 // If track's transverse parameter is larger than cleanPars[2]
491 // track's longitudinal parameter is larger than cleanPars[3]
492 // an attempt to remove this track from ESD is made.
494 // The track gets removed if it does not come
495 // from a reconstructed decay
499 Float_t dcaMax=cleanPars[0];
500 Float_t cspMin=cleanPars[1];
502 Int_t nV0s=GetNumberOfV0s();
503 for (Int_t i=nV0s-1; i>=0; i--) {
504 AliESDv0 *v0=GetV0(i);
506 Float_t dca=v0->GetDcaV0Daughters();
507 Float_t csp=v0->GetV0CosineOfPointingAngle();
508 Float_t cspcut=cspMin + dca/dcaMax*(1.-cspMin);
509 if (csp > cspcut) continue;
511 if (RemoveV0(i)) rc=kTRUE;
515 Float_t dmax=cleanPars[2], zmax=cleanPars[3];
517 const AliESDVertex *vertex=GetVertex();
518 Bool_t vtxOK=vertex->GetStatus();
520 Int_t nTracks=GetNumberOfTracks();
521 for (Int_t i=nTracks-1; i>=0; i--) {
522 AliESDtrack *track=GetTrack(i);
523 Float_t xy,z; track->GetImpactParameters(xy,z);
524 if ((TMath::Abs(xy) > dmax) || (vtxOK && (TMath::Abs(z) > zmax))) {
525 if (RemoveTrack(i)) rc=kTRUE;
532 Int_t AliESD::AddV0(const AliESDv0 *v) {
536 Int_t idx=fV0s.GetEntriesFast();
537 new(fV0s[idx]) AliESDv0(*v);
541 //______________________________________________________________________________
542 void AliESD::Print(Option_t *) const
545 // Print header information of the event
547 printf("ESD run information\n");
548 printf("Event # in file %d Bunch crossing # %d Orbit # %d Period # %d Run # %d Trigger %lld Magnetic field %f \n",
549 GetEventNumberInFile(),
550 GetBunchCrossNumber(),
555 GetMagneticField() );
556 printf("Vertex: (%.4f +- %.4f, %.4f +- %.4f, %.4f +- %.4f) cm\n",
557 fPrimaryVertex.GetXv(), fPrimaryVertex.GetXRes(),
558 fPrimaryVertex.GetYv(), fPrimaryVertex.GetYRes(),
559 fPrimaryVertex.GetZv(), fPrimaryVertex.GetZRes());
560 printf("Mean vertex in RUN: X=%.4f Y=%.4f cm\n",
561 GetDiamondX(),GetDiamondY());
562 printf("SPD Multiplicity. Number of tracklets %d \n",
563 fSPDMult.GetNumberOfTracklets());
564 printf("Event from reconstruction version %d \n",fRecoVersion);
565 printf("Number of tracks: \n");
566 printf(" charged %d\n", GetNumberOfTracks());
567 printf(" hlt CF %d\n", GetNumberOfHLTConfMapTracks());
568 printf(" hlt HT %d\n", GetNumberOfHLTHoughTracks());
569 printf(" muon %d\n", GetNumberOfMuonTracks());
570 printf(" pmd %d\n", GetNumberOfPmdTracks());
571 printf(" trd %d\n", GetNumberOfTrdTracks());
572 printf(" v0 %d\n", GetNumberOfV0s());
573 printf(" cascades %d\n", GetNumberOfCascades());
574 printf(" kinks %d\n", GetNumberOfKinks());
575 printf(" CaloClusters %d\n", GetNumberOfCaloClusters());
576 printf(" phos %d\n", GetNumberOfPHOSClusters());
577 printf(" emcal %d\n", GetNumberOfEMCALClusters());
578 printf(" FMD %s\n", (fESDFMD ? "yes" : "no"));
579 printf(" VZERO %s\n", (fESDVZERO ? "yes" : "no"));
582 void AliESD::SetESDfriend(const AliESDfriend *ev) {
584 // Attaches the complementary info to the ESD
588 Int_t ntrk=ev->GetNumberOfTracks();
590 for (Int_t i=0; i<ntrk; i++) {
591 const AliESDfriendTrack *f=ev->GetTrack(i);
592 GetTrack(i)->SetFriendTrack(f);
596 void AliESD::GetESDfriend(AliESDfriend *ev) const {
598 // Extracts the complementary info from the ESD
602 Int_t ntrk=GetNumberOfTracks();
604 for (Int_t i=0; i<ntrk; i++) {
605 AliESDtrack *t=GetTrack(i);
606 const AliESDfriendTrack *f=t->GetFriendTrack();
609 t->ReleaseESDfriendTrack();// Not to have two copies of "friendTrack"
614 void AliESD::SetDiamond(const AliESDVertex *vertex)
617 // Set the interaction diamond
619 fDiamondXY[0]=vertex->GetXv();
620 fDiamondXY[1]=vertex->GetYv();
622 vertex->GetCovMatrix(cov);
623 fDiamondCovXY[0]=cov[0];
624 fDiamondCovXY[1]=cov[1];
625 fDiamondCovXY[2]=cov[2];