]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ANALYSIS/AliESDpidCuts.cxx
remove temporary task that was used to troubleshoot the gamma flow anaysis
[u/mrichter/AliRoot.git] / ANALYSIS / AliESDpidCuts.cxx
index 0dddcc9b3411f2f10437eb57fab02d75133fd4b8..9f7bef18eedbbb4788444837828ce0f6b8e9fe81 100644 (file)
@@ -1,3 +1,17 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
 #include <TCanvas.h>
 #include <TClass.h>
 #include <TCollection.h>
 #include <TString.h>
 #include <TList.h>
 
+#include "AliAnalysisManager.h"
+#include "AliInputEventHandler.h"
 #include "AliESDtrack.h"
 #include "AliESDEvent.h"
 #include "AliLog.h"
-#include "AliESDpid.h"
+#include "AliPIDResponse.h"
 
 #include "AliESDpidCuts.h"
 
@@ -24,7 +40,7 @@ const Int_t AliESDpidCuts::kNcuts = 3;
 //_____________________________________________________________________
 AliESDpidCuts::AliESDpidCuts(const Char_t *name, const Char_t *title):
     AliAnalysisCuts(name, title)
-  , fESDpid(NULL)
+  , fPIDresponse(NULL)
   , fTPCsigmaCutRequired(0)
   , fTOFsigmaCutRequired(0)
   , fCutTPCclusterRatio(0.)
@@ -36,9 +52,8 @@ AliESDpidCuts::AliESDpidCuts(const Char_t *name, const Char_t *title):
   // Default constructor
   //
   
-  fESDpid = new AliESDpid;
-  memset(fCutTPCnSigma, 0, sizeof(Float_t) * 2);
-  memset(fCutTOFnSigma, 0, sizeof(Float_t) * 2);
+  memset(fCutTPCnSigma, 0, sizeof(Float_t)* AliPID::kSPECIES * 2);
+  memset(fCutTOFnSigma, 0, sizeof(Float_t)* AliPID::kSPECIES * 2);
 
   memset(fHclusterRatio, 0, sizeof(TH1F *) * 2);
   memset(fHnSigmaTPC, 0, sizeof(TH1F *) * AliPID::kSPECIES * 2);
@@ -48,7 +63,7 @@ AliESDpidCuts::AliESDpidCuts(const Char_t *name, const Char_t *title):
 //_____________________________________________________________________
 AliESDpidCuts::AliESDpidCuts(const AliESDpidCuts &ref):
     AliAnalysisCuts(ref)
-  , fESDpid(NULL)
+  , fPIDresponse(NULL)
   , fTPCsigmaCutRequired(ref.fTPCsigmaCutRequired)
   , fTOFsigmaCutRequired(ref.fTOFsigmaCutRequired)
   , fCutTPCclusterRatio(ref.fCutTPCclusterRatio)
@@ -59,7 +74,7 @@ AliESDpidCuts::AliESDpidCuts(const AliESDpidCuts &ref):
   //
   // Copy constructor
   //
-  fESDpid = new AliESDpid(*ref.fESDpid);
+  fPIDresponse = ref.fPIDresponse;
   memcpy(fCutTPCnSigma, ref.fCutTPCnSigma, sizeof(Float_t) * AliPID::kSPECIES * 2);
   memcpy(fCutTOFnSigma, ref.fCutTOFnSigma, sizeof(Float_t) * AliPID::kSPECIES * 2);
   
