]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Add event count histogram
authorsaiola <salvatore.aiola@cern.ch>
Sat, 18 Oct 2014 03:44:03 +0000 (23:44 -0400)
committersaiola <salvatore.aiola@cern.ch>
Sat, 18 Oct 2014 03:44:03 +0000 (23:44 -0400)
PWG/EMCAL/AliAnalysisTaskEmcal.cxx
PWG/EMCAL/AliAnalysisTaskEmcal.h

index 686ee2293aa8f0f50c009bfd457ae7e7db29c82e..06ed828d5ae5c20caf1498ec1ab80e4fc2f2c712 100644 (file)
@@ -1,8 +1,8 @@
-// $Id$
 //
 // Emcal base analysis task.
 //
 // Author: S.Aiola, M. Verweij
+
 #include "AliAnalysisTaskEmcal.h"
 
 #include <TClonesArray.h>
@@ -100,6 +100,7 @@ AliAnalysisTaskEmcal::AliAnalysisTaskEmcal() :
   fMainTriggerPatch(0x0),
   fTriggers(0),
   fOutput(0),
+  fHistEventCount(0),
   fHistTrialsAfterSel(0),
   fHistEventsAfterSel(0),
   fHistXsectionAfterSel(0),
@@ -182,6 +183,7 @@ AliAnalysisTaskEmcal::AliAnalysisTaskEmcal(const char *name, Bool_t histo) :
   fMainTriggerPatch(0x0),
   fTriggers(0),
   fOutput(0),
+  fHistEventCount(0),
   fHistTrialsAfterSel(0),
   fHistEventsAfterSel(0),
   fHistXsectionAfterSel(0),
@@ -357,22 +359,28 @@ void AliAnalysisTaskEmcal::UserCreateOutputObjects()
   fHistEventPlane->GetYaxis()->SetTitle("counts");
   fOutput->Add(fHistEventPlane);
 
-  fHistEventRejection = new TH1I("fHistEventRejection","Reasons to reject event",20,0,20);
-  fHistEventRejection->Fill("PhysSel",0);
-  fHistEventRejection->Fill("trigger",0);
-  fHistEventRejection->Fill("trigTypeSel",0);
-  fHistEventRejection->Fill("Cent",0);
-  fHistEventRejection->Fill("vertex contr.",0);
-  fHistEventRejection->Fill("Vz",0);
-  fHistEventRejection->Fill("trackInEmcal",0);
-  fHistEventRejection->Fill("minNTrack",0);
-  fHistEventRejection->Fill("VtxSel2013pA",0);
-  fHistEventRejection->Fill("PileUp",0);
-  fHistEventRejection->Fill("EvtPlane",0);
-  fHistEventRejection->Fill("SelPtHardBin",0);
+  fHistEventRejection = new TH1F("fHistEventRejection","Reasons to reject event",20,0,20);
+  fHistEventRejection->GetXaxis()->SetBinLabel(1,"PhysSel");
+  fHistEventRejection->GetXaxis()->SetBinLabel(2,"trigger");
+  fHistEventRejection->GetXaxis()->SetBinLabel(3,"trigTypeSel");
+  fHistEventRejection->GetXaxis()->SetBinLabel(4,"Cent");
+  fHistEventRejection->GetXaxis()->SetBinLabel(5,"vertex contr.");
+  fHistEventRejection->GetXaxis()->SetBinLabel(6,"Vz");
+  fHistEventRejection->GetXaxis()->SetBinLabel(7,"trackInEmcal");
+  fHistEventRejection->GetXaxis()->SetBinLabel(8,"minNTrack");
+  fHistEventRejection->GetXaxis()->SetBinLabel(9,"VtxSel2013pA");
+  fHistEventRejection->GetXaxis()->SetBinLabel(10,"PileUp");
+  fHistEventRejection->GetXaxis()->SetBinLabel(11,"EvtPlane");
+  fHistEventRejection->GetXaxis()->SetBinLabel(12,"SelPtHardBin");
   fHistEventRejection->GetYaxis()->SetTitle("counts");
   fOutput->Add(fHistEventRejection);
 
