claening the code and adding pile-up cut
authormchojnac <Marek.Chojnacki@cern.ch>
Thu, 14 Aug 2014 12:17:20 +0000 (14:17 +0200)
committermchojnac <Marek.Chojnacki@cern.ch>
Thu, 14 Aug 2014 12:19:11 +0000 (14:19 +0200)
PWGLF/SPECTRA/PiKaPr/TestAOD/AliAnalysisTaskSpectraBoth.cxx
PWGLF/SPECTRA/PiKaPr/TestAOD/AliSpectraBothEventCuts.cxx
PWGLF/SPECTRA/PiKaPr/TestAOD/AliSpectraBothEventCuts.h
PWGLF/SPECTRA/PiKaPr/TestAOD/AliSpectraBothTrackCuts.h
PWGLF/SPECTRA/PiKaPr/TestAOD/QAPlotsBoth.C

index b129799..7132361 100644 (file)
@@ -114,7 +114,8 @@ void AliAnalysisTaskSpectraBoth::UserExec(Option_t *)
        else
                AliFatal("Not processing AODs or ESDS") ;
        if(fdotheMCLoopAfterEventCuts)
-               if(!fEventCuts->IsSelected(fAOD,fTrackCuts))return;//event selection
+               if(!fEventCuts->IsSelected(fAOD,fTrackCuts))
+                       return;//event selection
        TClonesArray *arrayMC = 0;
        Int_t npar=0;
        AliStack* stack=0x0;
index 670c79b..87464b9 100644 (file)
@@ -36,6 +36,7 @@
 #include "AliAnalysisDataContainer.h"
 #include "AliSpectraBothEventCuts.h"
 #include "AliSpectraBothTrackCuts.h"
+#include "AliAnalysisUtils.h"  
 //#include "AliSpectraBothHistoManager.h"
 #include <iostream>
 
@@ -48,7 +49,7 @@ fIsSelected(0), fCentralityCutMin(0), fCentralityCutMax(0), fQVectorCutMin(0), f
 fMinRun(0),fMaxRun(0),fetarangeofmultiplicitycut(0.0),
 fHistoCuts(0),fHistoVtxBefSel(0),fHistoVtxAftSel(0),fHistoEtaBefSel(0),fHistoEtaAftSel(0),fHistoNChAftSel(0),fHistoQVector(0)
 ,fHistoEP(0),fHistoVtxAftSelwithoutZvertexCut(0),fHistoVtxalltriggerEventswithMCz(0),fHistoVtxAftSelwithoutZvertexCutusingMCz(0),fHistoRunNumbers(0),
-fHistoCentrality(0),fHistoMultiplicty(0)
+fHistoCentrality(0),fHistoMultiplicty(0),fAnalysisUtils(0)
 
 {
   // Constructori
@@ -116,6 +117,8 @@ AliSpectraBothEventCuts::~AliSpectraBothEventCuts()
                delete fHistoCentrality;
        if(fHistoMultiplicty)
                delete fHistoMultiplicty;
+       if(fAnalysisUtils)
+               delete fAnalysisUtils;
 
 }
 //______________________________________________________
@@ -172,15 +175,18 @@ Bool_t AliSpectraBothEventCuts::IsSelected(AliVEvent * aod,AliSpectraBothTrackCu
   fHistoCuts->Fill(kProcessedEvents);
   fHistoRunNumbers->Fill(aod->GetRunNumber());
   Bool_t IsPhysSel = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & fTriggerSettings);//FIXME we can add the trigger mask here
-  if(!IsPhysSel)return IsPhysSel;
-
+ if(fAnalysisUtils) // we check for pile-up
+                IsPhysSel = (!fAnalysisUtils->IsPileUpEvent(fAOD));
+  if(!IsPhysSel)
+       return IsPhysSel;
+       
   if(isMC)     
        fHistoVtxalltriggerEventswithMCz->Fill(mcZ);
    //loop on tracks, before event selection, filling QA histos
- AliESDEvent* esdevent=0x0;
+  AliESDEvent* esdevent=0x0;
   AliAODEvent* aodevent=0x0;
   Bool_t isSDD=kFALSE;
