]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/ESD/AliESDEvent.cxx
Merge branch 'master' of http://git.cern.ch/pub/AliRoot
[u/mrichter/AliRoot.git] / STEER / ESD / AliESDEvent.cxx
index 5f72ac612ac4e9237ee44cfc5c54650d38166d39..3bb69e763cb014339fe7dadbe0ab0db60c091ddb 100644 (file)
@@ -46,6 +46,7 @@
 #include "AliESDMuonTrack.h"
 #include "AliESDMuonCluster.h"
 #include "AliESDMuonPad.h"
+#include "AliESDMuonGlobalTrack.h"       // AU
 #include "AliESDPmdTrack.h"
 #include "AliESDTrdTrack.h"
 #include "AliESDVertex.h"
 #include "AliTriggerCluster.h"
 #include "AliEventplane.h"
 
-
 ClassImp(AliESDEvent)
 
-
-
 // here we define the names, some classes are no TNamed, therefore the classnames 
 // are the Names
   const char* AliESDEvent::fgkESDListName[kESDListN] = {"AliESDRun",
@@ -103,6 +101,7 @@ ClassImp(AliESDEvent)
                                                        "MuonTracks",
                                                        "MuonClusters",
                                                        "MuonPads",
+                                                       "MuonGlobalTracks",      // AU
                                                        "PmdTracks",
                                                        "AliESDTrdTrigger",
                                                        "TrdTracks",
@@ -117,7 +116,11 @@ ClassImp(AliESDEvent)
                                                        "AliESDACORDE",
                                                        "AliESDAD",
                                                        "AliTOFHeader",
-                                                        "CosmicTracks"};
+                                                        "CosmicTracks",
+                                                       "AliESDTOFCluster",
+                                                       "AliESDTOFHit",
+                                                       "AliESDTOFMatch"};
+
 
 //______________________________________________________________________________
 AliESDEvent::AliESDEvent():
@@ -144,6 +147,7 @@ AliESDEvent::AliESDEvent():
   fMuonTracks(0),
   fMuonClusters(0),
   fMuonPads(0),
+  fMuonGlobalTracks(0),    // AU
   fPmdTracks(0),
   fTrdTracks(0),
   fTrdTracklets(0),
@@ -153,20 +157,22 @@ AliESDEvent::AliESDEvent():
   fCaloClusters(0),
   fEMCALCells(0), fPHOSCells(0),
   fCosmicTracks(0),
+  fESDTOFClusters(0),
+  fESDTOFHits(0),
+  fESDTOFMatches(0),
   fErrorLogs(0),
   fOldMuonStructure(kFALSE),
   fESDOld(0),
   fESDFriendOld(0),
   fConnected(kFALSE),
   fUseOwnList(kFALSE),
+  fTracksConnected(kFALSE),
   fTOFHeader(0),
   fCentrality(0),
   fEventplane(0),
   fDetectorStatus(0xFFFFFFFF),
   fDAQDetectorPattern(0xFFFF),
-  fDAQAttributes(0xFFFF),
-  fNTOFclusters(0),
-  fTOFcluster(0)
+  fDAQAttributes(0xFFFF)
 {
 }
 //______________________________________________________________________________
@@ -194,6 +200,7 @@ AliESDEvent::AliESDEvent(const AliESDEvent& esd):
   fMuonTracks(new TClonesArray(*esd.fMuonTracks)),
   fMuonClusters(new TClonesArray(*esd.fMuonClusters)),
   fMuonPads(new TClonesArray(*esd.fMuonPads)),
+  fMuonGlobalTracks(new TClonesArray(*esd.fMuonGlobalTracks)),     // AU
   fPmdTracks(new TClonesArray(*esd.fPmdTracks)),
   fTrdTracks(new TClonesArray(*esd.fTrdTracks)),
   fTrdTracklets(new TClonesArray(*esd.fTrdTracklets)),
@@ -204,21 +211,22 @@ AliESDEvent::AliESDEvent(const AliESDEvent& esd):
   fEMCALCells(new AliESDCaloCells(*esd.fEMCALCells)),
   fPHOSCells(new AliESDCaloCells(*esd.fPHOSCells)),
   fCosmicTracks(new TClonesArray(*esd.fCosmicTracks)),
+  fESDTOFClusters(esd.fESDTOFClusters ? new TClonesArray(*esd.fESDTOFClusters) : 0),
+  fESDTOFHits(esd.fESDTOFHits ? new TClonesArray(*esd.fESDTOFHits) : 0),
+  fESDTOFMatches(esd.fESDTOFMatches ? new TClonesArray(*esd.fESDTOFMatches) : 0),
   fErrorLogs(new TClonesArray(*esd.fErrorLogs)),
   fOldMuonStructure(esd.fOldMuonStructure),
   fESDOld(esd.fESDOld ? new AliESD(*esd.fESDOld) : 0),
   fESDFriendOld(esd.fESDFriendOld ? new AliESDfriend(*esd.fESDFriendOld) : 0),
   fConnected(esd.fConnected),
   fUseOwnList(esd.fUseOwnList),
+  fTracksConnected(kFALSE),
   fTOFHeader(new AliTOFHeader(*esd.fTOFHeader)),
   fCentrality(new AliCentrality(*esd.fCentrality)),
   fEventplane(new AliEventplane(*esd.fEventplane)),
   fDetectorStatus(esd.fDetectorStatus),
   fDAQDetectorPattern(esd.fDAQDetectorPattern),
-  fDAQAttributes(esd.fDAQAttributes),
-  fNTOFclusters(esd.fNTOFclusters),
-  //  fTOFcluster(esd.fTOFcluster)
-  fTOFcluster(new TObjArray(*(esd.fTOFcluster)))
+  fDAQAttributes(esd.fDAQAttributes)
 {
   printf("copying ESD event...\n");   // AU
   // CKB init in the constructor list and only add here ...
@@ -239,6 +247,7 @@ AliESDEvent::AliESDEvent(const AliESDEvent& esd):
   AddObject(fTrkPileupVertices);
   AddObject(fTracks);
   AddObject(fMuonTracks);
+  AddObject(fMuonGlobalTracks);    // AU
   AddObject(fPmdTracks);
   AddObject(fTrdTracks);
   AddObject(fTrdTracklets);
@@ -249,6 +258,9 @@ AliESDEvent::AliESDEvent(const AliESDEvent& esd):
   AddObject(fEMCALCells);
   AddObject(fPHOSCells);
   AddObject(fCosmicTracks);
+  AddObject(fESDTOFClusters);
+  AddObject(fESDTOFHits);
+  AddObject(fESDTOFMatches);
   AddObject(fErrorLogs);
   AddObject(fESDACORDE);
   AddObject(fESDAD);
@@ -256,6 +268,8 @@ AliESDEvent::AliESDEvent(const AliESDEvent& esd):
   AddObject(fMuonClusters);
   AddObject(fMuonPads);
   GetStdContent();
+  ConnectTracks();
+
 }
 
 //______________________________________________________________________________