@@ -89,9 +104,7 @@ AliESDpidCuts::~AliESDpidCuts(){
   //
   // Destructor
   //
-  delete fESDpid;
 
-  delete fHcutStatistics;
   delete fHcutCorrelation;
   for(Int_t imode = 0; imode < 2; imode++){
     delete fHclusterRatio[imode];
@@ -102,6 +115,20 @@ AliESDpidCuts::~AliESDpidCuts(){
   }
 }
 
+//_____________________________________________________________________
+void AliESDpidCuts::Init(){
+  //
+  // Init function, get PID response from the Analysis Manager
+  //
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if(mgr){
+    AliInputEventHandler *handler = dynamic_cast<AliInputEventHandler*>(mgr->GetInputEventHandler());
+    if(handler){
+      fPIDresponse = handler->GetPIDResponse();
+    }
+  }
+}
+
 //_____________________________________________________________________
 Bool_t AliESDpidCuts::IsSelected(TObject *obj){
   //
@@ -112,7 +139,7 @@ Bool_t AliESDpidCuts::IsSelected(TObject *obj){
     AliError("Provided object is not AliESDtrack!");
     return kFALSE;
   }
-  AliESDEvent* evt = trk->GetESDEvent();
+  const AliESDEvent* evt = trk->GetESDEvent();
   if(!evt){
     AliError("No AliESDEvent!");
     return kFALSE;
@@ -127,7 +154,7 @@ void AliESDpidCuts::Copy(TObject &c) const {
   //
   AliESDpidCuts &target = dynamic_cast<AliESDpidCuts &>(c);
 
-  target.fESDpid = new AliESDpid(*fESDpid);
+  target.fPIDresponse = fPIDresponse;
 
   target.fCutTPCclusterRatio = fCutTPCclusterRatio;
   target.fMinMomentumTOF = fMinMomentumTOF;
@@ -146,7 +173,7 @@ void AliESDpidCuts::Copy(TObject &c) const {
   }
  
   memcpy(target.fCutTPCnSigma, fCutTPCnSigma, sizeof(Float_t) * AliPID::kSPECIES * 2);
-  memcpy(target.fCutTOFnSigma, fCutTOFnSigma, sizeof(Float_t) * AliPID::kSPECIES);
+  memcpy(target.fCutTOFnSigma, fCutTOFnSigma, sizeof(Float_t) * AliPID::kSPECIES * 2);
  
   AliESDpidCuts::Copy(c);
 }
@@ -156,8 +183,8 @@ Long64_t AliESDpidCuts::Merge(TCollection *coll){
   //
   // Merge Cut objects
   //
-  if(coll) return 0;
-  if(coll->IsEmpty()) return 1;
+  if(!coll) return 0;
+  if(coll->IsEmpty())   return 1;
   if(!HasHistograms())  return 0;
   
   TIterator *iter = coll->MakeIterator();
@@ -200,15 +227,15 @@ void AliESDpidCuts::DefineHistograms(Color_t color){
   }
   Char_t hname[256], htitle[256];
   for(Int_t imode = 0; imode < 2; imode++){
-    sprintf(hname, "fHclusterRatio%s", imode ? "After" : "Before");
-    sprintf(htitle, "TPC cluster Ratio %s cuts;Ratio;Entries", imode ? "after" : "before");
+    snprintf(hname, 256, "fHclusterRatio%s", imode ? "After" : "Before");
+    snprintf(htitle, 256, "TPC cluster Ratio %s cuts;Ratio;Entries", imode ? "after" : "before");
     fHclusterRatio[imode] = new TH1F(hname, htitle, 20, 0., 1.);
     for(Int_t ispec = 0; ispec < AliPID::kSPECIES; ispec++){
-      sprintf(hname, "fHnSigma%sTPC%s", AliPID::ParticleName(ispec), imode ? "after" : "before");
-      sprintf(htitle, "TPC sigma for %s %s cuts;sigma;Entries", AliPID::ParticleName(ispec), imode ? "after" : "before");
+      snprintf(hname, 256, "fHnSigma%sTPC%s", AliPID::ParticleName(ispec), imode ? "after" : "before");
+      snprintf(htitle, 256, "TPC sigma for %s %s cuts;sigma;Entries", AliPID::ParticleName(ispec), imode ? "after" : "before");
       fHnSigmaTPC[ispec][imode] = new TH1F(hname, htitle, 200, -10., 10.);
-      sprintf(hname, "fHnSigma%sTOF%s", AliPID::ParticleName(ispec), imode ? "after" : "before");
-      sprintf(htitle, "TOF sigma for %s %s cuts;sigma;Entries", AliPID::ParticleName(ispec), imode ? "after" : "before");
+      snprintf(hname, 256, "fHnSigma%sTOF%s", AliPID::ParticleName(ispec), imode ? "after" : "before");
+      snprintf(htitle, 256, "TOF sigma for %s %s cuts;sigma;Entries", AliPID::ParticleName(ispec), imode ? "after" : "before");
       fHnSigmaTOF[ispec][imode] = new TH1F(hname, htitle, 200, -10., 10.);
     }
   }
@@ -219,14 +246,22 @@ Bool_t AliESDpidCuts::AcceptTrack(const AliESDtrack *track, const AliESDEvent *e
   //
   // Check whether the tracks survived the cuts
   //
+  if(!fPIDresponse){
+    Init();
+    if (!fPIDresponse)
+      AliError("PID Response not available");
+    return 0;
+  }
   enum{
     kCutClusterRatioTPC,
     kCutNsigmaTPC,
     kCutNsigmaTOF
   };
   Long64_t cutRequired=0, cutFullfiled = 0;
-  if(fTOFsigmaCutRequired && event == 0) 
+  if(fTOFsigmaCutRequired && event == 0)  {
     AliError("No event pointer. Need event pointer for T0 for TOF cut");
+    return (0);
+  }
   Double_t clusterRatio = track->GetTPCNclsF() ? static_cast<Float_t>(track->GetTPCNcls())/static_cast<Float_t>(track->GetTPCNclsF()) : 1.;
   if(fCutTPCclusterRatio > 0.){
     SETBIT(cutRequired, kCutClusterRatioTPC);
@@ -236,7 +271,7 @@ Bool_t AliESDpidCuts::AcceptTrack(const AliESDtrack *track, const AliESDEvent *e
   // check TPC nSigma cut
   Float_t nsigmaTPC[AliPID::kSPECIES], nsigma;   // need all sigmas for QA plotting
   for(Int_t ispec = 0; ispec < AliPID::kSPECIES; ispec++){
-    nsigmaTPC[ispec] = nsigma = fESDpid->NumberOfSigmasTPC(track,(AliPID::EParticleType)ispec);
+    nsigmaTPC[ispec] = nsigma = fPIDresponse->NumberOfSigmasTPC(track,(AliPID::EParticleType)ispec);
     if(!(fTPCsigmaCutRequired & 1 << ispec)) continue;
     SETBIT(cutRequired, kCutNsigmaTPC); // We found at least one species where the n-Sigma Cut is required
     if(nsigma >= fCutTPCnSigma[2*ispec] && nsigma <= fCutTPCnSigma[2*ispec+1]) SETBIT(cutFullfiled, kCutNsigmaTPC);    // Fullfiled for at least one species
@@ -248,7 +283,7 @@ Bool_t AliESDpidCuts::AcceptTrack(const AliESDtrack *track, const AliESDEvent *e
   track->GetIntegratedTimes(times);
   for(Int_t ispec = 0; ispec < AliPID::kSPECIES; ispec++){
     
-    if(hasTOFpid) nsigmaTOF[ispec] = nsigma = fESDpid->NumberOfSigmasTOF(track,(AliPID::EParticleType)ispec, event->GetT0());
+    if(hasTOFpid && event) nsigmaTOF[ispec] = nsigma = fPIDresponse->NumberOfSigmasTOF(track,(AliPID::EParticleType)ispec);
     if(!(fTOFsigmaCutRequired && 1 << ispec)) continue;
     SETBIT(cutRequired, kCutNsigmaTOF);
     if(track->GetOuterParam()->P() >= fMinMomentumTOF){