]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
New method to get the correponding matched track, it hides if the ESD or AOD was...
authorgconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 30 Jan 2012 15:03:37 +0000 (15:03 +0000)
committergconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 30 Jan 2012 15:03:37 +0000 (15:03 +0000)
PWG/CaloTrackCorrBase/AliCalorimeterUtils.cxx
PWG/CaloTrackCorrBase/AliCalorimeterUtils.h

index c24124ca5fa6a9184576e3fc3232347bb79e165c..92280326dc782a86e26e038857b2e39e01ec445b 100755 (executable)
@@ -12,7 +12,6 @@
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-/* $Id:  $ */
 
 //_________________________________________________________________________
 // Class utility for Calorimeter specific selection methods                ///
@@ -333,6 +332,60 @@ Int_t  AliCalorimeterUtils::GetMaxEnergyCell(AliVCaloCells* cells, const AliVClu
   
 }
 
+//__________________________________________________________________________
+AliVTrack * AliCalorimeterUtils::GetMatchedTrack(const AliVCluster* cluster, 
+                                                 const AliVEvent* event, 
+                                                 const Int_t index) const
+{
+  // Get the matched track given its index, usually just the first match
+  // Since it is different for ESDs and AODs here it is a wrap method to do it
+  
+  AliVTrack *track = 0;
+  
+  // EMCAL case only when matching is recalculated
+  if(cluster->IsEMCAL() && IsRecalculationOfClusterTrackMatchingOn())
+  {
+    Int_t trackIndex = fEMCALRecoUtils->GetMatchedTrackIndex(cluster->GetID());
+    //printf("track index %d, cluster ID %d \n ",trackIndex,cluster->GetID());
+    
+    if(trackIndex < 0 )
+    { 
+      printf("AliCalorimeterUtils::GetMatchedTrack() - Wrong track index %d, from recalculation\n", trackIndex);
+    }
+    else 
+    {
+      track = dynamic_cast<AliVTrack*> (event->GetTrack(trackIndex));
+    }
+
+    return track ;
+    
+  }   
+  
+  // Normal case, get info from ESD or AOD
+  // ESDs
+  if(!strcmp("AliESDCaloCluster",Form("%s",cluster->ClassName())))
+  {
+    Int_t iESDtrack = cluster->GetTrackMatchedIndex();
+    
+    if(iESDtrack < 0 )
+    { 
+      printf("AliCalorimeterUtils::GetMatchedTrack() - Wrong track index %d\n", index);
+      return 0x0;
+    }
+    
+    track = dynamic_cast<AliVTrack*> (event->GetTrack(iESDtrack));
+    
+  }
+  else // AODs
+  {
+    if(cluster->GetNTracksMatched() > 0 )
+      track = dynamic_cast<AliVTrack*>(cluster->GetTrackMatched(index));
+  }
+  
+  return track ;
+  
+}
+
 //_____________________________________________________________________________________________________
 Int_t AliCalorimeterUtils::GetModuleNumber(AliAODPWG4Particle * particle, AliVEvent * inputEvent) const
 {
index 4640aaa9093f1fbc71a71f4938887c3cb81908de..f65ee8958a3bd0188fbeffe6ddb017a39f4f5f05 100755 (executable)
@@ -2,7 +2,6 @@
 #define ALICALORIMETERUTILS_H
 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice     */
-/* $Id:  $ */
 
 //_________________________________________________________________________
 // Class utility for Calorimeter specific selection methods                ///
@@ -22,6 +21,7 @@ class TArrayF;
 
 //--- ANALYSIS system ---
 class AliVEvent;
+class AliVTrack;
 class AliAODPWG4Particle;
 class AliVCluster;
 class AliVCaloCells;
@@ -189,7 +189,11 @@ class AliCalorimeterUtils : public TObject {
   
   void          RecalculateClusterPID(AliVCluster* clu)    { fEMCALRecoUtils->RecalculateClusterPID(clu)              ; }
 
-  //Track matching recalculation
+  // *** Track Matching ***
+  
+  AliVTrack *   GetMatchedTrack(const AliVCluster * cluster, const AliVEvent * event, const Int_t index = 0) const ;
+  
+  // Recalculation
   void          RecalculateClusterTrackMatching(AliVEvent * event, TObjArray* clusterArray = 0x0) ;
     
   void          GetMatchedResiduals(Int_t index, Float_t &dR, Float_t &dZ) {
@@ -248,7 +252,7 @@ class AliCalorimeterUtils : public TObject {
   AliCalorimeterUtils(const AliCalorimeterUtils & g) ; // cpy ctor
   AliCalorimeterUtils & operator = (const AliCalorimeterUtils & g) ;//cpy assignment
   
-  ClassDef(AliCalorimeterUtils,7)
+  ClassDef(AliCalorimeterUtils,8)
 } ;