-     TString nameoftrack(fAOD->ClassName());  
+  TString nameoftrack(fAOD->ClassName());  
     if(!nameoftrack.CompareTo("AliESDEvent"))
     {
                fAODEvent=AliSpectraBothTrackCuts::kESDobject;
@@ -220,12 +226,13 @@ Bool_t AliSpectraBothEventCuts::IsSelected(AliVEvent * aod,AliSpectraBothTrackCu
 
    const AliVVertex * vertex = fAOD->GetPrimaryVertex();//FIXME vertex is recreated    
 
-  if(vertex)fHistoVtxBefSel->Fill(vertex->GetZ());
+  if(vertex)
+       fHistoVtxBefSel->Fill(vertex->GetZ());
   fIsSelected =kFALSE;
-  if(CheckVtx() && CheckCentralityCut() && CheckMultiplicityCut() && CheckVtxChi2perNDF())
+  if(CheckVtx() && CheckCentralityCut() && CheckMultiplicityCut())
    { //selection on vertex and Centrality
 
-    fIsSelected=CheckQVectorCut(); // QVector is calculated only if the centrality and vertex are correct (performance)
+    fIsSelected=kTRUE;
   }
   if(fIsSelected&&vertex)
  {
@@ -243,6 +250,12 @@ Bool_t AliSpectraBothEventCuts::IsSelected(AliVEvent * aod,AliSpectraBothTrackCu
                fIsSelected=kFALSE;
     }  
   }
+
+  if(fIsSelected)
+       fIsSelected=CheckQVectorCut(); 
+
+
+
   Int_t Nch=0;
   for (Int_t iTracks = 0; iTracks < fAOD->GetNumberOfTracks(); iTracks++) {
     AliVTrack* track =dynamic_cast<AliVTrack*>(fAOD->GetTrack(iTracks));
@@ -259,7 +272,8 @@ Bool_t AliSpectraBothEventCuts::IsSelected(AliVEvent * aod,AliSpectraBothTrackCu
       Nch++;
     }
   }
-  if(fIsSelected)fHistoNChAftSel->Fill(Nch);
+  if(fIsSelected)
+       fHistoNChAftSel->Fill(Nch);
   return fIsSelected;
 }
 
@@ -295,7 +309,10 @@ Bool_t AliSpectraBothEventCuts::CheckVtx()
    // {
     //  return kTRUE;
    // }
-  fHistoCuts->Fill(kVtxRange);
+   if(!CheckVtxChi2perNDF())     
+       return kFALSE;
+               
+ fHistoCuts->Fill(kGoodVtx);
   //return kFALSE;
    return kTRUE;
 }
@@ -425,7 +442,7 @@ void AliSpectraBothEventCuts::PrintCuts()
         cout << " > Number of accepted events: " << fHistoCuts->GetBinContent(kAcceptedEvents + 1) << endl;
         cout << " > Number of processed events: " << fHistoCuts->GetBinContent(kProcessedEvents + 1) << endl;
         cout << " > Number of PhysSel events: " << fHistoCuts->GetBinContent(kPhysSelEvents + 1) << endl;
-        cout << " > Vertex out of range: " << fHistoCuts->GetBinContent(kVtxRange + 1) << endl;
+        cout << " > With good veretx: " << fHistoCuts->GetBinContent(kGoodVtx + 1) << endl;
         cout << " > Events cut by centrality: " << fHistoCuts->GetBinContent(kVtxCentral + 1) << endl;
         cout << " > Events without vertex: " << fHistoCuts->GetBinContent(kVtxNoEvent + 1) << endl;
          cout << " > QVector cut: " << fHistoCuts->GetBinContent(kQVector + 1) << endl;
index 0f0d7da..7aad558 100644 (file)
@@ -19,10 +19,21 @@ class AliSpectraBothTrackCuts;
 #include "TH1I.h"
 #include "TNamed.h"
 #include "AliSpectraBothTrackCuts.h"
