Possibility of skipping IsEventSelected and check of MC generator (for ITS upgrade)
authordcaffarr <dcaffarr@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 9 Sep 2013 10:21:30 +0000 (10:21 +0000)
committerdcaffarr <dcaffarr@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 9 Sep 2013 10:21:30 +0000 (10:21 +0000)
PWGHF/vertexingHF/AliAnalysisTaskSECharmFraction.cxx
PWGHF/vertexingHF/AliAnalysisTaskSECharmFraction.h
PWGHF/vertexingHF/macros/AddTaskSECharmFraction.C

index 718d5cf..d4b564f 100644 (file)
@@ -51,6 +51,7 @@
 #include "AliAODInputHandler.h"
 #include "AliAnalysisManager.h"
 #include "AliNormalizationCounter.h"
+#include "AliVertexingHFUtils.h"
 
 class TCanvas;
 class TTree;
@@ -105,8 +106,11 @@ AliAnalysisTaskSECharmFraction::AliAnalysisTaskSECharmFraction()
   flistTghCutsBack(0),
   flistTghCutsFromB(0),
   flistTghCutsFromDstar(0),
-  flistTghCutsOther(0)
-  
+  flistTghCutsOther(0),
+  fVertUtil(0),
+  fselectForUpgrade(0),  
+  fskipEventSelection(kFALSE),
+  fZvtxUpgr(10.)
 {
   //Default constructor
 }
@@ -155,14 +159,17 @@ AliAnalysisTaskSECharmFraction::AliAnalysisTaskSECharmFraction()
       flistTghCutsBack(0),
       flistTghCutsFromB(0),
       flistTghCutsFromDstar(0),
