new cuts to use combined basian pid without tender for pass 2
authorsnelling <snelling@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 26 Jul 2011 14:57:34 +0000 (14:57 +0000)
committersnelling <snelling@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 26 Jul 2011 14:57:34 +0000 (14:57 +0000)
PWG2/FLOW/AliFlowTasks/AliFlowBayesianPID.cxx
PWG2/FLOW/AliFlowTasks/AliFlowBayesianPID.h
PWG2/FLOW/AliFlowTasks/AliFlowTrackCuts.cxx
PWG2/FLOW/AliFlowTasks/AliFlowTrackCuts.h

index 8481bdf..fd46ff9 100644 (file)
@@ -67,6 +67,16 @@ AliFlowBayesianPID::AliFlowBayesianPID(AliESDpid *esdpid)
   }
 }
 //________________________________________________________________________
+AliFlowBayesianPID::~AliFlowBayesianPID(){
+  if(fMism) delete fMism;
+  if(fTofGeo) delete fTofGeo;
+  if(fTOFResponse) delete fTOFResponse;
+  if(fTPCResponse) delete fTPCResponse;
+  if(fTOFmaker) delete fTOFmaker;
+  if(fBBdata) delete fBBdata;
+  for(Int_t i=0;i < 5;i++) if(hPriors[i]) delete (hPriors[i]);
+}
+//________________________________________________________________________
 void AliFlowBayesianPID::SetDetResponse(AliESDEvent *esd,Float_t centrality,EStartTimeType_t flagStart,Bool_t recomputeT0TOF){
   if(!esd){
     printf("AliFlowBayesianPID::SetDetResponse -> Error -> No valid esd event");
@@ -176,7 +186,7 @@ void AliFlowBayesianPID::SetDetResponse(AliESDEvent *esd,Float_t centrality,ESta
   fPIDesd->MakePID(esd,kFALSE);
 }
 //________________________________________________________________________
-void AliFlowBayesianPID::ComputeWeights(AliESDtrack *t,Float_t centr){
+void AliFlowBayesianPID::ComputeWeights(const AliESDtrack *t,Float_t centr){
   Float_t pt = t->Pt();
   Float_t p = t->P();
   Double_t ptpc[3];
@@ -203,10 +213,11 @@ void AliFlowBayesianPID::ComputeWeights(AliESDtrack *t,Float_t centr){
 
       fWeights[0][iS] = fTPCResponse->Eval((dedx - dedxExp)/resolutionTPC)/resolutionTPC;
     }
-
+    fMaskCurrent[0] = kTRUE;
   }
   else{
     for(Int_t iS=0;iS<5;iS++) fWeights[0][iS] = 1;
+    fMaskCurrent[0] = kFALSE;
   }
 
   // TOF
@@ -243,9 +254,11 @@ void AliFlowBayesianPID::ComputeWeights(AliESDtrack *t,Float_t centr){
       } else
        fWeights[1][iS] = fTOFResponse->Eval(delta/expsigma)/expsigma + mismfrac*mismweight;
     }
+    fMaskCurrent[1] = kTRUE;
   }
   else{
     for(Int_t iS=0;iS<5;iS++) fWeights[1][iS] = 1;    
+    fMaskCurrent[1] = kFALSE;
   }
 
   for(Int_t j=0;j < 2;j++){
@@ -258,7 +271,7 @@ void AliFlowBayesianPID::ComputeWeights(AliESDtrack *t,Float_t centr){
   }  
 }
 //________________________________________________________________________
-void AliFlowBayesianPID::ComputeProb(AliESDtrack *t,Float_t centr){
+void AliFlowBayesianPID::ComputeProb(const AliESDtrack *t,Float_t centr){
   ComputeWeights(t,centr);
   Float_t priors[5];
   fProbTofMism = 0;
@@ -6382,3 +6395,4 @@ x[4999]=110229.399237; y[4999]=6.896278e-07;
 
   return sp;
 }
+
index fb1bf54..2bd5b17 100644 (file)
@@ -60,7 +60,7 @@ for data starting from the PbPb pass2 reconstruction
 class AliFlowBayesianPID : public AliPIDResponse {
  public:
   AliFlowBayesianPID(AliESDpid *esdpid=NULL); 
-  virtual ~AliFlowBayesianPID() {};
+  virtual ~AliFlowBayesianPID();
   
   // virtual method of AliPIDResponse
   virtual Float_t NumberOfSigmasTOF(const AliVParticle *vtrack, AliPID::EParticleType type) const {if(vtrack || type) printf("Don't call AliFlowBayesianPID::NumberOfSigmasTOF method\n"); return 0.0;} // do not use it
@@ -91,8 +91,8 @@ class AliFlowBayesianPID : public AliPIDResponse {
   Bool_t GetCurrentMask(Int_t idet){if(idet < fNdetectors && idet >= 0){return fMaskCurrent[idet];} else{return kFALSE;} };
 
   // methods for Bayesina Combined PID
-  void ComputeWeights(AliESDtrack *t,Float_t centr=-1.0);
-  void ComputeProb(AliESDtrack *t,Float_t centr=-1.0);
+  void ComputeWeights(const AliESDtrack *t,Float_t centr=-1.0);
+  void ComputeProb(const AliESDtrack *t,Float_t centr=-1.0);
 
   void SetTOFres(Float_t res){fTOFres=res;};
 
@@ -133,3 +133,4 @@ class AliFlowBayesianPID : public AliPIDResponse {
 };
 
 #endif
+
index f90905c..e9fc127 100644 (file)
@@ -60,6 +60,8 @@
 
 ClassImp(AliFlowTrackCuts)
 
+AliFlowBayesianPID *gBayesianPID;
+
 //-----------------------------------------------------------------------
 AliFlowTrackCuts::AliFlowTrackCuts():
   AliFlowTrackSimpleCuts(),
@@ -119,6 +121,7 @@ AliFlowTrackCuts::AliFlowTrackCuts():
   fTPCtrack(),
   fFlowTagType(AliFlowTrackSimple::kInvalid),
   fESDpid(),
+  fBayesianResponse(NULL),
   fPIDsource(kTOFpid),
   fTPCpidCuts(NULL),
   fTOFpidCuts(NULL),
@@ -126,11 +129,19 @@ AliFlowTrackCuts::AliFlowTrackCuts():
   fParticleProbability(.9),
   fAllowTOFmismatchFlag(kFALSE),
   fRequireStrictTOFTPCagreement(kFALSE),
-  fCutRejectElectronsWithTPCpid(kFALSE)
+  fCutRejectElectronsWithTPCpid(kFALSE),
+  fCurrCentr(0.0)
 {
   //io constructor 
   for ( Int_t i=0; i<5; i++ ) { fProbBayes[i]=0.0; }
   SetPriors(); //init arrays
+
+  // New PID procedure (Bayesian Combined PID)
+  if(! gBayesianPID){
+    gBayesianPID = new AliFlowBayesianPID();
+    gBayesianPID->SetNewTrackParam();
+  }
+  fBayesianResponse = gBayesianPID;
 }
 
 //-----------------------------------------------------------------------
@@ -192,6 +203,7 @@ AliFlowTrackCuts::AliFlowTrackCuts(const char* name):
   fTPCtrack(),
   fFlowTagType(AliFlowTrackSimple::kInvalid),
   fESDpid(),
+  fBayesianResponse(NULL),
   fPIDsource(kTOFpid),
   fTPCpidCuts(NULL),
   fTOFpidCuts(NULL),
@@ -199,7 +211,8 @@ AliFlowTrackCuts::AliFlowTrackCuts(const char* name):
   fParticleProbability(.9),
   fAllowTOFmismatchFlag(kFALSE),
   fRequireStrictTOFTPCagreement(kFALSE),
-  fCutRejectElectronsWithTPCpid(kFALSE)
+  fCutRejectElectronsWithTPCpid(kFALSE),
+  fCurrCentr(0.0)
 {
   //constructor 
   SetName(name);
@@ -212,6 +225,12 @@ AliFlowTrackCuts::AliFlowTrackCuts(const char* name):
   for ( Int_t i=0; i<5; i++ ) { fProbBayes[i]=0.0; }
   SetPriors(); //init arrays
 
+  // New PID procedure (Bayesian Combined PID)
+  if(! gBayesianPID){
+    gBayesianPID = new AliFlowBayesianPID();
+    gBayesianPID->SetNewTrackParam();
+  }
+  fBayesianResponse = gBayesianPID;
 }
 
 //-----------------------------------------------------------------------
@@ -273,6 +292,7 @@ AliFlowTrackCuts::AliFlowTrackCuts(const AliFlowTrackCuts& that):
   fTPCtrack(),
   fFlowTagType(that.fFlowTagType),
   fESDpid(that.fESDpid),
+  fBayesianResponse(NULL),
   fPIDsource(that.fPIDsource),
   fTPCpidCuts(NULL),
   fTOFpidCuts(NULL),
@@ -280,7 +300,8 @@ AliFlowTrackCuts::AliFlowTrackCuts(const AliFlowTrackCuts& that):
   fParticleProbability(that.fParticleProbability),
   fAllowTOFmismatchFlag(that.fAllowTOFmismatchFlag),
   fRequireStrictTOFTPCagreement(that.fRequireStrictTOFTPCagreement),
-  fCutRejectElectronsWithTPCpid(that.fCutRejectElectronsWithTPCpid)
+  fCutRejectElectronsWithTPCpid(that.fCutRejectElectronsWithTPCpid),
+  fCurrCentr(0.0)
 {
   //copy constructor
   if (that.fTPCpidCuts) fTPCpidCuts = new TMatrixF(*(that.fTPCpidCuts));
@@ -289,6 +310,13 @@ AliFlowTrackCuts::AliFlowTrackCuts(const AliFlowTrackCuts& that):
   memcpy(fProbBayes,that.fProbBayes,sizeof(fProbBayes));
   SetPriors(); //init arrays
   if (that.fQA) DefineHistograms();
+
+  // New PID procedure (Bayesian Combined PID)
+  if(! gBayesianPID){
+    gBayesianPID = new AliFlowBayesianPID();
+    gBayesianPID->SetNewTrackParam();
+  }
+  fBayesianResponse = gBayesianPID;
 }
 
 //-----------------------------------------------------------------------
@@ -375,6 +403,15 @@ AliFlowTrackCuts& AliFlowTrackCuts::operator=(const AliFlowTrackCuts& that)
   fCutRejectElectronsWithTPCpid=that.fCutRejectElectronsWithTPCpid;
   memcpy(fProbBayes,that.fProbBayes,sizeof(fProbBayes));
 
+  fCurrCentr = that.fCurrCentr;
+
+  // New PID procedure (Bayesian Combined PID)
+  if(! gBayesianPID){
+    gBayesianPID = new AliFlowBayesianPID();
+    gBayesianPID->SetNewTrackParam();
+  }
+  fBayesianResponse = gBayesianPID;
+
   return *this;
 }
 
@@ -402,8 +439,11 @@ void AliFlowTrackCuts::SetEvent(AliVEvent* event, AliMCEvent* mcEvent)
   {
     //TODO: maybe call it only for the TOF options?
     // Added by F. Noferini for TOF PID
+    // old procedure now implemented inside fBayesianResponse
+    //    fESDpid.MakePID(myESD,kFALSE);
+    // new procedure
+    fBayesianResponse->SetDetResponse(myESD, fCurrCentr,AliESDpid::kTOF_T0,kTRUE); // centrality = PbPb centrality class (0-100%) or -1 for pp collisions
     fESDpid.SetTOFResponse(myESD,AliESDpid::kTOF_T0);
-    fESDpid.MakePID(myESD,kFALSE);
     // End F. Noferini added part
   }
 
@@ -2053,41 +2093,55 @@ Bool_t AliFlowTrackCuts::PassesTPCbayesianCut(const AliESDtrack* track)
   //Bool_t statusMatchingHard = TPCTOFagree(track);
   //if (fRequireStrictTOFTPCagreement && (!statusMatchingHard))
   //     return kFALSE;
+  Int_t kTPC = fBayesianResponse->GetCurrentMask(0); // is TPC on
+  Int_t kTOF = fBayesianResponse->GetCurrentMask(1); // is TOF on
 
-  Int_t pdg = GetESDPdg(track,"bayesianTPC");
-  //  printf("pdg set to %i\n",pdg);
+  if(! kTPC) return kFALSE;
+
+  Bool_t statusMatchingHard = 1;
+  Float_t mismProb = 0;
+  if(kTOF){
+    statusMatchingHard = TPCTOFagree(track);
+    mismProb = fBayesianResponse->GetTOFMismProb();
+  }
+  if (fRequireStrictTOFTPCagreement && (!statusMatchingHard))
+       return kFALSE;
+
+  fBayesianResponse->ComputeProb(track,fCurrCentr); // fCurrCentr is needed for mismatch fraction
+  Float_t *probabilities = fBayesianResponse->GetProb(); // Bayesian Probability (from 0 to 4) (Combined TPC || TOF) including a tuning of priors and TOF mismatch parameterization
+
+  fProbBayes[0] = probabilities[0];
+  fProbBayes[1] = probabilities[1];
+  fProbBayes[2] = probabilities[2];
+  fProbBayes[3] = probabilities[3];
+  fProbBayes[4] = probabilities[4];
 
-  Int_t pid = 0;
   Float_t prob = 0;
   switch (fParticleID)
   {
     case AliPID::kPion:
-      pid=211;
       prob = fProbBayes[2];
       break;
     case AliPID::kKaon:
-      pid=321;
       prob = fProbBayes[3];
      break;
     case AliPID::kProton:
-      pid=2212;
       prob = fProbBayes[4];
       break;
     case AliPID::kElectron:
-      pid=-11;
        prob = fProbBayes[0];
      break;
     default:
       return kFALSE;
   }
 
-  if(TMath::Abs(pdg) == TMath::Abs(pid) && prob > fParticleProbability)
-  {
-    if(!fCutCharge)
-      return kTRUE;
-    else if (fCutCharge && fCharge * track->GetSign() > 0)
-      return kTRUE;
-  }
+  if(prob > fParticleProbability && mismProb < 0.5)
+    {
+      if(!fCutCharge)
+       return kTRUE;
+      else if (fCutCharge && fCharge * track->GetSign() > 0)
+       return kTRUE;
+    }
   return kFALSE;
 }
 
@@ -2110,27 +2164,29 @@ Bool_t AliFlowTrackCuts::PassesTOFbayesianCut(const AliESDtrack* track)
   if (fRequireStrictTOFTPCagreement && (!statusMatchingHard))
        return kFALSE;
 
-  Int_t pdg = GetESDPdg(track,"bayesianALL");
-  //  printf("pdg set to %i\n",pdg);
+  fBayesianResponse->ComputeProb(track,fCurrCentr); // fCurrCentr is needed for mismatch fraction
+  Float_t *probabilities = fBayesianResponse->GetProb(); // Bayesian Probability (from 0 to 4) (Combined TPC || TOF) including a tuning of priors and TOF mismatch parameterization
+
+  fProbBayes[0] = probabilities[0];
+  fProbBayes[1] = probabilities[1];
+  fProbBayes[2] = probabilities[2];
+  fProbBayes[3] = probabilities[3];
+  fProbBayes[4] = probabilities[4];
+  Float_t mismProb = fBayesianResponse->GetTOFMismProb(); // mismatch Bayesian probabilities
 
-  Int_t pid = 0;
   Float_t prob = 0;
   switch (fParticleID)
   {
     case AliPID::kPion:
-      pid=211;
       prob = fProbBayes[2];
       break;
     case AliPID::kKaon:
-      pid=321;
       prob = fProbBayes[3];
      break;
     case AliPID::kProton:
-      pid=2212;
       prob = fProbBayes[4];
       break;
     case AliPID::kElectron:
-      pid=-11;
        prob = fProbBayes[0];
      break;
     default:
@@ -2138,7 +2194,7 @@ Bool_t AliFlowTrackCuts::PassesTOFbayesianCut(const AliESDtrack* track)
   }
 
   //  printf("pt = %f -- all prob = [%4.2f,%4.2f,%4.2f,%4.2f,%4.2f] -- prob = %f\n",track->Pt(),fProbBayes[0],fProbBayes[1],fProbBayes[2],fProbBayes[3],fProbBayes[4],prob);
-  if(TMath::Abs(pdg) == TMath::Abs(pid) && prob > fParticleProbability){
+  if(prob > fParticleProbability && mismProb < 0.5){
     if(!fCutCharge)
       return kTRUE;
     else if (fCutCharge && fCharge * track->GetSign() > 0)
@@ -2401,7 +2457,9 @@ Int_t AliFlowTrackCuts::GetESDPdg(const AliESDtrack *track,Option_t *option,Int_
 
 //-----------------------------------------------------------------------
 void AliFlowTrackCuts::SetPriors(Float_t centrCur){
-  //set priors for the bayesian pid selection
+  fCurrCentr = centrCur;
+
+ //set priors for the bayesian pid selection
   fBinLimitPID[0] = 0.300000;
   fBinLimitPID[1] = 0.400000;
   fBinLimitPID[2] = 0.500000;
@@ -3678,3 +3736,4 @@ Long64_t AliFlowTrackCuts::Merge(TCollection* list)
   return fQA->Merge(&tmplist);
 }
 
+
index 343dae8..f2a5d8c 100644 (file)
@@ -17,6 +17,7 @@
 #include "AliESDtrack.h"
 #include "AliPID.h"
 #include "AliESDpid.h"
+#include "AliFlowBayesianPID.h"
 
 class TBrowser;
 class AliVParticle;
@@ -105,7 +106,7 @@ class AliFlowTrackCuts : public AliFlowTrackSimpleCuts {
   void SetPmdDetPlane(Int_t pmdDet){fCutPmdDet=kTRUE; fPmdDet = pmdDet; }
   void SetPmdAdc(Float_t pmdAdc){fCutPmdAdc=kTRUE; fPmdAdc = pmdAdc; }
   void SetPmdNcell(Float_t pmdNcell) {fCutPmdNcell=kTRUE; fPmdNcell = pmdNcell; }                                               
-  void SetPriors(Float_t centr = 0); // set my favourite priors for Bayesian PID
+  void SetPriors(Float_t centr = 0); // set my favourite priors for Bayesian PID (requested if Bayesian PID is used)
   void SetFlowTagType(AliFlowTrackSimple::tagType t) {fFlowTagType=t;}
 
   Int_t GetMinNClustersTPC() const {if (!fAliESDtrackCuts) return 0; return fAliESDtrackCuts->GetMinNClusterTPC();}
@@ -299,6 +300,7 @@ class AliFlowTrackCuts : public AliFlowTrackSimpleCuts {
 
   //PID
   AliESDpid fESDpid; //pid obj
+  AliFlowBayesianPID *fBayesianResponse; // Baysian response with all the TOF tuning (using fESDpid)
   PIDsource fPIDsource; //pid source
   TMatrixF* fTPCpidCuts; //tpc pid cuts
   TMatrixF* fTOFpidCuts; //tof pid cuts
@@ -312,7 +314,8 @@ class AliFlowTrackCuts : public AliFlowTrackSimpleCuts {
   static const Int_t fgkPIDptBin = 20; // pT bins for priors
   Float_t fC[fgkPIDptBin][5],fBinLimitPID[fgkPIDptBin]; // pt bin limit and priors
   Float_t fProbBayes[5]; // bayesian probability
-  // end part added by F. Noferini
+  Float_t fCurrCentr; // current centrality used for set the priors
+ // end part added by F. Noferini
 
   static const Int_t fgkNumberOfV0tracks=64; //number of V0 channels
 
@@ -321,3 +324,4 @@ class AliFlowTrackCuts : public AliFlowTrackSimpleCuts {
 
 #endif
 
+