]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALPID.cxx
write to special output (needed for CAF)
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALPID.cxx
index 98494b5b95cdf2ea837ab4cb7a7a6a4dc0b83518..60be817782690760f6fd187a3eef0cdee310a585 100644 (file)
 /* History of cvs commits:
  *
  * $Log$
+ * Revision 1.16  2007/11/23 13:39:05  gustavo
+ * Track matching and PID parameters added to AliEMCALRecParam
+ *
+ * Revision 1.15  2007/10/09 08:46:10  hristov
+ * The data members fEMCALClusterCluster and fPHOSCluster are removed from AliESDCaloCluster, the fClusterType is used to select PHOS or EMCAL clusters. Changes, needed to use correctly the new AliESDCaloCluster. (Christian)
+ *
+ * Revision 1.14  2007/07/26 16:54:53  morsch
+ * Changes in AliESDEvent fwd declarartions.
+ *
+ * Revision 1.13  2007/07/11 13:43:29  hristov
+ * New class AliESDEvent, backward compatibility with the old AliESD (Christian)
+ *
+ * Revision 1.12  2007/06/11 20:43:06  hristov
+ * Changes required by the updated AliESDCaloCluster (Gustavo)
+ *
+ * Revision 1.11  2007/03/30 13:50:34  gustavo
+ * PID for particles with E < 5 GeV was not done, temporal solution found (Guenole)
+ *
+ * Revision 1.10  2007/03/09 14:34:11  gustavo
+ * Correct probability calculation, added missing initialization of data members
+ *
  * Revision 1.9  2007/02/20 20:17:43  hristov
  * Corrected array size, removed warnings (icc)
  *
@@ -70,8 +91,6 @@
 
 // standard C++ includes
 #include <Riostream.h>
-// #include <cstdlib>
-// #include <cmath>
 
 // ROOT includes
 #include "TTree.h"
 #include "TH2.h"
 #include "TParticle.h"
 
-// // STEER includes
-// #include "AliRun.h"
-// #include "AliRunLoader.h"
-// #include "AliHeader.h"
-// #include "AliLoader.h"
-// #include "AliStack.h"
-// #include "AliESDtrack.h"
-// #include "AliESD.h"
+// STEER includes
 #include "AliLog.h"
 #include "AliEMCALPID.h"
+#include "AliESDCaloCluster.h"
+#include "AliEMCALRecParam.h"
+#include "AliEMCALReconstructor.h"
+
   
 ClassImp(AliEMCALPID)
 
@@ -109,133 +125,45 @@ ClassImp(AliEMCALPID)
   // Initialize all constant values which have to be used
   // during PID algorithm execution
   //
-  
-  // set flag for printing to FALSE by default
-  fPrintInfo = kFALSE;
-  
-  // as a first step, all array elements are initialized to 0.0
-  Int_t i, j;
-  for (i = 0; i < 6; i++) {
-    for (j = 0; j < 6; j++) {
-      fGamma[i][j] = fHadron[i][j] = fPiZero5to10[i][j] = fPiZero10to60[i][j] = 0.;
-    }
-  }
-  
-  // then, only the ones which must be not zero are initialized
-  // while the others will remain to the value 0.0
-  
-  fGamma[0][0] =  0.038022;
-  fGamma[0][1] = -0.0001883;
-  fGamma[0][2] =  5.449e-06;
-  
-  fGamma[1][0] =  0.207313;
-  fGamma[1][1] = -0.000978;
-  fGamma[1][2] =  0.00001634;
-  
-  fGamma[2][0] =  0.043364;
-  fGamma[2][1] = -0.0002048;
-  fGamma[2][2] =  8.661e-06;
-  fGamma[2][3] = -1.353e-07;
-  
-  fGamma[3][0] =  0.265004;
-  fGamma[3][1] =  0.061298;
-  fGamma[3][2] = -0.003203;
-  fGamma[3][3] =  4.73e-05;
-  
-  fGamma[4][0] =  0.243579;
-  fGamma[4][1] = -1.614e-05;
-  
-  fGamma[5][0] =  0.002942;
-  fGamma[5][1] = -3.976e-05;
-  
-  fHadron[0][0] =  0.011945 / 3.;
-  fHadron[0][1] =  0.000386 / 3.;
-  fHadron[0][2] = -0.000014 / 3.;
-  fHadron[0][3] =  1.336e-07 / 3.;
-  
-  fHadron[1][0] =  0.496544;
-  fHadron[1][1] = -0.003226;
-  fHadron[1][2] =  0.00001678;
-  
-  fHadron[2][0] =  0.144838;
-  fHadron[2][1] = -0.002954;
-  fHadron[2][2] =  0.00008754;
-  fHadron[2][3] = -7.587e-07;
-  
-  fHadron[3][0] =  1.264461 / 7.;
-  fHadron[3][1] =  0.002097 / 7.;
-  
-  fHadron[4][0] =  0.261950;
-  fHadron[4][1] = -0.001078;
-  fHadron[4][2] =  0.00003237;
-  fHadron[4][3] = -3.241e-07;
-  fHadron[4][4] =  0.;
-  fHadron[4][5] =  0.;
-  fHadron[5][0] =  0.010317;
-  fHadron[5][1] =  0.;
-  fHadron[5][2] =  0.;
-  fHadron[5][3] =  0.;
-  fHadron[5][4] =  0.;
-  fHadron[5][5] =  0.;
-  
-  fPiZero5to10[0][0] = 0.009138;
-  fPiZero5to10[0][1] = 0.0006377;
-  
-  fPiZero5to10[1][0] = 0.08;
-  
-  fPiZero5to10[2][0] = -0.061119;
-  fPiZero5to10[2][1] =  0.019013;
-  
-  fPiZero5to10[3][0] =  0.2;
-  
-  fPiZero5to10[4][0] =  0.252044;
-  fPiZero5to10[4][1] = -0.002315;
-  
-  fPiZero5to10[5][0] =  0.002942;
-  fPiZero5to10[5][1] = -3.976e-05;
-  
-  fPiZero10to60[0][0] =  0.009138;
-  fPiZero10to60[0][1] =  0.0006377;
-  
-  fPiZero10to60[1][0] =  1.272837;
-  fPiZero10to60[1][1] = -0.069708;
-  fPiZero10to60[1][2] =  0.001568;
-  fPiZero10to60[1][3] = -1.162e-05;
-  
-  fPiZero10to60[2][0] =  0.139703;
-  fPiZero10to60[2][1] =  0.003687;
-  fPiZero10to60[2][2] = -0.000568;
-  fPiZero10to60[2][3] =  1.498e-05;
-  fPiZero10to60[2][4] = -1.174e-07;
-  
-  fPiZero10to60[3][0] = -0.826367;
-  fPiZero10to60[3][1] =  0.096951;
-  fPiZero10to60[3][2] = -0.002215;
-  fPiZero10to60[3][3] =  2.523e-05;
-  
-  fPiZero10to60[4][0] =  0.249890;
-  fPiZero10to60[4][1] = -0.000063;
-  
-  fPiZero10to60[5][0] =  0.002942;
-  fPiZero10to60[5][1] = -3.976e-05;
-  
   fPIDWeight[0] = -1;
   fPIDWeight[1] = -1;
   fPIDWeight[2] = -1;
-  fReconstructor = kFALSE;
+
+  for(Int_t i=0; i<AliPID::kSPECIESN+1; i++)
+    fPIDFinal[i]= 0;
+
+  const AliEMCALRecParam* recParam = AliEMCALReconstructor::GetRecParam();
+  if(!recParam) {
+    AliFatal("Reconstruction parameters for EMCAL not set!");
+  }
+  else {
+    for(Int_t i=0; i<6; i++){
+      for(Int_t j=0; j<6; j++){
+       fGamma[i][j] = recParam->GetGamma(i,j);
+       fHadron[i][j] = recParam->GetHadron(i,j);
+       fPiZero5to10[i][j] = recParam->GetPiZero5to10(i,j);
+       fPiZero10to60[i][j] = recParam->GetPiZero10to60(i,j);
+       AliDebug(1,Form("PID parameters (%d, %d): fGamma=%.3f, fPi=%.3f, fHadron=%.3f",
+                       i,j, fGamma[i][j],fPiZero5to10[i][j],fHadron[i][j] ));
+      }
+    }
+    
+  }
+  
 }
 
 //______________________________________________
-void AliEMCALPID::RunPID(AliESD *esd)
+void AliEMCALPID::RunPID(AliESDEvent *esd)
 {
 //
 // Make the PID for all the EMCAL clusters containedin the ESDs File
 // but just gamma/PiO/Hadron
 //
        // trivial check against NULL object passed
-  
+
   if (esd == 0x0) {
-    AliInfo("NULL ESD object passed!!" );
+    AliInfo("NULL ESD object passed !!" );
     return ;
   }
 
@@ -243,16 +171,21 @@ void AliEMCALPID::RunPID(AliESD *esd)
   Int_t firstCluster = esd->GetFirstEMCALCluster();
   Double_t energy, lambda0;
   for (Int_t iCluster = firstCluster; iCluster < (nClusters + firstCluster); iCluster++) {
-    
+
     AliESDCaloCluster *clust = esd->GetCaloCluster(iCluster);
-    energy = clust->GetClusterEnergy();
+    energy = clust->E();
     lambda0 = clust->GetM02();
     // verify cluster type
     Int_t clusterType= clust->GetClusterType();
-    if (clusterType == AliESDCaloCluster::kClusterv1 && lambda0 != 0 && energy > 5 && energy < 1000) {
+    if (clusterType == AliESDCaloCluster::kEMCALClusterv1 && lambda0 != 0  && energy < 1000) {
+
+
       // reject clusters with lambda0 = 0
-      // reject clusters with energy < 5 GeV
+
+
       ComputePID(energy, lambda0);
+
+
       if (fPrintInfo) {
        AliInfo("___________________________________________________");
        AliInfo(Form( "Particle Energy = %f",energy));
@@ -289,6 +222,10 @@ void AliEMCALPID::ComputePID(Double_t energy, Double_t lambda0)
 // This is the main command, which uses the distributions computed and parametrised, 
 // and gives the PID by the bayesian method.
 //
+
+if (energy<5){energy =6;}
+
+
   TArrayD paramDistribGamma  = DistLambda0(energy, 1);
   TArrayD paramDistribPiZero = DistLambda0(energy, 2);
   TArrayD paramDistribHadron = DistLambda0(energy, 3);
@@ -355,6 +292,8 @@ TArrayD AliEMCALPID::DistLambda0(Double_t energy, Int_t type)
     constLandau = Polynomial(energy, fGamma[3]);
     mpvLandau   = Polynomial(energy, fGamma[4]);
     sigmaLandau = Polynomial(energy, fGamma[5]);
+    
+
     break;
   case 2:
     if (energy < 10) {
@@ -364,6 +303,7 @@ TArrayD AliEMCALPID::DistLambda0(Double_t energy, Int_t type)
       constLandau = Polynomial(energy, fPiZero5to10[3]);
       mpvLandau   = Polynomial(energy, fPiZero5to10[4]);
       sigmaLandau = Polynomial(energy, fPiZero5to10[5]);
+
     }
     else {
       constGauss  = Polynomial(energy, fPiZero10to60[0]);
@@ -372,6 +312,7 @@ TArrayD AliEMCALPID::DistLambda0(Double_t energy, Int_t type)
       constLandau = Polynomial(energy, fPiZero10to60[3]);
       mpvLandau   = Polynomial(energy, fPiZero10to60[4]);
       sigmaLandau = Polynomial(energy, fPiZero10to60[5]);
     }
     break;
   case 3:
@@ -381,6 +322,7 @@ TArrayD AliEMCALPID::DistLambda0(Double_t energy, Int_t type)
     constLandau = Polynomial(energy, fHadron[3]);
     mpvLandau   = Polynomial(energy, fHadron[4]);
     sigmaLandau = Polynomial(energy, fHadron[5]);
+
     break;
   }
   
@@ -401,6 +343,7 @@ Double_t AliEMCALPID::Polynomial(Double_t x, Double_t *params)
   // Compute a polynomial for a given value of 'x'
   // with the array of parameters passed as the second arg
   //
+  
   Double_t y;
   y  = params[0];
   y += params[1] * x;