Adding cut on pythia process type
authormchojnac <Marek.Chojnacki@cern.ch>
Mon, 17 Nov 2014 18:49:15 +0000 (19:49 +0100)
committermchojnac <Marek.Chojnacki@cern.ch>
Mon, 17 Nov 2014 18:50:06 +0000 (19:50 +0100)
PWGLF/SPECTRA/PiKaPr/TestAOD/AliAnalysisTaskSpectraBoth.cxx
PWGLF/SPECTRA/PiKaPr/TestAOD/AliSpectraBothEventCuts.cxx
PWGLF/SPECTRA/PiKaPr/TestAOD/AliSpectraBothEventCuts.h

index 15e049a..af9348a 100644 (file)
@@ -113,6 +113,13 @@ void AliAnalysisTaskSpectraBoth::UserExec(Option_t *)
        }
        else
                AliFatal("Not processing AODs or ESDS") ;
+       if(fIsMC)
+       {               
+               if(!fEventCuts->CheckMCProcessType(MCEvent()))
+                       return ;                
+       }
+
+
        if(fdotheMCLoopAfterEventCuts)
                if(!fEventCuts->IsSelected(fAOD,fTrackCuts,fIsMC,-100,fHistMan->GetEventStatHist()))
                        return;//event selection
index 87b75e5..4a9c90b 100644 (file)
@@ -38,6 +38,7 @@
 #include "AliSpectraBothTrackCuts.h"
 #include "AliAnalysisUtils.h"
 #include "AliPPVsMultUtils.h"  
+#include "AliGenPythiaEventHeader.h"
 //#include "AliSpectraBothHistoManager.h"
 #include <iostream>
 
@@ -48,6 +49,7 @@ ClassImp(AliSpectraBothEventCuts)
 AliSpectraBothEventCuts::AliSpectraBothEventCuts(const char *name) : TNamed(name, "AOD Event Cuts"), fAOD(0),fAODEvent(AliSpectraBothTrackCuts::kAODobject), fTrackBits(0),fIsMC(0),fCentEstimator(""), fUseCentPatchAOD049(0), fUseSDDPatchforLHC11a(kDoNotCheckforSDD),fTriggerSettings(AliVEvent::kMB),fTrackCuts(0),
 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),fUseAliPPVsMultUtils(false),
+fNMCProcessType(0),fEventMCProcessType(0),fEventMCProcessTypeIncluded(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),fAnalysisUtils(0),fAliPPVsMultUtils(0)
@@ -83,7 +85,7 @@ fHistoCentrality(0),fHistoMultiplicty(0),fAnalysisUtils(0),fAliPPVsMultUtils(0)
   fMultiplicityCutMax=-1.0;
   fTrackBits=1;
   fCentEstimator="V0M";
-  fMaxChi2perNDFforVertex=-1;
+  fMaxChi2perNDFforVertex=-1;  
  // TH1::AddDirectory(oldStatus);      
 }
 //______________________________________________________
@@ -122,6 +124,8 @@ AliSpectraBothEventCuts::~AliSpectraBothEventCuts()
                delete fAnalysisUtils;
        if(fAliPPVsMultUtils)
                delete fAliPPVsMultUtils;
+       if(fEventMCProcessType)
+               delete [] fEventMCProcessType;
 
 }
 //______________________________________________________
@@ -400,7 +404,7 @@ Bool_t AliSpectraBothEventCuts::CheckMultiplicityCut()
                return kFALSE;   
 
    fHistoMultiplicty->Fill(0.5,Ncharged);
-   if(Ncharged>=fMultiplicityCutMin && Ncharged<fMultiplicityCutMax&& Ncharged>0)
+   if(Ncharged>=fMultiplicityCutMin && Ncharged<fMultiplicityCutMax)
    { 
        fHistoMultiplicty->Fill(1.5,Ncharged);
        return kTRUE;
@@ -681,3 +685,50 @@ void AliSpectraBothEventCuts::SetRunNumberRange(Int_t min, Int_t max)
                 fMaxRun=max;
        }
 }
+//__________________________________________________________________________________________________________
+Bool_t AliSpectraBothEventCuts::CheckMCProcessType(AliMCEvent* mcevent)
+{
+       if(fNMCProcessType<0)
+               return kTRUE;
+       if(!mcevent)
+               return kFALSE;
+       AliHeader* aHeader=mcevent->Header();
+       if(!aHeader)
+               return kFALSE;
+       AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(aHeader->GenEventHeader());
+       if(!pythiaGenHeader)
+               return kFALSE;  
+       Int_t processtype=pythiaGenHeader->ProcessType();
+       for(int i=0;i<fNMCProcessType;i++)
+       {
+               if(fEventMCProcessType[i]<0)
+                       continue;
+               if (processtype==fEventMCProcessType[i])
+                       return fEventMCProcessTypeIncluded;
+       }
+       return !fEventMCProcessTypeIncluded;
+}
+//_____________________________________________________________________________________________________________
+void AliSpectraBothEventCuts::SetNMCProcessType(Int_t flag) 
+{
+       fNMCProcessType=flag;
+       if(fEventMCProcessType)
+               delete [] fEventMCProcessType;
+       
+       fEventMCProcessType= new Int_t[fNMCProcessType];
+       if(!fEventMCProcessType)
+       {
+               fNMCProcessType=-1;
+               return;
+       }
+       for(int i=0;i<fNMCProcessType;i++)
+               fEventMCProcessType[i]=-1.0;
+       return;
+}
+//________________________________________________________________________________________________________________________
+void AliSpectraBothEventCuts::AddMCProcessType(Int_t type,Int_t index)
+{
+       if(index<fNMCProcessType)
+               fEventMCProcessType[index]=type;
+}
+
index f51ab79..af56833 100644 (file)
@@ -41,10 +41,13 @@ enum {kDoNotCheckforSDD=0,kwithSDD,kwithoutSDD};
  AliSpectraBothEventCuts() : TNamed(), fAOD(0),fAODEvent(AliSpectraBothTrackCuts::kAODobject),fTrackBits(0), fIsMC(0), fCentEstimator(""), fUseCentPatchAOD049(0),fUseSDDPatchforLHC11a(kDoNotCheckforSDD),fTriggerSettings(AliVEvent::kMB),fTrackCuts(0),
 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),fUseAliPPVsMultUtils(false),
