AliRoot Core  3dc7879 (3dc7879)
AliESDEvent.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
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  **************************************************************************/
15 
16 /* $Id: AliESDEvent.cxx 64008 2013-08-28 13:09:59Z hristov $ */
17 
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.
22 /*
23  AliESDEvent *ev= new AliESDEvent();
24  ev->ReadFromTree(esdTree);
25  ...
26  for (Int_t i=0; i<nev; i++) {
27  esdTree->GetEntry(i);
28  if(ev->GetAliESDOld())ev->CopyFromOldESD();
29 */
30 // The AliESDInputHandler does this automatically for you
31 //
32 // Origin: Christian Klein-Boesing, CERN, Christian.Klein-Boesing@cern.ch
33 //-----------------------------------------------------------------
34 
35 #include "TList.h"
36 #include "TRefArray.h"
37 #include <TNamed.h>
38 #include <TROOT.h>
39 #include <TInterpreter.h>
40 
41 #include "event.h"
42 #include "AliESDEvent.h"
43 #include "AliESDfriend.h"
44 #include "AliESDVZERO.h"
45 #include "AliESDFMD.h"
46 #include "AliESD.h"
47 #include "AliESDMuonTrack.h"
48 #include "AliESDMuonCluster.h"
49 #include "AliESDMuonPad.h"
50 #include "AliESDMuonGlobalTrack.h" // AU
51 #include "AliESDPmdTrack.h"
52 #include "AliESDTrdTrack.h"
53 #include "AliESDVertex.h"
54 #include "AliESDcascade.h"
55 #include "AliESDPmdTrack.h"
56 #include "AliESDTrdTrigger.h"
57 #include "AliESDTrdTrack.h"
58 #include "AliESDTrdTracklet.h"
59 #include "AliESDVertex.h"
60 #include "AliVertexerTracks.h"
61 #include "AliESDcascade.h"
62 #include "AliESDkink.h"
63 #include "AliESDtrack.h"
64 #include "AliESDHLTtrack.h"
65 #include "AliESDCaloCluster.h"
66 #include "AliESDCaloCells.h"
67 #include "AliESDv0.h"
68 #include "AliESDFMD.h"
69 #include "AliESDVZERO.h"
70 #include "AliMultiplicity.h"
71 #include "AliRawDataErrorLog.h"
72 #include "AliLog.h"
73 #include "AliESDACORDE.h"
74 #include "AliESDAD.h"
75 #include "AliESDHLTDecision.h"
76 #include "AliCentrality.h"
77 #include "AliESDCosmicTrack.h"
79 #include "AliTriggerClass.h"
80 #include "AliTriggerCluster.h"
81 #include "AliEventplane.h"
82 #include "AliMCEvent.h"
83 #include "AliGRPRecoParam.h"
84 #include "AliV0HypSel.h"
85 
86 ClassImp(AliESDEvent)
87 
88 // here we define the names, some classes are no TNamed, therefore the classnames
89 // are the Names
90  const char* AliESDEvent::fgkESDListName[kESDListN] = {"AliESDRun",
91  "AliESDHeader",
92  "AliESDZDC",
93  "AliESDFMD",
94  "AliESDVZERO",
95  "AliESDTZERO",
96  "TPCVertex",
97  "SPDVertex",
98  "PrimaryVertex",
99  "AliMultiplicity",
100  "PHOSTrigger",
101  "EMCALTrigger",
102  "SPDPileupVertices",
103  "TrkPileupVertices",
104  "Tracks",
105  "MuonTracks",
106  "MuonClusters",
107  "MuonPads",
108  "MuonGlobalTracks", // AU
109  "PmdTracks",
110  "AliESDTrdTrigger",
111  "TrdTracks",
112  "TrdTracklets",
113  "V0s",
114  "Cascades",
115  "Kinks",
116  "CaloClusters",
117  "EMCALCells",
118  "PHOSCells",
119  "AliRawDataErrorLogs",
120  "AliESDACORDE",
121  "AliESDAD",
122  "AliTOFHeader",
123  "CosmicTracks",
124  "AliESDTOFCluster",
125  "AliESDTOFHit",
126  "AliESDTOFMatch",
127  "AliESDFIT"};
128 
129 
130 //______________________________________________________________________________
132  AliVEvent(),
133  fESDObjects(new TList()),
134  fESDRun(0),
135  fHeader(0),
136  fESDZDC(0),
137  fESDFMD(0),
138  fESDVZERO(0),
139  fESDTZERO(0),
140  fESDFIT(0),
141  fTPCVertex(0),
142  fSPDVertex(0),
143  fPrimaryVertex(0),
144  fSPDMult(0),
145  fPHOSTrigger(0),
146  fEMCALTrigger(0),
147  fESDACORDE(0),
148  fESDAD(0),
149  fTrdTrigger(0),
150  fSPDPileupVertices(0),
151  fTrkPileupVertices(0),
152  fTracks(0),
153  fMuonTracks(0),
154  fMuonClusters(0),
155  fMuonPads(0),
156  fMuonGlobalTracks(0), // AU
157  fPmdTracks(0),
158  fTrdTracks(0),
159  fTrdTracklets(0),
160  fV0s(0),
161  fCascades(0),
162  fKinks(0),
163  fCaloClusters(0),
164  fEMCALCells(0), fPHOSCells(0),
165  fCosmicTracks(0),
166  fESDTOFClusters(0),
167  fESDTOFHits(0),
168  fESDTOFMatches(0),
169  fErrorLogs(0),
170  fOldMuonStructure(kFALSE),
171  fESDOld(0),
172  fESDFriendOld(0),
173  fConnected(kFALSE),
174  fUseOwnList(kFALSE),
175  fTracksConnected(kFALSE),
176  fTOFHeader(0),
177  fCentrality(0),
178  fEventplane(0),
179  fNTPCFriend2Store(0),
180  fDetectorStatus(0xFFFFFFFF),
181  fDAQDetectorPattern(0xFFFF),
182  fDAQAttributes(0xFFFF),
183  fNTPCClusters(0),
184  fNumberOfESDTracks(-1)
185 {
186 }
187 
188 //______________________________________________________________________________
190  AliVEvent(esd),
191  fESDObjects(new TList()),
192  fESDRun(new AliESDRun(*esd.fESDRun)),
193  fHeader(new AliESDHeader(*esd.fHeader)),
194  fESDZDC(new AliESDZDC(*esd.fESDZDC)),
195  fESDFMD(new AliESDFMD(*esd.fESDFMD)),
196  fESDVZERO(new AliESDVZERO(*esd.fESDVZERO)),
197  fESDTZERO(new AliESDTZERO(*esd.fESDTZERO)),
198  fESDFIT(new AliESDFIT(*esd.fESDFIT)),
202  fSPDMult(new AliMultiplicity(*esd.fSPDMult)),
206  fESDAD(new AliESDAD(*esd.fESDAD)),
208  fSPDPileupVertices(new TClonesArray(*esd.fSPDPileupVertices)),
209  fTrkPileupVertices(new TClonesArray(*esd.fTrkPileupVertices)),
210  fTracks(new TClonesArray(*esd.fTracks)),
211  fMuonTracks(new TClonesArray(*esd.fMuonTracks)),
212  fMuonClusters(new TClonesArray(*esd.fMuonClusters)),
213  fMuonPads(new TClonesArray(*esd.fMuonPads)),
214  fMuonGlobalTracks(new TClonesArray(*esd.fMuonGlobalTracks)), // AU
215  fPmdTracks(new TClonesArray(*esd.fPmdTracks)),
216  fTrdTracks(new TClonesArray(*esd.fTrdTracks)),
217  fTrdTracklets(new TClonesArray(*esd.fTrdTracklets)),
218  fV0s(new TClonesArray(*esd.fV0s)),
219  fCascades(new TClonesArray(*esd.fCascades)),
220  fKinks(new TClonesArray(*esd.fKinks)),
221  fCaloClusters(new TClonesArray(*esd.fCaloClusters)),
224  fCosmicTracks(new TClonesArray(*esd.fCosmicTracks)),
225  fESDTOFClusters(esd.fESDTOFClusters ? new TClonesArray(*esd.fESDTOFClusters) : 0),
226  fESDTOFHits(esd.fESDTOFHits ? new TClonesArray(*esd.fESDTOFHits) : 0),
227  fESDTOFMatches(esd.fESDTOFMatches ? new TClonesArray(*esd.fESDTOFMatches) : 0),
228  fErrorLogs(new TClonesArray(*esd.fErrorLogs)),
230  fESDOld(esd.fESDOld ? new AliESD(*esd.fESDOld) : 0),
232  fConnected(esd.fConnected),
234  fTracksConnected(kFALSE),
244 {
245  printf("copying ESD event...\n"); // AU
246  // CKB init in the constructor list and only add here ...
268  AddObject(fV0s);
270  AddObject(fKinks);
280  AddObject(fESDAD);
284  //
286  GetStdContent();
287  ConnectTracks();
288 
289 }
290 
291 //______________________________________________________________________________
293 
294  // Assignment operator
295  printf("operator = ESD\n");
296  if(&source == this) return *this;
297  AliVEvent::operator=(source);
298 
299  // This assumes that the list is already created
300  // and that the virtual void Copy(Tobject&) function
301  // is correctly implemented in the derived class
302  // otherwise only TObject::Copy() will be used
303 
304 
305 
306  if((fESDObjects->GetSize()==0)&&(source.fESDObjects->GetSize()>=kESDListN)){
307  // We cover the case that we do not yet have the
308  // standard content but the source has it
310  }
311 
312  TIter next(source.GetList());
313  TObject *its = 0;
314  TString name;
315  while ((its = next())) {
316  name.Form("%s", its->GetName());
317  TObject *mine = fESDObjects->FindObject(name.Data());
318  if(!mine){
319  TClass* pClass=TClass::GetClass(its->ClassName());
320  if (!pClass) {
321  AliWarning(Form("Can not find class description for entry %s (%s)\n",
322  its->ClassName(), name.Data()));
323  continue;
324  }
325 
326  mine=(TObject*)pClass->New();
327  if(!mine){
328  // not in this: can be added to list
329  AliWarning(Form("%s:%d Could not find %s for copying \n",
330  (char*)__FILE__,__LINE__,name.Data()));
331  continue;
332  }
333  if(mine->InheritsFrom("TNamed")){
334  ((TNamed*)mine)->SetName(name);
335  }
336  else if(mine->InheritsFrom("TCollection")){
337  if(mine->InheritsFrom("TClonesArray")) {
338  TClonesArray* tcits = dynamic_cast<TClonesArray*>(its);
339  if (tcits)
340  dynamic_cast<TClonesArray*>(mine)->SetClass(tcits->GetClass());
341  }
342  dynamic_cast<TCollection*>(mine)->SetName(name);
343  }
344  AliDebug(1, Form("adding object %s of type %s", mine->GetName(), mine->ClassName()));
345  AddObject(mine);
346  }
347 
348  if(!its->InheritsFrom("TCollection")){
349  // simple objects
350  its->Copy(*mine);
351  }
352  else if(its->InheritsFrom("TClonesArray")){
353  // Create or expand the tclonesarray pointers
354  // so we can directly copy to the object
355  TClonesArray *itstca = (TClonesArray*)its;
356  TClonesArray *minetca = (TClonesArray*)mine;
357 
358  // this leaves the capacity of the TClonesArray the same
359  // except for a factor of 2 increase when size > capacity
360  // does not release any memory occupied by the tca
361  minetca->ExpandCreate(itstca->GetEntriesFast());
362  for(int i = 0;i < itstca->GetEntriesFast();++i){
363  // copy
364  TObject *minetcaobj = minetca->At(i);
365  TObject *itstcaobj = itstca->At(i);
366  // no need to delete first
367  // pointers within the class should be handled by Copy()...
368  // Can there be Empty slots?
369  itstcaobj->Copy(*minetcaobj);
370  }
371  }
372  else{
373  AliWarning(Form("%s:%d cannot copy TCollection \n",
374  (char*)__FILE__,__LINE__));
375  }
376  }
377 
379 
380  fCentrality = source.fCentrality;
381  fEventplane = source.fEventplane;
382  fConnected = source.fConnected;
383  fUseOwnList = source.fUseOwnList;
384 
388  fNTPCClusters = source.fNTPCClusters;
390 
392  fTracksConnected = kFALSE;
393  ConnectTracks();
394  return *this;
395 }
396 
397 
398 //______________________________________________________________________________
400 {
401  //
402  // Standard destructor
403  //
404 
405  // everthing on the list gets deleted automatically
406 
407 
408  if(fESDObjects&&!fConnected)
409  {
410  delete fESDObjects;
411  fESDObjects = 0;
412  }
413  if (fCentrality) delete fCentrality;
414  if (fEventplane) delete fEventplane;
415 
416 
417 }
418 
419 void AliESDEvent::Copy(TObject &obj) const {
420 
421  // interface to TOBject::Copy
422  // Copies the content of this into obj!
423  // bascially obj = *this
424 
425  if(this==&obj)return;
426  AliESDEvent *robj = dynamic_cast<AliESDEvent*>(&obj);
427  if(!robj)return; // not an AliESEvent
428  *robj = *this;
429  return;
430 }
431 
432 //______________________________________________________________________________
434 {
435 
436  // Handle the cases
437  // Std content + Non std content
438  // Reset the standard contents
439  ResetStdContent();
440  fDetectorStatus = 0xFFFFFFFF;
441  fDAQDetectorPattern = 0xFFFF;
442  fDAQAttributes = 0xFFFF;
443  fNTPCClusters = 0;
444  fNumberOfESDTracks = -1;
445  // reset for the old data without AliESDEvent...
446  if(fESDOld)fESDOld->Reset();
447  if(fESDFriendOld){
449  new (fESDFriendOld) AliESDfriend();
450  }
451  //
452 
453  if(fESDObjects->GetSize()>kESDListN){
454  // we have non std content
455  // this also covers esdfriends
456  for(int i = kESDListN;i < fESDObjects->GetSize();++i){
457  TObject *pObject = fESDObjects->At(i);
458  // TClonesArrays
459  if(pObject->InheritsFrom(TClonesArray::Class())){
460  ((TClonesArray*)pObject)->Delete();
461  }
462  else if(!pObject->InheritsFrom(TCollection::Class())){
463  TClass *pClass = TClass::GetClass(pObject->ClassName());
464  if (pClass && pClass->GetListOfMethods()->FindObject("Clear")) {
465  AliDebug(1, Form("Clear for object %s class %s", pObject->GetName(), pObject->ClassName()));
466  pObject->Clear();
467  }
468  else {
469  AliDebug(1, Form("ResetWithPlacementNew for object %s class %s", pObject->GetName(), pObject->ClassName()));
470  ResetWithPlacementNew(pObject);
471  }
472  }
473  else{
474  AliWarning(Form("No reset for %s \n",
475  pObject->ClassName()));
476  }
477  }
478  }
479 
480 }
481 
482 //______________________________________________________________________________
483 Bool_t AliESDEvent::ResetWithPlacementNew(TObject *pObject){
484  //
485  // funtion to reset using the already allocated space
486  //
487  Long_t dtoronly = TObject::GetDtorOnly();
488  TClass *pClass = TClass::GetClass(pObject->ClassName());
489  TObject::SetDtorOnly(pObject);
490  delete pObject;
491  // Recreate with placement new
492  pClass->New(pObject);
493  // Restore the state.
494  TObject::SetDtorOnly((void*)dtoronly);
495  return kTRUE;
496 }
497 
498 //______________________________________________________________________________
500 {
501  // Reset the standard contents
502  if(fESDRun) fESDRun->Reset();
503  if(fHeader) fHeader->Reset();
506  if(fESDZDC) fESDZDC->Reset();
507  if(fESDFMD) {
508  fESDFMD->Clear();
509  }
510  if(fESDVZERO){
511  // reset by callin d'to /c'tor keep the pointer
513  new (fESDVZERO) AliESDVZERO();
514  }
515  if(fESDACORDE){
517  new (fESDACORDE) AliESDACORDE();
518  }
519 
520  if(fESDAD){
521  fESDAD->~AliESDAD();
522  new (fESDAD) AliESDAD();
523  }
524 
525  if(fESDFIT) fESDFIT->Reset();
526 
527  if(fESDTZERO) fESDTZERO->Reset();
528  // CKB no clear/reset implemented
529  if(fTPCVertex){
531  new (fTPCVertex) AliESDVertex();
533  }
534  if(fSPDVertex){
536  new (fSPDVertex) AliESDVertex();
538  }
539  if(fPrimaryVertex){
543  }
544  if(fSPDMult){
546  new (fSPDMult) AliMultiplicity();
547  }
548  if(fTOFHeader){
550  new (fTOFHeader) AliTOFHeader();
551  //fTOFHeader->SetName(fgkESDListName[kTOFHeader]);
552  }
553  if (fTrdTrigger) {
556  }
557 
562  fTracksConnected = kFALSE;
563  if(fTracks)fTracks->Delete();
564  if(fMuonTracks)fMuonTracks->Clear("C");
565  if(fMuonClusters)fMuonClusters->Clear("C");
566  if(fMuonPads)fMuonPads->Clear("C");
567  if(fMuonGlobalTracks)fMuonGlobalTracks->Clear("C"); // AU
568  if(fPmdTracks)fPmdTracks->Delete();
569  if(fTrdTracks)fTrdTracks->Delete();
570  if(fTrdTracklets)fTrdTracklets->Delete();
571  if(fV0s)fV0s->Delete();
572  if(fCascades)fCascades->Delete();
573  if(fKinks)fKinks->Delete();
574  if(fCaloClusters)fCaloClusters->Delete();
577  if(fCosmicTracks)fCosmicTracks->Delete();
578  if(fESDTOFClusters)fESDTOFClusters->Clear();
579  if(fESDTOFHits)fESDTOFHits->Clear();
580  if(fESDTOFMatches)fESDTOFMatches->Clear();
581  if(fErrorLogs) fErrorLogs->Delete();
582 
583  // don't reset fconnected fConnected and the list
584 
585 }
586 
587 
588 //______________________________________________________________________________
589 Int_t AliESDEvent::AddV0(const AliESDv0 *v) {
590  //
591  // Add V0
592  //
593  TClonesArray &fv = *fV0s;
594  Int_t idx=fV0s->GetEntriesFast();
595  new(fv[idx]) AliESDv0(*v);
596  return idx;
597 }
598 
599 //______________________________________________________________________________
600 Bool_t AliESDEvent::IsDetectorInTriggerCluster(TString detector, AliTriggerConfiguration* trigConf) const {
601  // Check if a given detector was read-out in the analyzed event
602  const TObjArray& classesArray=trigConf->GetClasses();
603  ULong64_t trigMask=GetTriggerMask();
604  ULong64_t trigMaskNext50=GetTriggerMaskNext50();
605  Int_t nclasses = classesArray.GetEntriesFast();
606  for(Int_t iclass=0; iclass < nclasses; iclass++ ) {
607  AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At(iclass);
608  ULong64_t classMask=trclass->GetMask();
609  ULong64_t classMaskNext50=trclass->GetMaskNext50();
610  if(trigMask & classMask){
611  TString detList=trclass->GetCluster()->GetDetectorsInCluster();
612  if(detList.Contains(detector.Data())){
613  return kTRUE;
614  }
615  }
616  if(trigMaskNext50 & classMaskNext50){
617  TString detList=trclass->GetCluster()->GetDetectorsInCluster();
618  if(detList.Contains(detector.Data())){
619  return kTRUE;
620  }
621  }
622  }
623  return kFALSE;
624 }
625 //______________________________________________________________________________
626 void AliESDEvent::Print(Option_t *) const
627 {
628  //
629  // Print header information of the event
630  //
631  printf("ESD run information\n");
632  printf("Event # in file %d Bunch crossing # %d Orbit # %d Period # %d Run # %d Trigger %lld %lld Magnetic field %f \n",
635  GetOrbitNumber(),
636  GetPeriodNumber(),
637  GetRunNumber(),
638  GetTriggerMask(),
640  GetMagneticField() );
641  if (fPrimaryVertex)
642  printf("Vertex: (%.4f +- %.4f, %.4f +- %.4f, %.4f +- %.4f) cm\n",
646  printf("Mean vertex in RUN: X=%.4f Y=%.4f Z=%.4f cm\n",
648  if(fSPDMult)
649  printf("SPD Multiplicity. Number of tracklets %d \n",
651  printf("Number of pileup primary vertices reconstructed with SPD %d\n",
653  printf("Number of pileup primary vertices reconstructed using the tracks %d\n",
655  printf("Number of tracks: \n");
656  printf(" charged %d\n", GetNumberOfTracks());
657  printf(" muon %d\n", GetNumberOfMuonTracks());
658  printf(" glob muon %d\n", GetNumberOfMuonGlobalTracks()); // AU
659  printf(" pmd %d\n", GetNumberOfPmdTracks());
660  printf(" trd %d\n", GetNumberOfTrdTracks());
661  printf(" trd trkl %d\n", GetNumberOfTrdTracklets());
662  printf(" v0 %d\n", GetNumberOfV0s());
663  printf(" cascades %d\n", GetNumberOfCascades());
664  printf(" kinks %d\n", GetNumberOfKinks());
665  if(fPHOSCells)printf(" PHOSCells %d\n", fPHOSCells->GetNumberOfCells());
666  else printf(" PHOSCells not in the Event\n");
667  if(fEMCALCells)printf(" EMCALCells %d\n", fEMCALCells->GetNumberOfCells());
668  else printf(" EMCALCells not in the Event\n");
669  printf(" CaloClusters %d\n", GetNumberOfCaloClusters());
670  printf(" FMD %s\n", (fESDFMD ? "yes" : "no"));
671  printf(" VZERO %s\n", (fESDVZERO ? "yes" : "no"));
672  printf(" muClusters %d\n", fMuonClusters ? fMuonClusters->GetEntriesFast() : 0);
673  printf(" muPad %d\n", fMuonPads ? fMuonPads->GetEntriesFast() : 0);
674  if (fCosmicTracks) printf(" Cosmics %d\n", GetNumberOfCosmicTracks());
675 
676  TObject* pHLTDecision=GetHLTTriggerDecision();
677  printf("HLT trigger decision: %s\n", pHLTDecision?pHLTDecision->GetOption():"not available");
678  if (pHLTDecision) pHLTDecision->Print("compact");
679 
680  return;
681 }
682 
683 //______________________________________________________________________________
685 {
686 //
687 // Attaches the complementary info to the ESD
688 //
689  if (!ev) return;
690 
691  // to be sure that we set the tracks also
692  // in case of old esds
693  // if(fESDOld)CopyFromOldESD();
694 
695  Int_t ntrkF=ev->GetNumberOfTracks();
696  if (ev->GetESDIndicesStored()) { // new format: sparse friends
697  for (Int_t i=0; i<ntrkF; i++) {
698  AliESDfriendTrack *f=ev->GetTrack(i);
699  int esdid = f->GetESDtrackID();
700  AliESDtrack* esdt = GetTrack(esdid);
701  if (!esdt) {AliFatalF("ESDfriendTrack %d points on non-existing ESDtrack %d",i,esdid);}
702  if (esdt->GetFriendNotStored()) {AliFatalF("ESDtrack %d did not store the friend, but ESDfriendTrack %d points on it",esdid,i);}
703  esdt->SetFriendTrack(f);
704  }
705  }
706  else {
707  for (Int_t i=0; i<ntrkF; i++) { // old format: 1 to 1 correspondence
708  const AliESDfriendTrack *f=ev->GetTrack(i);
709  if (!f) {AliFatal(Form("NULL pointer for ESD track %d",i));}
710  GetTrack(i)->SetFriendTrack(f);
711  }
712  }
713 }
714 
715 //______________________________________________________________________________
716 Bool_t AliESDEvent::RemoveKink(Int_t rm) const
717 {
718 // ---------------------------------------------------------
719 // Remove a kink candidate and references to it from ESD
720 // ---------------------------------------------------------
721  Int_t last=GetNumberOfKinks()-1;
722  if ((rm<0)||(rm>last)) return kFALSE;
723  TClonesArray &a=*fKinks;
724  AliESDkink* kink = GetKink(rm);
725  // release kink indices from ESDtracks
726  if (kink->GetIndex(0)>=0 && kink->GetIndex(1)>=0) { // the indices migh have been already disabled
727  for (int i=2;i--;) {
728  AliESDtrack* trc = GetTrack(kink->GetIndex(i));
729  int indK[3]={0,0,0},restK=0;
730  for (int j=0;j<3;j++) {
731  int ind = trc->GetKinkIndex(j);
732  if (!ind) break;
733  if (TMath::Abs(ind)!=rm+1) indK[restK++] = ind;
734  }
735  trc->SetKinkIndexes(indK);
736  }
737  }
738  //
739  a.RemoveAt(rm);
740  if (rm==last) return kTRUE;
741  kink = GetKink(last);
742  new (a[rm]) AliESDkink(*kink);
743  //
744  // update references on the moved kink
745  if (kink->GetIndex(0)>=0 && kink->GetIndex(1)>=0) { // the indices migh have been already disabled
746  for (int i=2;i--;) {
747  AliESDtrack* trc = GetTrack(kink->GetIndex(i));
748  int indK[3]={0,0,0};
749  for (int j=0;j<3;j++) {
750  int ind = trc->GetKinkIndex(j);
751  if (!ind) break;
752  int lastI = last+1;
753  if (ind==lastI) indK[j] = rm+1;
754  else if (ind==-lastI) indK[j] = -(rm+1);
755  }
756  trc->SetKinkIndexes(indK);
757  }
758  }
759  a.RemoveAt(last); // remove original copy of moved tracks
760  //
761  return kTRUE;
762 }
763 
764 //______________________________________________________________________________
765 Bool_t AliESDEvent::RemoveV0(Int_t rm) const
766 {
767 // ---------------------------------------------------------
768 // Remove a V0 candidate and references to it from ESD,
769 // if this candidate does not come from a reconstructed decay
770 // ---------------------------------------------------------
771  Int_t last=GetNumberOfV0s()-1;
772  if ((rm<0)||(rm>last)) return kFALSE;
773 
774  AliESDv0 *v0=GetV0(rm);
775  Int_t idxP=v0->GetPindex(), idxN=v0->GetNindex();
776 
777  // Check if this V0 comes from a reconstructed decay
778  Int_t ncs=GetNumberOfCascades();
779  for (Int_t n=0; n<ncs; n++) {
780  AliESDcascade *cs=GetCascade(n);
781  if (idxP==cs->GetPindex() && idxN==cs->GetNindex()) return kFALSE; // cannot remove
782  }
783 
784  //Replace the removed V0 with the last V0
785  TClonesArray &a=*fV0s;
786  delete a.RemoveAt(rm);
787  if (rm!=last) {
788  //move last v0 in place of removed one
789  v0=GetV0(last);
790  new (a[rm]) AliESDv0(*v0);
791  delete a.RemoveAt(last);
792  }
793  return kTRUE;
794 }
795 
796 //______________________________________________________________________________
797 AliESDfriendTrack* AliESDEvent::RemoveTrack(Int_t rm, Bool_t checkPrimVtx)
798 {
799 // ---------------------------------------------------------
800 // Remove a track and references to it from ESD,
801 // if this track does not come from a reconstructed decay
802 // ---------------------------------------------------------
803 
804  AliESDtrack* trc = GetTrack(rm);
805  if (trc->GetKinkIndex(0)!=0) return 0;
806 
807  Int_t last=GetNumberOfTracks()-1;
808  if ((rm<0)||(rm>last)) return 0;
809  Int_t ncs=GetNumberOfCascades();
810  Int_t nv0=GetNumberOfV0s();
811  Int_t ncl=GetNumberOfCaloClusters();
812  Int_t used=0;
813  Bool_t lastUsePVTrc=kFALSE,lastUsePVTPC=kFALSE;
814 
815  if (fTPCVertex && fTPCVertex->GetStatus()) {
816  if (checkPrimVtx && fTPCVertex->UsesTrack(rm)) return 0;// Check if this track comes from the reconstructed primary vertices
817  if (fTPCVertex->UsesTrack(last)) {
818  lastUsePVTPC = kTRUE;
819  used++;
820  }
821  }
823  if (checkPrimVtx && fPrimaryVertex->UsesTrack(rm)) return 0;// Check if this track comes from the reconstructed primary vertices
824  if (fPrimaryVertex->UsesTrack(last)) {
825  lastUsePVTrc = kTRUE;
826  used++;
827  }
828  }
829 
830  // Check if this track comes from a reconstructed decay
831  for (Int_t n=0; n<nv0; n++) {
832  AliESDv0 *v0=GetV0(n);
833 
834  Int_t idx=v0->GetNindex();
835  if (rm==idx) return 0;
836  if (idx==last) used++;
837 
838  idx=v0->GetPindex();
839  if (rm==idx) return 0;
840  if (idx==last) used++;
841  }
842 
843  for (Int_t n=0; n<ncs; n++) {
844  AliESDcascade *cs=GetCascade(n);
845 
846  Int_t idx=cs->GetIndex();
847  if (rm==idx) return 0;
848  if (idx==last) used++;
849 
850  AliESDv0 *v0=cs;
851  idx=v0->GetNindex();
852  if (rm==idx) return 0;
853  if (idx==last) used++;
854 
855  idx=v0->GetPindex();
856  if (rm==idx) return 0;
857  if (idx==last) used++;
858  }
859 
860  // Check if this track is associated with a CaloCluster
861  for (Int_t n=0; n<ncl; n++) {
862  AliESDCaloCluster *cluster=GetCaloCluster(n);
863  TArrayI *arr=cluster->GetTracksMatched();
864  Int_t s=arr->GetSize();
865  while (s--) {
866  Int_t idx=arr->At(s);
867  if (rm==idx) return 0;
868  if (idx==last) used++;
869  }
870  }
871 
872 
873  // from here on we remove the track
874  //
875  //Replace the removed track with the last track
876  TClonesArray &a=*fTracks;
877  AliESDtrack* trm = GetTrack(rm);
878  trm->SuppressTOFMatches(); // remove reference to this track from stored TOF clusters
879  AliESDfriendTrack* trfKeep = (AliESDfriendTrack*)trm->GetFriendTrack(); // friend should be cleaned in the reco
880  trm->ReleaseESDfriendTrack();
881  a.RemoveAt(rm);
882 
883  //
884  if (rm==last) {
885  if (fNumberOfESDTracks>=0) SetNumberOfESDTracks(fTracks->GetEntriesFast());
886  return trfKeep;
887  }
888 
889  AliESDtrack *t=GetTrack(last);
890  if (!t) {AliFatal(Form("NULL pointer for ESD track %d",last));}
891  t->SetID(rm);
892  //
893  // RS: we need to transfer the eventual friend track pointer, w/o creating a clone
895  t->ReleaseESDfriendTrack(); // nullify friend pointer
896  AliESDtrack* trMove = new (a[rm]) AliESDtrack(*t);
897  trMove->SetFriendTrackPointer(tfr);
898  trMove->SetFriendNotStored(tfr==0);
899  tfr->SetESDtrackID(rm);
900  delete a.RemoveAt(last);
901 
902  if (fNumberOfESDTracks>=0) SetNumberOfESDTracks(fTracks->GetEntriesFast());
903 
904  // check if moved track was pointing to a kink, fix index
905  for (int iki=0;iki<3;iki++) {
906  int idkink = trMove->GetKinkIndex(iki);
907  if (!idkink) break;
908  AliESDkink *kn = (AliESDkink*)GetKink(TMath::Abs(idkink)-1);
909  kn->SetIndex(rm, idkink<0 ? 0:1);
910  }
911 
912  if (!used) return trfKeep;
913 
914  // Remap the indices of the tracks used for the primary vertex reconstruction
915  if ( lastUsePVTPC && fTPCVertex->SubstituteTrack(last,rm)) used--;
916  if ( lastUsePVTrc && fPrimaryVertex->SubstituteTrack(last,rm)) used--;
917  if (used<1) return trfKeep;
918 
919  // Remap the indices of the daughters of reconstructed decays
920  for (Int_t n=0; n<nv0; n++) {
921  AliESDv0 *v0=GetV0(n);
922  for (int ip=2;ip--;) {
923  if (v0->GetIndex(ip)==last) {
924  v0->SetIndex(ip,rm);
925  if (--used<1) return trfKeep;
926  }
927  }
928  }
929  for (Int_t n=0; n<ncs; n++) {
930  AliESDcascade *cs=GetCascade(n);
931  if (cs->GetIndex()==last) {
932  cs->SetIndex(rm);
933  if (--used<1) return trfKeep;
934  }
935  AliESDv0 *v0=cs;
936  for (int ip=2;ip--;) {
937  if (v0->GetIndex(ip)==last) {
938  v0->SetIndex(ip,rm);
939  if (--used<1) return trfKeep;
940  }
941  }
942  }
943  // Remap the indices of the tracks accosicated with CaloClusters
944  for (Int_t n=0; n<ncl; n++) {
945  AliESDCaloCluster *cluster=GetCaloCluster(n);
946  TArrayI *arr=cluster->GetTracksMatched();
947  Int_t s=arr->GetSize();
948  while (s--) {
949  Int_t idx=arr->At(s);
950  if (idx==last) {
951  arr->AddAt(rm,s);
952  if (--used<1) return trfKeep;
953  }
954  }
955  }
956  return trfKeep;
957 }
958 
959 //______________________________________________________________________________
960 int AliESDEvent::CleanV0s(const AliGRPRecoParam *grpRecoParam)
961 {
962  // remove v0's not contributing to physics
963  double etaMax = grpRecoParam ? grpRecoParam->GetVertexerV0EtaMax() : 5.0;
964  const TObjArray* v0HypSel = grpRecoParam ? grpRecoParam->GetV0HypSelArray() : 0;
965  int nv0Rem=0, nhypsel = v0HypSel ? v0HypSel->GetEntriesFast() : 0;
966  Bool_t cleanProngs = grpRecoParam ? grpRecoParam->GetCleanOfflineV0Prongs() : kFALSE;
967  if (!cleanProngs && !nhypsel && etaMax>3) return nv0Rem;
968  const double zeroArr[15] = {0.};
969 
971 
972  for (int iv=GetNumberOfV0s();iv--;) {
973  const AliESDv0 *v0 = GetV0(iv);
974  int badV0 = 0;
975  //
976  Bool_t used = v0->GetUsedByCascade();
977  if (v0->GetOnFlyStatus()) {
978  if (used) continue;
979  if (TMath::Abs(v0->Eta())>etaMax) badV0 = 1;
980  else if (nhypsel) {
981  Bool_t reject = kTRUE;
982  float pt = v0->Pt();
983  for (int ih=nhypsel;ih--;) {
984  const AliV0HypSel* hyp = (const AliV0HypSel*)(*v0HypSel)[ih];
985  double m = v0->GetEffMassExplicit(hyp->GetM0(),hyp->GetM1());
986  if (TMath::Abs(m - hyp->GetMass())<hyp->GetMassMargin(pt)) {
987  reject = kFALSE;
988  break;
989  }
990  } // loop over hypotheses
991  if (reject) badV0 = 2;
992  }
993  } // end of online V0 check
994  else {
995  // offline V0s have passed mass hypothesis check already at V0-vertexer level
996  if ( TMath::Abs(v0->Eta())>etaMax && !used) badV0 = 1;
997  if (cleanProngs) { // empty redundand prongs info
1000  parP->Set(parP->GetX(),0.,zeroArr,zeroArr);
1001  parN->Set(parN->GetX(),0.,zeroArr,zeroArr);
1002  }
1003  } // end of offline V0 check
1004 
1005  if (badV0) nv0Rem += RemoveV0(iv);
1006  }
1007  return nv0Rem;
1008 }
1009 
1010 //______________________________________________________________________________
1011 Bool_t AliESDEvent::Clean(TObjArray* tracks2destroy, const AliGRPRecoParam *grpRecoParam)
1012 {
1013  static TBits trackUsed, removeCand;
1014  Bool_t rc = kFALSE;
1015  //
1016  trackUsed.ResetAllBits();
1017  removeCand.ResetAllBits();
1018  //
1019  ULong_t flagsToKeep = grpRecoParam ? grpRecoParam->GetFlagsNotToClean() : 0;
1020 
1021  // flag the tracks used by primary vertices, they will not be touched.
1022  if (fTPCVertex && fTPCVertex->GetStatus()) {
1023  const UShort_t *vind = fTPCVertex->GetIndices();
1024  if (vind) for (int id=fTPCVertex->GetNIndices();id--;) trackUsed.SetBitNumber(vind[id]);
1025  }
1027  const UShort_t *vind = fPrimaryVertex->GetIndices();
1028  if (vind) for (int id=fPrimaryVertex->GetNIndices();id--;) trackUsed.SetBitNumber(vind[id]);
1029  }
1030 
1031  for (int ic=GetNumberOfCascades();ic--;) {
1032  // flag the tracks used by cascades, they will not be touched. Note that cascades use only offline V0's
1033  const AliESDcascade* casc = GetCascade(ic);
1034  trackUsed.SetBitNumber(casc->GetIndex());
1035  trackUsed.SetBitNumber(casc->GetPindex());
1036  trackUsed.SetBitNumber(casc->GetNindex());
1037  }
1038  //
1039  for (int iv=GetNumberOfV0s();iv--;) {
1040  const AliESDv0 *v0 = GetV0(iv);
1041  trackUsed.SetBitNumber(v0->GetIndex(0));
1042  trackUsed.SetBitNumber(v0->GetIndex(1));
1043  }
1044  //
1045  for (int it=GetNumberOfCosmicTracks();it--;) {
1046  const AliESDCosmicTrack *tc = GetCosmicTrack(it);
1047  if (!tc) continue;
1048  trackUsed.SetBitNumber(tc->GetESDUpperTrackIndex());
1049  trackUsed.SetBitNumber(tc->GetESDLowerTrackIndex());
1050  }
1051  // Flag tracks matched to Calo clusters
1052  int nec = GetNumberOfCaloClusters(), necMatch=0;
1053  for (Int_t ic=0; ic<nec; ic++) {
1054  AliESDCaloCluster *cluster = GetCaloCluster(ic);
1055  TArrayI *arr = cluster->GetTracksMatched();
1056  Int_t s = arr->GetSize();
1057  while (s--) {
1058  int tid = arr->At(s);
1059  if (!trackUsed.TestBitNumber(tid)) necMatch++;
1060  trackUsed.SetBitNumber(tid);
1061  }
1062  }
1063 
1064  // remove TPC-only tracks not used by dependent objects
1065  int nRemCand = 0;
1066  float dcaZCut = grpRecoParam ? grpRecoParam->GetCleanDCAZCut() : -1;
1067  if (dcaZCut>0) {
1068  const AliESDVertex* vtx = GetPrimaryVertex();
1069  float zVtx = vtx->GetStatus() ? vtx->GetZ() : 0.;
1070  for (int itr=0;itr<GetNumberOfTracks();itr++) {
1071  if (trackUsed.TestBitNumber(itr)) continue; // used by other objects
1072  AliESDtrack* trc = GetTrack(itr);
1073  if ( (trc->GetStatus() & flagsToKeep)!=0 ) continue; // don't discard with these flags
1074  //
1075  float impPar[2],impCov[3]={0.,0.,0.};
1076  trc->GetImpactParameters(impPar,impCov);
1077  if (impCov[2]<1e-9) { // track was not propagated to vertex, use straight line propagation
1078  impPar[1] = trc->GetZ()-trc->GetTgl()*trc->GetX() - zVtx;
1079  }
1080  if (TMath::Abs(impPar[1])<dcaZCut) continue; // don't touch tracks close to the vtx
1081 
1082  // check if track is a candidate to be matched with PHOS
1083  const AliExternalTrackParam* outPar = trc->GetOuterParam();
1084  double xEst=0, xyzPHOS[3];
1085  if ( outPar && outPar->GetXatLabR(460.,xEst, GetMagneticField()) &&
1086  outPar->GetXYZAt(xEst,GetMagneticField(),xyzPHOS) &&
1087  TMath::Abs(xyzPHOS[2])<95. && // +-64cm + safety margin
1088  TMath::Abs(-1.3963-TMath::ATan2(xyzPHOS[1],xyzPHOS[0]))<7.854e-01) { // 240<phi<330 with 5 degrees margin
1089  continue; // spare this track for potential PHOS matching
1090  }
1091  // flag candidate for removal track
1092  removeCand.SetBitNumber(itr);
1093  nRemCand++;
1094  } // loop over TPConly tracks
1095  }
1096 
1097  if (!nRemCand) return kFALSE; // not track to be removed
1098 
1099  // check if there are kinks whose both legs are flagged for removal
1100  for (int ik=GetNumberOfKinks();ik--;) {
1101  const AliESDkink *kink = GetKink(ik);
1102  int indM = kink->GetIndex(0);
1103  int indD = kink->GetIndex(1);
1104  // remove kink only if both mother and daughter are to be spared
1105  if (removeCand.TestBitNumber(indM) && removeCand.TestBitNumber(indD)) {
1106  RemoveKink(ik);
1107  }
1108  else {
1109  removeCand.ResetBitNumber(indM); // make sure both legs of spared kink are spared
1110  removeCand.ResetBitNumber(indD);
1111  }
1112  }
1113  //
1114  for (int itr=GetNumberOfTracks();itr--;) {
1115  if (removeCand.TestBitNumber(itr)) {
1116  AliESDfriendTrack *remTr = RemoveTrack(itr, kFALSE);
1117  if (remTr) {
1118  rc=kTRUE;
1119  tracks2destroy->Add(remTr);
1120  }
1121  }
1122  }
1123 
1124  return rc;
1125 }
1126 
1127 /*
1128 //______________________________________________________________________________
1129 Bool_t AliESDEvent::Clean(Float_t *cleanPars, TObjArray* tracks2destroy)
1130 {
1131  //
1132  // Remove the data which are not needed for the physics analysis.
1133  //
1134  // 1) Cleaning the V0 candidates
1135  // ---------------------------
1136  // If the cosine of the V0 pointing angle "csp" and
1137  // the DCA between the daughter tracks "dca" does not satisfy
1138  // the conditions
1139  //
1140  // csp > cleanPars[1] + dca/cleanPars[0]*(1.- cleanPars[1])
1141  //
1142  // an attempt to remove this V0 candidate from ESD is made.
1143  //
1144  // The V0 candidate gets removed if it does not belong to any
1145  // recosntructed cascade decay
1146  //
1147  // 12.11.2007, optimal values: cleanPars[0]=0.5, cleanPars[1]=0.999
1148  //
1149  // 2) Cleaning the tracks
1150  // ----------------------
1151  // If track's transverse parameter is larger than cleanPars[2]
1152  // OR
1153  // track's longitudinal parameter is larger than cleanPars[3]
1154  // an attempt to remove this track from ESD is made.
1155  //
1156  // The track gets removed if it does not come
1157  // from a reconstructed decay
1158  //
1159  Bool_t rc=kFALSE;
1160 
1161  Float_t dcaMax=cleanPars[0];
1162  Float_t cspMin=cleanPars[1];
1163 
1164  Int_t nV0s=GetNumberOfV0s();
1165  for (Int_t i=nV0s-1; i>=0; i--) {
1166  AliESDv0 *v0=GetV0(i);
1167 
1168  Float_t dca=v0->GetDcaV0Daughters();
1169  Float_t csp=v0->GetV0CosineOfPointingAngle();
1170  Float_t cspcut=cspMin + dca/dcaMax*(1.-cspMin);
1171  if (csp > cspcut) continue;
1172  if (RemoveV0(i)) rc=kTRUE;
1173  }
1174 
1175 
1176  Float_t dmax=cleanPars[2], zmax=cleanPars[3];
1177 
1178  const AliESDVertex *vertex=GetPrimaryVertexSPD();
1179  Bool_t vtxOK=vertex->GetStatus();
1180 
1181  tracks2destroy->Clear();
1182 
1183  Int_t nTracks=GetNumberOfTracks();
1184  for (Int_t i=nTracks-1; i>=0; i--) {
1185  AliESDtrack *track=GetTrack(i);
1186  if (!track) {AliFatal(Form("NULL pointer for ESD track %d",i));}
1187  Float_t xy,z; track->GetImpactParameters(xy,z);
1188  if ((TMath::Abs(xy) > dmax) || (vtxOK && (TMath::Abs(z) > zmax))) {
1189  AliESDfriendTrack *remTr = RemoveTrack(i);
1190  if (remTr) {
1191  rc=kTRUE;
1192  tracks2destroy->Add(remTr);
1193  }
1194  }
1195  }
1196 
1197  return rc;
1198 }
1199 */
1200 //______________________________________________________________________________
1202 {
1203  // Add a pileup primary vertex reconstructed with SPD
1204  TClonesArray &ftr = *fSPDPileupVertices;
1205  Char_t n=Char_t(ftr.GetEntriesFast());
1206  AliESDVertex *vertex = new(ftr[n]) AliESDVertex(*vtx);
1207  vertex->SetID(n);
1208  return n;
1209 }
1210 
1211 //______________________________________________________________________________
1213 {
1214  // Add a pileup primary vertex reconstructed with SPD
1215  TClonesArray &ftr = *fTrkPileupVertices;
1216  Char_t n=Char_t(ftr.GetEntriesFast());
1217  AliESDVertex *vertex = new(ftr[n]) AliESDVertex(*vtx);
1218  vertex->SetID(n);
1219  return n;
1220 }
1221 
1222 //______________________________________________________________________________
1224 {
1225  // Add track
1226  TClonesArray &ftr = *fTracks;
1227  AliESDtrack * track = new(ftr[fTracks->GetEntriesFast()])AliESDtrack(*t);
1228  track->SetESDEvent(this);
1229  SetNumberOfESDTracks(fTracks->GetEntriesFast());
1230  track->SetID(fNumberOfESDTracks-1);
1231  return track->GetID();
1232 }
1233 
1234 //______________________________________________________________________________
1236 {
1237  // Add a new track
1238  TClonesArray &ftr = *fTracks;
1239  AliESDtrack * track = new(ftr[fTracks->GetEntriesFast()])AliESDtrack();
1240  SetNumberOfESDTracks(fTracks->GetEntriesFast());
1241  track->SetID(fNumberOfESDTracks-1);
1242  track->SetESDEvent(this);
1243  return track;
1244 }
1245 
1246 //______________________________________________________________________________
1248 {
1249  // move MUON clusters and pads to the new ESD structure in needed.
1250  // to ensure backward compatibility
1251 
1252  if (!fOldMuonStructure) return kTRUE;
1253 
1254  if (!fMuonTracks || !fMuonClusters || !fMuonPads) return kFALSE;
1255 
1256  Bool_t reset = kTRUE;
1257  Bool_t containTrackerData = kFALSE;
1258  for (Int_t i = 0; i < fMuonTracks->GetEntriesFast(); i++) {
1259 
1260  AliESDMuonTrack *track = (AliESDMuonTrack*) fMuonTracks->UncheckedAt(i);
1261 
1262  if (track->ContainTrackerData()) containTrackerData = kTRUE;
1263  else continue;
1264 
1265  if (!track->IsOldTrack()) continue;
1266 
1267  // remove objects connected to previous event if needed
1268  if (reset) {
1269  if (fMuonClusters->GetEntriesFast() > 0) fMuonClusters->Clear("C");
1270  if (fMuonPads->GetEntriesFast() > 0) fMuonPads->Clear("C");
1271  reset = kFALSE;
1272  }
1273 
1274  track->MoveClustersToESD(*this);
1275 
1276  }
1277 
1278  // remove objects connected to previous event if needed
1279  if (!containTrackerData) {
1280  if (fMuonClusters->GetEntriesFast() > 0) fMuonClusters->Clear("C");
1281  if (fMuonPads->GetEntriesFast() > 0) fMuonPads->Clear("C");
1282  }
1283 
1284  return kTRUE;
1285 }
1286 
1287 //______________________________________________________________________________
1289 {
1290  // get the MUON track at the position i in the internal array of track
1291  if (!fMuonTracks) return 0x0;
1292  if (!MoveMuonObjects()) return 0x0;
1293  AliESDMuonTrack *track = (AliESDMuonTrack*) fMuonTracks->UncheckedAt(i);
1294  track->SetESDEvent(this);
1295  return track;
1296 }
1297 
1298 //______________________________________________________________________________
1300 {
1301  // get the MUON+MFT track at the position i in the internal array of track
1302  if (!fMuonGlobalTracks) return 0x0;
1304  track->SetESDEvent(this);
1305  return track;
1306 }
1307 
1308 //______________________________________________________________________________
1310 {
1311  // add a MUON track
1312  TClonesArray &fmu = *fMuonTracks;
1313  AliESDMuonTrack *track = new(fmu[fMuonTracks->GetEntriesFast()]) AliESDMuonTrack(*t);
1314  track->MoveClustersToESD(*this);
1315 }
1316 
1317 //______________________________________________________________________________
1319 {
1320  // add a MUON+MFT track
1321  TClonesArray &fmu = *fMuonGlobalTracks;
1322  new (fmu[fMuonGlobalTracks->GetEntriesFast()]) AliESDMuonGlobalTrack(*t);
1323 }
1324 
1325 //______________________________________________________________________________
1326 
1328 {
1329  // create a new MUON track at the end of the internal array of track
1330  TClonesArray &fmu = *fMuonTracks;
1331  return new(fmu[fMuonTracks->GetEntriesFast()]) AliESDMuonTrack();
1332 }
1333 
1334 //______________________________________________________________________________
1336 {
1337  // create a new MUON+MFT track at the end of the internal array of track
1338  TClonesArray &fmu = *fMuonGlobalTracks;
1339  return new(fmu[fMuonGlobalTracks->GetEntriesFast()]) AliESDMuonGlobalTrack();
1340 }
1341 
1342 //______________________________________________________________________________
1344 {
1345  // get the number of MUON clusters
1346  if (!fMuonClusters) return 0;
1347  if (!MoveMuonObjects()) return 0;
1348  return fMuonClusters->GetEntriesFast();
1349 }
1350 
1351 //______________________________________________________________________________
1353 {
1354  // get the MUON cluster at the position i in the internal array of cluster
1355  if (!fMuonClusters) return 0x0;
1356  if (!MoveMuonObjects()) return 0x0;
1357  return (AliESDMuonCluster*) fMuonClusters->UncheckedAt(i);
1358 }
1359 
1360 //______________________________________________________________________________
1362 {
1363  // find the MUON cluster with this Id in the internal array of cluster
1364  if (!fMuonClusters) return 0x0;
1365  if (!MoveMuonObjects()) return 0x0;
1366  for (Int_t i = 0; i < fMuonClusters->GetEntriesFast(); i++) {
1367  AliESDMuonCluster *cluster = (AliESDMuonCluster*) fMuonClusters->UncheckedAt(i);
1368  if (cluster->GetUniqueID() == clusterId) return cluster;
1369  }
1370  return 0x0;
1371 }
1372 
1373 //______________________________________________________________________________
1375 {
1376  // create a new MUON cluster at the end of the internal array of cluster
1377  TClonesArray &fmu = *fMuonClusters;
1378  return new(fmu[fMuonClusters->GetEntriesFast()]) AliESDMuonCluster();
1379 }
1380 
1381 //______________________________________________________________________________
1383 {
1384  // get the number of MUON pads
1385  if (!fMuonPads) return 0;
1386  if (!MoveMuonObjects()) return 0;
1387  return fMuonPads->GetEntriesFast();
1388 }
1389 
1390 //______________________________________________________________________________
1392 {
1393  // get the MUON pad at the position i in the internal array of pad
1394  if (!fMuonPads) return 0x0;
1395  if (!MoveMuonObjects()) return 0x0;
1396  return (AliESDMuonPad*) fMuonPads->UncheckedAt(i);
1397 }
1398 
1399 //______________________________________________________________________________
1401 {
1402  // find the MUON pad with this Id in the internal array of pad
1403  if (!fMuonPads) return 0x0;
1404  if (!MoveMuonObjects()) return 0x0;
1405  for (Int_t i = 0; i < fMuonPads->GetEntriesFast(); i++) {
1406  AliESDMuonPad *pad = (AliESDMuonPad*) fMuonPads->UncheckedAt(i);
1407  if (pad->GetUniqueID() == padId) return pad;
1408  }
1409  return 0x0;
1410 }
1411 
1412 //______________________________________________________________________________
1414 {
1415  // create a new MUON pad at the end of the internal array of pad
1416  TClonesArray &fmu = *fMuonPads;
1417  return new(fmu[fMuonPads->GetEntriesFast()]) AliESDMuonPad();
1418 }
1419 
1420 //______________________________________________________________________________
1422 {
1423  TClonesArray &fpmd = *fPmdTracks;
1424  new(fpmd[fPmdTracks->GetEntriesFast()]) AliESDPmdTrack(*t);
1425 }
1426 
1427 //______________________________________________________________________________
1429 {
1430  *fTrdTrigger = *t;
1431 }
1432 
1433 //______________________________________________________________________________
1435 {
1436  TClonesArray &ftrd = *fTrdTracks;
1437  new(ftrd[fTrdTracks->GetEntriesFast()]) AliESDTrdTrack(*t);
1438 }
1439 
1440 //______________________________________________________________________________
1442 {
1443  new ((*fTrdTracklets)[fTrdTracklets->GetEntriesFast()]) AliESDTrdTracklet(*trkl);
1444 }
1445 
1446 //______________________________________________________________________________
1447 void AliESDEvent::AddTrdTracklet(UInt_t trackletWord, Short_t hcid, const Int_t* label)
1448 {
1449  new ((*fTrdTracklets)[fTrdTracklets->GetEntriesFast()]) AliESDTrdTracklet(trackletWord, hcid, label);
1450 }
1451 
1452 //______________________________________________________________________________
1454 {
1455  // Add kink
1456  TClonesArray &fk = *fKinks;
1457  AliESDkink * kink = new(fk[fKinks->GetEntriesFast()]) AliESDkink(*c);
1458  kink->SetID(fKinks->GetEntriesFast()); // CKB different from the other imps..
1459  return fKinks->GetEntriesFast()-1;
1460 }
1461 
1462 
1463 //______________________________________________________________________________
1465 {
1466  TClonesArray &fc = *fCascades;
1467  new(fc[fCascades->GetEntriesFast()]) AliESDcascade(*c);
1468 }
1469 
1470 //______________________________________________________________________________
1472 {
1473  TClonesArray &ft = *fCosmicTracks;
1474  new(ft[fCosmicTracks->GetEntriesFast()]) AliESDCosmicTrack(*t);
1475 }
1476 
1477 
1478 //______________________________________________________________________________
1480 {
1481  // Add calocluster
1482  TClonesArray &fc = *fCaloClusters;
1483  AliESDCaloCluster *clus = new(fc[fCaloClusters->GetEntriesFast()]) AliESDCaloCluster(*c);
1484  clus->SetID(fCaloClusters->GetEntriesFast()-1);
1485  return fCaloClusters->GetEntriesFast()-1;
1486 }
1487 
1488 
1489 //______________________________________________________________________________
1491  TClonesArray &errlogs = *fErrorLogs;
1492  new(errlogs[errlogs.GetEntriesFast()]) AliRawDataErrorLog(*log);
1493 }
1494 
1495 //______________________________________________________________________________
1497 {
1498  // use already allocated space
1499  if(fESDZDC)
1500  *fESDZDC = *obj;
1501 }
1502 
1503 //______________________________________________________________________________
1505 {
1506  // Set the TPC vertex
1507  // use already allocated space
1508  if(fTPCVertex){
1509  *fTPCVertex = *vertex;
1511  }
1512 }
1513 
1514 //______________________________________________________________________________
1516 {
1517  // Set the SPD vertex
1518  // use already allocated space
1519  if(fSPDVertex){
1520  *fSPDVertex = *vertex;
1522  }
1523 }
1524 
1525 //______________________________________________________________________________
1527 {
1528  // Set the primary vertex reconstructed using he ESD tracks.
1529  // use already allocated space
1530  if(fPrimaryVertex){
1531  *fPrimaryVertex = *vertex;
1533  }
1534 }
1535 
1536 //______________________________________________________________________________
1538 {
1539  //
1540  // Get the "best" available reconstructed primary vertex.
1541  //
1542  if(fPrimaryVertex){
1543  if (fPrimaryVertex->GetStatus()) return fPrimaryVertex;
1544  }
1545  if(fSPDVertex){
1546  if (fSPDVertex->GetStatus()) return fSPDVertex;
1547  }
1548  if(fTPCVertex) return fTPCVertex;
1549 
1550  AliWarning("No primary vertex available. Returning the \"default\"...");
1551  return fSPDVertex;
1552 }
1553 
1554 //______________________________________________________________________________
1556 {
1557  //
1558  // Removes diamond constraint from fPrimaryVertex (reconstructed with tracks)
1559  // Returns a AliESDVertex which has to be deleted by the user
1560  //
1561  if(!fPrimaryVertex) {
1562  AliWarning("No primary vertex from tracks available.");
1563  return 0;
1564  }
1565  if(!fPrimaryVertex->GetStatus()) {
1566  AliWarning("No primary vertex from tracks available.");
1567  return 0;
1568  }
1569 
1570  AliVertexerTracks vertexer(GetMagneticField());
1571  Float_t diamondxyz[3]={(Float_t)GetDiamondX(),(Float_t)GetDiamondY(),0.};
1572  Float_t diamondcovxy[3]; GetDiamondCovXY(diamondcovxy);
1573  Float_t diamondcov[6]={diamondcovxy[0],diamondcovxy[1],diamondcovxy[2],0.,0.,7.};
1574  AliESDVertex *vertex =
1575  (AliESDVertex*)vertexer.RemoveConstraintFromVertex(fPrimaryVertex,diamondxyz,diamondcov);
1576 
1577  return vertex;
1578 }
1579 
1580 //______________________________________________________________________________
1582 {
1583  // Set the SPD Multiplicity
1584  if(fSPDMult){
1585  *fSPDMult = *mul;
1586  }
1587 }
1588 
1589 
1590 //______________________________________________________________________________
1592 {
1593  // use already allocated space
1594  if(fESDFMD){
1595  *fESDFMD = *obj;
1596  }
1597 }
1598 
1599 //______________________________________________________________________________
1601 {
1602  // use already allocated space
1603  if(fESDVZERO)
1604  *fESDVZERO = *obj;
1605 }
1606 
1607 //______________________________________________________________________________
1609 {
1610  // use already allocated space
1611  if(fESDTZERO)
1612  *fESDTZERO = *obj;
1613 }
1614 
1615 //______________________________________________________________________________
1617 {
1618  // use already allocated space
1619  if(fESDFIT)
1620  *fESDFIT = *obj;
1621 }
1622 
1623 
1624 //______________________________________________________________________________
1626 {
1627  if(fESDACORDE)
1628  *fESDACORDE = *obj;
1629 }
1630 
1631 //______________________________________________________________________________
1633 {
1634  if(fESDAD)
1635  *fESDAD = *obj;
1636 }
1637 
1638 //______________________________________________________________________________
1640 {
1641  //
1642  // Extracts the complementary info from the ESD
1643  // RS: instead of cloning full objects, create shallow copies of friend tracks
1644  //
1645  if (!ev) return;
1646 
1647  Int_t ntrk=GetNumberOfTracks();
1648  int nfadd = 0;
1649  for (Int_t i=0; i<ntrk; i++) {
1650  AliESDtrack *t=GetTrack(i);
1651  if (!t) {AliFatal(Form("NULL pointer for ESD track %d",i));}
1652  if (t->GetFriendNotStored()) continue; // skip this one
1654  AliESDfriendTrack *fcopy = ev->AddTrack(f,kTRUE); // create shallow copy
1655  fcopy->SetESDtrackID(i);
1656  t->SetFriendTrackID(nfadd);
1657  f->SetESDtrackID(nfadd++);
1658  }
1659  AliESDfriend *fr = (AliESDfriend*)(const_cast<AliESDEvent*>(this)->FindFriend());
1660  if (fr) ev->SetVZEROfriend(fr->GetVZEROfriend());
1661  ev->SetESDIndicesStored(kTRUE);
1662 }
1663 
1664 //______________________________________________________________________________
1665 void AliESDEvent::AddObject(TObject* obj)
1666 {
1667  // Add an object to the list of object.
1668  // Please be aware that in order to increase performance you should
1669  // refrain from using TObjArrays (if possible). Use TClonesArrays, instead.
1670  fESDObjects->SetOwner(kTRUE);
1671  fESDObjects->AddLast(obj);
1672 }
1673 
1674 //______________________________________________________________________________
1676 {
1677  // set pointers for standard content
1678  // get by name much safer and not a big overhead since not called very often
1679 
1693  fSPDPileupVertices = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kSPDPileupVertices]);
1694  fTrkPileupVertices = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTrkPileupVertices]);
1695  fTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTracks]);
1696  fMuonTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kMuonTracks]);
1697  fMuonClusters = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kMuonClusters]);
1698  fMuonPads = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kMuonPads]);
1699  fMuonGlobalTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kMuonGlobalTracks]); // AU
1700  fPmdTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kPmdTracks]);
1702  fTrdTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTrdTracks]);
1703  fTrdTracklets = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTrdTracklets]);
1704  fV0s = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kV0s]);
1705  fCascades = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kCascades]);
1706  fKinks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kKinks]);
1707  fCaloClusters = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kCaloClusters]);
1710  fErrorLogs = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kErrorLogs]);
1712  fESDAD = (AliESDAD*)fESDObjects->FindObject(fgkESDListName[kESDAD]);
1714  fCosmicTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kCosmicTracks]);
1715  fESDTOFClusters = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTOFclusters]);
1716  fESDTOFHits = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTOFhit]);
1717  fESDTOFMatches = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTOFmatch]);
1718 }
1719 
1720 //______________________________________________________________________________
1722  // Set the names of the standard contents
1723  //
1724  if(fESDObjects->GetEntries()>=kESDListN){
1725  for(int i = 0;i < fESDObjects->GetEntries() && i<kESDListN;i++){
1726  TObject *fObj = fESDObjects->At(i);
1727  if(fObj->InheritsFrom("TNamed")){
1728  ((TNamed*)fObj)->SetName(fgkESDListName[i]);
1729  }
1730  else if(fObj->InheritsFrom("TClonesArray")){
1731  ((TClonesArray*)fObj)->SetName(fgkESDListName[i]);
1732  }
1733  }
1734  }
1735  else{
1736  AliWarning("Std Entries missing");
1737  }
1738 }
1739 
1740 //______________________________________________________________________________
1741 void AliESDEvent::CreateStdContent(Bool_t bUseThisList){
1742  fUseOwnList = bUseThisList;
1743  CreateStdContent();
1744 }
1745 
1746 //______________________________________________________________________________
1748 {
1749  // create the standard AOD content and set pointers
1750 
1751  // create standard objects and add them to the TList of objects
1752  if (fESDObjects->GetEntries()>=kESDListN) {
1753  AliInfoF("StdContent has %d entries, will not create new ones",fESDObjects->GetEntries());
1754  return;
1755  }
1756  AddObject(new AliESDRun());
1757  AddObject(new AliESDHeader());
1758  AddObject(new AliESDZDC());
1759  AddObject(new AliESDFMD());
1760  AddObject(new AliESDVZERO());
1761  AddObject(new AliESDTZERO());
1762  AddObject(new AliESDVertex());
1763  AddObject(new AliESDVertex());
1764  AddObject(new AliESDVertex());
1765  AddObject(new AliMultiplicity());
1768  AddObject(new TClonesArray("AliESDVertex",0));
1769  AddObject(new TClonesArray("AliESDVertex",0));
1770  AddObject(new TClonesArray("AliESDtrack",0));
1771  AddObject(new TClonesArray("AliESDMuonTrack",0));
1772  AddObject(new TClonesArray("AliESDMuonCluster",0));
1773  AddObject(new TClonesArray("AliESDMuonPad",0));
1774  AddObject(new TClonesArray("AliESDMuonGlobalTrack",0)); // AU
1775  AddObject(new TClonesArray("AliESDPmdTrack",0));
1776  AddObject(new AliESDTrdTrigger());
1777  AddObject(new TClonesArray("AliESDTrdTrack",0));
1778  AddObject(new TClonesArray("AliESDTrdTracklet",0));
1779  AddObject(new TClonesArray("AliESDv0",0));
1780  AddObject(new TClonesArray("AliESDcascade",0));
1781  AddObject(new TClonesArray("AliESDkink",0));
1782  AddObject(new TClonesArray("AliESDCaloCluster",0));
1783  AddObject(new AliESDCaloCells());
1784  AddObject(new AliESDCaloCells());
1785  AddObject(new TClonesArray("AliRawDataErrorLog",0));
1786  AddObject(new AliESDACORDE());
1787  AddObject(new AliESDAD());
1788  AddObject(new AliTOFHeader());
1789  AddObject(new TClonesArray("AliESDCosmicTrack",0));
1790  AddObject(new TClonesArray("AliESDTOFCluster",0));
1791  AddObject(new TClonesArray("AliESDTOFHit",0));
1792  AddObject(new TClonesArray("AliESDTOFMatch",0));
1793  AddObject(new AliESDFIT());
1794  // check the order of the indices against enum...
1795 
1796  // set names
1797  SetStdNames();
1798  // read back pointers
1799  GetStdContent();
1800 }
1801 
1802 //______________________________________________________________________________
1804 {
1805  // Create missing standard objects and add them to the TList of objects
1806  //
1807  // Add cosmic tracks for cases where esd files were created
1808  // before adding them to the std content
1809  if (!fESDObjects->FindObject(fgkESDListName[kCosmicTracks])) {
1810  TClonesArray* cosmics = new TClonesArray("AliESDCosmicTrack",0);
1811  fESDObjects->AddAt(cosmics, kCosmicTracks);
1812  fESDObjects->SetOwner(kTRUE);
1813  }
1814  // Add new MUON containers if missing (for backward compatibility)
1815  if (!fESDObjects->FindObject(fgkESDListName[kMuonClusters])) {
1816  TClonesArray* muonClusters = new TClonesArray("AliESDMuonCluster",0);
1817  muonClusters->SetName(fgkESDListName[kMuonClusters]);
1818  fESDObjects->AddAt(muonClusters, kMuonClusters);
1819  fESDObjects->SetOwner(kTRUE);
1820  }
1821  if (!fESDObjects->FindObject(fgkESDListName[kMuonPads])) {
1822  TClonesArray* muonPads = new TClonesArray("AliESDMuonPad",0);
1823  muonPads->SetName(fgkESDListName[kMuonPads]);
1824  fESDObjects->AddAt(muonPads, kMuonPads);
1825  fESDObjects->SetOwner(kTRUE);
1826  }
1827 }
1828 
1829 //______________________________________________________________________________
1830 TObject* AliESDEvent::FindListObject(const char *name) const {
1831 //
1832 // Find object with name "name" in the list of branches
1833 //
1834  if(fESDObjects){
1835  return fESDObjects->FindObject(name);
1836  }
1837  return 0;
1838 }
1839 
1840 //______________________________________________________________________________
1841 Int_t AliESDEvent::GetPHOSClusters(TRefArray *clusters) const
1842 {
1843  // fills the provided TRefArray with all found phos clusters
1844 
1845  clusters->Clear();
1846 
1847  AliESDCaloCluster *cl = 0;
1848  for (Int_t i = 0; i < GetNumberOfCaloClusters(); i++) {
1849 
1850  if ( (cl = GetCaloCluster(i)) ) {
1851  if (cl->IsPHOS()){
1852  clusters->Add(cl);
1853  AliDebug(1,Form("IsPHOS cluster %d Size: %d \n",i,clusters->GetEntriesFast()));
1854  }
1855  }
1856  }
1857  return clusters->GetEntriesFast();
1858 }
1859 
1860 //______________________________________________________________________________
1861 Int_t AliESDEvent::GetEMCALClusters(TRefArray *clusters) const
1862 {
1863  // fills the provided TRefArray with all found emcal clusters
1864 
1865  clusters->Clear();
1866 
1867  AliESDCaloCluster *cl = 0;
1868  for (Int_t i = 0; i < GetNumberOfCaloClusters(); i++) {
1869 
1870  if ( (cl = GetCaloCluster(i)) ) {
1871  if (cl->IsEMCAL()){
1872  clusters->Add(cl);
1873  AliDebug(1,Form("IsEMCAL cluster %d Size: %d \n",i,clusters->GetEntriesFast()));
1874  }
1875  }
1876  }
1877  return clusters->GetEntriesFast();
1878 }
1879 
1880 //______________________________________________________________________________
1881 void AliESDEvent::WriteToTree(TTree* tree) const {
1882  // Book the branches as in TTree::Branch(TCollection*)
1883  // but add a "." at the end of top level branches which are
1884  // not a TClonesArray
1885 
1886 
1887  TString branchname;
1888  TIter next(fESDObjects);
1889  const Int_t kSplitlevel = 99; // default value in TTree::Branch()
1890  const Int_t kBufsize = 32000; // default value in TTree::Branch()
1891  TObject *obj = 0;
1892 
1893  while ((obj = next())) {
1894  branchname.Form("%s", obj->GetName());
1895  if(branchname.CompareTo("AliESDfriend")==0)branchname = "ESDfriend.";
1896  if ((kSplitlevel > 1) && !obj->InheritsFrom(TClonesArray::Class())) {
1897  if(!branchname.EndsWith("."))branchname += ".";
1898  }
1899  if (!tree->FindBranch(branchname)) {
1900  // For the custom streamer to be called splitlevel
1901  // has to be negative, only needed for HLT
1902  Int_t splitLevel = (TString(obj->ClassName()) == "AliHLTGlobalTriggerDecision") ? -1 : kSplitlevel - 1;
1903  tree->Bronch(branchname, obj->ClassName(), fESDObjects->GetObjectRef(obj),kBufsize, splitLevel);
1904  }
1905  }
1906 
1907  tree->Branch("fDetectorStatus",(void*)&fDetectorStatus,"fDetectorStatus/l");
1908  tree->Branch("fDAQDetectorPattern",(void*)&fDAQDetectorPattern,"fDAQDetectorPattern/i");
1909  tree->Branch("fDAQAttributes",(void*)&fDAQAttributes,"fDAQAttributes/i");
1910  tree->Branch("fNTPCClusters",(void*)&fNTPCClusters,"fNTPCClusters/I");
1911  tree->Branch("fNumberOfESDTracks",(void*)&fNumberOfESDTracks,"fNumberOfESDTracks/I");
1912 }
1913 
1914 //______________________________________________________________________________
1915 void AliESDEvent::ReadFromTree(TTree *tree, Option_t* opt){
1916 //
1917 // Connect the ESDEvent to a tree
1918 //
1919  if(!tree){
1920  AliWarning("AliESDEvent::ReadFromTree() Zero Pointer to Tree \n");
1921  return;
1922  }
1923  // load the TTree
1924  if(!tree->GetTree())tree->LoadTree(0);
1925 
1926  // if we find the "ESD" branch on the tree we do have the old structure
1927  if(tree->GetBranch("ESD")) {
1928  fOldMuonStructure = kFALSE;
1929  char ** address = (char **)(tree->GetBranch("ESD")->GetAddress());
1930  // do we have the friend branch
1931  TBranch * esdFB = tree->GetBranch("ESDfriend.");
1932  char ** addressF = 0;
1933  if(esdFB)addressF = (char **)(esdFB->GetAddress());
1934  if (!address) {
1935  AliInfo("AliESDEvent::ReadFromTree() Reading old Tree");
1936  tree->SetBranchAddress("ESD", &fESDOld);
1937  if(esdFB){
1938  tree->SetBranchAddress("ESDfriend.",&fESDFriendOld);
1939  }
1940  } else {
1941  AliInfo("AliESDEvent::ReadFromTree() Reading old Tree");
1942  AliInfo("Branch already connected. Using existing branch address.");
1943  fESDOld = (AliESD*) (*address);
1944  // addressF can still be 0, since branch needs to switched on
1945  if(addressF)fESDFriendOld = (AliESDfriend*) (*addressF);
1946  }
1947 
1948  // have already connected the old ESD structure... ?
1949  // reuse also the pointer of the AlliESDEvent
1950  // otherwise create new ones
1951  TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("ESDObjectsConnectedToTree"));
1952 
1953  if(connectedList){
1954  // If connected use the connected list of objects
1955  if(fESDObjects!= connectedList){
1956  // protect when called twice
1957  fESDObjects->Delete();
1958  fESDObjects = connectedList;
1959  }
1960  GetStdContent();
1961 
1962 
1963  // The pointer to the friend changes when called twice via InitIO
1964  // since AliESDEvent is deleted
1965  TObject* oldf = FindListObject("AliESDfriend");
1966  TObject* newf = 0;
1967  if(addressF){
1968  newf = (TObject*)*addressF;
1969  }
1970  if(newf!=0&&oldf!=newf){
1971  // remove the old reference
1972  // Should we also delete it? Or is this handled in TTree I/O
1973  // since it is created by the first SetBranchAddress
1974  fESDObjects->Remove(oldf);
1975  // add the new one
1976  fESDObjects->Add(newf);
1977  }
1978 
1979  fConnected = true;
1980  return;
1981  }
1982  // else...
1983  CreateStdContent(); // create for copy
1984  // if we have the esdfriend add it, so we always can access it via the userinfo
1986  // we are not owner of the list objects
1987  // must not delete it
1988  fESDObjects->SetOwner(kTRUE);
1989  fESDObjects->SetName("ESDObjectsConnectedToTree");
1990  tree->GetUserInfo()->Add(fESDObjects);
1991  fConnected = true;
1992  return;
1993  }
1994 
1995 
1996  delete fESDOld;
1997  fESDOld = 0;
1998  // Try to find AliESDEvent
1999  AliESDEvent *esdEvent = 0;
2000  esdEvent = (AliESDEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliESDEvent");
2001  if(esdEvent){
2002  // Check if already connected to tree
2003  esdEvent->Reset();
2004  TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("ESDObjectsConnectedToTree"));
2005 
2006 
2007  if (connectedList && (strcmp(opt, "reconnect"))) {
2008  // If connected use the connected list if objects
2009  fESDObjects->Delete();
2010  fESDObjects = connectedList;
2011  tree->SetBranchAddress("fDetectorStatus",&fDetectorStatus); //PH probably redundant
2012  tree->SetBranchAddress("fDAQDetectorPattern",&fDAQDetectorPattern);
2013  tree->SetBranchAddress("fDAQAttributes",&fDAQAttributes);
2014  tree->SetBranchAddress("fNTPCClusters",&fNTPCClusters);
2015  if (tree->GetBranch("fNumberOfESDTracks")) tree->SetBranchAddress("fNumberOfESDTracks",&fNumberOfESDTracks);
2016  GetStdContent();
2017  fOldMuonStructure = fESDObjects->TestBit(BIT(23));
2018  fConnected = true;
2019  return;
2020  }
2021 
2022  // Connect to tree
2023  // prevent a memory leak when reading back the TList
2024  // if (!(strcmp(opt, "reconnect"))) fESDObjects->Delete();
2025 
2026  if(!fUseOwnList){
2027  // create a new TList from the UserInfo TList...
2028  // copy constructor does not work...
2029  fESDObjects = (TList*)(esdEvent->GetList()->Clone());
2030  fESDObjects->SetOwner(kTRUE);
2031  }
2032  else if ( fESDObjects->GetEntries()==0){
2033  // at least create the std content if we want to read to our list
2034  CreateStdContent();
2035  }
2036 
2037  // in principle
2038  // we only need new things in the list if we do no already have it..
2039  // TODO just add new entries
2041 
2042  if(fESDObjects->GetEntries()<kESDListN){
2043  AliWarning(Form("AliESDEvent::ReadFromTree() TList contains less than the standard contents %d < %d \n",
2044  fESDObjects->GetEntries(),kESDListN));
2045  }
2046  // set the branch addresses
2047  fOldMuonStructure = kFALSE;
2048  TIter next(fESDObjects);
2049  TNamed *el;
2050  while((el=(TNamed*)next())){
2051  TString bname(el->GetName());
2052  if(bname.CompareTo("AliESDfriend")==0)
2053  {
2054  // AliESDfriend does not have a name ...
2055  TBranch *br = tree->GetBranch("ESDfriend.");
2056  if (br) tree->SetBranchAddress("ESDfriend.",fESDObjects->GetObjectRef(el));
2057  }
2058  else{
2059  // check if branch exists under this Name
2060  TBranch *br = tree->GetBranch(bname.Data());
2061  if(br){
2062  tree->SetBranchAddress(bname.Data(),fESDObjects->GetObjectRef(el));
2063  }
2064  else{
2065  br = tree->GetBranch(Form("%s.",bname.Data()));
2066  if(br){
2067  tree->SetBranchAddress(Form("%s.",bname.Data()),fESDObjects->GetObjectRef(el));
2068  }
2069  else{
2070  AliWarning(Form("AliESDEvent::ReadFromTree() No Branch found with Name %s or %s.",bname.Data(),bname.Data()));
2071  if (bname == fgkESDListName[kMuonClusters]) {
2072  fOldMuonStructure = kTRUE;
2073  }
2074  }
2075 
2076  }
2077  }
2078  }
2079  tree->SetBranchAddress("fDetectorStatus",&fDetectorStatus);
2080  tree->SetBranchAddress("fDAQDetectorPattern",&fDAQDetectorPattern);
2081  tree->SetBranchAddress("fDAQAttributes",&fDAQAttributes);
2082  tree->SetBranchAddress("fNTPCClusters",&fNTPCClusters);
2083  if (tree->GetBranch("fNumberOfESDTracks")) tree->SetBranchAddress("fNumberOfESDTracks",&fNumberOfESDTracks);
2084  GetStdContent();
2085  // when reading back we are not owner of the list
2086  // must not delete it
2087  fESDObjects->SetOwner(kTRUE);
2088  fESDObjects->SetName("ESDObjectsConnectedToTree");
2089  fESDObjects->SetBit(BIT(23), fOldMuonStructure);
2090  // we are not owner of the list objects
2091  // must not delete it
2092  tree->GetUserInfo()->Add(fESDObjects);
2093  tree->GetUserInfo()->SetOwner(kFALSE);
2094  fConnected = true;
2095  }// no esdEvent -->
2096  else {
2097  // we can't get the list from the user data, create standard content
2098  // and set it by hand (no ESDfriend at the moment
2099  CreateStdContent();
2100  fOldMuonStructure = kFALSE;
2101  TIter next(fESDObjects);
2102  TNamed *el;
2103  while((el=(TNamed*)next())){
2104  TString bname(el->GetName());
2105  TBranch *br = tree->GetBranch(bname.Data());
2106  if(br){
2107  tree->SetBranchAddress(bname.Data(),fESDObjects->GetObjectRef(el));
2108  }
2109  else{
2110  br = tree->GetBranch(Form("%s.",bname.Data()));
2111  if(br){
2112  tree->SetBranchAddress(Form("%s.",bname.Data()),fESDObjects->GetObjectRef(el));
2113  }
2114  else if (bname == fgkESDListName[kMuonClusters]) {
2115  fOldMuonStructure = kTRUE;
2116  }
2117  }
2118  }
2119  tree->SetBranchAddress("fDetectorStatus",&fDetectorStatus);
2120  tree->SetBranchAddress("fDAQDetectorPattern",&fDAQDetectorPattern);
2121  tree->SetBranchAddress("fDAQAttributes",&fDAQAttributes);
2122  tree->SetBranchAddress("fNTPCClusters",&fNTPCClusters);
2123  if (tree->GetBranch("fNumberOfESDTracks")) tree->SetBranchAddress("fNumberOfESDTracks",&fNumberOfESDTracks);
2124 
2125  GetStdContent();
2126  // when reading back we are not owner of the list
2127  // must not delete it
2128  fESDObjects->SetOwner(kTRUE);
2129  }
2130 }
2131 
2132 //______________________________________________________________________________
2134 {
2135  // Method which copies over everthing from the old esd structure to the
2136  // new
2137  if(fESDOld){
2138  ResetStdContent();
2139  // Run
2143 
2144  // leave out diamond ...
2145  // SetDiamond(const AliESDVertex *vertex) { fESDRun->SetDiamond(vertex);}
2146 
2147  // header
2155 
2156  // ZDC
2157 
2161  0,
2165  0,
2166  0,
2167  0,
2168  0,
2169  0,
2170  0);
2171 
2172  // FMD
2173 
2175 
2176  // T0
2177 
2179  SetT0(fESDOld->GetT0());
2180  // leave amps out
2181 
2182  // VZERO
2184 
2186 
2188 
2190 
2191  for(int i = 0;i<fESDOld->GetNumberOfTracks();i++){
2192  AddTrack(fESDOld->GetTrack(i));
2193  }
2194 
2195  for(int i = 0;i<fESDOld->GetNumberOfMuonTracks();i++){
2197  }
2198 
2199  for(int i = 0;i<fESDOld->GetNumberOfPmdTracks();i++){
2201  }
2202 
2203  for(int i = 0;i<fESDOld->GetNumberOfTrdTracks();i++){
2205  }
2206 
2207  for(int i = 0;i<fESDOld->GetNumberOfV0s();i++){
2208  AddV0(fESDOld->GetV0(i));
2209  }
2210 
2211  for(int i = 0;i<fESDOld->GetNumberOfCascades();i++){
2213  }
2214 
2215  for(int i = 0;i<fESDOld->GetNumberOfKinks();i++){
2216  AddKink(fESDOld->GetKink(i));
2217  }
2218 
2219 
2220  for(int i = 0;i<fESDOld->GetNumberOfCaloClusters();i++){
2222  }
2223 
2224  }// if fesdold
2225 }
2226 
2227 //______________________________________________________________________________
2228 Bool_t AliESDEvent::IsEventSelected(const char *trigExpr) const
2229 {
2230  // Check if the event satisfies the trigger
2231  // selection expression trigExpr.
2232  // trigExpr can be any logical expression
2233  // of the trigger classes defined in AliESDRun
2234  // In case of wrong syntax return kTRUE.
2235  // Modified by rl for 100 classes - to be tested
2236 
2237  TString expr(trigExpr);
2238  if (expr.IsNull()) return kTRUE;
2239 
2240  ULong64_t mask = GetTriggerMask();
2241  for(Int_t itrig = 0; itrig < AliESDRun::kNTriggerClasses/2; itrig++) {
2242  if (mask & (1ull << itrig)) {
2243  expr.ReplaceAll(GetESDRun()->GetTriggerClass(itrig),"1");
2244  }
2245  else {
2246  expr.ReplaceAll(GetESDRun()->GetTriggerClass(itrig),"0");
2247  }
2248  }
2249  ULong64_t maskNext50 = GetTriggerMaskNext50();
2250  for(Int_t itrig = 0; itrig < AliESDRun::kNTriggerClasses/2; itrig++) {
2251  if (maskNext50 & (1ull << itrig)) {
2252  expr.ReplaceAll(GetESDRun()->GetTriggerClass(itrig+50),"1");
2253  }
2254  else {
2255  expr.ReplaceAll(GetESDRun()->GetTriggerClass(itrig+50),"0");
2256  }
2257  }
2258 
2259  Int_t error;
2260  if ((gROOT->ProcessLineFast(expr.Data(),&error) == 0) &&
2261  (error == TInterpreter::kNoError)) {
2262  return kFALSE;
2263  }
2264 
2265  return kTRUE;
2266 
2267 }
2268 
2269 //______________________________________________________________________________
2271 {
2272  // get the HLT trigger decission object
2273 
2274  // cast away const'nes because the FindListObject method
2275  // is not const
2276  AliESDEvent* pNonConst=const_cast<AliESDEvent*>(this);
2277  return pNonConst->FindListObject("HLTGlobalTrigger");
2278 }
2279 
2281 {
2282  // get the HLT trigger decission description
2283  TString description;
2284  TObject* pDecision=GetHLTTriggerDecision();
2285  if (pDecision) {
2286  description=pDecision->GetTitle();
2287  }
2288 
2289  return description;
2290 }
2291 
2292 //______________________________________________________________________________
2293 Bool_t AliESDEvent::IsHLTTriggerFired(const char* name) const
2294 {
2295  // get the HLT trigger decission description
2296  TObject* pDecision=GetHLTTriggerDecision();
2297  if (!pDecision) return kFALSE;
2298 
2299  Option_t* option=pDecision->GetOption();
2300  if (option==NULL || *option!='1') return kFALSE;
2301 
2302  if (name) {
2303  TString description=GetHLTTriggerDescription();
2304  Int_t index=description.Index(name);
2305  if (index<0) return kFALSE;
2306  index+=strlen(name);
2307  if (index>=description.Length()) return kFALSE;
2308  if (description[index]!=0 && description[index]!=' ') return kFALSE;
2309  }
2310  return kTRUE;
2311 }
2312 
2313 //______________________________________________________________________________
2314 Bool_t AliESDEvent::IsPileupFromSPD(Int_t minContributors,
2315  Double_t minZdist,
2316  Double_t nSigmaZdist,
2317  Double_t nSigmaDiamXY,
2318  Double_t nSigmaDiamZ) const{
2319  //
2320  // This function checks if there was a pile up
2321  // reconstructed with SPD
2322  //
2323  Int_t nc1=fSPDVertex->GetNContributors();
2324  if(nc1<1) return kFALSE;
2325  Int_t nPileVert=GetNumberOfPileupVerticesSPD();
2326  if(nPileVert==0) return kFALSE;
2327 
2328  for(Int_t i=0; i<nPileVert;i++){
2329  const AliESDVertex* pv=GetPileupVertexSPD(i);
2330  Int_t nc2=pv->GetNContributors();
2331  if(nc2>=minContributors){
2332  Double_t z1=fSPDVertex->GetZ();
2333  Double_t z2=pv->GetZ();
2334  Double_t distZ=TMath::Abs(z2-z1);
2335  Double_t distZdiam=TMath::Abs(z2-GetDiamondZ());
2336  Double_t cutZdiam=nSigmaDiamZ*TMath::Sqrt(GetSigma2DiamondZ());
2337  if(GetSigma2DiamondZ()<0.0001)cutZdiam=99999.; //protection for missing z diamond information
2338  if(distZ>minZdist && distZdiam<cutZdiam){
2339  Double_t x2=pv->GetX();
2340  Double_t y2=pv->GetY();
2341  Double_t distXdiam=TMath::Abs(x2-GetDiamondX());
2342  Double_t distYdiam=TMath::Abs(y2-GetDiamondY());
2343  Double_t cov1[6],cov2[6];
2345  pv->GetCovarianceMatrix(cov2);
2346  Double_t errxDist=TMath::Sqrt(cov2[0]+GetSigma2DiamondX());
2347  Double_t erryDist=TMath::Sqrt(cov2[2]+GetSigma2DiamondY());
2348  Double_t errzDist=TMath::Sqrt(cov1[5]+cov2[5]);
2349  Double_t cutXdiam=nSigmaDiamXY*errxDist;
2350  if(GetSigma2DiamondX()<0.0001)cutXdiam=99999.; //protection for missing diamond information
2351  Double_t cutYdiam=nSigmaDiamXY*erryDist;
2352  if(GetSigma2DiamondY()<0.0001)cutYdiam=99999.; //protection for missing diamond information
2353  if( (distXdiam<cutXdiam) && (distYdiam<cutYdiam) && (distZ>nSigmaZdist*errzDist) ){
2354  return kTRUE;
2355  }
2356  }
2357  }
2358  }
2359  return kFALSE;
2360 }
2361 
2362 //______________________________________________________________________________
2363 void AliESDEvent::EstimateMultiplicity(Int_t &tracklets, Int_t &trITSTPC, Int_t &trITSSApure, Double_t eta, Bool_t useDCAFlag,Bool_t useV0Flag) const
2364 {
2365  //
2366  // calculates 3 estimators for the multiplicity in the -eta:eta range
2367  // tracklets : using SPD tracklets only
2368  // trITSTPC : using TPC/ITS + complementary ITS SA tracks + tracklets from clusters not used by tracks
2369  // trITSSApure : using ITS standalone tracks + tracklets from clusters not used by tracks
2370  // if useDCAFlag is true: account for the ESDtrack flag marking the tracks with large DCA
2371  // if useV0Flag is true: account for the ESDtrack flag marking conversion and K0's V0s
2372 
2373  AliWarning("This obsolete method will be eliminated soon. Use AliESDtrackCuts::GetReferenceMultiplicity");
2374 
2375  tracklets = trITSSApure = trITSTPC = 0;
2376  int ntr = fSPDMult ? fSPDMult->GetNumberOfTracklets() : 0;
2377  //
2378  // count tracklets
2379  for (int itr=ntr;itr--;) {
2380  if (TMath::Abs(fSPDMult->GetEta(itr))>eta) continue;
2381  tracklets++;
2382  if (fSPDMult->FreeClustersTracklet(itr,0)) trITSTPC++; // not used in ITS/TPC or ITS_SA track
2383  if (fSPDMult->FreeClustersTracklet(itr,1)) trITSSApure++; // not used in ITS_SA_Pure track
2384  }
2385  //
2386  // count real tracks
2387  ntr = GetNumberOfTracks();
2388  for (int itr=ntr;itr--;) {
2389  AliESDtrack *t = GetTrack(itr);
2390  if (!t) {AliFatal(Form("NULL pointer for ESD track %d",itr));}
2391  if (TMath::Abs(t->Eta())>eta) continue;
2392  if (!t->IsOn(AliESDtrack::kITSin)) continue;
2393  if (useDCAFlag && t->IsOn(AliESDtrack::kMultSec)) continue;
2394  if (useV0Flag && t->IsOn(AliESDtrack::kMultInV0)) continue;
2395  if (t->IsOn(AliESDtrack::kITSpureSA)) trITSSApure++;
2396  else trITSTPC++;
2397  }
2398  //
2399 }
2400 
2401 //______________________________________________________________________________
2403  Int_t nTracklets=GetMultiplicity()->GetNumberOfTracklets();
2404  if(nTracklets<20) return IsPileupFromSPD(3,0.8);
2405  else if(nTracklets<50) return IsPileupFromSPD(4,0.8);
2406  else return IsPileupFromSPD(5,0.8);
2407 }
2408 
2409 //______________________________________________________________________________
2411 {
2412  //
2413  // Set the TOF event_time
2414  //
2415 
2416  if (fTOFHeader) {
2417  *fTOFHeader=*header;
2418  //fTOFHeader->SetName(fgkESDListName[kTOFHeader]);
2419  }
2420  else {
2421  // for analysis of reconstructed events
2422  // when this information is not avaliable
2423  fTOFHeader = new AliTOFHeader(*header);
2424  //AddObject(fTOFHeader);
2425  }
2426 
2427 }
2428 
2429 //______________________________________________________________________________
2431 {
2432  if (!fCentrality) fCentrality = new AliCentrality();
2433  return fCentrality;
2434 }
2435 
2436 //______________________________________________________________________________
2438 {
2439  if (!fEventplane) fEventplane = new AliEventplane();
2440  return fEventplane;
2441 }
2442 
2443 //______________________________________________________________________________
2445 {
2446  // Get VZERO Multiplicity for channel i
2447  // Themethod uses the equalization factors
2448  // stored in the ESD-run object in order to
2449  // get equal multiplicities within a VZERO rins (1/8 of VZERO)
2450  if (!fESDVZERO || !fESDRun) return -1;
2451 
2452  Int_t ring = i/8;
2453  Float_t factorSum = 0;
2454  for(Int_t j = 8*ring; j < (8*ring+8); ++j) {
2455  factorSum += fESDRun->GetVZEROEqFactors(j);
2456  }
2457  Float_t factor = fESDRun->GetVZEROEqFactors(i)*8./factorSum;
2458 
2459  return (fESDVZERO->GetMultiplicity(i)/factor);
2460 }
2461 
2462 //______________________________________________________________________________
2463 void AliESDEvent::SetTOFcluster(Int_t ntofclusters,AliESDTOFCluster *cluster,Int_t *mapping)
2464 {
2465  // Reset TClonesArray of TOF clusters
2466  if (!fESDTOFClusters) {
2467  AliError("fESDTOFClusters is not initialized");
2468  return;
2469  }
2470  fESDTOFClusters->Clear();
2471 
2472  Int_t goodhit[20000];
2473  if(mapping){
2474  for(Int_t i=0;i < 20000;i++){
2475  goodhit[i] = 0;
2476  }
2477  }
2478 
2479  for(Int_t i=0;i < ntofclusters;i++){
2480 
2481  if(cluster[i].GetNMatchableTracks() || !mapping){
2482  if(mapping)
2483  mapping[i] = fESDTOFClusters->GetEntriesFast();
2484 
2485  // update TClonesArray
2486  TClonesArray &ftr = *fESDTOFClusters;
2487  AliESDTOFCluster *clusterTBW = new(ftr[fESDTOFClusters->GetEntriesFast()])AliESDTOFCluster(cluster[i]);
2488 
2489  if(mapping){
2490  // loop over hit in the cluster
2491  for(Int_t k=0;k < clusterTBW->GetNTOFhits();k++){
2492  Int_t ipos = clusterTBW->GetHitIndex(k);
2493  goodhit[ipos] = 1; // hit should be kept
2494  }
2495  }
2496  }
2497  }
2498 
2499  if(mapping){
2500  AliInfo(Form("TOF cluster before of matching = %i , after = %i\n",ntofclusters,fESDTOFClusters->GetEntriesFast()));
2501  Int_t hitnewpos[20000]={0};
2502  Int_t nhitOriginal = fESDTOFHits->GetEntries();
2503  for(Int_t i=0;i < fESDTOFHits->GetEntries();i++){
2504  if(goodhit[i]){
2505  hitnewpos[i] = i;
2506  }
2507  else{ // remove hit and decrease the hit array
2508  TClonesArray &a=*fESDTOFHits;
2509  Int_t lastpos = fESDTOFHits->GetEntries()-1;
2510 
2511  if(i == lastpos)
2512  delete a.RemoveAt(i);
2513  else{
2514  Int_t nhitBefore = fESDTOFHits->GetEntries();
2515  for(Int_t k=nhitBefore-1;k>i;k--){ // find the last good track
2516  if(!goodhit[k]){ // remove track
2517  delete a.RemoveAt(k);
2518  if(k-i==1) delete a.RemoveAt(i);
2519  }
2520  else{ // replace last one to the "i"
2521  AliESDTOFHit *last = (AliESDTOFHit *) fESDTOFHits->At(k);
2522  delete a.RemoveAt(i);
2523  new (a[i]) AliESDTOFHit(*last);
2524  delete a.RemoveAt(k);
2525  hitnewpos[k] = i;
2526  k = 0;
2527  }
2528  }
2529  }
2530  }
2531  }
2532 
2533  // remap cluster to hits
2534  for(Int_t i=0;i < fESDTOFClusters->GetEntries();i++){
2536  // loop over hit in the cluster
2537  for(Int_t k=0;k < cl->GetNTOFhits();k++){
2538  cl->SetHitIndex(k,hitnewpos[cl->GetHitIndex(k)]);
2539  }
2540  }
2541  AliInfo(Form("TOF hit before of matching = %i , after = %i\n",nhitOriginal,fESDTOFHits->GetEntriesFast()));
2542  } // end mapping
2543 
2544 }
2545 
2546 //______________________________________________________________________________
2547 void AliESDEvent::SetTOFcluster(Int_t ntofclusters,AliESDTOFCluster *cluster[],Int_t *mapping)
2548 {
2549  // Reset TClonesArray of TOF clusters
2550  if(fESDTOFClusters)fESDTOFClusters->Delete();
2551 
2552  Int_t goodhit[20000];
2553  if(mapping){
2554  for(Int_t i=0;i < 20000;i++){
2555  goodhit[i] = 0;
2556  }
2557  }
2558 
2559  for(Int_t i=0;i < ntofclusters;i++){
2560 
2561  if(cluster[i]->GetNMatchableTracks() || !mapping){
2562  if(mapping)
2563  mapping[i] = fESDTOFClusters->GetEntriesFast();
2564 
2565  // update TClonesArray
2566  TClonesArray &ftr = *fESDTOFClusters;
2567  AliESDTOFCluster *clusterTBW = new(ftr[fESDTOFClusters->GetEntriesFast()])AliESDTOFCluster(*(cluster[i]));
2568 
2569  if(mapping){
2570  // loop over hit in the cluster
2571  for(Int_t k=0;k < clusterTBW->GetNTOFhits();k++){
2572  Int_t ipos = clusterTBW->GetHitIndex(k);
2573  goodhit[ipos] = 1; // hit should be kept
2574  }
2575  }
2576  }
2577  }
2578 
2579  if(mapping){
2580  AliInfo(Form("TOF cluster before of matching = %i , after = %i\n",ntofclusters,fESDTOFClusters->GetEntriesFast()));
2581  Int_t hitnewpos[20000]={0};
2582  Int_t nhitOriginal = fESDTOFHits->GetEntries();
2583  for(Int_t i=0;i < fESDTOFHits->GetEntries();i++){
2584  if(goodhit[i]){
2585  hitnewpos[i] = i;
2586  }
2587  else{ // remove hit and decrease the hit array
2588  TClonesArray &a=*fESDTOFHits;
2589  Int_t lastpos = fESDTOFHits->GetEntries()-1;
2590 
2591  if(i == lastpos)
2592  delete a.RemoveAt(i);
2593  else{
2594  Int_t nhitBefore = fESDTOFHits->GetEntries();
2595  for(Int_t k=nhitBefore-1;k>i;k--){ // find the last good track
2596  if(!goodhit[k]){ // remove track
2597  delete a.RemoveAt(k);
2598  if(k-i==1) delete a.RemoveAt(i);
2599  }
2600  else{ // replace last one to the "i"
2601  AliESDTOFHit *last = (AliESDTOFHit *) fESDTOFHits->At(k);
2602  delete a.RemoveAt(i);
2603  new (a[i]) AliESDTOFHit(*last);
2604  delete a.RemoveAt(k);
2605  hitnewpos[k] = i;
2606  k = 0;
2607  }
2608  }
2609  }
2610  }
2611  }
2612 
2613  // remap cluster to hits
2614  for(Int_t i=0;i < fESDTOFClusters->GetEntries();i++){
2616  // loop over hit in the cluster
2617  for(Int_t k=0;k < cl->GetNTOFhits();k++){
2618  cl->SetHitIndex(k,hitnewpos[cl->GetHitIndex(k)]);
2619  }
2620  }
2621  AliInfo(Form("TOF hit before of matching = %i , after = %i\n",nhitOriginal,fESDTOFHits->GetEntriesFast()));
2622  } // end mapping
2623 
2624 }
2625 
2626 //______________________________________________________________________________
2628 // Connect tracks to this event
2629  if (fTracksConnected || !fTracks || !fTracks->GetEntriesFast()) return;
2630  AliESDtrack *track;
2631  TIter next(fTracks);
2632  while ((track=(AliESDtrack*)next())) track->SetESDEvent(this);
2633  //
2634  // The same for TOF clusters
2635  if (fESDTOFClusters) {
2636  AliESDTOFCluster *clus;
2637  TIter nextTOF(fESDTOFClusters);
2638  while ((clus=(AliESDTOFCluster*)nextTOF())) clus->SetEvent((AliVEvent *) this);
2639  }
2641  fTracksConnected = kTRUE;
2642  //
2643 }
2644 
2645 //______________________________________________________________________________
2647 {
2648  return static_cast<AliESDfriend*>(FindListObject("AliESDfriend"));
2649 }
2650 
2652 
2653 //______________________________________________________________________________
2655 {
2656  // check if DAQ has set the incomplete event attributes
2657  return (fDAQAttributes&ATTR_2_B(ATTR_INCOMPLETE_EVENT))!=0
2658  || (fDAQAttributes&ATTR_2_B(ATTR_FLUSHED_EVENT))!=0;
2659 
2660 }
2661 
2662 //______________________________________________________________________________
2664 {
2665  // calculate/return CTP time stamp in the approximation of BC=25ns
2666  const AliTimeStamp* ctp0 = GetCTPStart();
2667  UInt_t tCTP = 0;
2668  if ( !(tCTP=ctp0->GetSeconds()) ) return GetTimeStamp(); // N/A
2669  // subtract from current orbit the orbit at CTP SOR
2670  Long64_t span= Long64_t(GetOrbitNumber())-Long64_t(ctp0->GetOrbit());
2671  // sometimes the ctp0 points to time after the triggers start
2672  if (span<-10000 && GetPeriodNumber()==ctp0->GetPeriod()) {
2673  AliWarningF("The triggered orbit is too much ahead (%lld) of 1st scaler, fall back to GetTimeStamp",span);
2674  return GetTimeStamp();
2675  }
2676  span += Long64_t(GetPeriodNumber()<<24);
2677  tCTP += (span*3564*25/1000 + ctp0->GetMicroSecs())/1000000;
2678  return tCTP;
2679 }
2680 
2681 //______________________________________________________________________________
2683 {
2684  // calculate/return CTP time stamp in the approximation of BC=25ns
2685  const AliTimeStamp* ctp0 = GetCTPStart();
2686  const double kBCLHC = 1./40.079;
2687  double tCTP = 0;
2688  if ( !(tCTP=ctp0->GetSeconds()) ) return GetTimeStamp(); // N/A
2689  Long64_t span= Long64_t(GetOrbitNumber())-Long64_t(ctp0->GetOrbit());
2690  // sometimes the ctp0 points to time after the triggers start
2691  if (span<-10000 && GetPeriodNumber()==ctp0->GetPeriod()) {
2692  AliWarningF("The triggered orbit is too much ahead (%lld) of 1st scaler, fall back to GetTimeStamp",span);
2693  return GetTimeStamp();
2694  }
2695  // subtract from current orbit the orbit at CTP SOR
2696  span += Long64_t(GetPeriodNumber()<<24);
2697  span *= 3564;
2698  span += int(GetBunchCrossNumber())-int(ctp0->GetBunchCross()%3564);
2699  tCTP += (span*kBCLHC+ctp0->GetMicroSecs())/1000000;
2700  return tCTP;
2701 }
2702 
2703 //______________________________________________________________________________
2705 {
2706  // return precise time stamp
2707  const AliTimeStamp* ctp0 = GetCTPStart();
2708  const double kBCLHC = 1./40.079;
2709  UInt_t sec = ctp0->GetSeconds();
2710  UInt_t msec = ctp0->GetMicroSecs();
2711  Long64_t span= Long64_t(GetOrbitNumber())-Long64_t(ctp0->GetOrbit());
2712  Bool_t fail = kFALSE;
2713  if ( !sec ) {
2714  AliWarning("CTP start not available, building from GetTimeStamp()");
2715  sec = GetTimeStamp();
2716  fail = kTRUE;
2717  }
2718  else if (span<-10000 && GetPeriodNumber()==ctp0->GetPeriod()) {
2719  AliWarningF("The triggered orbit is too much ahead (%lld) of 1st scaler, fall back to GetTimeStamp",span);
2720  sec = GetTimeStamp();
2721  fail = kTRUE;
2722  }
2723  else {
2724  span += Long64_t(GetPeriodNumber()<<24);
2725  span *= 3564;
2726  span += int(GetBunchCrossNumber())-int(ctp0->GetBunchCross()%3564);
2727  span *= kBCLHC;
2728  span += msec;
2729  sec += span/1000000;
2730  msec = span%1000000;
2731  }
2732  AliTimeStamp evSt(GetOrbitNumber(),GetPeriodNumber(),sec,msec);
2733  evSt.SetUniqueID(fail);
2734  return evSt;
2735 }
2736 
2737 //______________________________________________________________________________
2739 {
2740  // get number of tracks with TPCrefit
2741  int ntrTPC = 0;
2742  for (int itr=GetNumberOfTracks();itr--;) if (GetTrack(itr)->IsOn(AliESDtrack::kTPCrefit)) ntrTPC++;
2743  return ntrTPC;
2744 }
2745 
2746 //______________________________________________________________________________
2748 {
2749  // adjust labels to account for eventual composed MC event
2750  if (!mcTruth) return;
2751  if (mcTruth->IsA()!=AliMCEvent::Class()) {
2752  AliFatalF("Argument of type %s is expected, %s supplied",
2753  "AliMCEvent",mcTruth->IsA()->GetName());
2754  }
2755  AliMCEvent* mcEvent = (AliMCEvent*) mcTruth;
2756  if (!mcEvent->HasSubsidiaries()) return; // no relabling needed
2757 
2758  int lbraw,lbfix;
2759  for (int itr=GetNumberOfTracks();itr--;) {
2760  AliESDtrack* trc = GetTrack(itr);
2761  // global label
2762  lbraw = trc->GetLabel();
2763  lbfix = mcEvent->Raw2MergedLabel(lbraw<0 ? -lbraw:lbraw);
2764  trc->SetLabel(lbraw<0 ? -lbfix:lbfix);
2765  // ITS label
2766  if (trc->IsOn(AliESDtrack::kITSin)) {
2767  lbraw = trc->GetITSLabel();
2768  lbfix = mcEvent->Raw2MergedLabel(lbraw<0 ? -lbraw:lbraw);
2769  trc->SetITSLabel(lbraw<0 ? -lbfix:lbfix);
2770  }
2771  // TPC label
2772  if (trc->IsOn(AliESDtrack::kTPCin)) {
2773  lbraw = trc->GetTPCLabel();
2774  lbfix = mcEvent->Raw2MergedLabel(lbraw<0 ? -lbraw:lbraw);
2775  trc->SetTPCLabel(lbraw<0 ? -lbfix:lbfix);
2776  }
2777  // TRD label
2778  if (trc->GetTRDntracklets()) {
2779  lbraw = trc->GetTRDLabel();
2780  lbfix = mcEvent->Raw2MergedLabel(lbraw<0 ? -lbraw:lbraw);
2781  trc->SetTRDLabel(lbraw<0 ? -lbfix:lbfix);
2782  }
2783  }
2784  //
2785  // TOF hits (-1 is dummy)
2786  for (int ih=fESDTOFHits->GetEntriesFast();ih--;) {
2787  AliESDTOFHit* thit = (AliESDTOFHit*)fESDTOFHits->At(ih);
2788  int lbtof[3] = {-1,-1,-1};
2789  for (int i=0;i<3;i++) {
2790  if ( (lbtof[i] = thit->GetTOFLabel(i))<0 ) break;
2791  lbtof[i] = mcEvent->Raw2MergedLabel(lbtof[i]);
2792  }
2793  thit->SetTOFLabel(lbtof);
2794  }
2795  // MUON tracks
2796  for (int itr=GetNumberOfMuonTracks();itr--;) {
2797  AliESDMuonTrack* trc = GetMuonTrack(itr);
2798  lbraw = trc->GetLabel();
2799  lbfix = mcEvent->Raw2MergedLabel(lbraw<0 ? -lbraw:lbraw);
2800  trc->SetLabel(lbraw<0 ? -lbfix:lbfix);
2801  }
2802  //
2803  // MFT-MUON Global tracks
2804  for (int itr=GetNumberOfMuonGlobalTracks();itr--;) {
2806  lbraw = trc->GetLabel();
2807  lbfix = mcEvent->Raw2MergedLabel(lbraw<0 ? -lbraw:lbraw);
2808  trc->SetLabel(lbraw<0 ? -lbfix:lbfix);
2809  }
2810  // CALO clusters
2811  for (int icl=GetNumberOfCaloClusters();icl--;) {
2812  AliESDCaloCluster* cl = GetCaloCluster(icl);
2813  int* lbArr = cl->GetLabels();
2814  if (!lbArr) continue;
2815  int nlb = cl->GetNLabels();
2816  for (int i=nlb;i--;) {
2817  lbArr[i] = mcEvent->Raw2MergedLabel(lbArr[i]);
2818  }
2819  }
2820  //
2821  // EMCAL Cells
2822  if (fEMCALCells) {
2823  int ncells = fEMCALCells->GetNumberOfCells();
2824  for (int i=ncells;i--;) {
2825  lbraw = fEMCALCells->GetMCLabel(i);
2826  if (lbraw<-1) continue;
2827  fEMCALCells->SetMCLabel(i,mcEvent->Raw2MergedLabel(lbraw));
2828  }
2829  }
2830  // PHOS Cells
2831  if (fPHOSCells) {
2832  int ncells = fPHOSCells->GetNumberOfCells();
2833  for (int i=ncells;i--;) {
2834  lbraw = fPHOSCells->GetMCLabel(i);
2835  if (lbraw<-1) continue;
2836  fPHOSCells->SetMCLabel(i,mcEvent->Raw2MergedLabel(lbraw));
2837  }
2838  }
2839  // TRD tracklets
2840  for (int itr=GetNumberOfTrdTracklets();itr--;) {
2841  AliESDTrdTracklet* trdTklet = GetTrdTracklet(itr);
2842  for (int i=3;i--;) {
2843  lbraw = trdTklet->GetLabel(i);
2844  if (lbraw<0) continue;
2845  trdTklet->SetLabel(i,mcEvent->Raw2MergedLabel(lbraw));
2846  }
2847  }
2848  // TRD tracks
2849  for (int itr=GetNumberOfTrdTracks();itr--;) {
2850  AliESDTrdTrack* trdTrk = GetTrdTrack(itr);
2851  lbraw = trdTrk->GetLabel();
2852  if (lbraw<0) continue;
2853  trdTrk->SetLabel(mcEvent->Raw2MergedLabel(lbraw));
2854  }
2855  // PMD tracks
2856  for (int itr=GetNumberOfPmdTracks();itr--;) {
2857  AliESDPmdTrack* pmdTrk = GetPmdTrack(itr);
2858  lbraw = pmdTrk->GetClusterTrackNo();
2859  if (lbraw<0) continue;
2860  pmdTrk->SetClusterTrackNo(mcEvent->Raw2MergedLabel(lbraw));
2861  }
2862 
2863 
2864 }
2865 
2866 //________________________________________________
2868 {
2869  // fill redundant prongs info by 0 for offline v0s;
2870  Int_t nv0=GetNumberOfV0s();
2871  const double par0[5]={0.}, cov0[15]={0.};
2872  for (Int_t n=0; n<nv0; n++) {
2873  AliESDv0 *v0=GetV0(n);
2874  if (v0->GetOnFlyStatus()) continue;
2877  parP->Set(parP->GetX(),0.,par0,cov0);
2878  parN->Set(parP->GetX(),0.,par0,cov0);
2879  }
2880 }
2881 
2882 //________________________________________________
2884 {
2885  // fill redundant prongs info by 0 for offline v0s;
2886  Int_t nv0=GetNumberOfV0s();
2887  double bZ = GetMagneticField();
2888  for (Int_t n=0; n<nv0; n++) {
2889  AliESDv0 *v0=GetV0(n);
2890  if (v0->GetOnFlyStatus()) continue;
2893  // if at least 1 v0 was not filled by 0s, this is true for all ...
2894  if (parP->GetSigmaY2()>0. && parP->GetSigmaZ2()>0.) continue;
2895  double xP = parP->GetX(), xN = parN->GetX(); // Only X info is valid
2896  *parP = *GetTrack(v0->GetPindex());
2897  *parN = *GetTrack(v0->GetNindex());
2898  if (!parP->PropagateTo(xP,bZ)) {
2899  AliErrorF("Failed to restore V0 prong from track %d at X=%e",v0->GetPindex(),xP);
2900  parP->Print();
2901  continue;
2902  }
2903  if (!parN->PropagateTo(xN,bZ)) {
2904  AliErrorF("Failed to restore V0 prong from track %d at X=%e",v0->GetPindex(),xP);
2905  parP->Print();
2906  continue;
2907  }
2908  //
2909  }
2910 }
void EmptyOfflineV0Prongs()
Container for HLT decision within the ESD.
Bool_t fOldMuonStructure
Raw-data reading error messages.
Definition: AliESDEvent.h:660
ULong64_t GetBunchCross() const
Definition: AliTimeStamp.h:38
Float_t GetZDCN2Energy() const
Definition: AliESD.h:223
const TObjArray * GetV0HypSelArray() const
void Print(Option_t *option="") const
AliESDtrack * GetTrack(Int_t i) const
Definition: AliESD.h:62
virtual Double_t Pt() const
Definition: AliESDv0.h:41
Class to describe the MUON pads in the Event Summary Data.
Definition: AliESDMuonPad.h:16
Double_t GetSigma2DiamondZ() const
Definition: AliESDEvent.h:155
void SetHitIndex(Int_t i, Int_t index)
void SetTrdTrigger(const AliESDTrdTrigger *t)
static Bool_t ResetWithPlacementNew(TObject *pObject)
const Float_t * GetVZEROEqFactors() const
Definition: AliESDRun.h:127
AliESDCaloCluster * GetCaloCluster(Int_t i) const
Definition: AliESDEvent.h:500
Int_t GetHitIndex(Int_t i) const
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
Bool_t GetUsedByCascade() const
Definition: AliESDv0.h:149
void SetMagneticField(Double_t mf)
Definition: AliESDEvent.h:147
Bool_t fConnected
Old friend esd Structure.
Definition: AliESDEvent.h:664
void SetTPCLabel(int lbl)
Definition: AliESDtrack.h:270
TObject * GetHLTTriggerDecision() const
Int_t GetNumberOfV0s() const
Definition: AliESDEvent.h:552
TClonesArray * fMuonGlobalTracks
MUON ESD pads.
Definition: AliESDEvent.h:644
AliESDfriendTrack * RemoveTrack(Int_t i, Bool_t checkPrimVtx)
Int_t GetPindex() const
Definition: AliESDv0.h:86
void Print(Option_t *option="") const
const AliMultiplicity * GetMultiplicity() const
Definition: AliESD.h:148
AliESDTrdTracklet * GetTrdTracklet(Int_t idx) const
Definition: AliESDEvent.h:470
Double_t GetMagneticField() const
Definition: AliESDEvent.h:148
Double_t GetSigma2DiamondY() const
Definition: AliESDEvent.h:154
UInt_t GetMicroSecs() const
Definition: AliTimeStamp.h:40
virtual Bool_t SubstituteTrack(Int_t indexOld, Int_t indexNew)
Definition: AliVertex.cxx:163
Int_t GetNumberOfTracks() const
Definition: AliESD.h:175
void SetLabel(Int_t label)
AliESDPmdTrack * GetPmdTrack(Int_t i) const
Definition: AliESDEvent.h:450
Double_t GetSigmaZ2() const
float GetM1() const
Definition: AliV0HypSel.h:25
void SetID(Char_t id)
Definition: AliESDVertex.h:81
AliESDkink * GetKink(Int_t i) const
Definition: AliESDEvent.h:495
AliESDTrdTrigger * fTrdTrigger
AD ESD object caontaining bit pattern.
Definition: AliESDEvent.h:636
Int_t GetNumberOfTrdTracks() const
Definition: AliESDEvent.h:550
UInt_t GetSeconds() const
Definition: AliTimeStamp.h:39
Double_t GetDiamondY() const
Definition: AliESDEvent.h:151
Int_t GetITSLabel() const
Definition: AliESDtrack.h:210
Int_t GetTRDLabel() const
Definition: AliESDtrack.h:329
AliESDCosmicTrack * GetCosmicTrack(Int_t i) const
Definition: AliESDEvent.h:516
virtual UShort_t * GetIndices() const
Definition: AliVertex.h:63
AliESDCaloCluster * GetCaloCluster(Int_t i) const
Definition: AliESD.h:126
AliESDMuonTrack * GetMuonTrack(Int_t i)
void SetT0zVertex(Double32_t z)
Definition: AliESDEvent.h:265
UInt_t GetOrbitNumber() const
Definition: AliESD.h:166
TClonesArray * fESDTOFClusters
Tracks created by cosmics finder.
Definition: AliESDEvent.h:655
Int_t fNumberOfESDTracks
Definition: AliESDEvent.h:680
AliESDTZERO * fESDTZERO
VZERO object containing rough multiplicity.
Definition: AliESDEvent.h:626
AliESDMuonTrack * NewMuonTrack()
AliESDFMD * fESDFMD
ZDC information.
Definition: AliESDEvent.h:624
void AddObject(TObject *obj)
void AddRawDataErrorLog(const AliRawDataErrorLog *log) const
Double_t GetEta(Int_t i) const
const AliExternalTrackParam * GetOuterParam() const
Definition: AliESDtrack.h:147
virtual void Copy(TObject &obj) const
Float_t GetZDCP2Energy() const
Definition: AliESD.h:224
void Set(T x, T alpha, const T param[5], const T covar[15])
virtual Float_t GetMultiplicity(Int_t i) const
Int_t GetNumberOfPileupVerticesSPD() const
Definition: AliESDEvent.h:530
Class to describe the MUON tracks in the Event Summary Data class.
virtual Double_t GetY() const
Definition: AliVertex.h:39
#define AliFatalF(message,...)
Definition: AliLog.h:655
#define TObjArray
void SetNumberOfESDTracks(int ntr)
Definition: AliESDEvent.h:539
void SetPrimaryVertexTracks(const AliESDVertex *vertex)
void SetTOFcluster(Int_t ntofclusters, AliESDTOFCluster *cluster, Int_t *mapping=NULL)
const AliESDVertex * GetPrimaryVertex() const
Definition: AliESD.h:153
TArrayI * GetTracksMatched() const
AliESDcascade * GetCascade(Int_t i) const
Definition: AliESDEvent.h:489
Bool_t FreeClustersTracklet(Int_t i, Int_t mode) const
AliESDVertex * fSPDVertex
Primary vertex estimated by the TPC.
Definition: AliESDEvent.h:629
float GetMassMargin(float pT) const
Definition: AliV0HypSel.h:32
Bool_t GetOnFlyStatus() const
Definition: AliESDv0.h:93
void SetFriendTrackID(int id)
Definition: AliESDtrack.h:545
const TObjArray & GetClasses() const
void EstimateMultiplicity(Int_t &tracklets, Int_t &trITSTPC, Int_t &trITSSApure, Double_t eta=1., Bool_t useDCAFlag=kTRUE, Bool_t useV0Flag=kTRUE) const
AliEventplane * fEventplane
Centrality for AA collision.
Definition: AliESDEvent.h:674
TList * fESDObjects
Definition: AliESDEvent.h:619
Double_t GetTimeStampCTPBCCorr() const
Int_t GetID() const
Definition: AliESDtrack.h:69
virtual ~AliESDVZERO()
Definition: AliESDVZERO.h:22
void SetTimeStamp(UInt_t timeStamp)
Definition: AliESDEvent.h:199
Int_t GetLabel() const
Definition: AliESDtrack.h:83
TClonesArray * fSPDPileupVertices
TRD trigger information.
Definition: AliESDEvent.h:638
AliCentrality * fCentrality
event times (and sigmas) as estimated by TOF
Definition: AliESDEvent.h:673
AliESDTrdTrack * GetTrdTrack(Int_t i) const
Definition: AliESD.h:77
Int_t GetNumberOfMuonTracks() const
Definition: AliESD.h:178
void AddPmdTrack(const AliESDPmdTrack *t)
void SetPrimaryVertexTPC(const AliESDVertex *vertex)
Int_t GetESDUpperTrackIndex() const
void SetESDIndicesStored(Bool_t v)
Definition: AliESDfriend.h:87
Int_t AddKink(const AliESDkink *c)
virtual void SetTOFLabel(const Int_t label[3])
Definition: AliESDTOFHit.h:42
void ReleaseESDfriendTrack()
Definition: AliESDtrack.h:63
Int_t GetNTOFhits() const
TROOT * gROOT
Double_t GetYRes() const
Definition: AliESDVertex.h:62
void SetLabel(Int_t label)
Definition: AliESDtrack.h:84
Int_t GetNumberOfPileupVerticesTracks() const
Definition: AliESDEvent.h:533
void SetID(Int_t id)
UShort_t GetBunchCrossNumber() const
Definition: AliESD.h:165
Bool_t fUseOwnList
flag if leaves are alreday connected
Definition: AliESDEvent.h:665
void SetID(Short_t id)
void SetFriendTrack(const AliESDfriendTrack *t)
Definition: AliESDtrack.h:60
Int_t GetIndex(Int_t i) const
Definition: AliESDkink.h:45
AliESDcascade * GetCascade(Int_t i) const
Definition: AliESD.h:110
Double32_t GetT0() const
Definition: AliESD.h:203
ULong64_t GetTriggerMaskNext50() const
Definition: AliESDEvent.h:208
virtual AliESDfriend * FindFriend() const
Char_t AddPileupVertexTracks(const AliESDVertex *vtx)
AliESDPmdTrack * GetPmdTrack(Int_t i) const
Definition: AliESD.h:74
Bool_t IsIncompleteDAQ()
TClonesArray * fTrdTracklets
TRD ESD tracks (triggered)
Definition: AliESDEvent.h:647
void ConnectTracks()
void SetVZEROfriend(const AliESDVZEROfriend *obj)
AliTPCfastTrack * track
ULong64_t GetTriggerMask() const
Definition: AliESD.h:171
void Reset()
Definition: AliESDFIT.cxx:101
Int_t AddCaloCluster(const AliESDCaloCluster *c)
#define AliInfoF(message,...)
Definition: AliLog.h:499
TList * GetList() const
Definition: AliESDEvent.h:582
Int_t GetEventNumberInFile() const
Definition: AliESD.h:164
virtual Double_t GetTgl() const
ULong_t GetFlagsNotToClean() const
UInt_t fDAQAttributes
Definition: AliESDEvent.h:678
ULong64_t GetMask() const
Double_t GetDiamondX() const
Definition: AliESDEvent.h:150
static void AccountBField(float b)
Definition: AliV0HypSel.cxx:94
AliESDHeader * fHeader
Run information tmp put in the Userdata.
Definition: AliESDEvent.h:622
virtual ~AliMultiplicity()
void AddMuonGlobalTrack(const AliESDMuonGlobalTrack *t)
Bool_t ContainTrackerData() const
Float_t GetZDCN1Energy() const
Definition: AliESD.h:221
UInt_t GetTimeStamp() const
Definition: AliESDEvent.h:218
AliESDVertex * PrimaryVertexTracksUnconstrained() const
void SetLabel(Int_t label[])
AliMultiplicity * fSPDMult
Primary vertex estimated using ESD tracks.
Definition: AliESDEvent.h:631
Int_t GetNumberOfMuonPads()
virtual Int_t GetNIndices() const
Definition: AliVertex.h:43
Bool_t MoveMuonObjects()
#define AliWarning(message)
Definition: AliLog.h:541
Double_t GetSigma2DiamondX() const
Definition: AliESDEvent.h:153
AliTOFHeader * fTOFHeader
Definition: AliESDEvent.h:669
void SetZDC(Float_t n1Energy, Float_t p1Energy, Float_t em1Energy, Float_t em2Energy, Float_t n2Energy, Float_t p2Energy, Int_t participants, Int_t nPartA, Int_t nPartC, Double_t b, Double_t bA, Double_t bC, UInt_t recoflag)
Definition: AliESDEvent.h:245
AliESD * fESDOld
Flag if reading ESD with old MUON structure.
Definition: AliESDEvent.h:662
AliESDCaloTrigger * fPHOSTrigger
SPD tracklet multiplicity.
Definition: AliESDEvent.h:632
Int_t GetKinkIndex(Int_t i) const
Definition: AliESDtrack.h:271
Float_t GetZDCEMEnergy() const
Definition: AliESD.h:225
Int_t GetClusterTrackNo() const
const char * GetDetectorsInCluster() const
const AliExternalTrackParam * GetParamP() const
Definition: AliESDv0.h:94
AliESDfriend * fESDFriendOld
Old esd Structure.
Definition: AliESDEvent.h:663
void ResetStdContent()
float GetM0() const
Definition: AliV0HypSel.h:24
TClonesArray * fMuonClusters
MUON ESD tracks.
Definition: AliESDEvent.h:642
void SetFriendNotStored(Bool_t v)
Definition: AliESDtrack.h:543
UInt_t GetTimeStamp() const
Definition: AliESD.h:169
Bool_t IsHLTTriggerFired(const char *name=NULL) const
virtual Float_t GetVZEROEqMultiplicity(Int_t i) const
Char_t AddPileupVertexSPD(const AliESDVertex *vtx)
AliESDVertex * RemoveConstraintFromVertex(AliESDVertex *inVtx, Float_t *diamondxyz, Float_t *diamondcov) const
UInt_t GetEventType() const
Definition: AliESD.h:170
void Reset()
Definition: AliESD.cxx:187
void AdjustMCLabels(const AliVEvent *mctruth)
TClonesArray * fMuonPads
MUON ESD clusters.
Definition: AliESDEvent.h:643
AliESDv0 * GetV0(Int_t i) const
Definition: AliESDEvent.h:478
AliESDMuonPad * FindMuonPad(UInt_t padId)
UChar_t GetTRDntracklets() const
Definition: AliESDtrack.h:294
TTree * tree
float GetMass() const
Definition: AliV0HypSel.h:26
Int_t GetESDtrackID() const
Bool_t IsOn(ULong64_t mask) const
Definition: AliESDtrack.h:81
Bool_t GetXatLabR(Double_t r, Double_t &x, Double_t bz, Int_t dir=0) const
void SetADData(AliESDAD *obj)
ULong64_t GetTriggerMask() const
Definition: AliESDEvent.h:207
Bool_t IsPHOS() const
void RestoreOfflineV0Prongs()
void SetRunNumber(Int_t n)
Definition: AliESDEvent.h:140
void SetESDEvent(AliESDEvent *evt)
void SetIndex(Int_t index, Int_t pos)
Definition: AliESDkink.h:46
void SetLabel(Int_t label)
Set the corresponding MC track number.
TClonesArray * fCascades
V0 vertices.
Definition: AliESDEvent.h:649
AliESDMuonTrack * GetMuonTrack(Int_t i) const
Definition: AliESD.h:71
virtual ~AliESDAD()
Definition: AliESDAD.h:23
Int_t GetNumberOfMuonTracks() const
Definition: AliESDEvent.h:545
Double_t GetSigmaY2() const
const AliESDVertex * GetVertex() const
Definition: AliESD.h:143
void SetMCLabel(Short_t pos, Int_t val)
const AliESDVertex * GetPileupVertexSPD(Int_t i) const
Definition: AliESDEvent.h:383
AliESDtrack * NewTrack()
add new track at the end of tracks array and return instance
#define AliInfo(message)
Definition: AliLog.h:484
Int_t GetNumberOfCaloClusters() const
Definition: AliESD.h:184
Int_t GetRunNumber() const
Definition: AliESDEvent.h:141
AliEventplane * GetEventplane()
Container with calorimeter trigger information in the ESD event.
Int_t GetNumberOfTracks() const
Definition: AliESDfriend.h:41
Double_t GetZRes() const
Definition: AliESDVertex.h:63
void WriteToTree(TTree *tree) const
Class to describe the MUON clusters in the Event Summary Data.
Bool_t GetCleanOfflineV0Prongs() const
void SetPrimaryVertexSPD(const AliESDVertex *vertex)
void CreateStdContent()
Int_t GetNumberOfCosmicTracks() const
Definition: AliESDEvent.h:556
Int_t GetNumberOfPmdTracks() const
Definition: AliESD.h:179
AliESDMuonCluster * FindMuonCluster(UInt_t clusterId)
Int_t GetEMCALClusters(TRefArray *clusters) const
void SetPeriodNumber(UInt_t n)
Definition: AliESDEvent.h:142
TClonesArray * fKinks
Cascade vertices.
Definition: AliESDEvent.h:650
virtual Double_t GetZ() const
Definition: AliVertex.h:40
Double_t GetCleanDCAZCut() const
UInt_t fDAQDetectorPattern
Definition: AliESDEvent.h:677
Int_t GetNumberOfTrdTracklets() const
Definition: AliESDEvent.h:551
AliMultiplicity * GetMultiplicity() const
Definition: AliESDEvent.h:361
int CleanV0s(const AliGRPRecoParam *grpRecoParam)
Int_t GetZDCParticipants() const
Definition: AliESD.h:226
TClonesArray * fCaloClusters
Kinks.
Definition: AliESDEvent.h:651
ULong64_t GetStatus() const
Definition: AliESDtrack.h:82
Int_t GetNumberOfMuonClusters()
void SetZDCData(const AliESDZDC *obj)
UInt_t GetNLabels() const
void SetBunchCrossNumber(UShort_t n)
Definition: AliESDEvent.h:204
Int_t * GetLabels() const
void AddCosmicTrack(const AliESDCosmicTrack *t)
void SetID(Short_t id)
Definition: AliESDkink.h:28
AliESDkink * GetKink(Int_t i) const
Definition: AliESD.h:117
void SetT0(Double32_t timeStart)
Definition: AliESDEvent.h:267
void Reset()
Definition: AliESDRun.cxx:240
TObject * FindListObject(const char *name) const
Int_t AddV0(const AliESDv0 *v)
AliESDVZERO * fESDVZERO
FMD object containing rough multiplicity.
Definition: AliESDEvent.h:625
Event Summary Data for the Forward Multiplicity Detector.This stores the psuedo-multiplicity and -rap...
Definition: AliESDFMD.h:30
AliESDCaloCells * fPHOSCells
EMCAL cell info.
Definition: AliESDEvent.h:653
AliVEvent & operator=(const AliVEvent &vEvnt)
Definition: AliVEvent.cxx:29
Int_t GetNindex() const
Definition: AliESDv0.h:85
void SetITSLabel(Int_t label)
Definition: AliESDtrack.h:211
void AddCascade(const AliESDcascade *c)
Int_t GetNumberOfTrdTracks() const
Definition: AliESD.h:180
Int_t GetRunNumber() const
Definition: AliESD.h:168
Float_t GetZDCP1Energy() const
Definition: AliESD.h:222
Int_t GetNumberOfMuonGlobalTracks() const
Definition: AliESDEvent.h:548
AliESDMuonPad * GetMuonPad(Int_t i)
void SetMultiplicity(const AliMultiplicity *mul)
AliESDTrdTrack * GetTrdTrack(Int_t i) const
Definition: AliESDEvent.h:457
AliTPCcalibV0 v0
const AliTimeStamp * GetCTPStart() const
Definition: AliESDEvent.h:138
Double32_t GetT0zVertex() const
Definition: AliESD.h:201
#define AliWarningF(message,...)
Definition: AliLog.h:556
Calorimeter cluster data container.
void SetESDtrackID(int i)
#define AliFatal(message)
Definition: AliLog.h:640
virtual Double_t GetX() const
Definition: AliVertex.h:38
UInt_t GetOrbitNumber() const
Definition: AliESDEvent.h:217
AliESDEvent & operator=(const AliESDEvent &source)
TF1 * f
Definition: interpolTest.C:21
TClonesArray * fESDTOFHits
TOF clusters.
Definition: AliESDEvent.h:656
AliCentrality * GetCentrality()
AliESDVZEROfriend * GetVZEROfriend()
Definition: AliESDfriend.h:56
AliESDMuonCluster * NewMuonCluster()
AliESDMuonGlobalTrack * GetMuonGlobalTrack(Int_t i)
void SetTOFHeader(const AliTOFHeader *tofEventTime)
void SetIndex(Int_t i, Int_t ind)
Definition: AliESDv0.h:217
Int_t GetLabel() const
Return the corresponding MC track number.
AliESDCaloTrigger * fEMCALTrigger
PHOS Trigger information.
Definition: AliESDEvent.h:633
AliESDFMD * GetFMDData()
Definition: AliESD.h:239
EDataLayoutType
Definition: AliVEvent.h:46
AliESDMuonGlobalTrack * NewMuonGlobalTrack()
Bool_t IsEMCAL() const
void SuppressTOFMatches()
void SetESDfriend(const AliESDfriend *f) const
UInt_t GetPeriod() const
Definition: AliTimeStamp.h:37
void Clear(Option_t *option="")
Definition: AliESDFMD.cxx:176
Int_t GetNumberOfKinks() const
Definition: AliESD.h:183
Double_t GetEffMassExplicit(Double_t m1, Double_t m2) const
Definition: AliESDv0.cxx:881
Int_t GetNumberOfV0s() const
Definition: AliESD.h:181
AliTriggerCluster * GetCluster() const
void Reset()
Definition: AliESDZDC.cxx:194
AliESDFIT * fESDFIT
TZEROObject.
Definition: AliESDEvent.h:627
Int_t fNTPCFriend2Store
Event plane for AA collision.
Definition: AliESDEvent.h:675
TClonesArray * fTrdTracks
PMD ESD tracks.
Definition: AliESDEvent.h:646
#define AliDebug(logLevel, message)
Definition: AliLog.h:300
void SetESDEvent(const AliESDEvent *evt)
Definition: AliESDtrack.h:471
void AddMuonTrack(const AliESDMuonTrack *t)
TClonesArray * fTrkPileupVertices
Pileup primary vertices reconstructed by SPD.
Definition: AliESDEvent.h:639
AliTimeStamp GetAliTimeStamp() const
void ReadFromTree(TTree *tree, Option_t *opt="")
void GetDiamondCovXY(Float_t cov[3]) const
Definition: AliESDEvent.h:156
Int_t fNTPCClusters
Definition: AliESDEvent.h:679
void SetFMDData(AliESDFMD *obj)
AliESDv0 * GetV0(Int_t i) const
Definition: AliESD.h:105
static const char * fgkESDListName[kESDListN]
flag if tracks have already pointer to event set
Definition: AliESDEvent.h:667
virtual Double_t Eta() const
Definition: AliESDv0.h:55
virtual Int_t GetNContributors() const
Definition: AliVertex.h:42
AliESDVertex * fPrimaryVertex
Primary vertex estimated by the SPD.
Definition: AliESDEvent.h:630
Int_t GetIndex() const
Definition: AliESDcascade.h:87
Int_t GetLabel() const
ULong64_t GetMaskNext50() const
Int_t GetNumberOfCascades() const
Definition: AliESDEvent.h:553
UInt_t GetOrbit() const
Definition: AliTimeStamp.h:36
virtual void SetEvent(const AliVEvent *ev)
virtual void GetImpactParameters(Float_t &xy, Float_t &z) const
Definition: AliESDtrack.h:448
Bool_t IsDetectorInTriggerCluster(TString detector, AliTriggerConfiguration *trigConf) const
const AliESDVertex * GetPrimaryVertex() const
void SetESDEvent(AliESDEvent *evt)
void CompleteStdContent()
Short_t GetNumberOfCells() const
Int_t GetMCLabel(Short_t pos) const
Int_t GetIndex(Int_t i) const
Definition: AliESDv0.h:120
void SetTZEROData(const AliESDTZERO *obj)
void SetTRDLabel(int lbl)
Definition: AliESDtrack.h:330
AliESDfriendTrack * AddTrack(const AliESDfriendTrack *t, Bool_t shallow=kFALSE)
Definition: AliESDfriend.h:47
virtual Int_t GetTOFLabel(Int_t i) const
Definition: AliESDTOFHit.h:41
Int_t GetNumberOfTracks() const
Definition: AliESDEvent.h:536
void GetStdContent()
UInt_t GetPeriodNumber() const
Definition: AliESDEvent.h:146
AliESDtrack * GetTrack(Int_t i) const
Definition: AliESDEvent.h:405
const AliESDRun * GetESDRun() const
Definition: AliESDEvent.h:135
const AliESDfriendTrack * GetFriendTrack() const
Definition: AliESDtrack.h:59
AliESDVZERO * GetVZEROData()
Definition: AliESD.h:242
virtual ~AliESDVertex()
Definition: AliESDVertex.h:52
Int_t GetLabel() const
Bool_t RemoveV0(Int_t i) const
virtual ~AliESDfriend()
AliESDMuonPad * NewMuonPad()
TClonesArray * fV0s
TRD tracklets (for trigger)
Definition: AliESDEvent.h:648
void GetESDfriend(AliESDfriend *f)
void SetVZEROData(const AliESDVZERO *obj)
TClonesArray * fMuonTracks
ESD tracks.
Definition: AliESDEvent.h:641
void SetStdNames()
void AddTrdTrack(const AliESDTrdTrack *t)
void AddTrdTracklet(const AliESDTrdTracklet *trkl)
UInt_t GetPeriodNumber() const
Definition: AliESD.h:167
AliESDMuonCluster * GetMuonCluster(Int_t i)
Int_t GetEventNumberInFile() const
Definition: AliESDEvent.h:224
Int_t GetNumberOfCaloClusters() const
Definition: AliESDEvent.h:559
virtual Bool_t GetStatus() const
Definition: AliVertex.h:44
#define AliError(message)
Definition: AliLog.h:591
void SetKinkIndexes(Int_t points[3])
Definition: AliESDtrack.h:237
void SetClusterTrackNo(Int_t trno)
UChar_t GetTriggerCluster() const
Definition: AliESD.h:173
virtual Bool_t IsPileupFromSPD(Int_t minContributors=5, Double_t minZdist=0.8, Double_t nSigmaZdist=3., Double_t nSigmaDiamXY=2., Double_t nSigmaDiamZ=5.) const
void SetOrbitNumber(UInt_t n)
Definition: AliESDEvent.h:198
AliESDfriendTrack * GetTrack(Int_t i) const
Definition: AliESDfriend.h:42
virtual Bool_t UsesTrack(Int_t index) const
Definition: AliVertex.cxx:151
Int_t GetTPCLabel() const
Definition: AliESDtrack.h:269
Bool_t fTracksConnected
Do not use the list from the esdTree but use the one created by this class.
Definition: AliESDEvent.h:666
TClonesArray * fCosmicTracks
PHOS cell info.
Definition: AliESDEvent.h:654
AliESDVertex * fTPCVertex
FITObject.
Definition: AliESDEvent.h:628
Bool_t PropagateTo(Double_t p[3], Double_t covyz[3], Double_t covxyz[3], Double_t b)
Class for calorimeter cell ESD data handling.
Int_t GetESDLowerTrackIndex() const
Int_t GetNumberOfPmdTracks() const
Definition: AliESDEvent.h:549
AliESDZDC * fESDZDC
ESD Event Header.
Definition: AliESDEvent.h:623
Bool_t GetESDIndicesStored() const
Definition: AliESDfriend.h:86
Double_t GetDiamondZ() const
Definition: AliESDEvent.h:152
UInt_t GetTimeStampCTP() const
TString GetHLTTriggerDescription() const
TClonesArray * fTracks
Pileup primary vertices reconstructed using the tracks.
Definition: AliESDEvent.h:640
void SetFriendTrackPointer(AliESDfriendTrack *t)
Definition: AliESDtrack.h:64
void SetEventNumberInFile(Int_t n)
Definition: AliESDEvent.h:202
AliESDACORDE * fESDACORDE
PHOS Trigger information.
Definition: AliESDEvent.h:634
Bool_t RemoveKink(Int_t i) const
Int_t GetNumberOfKinks() const
Definition: AliESDEvent.h:554
TClonesArray * fErrorLogs
TOF matching info (with the reference to tracks)
Definition: AliESDEvent.h:658
#define AliErrorF(message,...)
Definition: AliLog.h:606
virtual ~AliESDACORDE()
Definition: AliESDACORDE.h:17
Double_t GetXRes() const
Definition: AliESDVertex.h:61
virtual Bool_t IsPileupFromSPDInMultBins() const
void GetCovarianceMatrix(Double_t covmatrix[6]) const
Definition: AliESDVertex.h:56
TClonesArray * fESDTOFMatches
TOF hits (used for clusters)
Definition: AliESDEvent.h:657
Int_t GetNumberOfCascades() const
Definition: AliESD.h:182
Definition: AliESD.h:40
virtual ~AliESDEvent()
virtual AliVEvent::EDataLayoutType GetDataLayoutType() const
TClonesArray * fPmdTracks
MUON+MFT ESD tracks // AU.
Definition: AliESDEvent.h:645
Bool_t Clean(TObjArray *track2destroy, const AliGRPRecoParam *grpRecoParam)
AliESDAD * fESDAD
ACORDE ESD object caontaining bit pattern.
Definition: AliESDEvent.h:635
Bool_t IsEventSelected(const char *trigExpr) const
void SetTriggerMask(ULong64_t n)
Definition: AliESDEvent.h:196
AliESDCaloCells * fEMCALCells
Calorimeter clusters for PHOS/EMCAL.
Definition: AliESDEvent.h:652
void SetIndex(Int_t i)
Definition: AliESDcascade.h:86
void SetEventType(UInt_t eventType)
Definition: AliESDEvent.h:200
void SetTriggerCluster(UChar_t n)
Definition: AliESDEvent.h:205
AliESDRun * fESDRun
Definition: AliESDEvent.h:621
Double_t GetVertexerV0EtaMax() const
const AliExternalTrackParam * GetParamN() const
Definition: AliESDv0.h:95
Bool_t GetXYZAt(Double_t x, Double_t b, Double_t r[3]) const
void SetFITData(const AliESDFIT *obj)
Bool_t GetFriendNotStored() const
Definition: AliESDtrack.h:544
Int_t GetNumberOfTPCTracks() const
void CopyFromOldESD()
Float_t GetMagneticField() const
Definition: AliESD.h:60
virtual ~AliTOFHeader()
void SetACORDEData(AliESDACORDE *obj)
void MoveClustersToESD(AliESDEvent &esd)
virtual Int_t GetNumberOfTracklets() const
Int_t AddTrack(const AliESDtrack *t)
UShort_t GetBunchCrossNumber() const
Definition: AliESDEvent.h:225
ULong64_t fDetectorStatus
number of TPC friend tracks to store
Definition: AliESDEvent.h:676
Int_t GetPHOSClusters(TRefArray *clusters) const