@@ -352,15 +366,13 @@ AliESDEvent & AliESDEvent::operator=(const AliESDEvent& source) {
 
   fConnected  = source.fConnected;
   fUseOwnList = source.fUseOwnList;
-  
+
   fDetectorStatus = source.fDetectorStatus;
   fDAQDetectorPattern = source.fDAQDetectorPattern;
   fDAQAttributes = source.fDAQAttributes;
-  fNTOFclusters = source.fNTOFclusters;
-
-  *fTOFcluster = *source.fTOFcluster;
-  //  fTOFcluster = new TObjArray(*(source.fTOFcluster));
 
+  fTracksConnected = kFALSE;
+  ConnectTracks();
   return *this;
 }
 
@@ -384,10 +396,6 @@ AliESDEvent::~AliESDEvent()
   if (fEventplane) delete fEventplane;
   
 
-  if(fTOFcluster){
-    fTOFcluster->Clear();
-    delete fTOFcluster;
-  }
 }
 
 void AliESDEvent::Copy(TObject &obj) const {
@@ -452,6 +460,7 @@ void AliESDEvent::Reset()
 
 }
 
+//______________________________________________________________________________
 Bool_t AliESDEvent::ResetWithPlacementNew(TObject *pObject){
   //
   // funtion to reset using the already allocated space
@@ -467,6 +476,7 @@ Bool_t AliESDEvent::ResetWithPlacementNew(TObject *pObject){
   return kTRUE;
 }
 
+//______________________________________________________________________________
 void AliESDEvent::ResetStdContent()
 {
   // Reset the standard contents
@@ -529,10 +539,12 @@ void AliESDEvent::ResetStdContent()
   if(fEMCALTrigger)fEMCALTrigger->DeAllocate(); 
   if(fSPDPileupVertices)fSPDPileupVertices->Delete();
   if(fTrkPileupVertices)fTrkPileupVertices->Delete();
+  fTracksConnected = kFALSE;
   if(fTracks)fTracks->Delete();
   if(fMuonTracks)fMuonTracks->Clear("C");
   if(fMuonClusters)fMuonClusters->Clear("C");
   if(fMuonPads)fMuonPads->Clear("C");
+  if(fMuonGlobalTracks)fMuonGlobalTracks->Clear("C");     // AU
   if(fPmdTracks)fPmdTracks->Delete();
   if(fTrdTracks)fTrdTracks->Delete();
   if(fTrdTracklets)fTrdTracklets->Delete();
@@ -543,6 +555,9 @@ void AliESDEvent::ResetStdContent()
   if(fPHOSCells)fPHOSCells->DeleteContainer();
   if(fEMCALCells)fEMCALCells->DeleteContainer();
   if(fCosmicTracks)fCosmicTracks->Delete();
+  if(fESDTOFClusters)fESDTOFClusters->Clear();
+  if(fESDTOFHits)fESDTOFHits->Clear();
+  if(fESDTOFMatches)fESDTOFMatches->Clear();
   if(fErrorLogs) fErrorLogs->Delete();
 
   // don't reset fconnected fConnected and the list
@@ -550,6 +565,7 @@ void AliESDEvent::ResetStdContent()
 }
 
 
+//______________________________________________________________________________
 Int_t AliESDEvent::AddV0(const AliESDv0 *v) {
   //
   // Add V0
@@ -565,16 +581,24 @@ Bool_t AliESDEvent::IsDetectorInTriggerCluster(TString detector, AliTriggerConfi
   // Check if a given detector was read-out in the analyzed event
   const TObjArray& classesArray=trigConf->GetClasses();
   ULong64_t trigMask=GetTriggerMask();
+  ULong64_t trigMaskNext50=GetTriggerMaskNext50();
   Int_t nclasses = classesArray.GetEntriesFast();
   for(Int_t iclass=0; iclass < nclasses; iclass++ ) {
     AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At(iclass);
-    Int_t classMask=trclass->GetMask();
+    ULong64_t classMask=trclass->GetMask();
+    ULong64_t classMaskNext50=trclass->GetMaskNext50();
     if(trigMask & classMask){
       TString detList=trclass->GetCluster()->GetDetectorsInCluster();
       if(detList.Contains(detector.Data())){
        return kTRUE;
       }
     }
+    if(trigMaskNext50 & classMaskNext50){
+      TString detList=trclass->GetCluster()->GetDetectorsInCluster();
+      if(detList.Contains(detector.Data())){
+       return kTRUE;
+      }
+    }
   }
   return kFALSE; 
 }
@@ -585,19 +609,20 @@ void AliESDEvent::Print(Option_t *) const
   // Print header information of the event
   //
   printf("ESD run information\n");
-  printf("Event # in file %d Bunch crossing # %d Orbit # %d Period # %d Run # %d Trigger %lld Magnetic field %f \n",
+  printf("Event # in file %d Bunch crossing # %d Orbit # %d Period # %d Run # %d Trigger %lld %lld Magnetic field %f \n",
         GetEventNumberInFile(),
         GetBunchCrossNumber(),
         GetOrbitNumber(),
         GetPeriodNumber(),
         GetRunNumber(),
         GetTriggerMask(),
+        GetTriggerMaskNext50(),
         GetMagneticField() );
   if (fPrimaryVertex)
     printf("Vertex: (%.4f +- %.4f, %.4f +- %.4f, %.4f +- %.4f) cm\n",
-          fPrimaryVertex->GetXv(), fPrimaryVertex->GetXRes(),
-          fPrimaryVertex->GetYv(), fPrimaryVertex->GetYRes(),
-          fPrimaryVertex->GetZv(), fPrimaryVertex->GetZRes());
+          fPrimaryVertex->GetX(), fPrimaryVertex->GetXRes(),
+          fPrimaryVertex->GetY(), fPrimaryVertex->GetYRes(),
+          fPrimaryVertex->GetZ(), fPrimaryVertex->GetZRes());
   printf("Mean vertex in RUN: X=%.4f Y=%.4f Z=%.4f cm\n",
         GetDiamondX(),GetDiamondY(),GetDiamondZ());
   if(fSPDMult)
@@ -610,6 +635,7 @@ void AliESDEvent::Print(Option_t *) const
   printf("Number of tracks: \n");
   printf("                 charged   %d\n", GetNumberOfTracks());
   printf("                 muon      %d\n", GetNumberOfMuonTracks());
+  printf("                 glob muon %d\n", GetNumberOfMuonGlobalTracks());    // AU
   printf("                 pmd       %d\n", GetNumberOfPmdTracks());
   printf("                 trd       %d\n", GetNumberOfTrdTracks());
   printf("                 trd trkl  %d\n", GetNumberOfTrdTracklets());
@@ -634,10 +660,12 @@ void AliESDEvent::Print(Option_t *) const
   return;
 }
 
-void AliESDEvent::SetESDfriend(const AliESDfriend *ev) const {
-  //
-  // Attaches the complementary info to the ESD
-  //
+//______________________________________________________________________________
+void AliESDEvent::SetESDfriend(const AliESDfriend *ev) const 
+{
+//
+// Attaches the complementary info to the ESD
+//
   if (!ev) return;
 
   // to be sure that we set the tracks also
@@ -653,23 +681,27 @@ void AliESDEvent::SetESDfriend(const AliESDfriend *ev) const {
   }
 }
 
-Bool_t  AliESDEvent::RemoveKink(Int_t rm) const {
-  // ---------------------------------------------------------
-  // Remove a kink candidate and references to it from ESD,
-  // if this candidate does not come from a reconstructed decay
-  // Not yet implemented...
-  // ---------------------------------------------------------
+//______________________________________________________________________________
+Bool_t  AliESDEvent::RemoveKink(Int_t rm) const 
+{
+// ---------------------------------------------------------
+// Remove a kink candidate and references to it from ESD,
+// if this candidate does not come from a reconstructed decay
+// Not yet implemented...
+// ---------------------------------------------------------
   Int_t last=GetNumberOfKinks()-1;
   if ((rm<0)||(rm>last)) return kFALSE;
 
   return kTRUE;
 }
 
-Bool_t  AliESDEvent::RemoveV0(Int_t rm) const {
-  // ---------------------------------------------------------
-  // Remove a V0 candidate and references to it from ESD,
-  // if this candidate does not come from a reconstructed decay
-  // ---------------------------------------------------------
+//______________________________________________________________________________
+Bool_t  AliESDEvent::RemoveV0(Int_t rm) const 
+{
+// ---------------------------------------------------------
+// Remove a V0 candidate and references to it from ESD,
+// if this candidate does not come from a reconstructed decay
+// ---------------------------------------------------------
   Int_t last=GetNumberOfV0s()-1;
   if ((rm<0)||(rm>last)) return kFALSE;
 
@@ -729,11 +761,13 @@ Bool_t  AliESDEvent::RemoveV0(Int_t rm) const {
   return kTRUE;
 }
 
-Bool_t  AliESDEvent::RemoveTrack(Int_t rm) const {
-  // ---------------------------------------------------------
-  // Remove a track and references to it from ESD,
-  // if this track does not come from a reconstructed decay
-  // ---------------------------------------------------------
+//______________________________________________________________________________
+Bool_t  AliESDEvent::RemoveTrack(Int_t rm) const 
+{
+// ---------------------------------------------------------
+// Remove a track and references to it from ESD,
+// if this track does not come from a reconstructed decay
+// ---------------------------------------------------------
   Int_t last=GetNumberOfTracks()-1;
   if ((rm<0)||(rm>last)) return kFALSE;
 
@@ -817,12 +851,14 @@ Bool_t  AliESDEvent::RemoveTrack(Int_t rm) const {
     }
   }
 
-
-
+  // from here on we remove the track
+  //
   //Replace the removed track with the last track 
   TClonesArray &a=*fTracks;
+  AliESDtrack* trm = GetTrack(rm);
+  trm->SuppressTOFMatches(); // remove reference to this track from stored TOF clusters
   delete a.RemoveAt(rm);
-
+  //
   if (rm==last) return kTRUE;
 
   AliESDtrack *t=GetTrack(last);
@@ -831,7 +867,6 @@ Bool_t  AliESDEvent::RemoveTrack(Int_t rm) const {
   new (a[rm]) AliESDtrack(*t);
   delete a.RemoveAt(last);
 
-
   if (!used) return kTRUE;
   
 
@@ -928,8 +963,9 @@ Bool_t  AliESDEvent::RemoveTrack(Int_t rm) const {
   return kTRUE;
 }
 
-
-Bool_t AliESDEvent::Clean(Float_t *cleanPars) {
+//______________________________________________________________________________
+Bool_t AliESDEvent::Clean(Float_t *cleanPars) 
+{
   //
   // Remove the data which are not needed for the physics analysis.
   //
@@ -993,6 +1029,7 @@ Bool_t AliESDEvent::Clean(Float_t *cleanPars) {
   return rc;
 }
 
+//______________________________________________________________________________
 Char_t  AliESDEvent::AddPileupVertexSPD(const AliESDVertex *vtx) 
 {
     // Add a pileup primary vertex reconstructed with SPD
@@ -1003,6 +1040,7 @@ Char_t  AliESDEvent::AddPileupVertexSPD(const AliESDVertex *vtx)
     return n;
 }
 
+//______________________________________________________________________________
 Char_t  AliESDEvent::AddPileupVertexTracks(const AliESDVertex *vtx) 
 {
     // Add a pileup primary vertex reconstructed with SPD
@@ -1013,21 +1051,25 @@ Char_t  AliESDEvent::AddPileupVertexTracks(const AliESDVertex *vtx)
     return n;
 }
 
+//______________________________________________________________________________
 Int_t  AliESDEvent::AddTrack(const AliESDtrack *t) 
 {
     // Add track
     TClonesArray &ftr = *fTracks;
     AliESDtrack * track = new(ftr[fTracks->GetEntriesFast()])AliESDtrack(*t);
     track->SetID(fTracks->GetEntriesFast()-1);
+    track->SetESDEvent(this);
     return  track->GetID();    
 }
 
+//______________________________________________________________________________
 AliESDtrack*  AliESDEvent::NewTrack() 
 {
     // Add a new track
     TClonesArray &ftr = *fTracks;
     AliESDtrack * track = new(ftr[fTracks->GetEntriesFast()])AliESDtrack();
     track->SetID(fTracks->GetEntriesFast()-1);
+    track->SetESDEvent(this);
     return  track;
 }
 
@@ -1083,6 +1125,16 @@ AliESDMuonTrack* AliESDEvent::GetMuonTrack(Int_t i)
   return track;
 }
 
+//______________________________________________________________________________
+AliESDMuonGlobalTrack* AliESDEvent::GetMuonGlobalTrack(Int_t i)                      // AU
+{
+  // get the MUON+MFT track at the position i in the internal array of track
+  if (!fMuonGlobalTracks) return 0x0;
+  AliESDMuonGlobalTrack *track = (AliESDMuonGlobalTrack*) fMuonGlobalTracks->UncheckedAt(i);
+  track->SetESDEvent(this);
+  return track;
+}
+
 //______________________________________________________________________________
 void AliESDEvent::AddMuonTrack(const AliESDMuonTrack *t) 
 {
@@ -1093,6 +1145,15 @@ void AliESDEvent::AddMuonTrack(const AliESDMuonTrack *t)
 }
 
 //______________________________________________________________________________
+void AliESDEvent::AddMuonGlobalTrack(const AliESDMuonGlobalTrack *t)                             // AU
+{
+  // add a MUON+MFT track
+  TClonesArray &fmu = *fMuonGlobalTracks;
+  new (fmu[fMuonGlobalTracks->GetEntriesFast()]) AliESDMuonGlobalTrack(*t);
+}
+
+//______________________________________________________________________________
+
 AliESDMuonTrack* AliESDEvent::NewMuonTrack() 
 {
   // create a new MUON track at the end of the internal array of track
@@ -1100,6 +1161,14 @@ AliESDMuonTrack* AliESDEvent::NewMuonTrack()
   return new(fmu[fMuonTracks->GetEntriesFast()]) AliESDMuonTrack();
 }
 
+//______________________________________________________________________________
+AliESDMuonGlobalTrack* AliESDEvent::NewMuonGlobalTrack()                                         // AU
+{
+  // create a new MUON+MFT track at the end of the internal array of track
+  TClonesArray &fmu = *fMuonGlobalTracks;
+  return new(fmu[fMuonGlobalTracks->GetEntriesFast()]) AliESDMuonGlobalTrack();
+}
+
 //______________________________________________________________________________
 Int_t AliESDEvent::GetNumberOfMuonClusters()
 {
@@ -1178,49 +1247,57 @@ AliESDMuonPad* AliESDEvent::NewMuonPad()
   return new(fmu[fMuonPads->GetEntriesFast()]) AliESDMuonPad();
 }
 
+//______________________________________________________________________________
 void AliESDEvent::AddPmdTrack(const AliESDPmdTrack *t) 
 {
   TClonesArray &fpmd = *fPmdTracks;
   new(fpmd[fPmdTracks->GetEntriesFast()]) AliESDPmdTrack(*t);
 }
 
+//______________________________________________________________________________
 void AliESDEvent::SetTrdTrigger(const AliESDTrdTrigger *t)
 {
   *fTrdTrigger = *t;
 }
 
+//______________________________________________________________________________
 void AliESDEvent::AddTrdTrack(const AliESDTrdTrack *t) 
 {
   TClonesArray &ftrd = *fTrdTracks;
   new(ftrd[fTrdTracks->GetEntriesFast()]) AliESDTrdTrack(*t);
 }
 
+//______________________________________________________________________________
 void AliESDEvent::AddTrdTracklet(const AliESDTrdTracklet *trkl)
 {
   new ((*fTrdTracklets)[fTrdTracklets->GetEntriesFast()]) AliESDTrdTracklet(*trkl);
 }
 
+//______________________________________________________________________________
 void AliESDEvent::AddTrdTracklet(UInt_t trackletWord, Short_t hcid, Int_t label)
 {
   new ((*fTrdTracklets)[fTrdTracklets->GetEntriesFast()]) AliESDTrdTracklet(trackletWord, hcid, label);
 }
 
+//______________________________________________________________________________
 Int_t AliESDEvent::AddKink(const AliESDkink *c) 
 {
-    // Add kink
-    TClonesArray &fk = *fKinks;
-    AliESDkink * kink = new(fk[fKinks->GetEntriesFast()]) AliESDkink(*c);
-    kink->SetID(fKinks->GetEntriesFast()); // CKB different from the other imps..
-    return fKinks->GetEntriesFast()-1;
+  // Add kink
+  TClonesArray &fk = *fKinks;
+  AliESDkink * kink = new(fk[fKinks->GetEntriesFast()]) AliESDkink(*c);
+  kink->SetID(fKinks->GetEntriesFast()); // CKB different from the other imps..
+  return fKinks->GetEntriesFast()-1;
 }
 
 
+//______________________________________________________________________________
 void AliESDEvent::AddCascade(const AliESDcascade *c) 
 {
   TClonesArray &fc = *fCascades;
   new(fc[fCascades->GetEntriesFast()]) AliESDcascade(*c);
 }
 
+//______________________________________________________________________________
 void AliESDEvent::AddCosmicTrack(const AliESDCosmicTrack *t) 
 {
   TClonesArray &ft = *fCosmicTracks;
@@ -1228,21 +1305,24 @@ void AliESDEvent::AddCosmicTrack(const AliESDCosmicTrack *t)
 } 
 
 
+//______________________________________________________________________________
 Int_t AliESDEvent::AddCaloCluster(const AliESDCaloCluster *c) 
 {
-    // Add calocluster
-    TClonesArray &fc = *fCaloClusters;
-    AliESDCaloCluster *clus = new(fc[fCaloClusters->GetEntriesFast()]) AliESDCaloCluster(*c);
-    clus->SetID(fCaloClusters->GetEntriesFast()-1);
-    return fCaloClusters->GetEntriesFast()-1;
-  }
+  // Add calocluster
+  TClonesArray &fc = *fCaloClusters;
+  AliESDCaloCluster *clus = new(fc[fCaloClusters->GetEntriesFast()]) AliESDCaloCluster(*c);
+  clus->SetID(fCaloClusters->GetEntriesFast()-1);
+  return fCaloClusters->GetEntriesFast()-1;
+}
 
 
+//______________________________________________________________________________
 void  AliESDEvent::AddRawDataErrorLog(const AliRawDataErrorLog *log) const {
   TClonesArray &errlogs = *fErrorLogs;
   new(errlogs[errlogs.GetEntriesFast()])  AliRawDataErrorLog(*log);
 }
 
+//______________________________________________________________________________
 void AliESDEvent::SetZDCData(const AliESDZDC * obj)
 { 
   // use already allocated space
@@ -1250,6 +1330,7 @@ void AliESDEvent::SetZDCData(const AliESDZDC * obj)
     *fESDZDC = *obj;
 }
 
+//______________________________________________________________________________
 void  AliESDEvent::SetPrimaryVertexTPC(const AliESDVertex *vertex) 
 {
   // Set the TPC vertex
@@ -1260,6 +1341,7 @@ void  AliESDEvent::SetPrimaryVertexTPC(const AliESDVertex *vertex)
   }
 }
 
+//______________________________________________________________________________
 void  AliESDEvent::SetPrimaryVertexSPD(const AliESDVertex *vertex) 
 {
   // Set the SPD vertex
@@ -1270,6 +1352,7 @@ void  AliESDEvent::SetPrimaryVertexSPD(const AliESDVertex *vertex)
   }
 }
 
+//______________________________________________________________________________
 void  AliESDEvent::SetPrimaryVertexTracks(const AliESDVertex *vertex) 
 {
   // Set the primary vertex reconstructed using he ESD tracks.
@@ -1280,6 +1363,7 @@ void  AliESDEvent::SetPrimaryVertexTracks(const AliESDVertex *vertex)
   }
 }
 
+//______________________________________________________________________________
 const AliESDVertex * AliESDEvent::GetPrimaryVertex() const 
 {
   //
@@ -1297,6 +1381,7 @@ const AliESDVertex * AliESDEvent::GetPrimaryVertex() const
   return fSPDVertex;
 }
 
+//______________________________________________________________________________
 AliESDVertex * AliESDEvent::PrimaryVertexTracksUnconstrained() const 
 {
   //
@@ -1322,6 +1407,7 @@ AliESDVertex * AliESDEvent::PrimaryVertexTracksUnconstrained() const
   return vertex;
 }
 
+//______________________________________________________________________________
 void AliESDEvent::SetMultiplicity(const AliMultiplicity *mul) 
 {
   // Set the SPD Multiplicity
@@ -1331,6 +1417,7 @@ void AliESDEvent::SetMultiplicity(const AliMultiplicity *mul)
 }
 
 
+//______________________________________________________________________________
 void AliESDEvent::SetFMDData(AliESDFMD * obj) 
 { 
   // use already allocated space
@@ -1339,6 +1426,7 @@ void AliESDEvent::SetFMDData(AliESDFMD * obj)
   }
 }
 
+//______________________________________________________________________________
 void AliESDEvent::SetVZEROData(const AliESDVZERO * obj)
 { 
   // use already allocated space
@@ -1346,6 +1434,7 @@ void AliESDEvent::SetVZEROData(const AliESDVZERO * obj)
     *fESDVZERO = *obj;
 }
 
+//______________________________________________________________________________
 void AliESDEvent::SetTZEROData(const AliESDTZERO * obj)
 { 
   // use already allocated space
@@ -1354,20 +1443,21 @@ void AliESDEvent::SetTZEROData(const AliESDTZERO * obj)
 }
 
 
+//______________________________________________________________________________
 void AliESDEvent::SetACORDEData(AliESDACORDE * obj)
 {
   if(fESDACORDE)
     *fESDACORDE = *obj;
 }
 
+//______________________________________________________________________________
 void AliESDEvent::SetADData(AliESDAD * obj)
 {
   if(fESDAD)
     *fESDAD = *obj;
 }
 
-
-
+//______________________________________________________________________________
 void AliESDEvent::GetESDfriend(AliESDfriend *ev) const 
 {
   //
@@ -1387,10 +1477,11 @@ void AliESDEvent::GetESDfriend(AliESDfriend *ev) const
 
   }
 
-  AliESDfriend *fr = (AliESDfriend*)(const_cast<AliESDEvent*>(this)->FindListObject("AliESDfriend"));
+  AliESDfriend *fr = (AliESDfriend*)(const_cast<AliESDEvent*>(this)->FindFriend());
   if (fr) ev->SetVZEROfriend(fr->GetVZEROfriend());
 }
 
+//______________________________________________________________________________
 void AliESDEvent::AddObject(TObject* obj) 
 {
   // Add an object to the list of object.
@@ -1400,7 +1491,7 @@ void AliESDEvent::AddObject(TObject* obj)
   fESDObjects->AddLast(obj);
 }
 
-
+//______________________________________________________________________________
 void AliESDEvent::GetStdContent() 
 {
   // set pointers for standard content
@@ -1424,6 +1515,7 @@ void AliESDEvent::GetStdContent()
   fMuonTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kMuonTracks]);
   fMuonClusters = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kMuonClusters]);
   fMuonPads = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kMuonPads]);
