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)
83 // Standar constructor
86 for (Int_t i=0; i<3; i++) fT0TOF[i] = 0;
87 for (Int_t i=0; i<24; i++) {
91 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
92 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=0.;
95 //______________________________________________________________________________
96 AliESD::AliESD(const AliESD& esd):
98 fEventNumberInFile(esd.fEventNumberInFile),
99 fBunchCrossNumber(esd.fBunchCrossNumber),
100 fOrbitNumber(esd.fOrbitNumber),
101 fPeriodNumber(esd.fPeriodNumber),
102 fRunNumber(esd.fRunNumber),
103 fTimeStamp(esd.fTimeStamp),
104 fEventType(esd.fEventType),
105 fTriggerMask(esd.fTriggerMask),
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),
143 fErrorLogs(*((TClonesArray*)esd.fErrorLogs.Clone()))
145 //, fESDMFT(esd.fESDMFT)
151 for (Int_t i=0; i<3; i++)fT0TOF[i] = esd.fT0TOF[i];
152 for (Int_t i=0; i<24; i++) {
153 fT0time[i] = esd.fT0time[i];
154 fT0amplitude[i] = esd.fT0amplitude[i];
156 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
157 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
160 //______________________________________________________________________________
164 // Standard destructor
167 fHLTConfMapTracks.Delete();
168 fHLTHoughTracks.Delete();
169 fMuonTracks.Delete();
175 fCaloClusters.Delete();
178 delete fEMCALTriggerPosition;
179 delete fEMCALTriggerAmplitudes;
180 delete fPHOSTriggerPosition;
181 delete fPHOSTriggerAmplitudes;
190 //______________________________________________________________________________
194 // Reset the contents and delete the entries in TClonesArrays
197 fEventNumberInFile=0;
216 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
217 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=0.;
219 for (Int_t i=0; i<24; i++) {
225 for (Int_t i=0; i<3; i++) fT0TOF[i] = 0;
227 fSPDMult.~AliMultiplicity();
228 new (&fSPDMult) AliMultiplicity();
229 fSPDVertex.~AliESDVertex();
230 new (&fSPDVertex) AliESDVertex();
231 fPrimaryVertex.~AliESDVertex();
232 new (&fPrimaryVertex) AliESDVertex();
235 fHLTConfMapTracks.Delete();
236 fHLTHoughTracks.Delete();
237 fMuonTracks.Delete();
243 fCaloClusters.Delete();
246 fFirstEMCALCluster=-1;
248 fFirstPHOSCluster=-1;
250 if (fEMCALTriggerPosition) fEMCALTriggerPosition ->Reset();
251 if (fEMCALTriggerAmplitudes) fEMCALTriggerAmplitudes->Reset();
252 if (fPHOSTriggerPosition) fPHOSTriggerPosition ->Reset();
253 if (fPHOSTriggerAmplitudes) fPHOSTriggerAmplitudes ->Reset();
255 if (fESDFMD) fESDFMD->Clear();
258 fESDVZERO->~AliESDVZERO();
259 new (fESDVZERO) AliESDVZERO();
263 fESDACORDE->~AliESDACORDE();
264 new (fESDACORDE) AliESDACORDE();
269 // fESDMFT->~AliESDMFT();
270 // new (fESDMFT) AliESDMFT();
278 Bool_t AliESD::RemoveKink(Int_t rm) {
279 // ---------------------------------------------------------
280 // Remove a kink candidate and references to it from ESD,
281 // if this candidate does not come from a reconstructed decay
282 // Not yet implemented...
283 // ---------------------------------------------------------
284 Int_t last=GetNumberOfKinks()-1;
285 if ((rm<0)||(rm>last)) return kFALSE;
290 Bool_t AliESD::RemoveV0(Int_t rm) {
291 // ---------------------------------------------------------
292 // Remove a V0 candidate and references to it from ESD,
293 // if this candidate does not come from a reconstructed decay
294 // ---------------------------------------------------------
295 Int_t last=GetNumberOfV0s()-1;
296 if ((rm<0)||(rm>last)) return kFALSE;
298 AliESDv0 *v0=GetV0(rm);
299 Int_t idxP=v0->GetPindex(), idxN=v0->GetNindex();
302 Int_t lastIdxP=v0->GetPindex(), lastIdxN=v0->GetNindex();
306 // Check if this V0 comes from a reconstructed decay
307 Int_t ncs=GetNumberOfCascades();
308 for (Int_t n=0; n<ncs; n++) {
309 AliESDcascade *cs=GetCascade(n);
311 Int_t csIdxP=cs->GetPindex();
312 Int_t csIdxN=cs->GetNindex();
315 if (idxN==csIdxN) return kFALSE;
317 if (csIdxP==lastIdxP)
318 if (csIdxN==lastIdxN) used++;
321 //Replace the removed V0 with the last V0
322 TClonesArray &a=fV0s;
323 delete a.RemoveAt(rm);
325 if (rm==last) return kTRUE;
327 //v0 is pointing to the last V0 candidate...
328 new (a[rm]) AliESDv0(*v0);
329 delete a.RemoveAt(last);
331 if (!used) return kTRUE;
334 // Remap the indices of the daughters of reconstructed decays
335 for (Int_t n=0; n<ncs; n++) {
336 AliESDcascade *cs=GetCascade(n);
339 Int_t csIdxP=cs->GetPindex();
340 Int_t csIdxN=cs->GetNindex();
342 if (csIdxP==lastIdxP)
343 if (csIdxN==lastIdxN) {
344 cs->AliESDv0::SetIndex(1,idxP);
345 cs->AliESDv0::SetIndex(0,idxN);
347 if (!used) return kTRUE;
354 Bool_t AliESD::RemoveTrack(Int_t rm) {
355 // ---------------------------------------------------------
356 // Remove a track and references to it from ESD,
357 // if this track does not come from a reconstructed decay
358 // ---------------------------------------------------------
359 Int_t last=GetNumberOfTracks()-1;
360 if ((rm<0)||(rm>last)) return kFALSE;
364 // Check if this track comes from the reconstructed primary vertex
365 if (fPrimaryVertex.GetStatus()) {
366 UShort_t *primIdx=fPrimaryVertex.GetIndices();
367 Int_t n=fPrimaryVertex.GetNIndices();
369 Int_t idx=Int_t(primIdx[n]);
370 if (rm==idx) return kFALSE;
371 if (idx==last) used++;
375 // Check if this track comes from a reconstructed decay
376 Int_t nv0=GetNumberOfV0s();
377 for (Int_t n=0; n<nv0; n++) {
378 AliESDv0 *v0=GetV0(n);
380 Int_t idx=v0->GetNindex();
381 if (rm==idx) return kFALSE;
382 if (idx==last) used++;
385 if (rm==idx) return kFALSE;
386 if (idx==last) used++;
389 Int_t ncs=GetNumberOfCascades();
390 for (Int_t n=0; n<ncs; n++) {
391 AliESDcascade *cs=GetCascade(n);
393 Int_t idx=cs->GetIndex();
394 if (rm==idx) return kFALSE;
395 if (idx==last) used++;
398 Int_t nkn=GetNumberOfKinks();
399 for (Int_t n=0; n<nkn; n++) {
400 AliESDkink *kn=GetKink(n);
402 Int_t idx=kn->GetIndex(0);
403 if (rm==idx) return kFALSE;
404 if (idx==last) used++;
407 if (rm==idx) return kFALSE;
408 if (idx==last) used++;
412 //Replace the removed track with the last track
413 TClonesArray &a=fTracks;
414 delete a.RemoveAt(rm);
416 if (rm==last) return kTRUE;
418 AliESDtrack *t=GetTrack(last);
420 new (a[rm]) AliESDtrack(*t);
421 delete a.RemoveAt(last);
424 if (!used) return kTRUE;
427 // Remap the indices of the tracks used for the primary vertex reconstruction
428 if (fPrimaryVertex.GetStatus()) {
429 UShort_t *primIdx=fPrimaryVertex.GetIndices();
430 Int_t n=fPrimaryVertex.GetNIndices();
432 Int_t idx=Int_t(primIdx[n]);
434 primIdx[n]=Short_t(rm);
436 if (!used) return kTRUE;
441 // Remap the indices of the daughters of reconstructed decays
442 for (Int_t n=0; n<nv0; n++) {
443 AliESDv0 *v0=GetV0(n);
444 if (v0->GetIndex(0)==last) {
447 if (!used) return kTRUE;
449 if (v0->GetIndex(1)==last) {
452 if (!used) return kTRUE;
456 for (Int_t n=0; n<ncs; n++) {
457 AliESDcascade *cs=GetCascade(n);
458 if (cs->GetIndex()==last) {
461 if (!used) return kTRUE;
465 for (Int_t n=0; n<nkn; n++) {
466 AliESDkink *kn=GetKink(n);
467 if (kn->GetIndex(0)==last) {
470 if (!used) return kTRUE;
472 if (kn->GetIndex(1)==last) {
475 if (!used) return kTRUE;
483 Bool_t AliESD::Clean(Float_t *cleanPars) {
485 // Remove the data which are not needed for the physics analysis.
487 // 1) Cleaning the V0 candidates
488 // ---------------------------
489 // If the cosine of the V0 pointing angle "csp" and
490 // the DCA between the daughter tracks "dca" does not satisfy
493 // csp > cleanPars[1] + dca/cleanPars[0]*(1.- cleanPars[1])
495 // an attempt to remove this V0 candidate from ESD is made.
497 // The V0 candidate gets removed if it does not belong to any
498 // recosntructed cascade decay
500 // 12.11.2007, optimal values: cleanPars[0]=0.5, cleanPars[1]=0.999
502 // 2) Cleaning the tracks
503 // ----------------------
504 // If track's transverse parameter is larger than cleanPars[2]
506 // track's longitudinal parameter is larger than cleanPars[3]
507 // an attempt to remove this track from ESD is made.
509 // The track gets removed if it does not come
510 // from a reconstructed decay
514 Float_t dcaMax=cleanPars[0];
515 Float_t cspMin=cleanPars[1];
517 Int_t nV0s=GetNumberOfV0s();
518 for (Int_t i=nV0s-1; i>=0; i--) {
519 AliESDv0 *v0=GetV0(i);
521 Float_t dca=v0->GetDcaV0Daughters();
522 Float_t csp=v0->GetV0CosineOfPointingAngle();
523 Float_t cspcut=cspMin + dca/dcaMax*(1.-cspMin);
524 if (csp > cspcut) continue;
526 if (RemoveV0(i)) rc=kTRUE;
530 Float_t dmax=cleanPars[2], zmax=cleanPars[3];
532 const AliESDVertex *vertex=GetVertex();
533 Bool_t vtxOK=vertex->GetStatus();
535 Int_t nTracks=GetNumberOfTracks();
536 for (Int_t i=nTracks-1; i>=0; i--) {
537 AliESDtrack *track=GetTrack(i);
538 Float_t xy,z; track->GetImpactParameters(xy,z);
539 if ((TMath::Abs(xy) > dmax) || (vtxOK && (TMath::Abs(z) > zmax))) {
540 if (RemoveTrack(i)) rc=kTRUE;
547 Int_t AliESD::AddV0(const AliESDv0 *v) {
551 Int_t idx=fV0s.GetEntriesFast();
552 new(fV0s[idx]) AliESDv0(*v);
556 //______________________________________________________________________________
557 void AliESD::Print(Option_t *) const
560 // Print header information of the event
562 printf("ESD run information\n");
563 printf("Event # in file %d Bunch crossing # %d Orbit # %d Period # %d Run # %d Trigger %lld Magnetic field %f \n",
564 GetEventNumberInFile(),
565 GetBunchCrossNumber(),
570 GetMagneticField() );
571 printf("Vertex: (%.4f +- %.4f, %.4f +- %.4f, %.4f +- %.4f) cm\n",
572 fPrimaryVertex.GetXv(), fPrimaryVertex.GetXRes(),
573 fPrimaryVertex.GetYv(), fPrimaryVertex.GetYRes(),
574 fPrimaryVertex.GetZv(), 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"));
596 // printf(" MFT %s\n", (fESDMFT ? "yes" : "no"));
600 void AliESD::SetESDfriend(const AliESDfriend *ev) {
602 // Attaches the complementary info to the ESD
606 Int_t ntrk=ev->GetNumberOfTracks();
608 for (Int_t i=0; i<ntrk; i++) {
609 const AliESDfriendTrack *f=ev->GetTrack(i);
610 GetTrack(i)->SetFriendTrack(f);
614 void AliESD::GetESDfriend(AliESDfriend *ev) const {
616 // Extracts the complementary info from the ESD
620 Int_t ntrk=GetNumberOfTracks();
622 for (Int_t i=0; i<ntrk; i++) {
623 AliESDtrack *t=GetTrack(i);
624 const AliESDfriendTrack *f=t->GetFriendTrack();
627 t->ReleaseESDfriendTrack();// Not to have two copies of "friendTrack"
632 void AliESD::SetDiamond(const AliESDVertex *vertex)
635 // Set the interaction diamond
637 fDiamondXY[0]=vertex->GetXv();
638 fDiamondXY[1]=vertex->GetYv();
640 vertex->GetCovMatrix(cov);
641 fDiamondCovXY[0]=cov[0];
642 fDiamondCovXY[1]=cov[1];
643 fDiamondCovXY[2]=cov[2];