+#include "AliAnalysisUtils.h"  
+
 class AliSpectraBothEventCuts : public TNamed
 {
  public:
-  enum {  kProcessedEvents = 0,kPhysSelEvents,kAcceptedEvents, kVtxRange, kVtxCentral, kVtxNoEvent, kQVector,kTPCasPV,kZeroCont,kNVtxCuts};
+  enum {  kProcessedEvents = 0, // all events 
+kPhysSelEvents, // phys selected and not pile-up
+kAcceptedEvents, // events passing all cuts  
+kGoodVtx,// events with good veretx and   
+kVtxCentral, 
+kVtxNoEvent, 
+kQVector,
+kTPCasPV,
+kZeroCont,
+kNVtxCuts};
 enum {kDoNotCheckforSDD=0,kwithSDD,kwithoutSDD};       
 
   // Constructors
@@ -30,7 +41,7 @@ enum {kDoNotCheckforSDD=0,kwithSDD,kwithoutSDD};
 fIsSelected(0), fCentralityCutMin(0), fCentralityCutMax(0), fQVectorCutMin(0), fQVectorCutMax(0), fVertexCutMin(0), 
 fVertexCutMax(0), fMultiplicityCutMin(0), fMultiplicityCutMax(0), fMaxChi2perNDFforVertex(0),fMinRun(0),fMaxRun(0),fetarangeofmultiplicitycut(0.0),
 fHistoCuts(0),fHistoVtxBefSel(0),fHistoVtxAftSel(0),fHistoEtaBefSel(0),fHistoEtaAftSel(0),
-fHistoNChAftSel(0),fHistoQVector(0),fHistoEP(0), fHistoVtxAftSelwithoutZvertexCut(0),fHistoVtxalltriggerEventswithMCz(0),fHistoVtxAftSelwithoutZvertexCutusingMCz(0),fHistoRunNumbers(0),fHistoCentrality(0),fHistoMultiplicty(0)
+fHistoNChAftSel(0),fHistoQVector(0),fHistoEP(0), fHistoVtxAftSelwithoutZvertexCut(0),fHistoVtxalltriggerEventswithMCz(0),fHistoVtxAftSelwithoutZvertexCutusingMCz(0),fHistoRunNumbers(0),fHistoCentrality(0),fHistoMultiplicty(0),fAnalysisUtils(0)
 
 {}
   AliSpectraBothEventCuts(const char *name);
@@ -69,6 +80,8 @@ fHistoNChAftSel(0),fHistoQVector(0),fHistoEP(0), fHistoVtxAftSelwithoutZvertexCu
   void SetMaxChi2perNDFforVertex(Float_t cut) { fMaxChi2perNDFforVertex=cut;}
   void SetRunNumberRange(Int_t min,Int_t max); 
   void SetEtaRangeforMultiplictyCut(Float_t eta) {fetarangeofmultiplicitycut=eta;}
+  void  SetAnalysisUtils(AliAnalysisUtils* inAnalysisUtils){fAnalysisUtils=inAnalysisUtils;}
+  
   UInt_t GetTrackType()  const    { return fTrackBits;}
   TH1I * GetHistoCuts()         {  return fHistoCuts; }
   TH1F * GetHistoVtxBefSel()         {  return fHistoVtxBefSel; }
@@ -100,7 +113,7 @@ fHistoNChAftSel(0),fHistoQVector(0),fHistoEP(0), fHistoVtxAftSelwithoutZvertexCu
   Float_t  GetMultiplicityCutMin()  const {  return fMultiplicityCutMin; }
   Float_t  GetMultiplicityCutMax()  const {  return fMultiplicityCutMax; }
   Float_t GetMaxChi2perNDFforVertex() const {return fMaxChi2perNDFforVertex;}
-  
+   AliAnalysisUtils* GetAnalysisUtils() const {return fAnalysisUtils; }
 
 
   void InitHisto();    
@@ -141,7 +154,7 @@ fHistoNChAftSel(0),fHistoQVector(0),fHistoEP(0), fHistoVtxAftSelwithoutZvertexCu
   Float_t        fMaxChi2perNDFforVertex; // maximum value of Chi2perNDF of vertex
   Int_t           fMinRun;                //minmum run number                   
   Int_t          fMaxRun;                //maximum run number   
-  Float_t         fetarangeofmultiplicitycut; // eta range fot multipilicty cut 
+  Float_t         fetarangeofmultiplicitycut; // eta range fot multipilicty cut        
   TH1I            *fHistoCuts;        // Cuts statistics
   TH1F            *fHistoVtxBefSel;        // Vtx distr before event selection         
   TH1F            *fHistoVtxAftSel;        // Vtx distr after event selection
@@ -158,14 +171,13 @@ fHistoNChAftSel(0),fHistoQVector(0),fHistoEP(0), fHistoVtxAftSelwithoutZvertexCu
   TH1F            *fHistoRunNumbers;   // histogram of numbers of events per run
   TH2F                   *fHistoCentrality; // centrality histogram
   TH2F                   *fHistoMultiplicty; // multiplicty histogram
-                               
-
+  AliAnalysisUtils *fAnalysisUtils;// Analysis Utils which have pile-up cut
 
 
   AliSpectraBothEventCuts(const AliSpectraBothEventCuts&);
   AliSpectraBothEventCuts& operator=(const AliSpectraBothEventCuts&);
   
-  ClassDef(AliSpectraBothEventCuts, 9);
+  ClassDef(AliSpectraBothEventCuts, 10);
   
 };
 #endif