+  fMuonGlobalTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kMuonGlobalTracks]);         // AU
   fPmdTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kPmdTracks]);
   fTrdTrigger = (AliESDTrdTrigger*)fESDObjects->FindObject(fgkESDListName[kTrdTrigger]);
   fTrdTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTrdTracks]);
@@ -1439,9 +1531,12 @@ void AliESDEvent::GetStdContent()
   fESDAD = (AliESDAD*)fESDObjects->FindObject(fgkESDListName[kESDAD]);
   fTOFHeader = (AliTOFHeader*)fESDObjects->FindObject(fgkESDListName[kTOFHeader]);
   fCosmicTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kCosmicTracks]);
-  fTOFcluster = new TObjArray(1);
+  fESDTOFClusters = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTOFclusters]);
+  fESDTOFHits = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTOFhit]);
+  fESDTOFMatches = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTOFmatch]);
 }
 
+//______________________________________________________________________________
 void AliESDEvent::SetStdNames(){
   // Set the names of the standard contents
   // 
@@ -1461,12 +1556,13 @@ void AliESDEvent::SetStdNames(){
   }
 } 
 
-
+//______________________________________________________________________________
 void AliESDEvent::CreateStdContent(Bool_t bUseThisList){
   fUseOwnList = bUseThisList;
   CreateStdContent();
 }
 