+fNMCProcessType(-1),fEventMCProcessType(0),fEventMCProcessTypeIncluded(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),fAnalysisUtils(0),fAliPPVsMultUtils(0)
 
-{}
+{
+
+}
   AliSpectraBothEventCuts(const char *name);
   virtual ~AliSpectraBothEventCuts();// {}
   
@@ -70,6 +73,7 @@ fHistoNChAftSel(0),fHistoQVector(0),fHistoEP(0), fHistoVtxAftSelwithoutZvertexCu
   Bool_t CheckMultiplicityCut();
   Bool_t CheckQVectorCut();
   Bool_t CheckVtxChi2perNDF();
+  Bool_t CheckMCProcessType(AliMCEvent* mcevent);      
   void  SetCentralityCutMin(Float_t cut)  { fCentralityCutMin = cut; }
   void  SetCentralityCutMax(Float_t cut)  { fCentralityCutMax = cut; }
   //void  SetQVectorPosCut(Float_t min,Float_t max)  { fQVectorPosCutMin = min; fQVectorPosCutMax = max; }
@@ -83,7 +87,9 @@ fHistoNChAftSel(0),fHistoQVector(0),fHistoEP(0), fHistoVtxAftSelwithoutZvertexCu
   void SetEtaRangeforMultiplictyCut(Float_t eta) {fetarangeofmultiplicitycut=eta;}
   void  SetAnalysisUtils(AliAnalysisUtils* inAnalysisUtils){fAnalysisUtils=inAnalysisUtils;}
   void SetUseAliPPVsMultUtils(Bool_t flag){fUseAliPPVsMultUtils=flag;} 
+  void  SetEventMCProcessTypeIncluded(Bool_t flag) {fEventMCProcessTypeIncluded=flag;}
+  void SetNMCProcessType(Int_t flag); 
+   void AddMCProcessType(Int_t type,Int_t index);
   UInt_t GetTrackType()  const    { return fTrackBits;}
   TH1I * GetHistoCuts()         {  return fHistoCuts; }
   TH1F * GetHistoVtxBefSel()         {  return fHistoVtxBefSel; }
@@ -117,6 +123,10 @@ fHistoNChAftSel(0),fHistoQVector(0),fHistoEP(0), fHistoVtxAftSelwithoutZvertexCu
   Float_t GetMaxChi2perNDFforVertex() const {return fMaxChi2perNDFforVertex;}
    AliAnalysisUtils* GetAnalysisUtils() const {return fAnalysisUtils; }
 Bool_t GetUseAliPPVsMultUtils() const {return fUseAliPPVsMultUtils;} 
+ Int_t  GetNMCProcessType() const { return fNMCProcessType;}
+ Bool_t  GetEventMCProcessTypeIncluded(Bool_t flag) const {return flag;}
+
+
 
   void InitHisto();    
   void   PrintCuts();
@@ -157,7 +167,10 @@ Bool_t GetUseAliPPVsMultUtils() const {return fUseAliPPVsMultUtils;}
   Int_t           fMinRun;                //minmum run number                   
   Int_t          fMaxRun;                //maximum run number   
   Float_t         fetarangeofmultiplicitycut; // eta range fot multipilicty cut 
-  Bool_t         fUseAliPPVsMultUtils;   // use  AliPPVsMultUtils for centrailty                       
+  Bool_t         fUseAliPPVsMultUtils;   // use  AliPPVsMultUtils for centrailty 
+  Int_t           fNMCProcessType;  // to include or exlude 
+  Int_t          *fEventMCProcessType;   //[fNMCProcessType] process typ cut                             
+  Bool_t         fEventMCProcessTypeIncluded; // if false those process are excluded if true they are included  
   TH1I            *fHistoCuts;        // Cuts statistics
   TH1F            *fHistoVtxBefSel;        // Vtx distr before event selection         
   TH1F            *fHistoVtxAftSel;        // Vtx distr after event selection
@@ -180,7 +193,7 @@ Bool_t GetUseAliPPVsMultUtils() const {return fUseAliPPVsMultUtils;}
   AliSpectraBothEventCuts(const AliSpectraBothEventCuts&);
   AliSpectraBothEventCuts& operator=(const AliSpectraBothEventCuts&);
   
-  ClassDef(AliSpectraBothEventCuts, 12);
+  ClassDef(AliSpectraBothEventCuts, 13);
   
 };
 #endif