PID functionality revised. Code clean-up.
authormarkus <markus@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 23 Mar 2007 16:37:18 +0000 (16:37 +0000)
committermarkus <markus@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 23 Mar 2007 16:37:18 +0000 (16:37 +0000)
STEER/AliAODCluster.cxx
STEER/AliAODCluster.h

index 68ca43b..fecf1cf 100644 (file)
@@ -48,7 +48,7 @@ AliAODCluster::AliAODCluster(Int_t id,
                             Double_t energy,
                             Double_t x[3],
                             Double_t covMatrix[10],
-                            Double_t pid[10],
+                            Double_t pid[9],
                             AliAODVertex *prodVertex,
                             AliAODTrack *primTrack,
                             Char_t ttype) :
@@ -76,7 +76,7 @@ AliAODCluster::AliAODCluster(Int_t id,
                             Float_t energy,
                             Float_t x[3],
                             Float_t covMatrix[10],
-                            Float_t pid[10],
+                            Float_t pid[9],
                             AliAODVertex *prodVertex,
                             AliAODTrack *primTrack,
                             Char_t ttype) :
@@ -108,49 +108,49 @@ AliAODCluster::~AliAODCluster()
 
 
 //______________________________________________________________________________
-AliAODCluster::AliAODCluster(const AliAODCluster& trk) :
-  AliVirtualParticle(trk),
-  fEnergy(trk.fEnergy),
-  fChi2(trk.fChi2),
-  fID(trk.fID),
-  fLabel(trk.fLabel),
+AliAODCluster::AliAODCluster(const AliAODCluster& clus) :
+  AliVirtualParticle(clus),
+  fEnergy(clus.fEnergy),
+  fChi2(clus.fChi2),
+  fID(clus.fID),
+  fLabel(clus.fLabel),
   fCovMatrix(NULL),
-  fProdVertex(trk.fProdVertex),
-  fPrimTrack(trk.fPrimTrack),
-  fType(trk.fType)
+  fProdVertex(clus.fProdVertex),
+  fPrimTrack(clus.fPrimTrack),
+  fType(clus.fType)
 {
   // Copy constructor
 
-  trk.GetPosition(fPosition);
-  if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<4>(*trk.fCovMatrix);
-  SetPID(trk.fPID);
+  clus.GetPosition(fPosition);
+  if(clus.fCovMatrix) fCovMatrix=new AliAODRedCov<4>(*clus.fCovMatrix);
+  SetPID(clus.fPID);
 
 }
 
 //______________________________________________________________________________