+//______________________________________________________________________________
 void AliESDEvent::CreateStdContent() 
 {
   // create the standard AOD content and set pointers
@@ -1490,6 +1586,7 @@ void AliESDEvent::CreateStdContent()
   AddObject(new TClonesArray("AliESDMuonTrack",0));
   AddObject(new TClonesArray("AliESDMuonCluster",0));
   AddObject(new TClonesArray("AliESDMuonPad",0));
+  AddObject(new TClonesArray("AliESDMuonGlobalTrack",0));   // AU
   AddObject(new TClonesArray("AliESDPmdTrack",0));
   AddObject(new AliESDTrdTrigger());
   AddObject(new TClonesArray("AliESDTrdTrack",0));
@@ -1505,6 +1602,9 @@ void AliESDEvent::CreateStdContent()
   AddObject(new AliESDAD()); 
   AddObject(new AliTOFHeader());
   AddObject(new TClonesArray("AliESDCosmicTrack",0));
+  AddObject(new TClonesArray("AliESDTOFCluster",0));
+  AddObject(new TClonesArray("AliESDTOFHit",0));
+  AddObject(new TClonesArray("AliESDTOFMatch",0));
        
   // check the order of the indices against enum...
 
@@ -1514,6 +1614,7 @@ void AliESDEvent::CreateStdContent()
   GetStdContent();
 }
 