-      flistTghCutsOther(0)
-   
-{
-  // Constructor
-  // Define input and output slots here
-  // Input slot #0 works with a TChain
-  // Output slot #0 writes into a TH1 container
+      flistTghCutsOther(0),
+      fVertUtil(0),
+      fselectForUpgrade(0),
+      fskipEventSelection(kFALSE),
+      fZvtxUpgr(10.)
+  {
+    // Constructor
+    
+    // Define input and output slots here
+    // Input slot #0 works with a TChain
+    // Output slot #0 writes into a TH1 container
 
   //Standard pt bin
   fnbins=SetStandardCuts(fptbins);// THIS TO SET NBINS AND BINNING
@@ -176,7 +183,7 @@ AliAnalysisTaskSECharmFraction::AliAnalysisTaskSECharmFraction()
   for(Int_t j=6;j<22;j++){
     DefineOutput(j, TList::Class());
   }
-
+  fVertUtil=new AliVertexingHFUtils();
   // Output slot for the Cut Objects 
   DefineOutput(22,AliRDHFCutsD0toKpi::Class());  //My private output
   DefineOutput(23,AliRDHFCutsD0toKpi::Class());  //My private output
@@ -228,7 +235,11 @@ AliAnalysisTaskSECharmFraction::AliAnalysisTaskSECharmFraction(const char *name,
     flistTghCutsBack(0),
     flistTghCutsFromB(0),
     flistTghCutsFromDstar(0),
-    flistTghCutsOther(0)
+    flistTghCutsOther(0),
+    fVertUtil(0),
+    fselectForUpgrade(0),
+    fskipEventSelection(kFALSE),
+    fZvtxUpgr(10.)
 {
   // Constructor
   if(fCutsTight){
@@ -255,7 +266,8 @@ AliAnalysisTaskSECharmFraction::AliAnalysisTaskSECharmFraction(const char *name,
     }
     SetPtBins(fCutsTight->GetNPtBins(),fCutsTight->GetPtBinLimits());   
   }
-  
+
+  fVertUtil=new AliVertexingHFUtils();
   // Output slot #0 writes into a TH1 container
   DefineOutput(1, TH1F::Class());
   DefineOutput(2, TH1F::Class());
@@ -399,7 +411,7 @@ AliAnalysisTaskSECharmFraction::~AliAnalysisTaskSECharmFraction()
     flistTghCutsOther=0;
   }
   
-  
+  delete   fVertUtil;
 }  
 
 
@@ -5461,40 +5473,48 @@ void AliAnalysisTaskSECharmFraction::UserExec(Option_t */*option*/)
   Int_t nSelectedloose=0, nSelectedtight=0; 
 
   Bool_t isEventSelTGHT=kTRUE,isEventSelLOOSE=kTRUE;
-  if(!fCutsTight->IsEventSelected(aod)){
-    isEventSelTGHT=kFALSE;
-    if(fCutsTight->GetWhyRejection()==1){ 
-      // rejected for pileup
-      fNentries->Fill(2);    
-    }
-    if(fCutsTight->GetWhyRejection()==6){
-      // |prim Vtx Zspd| > acceptable
-      fNentries->Fill(4);      
+  if(!fskipEventSelection){
+    if(!fCutsTight->IsEventSelected(aod)){
+      isEventSelTGHT=kFALSE;
+      if(fCutsTight->GetWhyRejection()==1){ 
+       // rejected for pileup
+       fNentries->Fill(2);    
+      }
+      if(fCutsTight->GetWhyRejection()==6){
+       // |prim Vtx Zspd| > acceptable
+       fNentries->Fill(4);      
+      }
+    }  
+    else {
+      fNentries->Fill(1);    
     }
-  }
-  else {
-    fNentries->Fill(1);    
-  }
-  if(!fCutsLoose->IsEventSelected(aod)){
-    isEventSelLOOSE=kFALSE;
-    if(fCutsLoose->GetWhyRejection()==1){
-      // rejected for pileup    
-      fNentries->Fill(9);
-      
+    if(!fCutsLoose->IsEventSelected(aod)){
+      isEventSelLOOSE=kFALSE;
+      if(fCutsLoose->GetWhyRejection()==1){
+       // rejected for pileup    
+       fNentries->Fill(9);
+       
+      }
+      if(fCutsLoose->GetWhyRejection()==6){
+       // |prim Vtx Z| > acceptable
+       fNentries->Fill(11);      
+      }
     }
-    if(fCutsLoose->GetWhyRejection()==6){
-      // |prim Vtx Z| > acceptable
-      fNentries->Fill(11);      
+    else {
+      fNentries->Fill(8);    
     }
-  }
-  else {
-    fNentries->Fill(8);    
-  }
-  
-  if(!(isEventSelTGHT||isEventSelLOOSE)){
+    
+    if(!(isEventSelTGHT||isEventSelLOOSE)){
       PostData(1,fNentries);
       return;
+    }
   }
+  else{
+    fCutsTight->SetupPID(aod);
+    // SHOULD ADD RECOMPUTATION OF PRIMARY VERTEX DONE AT THE BEGINNING OF IS EVENT SELECTED??
+    // LIKELY NOT NEEDE
+  }
+
   // fix for temporary bug in ESDfilter
   // the AODs with null vertex pointer didn't pass the PhysSel
   if(!aod->GetPrimaryVertex() || TMath::Abs(aod->GetMagneticField())<0.001){
@@ -5513,10 +5533,21 @@ void AliAnalysisTaskSECharmFraction::UserExec(Option_t */*option*/)
   }
   else {
     PostData(1,fNentries);
-    return;
-    
+    return;    
+  }
+  if(fskipEventSelection){
+    //check z of the primary vertex for the cases in which the z vtx > maximum
+    if(TMath::Abs(vtx1->GetZ())>fZvtxUpgr){
+       fNentries->Fill(4);      
+       fNentries->Fill(11);      
+       PostData(1,fNentries);
+       return;
+    }
+    else {
+      fNentries->Fill(1);    
+      fNentries->Fill(8);    
+    }
   }
-
   // FILL n-tracks counter
   if(isEventSelTGHT)fNentries->Fill(5,aod->GetNumberOfTracks());
   if(isEventSelLOOSE)fNentries->Fill(12,aod->GetNumberOfTracks());
@@ -5651,7 +5682,8 @@ void AliAnalysisTaskSECharmFraction::UserExec(Option_t */*option*/)
     //       d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
     //       unsetvtx=kTRUE;
     //     }
-
+    
+    
     //recalculate vertex w/o daughters
     AliAODVertex *origownvtx=0x0;
     if(fCleanCandOwnVtx){      
@@ -5706,7 +5738,41 @@ void AliAnalysisTaskSECharmFraction::UserExec(Option_t */*option*/)
 
     // INVESTIGATE SIGNAL TYPE : ACCESS TO MC INFORMATION
     if(fReadMC){
-      aodDMC=GetD0toKPiSignalType(d,arrayMC,signallevel,massmumtrue,vtxTrue);
+      if(fselectForUpgrade){
+       TString nameGen;        
+       Int_t generator=0;// adding per track: -1 hijing; 0-pythiaHF; 2-the rest  --> -2= pure hijing -> back ok (but check identity); 0= phytia,pythia-> ok for checking signal; reject the rest: -1 (Hij,pyt), 1 (hij, rest), 2 (pythia,rest) ,4 (rest,rest) 
+       for(Int_t jp=0;jp<2;jp++){
+         AliAODTrack *daughA=(AliAODTrack*)d->GetDaughter(0);
+         fVertUtil->GetTrackPrimaryGenerator(daughA,aodmcHeader,arrayMC,nameGen);
+         if(nameGen.Contains("ijing")){
+           generator+=-1;
+         }
+         else if(!nameGen.Contains("pythia")){
+           generator+=2;
+         }
+       }
+       if(generator==-2){
+         Int_t pdgdaughters[2]={211,321};
+         Int_t labMum=d->MatchToMC(421,arrayMC,2,pdgdaughters);
+         if(labMum<0)signallevel=-1;
+         else signallevel=-2;
+       }
+       else if (generator==0){
+         aodDMC=GetD0toKPiSignalType(d,arrayMC,signallevel,massmumtrue,vtxTrue);
+       }
+       else{
+         signallevel=-3;
+       }
+       if(fVertUtil->IsCandidateInjected(d,aodmcHeader,arrayMC)){
+         //      Printf("The candidate is injected and generator is : %d",generator);
+       }
+       else {
+         //      Printf("The candidate is not injected and generator is : %d",generator);
+       }
+      }      
+      else {
+       aodDMC=GetD0toKPiSignalType(d,arrayMC,signallevel,massmumtrue,vtxTrue);
+      }
     }
     else signallevel=0;
     //   ACCOUNT FOR ETA & ITS CLUSTER SELECTION
@@ -6510,18 +6576,19 @@ AliAODRecoDecayHF* AliAnalysisTaskSECharmFraction::GetD0toKPiSignalType(const Al
     signaltype=-1;
     return aodDMC;    
   }
+  
 
   if(labMum<0){
     signaltype=-1;
     return aodDMC;    
   }
-
+  
   // get daughter AOD tracks
   AliAODTrack *trk0 = (AliAODTrack*)d->GetDaughter(0);
   AliAODTrack *trk1 = (AliAODTrack*)d->GetDaughter(1);
  
   if(trk0==0x0||trk1==0x0){
-    AliDebug(2,"Delete tracks I AM \n");
+    AliDebug(2,"null daughter tracks \n");
   
     signaltype=-1;
     return aodDMC;
index 94fb9fc..7ded106 100644 (file)
@@ -23,6 +23,7 @@ class AliAODMCParticle;
 class AliAnalysisVertexingHF;\r
 class AliRDHFCutsD0toKpi;\r
 class AliNormalizationCounter;\r
+class AliVertexingHFUtils;\r
 \r
 #include "AliAnalysisTaskSE.h"\r
 \r
@@ -75,7 +76,9 @@ class AliAnalysisTaskSECharmFraction : public AliAnalysisTaskSE {
   void FillAziHistos(AliAODRecoDecayHF2Prong *d,TList *&list,Int_t ptbin,Double_t azilist[30000],Int_t trkIDlist[30000],Int_t nprim,Int_t okD0,Int_t okD0bar,Bool_t isPeakD0,Bool_t isPeakD0bar,Bool_t isSideBandD0,Bool_t isSideBandD0bar)const;\r
 \r
   AliAODVertex* GetPrimaryVtxSkipped(AliAODEvent *aodev,AliAODRecoDecayHF2Prong *d);\r
\r
+  void SetRejecCandidateMCUpgrade(Bool_t selection){fselectForUpgrade=selection;}\r
+  void SetSkipEventSelection(Bool_t skip){fskipEventSelection=skip;}\r
+  void SetMaxZvtxForSkipEventSelection(Double_t zmax){fZvtxUpgr=zmax;}\r
   /* ######### THE FOLLOWING IS FOR FURTHER IMPLEMENATION ############\r
      Int_t GetPtBin(Double_t pt)const;\r
      void SetD0Cuts(Int_t ptbin,Double_t &*d0cutsLoose,Double_t &*d0cutsTight);\r
@@ -152,6 +155,10 @@ class AliAnalysisTaskSECharmFraction : public AliAnalysisTaskSE {
   TList *flistTghCutsFromB;               //!TList for D from B or D from Dstar from Bwith tight cuts, container 18\r
   TList *flistTghCutsFromDstar;               //!TList for D from Dstar Dstar with tight cuts, container 19\r
   TList *flistTghCutsOther;               //!TList for others with tight cuts, container 20\r
+  AliVertexingHFUtils *fVertUtil;         // vertexing HF Util\r
+  Bool_t fselectForUpgrade;               // switch to reject candidates from HIJING and not Pythia for upgrade studies\r
+  Bool_t fskipEventSelection;               // switch to skip event selection (for upgrade studies)\r
+  Double_t fZvtxUpgr;                       // cut value on max zvtx used ONLY if fskipEventSelection is kTRUE\r
   /*  Bool_t       fD0usecuts;            // Switch on the use of the cuts             TO BE IMPLEMENTED \r
       Bool_t       fcheckMC;              //  Switch on MC check: minimum check is same mother  TO BE IMPLEMENTED\r
       Bool_t       fcheckMCD0;           //  check the mother is a D0                  TO BE IMPLEMENTED\r
@@ -166,7 +173,7 @@ class AliAnalysisTaskSECharmFraction : public AliAnalysisTaskSE {
   AliAnalysisTaskSECharmFraction(const AliAnalysisTaskSECharmFraction&); // not implemented\r
   AliAnalysisTaskSECharmFraction& operator=(const AliAnalysisTaskSECharmFraction&); // not implemented\r
   \r
-  ClassDef(AliAnalysisTaskSECharmFraction,4); // analysis task for prompt charm fraction\r
+  ClassDef(AliAnalysisTaskSECharmFraction,5); // analysis task for prompt charm fraction\r
 };\r
 \r
 #endif\r
index d5c5bbb..11144aa 100644 (file)
@@ -1,4 +1,4 @@
-AliAnalysisTaskSECharmFraction* AddTaskSECharmFraction(TString fileout="d0D0.root",Int_t *switchMC=0x0,Bool_t readmc=kFALSE,Bool_t usepid=kTRUE,Bool_t likesign=kFALSE,TString cutfile="D0toKpiCharmFractCuts.root",TString containerprefix="c",Int_t ppPbPb=0,Int_t analysLevel=2, Float_t minC=0., Float_t maxC=7.5,Float_t minCloose=20., Float_t maxCloose=50.,Bool_t checkBitD0=kTRUE)
+AliAnalysisTaskSECharmFraction* AddTaskSECharmFraction(TString fileout="d0D0.root",Int_t *switchMC=0x0,Int_t readmc=0,Bool_t usepid=kTRUE,Bool_t likesign=kFALSE,TString cutfile="D0toKpiCharmFractCuts.root",TString containerprefix="c",Int_t ppPbPb=0,Int_t analysLevel=2, Float_t minC=0., Float_t maxC=7.5,Float_t minCloose=20., Float_t maxCloose=50.,Bool_t checkBitD0=kTRUE)
 {  
   //
   // Configuration macro for the task to analyze the fraction of prompt charm
@@ -93,7 +93,13 @@ AliAnalysisTaskSECharmFraction* AddTaskSECharmFraction(TString fileout="d0D0.roo
     // ctight->SetUseDefaultPID(kTRUE);
   }
 
-  hfTask->SetReadMC(readmc);
+  if(readmc>0)hfTask->SetReadMC(kTRUE);
+  if(readmc==2){
+    hfTask->SetRejecCandidateMCUpgrade(kTRUE);
+    hfTask->SetSkipEventSelection(kTRUE);
+    hfTask->SetMaxZvtxForSkipEventSelection(10.);
+  }
+
   hfTask->SetNMaxTrForVtx(2);
   hfTask->SetAnalyzeLikeSign(likesign);
   hfTask->SetUsePID(usepid);