index 3b7bd01..90f047d 100644 (file)
@@ -68,7 +68,9 @@ fTrack(0),fCuts(0) {}
    TH3F * GetHistoNclustersQA() {return fHistoNclustersQA ;}
    TH3F * GetHistochi2perNDFQA() {return fHistochi2perNDFQA; }
    Bool_t GetUseTypeDependedTOFCut () {return fUseTypeDependedTOFCut;}
-                
+   AliESDtrackCuts* GetTrackCuts(){return fCuts;}
+                        
+
    void SetEta(Float_t etamin,Float_t etamax)   { fEtaCutMin = etamin;fEtaCutMax = etamax; }
    void SetDCA(Float_t dca)   { fDCACut = dca; }
    void SetP(Float_t p)       { fPCut = p; }
@@ -80,8 +82,7 @@ fTrack(0),fCuts(0) {}
    void SetHashitinSPD1 (Bool_t value) {fHashitinSPD1=value;}  
    void SetUsedAdditionalCuts (Bool_t value) {fusedadditionalcuts=value;}
    void SetPtTOFMatchingPartDepended(Float_t pion,Float_t kaon,Float_t proton);
-       
-   Float_t GetEtaMin()       const    { return fEtaCutMin; }
+     Float_t GetEtaMin()       const    { return fEtaCutMin; }
    Float_t GetEtaMax()       const    { return fEtaCutMax; }
    Float_t GetYMax()         const    { return fYCutMax; }
    Float_t GetYMin()         const    { return fYCutMin; }
@@ -138,8 +139,6 @@ fTrack(0),fCuts(0) {}
    AliSpectraBothTrackCuts& operator=(const AliSpectraBothTrackCuts&);
    void ConfigurePtTOFCut();   
   
-
    ClassDef(AliSpectraBothTrackCuts, 7);
 };
 #endif
-
index 2273f48..51cb29d 100644 (file)
@@ -120,18 +120,18 @@ TString pidmethods[3]={"TPC","TOF","TPCTOF"};
        Float_t mcvertexratio=fHistoVtxAftSelmc->Integral(-1,-1,"width")/fmc->GetParameter(0);
        */
        //Event cut histo 
-       TH1I* histodata=ecuts_data->GetHistoCuts();
-       TH1I* histomc=ecuts_mc->GetHistoCuts();
+       //TH1I* histodata=ecuts_data->GetHistoVtxAftSel();
+       //TH1I* histomc=ecuts_mc->GetHistoVtxAftSel();
        
-       Int_t events_data=histodata->GetBinContent(3);
-       Int_t events_mc=histomc->GetBinContent(3);
+       Int_t events_data=ecuts_data->GetHistoVtxAftSel()->GetEntries();
+       Int_t events_mc=ecuts_mc->GetHistoVtxAftSel()->GetEntries();
 
        if(events_data==0&&events_mc==0)
                return 0;
 
 
-       Float_t datavertexratio=((Float_t)(events_data))/((Float_t)histodata->GetBinContent(4));
-         Float_t mcvertexratio=((Float_t)(events_mc))/((Float_t)histomc->GetBinContent(4));
+       Float_t datavertexratio=((Float_t)(events_data))/((Float_t)ecuts_data->GetHistoVtxAftSelwithoutZvertexCut()->GetEntries());
+         Float_t mcvertexratio=((Float_t)(events_mc))/((Float_t)ecuts_mc->GetHistoVtxAftSelwithoutZvertexCut()->GetEntries());
         TH1F* fHistoEtaAftSeldata=(TH1F*)ecuts_data->GetHistoEtaAftSel();
         TH1F* fHistoEtaAftSelmc=(TH1F*)ecuts_mc->GetHistoEtaAftSel();
        flistcanvas->Add(plot_on_canvas("ETA",fHistoEtaAftSeldata,fHistoEtaAftSelmc));
@@ -162,7 +162,15 @@ TString pidmethods[3]={"TPC","TOF","TPCTOF"};
        TF1* badchunk=new TF1("badchunkfit","pol0",10,40);
        binzero->Fit("badchunkfit","R");
        Float_t badchunksfraction=badchunk->GetParameter(0);
-       cout<<"Bad chunks "<<badchunksfraction<<endl;   
+       cout<<"Bad chunks "<<badchunksfraction<<endl;
+       if(badchunksfraction<0.005)
+       {
+               badchunksfraction=0.0; //only applied if higer than 0.5%
+               cout<<"reset bad chunks correction"<<badchunksfraction<<endl;
+
+       }
+       
+       
        binzero->Draw("E1");
        flistcanvas->Add(cbc);
        if(TMath::Abs(hmul->GetEntries()/events_mc-1.0)>0.001)