+  fHistEventCount = new TH1F("fHistEventCount","fHistEventCount",2,0,2);
+  fHistEventCount->GetXaxis()->SetBinLabel(1,"Accepted");
+  fHistEventCount->GetXaxis()->SetBinLabel(2,"Rejected");
+  fHistEventCount->GetYaxis()->SetTitle("counts");
+  fOutput->Add(fHistEventCount);
+
   PostData(1, fOutput);
 }
 
@@ -409,8 +417,13 @@ void AliAnalysisTaskEmcal::UserExec(Option_t *)
   if (!RetrieveEventObjects())
     return;
 
-  if (!IsEventSelected()) 
+  if (IsEventSelected()) {
+    if (fGeneralHistograms) fHistEventCount->Fill("Accepted",1);
+  }
+  else {
+    if (fGeneralHistograms) fHistEventCount->Fill("Rejected",1);
     return;
+  }
 
   if (fGeneralHistograms && fCreateHisto) {
     if (!FillGeneralHistograms())
@@ -707,51 +720,53 @@ AliAnalysisTaskEmcal::BeamType AliAnalysisTaskEmcal::GetBeamType()
 }
 
 //________________________________________________________________________
-ULong_t AliAnalysisTaskEmcal::GetTriggerList(){
-         if (!fTriggerPatchInfo)
-           return 0;
-
-         //number of patches in event
-         Int_t nPatch = fTriggerPatchInfo->GetEntries();
-
-         //loop over patches to define trigger type of event
-         Int_t nG1 = 0;
-         Int_t nG2 = 0;
-         Int_t nJ1 = 0;
-         Int_t nJ2 = 0;
-         AliEmcalTriggerPatchInfo *patch;
-         for (Int_t iPatch = 0; iPatch < nPatch; iPatch++) {
-           patch = (AliEmcalTriggerPatchInfo*)fTriggerPatchInfo->At( iPatch );
-           if (patch->IsGammaHigh()) nG1++;
-           if (patch->IsGammaLow())  nG2++;
-           if (patch->IsJetHigh()) nJ1++;
-           if (patch->IsJetLow())  nJ2++;
-         }
+ULong_t AliAnalysisTaskEmcal::GetTriggerList()
+{
+  if (!fTriggerPatchInfo)
+    return 0;
+
+  //number of patches in event
+  Int_t nPatch = fTriggerPatchInfo->GetEntries();
 
-         AliDebug(2, "Patch summary: ");
-         AliDebug(2, Form("Number of patches: %d", nPatch));
-         AliDebug(2, Form("Jet:   low[%d], high[%d]" ,nJ2, nJ1));
-         AliDebug(2, Form("Gamma: low[%d], high[%d]" ,nG2, nG1));
-
-         ULong_t triggers(0);
-         if (nG1>0)
-               SETBIT(triggers, kG1);
-         if (nG2>0)
-               SETBIT(triggers, kG2);
-         if (nJ1>0)
-               SETBIT(triggers, kJ1);
-         if (nJ2>0)
-               SETBIT(triggers, kJ2);
-         return triggers;
+  //loop over patches to define trigger type of event
+  Int_t nG1 = 0;
+  Int_t nG2 = 0;
+  Int_t nJ1 = 0;
+  Int_t nJ2 = 0;
+  AliEmcalTriggerPatchInfo *patch;
+  for (Int_t iPatch = 0; iPatch < nPatch; iPatch++) {
+    patch = (AliEmcalTriggerPatchInfo*)fTriggerPatchInfo->At( iPatch );
+    if (patch->IsGammaHigh()) nG1++;
+    if (patch->IsGammaLow())  nG2++;
+    if (patch->IsJetHigh()) nJ1++;
+    if (patch->IsJetLow())  nJ2++;
+  }
+
+  AliDebug(2, "Patch summary: ");
+  AliDebug(2, Form("Number of patches: %d", nPatch));
+  AliDebug(2, Form("Jet:   low[%d], high[%d]" ,nJ2, nJ1));
+  AliDebug(2, Form("Gamma: low[%d], high[%d]" ,nG2, nG1));
+
+  ULong_t triggers(0);
+  if (nG1>0)
+    SETBIT(triggers, kG1);
+  if (nG2>0)
+    SETBIT(triggers, kG2);
+  if (nJ1>0)
+    SETBIT(triggers, kJ1);
+  if (nJ2>0)
+    SETBIT(triggers, kJ2);
+  return triggers;
 }
 
 //________________________________________________________________________
-Bool_t AliAnalysisTaskEmcal::HasTriggerType(TriggerType t){
-       // Check if event has a given trigger type
-       if(t == kND){
-               return fTriggers == 0;
-       }
-       return TESTBIT(fTriggers, int(t));
+Bool_t AliAnalysisTaskEmcal::HasTriggerType(TriggerType t)
+{
+  // Check if event has a given trigger type
+  if(t == kND){
+    return fTriggers == 0;
+  }
+  return TESTBIT(fTriggers, int(t));
 }
 
 //________________________________________________________________________
@@ -771,8 +786,7 @@ Bool_t AliAnalysisTaskEmcal::IsEventSelected()
       }
     }
     if ((res & fOffTrigger) == 0) {
-      if (fGeneralHistograms) 
-       fHistEventRejection->Fill("PhysSel",1);
+      if (fGeneralHistograms) fHistEventRejection->Fill("PhysSel",1);
       return kFALSE;
     }
   }