-AliAODCluster& AliAODCluster::operator=(const AliAODCluster& trk)
+AliAODCluster& AliAODCluster::operator=(const AliAODCluster& clus)
 {
   // Assignment operator
-  if(this!=&trk) {
+  if(this!=&clus) {
 
-    AliVirtualParticle::operator=(trk);
+    AliVirtualParticle::operator=(clus);
 
-    trk.GetPosition(fPosition);
-    trk.GetPID(fPID);
+    clus.GetPosition(fPosition);
+    clus.GetPID(fPID);
 
-    fChi2 = trk.fEnergy;
-    fChi2 = trk.fChi2;
+    fEnergy = clus.fEnergy;
+    fChi2 = clus.fChi2;
 
-    fID = trk.fID;
-    fLabel = trk.fLabel;    
+    fID = clus.fID;
+    fLabel = clus.fLabel;    
     
     delete fCovMatrix;
-    if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<4>(*trk.fCovMatrix);
+    if(clus.fCovMatrix) fCovMatrix=new AliAODRedCov<4>(*clus.fCovMatrix);
     else fCovMatrix=NULL;
-    fProdVertex = trk.fProdVertex;
-    fPrimTrack = trk.fPrimTrack;
+    fProdVertex = clus.fProdVertex;
+    fPrimTrack = clus.fPrimTrack;
 
-    fType = trk.fType;
+    fType = clus.fType;
   }
 
   return *this;
@@ -174,6 +174,35 @@ template <class T> void AliAODCluster::SetPosition(const T *x)
 }
 
 //______________________________________________________________________________
+AliAODCluster::AODCluPID_t AliAODCluster::GetMostProbablePID() const 
+{
+  // Returns the most probable PID array element.
+  
+  Int_t nPID = 9;
+  if (fPID) {
+    AODCluPID_t loc = kUnknown;
+    Double_t max = 0.;
+    Bool_t allTheSame = kTRUE;
+    
+    for (Int_t iPID = 0; iPID < nPID; iPID++) {
+      if (fPID[iPID] >= max) {
+       if (fPID[iPID] > max) {
+         allTheSame = kFALSE;
+         max = fPID[iPID];
+         loc = (AODCluPID_t)iPID;
+       } else {
+         allTheSame = kTRUE;
+       }
+      }
+    }
+    
+    return allTheSame ? kUnknown : loc;
+  } else {
+    return kUnknown;
+  }
+}
+
+//______________________________________________________________________________
 void AliAODCluster::Print(Option_t* /* option */) const
 {
   // prints information about AliAODCluster
index 857a8fb..0df3a75 100644 (file)
@@ -20,12 +20,24 @@ class AliAODCluster : public AliVirtualParticle {
 
  public:
   
-  enum AODClu_t {kUndef=-1, kPHOSNeutral,kPHOSCharged,
-                kEMCALPseudoCluster, kEMCALClusterv1,
-                 kPMDNeutral, kPMDCharged};
+  enum AODClu_t {kUndef = -1, 
+                kPHOSNeutral, 
+                kPHOSCharged,
+                kEMCALPseudoCluster, 
+                kEMCALClusterv1,
+                kPMDNeutral, 
+                kPMDCharged};
 
   enum AODCluPID_t {
-    kUnknown=0, kPhoton, kPi0, kNeutron, kKaon0, kEleCon, kCharged, kOther};
+    kUnknown = 0, 
+    kPhoton  = 1, 
+    kPi0     = 2, 
+    kNeutron = 3, 
+    kKaon0   = 4,
+    kEleCon  = 5, 
+    kCharged = 6, 
+    kNeutral = 7 , 
+    kOther   = 8};
 
   AliAODCluster();
   AliAODCluster(Int_t id,
@@ -33,7 +45,7 @@ class AliAODCluster : public AliVirtualParticle {
                Double_t energy,
                Double_t x[3],
                Double_t covMatrix[10],
-               Double_t pid[10],
+               Double_t pid[9],
                AliAODVertex *prodVertex, // not necessary for PMD
                AliAODTrack *primTrack,
                Char_t ttype=kUndef);
@@ -43,7 +55,7 @@ class AliAODCluster : public AliVirtualParticle {
                 Float_t energy,
                 Float_t x[3],
                 Float_t covMatrix[10],
-                Float_t pid[10],
+                Float_t pid[9],
                 AliAODVertex *prodVertex,
                 AliAODTrack *primTrack,
                 Char_t ttype=kUndef);
@@ -63,13 +75,14 @@ class AliAODCluster : public AliVirtualParticle {
 
   // PID
   virtual const Double_t *PID() const { return fPID; }
-
+  AODCluPID_t GetMostProbablePID() const;
   template <class T> void GetPID(T *pid) const {
-    for(Int_t i=0; i<10; ++i) pid[i]=fPID[i];}
+    for(Int_t i=0; i<9; ++i) pid[i]=fPID[i];}
  
   template <class T> void SetPID(const T *pid) {
-    if(pid) for(Int_t i=0; i<10; ++i) fPID[i]=pid[i];
-    else {for(Int_t i=1; i<10; fPID[i++]=0); fPID[0]=1.;}}
+    if(pid) for(Int_t i=0; i<9; ++i) fPID[i]=pid[i];
+    else {for(Int_t i=1; i<9; fPID[i++]=0);}}
 
   Int_t GetID() const { return fID; }
   Int_t GetLabel() const { return fLabel; } 
@@ -122,7 +135,7 @@ class AliAODCluster : public AliVirtualParticle {
   Double32_t    fEnergy;         // energy
   Double32_t    fPosition[3];    // position of the cluster
 
-  Double32_t    fPID[10];        // [0.,1.,8] pointer to PID object
+  Double32_t    fPID[9];         // [0.,1.,8] pointer to PID object
   Double32_t    fChi2;           // chi2 (probably not necessary for PMD)
 
   Int_t         fID;             // unique cluster ID, points back to the ESD cluster