+//______________________________________________________________________________
 void AliESDEvent::CompleteStdContent() 
 {
   // Create missing standard objects and add them to the TList of objects
@@ -1540,6 +1641,7 @@ void AliESDEvent::CompleteStdContent()
   }
 }
 
+//______________________________________________________________________________
 TObject* AliESDEvent::FindListObject(const char *name) const {
 //
 // Find object with name "name" in the list of branches
@@ -1550,6 +1652,7 @@ TObject* AliESDEvent::FindListObject(const char *name) const {
   return 0;
 } 
 
+//______________________________________________________________________________
 Int_t AliESDEvent::GetPHOSClusters(TRefArray *clusters) const
 {
   // fills the provided TRefArray with all found phos clusters
@@ -1569,6 +1672,7 @@ Int_t AliESDEvent::GetPHOSClusters(TRefArray *clusters) const
   return clusters->GetEntriesFast();
 }
 
+//______________________________________________________________________________
 Int_t AliESDEvent::GetEMCALClusters(TRefArray *clusters) const
 {
   // fills the provided TRefArray with all found emcal clusters
@@ -1588,6 +1692,7 @@ Int_t AliESDEvent::GetEMCALClusters(TRefArray *clusters) const
   return clusters->GetEntriesFast();
 }
 
+//______________________________________________________________________________
 void AliESDEvent::WriteToTree(TTree* tree) const {
   // Book the branches as in TTree::Branch(TCollection*)
   // but add a "." at the end of top level branches which are
@@ -1617,11 +1722,9 @@ void AliESDEvent::WriteToTree(TTree* tree) const {
   tree->Branch("fDetectorStatus",(void*)&fDetectorStatus,"fDetectorStatus/l");
   tree->Branch("fDAQDetectorPattern",(void*)&fDAQDetectorPattern,"fDAQDetectorPattern/i");
   tree->Branch("fDAQAttributes",(void*)&fDAQAttributes,"fDAQAttributes/i");
-  tree->Branch("fNTOFclusters",(void *) &fNTOFclusters,"fNTOFclusters/i");
-  tree->Branch("fTOFcluster","TObjArray",(void *) &fTOFcluster);
 }
 
-
+//______________________________________________________________________________
 void AliESDEvent::ReadFromTree(TTree *tree, Option_t* opt){
 //
 // Connect the ESDEvent to a tree
@@ -1721,8 +1824,6 @@ void AliESDEvent::ReadFromTree(TTree *tree, Option_t* opt){
       tree->SetBranchAddress("fDetectorStatus",&fDetectorStatus); //PH probably redundant
       tree->SetBranchAddress("fDAQDetectorPattern",&fDAQDetectorPattern);
       tree->SetBranchAddress("fDAQAttributes",&fDAQAttributes);
-      if(tree->GetBranch("fNTOFclusters")) tree->SetBranchAddress("fNTOFclusters",(UInt_t *) &fNTOFclusters);
-      if(tree->GetBranch("fTOFcluster")) tree->SetBranchAddress("fTOFcluster",&fTOFcluster);
       GetStdContent(); 
       fOldMuonStructure = fESDObjects->TestBit(BIT(23));
       fConnected = true;
@@ -1789,8 +1890,6 @@ void AliESDEvent::ReadFromTree(TTree *tree, Option_t* opt){
     tree->SetBranchAddress("fDetectorStatus",&fDetectorStatus);
     tree->SetBranchAddress("fDAQDetectorPattern",&fDAQDetectorPattern);
     tree->SetBranchAddress("fDAQAttributes",&fDAQAttributes);
-    if(tree->GetBranch("fNTOFclusters")) tree->SetBranchAddress("fNTOFclusters",(UInt_t *) &fNTOFclusters);
-    if(tree->GetBranch("fTOFcluster")) tree->SetBranchAddress("fTOFcluster",&fTOFcluster);
 
     GetStdContent();
     // when reading back we are not owner of the list 
@@ -1830,8 +1929,6 @@ void AliESDEvent::ReadFromTree(TTree *tree, Option_t* opt){
     tree->SetBranchAddress("fDetectorStatus",&fDetectorStatus);
     tree->SetBranchAddress("fDAQDetectorPattern",&fDAQDetectorPattern);
     tree->SetBranchAddress("fDAQAttributes",&fDAQAttributes);
-    if(tree->GetBranch("fNTOFclusters")) tree->SetBranchAddress("fNTOFclusters",(UInt_t *) &fNTOFclusters);
-    if(tree->GetBranch("fTOFcluster")) tree->SetBranchAddress("fTOFcluster",&fTOFcluster);
 
     GetStdContent();
     // when reading back we are not owner of the list 
@@ -1840,7 +1937,7 @@ void AliESDEvent::ReadFromTree(TTree *tree, Option_t* opt){
   }
 }
 
-
+//______________________________________________________________________________
 void AliESDEvent::CopyFromOldESD()
 {
   // Method which copies over everthing from the old esd structure to the 
@@ -1935,6 +2032,7 @@ void AliESDEvent::CopyFromOldESD()
   }// if fesdold
 }
 
+//______________________________________________________________________________
 Bool_t AliESDEvent::IsEventSelected(const char *trigExpr) const
 {
   // Check if the event satisfies the trigger
@@ -1942,12 +2040,13 @@ Bool_t AliESDEvent::IsEventSelected(const char *trigExpr) const
   // trigExpr can be any logical expression
   // of the trigger classes defined in AliESDRun
   // In case of wrong syntax return kTRUE.
+  // Modified by rl for 100 classes - to be tested
 
   TString expr(trigExpr);
   if (expr.IsNull()) return kTRUE;
 
   ULong64_t mask = GetTriggerMask();
-  for(Int_t itrig = 0; itrig < AliESDRun::kNTriggerClasses; itrig++) {
+  for(Int_t itrig = 0; itrig < AliESDRun::kNTriggerClasses/2; itrig++) {
     if (mask & (1ull << itrig)) {
       expr.ReplaceAll(GetESDRun()->GetTriggerClass(itrig),"1");
     }
@@ -1955,6 +2054,15 @@ Bool_t AliESDEvent::IsEventSelected(const char *trigExpr) const
       expr.ReplaceAll(GetESDRun()->GetTriggerClass(itrig),"0");
     }
   }
+  ULong64_t maskNext50 = GetTriggerMaskNext50();
+  for(Int_t itrig = 0; itrig < AliESDRun::kNTriggerClasses/2; itrig++) {
+    if (maskNext50 & (1ull << itrig)) {
+      expr.ReplaceAll(GetESDRun()->GetTriggerClass(itrig+50),"1");
+    }
+    else {
+      expr.ReplaceAll(GetESDRun()->GetTriggerClass(itrig+50),"0");
+    }
+  }
 
   Int_t error;
   if ((gROOT->ProcessLineFast(expr.Data(),&error) == 0) &&
@@ -1966,6 +2074,7 @@ Bool_t AliESDEvent::IsEventSelected(const char *trigExpr) const
 
 }
 
+//______________________________________________________________________________
 TObject*  AliESDEvent::GetHLTTriggerDecision() const
 {
   // get the HLT trigger decission object
@@ -1988,6 +2097,7 @@ TString   AliESDEvent::GetHLTTriggerDescription() const
   return description;
 }
 
+//______________________________________________________________________________
 Bool_t    AliESDEvent::IsHLTTriggerFired(const char* name) const
 {
   // get the HLT trigger decission description
@@ -2096,6 +2206,7 @@ void AliESDEvent::EstimateMultiplicity(Int_t &tracklets, Int_t &trITSTPC, Int_t
   //
 }
 
+//______________________________________________________________________________
 Bool_t AliESDEvent::IsPileupFromSPDInMultBins() const {
     Int_t nTracklets=GetMultiplicity()->GetNumberOfTracklets();
     if(nTracklets<20) return IsPileupFromSPD(3,0.8);
@@ -2103,6 +2214,7 @@ Bool_t AliESDEvent::IsPileupFromSPDInMultBins() const {
     else return IsPileupFromSPD(5,0.8);
 }
 
+//______________________________________________________________________________
 void  AliESDEvent::SetTOFHeader(const AliTOFHeader *header)
 {
   //
@@ -2122,18 +2234,21 @@ void  AliESDEvent::SetTOFHeader(const AliTOFHeader *header)
 
 }
 
+//______________________________________________________________________________
 AliCentrality* AliESDEvent::GetCentrality()
 {
     if (!fCentrality) fCentrality = new AliCentrality();
     return  fCentrality;
 }
 
+//______________________________________________________________________________
 AliEventplane* AliESDEvent::GetEventplane()
 {
     if (!fEventplane) fEventplane = new AliEventplane();
     return  fEventplane;
 }
 
+//______________________________________________________________________________
 Float_t AliESDEvent::GetVZEROEqMultiplicity(Int_t i) const
 {
   // Get VZERO Multiplicity for channel i
@@ -2152,45 +2267,193 @@ Float_t AliESDEvent::GetVZEROEqMultiplicity(Int_t i) const
   return (fESDVZERO->GetMultiplicity(i)/factor);
 }
 
-void AliESDEvent::SetTOFcluster(Int_t ntofclusters,AliESDTOFcluster *cluster,Int_t *mapping){
-  fNTOFclusters = 0;
+//______________________________________________________________________________
+void AliESDEvent::SetTOFcluster(Int_t ntofclusters,AliESDTOFCluster *cluster,Int_t *mapping)
+{
+  // Reset TClonesArray of TOF clusters
+  if (!fESDTOFClusters) {
+    AliError("fESDTOFClusters is not initialized");
+    return;
+  }
+  fESDTOFClusters->Clear();
+  
+  Int_t goodhit[20000];
+  if(mapping){
+    for(Int_t i=0;i < 20000;i++){
+      goodhit[i] = 0;
+    }
+  }
 
-  fTOFcluster->Clear();
-  fTOFcluster->Expand(1);      
-      
   for(Int_t i=0;i < ntofclusters;i++){
-
+    
     if(cluster[i].GetNMatchableTracks() || !mapping){
-      fTOFcluster->Expand(fNTOFclusters+1);      
-      fTOFcluster->AddAt(&cluster[i],fNTOFclusters);
       if(mapping)
-       mapping[i] = fNTOFclusters;
-      fNTOFclusters++;
+       mapping[i] = fESDTOFClusters->GetEntriesFast();
+      
+      // update TClonesArray
+      TClonesArray &ftr = *fESDTOFClusters;
+      AliESDTOFCluster *clusterTBW = new(ftr[fESDTOFClusters->GetEntriesFast()])AliESDTOFCluster(cluster[i]);
+
+      if(mapping){
+       // loop over hit in the cluster
+        for(Int_t k=0;k < clusterTBW->GetNTOFhits();k++){
+         Int_t ipos = clusterTBW->GetHitIndex(k);
+         goodhit[ipos] = 1; // hit should be kept
+       }
+      }
     }
   }
-  if(mapping)
-    printf("TOF cluster before of matching = %i , after = %i\n",ntofclusters,fNTOFclusters);
-   
+
+  if(mapping){
+    AliInfo(Form("TOF cluster before of matching = %i , after = %i\n",ntofclusters,fESDTOFClusters->GetEntriesFast()));
+    Int_t hitnewpos[20000]={0};
+    Int_t nhitOriginal = fESDTOFHits->GetEntries();
+    for(Int_t i=0;i < fESDTOFHits->GetEntries();i++){
+      if(goodhit[i]){
+       hitnewpos[i] = i;
+      }
+      else{ // remove hit and decrease the hit array
+       TClonesArray &a=*fESDTOFHits;
+       Int_t lastpos = fESDTOFHits->GetEntries()-1;
+
+       if(i == lastpos)
+         delete a.RemoveAt(i);
+       else{
+         Int_t nhitBefore = fESDTOFHits->GetEntries();
+         for(Int_t k=nhitBefore-1;k>i;k--){ // find the last good track
+           if(!goodhit[k]){ // remove track
+             delete a.RemoveAt(k);
+             if(k-i==1) delete a.RemoveAt(i);
+           }
+           else{ // replace last one to the "i"
+             AliESDTOFHit *last = (AliESDTOFHit *) fESDTOFHits->At(k);
+             delete a.RemoveAt(i);
+             new (a[i]) AliESDTOFHit(*last);
+             delete a.RemoveAt(k);
+             hitnewpos[k] = i;
+             k = 0;
+           }
+         }
+       }
+      }
+    }
+
+    // remap cluster to hits
+    for(Int_t i=0;i < fESDTOFClusters->GetEntries();i++){
+      AliESDTOFCluster *cl = (AliESDTOFCluster *) fESDTOFClusters->At(i);
+      // loop over hit in the cluster
+      for(Int_t k=0;k < cl->GetNTOFhits();k++){
+       cl->SetHitIndex(k,hitnewpos[cl->GetHitIndex(k)]);
+      }
+    }
+    AliInfo(Form("TOF hit before of matching = %i , after = %i\n",nhitOriginal,fESDTOFHits->GetEntriesFast()));
+  } // end mapping
 
 }
-void AliESDEvent::SetTOFcluster(Int_t ntofclusters,AliESDTOFcluster *cluster[],Int_t *mapping){
-  fNTOFclusters = 0;
 
-  fTOFcluster->Clear();
-  fTOFcluster->Expand(1);      
+//______________________________________________________________________________
+void AliESDEvent::SetTOFcluster(Int_t ntofclusters,AliESDTOFCluster *cluster[],Int_t *mapping)
+{    
+  // Reset TClonesArray of TOF clusters
+  if(fESDTOFClusters)fESDTOFClusters->Delete();
+   
+  Int_t goodhit[20000];
+  if(mapping){
+    for(Int_t i=0;i < 20000;i++){
+      goodhit[i] = 0;
+    }
+  }
       
   for(Int_t i=0;i < ntofclusters;i++){
 
     if(cluster[i]->GetNMatchableTracks() || !mapping){
-      fTOFcluster->Expand(fNTOFclusters+1);      
-      fTOFcluster->AddAt(cluster[i],fNTOFclusters);
       if(mapping)
-       mapping[i] = fNTOFclusters;
-      fNTOFclusters++;
+       mapping[i] = fESDTOFClusters->GetEntriesFast();
+       
+      // update TClonesArray
+      TClonesArray &ftr = *fESDTOFClusters;
+      AliESDTOFCluster *clusterTBW = new(ftr[fESDTOFClusters->GetEntriesFast()])AliESDTOFCluster(*(cluster[i]));
+
+      if(mapping){
+       // loop over hit in the cluster
+        for(Int_t k=0;k < clusterTBW->GetNTOFhits();k++){
+         Int_t ipos = clusterTBW->GetHitIndex(k);
+         goodhit[ipos] = 1; // hit should be kept
+       }
+      }
     }
   }
-  if(mapping)
-    printf("TOF cluster before of matching = %i , after = %i\n",ntofclusters,fNTOFclusters);
-   
 
+  if(mapping){
+    AliInfo(Form("TOF cluster before of matching = %i , after = %i\n",ntofclusters,fESDTOFClusters->GetEntriesFast()));
+    Int_t hitnewpos[20000]={0};
+    Int_t nhitOriginal = fESDTOFHits->GetEntries();
+    for(Int_t i=0;i < fESDTOFHits->GetEntries();i++){
+      if(goodhit[i]){
+       hitnewpos[i] = i;
+      }
+      else{ // remove hit and decrease the hit array
+       TClonesArray &a=*fESDTOFHits;
+       Int_t lastpos = fESDTOFHits->GetEntries()-1;
+
+       if(i == lastpos)
+         delete a.RemoveAt(i);
+       else{
+         Int_t nhitBefore = fESDTOFHits->GetEntries();
+         for(Int_t k=nhitBefore-1;k>i;k--){ // find the last good track
+           if(!goodhit[k]){ // remove track
+             delete a.RemoveAt(k);
+             if(k-i==1) delete a.RemoveAt(i);
+           }
+           else{ // replace last one to the "i"
+             AliESDTOFHit *last = (AliESDTOFHit *) fESDTOFHits->At(k);
+             delete a.RemoveAt(i);
+             new (a[i]) AliESDTOFHit(*last);
+             delete a.RemoveAt(k);
+             hitnewpos[k] = i;
+             k = 0;
+           }
+         }
+       }
+      }
+    }
+
+    // remap cluster to hits
+    for(Int_t i=0;i < fESDTOFClusters->GetEntries();i++){
+      AliESDTOFCluster *cl = (AliESDTOFCluster *) fESDTOFClusters->At(i);
+      // loop over hit in the cluster
+      for(Int_t k=0;k < cl->GetNTOFhits();k++){
+       cl->SetHitIndex(k,hitnewpos[cl->GetHitIndex(k)]);
+      }
+    }
+    AliInfo(Form("TOF hit before of matching = %i , after = %i\n",nhitOriginal,fESDTOFHits->GetEntriesFast()));
+  } // end mapping
+
+}
+
+//______________________________________________________________________________
+void AliESDEvent::ConnectTracks() {
+// Connect tracks to this event
+  if (fTracksConnected || !fTracks || !fTracks->GetEntriesFast()) return;
+  AliESDtrack *track;
+  TIter next(fTracks);
+  while ((track=(AliESDtrack*)next())) track->SetESDEvent(this);
+  //
+  // The same for TOF clusters
+  if (fESDTOFClusters) {
+    AliESDTOFCluster *clus;
+    TIter nextTOF(fESDTOFClusters);
+    while ((clus=(AliESDTOFCluster*)nextTOF())) clus->SetEvent((AliVEvent *) this);
+  }
+  fTracksConnected = kTRUE;
+  //
+}
+
+//______________________________________________________________________________
+AliESDfriend* AliESDEvent::FindFriend() const 
+{ 
+  return static_cast<AliESDfriend*>(FindListObject("AliESDfriend")); 
 }
+
+AliVEvent::EDataLayoutType AliESDEvent::GetDataLayoutType() const {return AliVEvent::kESD;}
+