@@ -789,14 +803,12 @@ Bool_t AliAnalysisTaskEmcal::IsEventSelected()
       }
     }
     if (!fired.Contains("-B-")) {
-      if (fGeneralHistograms) 
-       fHistEventRejection->Fill("trigger",1);
+      if (fGeneralHistograms) fHistEventRejection->Fill("trigger",1);
       return kFALSE;
     }
     TObjArray *arr = fTrigClass.Tokenize("|");
     if (!arr) {
-      if (fGeneralHistograms) 
-       fHistEventRejection->Fill("trigger",1);
+      if (fGeneralHistograms) fHistEventRejection->Fill("trigger",1);
       return kFALSE;
     }
     Bool_t match = 0;
@@ -811,24 +823,21 @@ Bool_t AliAnalysisTaskEmcal::IsEventSelected()
     }
     delete arr;
     if (!match) {
-      if (fGeneralHistograms) 
-       fHistEventRejection->Fill("trigger",1);
+      if (fGeneralHistograms) fHistEventRejection->Fill("trigger",1);
       return kFALSE;
     }
   }
 
   if (fTriggerTypeSel != kND) {
     if (!HasTriggerType(fTriggerTypeSel)) {
-      if (fGeneralHistograms) 
-       fHistEventRejection->Fill("trigTypeSel",1);
+      if (fGeneralHistograms) fHistEventRejection->Fill("trigTypeSel",1);
       return kFALSE;
     }
   }
 
   if ((fMinCent != -999) && (fMaxCent != -999)) {
     if (fCent<fMinCent || fCent>fMaxCent) {
-      if (fGeneralHistograms) 
-       fHistEventRejection->Fill("Cent",1);
+      if (fGeneralHistograms) fHistEventRejection->Fill("Cent",1);
       return kFALSE;
     }
   }
