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: AliESDEvent.cxx 64008 2013-08-28 13:09:59Z hristov $ */
18 //-----------------------------------------------------------------
19 // Implementation of the AliESDEvent class
20 // This is the class to deal with during the physics analysis of data.
21 // It also ensures the backward compatibility with the old ESD format.
23 AliESDEvent *ev= new AliESDEvent();
24 ev->ReadFromTree(esdTree);
26 for (Int_t i=0; i<nev; i++) {
28 if(ev->GetAliESDOld())ev->CopyFromOldESD();
30 // The AliESDInputHandler does this automatically for you
32 // Origin: Christian Klein-Boesing, CERN, Christian.Klein-Boesing@cern.ch
33 //-----------------------------------------------------------------
36 #include "TRefArray.h"
39 #include <TInterpreter.h>
41 #include "AliESDEvent.h"
42 #include "AliESDfriend.h"
43 #include "AliESDVZERO.h"
44 #include "AliESDFMD.h"
46 #include "AliESDMuonTrack.h"
47 #include "AliESDMuonCluster.h"
48 #include "AliESDMuonPad.h"
49 #include "AliESDMuonGlobalTrack.h" // AU
50 #include "AliESDPmdTrack.h"
51 #include "AliESDTrdTrack.h"
52 #include "AliESDVertex.h"
53 #include "AliESDcascade.h"
54 #include "AliESDPmdTrack.h"
55 #include "AliESDTrdTrigger.h"
56 #include "AliESDTrdTrack.h"
57 #include "AliESDTrdTracklet.h"
58 #include "AliESDVertex.h"
59 #include "AliVertexerTracks.h"
60 #include "AliESDcascade.h"
61 #include "AliESDkink.h"
62 #include "AliESDtrack.h"
63 #include "AliESDHLTtrack.h"
64 #include "AliESDCaloCluster.h"
65 #include "AliESDCaloCells.h"
67 #include "AliESDFMD.h"
68 #include "AliESDVZERO.h"
69 #include "AliMultiplicity.h"
70 #include "AliRawDataErrorLog.h"
72 #include "AliESDACORDE.h"
74 #include "AliESDHLTDecision.h"
75 #include "AliCentrality.h"
76 #include "AliESDCosmicTrack.h"
77 #include "AliTriggerConfiguration.h"
78 #include "AliTriggerClass.h"
79 #include "AliTriggerCluster.h"
80 #include "AliEventplane.h"
87 // here we define the names, some classes are no TNamed, therefore the classnames
89 const char* AliESDEvent::fgkESDListName[kESDListN] = {"AliESDRun",
107 "MuonGlobalTracks", // AU
118 "AliRawDataErrorLogs",
128 //______________________________________________________________________________
129 AliESDEvent::AliESDEvent():
131 fESDObjects(new TList()),
147 fSPDPileupVertices(0),
148 fTrkPileupVertices(0),
153 fMuonGlobalTracks(0), // AU
161 fEMCALCells(0), fPHOSCells(0),
167 fOldMuonStructure(kFALSE),
172 fTracksConnected(kFALSE),
176 fDetectorStatus(0xFFFFFFFF),
177 fDAQDetectorPattern(0xFFFF),
178 fDAQAttributes(0xFFFF)
181 //______________________________________________________________________________
182 AliESDEvent::AliESDEvent(const AliESDEvent& esd):
184 fESDObjects(new TList()),
185 fESDRun(new AliESDRun(*esd.fESDRun)),
186 fHeader(new AliESDHeader(*esd.fHeader)),
187 fESDZDC(new AliESDZDC(*esd.fESDZDC)),
188 fESDFMD(new AliESDFMD(*esd.fESDFMD)),
189 fESDVZERO(new AliESDVZERO(*esd.fESDVZERO)),
190 fESDTZERO(new AliESDTZERO(*esd.fESDTZERO)),
191 fTPCVertex(new AliESDVertex(*esd.fTPCVertex)),
192 fSPDVertex(new AliESDVertex(*esd.fSPDVertex)),
193 fPrimaryVertex(new AliESDVertex(*esd.fPrimaryVertex)),
194 fSPDMult(new AliMultiplicity(*esd.fSPDMult)),
195 fPHOSTrigger(new AliESDCaloTrigger(*esd.fPHOSTrigger)),
196 fEMCALTrigger(new AliESDCaloTrigger(*esd.fEMCALTrigger)),
197 fESDACORDE(new AliESDACORDE(*esd.fESDACORDE)),
198 fESDAD(new AliESDAD(*esd.fESDAD)),
199 fTrdTrigger(new AliESDTrdTrigger(*esd.fTrdTrigger)),
200 fSPDPileupVertices(new TClonesArray(*esd.fSPDPileupVertices)),
201 fTrkPileupVertices(new TClonesArray(*esd.fTrkPileupVertices)),
202 fTracks(new TClonesArray(*esd.fTracks)),
203 fMuonTracks(new TClonesArray(*esd.fMuonTracks)),
204 fMuonClusters(new TClonesArray(*esd.fMuonClusters)),
205 fMuonPads(new TClonesArray(*esd.fMuonPads)),
206 fMuonGlobalTracks(new TClonesArray(*esd.fMuonGlobalTracks)), // AU
207 fPmdTracks(new TClonesArray(*esd.fPmdTracks)),
208 fTrdTracks(new TClonesArray(*esd.fTrdTracks)),
209 fTrdTracklets(new TClonesArray(*esd.fTrdTracklets)),
210 fV0s(new TClonesArray(*esd.fV0s)),
211 fCascades(new TClonesArray(*esd.fCascades)),
212 fKinks(new TClonesArray(*esd.fKinks)),
213 fCaloClusters(new TClonesArray(*esd.fCaloClusters)),
214 fEMCALCells(new AliESDCaloCells(*esd.fEMCALCells)),
215 fPHOSCells(new AliESDCaloCells(*esd.fPHOSCells)),
216 fCosmicTracks(new TClonesArray(*esd.fCosmicTracks)),
217 fESDTOFClusters(esd.fESDTOFClusters ? new TClonesArray(*esd.fESDTOFClusters) : 0),
218 fESDTOFHits(esd.fESDTOFHits ? new TClonesArray(*esd.fESDTOFHits) : 0),
219 fESDTOFMatches(esd.fESDTOFMatches ? new TClonesArray(*esd.fESDTOFMatches) : 0),
220 fErrorLogs(new TClonesArray(*esd.fErrorLogs)),
221 fOldMuonStructure(esd.fOldMuonStructure),
222 fESDOld(esd.fESDOld ? new AliESD(*esd.fESDOld) : 0),
223 fESDFriendOld(esd.fESDFriendOld ? new AliESDfriend(*esd.fESDFriendOld) : 0),
224 fConnected(esd.fConnected),
225 fUseOwnList(esd.fUseOwnList),
226 fTracksConnected(kFALSE),
227 fTOFHeader(new AliTOFHeader(*esd.fTOFHeader)),
228 fCentrality(new AliCentrality(*esd.fCentrality)),
229 fEventplane(new AliEventplane(*esd.fEventplane)),
230 fDetectorStatus(esd.fDetectorStatus),
231 fDAQDetectorPattern(esd.fDAQDetectorPattern),
232 fDAQAttributes(esd.fDAQAttributes)
234 printf("copying ESD event...\n"); // AU
235 // CKB init in the constructor list and only add here ...
240 AddObject(fESDVZERO);
241 AddObject(fESDTZERO);
242 AddObject(fTPCVertex);
243 AddObject(fSPDVertex);
244 AddObject(fPrimaryVertex);
246 AddObject(fPHOSTrigger);
247 AddObject(fEMCALTrigger);
248 AddObject(fTrdTrigger);
249 AddObject(fSPDPileupVertices);
250 AddObject(fTrkPileupVertices);
252 AddObject(fMuonTracks);
253 AddObject(fMuonGlobalTracks); // AU
254 AddObject(fPmdTracks);
255 AddObject(fTrdTracks);
256 AddObject(fTrdTracklets);
258 AddObject(fCascades);
260 AddObject(fCaloClusters);
261 AddObject(fEMCALCells);
262 AddObject(fPHOSCells);
263 AddObject(fCosmicTracks);
264 AddObject(fESDTOFClusters);
265 AddObject(fESDTOFHits);
266 AddObject(fESDTOFMatches);
267 AddObject(fErrorLogs);
268 AddObject(fESDACORDE);
270 AddObject(fTOFHeader);
271 AddObject(fMuonClusters);
272 AddObject(fMuonPads);
277 //______________________________________________________________________________
278 AliESDEvent & AliESDEvent::operator=(const AliESDEvent& source) {
280 // Assignment operator
281 printf("operator = ESD\n");
282 if(&source == this) return *this;
283 AliVEvent::operator=(source);
285 // This assumes that the list is already created
286 // and that the virtual void Copy(Tobject&) function
287 // is correctly implemented in the derived class
288 // otherwise only TObject::Copy() will be used
292 if((fESDObjects->GetSize()==0)&&(source.fESDObjects->GetSize()>=kESDListN)){
293 // We cover the case that we do not yet have the
294 // standard content but the source has it
298 TIter next(source.GetList());
301 while ((its = next())) {
302 name.Form("%s", its->GetName());
303 TObject *mine = fESDObjects->FindObject(name.Data());
305 TClass* pClass=TClass::GetClass(its->ClassName());
307 AliWarning(Form("Can not find class description for entry %s (%s)\n",
308 its->ClassName(), name.Data()));
312 mine=(TObject*)pClass->New();
314 // not in this: can be added to list
315 AliWarning(Form("%s:%d Could not find %s for copying \n",
316 (char*)__FILE__,__LINE__,name.Data()));
319 if(mine->InheritsFrom("TNamed")){
320 ((TNamed*)mine)->SetName(name);
322 else if(mine->InheritsFrom("TCollection")){
323 if(mine->InheritsFrom("TClonesArray")) {
324 TClonesArray* tcits = dynamic_cast<TClonesArray*>(its);
326 dynamic_cast<TClonesArray*>(mine)->SetClass(tcits->GetClass());
328 dynamic_cast<TCollection*>(mine)->SetName(name);
330 AliDebug(1, Form("adding object %s of type %s", mine->GetName(), mine->ClassName()));
334 if(!its->InheritsFrom("TCollection")){
338 else if(its->InheritsFrom("TClonesArray")){
339 // Create or expand the tclonesarray pointers
340 // so we can directly copy to the object
341 TClonesArray *itstca = (TClonesArray*)its;
342 TClonesArray *minetca = (TClonesArray*)mine;
344 // this leaves the capacity of the TClonesArray the same
345 // except for a factor of 2 increase when size > capacity
346 // does not release any memory occupied by the tca
347 minetca->ExpandCreate(itstca->GetEntriesFast());
348 for(int i = 0;i < itstca->GetEntriesFast();++i){
350 TObject *minetcaobj = minetca->At(i);
351 TObject *itstcaobj = itstca->At(i);
352 // no need to delete first
353 // pointers within the class should be handled by Copy()...
354 // Can there be Empty slots?
355 itstcaobj->Copy(*minetcaobj);
359 AliWarning(Form("%s:%d cannot copy TCollection \n",
360 (char*)__FILE__,__LINE__));
364 fOldMuonStructure = source.fOldMuonStructure;
366 fCentrality = source.fCentrality;
367 fEventplane = source.fEventplane;
369 fConnected = source.fConnected;
370 fUseOwnList = source.fUseOwnList;
372 fDetectorStatus = source.fDetectorStatus;
373 fDAQDetectorPattern = source.fDAQDetectorPattern;
374 fDAQAttributes = source.fDAQAttributes;
376 fTracksConnected = kFALSE;
382 //______________________________________________________________________________
383 AliESDEvent::~AliESDEvent()
386 // Standard destructor
389 // everthing on the list gets deleted automatically
392 if(fESDObjects&&!fConnected)
397 if (fCentrality) delete fCentrality;
398 if (fEventplane) delete fEventplane;
403 void AliESDEvent::Copy(TObject &obj) const {
405 // interface to TOBject::Copy
406 // Copies the content of this into obj!
407 // bascially obj = *this
409 if(this==&obj)return;
410 AliESDEvent *robj = dynamic_cast<AliESDEvent*>(&obj);
411 if(!robj)return; // not an AliESEvent
416 //______________________________________________________________________________
417 void AliESDEvent::Reset()
421 // Std content + Non std content
423 // Reset the standard contents
425 fDetectorStatus = 0xFFFFFFFF;
426 fDAQDetectorPattern = 0xFFFF;
427 fDAQAttributes = 0xFFFF;
428 // reset for the old data without AliESDEvent...
429 if(fESDOld)fESDOld->Reset();
431 fESDFriendOld->~AliESDfriend();
432 new (fESDFriendOld) AliESDfriend();
436 if(fESDObjects->GetSize()>kESDListN){
437 // we have non std content
438 // this also covers esdfriends
439 for(int i = kESDListN;i < fESDObjects->GetSize();++i){
440 TObject *pObject = fESDObjects->At(i);
442 if(pObject->InheritsFrom(TClonesArray::Class())){
443 ((TClonesArray*)pObject)->Delete();
445 else if(!pObject->InheritsFrom(TCollection::Class())){
446 TClass *pClass = TClass::GetClass(pObject->ClassName());
447 if (pClass && pClass->GetListOfMethods()->FindObject("Clear")) {
448 AliDebug(1, Form("Clear for object %s class %s", pObject->GetName(), pObject->ClassName()));
452 AliDebug(1, Form("ResetWithPlacementNew for object %s class %s", pObject->GetName(), pObject->ClassName()));
453 ResetWithPlacementNew(pObject);
457 AliWarning(Form("No reset for %s \n",
458 pObject->ClassName()));
465 //______________________________________________________________________________
466 Bool_t AliESDEvent::ResetWithPlacementNew(TObject *pObject){
468 // funtion to reset using the already allocated space
470 Long_t dtoronly = TObject::GetDtorOnly();
471 TClass *pClass = TClass::GetClass(pObject->ClassName());
472 TObject::SetDtorOnly(pObject);
474 // Recreate with placement new
475 pClass->New(pObject);
476 // Restore the state.
477 TObject::SetDtorOnly((void*)dtoronly);
481 //______________________________________________________________________________
482 void AliESDEvent::ResetStdContent()
484 // Reset the standard contents
485 if(fESDRun) fESDRun->Reset();
486 if(fHeader) fHeader->Reset();
487 if(fCentrality) fCentrality->Reset();
488 if(fEventplane) fEventplane->Reset();
489 if(fESDZDC) fESDZDC->Reset();
494 // reset by callin d'to /c'tor keep the pointer
495 fESDVZERO->~AliESDVZERO();
496 new (fESDVZERO) AliESDVZERO();
499 fESDACORDE->~AliESDACORDE();
500 new (fESDACORDE) AliESDACORDE();
505 new (fESDAD) AliESDAD();
509 if(fESDTZERO) fESDTZERO->Reset();
510 // CKB no clear/reset implemented
512 fTPCVertex->~AliESDVertex();
513 new (fTPCVertex) AliESDVertex();
514 fTPCVertex->SetName(fgkESDListName[kTPCVertex]);
517 fSPDVertex->~AliESDVertex();
518 new (fSPDVertex) AliESDVertex();
519 fSPDVertex->SetName(fgkESDListName[kSPDVertex]);
522 fPrimaryVertex->~AliESDVertex();
523 new (fPrimaryVertex) AliESDVertex();
524 fPrimaryVertex->SetName(fgkESDListName[kPrimaryVertex]);
527 fSPDMult->~AliMultiplicity();
528 new (fSPDMult) AliMultiplicity();
531 fTOFHeader->~AliTOFHeader();
532 new (fTOFHeader) AliTOFHeader();
533 //fTOFHeader->SetName(fgkESDListName[kTOFHeader]);
536 fTrdTrigger->~AliESDTrdTrigger();
537 new (fTrdTrigger) AliESDTrdTrigger();
540 if(fPHOSTrigger)fPHOSTrigger->DeAllocate();
541 if(fEMCALTrigger)fEMCALTrigger->DeAllocate();
542 if(fSPDPileupVertices)fSPDPileupVertices->Delete();
543 if(fTrkPileupVertices)fTrkPileupVertices->Delete();
544 fTracksConnected = kFALSE;
545 if(fTracks)fTracks->Delete();
546 if(fMuonTracks)fMuonTracks->Clear("C");
547 if(fMuonClusters)fMuonClusters->Clear("C");
548 if(fMuonPads)fMuonPads->Clear("C");
549 if(fMuonGlobalTracks)fMuonGlobalTracks->Clear("C"); // AU
550 if(fPmdTracks)fPmdTracks->Delete();
551 if(fTrdTracks)fTrdTracks->Delete();
552 if(fTrdTracklets)fTrdTracklets->Delete();
553 if(fV0s)fV0s->Delete();
554 if(fCascades)fCascades->Delete();
555 if(fKinks)fKinks->Delete();
556 if(fCaloClusters)fCaloClusters->Delete();
557 if(fPHOSCells)fPHOSCells->DeleteContainer();
558 if(fEMCALCells)fEMCALCells->DeleteContainer();
559 if(fCosmicTracks)fCosmicTracks->Delete();
560 if(fESDTOFClusters)fESDTOFClusters->Clear();
561 if(fESDTOFHits)fESDTOFHits->Clear();
562 if(fESDTOFMatches)fESDTOFMatches->Clear();
563 if(fErrorLogs) fErrorLogs->Delete();
565 // don't reset fconnected fConnected and the list
570 //______________________________________________________________________________
571 Int_t AliESDEvent::AddV0(const AliESDv0 *v) {
575 TClonesArray &fv = *fV0s;
576 Int_t idx=fV0s->GetEntriesFast();
577 new(fv[idx]) AliESDv0(*v);
581 //______________________________________________________________________________
582 Bool_t AliESDEvent::IsDetectorInTriggerCluster(TString detector, AliTriggerConfiguration* trigConf) const {
583 // Check if a given detector was read-out in the analyzed event
584 const TObjArray& classesArray=trigConf->GetClasses();
585 ULong64_t trigMask=GetTriggerMask();
586 Int_t nclasses = classesArray.GetEntriesFast();
587 for(Int_t iclass=0; iclass < nclasses; iclass++ ) {
588 AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At(iclass);
589 Int_t classMask=trclass->GetMask();
590 if(trigMask & classMask){
591 TString detList=trclass->GetCluster()->GetDetectorsInCluster();
592 if(detList.Contains(detector.Data())){
599 //______________________________________________________________________________
600 void AliESDEvent::Print(Option_t *) const
603 // Print header information of the event
605 printf("ESD run information\n");
606 printf("Event # in file %d Bunch crossing # %d Orbit # %d Period # %d Run # %d Trigger %lld Magnetic field %f \n",
607 GetEventNumberInFile(),
608 GetBunchCrossNumber(),
613 GetMagneticField() );
615 printf("Vertex: (%.4f +- %.4f, %.4f +- %.4f, %.4f +- %.4f) cm\n",
616 fPrimaryVertex->GetX(), fPrimaryVertex->GetXRes(),
617 fPrimaryVertex->GetY(), fPrimaryVertex->GetYRes(),
618 fPrimaryVertex->GetZ(), fPrimaryVertex->GetZRes());
619 printf("Mean vertex in RUN: X=%.4f Y=%.4f Z=%.4f cm\n",
620 GetDiamondX(),GetDiamondY(),GetDiamondZ());
622 printf("SPD Multiplicity. Number of tracklets %d \n",
623 fSPDMult->GetNumberOfTracklets());
624 printf("Number of pileup primary vertices reconstructed with SPD %d\n",
625 GetNumberOfPileupVerticesSPD());
626 printf("Number of pileup primary vertices reconstructed using the tracks %d\n",
627 GetNumberOfPileupVerticesTracks());
628 printf("Number of tracks: \n");
629 printf(" charged %d\n", GetNumberOfTracks());
630 printf(" muon %d\n", GetNumberOfMuonTracks());
631 printf(" glob muon %d\n", GetNumberOfMuonGlobalTracks()); // AU
632 printf(" pmd %d\n", GetNumberOfPmdTracks());
633 printf(" trd %d\n", GetNumberOfTrdTracks());
634 printf(" trd trkl %d\n", GetNumberOfTrdTracklets());
635 printf(" v0 %d\n", GetNumberOfV0s());
636 printf(" cascades %d\n", GetNumberOfCascades());
637 printf(" kinks %d\n", GetNumberOfKinks());
638 if(fPHOSCells)printf(" PHOSCells %d\n", fPHOSCells->GetNumberOfCells());
639 else printf(" PHOSCells not in the Event\n");
640 if(fEMCALCells)printf(" EMCALCells %d\n", fEMCALCells->GetNumberOfCells());
641 else printf(" EMCALCells not in the Event\n");
642 printf(" CaloClusters %d\n", GetNumberOfCaloClusters());
643 printf(" FMD %s\n", (fESDFMD ? "yes" : "no"));
644 printf(" VZERO %s\n", (fESDVZERO ? "yes" : "no"));
645 printf(" muClusters %d\n", fMuonClusters ? fMuonClusters->GetEntriesFast() : 0);
646 printf(" muPad %d\n", fMuonPads ? fMuonPads->GetEntriesFast() : 0);
647 if (fCosmicTracks) printf(" Cosmics %d\n", GetNumberOfCosmicTracks());
649 TObject* pHLTDecision=GetHLTTriggerDecision();
650 printf("HLT trigger decision: %s\n", pHLTDecision?pHLTDecision->GetOption():"not available");
651 if (pHLTDecision) pHLTDecision->Print("compact");
656 //______________________________________________________________________________
657 void AliESDEvent::SetESDfriend(const AliESDfriend *ev) const
660 // Attaches the complementary info to the ESD
664 // to be sure that we set the tracks also
665 // in case of old esds
666 // if(fESDOld)CopyFromOldESD();
668 Int_t ntrk=ev->GetNumberOfTracks();
670 for (Int_t i=0; i<ntrk; i++) {
671 const AliESDfriendTrack *f=ev->GetTrack(i);
672 if (!f) {AliFatal(Form("NULL pointer for ESD track %d",i));}
673 GetTrack(i)->SetFriendTrack(f);
677 //______________________________________________________________________________
678 Bool_t AliESDEvent::RemoveKink(Int_t rm) const
680 // ---------------------------------------------------------
681 // Remove a kink candidate and references to it from ESD,
682 // if this candidate does not come from a reconstructed decay
683 // Not yet implemented...
684 // ---------------------------------------------------------
685 Int_t last=GetNumberOfKinks()-1;
686 if ((rm<0)||(rm>last)) return kFALSE;
691 //______________________________________________________________________________
692 Bool_t AliESDEvent::RemoveV0(Int_t rm) const
694 // ---------------------------------------------------------
695 // Remove a V0 candidate and references to it from ESD,
696 // if this candidate does not come from a reconstructed decay
697 // ---------------------------------------------------------
698 Int_t last=GetNumberOfV0s()-1;
699 if ((rm<0)||(rm>last)) return kFALSE;
701 AliESDv0 *v0=GetV0(rm);
702 Int_t idxP=v0->GetPindex(), idxN=v0->GetNindex();
705 Int_t lastIdxP=v0->GetPindex(), lastIdxN=v0->GetNindex();
709 // Check if this V0 comes from a reconstructed decay
710 Int_t ncs=GetNumberOfCascades();
711 for (Int_t n=0; n<ncs; n++) {
712 AliESDcascade *cs=GetCascade(n);
714 Int_t csIdxP=cs->GetPindex();
715 Int_t csIdxN=cs->GetNindex();
718 if (idxN==csIdxN) return kFALSE;
720 if (csIdxP==lastIdxP)
721 if (csIdxN==lastIdxN) used++;
724 //Replace the removed V0 with the last V0
725 TClonesArray &a=*fV0s;
726 delete a.RemoveAt(rm);
728 if (rm==last) return kTRUE;
730 //v0 is pointing to the last V0 candidate...
731 new (a[rm]) AliESDv0(*v0);
732 delete a.RemoveAt(last);
734 if (!used) return kTRUE;
737 // Remap the indices of the daughters of reconstructed decays
738 for (Int_t n=0; n<ncs; n++) {
739 AliESDcascade *cs=GetCascade(n);
742 Int_t csIdxP=cs->GetPindex();
743 Int_t csIdxN=cs->GetNindex();
745 if (csIdxP==lastIdxP)
746 if (csIdxN==lastIdxN) {
747 cs->AliESDv0::SetIndex(1,idxP);
748 cs->AliESDv0::SetIndex(0,idxN);
750 if (!used) return kTRUE;
757 //______________________________________________________________________________
758 Bool_t AliESDEvent::RemoveTrack(Int_t rm) const
760 // ---------------------------------------------------------
761 // Remove a track and references to it from ESD,
762 // if this track does not come from a reconstructed decay
763 // ---------------------------------------------------------
764 Int_t last=GetNumberOfTracks()-1;
765 if ((rm<0)||(rm>last)) return kFALSE;
769 // Check if this track comes from the reconstructed primary vertices
770 if (fTPCVertex && fTPCVertex->GetStatus()) {
771 UShort_t *primIdx=fTPCVertex->GetIndices();
772 Int_t n=fTPCVertex->GetNIndices();
774 Int_t idx=Int_t(primIdx[n]);
775 if (rm==idx) return kFALSE;
776 if (idx==last) used++;
779 if (fPrimaryVertex && fPrimaryVertex->GetStatus()) {
780 UShort_t *primIdx=fPrimaryVertex->GetIndices();
781 Int_t n=fPrimaryVertex->GetNIndices();
783 Int_t idx=Int_t(primIdx[n]);
784 if (rm==idx) return kFALSE;
785 if (idx==last) used++;
789 // Check if this track comes from a reconstructed decay
790 Int_t nv0=GetNumberOfV0s();
791 for (Int_t n=0; n<nv0; n++) {
792 AliESDv0 *v0=GetV0(n);
794 Int_t idx=v0->GetNindex();
795 if (rm==idx) return kFALSE;
796 if (idx==last) used++;
799 if (rm==idx) return kFALSE;
800 if (idx==last) used++;
803 Int_t ncs=GetNumberOfCascades();
804 for (Int_t n=0; n<ncs; n++) {
805 AliESDcascade *cs=GetCascade(n);
807 Int_t idx=cs->GetIndex();
808 if (rm==idx) return kFALSE;
809 if (idx==last) used++;
813 if (rm==idx) return kFALSE;
814 if (idx==last) used++;
817 if (rm==idx) return kFALSE;
818 if (idx==last) used++;
821 Int_t nkn=GetNumberOfKinks();
822 for (Int_t n=0; n<nkn; n++) {
823 AliESDkink *kn=GetKink(n);
825 Int_t idx=kn->GetIndex(0);
826 if (rm==idx) return kFALSE;
827 if (idx==last) used++;
830 if (rm==idx) return kFALSE;
831 if (idx==last) used++;
834 // Check if this track is associated with a CaloCluster
835 Int_t ncl=GetNumberOfCaloClusters();
836 for (Int_t n=0; n<ncl; n++) {
837 AliESDCaloCluster *cluster=GetCaloCluster(n);
838 TArrayI *arr=cluster->GetTracksMatched();
839 Int_t s=arr->GetSize();
841 Int_t idx=arr->At(s);
842 if (rm==idx) return kFALSE;
843 if (idx==last) used++;
847 // from here on we remove the track
849 //Replace the removed track with the last track
850 TClonesArray &a=*fTracks;
851 AliESDtrack* trm = GetTrack(rm);
852 trm->SuppressTOFMatches(); // remove reference to this track from stored TOF clusters
853 delete a.RemoveAt(rm);
855 if (rm==last) return kTRUE;
857 AliESDtrack *t=GetTrack(last);
858 if (!t) {AliFatal(Form("NULL pointer for ESD track %d",last));}
860 new (a[rm]) AliESDtrack(*t);
861 delete a.RemoveAt(last);
863 if (!used) return kTRUE;
866 // Remap the indices of the tracks used for the primary vertex reconstruction
867 if (fTPCVertex && fTPCVertex->GetStatus()) {
868 UShort_t *primIdx=fTPCVertex->GetIndices();
869 Int_t n=fTPCVertex->GetNIndices();
871 Int_t idx=Int_t(primIdx[n]);
873 primIdx[n]=Short_t(rm);
875 if (!used) return kTRUE;
879 if (fPrimaryVertex && fPrimaryVertex->GetStatus()) {
880 UShort_t *primIdx=fPrimaryVertex->GetIndices();
881 Int_t n=fPrimaryVertex->GetNIndices();
883 Int_t idx=Int_t(primIdx[n]);
885 primIdx[n]=Short_t(rm);
887 if (!used) return kTRUE;
892 // Remap the indices of the daughters of reconstructed decays
893 for (Int_t n=0; n<nv0; n++) {
894 AliESDv0 *v0=GetV0(n);
895 if (v0->GetIndex(0)==last) {
898 if (!used) return kTRUE;
900 if (v0->GetIndex(1)==last) {
903 if (!used) return kTRUE;
907 for (Int_t n=0; n<ncs; n++) {
908 AliESDcascade *cs=GetCascade(n);
909 if (cs->GetIndex()==last) {
912 if (!used) return kTRUE;
915 if (v0->GetIndex(0)==last) {
918 if (!used) return kTRUE;
920 if (v0->GetIndex(1)==last) {
923 if (!used) return kTRUE;
927 for (Int_t n=0; n<nkn; n++) {
928 AliESDkink *kn=GetKink(n);
929 if (kn->GetIndex(0)==last) {
932 if (!used) return kTRUE;
934 if (kn->GetIndex(1)==last) {
937 if (!used) return kTRUE;
941 // Remap the indices of the tracks accosicated with CaloClusters
942 for (Int_t n=0; n<ncl; n++) {
943 AliESDCaloCluster *cluster=GetCaloCluster(n);
944 TArrayI *arr=cluster->GetTracksMatched();
945 Int_t s=arr->GetSize();
947 Int_t idx=arr->At(s);
951 if (!used) return kTRUE;
959 //______________________________________________________________________________
960 Bool_t AliESDEvent::Clean(Float_t *cleanPars)
963 // Remove the data which are not needed for the physics analysis.
965 // 1) Cleaning the V0 candidates
966 // ---------------------------
967 // If the cosine of the V0 pointing angle "csp" and
968 // the DCA between the daughter tracks "dca" does not satisfy
971 // csp > cleanPars[1] + dca/cleanPars[0]*(1.- cleanPars[1])
973 // an attempt to remove this V0 candidate from ESD is made.
975 // The V0 candidate gets removed if it does not belong to any
976 // recosntructed cascade decay
978 // 12.11.2007, optimal values: cleanPars[0]=0.5, cleanPars[1]=0.999
980 // 2) Cleaning the tracks
981 // ----------------------
982 // If track's transverse parameter is larger than cleanPars[2]
984 // track's longitudinal parameter is larger than cleanPars[3]
985 // an attempt to remove this track from ESD is made.
987 // The track gets removed if it does not come
988 // from a reconstructed decay
992 Float_t dcaMax=cleanPars[0];
993 Float_t cspMin=cleanPars[1];
995 Int_t nV0s=GetNumberOfV0s();
996 for (Int_t i=nV0s-1; i>=0; i--) {
997 AliESDv0 *v0=GetV0(i);
999 Float_t dca=v0->GetDcaV0Daughters();
1000 Float_t csp=v0->GetV0CosineOfPointingAngle();
1001 Float_t cspcut=cspMin + dca/dcaMax*(1.-cspMin);
1002 if (csp > cspcut) continue;
1003 if (RemoveV0(i)) rc=kTRUE;
1007 Float_t dmax=cleanPars[2], zmax=cleanPars[3];
1009 const AliESDVertex *vertex=GetPrimaryVertexSPD();
1010 Bool_t vtxOK=vertex->GetStatus();
1012 Int_t nTracks=GetNumberOfTracks();
1013 for (Int_t i=nTracks-1; i>=0; i--) {
1014 AliESDtrack *track=GetTrack(i);
1015 if (!track) {AliFatal(Form("NULL pointer for ESD track %d",i));}
1016 Float_t xy,z; track->GetImpactParameters(xy,z);
1017 if ((TMath::Abs(xy) > dmax) || (vtxOK && (TMath::Abs(z) > zmax))) {
1018 if (RemoveTrack(i)) rc=kTRUE;
1025 //______________________________________________________________________________
1026 Char_t AliESDEvent::AddPileupVertexSPD(const AliESDVertex *vtx)
1028 // Add a pileup primary vertex reconstructed with SPD
1029 TClonesArray &ftr = *fSPDPileupVertices;
1030 Char_t n=Char_t(ftr.GetEntriesFast());
1031 AliESDVertex *vertex = new(ftr[n]) AliESDVertex(*vtx);
1036 //______________________________________________________________________________
1037 Char_t AliESDEvent::AddPileupVertexTracks(const AliESDVertex *vtx)
1039 // Add a pileup primary vertex reconstructed with SPD
1040 TClonesArray &ftr = *fTrkPileupVertices;
1041 Char_t n=Char_t(ftr.GetEntriesFast());
1042 AliESDVertex *vertex = new(ftr[n]) AliESDVertex(*vtx);
1047 //______________________________________________________________________________
1048 Int_t AliESDEvent::AddTrack(const AliESDtrack *t)
1051 TClonesArray &ftr = *fTracks;
1052 AliESDtrack * track = new(ftr[fTracks->GetEntriesFast()])AliESDtrack(*t);
1053 track->SetID(fTracks->GetEntriesFast()-1);
1054 track->SetESDEvent(this);
1055 return track->GetID();
1058 //______________________________________________________________________________
1059 AliESDtrack* AliESDEvent::NewTrack()
1062 TClonesArray &ftr = *fTracks;
1063 AliESDtrack * track = new(ftr[fTracks->GetEntriesFast()])AliESDtrack();
1064 track->SetID(fTracks->GetEntriesFast()-1);
1065 track->SetESDEvent(this);
1069 //______________________________________________________________________________
1070 Bool_t AliESDEvent::MoveMuonObjects()
1072 // move MUON clusters and pads to the new ESD structure in needed.
1073 // to ensure backward compatibility
1075 if (!fOldMuonStructure) return kTRUE;
1077 if (!fMuonTracks || !fMuonClusters || !fMuonPads) return kFALSE;
1079 Bool_t reset = kTRUE;
1080 Bool_t containTrackerData = kFALSE;
1081 for (Int_t i = 0; i < fMuonTracks->GetEntriesFast(); i++) {
1083 AliESDMuonTrack *track = (AliESDMuonTrack*) fMuonTracks->UncheckedAt(i);
1085 if (track->ContainTrackerData()) containTrackerData = kTRUE;
1088 if (!track->IsOldTrack()) continue;
1090 // remove objects connected to previous event if needed
1092 if (fMuonClusters->GetEntriesFast() > 0) fMuonClusters->Clear("C");
1093 if (fMuonPads->GetEntriesFast() > 0) fMuonPads->Clear("C");
1097 track->MoveClustersToESD(*this);
1101 // remove objects connected to previous event if needed
1102 if (!containTrackerData) {
1103 if (fMuonClusters->GetEntriesFast() > 0) fMuonClusters->Clear("C");
1104 if (fMuonPads->GetEntriesFast() > 0) fMuonPads->Clear("C");
1110 //______________________________________________________________________________
1111 AliESDMuonTrack* AliESDEvent::GetMuonTrack(Int_t i)
1113 // get the MUON track at the position i in the internal array of track
1114 if (!fMuonTracks) return 0x0;
1115 if (!MoveMuonObjects()) return 0x0;
1116 AliESDMuonTrack *track = (AliESDMuonTrack*) fMuonTracks->UncheckedAt(i);
1117 track->SetESDEvent(this);
1121 //______________________________________________________________________________
1122 AliESDMuonGlobalTrack* AliESDEvent::GetMuonGlobalTrack(Int_t i) // AU
1124 // get the MUON+MFT track at the position i in the internal array of track
1125 if (!fMuonGlobalTracks) return 0x0;
1126 AliESDMuonGlobalTrack *track = (AliESDMuonGlobalTrack*) fMuonGlobalTracks->UncheckedAt(i);
1127 track->SetESDEvent(this);
1131 //______________________________________________________________________________
1132 void AliESDEvent::AddMuonTrack(const AliESDMuonTrack *t)
1135 TClonesArray &fmu = *fMuonTracks;
1136 AliESDMuonTrack *track = new(fmu[fMuonTracks->GetEntriesFast()]) AliESDMuonTrack(*t);
1137 track->MoveClustersToESD(*this);
1140 //______________________________________________________________________________
1141 void AliESDEvent::AddMuonGlobalTrack(const AliESDMuonGlobalTrack *t) // AU
1143 // add a MUON+MFT track
1144 TClonesArray &fmu = *fMuonGlobalTracks;
1145 new (fmu[fMuonGlobalTracks->GetEntriesFast()]) AliESDMuonGlobalTrack(*t);
1148 //______________________________________________________________________________
1150 AliESDMuonTrack* AliESDEvent::NewMuonTrack()
1152 // create a new MUON track at the end of the internal array of track
1153 TClonesArray &fmu = *fMuonTracks;
1154 return new(fmu[fMuonTracks->GetEntriesFast()]) AliESDMuonTrack();
1157 //______________________________________________________________________________
1158 AliESDMuonGlobalTrack* AliESDEvent::NewMuonGlobalTrack() // AU
1160 // create a new MUON+MFT track at the end of the internal array of track
1161 TClonesArray &fmu = *fMuonGlobalTracks;
1162 return new(fmu[fMuonGlobalTracks->GetEntriesFast()]) AliESDMuonGlobalTrack();
1165 //______________________________________________________________________________
1166 Int_t AliESDEvent::GetNumberOfMuonClusters()
1168 // get the number of MUON clusters
1169 if (!fMuonClusters) return 0;
1170 if (!MoveMuonObjects()) return 0;
1171 return fMuonClusters->GetEntriesFast();
1174 //______________________________________________________________________________
1175 AliESDMuonCluster* AliESDEvent::GetMuonCluster(Int_t i)
1177 // get the MUON cluster at the position i in the internal array of cluster
1178 if (!fMuonClusters) return 0x0;
1179 if (!MoveMuonObjects()) return 0x0;
1180 return (AliESDMuonCluster*) fMuonClusters->UncheckedAt(i);
1183 //______________________________________________________________________________
1184 AliESDMuonCluster* AliESDEvent::FindMuonCluster(UInt_t clusterId)
1186 // find the MUON cluster with this Id in the internal array of cluster
1187 if (!fMuonClusters) return 0x0;
1188 if (!MoveMuonObjects()) return 0x0;
1189 for (Int_t i = 0; i < fMuonClusters->GetEntriesFast(); i++) {
1190 AliESDMuonCluster *cluster = (AliESDMuonCluster*) fMuonClusters->UncheckedAt(i);
1191 if (cluster->GetUniqueID() == clusterId) return cluster;
1196 //______________________________________________________________________________
1197 AliESDMuonCluster* AliESDEvent::NewMuonCluster()
1199 // create a new MUON cluster at the end of the internal array of cluster
1200 TClonesArray &fmu = *fMuonClusters;
1201 return new(fmu[fMuonClusters->GetEntriesFast()]) AliESDMuonCluster();
1204 //______________________________________________________________________________
1205 Int_t AliESDEvent::GetNumberOfMuonPads()
1207 // get the number of MUON pads
1208 if (!fMuonPads) return 0;
1209 if (!MoveMuonObjects()) return 0;
1210 return fMuonPads->GetEntriesFast();
1213 //______________________________________________________________________________
1214 AliESDMuonPad* AliESDEvent::GetMuonPad(Int_t i)
1216 // get the MUON pad at the position i in the internal array of pad
1217 if (!fMuonPads) return 0x0;
1218 if (!MoveMuonObjects()) return 0x0;
1219 return (AliESDMuonPad*) fMuonPads->UncheckedAt(i);
1222 //______________________________________________________________________________
1223 AliESDMuonPad* AliESDEvent::FindMuonPad(UInt_t padId)
1225 // find the MUON pad with this Id in the internal array of pad
1226 if (!fMuonPads) return 0x0;
1227 if (!MoveMuonObjects()) return 0x0;
1228 for (Int_t i = 0; i < fMuonPads->GetEntriesFast(); i++) {
1229 AliESDMuonPad *pad = (AliESDMuonPad*) fMuonPads->UncheckedAt(i);
1230 if (pad->GetUniqueID() == padId) return pad;
1235 //______________________________________________________________________________
1236 AliESDMuonPad* AliESDEvent::NewMuonPad()
1238 // create a new MUON pad at the end of the internal array of pad
1239 TClonesArray &fmu = *fMuonPads;
1240 return new(fmu[fMuonPads->GetEntriesFast()]) AliESDMuonPad();
1243 //______________________________________________________________________________
1244 void AliESDEvent::AddPmdTrack(const AliESDPmdTrack *t)
1246 TClonesArray &fpmd = *fPmdTracks;
1247 new(fpmd[fPmdTracks->GetEntriesFast()]) AliESDPmdTrack(*t);
1250 //______________________________________________________________________________
1251 void AliESDEvent::SetTrdTrigger(const AliESDTrdTrigger *t)
1256 //______________________________________________________________________________
1257 void AliESDEvent::AddTrdTrack(const AliESDTrdTrack *t)
1259 TClonesArray &ftrd = *fTrdTracks;
1260 new(ftrd[fTrdTracks->GetEntriesFast()]) AliESDTrdTrack(*t);
1263 //______________________________________________________________________________
1264 void AliESDEvent::AddTrdTracklet(const AliESDTrdTracklet *trkl)
1266 new ((*fTrdTracklets)[fTrdTracklets->GetEntriesFast()]) AliESDTrdTracklet(*trkl);
1269 //______________________________________________________________________________
1270 void AliESDEvent::AddTrdTracklet(UInt_t trackletWord, Short_t hcid, Int_t label)
1272 new ((*fTrdTracklets)[fTrdTracklets->GetEntriesFast()]) AliESDTrdTracklet(trackletWord, hcid, label);
1275 //______________________________________________________________________________
1276 Int_t AliESDEvent::AddKink(const AliESDkink *c)
1279 TClonesArray &fk = *fKinks;
1280 AliESDkink * kink = new(fk[fKinks->GetEntriesFast()]) AliESDkink(*c);
1281 kink->SetID(fKinks->GetEntriesFast()); // CKB different from the other imps..
1282 return fKinks->GetEntriesFast()-1;
1286 //______________________________________________________________________________
1287 void AliESDEvent::AddCascade(const AliESDcascade *c)
1289 TClonesArray &fc = *fCascades;
1290 new(fc[fCascades->GetEntriesFast()]) AliESDcascade(*c);
1293 //______________________________________________________________________________
1294 void AliESDEvent::AddCosmicTrack(const AliESDCosmicTrack *t)
1296 TClonesArray &ft = *fCosmicTracks;
1297 new(ft[fCosmicTracks->GetEntriesFast()]) AliESDCosmicTrack(*t);
1301 //______________________________________________________________________________
1302 Int_t AliESDEvent::AddCaloCluster(const AliESDCaloCluster *c)
1305 TClonesArray &fc = *fCaloClusters;
1306 AliESDCaloCluster *clus = new(fc[fCaloClusters->GetEntriesFast()]) AliESDCaloCluster(*c);
1307 clus->SetID(fCaloClusters->GetEntriesFast()-1);
1308 return fCaloClusters->GetEntriesFast()-1;
1312 //______________________________________________________________________________
1313 void AliESDEvent::AddRawDataErrorLog(const AliRawDataErrorLog *log) const {
1314 TClonesArray &errlogs = *fErrorLogs;
1315 new(errlogs[errlogs.GetEntriesFast()]) AliRawDataErrorLog(*log);
1318 //______________________________________________________________________________
1319 void AliESDEvent::SetZDCData(const AliESDZDC * obj)
1321 // use already allocated space
1326 //______________________________________________________________________________
1327 void AliESDEvent::SetPrimaryVertexTPC(const AliESDVertex *vertex)
1329 // Set the TPC vertex
1330 // use already allocated space
1332 *fTPCVertex = *vertex;
1333 fTPCVertex->SetName(fgkESDListName[kTPCVertex]);
1337 //______________________________________________________________________________
1338 void AliESDEvent::SetPrimaryVertexSPD(const AliESDVertex *vertex)
1340 // Set the SPD vertex
1341 // use already allocated space
1343 *fSPDVertex = *vertex;
1344 fSPDVertex->SetName(fgkESDListName[kSPDVertex]);
1348 //______________________________________________________________________________
1349 void AliESDEvent::SetPrimaryVertexTracks(const AliESDVertex *vertex)
1351 // Set the primary vertex reconstructed using he ESD tracks.
1352 // use already allocated space
1354 *fPrimaryVertex = *vertex;
1355 fPrimaryVertex->SetName(fgkESDListName[kPrimaryVertex]);
1359 //______________________________________________________________________________
1360 const AliESDVertex * AliESDEvent::GetPrimaryVertex() const
1363 // Get the "best" available reconstructed primary vertex.
1366 if (fPrimaryVertex->GetStatus()) return fPrimaryVertex;
1369 if (fSPDVertex->GetStatus()) return fSPDVertex;
1371 if(fTPCVertex) return fTPCVertex;
1373 AliWarning("No primary vertex available. Returning the \"default\"...");
1377 //______________________________________________________________________________
1378 AliESDVertex * AliESDEvent::PrimaryVertexTracksUnconstrained() const
1381 // Removes diamond constraint from fPrimaryVertex (reconstructed with tracks)
1382 // Returns a AliESDVertex which has to be deleted by the user
1384 if(!fPrimaryVertex) {
1385 AliWarning("No primary vertex from tracks available.");
1388 if(!fPrimaryVertex->GetStatus()) {
1389 AliWarning("No primary vertex from tracks available.");
1393 AliVertexerTracks vertexer(GetMagneticField());
1394 Float_t diamondxyz[3]={(Float_t)GetDiamondX(),(Float_t)GetDiamondY(),0.};
1395 Float_t diamondcovxy[3]; GetDiamondCovXY(diamondcovxy);
1396 Float_t diamondcov[6]={diamondcovxy[0],diamondcovxy[1],diamondcovxy[2],0.,0.,7.};
1397 AliESDVertex *vertex =
1398 (AliESDVertex*)vertexer.RemoveConstraintFromVertex(fPrimaryVertex,diamondxyz,diamondcov);
1403 //______________________________________________________________________________
1404 void AliESDEvent::SetMultiplicity(const AliMultiplicity *mul)
1406 // Set the SPD Multiplicity
1413 //______________________________________________________________________________
1414 void AliESDEvent::SetFMDData(AliESDFMD * obj)
1416 // use already allocated space
1422 //______________________________________________________________________________
1423 void AliESDEvent::SetVZEROData(const AliESDVZERO * obj)
1425 // use already allocated space
1430 //______________________________________________________________________________
1431 void AliESDEvent::SetTZEROData(const AliESDTZERO * obj)
1433 // use already allocated space
1439 //______________________________________________________________________________
1440 void AliESDEvent::SetACORDEData(AliESDACORDE * obj)
1446 //______________________________________________________________________________
1447 void AliESDEvent::SetADData(AliESDAD * obj)
1453 //______________________________________________________________________________
1454 void AliESDEvent::GetESDfriend(AliESDfriend *ev) const
1457 // Extracts the complementary info from the ESD
1461 Int_t ntrk=GetNumberOfTracks();
1463 for (Int_t i=0; i<ntrk; i++) {
1464 AliESDtrack *t=GetTrack(i);
1465 if (!t) {AliFatal(Form("NULL pointer for ESD track %d",i));}
1466 const AliESDfriendTrack *f=t->GetFriendTrack();
1469 t->ReleaseESDfriendTrack();// Not to have two copies of "friendTrack"
1473 AliESDfriend *fr = (AliESDfriend*)(const_cast<AliESDEvent*>(this)->FindListObject("AliESDfriend"));
1474 if (fr) ev->SetVZEROfriend(fr->GetVZEROfriend());
1477 //______________________________________________________________________________
1478 void AliESDEvent::AddObject(TObject* obj)
1480 // Add an object to the list of object.
1481 // Please be aware that in order to increase performance you should
1482 // refrain from using TObjArrays (if possible). Use TClonesArrays, instead.
1483 fESDObjects->SetOwner(kTRUE);
1484 fESDObjects->AddLast(obj);
1487 //______________________________________________________________________________
1488 void AliESDEvent::GetStdContent()
1490 // set pointers for standard content
1491 // get by name much safer and not a big overhead since not called very often
1493 fESDRun = (AliESDRun*)fESDObjects->FindObject(fgkESDListName[kESDRun]);
1494 fHeader = (AliESDHeader*)fESDObjects->FindObject(fgkESDListName[kHeader]);
1495 fESDZDC = (AliESDZDC*)fESDObjects->FindObject(fgkESDListName[kESDZDC]);
1496 fESDFMD = (AliESDFMD*)fESDObjects->FindObject(fgkESDListName[kESDFMD]);
1497 fESDVZERO = (AliESDVZERO*)fESDObjects->FindObject(fgkESDListName[kESDVZERO]);
1498 fESDTZERO = (AliESDTZERO*)fESDObjects->FindObject(fgkESDListName[kESDTZERO]);
1499 fTPCVertex = (AliESDVertex*)fESDObjects->FindObject(fgkESDListName[kTPCVertex]);
1500 fSPDVertex = (AliESDVertex*)fESDObjects->FindObject(fgkESDListName[kSPDVertex]);
1501 fPrimaryVertex = (AliESDVertex*)fESDObjects->FindObject(fgkESDListName[kPrimaryVertex]);
1502 fSPDMult = (AliMultiplicity*)fESDObjects->FindObject(fgkESDListName[kSPDMult]);
1503 fPHOSTrigger = (AliESDCaloTrigger*)fESDObjects->FindObject(fgkESDListName[kPHOSTrigger]);
1504 fEMCALTrigger = (AliESDCaloTrigger*)fESDObjects->FindObject(fgkESDListName[kEMCALTrigger]);
1505 fSPDPileupVertices = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kSPDPileupVertices]);
1506 fTrkPileupVertices = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTrkPileupVertices]);
1507 fTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTracks]);
1508 fMuonTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kMuonTracks]);
1509 fMuonClusters = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kMuonClusters]);
1510 fMuonPads = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kMuonPads]);
1511 fMuonGlobalTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kMuonGlobalTracks]); // AU
1512 fPmdTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kPmdTracks]);
1513 fTrdTrigger = (AliESDTrdTrigger*)fESDObjects->FindObject(fgkESDListName[kTrdTrigger]);
1514 fTrdTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTrdTracks]);
1515 fTrdTracklets = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTrdTracklets]);
1516 fV0s = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kV0s]);
1517 fCascades = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kCascades]);
1518 fKinks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kKinks]);
1519 fCaloClusters = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kCaloClusters]);
1520 fEMCALCells = (AliESDCaloCells*)fESDObjects->FindObject(fgkESDListName[kEMCALCells]);
1521 fPHOSCells = (AliESDCaloCells*)fESDObjects->FindObject(fgkESDListName[kPHOSCells]);
1522 fErrorLogs = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kErrorLogs]);
1523 fESDACORDE = (AliESDACORDE*)fESDObjects->FindObject(fgkESDListName[kESDACORDE]);
1524 fESDAD = (AliESDAD*)fESDObjects->FindObject(fgkESDListName[kESDAD]);
1525 fTOFHeader = (AliTOFHeader*)fESDObjects->FindObject(fgkESDListName[kTOFHeader]);
1526 fCosmicTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kCosmicTracks]);
1527 fESDTOFClusters = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTOFclusters]);
1528 fESDTOFHits = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTOFhit]);
1529 fESDTOFMatches = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTOFmatch]);
1532 //______________________________________________________________________________
1533 void AliESDEvent::SetStdNames(){
1534 // Set the names of the standard contents
1536 if(fESDObjects->GetEntries()>=kESDListN){
1537 for(int i = 0;i < fESDObjects->GetEntries() && i<kESDListN;i++){
1538 TObject *fObj = fESDObjects->At(i);
1539 if(fObj->InheritsFrom("TNamed")){
1540 ((TNamed*)fObj)->SetName(fgkESDListName[i]);
1542 else if(fObj->InheritsFrom("TClonesArray")){
1543 ((TClonesArray*)fObj)->SetName(fgkESDListName[i]);
1548 AliWarning("Std Entries missing");
1552 //______________________________________________________________________________
1553 void AliESDEvent::CreateStdContent(Bool_t bUseThisList){
1554 fUseOwnList = bUseThisList;
1558 //______________________________________________________________________________
1559 void AliESDEvent::CreateStdContent()
1561 // create the standard AOD content and set pointers
1563 // create standard objects and add them to the TList of objects
1564 AddObject(new AliESDRun());
1565 AddObject(new AliESDHeader());
1566 AddObject(new AliESDZDC());
1567 AddObject(new AliESDFMD());
1568 AddObject(new AliESDVZERO());
1569 AddObject(new AliESDTZERO());
1570 AddObject(new AliESDVertex());
1571 AddObject(new AliESDVertex());
1572 AddObject(new AliESDVertex());
1573 AddObject(new AliMultiplicity());
1574 AddObject(new AliESDCaloTrigger());
1575 AddObject(new AliESDCaloTrigger());
1576 AddObject(new TClonesArray("AliESDVertex",0));
1577 AddObject(new TClonesArray("AliESDVertex",0));
1578 AddObject(new TClonesArray("AliESDtrack",0));
1579 AddObject(new TClonesArray("AliESDMuonTrack",0));
1580 AddObject(new TClonesArray("AliESDMuonCluster",0));
1581 AddObject(new TClonesArray("AliESDMuonPad",0));
1582 AddObject(new TClonesArray("AliESDMuonGlobalTrack",0)); // AU
1583 AddObject(new TClonesArray("AliESDPmdTrack",0));
1584 AddObject(new AliESDTrdTrigger());
1585 AddObject(new TClonesArray("AliESDTrdTrack",0));
1586 AddObject(new TClonesArray("AliESDTrdTracklet",0));
1587 AddObject(new TClonesArray("AliESDv0",0));
1588 AddObject(new TClonesArray("AliESDcascade",0));
1589 AddObject(new TClonesArray("AliESDkink",0));
1590 AddObject(new TClonesArray("AliESDCaloCluster",0));
1591 AddObject(new AliESDCaloCells());
1592 AddObject(new AliESDCaloCells());
1593 AddObject(new TClonesArray("AliRawDataErrorLog",0));
1594 AddObject(new AliESDACORDE());
1595 AddObject(new AliESDAD());
1596 AddObject(new AliTOFHeader());
1597 AddObject(new TClonesArray("AliESDCosmicTrack",0));
1598 AddObject(new TClonesArray("AliESDTOFCluster",0));
1599 AddObject(new TClonesArray("AliESDTOFHit",0));
1600 AddObject(new TClonesArray("AliESDTOFMatch",0));
1602 // check the order of the indices against enum...
1606 // read back pointers
1610 //______________________________________________________________________________
1611 void AliESDEvent::CompleteStdContent()
1613 // Create missing standard objects and add them to the TList of objects
1615 // Add cosmic tracks for cases where esd files were created
1616 // before adding them to the std content
1617 if (!fESDObjects->FindObject(fgkESDListName[kCosmicTracks])) {
1618 TClonesArray* cosmics = new TClonesArray("AliESDCosmicTrack",0);
1619 fESDObjects->AddAt(cosmics, kCosmicTracks);
1620 fESDObjects->SetOwner(kTRUE);
1622 // Add new MUON containers if missing (for backward compatibility)
1623 if (!fESDObjects->FindObject(fgkESDListName[kMuonClusters])) {
1624 TClonesArray* muonClusters = new TClonesArray("AliESDMuonCluster",0);
1625 muonClusters->SetName(fgkESDListName[kMuonClusters]);
1626 fESDObjects->AddAt(muonClusters, kMuonClusters);
1627 fESDObjects->SetOwner(kTRUE);
1629 if (!fESDObjects->FindObject(fgkESDListName[kMuonPads])) {
1630 TClonesArray* muonPads = new TClonesArray("AliESDMuonPad",0);
1631 muonPads->SetName(fgkESDListName[kMuonPads]);
1632 fESDObjects->AddAt(muonPads, kMuonPads);
1633 fESDObjects->SetOwner(kTRUE);
1637 //______________________________________________________________________________
1638 TObject* AliESDEvent::FindListObject(const char *name) const {
1640 // Find object with name "name" in the list of branches
1643 return fESDObjects->FindObject(name);
1648 //______________________________________________________________________________
1649 Int_t AliESDEvent::GetPHOSClusters(TRefArray *clusters) const
1651 // fills the provided TRefArray with all found phos clusters
1655 AliESDCaloCluster *cl = 0;
1656 for (Int_t i = 0; i < GetNumberOfCaloClusters(); i++) {
1658 if ( (cl = GetCaloCluster(i)) ) {
1661 AliDebug(1,Form("IsPHOS cluster %d Size: %d \n",i,clusters->GetEntriesFast()));
1665 return clusters->GetEntriesFast();
1668 //______________________________________________________________________________
1669 Int_t AliESDEvent::GetEMCALClusters(TRefArray *clusters) const
1671 // fills the provided TRefArray with all found emcal clusters
1675 AliESDCaloCluster *cl = 0;
1676 for (Int_t i = 0; i < GetNumberOfCaloClusters(); i++) {
1678 if ( (cl = GetCaloCluster(i)) ) {
1681 AliDebug(1,Form("IsEMCAL cluster %d Size: %d \n",i,clusters->GetEntriesFast()));
1685 return clusters->GetEntriesFast();
1688 //______________________________________________________________________________
1689 void AliESDEvent::WriteToTree(TTree* tree) const {
1690 // Book the branches as in TTree::Branch(TCollection*)
1691 // but add a "." at the end of top level branches which are
1692 // not a TClonesArray
1696 TIter next(fESDObjects);
1697 const Int_t kSplitlevel = 99; // default value in TTree::Branch()
1698 const Int_t kBufsize = 32000; // default value in TTree::Branch()
1701 while ((obj = next())) {
1702 branchname.Form("%s", obj->GetName());
1703 if(branchname.CompareTo("AliESDfriend")==0)branchname = "ESDfriend.";
1704 if ((kSplitlevel > 1) && !obj->InheritsFrom(TClonesArray::Class())) {
1705 if(!branchname.EndsWith("."))branchname += ".";
1707 if (!tree->FindBranch(branchname)) {
1708 // For the custom streamer to be called splitlevel
1709 // has to be negative, only needed for HLT
1710 Int_t splitLevel = (TString(obj->ClassName()) == "AliHLTGlobalTriggerDecision") ? -1 : kSplitlevel - 1;
1711 tree->Bronch(branchname, obj->ClassName(), fESDObjects->GetObjectRef(obj),kBufsize, splitLevel);
1715 tree->Branch("fDetectorStatus",(void*)&fDetectorStatus,"fDetectorStatus/l");
1716 tree->Branch("fDAQDetectorPattern",(void*)&fDAQDetectorPattern,"fDAQDetectorPattern/i");
1717 tree->Branch("fDAQAttributes",(void*)&fDAQAttributes,"fDAQAttributes/i");
1720 //______________________________________________________________________________
1721 void AliESDEvent::ReadFromTree(TTree *tree, Option_t* opt){
1723 // Connect the ESDEvent to a tree
1726 AliWarning("AliESDEvent::ReadFromTree() Zero Pointer to Tree \n");
1730 if(!tree->GetTree())tree->LoadTree(0);
1732 // if we find the "ESD" branch on the tree we do have the old structure
1733 if(tree->GetBranch("ESD")) {
1734 fOldMuonStructure = kFALSE;
1735 char ** address = (char **)(tree->GetBranch("ESD")->GetAddress());
1736 // do we have the friend branch
1737 TBranch * esdFB = tree->GetBranch("ESDfriend.");
1738 char ** addressF = 0;
1739 if(esdFB)addressF = (char **)(esdFB->GetAddress());
1741 AliInfo("AliESDEvent::ReadFromTree() Reading old Tree");
1742 tree->SetBranchAddress("ESD", &fESDOld);
1744 tree->SetBranchAddress("ESDfriend.",&fESDFriendOld);
1747 AliInfo("AliESDEvent::ReadFromTree() Reading old Tree");
1748 AliInfo("Branch already connected. Using existing branch address.");
1749 fESDOld = (AliESD*) (*address);
1750 // addressF can still be 0, since branch needs to switched on
1751 if(addressF)fESDFriendOld = (AliESDfriend*) (*addressF);
1754 // have already connected the old ESD structure... ?
1755 // reuse also the pointer of the AlliESDEvent
1756 // otherwise create new ones
1757 TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("ESDObjectsConnectedToTree"));
1760 // If connected use the connected list of objects
1761 if(fESDObjects!= connectedList){
1762 // protect when called twice
1763 fESDObjects->Delete();
1764 fESDObjects = connectedList;
1769 // The pointer to the friend changes when called twice via InitIO
1770 // since AliESDEvent is deleted
1771 TObject* oldf = FindListObject("AliESDfriend");
1774 newf = (TObject*)*addressF;
1776 if(newf!=0&&oldf!=newf){
1777 // remove the old reference
1778 // Should we also delete it? Or is this handled in TTree I/O
1779 // since it is created by the first SetBranchAddress
1780 fESDObjects->Remove(oldf);
1782 fESDObjects->Add(newf);
1789 CreateStdContent(); // create for copy
1790 // if we have the esdfriend add it, so we always can access it via the userinfo
1791 if(fESDFriendOld)AddObject(fESDFriendOld);
1792 // we are not owner of the list objects
1793 // must not delete it
1794 fESDObjects->SetOwner(kTRUE);
1795 fESDObjects->SetName("ESDObjectsConnectedToTree");
1796 tree->GetUserInfo()->Add(fESDObjects);
1804 // Try to find AliESDEvent
1805 AliESDEvent *esdEvent = 0;
1806 esdEvent = (AliESDEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliESDEvent");
1808 // Check if already connected to tree
1810 TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("ESDObjectsConnectedToTree"));
1813 if (connectedList && (strcmp(opt, "reconnect"))) {
1814 // If connected use the connected list if objects
1815 fESDObjects->Delete();
1816 fESDObjects = connectedList;
1817 tree->SetBranchAddress("fDetectorStatus",&fDetectorStatus); //PH probably redundant
1818 tree->SetBranchAddress("fDAQDetectorPattern",&fDAQDetectorPattern);
1819 tree->SetBranchAddress("fDAQAttributes",&fDAQAttributes);
1821 fOldMuonStructure = fESDObjects->TestBit(BIT(23));
1827 // prevent a memory leak when reading back the TList
1828 // if (!(strcmp(opt, "reconnect"))) fESDObjects->Delete();
1831 // create a new TList from the UserInfo TList...
1832 // copy constructor does not work...
1833 fESDObjects = (TList*)(esdEvent->GetList()->Clone());
1834 fESDObjects->SetOwner(kTRUE);
1836 else if ( fESDObjects->GetEntries()==0){
1837 // at least create the std content if we want to read to our list
1842 // we only need new things in the list if we do no already have it..
1843 // TODO just add new entries
1844 CompleteStdContent();
1846 if(fESDObjects->GetEntries()<kESDListN){
1847 AliWarning(Form("AliESDEvent::ReadFromTree() TList contains less than the standard contents %d < %d \n",
1848 fESDObjects->GetEntries(),kESDListN));
1850 // set the branch addresses
1851 fOldMuonStructure = kFALSE;
1852 TIter next(fESDObjects);
1854 while((el=(TNamed*)next())){
1855 TString bname(el->GetName());
1856 if(bname.CompareTo("AliESDfriend")==0)
1858 // AliESDfriend does not have a name ...
1859 TBranch *br = tree->GetBranch("ESDfriend.");
1860 if (br) tree->SetBranchAddress("ESDfriend.",fESDObjects->GetObjectRef(el));
1863 // check if branch exists under this Name
1864 TBranch *br = tree->GetBranch(bname.Data());
1866 tree->SetBranchAddress(bname.Data(),fESDObjects->GetObjectRef(el));
1869 br = tree->GetBranch(Form("%s.",bname.Data()));
1871 tree->SetBranchAddress(Form("%s.",bname.Data()),fESDObjects->GetObjectRef(el));
1874 AliWarning(Form("AliESDEvent::ReadFromTree() No Branch found with Name %s or %s.",bname.Data(),bname.Data()));
1875 if (bname == fgkESDListName[kMuonClusters]) {
1876 fOldMuonStructure = kTRUE;
1883 tree->SetBranchAddress("fDetectorStatus",&fDetectorStatus);
1884 tree->SetBranchAddress("fDAQDetectorPattern",&fDAQDetectorPattern);
1885 tree->SetBranchAddress("fDAQAttributes",&fDAQAttributes);
1888 // when reading back we are not owner of the list
1889 // must not delete it
1890 fESDObjects->SetOwner(kTRUE);
1891 fESDObjects->SetName("ESDObjectsConnectedToTree");
1892 fESDObjects->SetBit(BIT(23), fOldMuonStructure);
1893 // we are not owner of the list objects
1894 // must not delete it
1895 tree->GetUserInfo()->Add(fESDObjects);
1896 tree->GetUserInfo()->SetOwner(kFALSE);
1900 // we can't get the list from the user data, create standard content
1901 // and set it by hand (no ESDfriend at the moment
1903 fOldMuonStructure = kFALSE;
1904 TIter next(fESDObjects);
1906 while((el=(TNamed*)next())){
1907 TString bname(el->GetName());
1908 TBranch *br = tree->GetBranch(bname.Data());
1910 tree->SetBranchAddress(bname.Data(),fESDObjects->GetObjectRef(el));
1913 br = tree->GetBranch(Form("%s.",bname.Data()));
1915 tree->SetBranchAddress(Form("%s.",bname.Data()),fESDObjects->GetObjectRef(el));
1917 else if (bname == fgkESDListName[kMuonClusters]) {
1918 fOldMuonStructure = kTRUE;
1922 tree->SetBranchAddress("fDetectorStatus",&fDetectorStatus);
1923 tree->SetBranchAddress("fDAQDetectorPattern",&fDAQDetectorPattern);
1924 tree->SetBranchAddress("fDAQAttributes",&fDAQAttributes);
1927 // when reading back we are not owner of the list
1928 // must not delete it
1929 fESDObjects->SetOwner(kTRUE);
1933 //______________________________________________________________________________
1934 void AliESDEvent::CopyFromOldESD()
1936 // Method which copies over everthing from the old esd structure to the
1941 SetRunNumber(fESDOld->GetRunNumber());
1942 SetPeriodNumber(fESDOld->GetPeriodNumber());
1943 SetMagneticField(fESDOld->GetMagneticField());
1945 // leave out diamond ...
1946 // SetDiamond(const AliESDVertex *vertex) { fESDRun->SetDiamond(vertex);}
1949 SetTriggerMask(fESDOld->GetTriggerMask());
1950 SetOrbitNumber(fESDOld->GetOrbitNumber());
1951 SetTimeStamp(fESDOld->GetTimeStamp());
1952 SetEventType(fESDOld->GetEventType());
1953 SetEventNumberInFile(fESDOld->GetEventNumberInFile());
1954 SetBunchCrossNumber(fESDOld->GetBunchCrossNumber());
1955 SetTriggerCluster(fESDOld->GetTriggerCluster());
1959 SetZDC(fESDOld->GetZDCN1Energy(),
1960 fESDOld->GetZDCP1Energy(),
1961 fESDOld->GetZDCEMEnergy(),
1963 fESDOld->GetZDCN2Energy(),
1964 fESDOld->GetZDCP2Energy(),
1965 fESDOld->GetZDCParticipants(),
1975 if(fESDOld->GetFMDData())SetFMDData(fESDOld->GetFMDData());
1979 SetT0zVertex(fESDOld->GetT0zVertex());
1980 SetT0(fESDOld->GetT0());
1984 if (fESDOld->GetVZEROData()) SetVZEROData(fESDOld->GetVZEROData());
1986 if(fESDOld->GetVertex())SetPrimaryVertexSPD(fESDOld->GetVertex());
1988 if(fESDOld->GetPrimaryVertex())SetPrimaryVertexTracks(fESDOld->GetPrimaryVertex());
1990 if(fESDOld->GetMultiplicity())SetMultiplicity(fESDOld->GetMultiplicity());
1992 for(int i = 0;i<fESDOld->GetNumberOfTracks();i++){
1993 AddTrack(fESDOld->GetTrack(i));
1996 for(int i = 0;i<fESDOld->GetNumberOfMuonTracks();i++){
1997 AddMuonTrack(fESDOld->GetMuonTrack(i));
2000 for(int i = 0;i<fESDOld->GetNumberOfPmdTracks();i++){
2001 AddPmdTrack(fESDOld->GetPmdTrack(i));
2004 for(int i = 0;i<fESDOld->GetNumberOfTrdTracks();i++){
2005 AddTrdTrack(fESDOld->GetTrdTrack(i));
2008 for(int i = 0;i<fESDOld->GetNumberOfV0s();i++){
2009 AddV0(fESDOld->GetV0(i));
2012 for(int i = 0;i<fESDOld->GetNumberOfCascades();i++){
2013 AddCascade(fESDOld->GetCascade(i));
2016 for(int i = 0;i<fESDOld->GetNumberOfKinks();i++){
2017 AddKink(fESDOld->GetKink(i));
2021 for(int i = 0;i<fESDOld->GetNumberOfCaloClusters();i++){
2022 AddCaloCluster(fESDOld->GetCaloCluster(i));
2028 //______________________________________________________________________________
2029 Bool_t AliESDEvent::IsEventSelected(const char *trigExpr) const
2031 // Check if the event satisfies the trigger
2032 // selection expression trigExpr.
2033 // trigExpr can be any logical expression
2034 // of the trigger classes defined in AliESDRun
2035 // In case of wrong syntax return kTRUE.
2037 TString expr(trigExpr);
2038 if (expr.IsNull()) return kTRUE;
2040 ULong64_t mask = GetTriggerMask();
2041 for(Int_t itrig = 0; itrig < AliESDRun::kNTriggerClasses; itrig++) {
2042 if (mask & (1ull << itrig)) {
2043 expr.ReplaceAll(GetESDRun()->GetTriggerClass(itrig),"1");
2046 expr.ReplaceAll(GetESDRun()->GetTriggerClass(itrig),"0");
2051 if ((gROOT->ProcessLineFast(expr.Data(),&error) == 0) &&
2052 (error == TInterpreter::kNoError)) {
2060 //______________________________________________________________________________
2061 TObject* AliESDEvent::GetHLTTriggerDecision() const
2063 // get the HLT trigger decission object
2065 // cast away const'nes because the FindListObject method
2067 AliESDEvent* pNonConst=const_cast<AliESDEvent*>(this);
2068 return pNonConst->FindListObject("HLTGlobalTrigger");
2071 TString AliESDEvent::GetHLTTriggerDescription() const
2073 // get the HLT trigger decission description
2074 TString description;
2075 TObject* pDecision=GetHLTTriggerDecision();
2077 description=pDecision->GetTitle();
2083 //______________________________________________________________________________
2084 Bool_t AliESDEvent::IsHLTTriggerFired(const char* name) const
2086 // get the HLT trigger decission description
2087 TObject* pDecision=GetHLTTriggerDecision();
2088 if (!pDecision) return kFALSE;
2090 Option_t* option=pDecision->GetOption();
2091 if (option==NULL || *option!='1') return kFALSE;
2094 TString description=GetHLTTriggerDescription();
2095 Int_t index=description.Index(name);
2096 if (index<0) return kFALSE;
2097 index+=strlen(name);
2098 if (index>=description.Length()) return kFALSE;
2099 if (description[index]!=0 && description[index]!=' ') return kFALSE;
2104 //______________________________________________________________________________
2105 Bool_t AliESDEvent::IsPileupFromSPD(Int_t minContributors,
2107 Double_t nSigmaZdist,
2108 Double_t nSigmaDiamXY,
2109 Double_t nSigmaDiamZ) const{
2111 // This function checks if there was a pile up
2112 // reconstructed with SPD
2114 Int_t nc1=fSPDVertex->GetNContributors();
2115 if(nc1<1) return kFALSE;
2116 Int_t nPileVert=GetNumberOfPileupVerticesSPD();
2117 if(nPileVert==0) return kFALSE;
2119 for(Int_t i=0; i<nPileVert;i++){
2120 const AliESDVertex* pv=GetPileupVertexSPD(i);
2121 Int_t nc2=pv->GetNContributors();
2122 if(nc2>=minContributors){
2123 Double_t z1=fSPDVertex->GetZ();
2124 Double_t z2=pv->GetZ();
2125 Double_t distZ=TMath::Abs(z2-z1);
2126 Double_t distZdiam=TMath::Abs(z2-GetDiamondZ());
2127 Double_t cutZdiam=nSigmaDiamZ*TMath::Sqrt(GetSigma2DiamondZ());
2128 if(GetSigma2DiamondZ()<0.0001)cutZdiam=99999.; //protection for missing z diamond information
2129 if(distZ>minZdist && distZdiam<cutZdiam){
2130 Double_t x2=pv->GetX();
2131 Double_t y2=pv->GetY();
2132 Double_t distXdiam=TMath::Abs(x2-GetDiamondX());
2133 Double_t distYdiam=TMath::Abs(y2-GetDiamondY());
2134 Double_t cov1[6],cov2[6];
2135 fSPDVertex->GetCovarianceMatrix(cov1);
2136 pv->GetCovarianceMatrix(cov2);
2137 Double_t errxDist=TMath::Sqrt(cov2[0]+GetSigma2DiamondX());
2138 Double_t erryDist=TMath::Sqrt(cov2[2]+GetSigma2DiamondY());
2139 Double_t errzDist=TMath::Sqrt(cov1[5]+cov2[5]);
2140 Double_t cutXdiam=nSigmaDiamXY*errxDist;
2141 if(GetSigma2DiamondX()<0.0001)cutXdiam=99999.; //protection for missing diamond information
2142 Double_t cutYdiam=nSigmaDiamXY*erryDist;
2143 if(GetSigma2DiamondY()<0.0001)cutYdiam=99999.; //protection for missing diamond information
2144 if( (distXdiam<cutXdiam) && (distYdiam<cutYdiam) && (distZ>nSigmaZdist*errzDist) ){
2153 //______________________________________________________________________________
2154 void AliESDEvent::EstimateMultiplicity(Int_t &tracklets, Int_t &trITSTPC, Int_t &trITSSApure, Double_t eta, Bool_t useDCAFlag,Bool_t useV0Flag) const
2157 // calculates 3 estimators for the multiplicity in the -eta:eta range
2158 // tracklets : using SPD tracklets only
2159 // trITSTPC : using TPC/ITS + complementary ITS SA tracks + tracklets from clusters not used by tracks
2160 // trITSSApure : using ITS standalone tracks + tracklets from clusters not used by tracks
2161 // if useDCAFlag is true: account for the ESDtrack flag marking the tracks with large DCA
2162 // if useV0Flag is true: account for the ESDtrack flag marking conversion and K0's V0s
2164 AliWarning("This obsolete method will be eliminated soon. Use AliESDtrackCuts::GetReferenceMultiplicity");
2166 tracklets = trITSSApure = trITSTPC = 0;
2167 int ntr = fSPDMult ? fSPDMult->GetNumberOfTracklets() : 0;
2170 for (int itr=ntr;itr--;) {
2171 if (TMath::Abs(fSPDMult->GetEta(itr))>eta) continue;
2173 if (fSPDMult->FreeClustersTracklet(itr,0)) trITSTPC++; // not used in ITS/TPC or ITS_SA track
2174 if (fSPDMult->FreeClustersTracklet(itr,1)) trITSSApure++; // not used in ITS_SA_Pure track
2177 // count real tracks
2178 ntr = GetNumberOfTracks();
2179 for (int itr=ntr;itr--;) {
2180 AliESDtrack *t = GetTrack(itr);
2181 if (!t) {AliFatal(Form("NULL pointer for ESD track %d",itr));}
2182 if (TMath::Abs(t->Eta())>eta) continue;
2183 if (!t->IsOn(AliESDtrack::kITSin)) continue;
2184 if (useDCAFlag && t->IsOn(AliESDtrack::kMultSec)) continue;
2185 if (useV0Flag && t->IsOn(AliESDtrack::kMultInV0)) continue;
2186 if (t->IsOn(AliESDtrack::kITSpureSA)) trITSSApure++;
2192 //______________________________________________________________________________
2193 Bool_t AliESDEvent::IsPileupFromSPDInMultBins() const {
2194 Int_t nTracklets=GetMultiplicity()->GetNumberOfTracklets();
2195 if(nTracklets<20) return IsPileupFromSPD(3,0.8);
2196 else if(nTracklets<50) return IsPileupFromSPD(4,0.8);
2197 else return IsPileupFromSPD(5,0.8);
2200 //______________________________________________________________________________
2201 void AliESDEvent::SetTOFHeader(const AliTOFHeader *header)
2204 // Set the TOF event_time
2208 *fTOFHeader=*header;
2209 //fTOFHeader->SetName(fgkESDListName[kTOFHeader]);
2212 // for analysis of reconstructed events
2213 // when this information is not avaliable
2214 fTOFHeader = new AliTOFHeader(*header);
2215 //AddObject(fTOFHeader);
2220 //______________________________________________________________________________
2221 AliCentrality* AliESDEvent::GetCentrality()
2223 if (!fCentrality) fCentrality = new AliCentrality();
2227 //______________________________________________________________________________
2228 AliEventplane* AliESDEvent::GetEventplane()
2230 if (!fEventplane) fEventplane = new AliEventplane();
2234 //______________________________________________________________________________
2235 Float_t AliESDEvent::GetVZEROEqMultiplicity(Int_t i) const
2237 // Get VZERO Multiplicity for channel i
2238 // Themethod uses the equalization factors
2239 // stored in the ESD-run object in order to
2240 // get equal multiplicities within a VZERO rins (1/8 of VZERO)
2241 if (!fESDVZERO || !fESDRun) return -1;
2244 Float_t factorSum = 0;
2245 for(Int_t j = 8*ring; j < (8*ring+8); ++j) {
2246 factorSum += fESDRun->GetVZEROEqFactors(j);
2248 Float_t factor = fESDRun->GetVZEROEqFactors(i)*8./factorSum;
2250 return (fESDVZERO->GetMultiplicity(i)/factor);
2253 //______________________________________________________________________________
2254 void AliESDEvent::SetTOFcluster(Int_t ntofclusters,AliESDTOFCluster *cluster,Int_t *mapping)
2256 // Reset TClonesArray of TOF clusters
2257 if (!fESDTOFClusters) {
2258 AliError("fESDTOFClusters is not initialized");
2261 fESDTOFClusters->Clear();
2263 Int_t goodhit[20000];
2265 for(Int_t i=0;i < 20000;i++){
2270 for(Int_t i=0;i < ntofclusters;i++){
2272 if(cluster[i].GetNMatchableTracks() || !mapping){
2274 mapping[i] = fESDTOFClusters->GetEntriesFast();
2276 // update TClonesArray
2277 TClonesArray &ftr = *fESDTOFClusters;
2278 AliESDTOFCluster *clusterTBW = new(ftr[fESDTOFClusters->GetEntriesFast()])AliESDTOFCluster(cluster[i]);
2281 // loop over hit in the cluster
2282 for(Int_t k=0;k < clusterTBW->GetNTOFhits();k++){
2283 Int_t ipos = clusterTBW->GetHitIndex(k);
2284 goodhit[ipos] = 1; // hit should be kept
2291 AliInfo(Form("TOF cluster before of matching = %i , after = %i\n",ntofclusters,fESDTOFClusters->GetEntriesFast()));
2292 Int_t hitnewpos[20000]={0};
2293 Int_t nhitOriginal = fESDTOFHits->GetEntries();
2294 for(Int_t i=0;i < fESDTOFHits->GetEntries();i++){
2298 else{ // remove hit and decrease the hit array
2299 TClonesArray &a=*fESDTOFHits;
2300 Int_t lastpos = fESDTOFHits->GetEntries()-1;
2303 delete a.RemoveAt(i);
2305 Int_t nhitBefore = fESDTOFHits->GetEntries();
2306 for(Int_t k=nhitBefore-1;k>i;k--){ // find the last good track
2307 if(!goodhit[k]){ // remove track
2308 delete a.RemoveAt(k);
2309 if(k-i==1) delete a.RemoveAt(i);
2311 else{ // replace last one to the "i"
2312 AliESDTOFHit *last = (AliESDTOFHit *) fESDTOFHits->At(k);
2313 delete a.RemoveAt(i);
2314 new (a[i]) AliESDTOFHit(*last);
2315 delete a.RemoveAt(k);
2324 // remap cluster to hits
2325 for(Int_t i=0;i < fESDTOFClusters->GetEntries();i++){
2326 AliESDTOFCluster *cl = (AliESDTOFCluster *) fESDTOFClusters->At(i);
2327 // loop over hit in the cluster
2328 for(Int_t k=0;k < cl->GetNTOFhits();k++){
2329 cl->SetHitIndex(k,hitnewpos[cl->GetHitIndex(k)]);
2332 AliInfo(Form("TOF hit before of matching = %i , after = %i\n",nhitOriginal,fESDTOFHits->GetEntriesFast()));
2337 //______________________________________________________________________________
2338 void AliESDEvent::SetTOFcluster(Int_t ntofclusters,AliESDTOFCluster *cluster[],Int_t *mapping)
2340 // Reset TClonesArray of TOF clusters
2341 if(fESDTOFClusters)fESDTOFClusters->Delete();
2343 Int_t goodhit[20000];
2345 for(Int_t i=0;i < 20000;i++){
2350 for(Int_t i=0;i < ntofclusters;i++){
2352 if(cluster[i]->GetNMatchableTracks() || !mapping){
2354 mapping[i] = fESDTOFClusters->GetEntriesFast();
2356 // update TClonesArray
2357 TClonesArray &ftr = *fESDTOFClusters;
2358 AliESDTOFCluster *clusterTBW = new(ftr[fESDTOFClusters->GetEntriesFast()])AliESDTOFCluster(*(cluster[i]));
2361 // loop over hit in the cluster
2362 for(Int_t k=0;k < clusterTBW->GetNTOFhits();k++){
2363 Int_t ipos = clusterTBW->GetHitIndex(k);
2364 goodhit[ipos] = 1; // hit should be kept
2371 AliInfo(Form("TOF cluster before of matching = %i , after = %i\n",ntofclusters,fESDTOFClusters->GetEntriesFast()));
2372 Int_t hitnewpos[20000]={0};
2373 Int_t nhitOriginal = fESDTOFHits->GetEntries();
2374 for(Int_t i=0;i < fESDTOFHits->GetEntries();i++){
2378 else{ // remove hit and decrease the hit array
2379 TClonesArray &a=*fESDTOFHits;
2380 Int_t lastpos = fESDTOFHits->GetEntries()-1;
2383 delete a.RemoveAt(i);
2385 Int_t nhitBefore = fESDTOFHits->GetEntries();
2386 for(Int_t k=nhitBefore-1;k>i;k--){ // find the last good track
2387 if(!goodhit[k]){ // remove track
2388 delete a.RemoveAt(k);
2389 if(k-i==1) delete a.RemoveAt(i);
2391 else{ // replace last one to the "i"
2392 AliESDTOFHit *last = (AliESDTOFHit *) fESDTOFHits->At(k);
2393 delete a.RemoveAt(i);
2394 new (a[i]) AliESDTOFHit(*last);
2395 delete a.RemoveAt(k);
2404 // remap cluster to hits
2405 for(Int_t i=0;i < fESDTOFClusters->GetEntries();i++){
2406 AliESDTOFCluster *cl = (AliESDTOFCluster *) fESDTOFClusters->At(i);
2407 // loop over hit in the cluster
2408 for(Int_t k=0;k < cl->GetNTOFhits();k++){
2409 cl->SetHitIndex(k,hitnewpos[cl->GetHitIndex(k)]);
2412 AliInfo(Form("TOF hit before of matching = %i , after = %i\n",nhitOriginal,fESDTOFHits->GetEntriesFast()));
2417 //______________________________________________________________________________
2418 void AliESDEvent::ConnectTracks() {
2419 // Connect tracks to this event
2420 if (fTracksConnected || !fTracks || !fTracks->GetEntriesFast()) return;
2422 TIter next(fTracks);
2423 while ((track=(AliESDtrack*)next())) track->SetESDEvent(this);
2425 // The same for TOF clusters
2426 if (fESDTOFClusters) {
2427 AliESDTOFCluster *clus;
2428 TIter nextTOF(fESDTOFClusters);
2429 while ((clus=(AliESDTOFCluster*)nextTOF())) clus->SetEvent((AliVEvent *) this);
2431 fTracksConnected = kTRUE;