@@ -842,27 +851,24 @@ Bool_t AliAnalysisTaskEmcal::IsEventSelected()
     if(fMinVz>10.)  fMaxVz = 10.;
 
     if (!fAliAnalysisUtils->IsVertexSelected2013pA(InputEvent())) {
-      if (fGeneralHistograms) 
-       fHistEventRejection->Fill("VtxSel2013pA",1);
+      if (fGeneralHistograms) fHistEventRejection->Fill("VtxSel2013pA",1);
       return kFALSE;
     }
 
     if (fAliAnalysisUtils->IsPileUpEvent(InputEvent())) {
-      fHistEventRejection->Fill("PileUp",1);
+      if (fGeneralHistograms) fHistEventRejection->Fill("PileUp",1);
       return kFALSE;
     }
   }
 
   if ((fMinVz != -999) && (fMaxVz != -999)) {
     if (fNVertCont == 0 ) {
-      if (fGeneralHistograms) 
-       fHistEventRejection->Fill("vertex contr.",1);
+      if (fGeneralHistograms) fHistEventRejection->Fill("vertex contr.",1);
       return kFALSE;
     }
     Double_t vz = fVertex[2];
     if (vz<fMinVz || vz>fMaxVz) {
-      if (fGeneralHistograms) 
-       fHistEventRejection->Fill("Vz",1);
+      if (fGeneralHistograms) fHistEventRejection->Fill("Vz",1);
       return kFALSE;
     }
   }
@@ -891,8 +897,7 @@ Bool_t AliAnalysisTaskEmcal::IsEventSelected()
       }
     }
     if (!trackInEmcalOk) {
-      if (fGeneralHistograms) 
-       fHistEventRejection->Fill("trackInEmcal",1);
+      if (fGeneralHistograms) fHistEventRejection->Fill("trackInEmcal",1);
       return kFALSE;
     }
   }
@@ -911,8 +916,7 @@ Bool_t AliAnalysisTaskEmcal::IsEventSelected()
       }
     }
     if (nTracksAcc<fMinNTrack) {
-      if (fGeneralHistograms) 
-       fHistEventRejection->Fill("minNTrack",1);
+      if (fGeneralHistograms) fHistEventRejection->Fill("minNTrack",1);
       return kFALSE;
     }
   }
@@ -921,17 +925,15 @@ Bool_t AliAnalysisTaskEmcal::IsEventSelected()
       !(fEPV0 + TMath::Pi() > fMinEventPlane && fEPV0 + TMath::Pi() <= fMaxEventPlane) &&
       !(fEPV0 - TMath::Pi() > fMinEventPlane && fEPV0 - TMath::Pi() <= fMaxEventPlane)) 
     {
-      if (fGeneralHistograms) 
-       fHistEventRejection->Fill("EvtPlane",1);
+      if (fGeneralHistograms) fHistEventRejection->Fill("EvtPlane",1);
       return kFALSE;
     }
 
   if (fSelectPtHardBin != -999 && fSelectPtHardBin != fPtHardBin)  {
-      if (fGeneralHistograms) 
-       fHistEventRejection->Fill("SelPtHardBin",1);
+      if (fGeneralHistograms) fHistEventRejection->Fill("SelPtHardBin",1);
       return kFALSE;
     }
-
+  
   return kTRUE;
 }
 
index d3de1b4c25ccfb6f11a553873ed1563a0fe9cdbb..14c4319920e19a2d3d7f7e0722106373e99c4d9d 100644 (file)
@@ -174,9 +174,10 @@ class AliAnalysisTaskEmcal : public AliAnalysisTaskSE {
   TObjArray                   fParticleCollArray;          // particle/track collection array
   TObjArray                   fClusterCollArray;           // cluster collection array
   AliEmcalTriggerPatchInfo   *fMainTriggerPatch;           // main trigger patch, will be cached after calling GetMainTriggerPatch() first time
-  ULong_t                        fTriggers;                // list of fired triggers
+  ULong_t                     fTriggers;                   // list of fired triggers
 
   TList                      *fOutput;                     //!output list
+  TH1                        *fHistEventCount;             //!incoming and selected events
   TH1                        *fHistTrialsAfterSel;         //!total number of trials per pt hard bin after selection
   TH1                        *fHistEventsAfterSel;         //!total number of events per pt hard bin after selection
   TProfile                   *fHistXsectionAfterSel;       //!x section from pythia header