Added new counters in AliNormalizationCounter to be used to properly count the number...
authorprino <prino@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 24 Jun 2011 22:43:51 +0000 (22:43 +0000)
committerprino <prino@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 24 Jun 2011 22:43:51 +0000 (22:43 +0000)
PWG3/vertexingHF/AliAnalysisTaskSECharmFraction.cxx
PWG3/vertexingHF/AliAnalysisTaskSED0Mass.cxx
PWG3/vertexingHF/AliAnalysisTaskSEDplus.cxx
PWG3/vertexingHF/AliAnalysisTaskSEDs.cxx
PWG3/vertexingHF/AliNormalizationCounter.cxx
PWG3/vertexingHF/AliNormalizationCounter.h

index e639a1d..ac4dd6f 100644 (file)
@@ -5327,7 +5327,8 @@ void AliAnalysisTaskSECharmFraction::UserExec(Option_t */*option*/)
 
   //histogram filled with 1 for every AOD
   fNentries->Fill(0);
-  fCounter->StoreEvent(aod,fReadMC); 
+  fCounter->StoreEvent(aod,fCutsLoose,fReadMC); 
+  //fCounter->StoreEvent(aod,fReadMC); 
   
   // trigger class for PbPb C0SMH-B-NOPF-ALLNOTRD, C0SMH-B-NOPF-ALL
   //  TString trigclass=aod->GetFiredTriggerClasses();
index 0129943..f9c6971 100644 (file)
@@ -739,7 +739,8 @@ void AliAnalysisTaskSED0Mass::UserExec(Option_t */*option*/)
   
   //histogram filled with 1 for every AOD
   fNentries->Fill(0);
-  fCounter->StoreEvent(aod,fReadMC); 
+  fCounter->StoreEvent(aod,fCuts,fReadMC); 
+  //fCounter->StoreEvent(aod,fReadMC); 
 
   // trigger class for PbPb C0SMH-B-NOPF-ALLNOTRD, C0SMH-B-NOPF-ALL
   TString trigclass=aod->GetFiredTriggerClasses();
index 26b13a8..792c969 100644 (file)
@@ -754,7 +754,6 @@ void AliAnalysisTaskSEDplus::UserCreateOutputObjects()
   AliAnalysisDataContainer *cont = GetOutputSlot(3)->GetContainer();
   if(cont)normName=(TString)cont->GetName();
   fCounter = new AliNormalizationCounter(normName.Data());
-  fCounter->SetRejectPileUp(fRDCutsProduction->GetOptPileUp());
 
   if(fFillNtuple){
     OpenFile(4); // 4 is the slot number of the ntuple
@@ -810,7 +809,7 @@ void AliAnalysisTaskSEDplus::UserExec(Option_t */*option*/)
   // 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) return;
-  fCounter->StoreEvent(aod,fReadMC);
+  fCounter->StoreEvent(aod,fRDCutsAnalysis,fReadMC);
   fHistNEvents->Fill(0); // count event
 
   Bool_t isEvSel=fRDCutsAnalysis->IsEventSelected(aod);
index 8f6fe8c..a598db2 100644 (file)
@@ -415,7 +415,8 @@ void AliAnalysisTaskSEDs::UserExec(Option_t */*option*/)
   // Post the data already here
   PostData(1,fOutput);
 
-  fCounter->StoreEvent(aod,fReadMC);
+  fCounter->StoreEvent(aod,fProdCuts,fReadMC);
+  //fCounter->StoreEvent(aod,fReadMC);
 
   TClonesArray *arrayMC=0;
   AliAODMCHeader *mcHeader=0;
index 2f2f4a8..0ce643a 100644 (file)
@@ -45,7 +45,6 @@ AliNormalizationCounter::AliNormalizationCounter():
 TNamed(),
 fCounters(),
 fESD(kFALSE),
-fRejectPileUp(kFALSE),
 fHistTrackFilterEvMult(0),
 fHistTrackAnaEvMult(0),
 fHistTrackFilterSpdMult(0),
@@ -59,14 +58,13 @@ AliNormalizationCounter::AliNormalizationCounter(const char *name):
 TNamed(name,name),
 fCounters(name),
 fESD(kFALSE),
-fRejectPileUp(kFALSE),
 fHistTrackFilterEvMult(0),
 fHistTrackAnaEvMult(0),
 fHistTrackFilterSpdMult(0),
 fHistTrackAnaSpdMult(0)
 {
   //default constructor
-  fCounters.AddRubric("Event","triggered/V0AND/PileUp/PbPbC0SMH-B-NOPF-ALLNOTRD/Candles0.2/Candles0.2spd1/Candles0.3/2xCandles0.2/CandleITSsa/Candle35clsTPC/PrimaryVTracks/PrimaryV/PrimaryVSPD/!V0A&Candle02/!V0A&Candle025/!V0A&Candle03/!V0A&PrimaryVTracks/!V0A&PrimaryV/!V0A&2xCandles02/Candid(Filter)/Candid(Analysis)/NCandid(Filter)/NCandid(Analysis)");
+  fCounters.AddRubric("Event","triggered/V0AND/PileUp/PbPbC0SMH-B-NOPF-ALLNOTRD/Candles0.3/PrimaryV/countForNorm/noPrimaryV/zvtxGT10/!V0A&Candle03/!V0A&PrimaryV/Candid(Filter)/Candid(Analysis)/NCandid(Filter)/NCandid(Analysis)");
   fCounters.AddRubric("Run", 1000000);
   fCounters.Init();
   fHistTrackFilterEvMult=new TH2F("FiltCandidvsTracksinEv","FiltCandidvsTracksinEv",10000,-0.5,9999.5,200,-0.5,199.5);
@@ -135,19 +133,18 @@ void AliNormalizationCounter::Add(const AliNormalizationCounter *norm){
   fHistTrackAnaSpdMult->Add(norm->fHistTrackAnaSpdMult);
 }
 //_______________________________________
-void AliNormalizationCounter::StoreEvent(AliVEvent *event,Bool_t mc){
+/*
+Stores the variables used for normalization as function of run number
+returns kTRUE if the event is to be counted for normalization
+(pass event selection cuts OR has no primary vertex)
+ */
+void AliNormalizationCounter::StoreEvent(AliVEvent *event,AliRDHFCuts *rdCut,Bool_t mc){
   //
 
   Bool_t v0A=kFALSE; 
   Bool_t v0B=kFALSE;
-  Bool_t flag02=kFALSE;
   Bool_t flag03=kFALSE;
-  Int_t flag0202=0;
   Bool_t flagPV=kFALSE;
-  Bool_t flagPVT=kFALSE; 
-  Bool_t flag35cls=kFALSE;
-  Bool_t flagITSsa=kFALSE;
-  Bool_t flag02spd=kFALSE;
 
   //Run Number
   Int_t runNumber = event->GetRunNumber();
@@ -160,89 +157,57 @@ void AliNormalizationCounter::StoreEvent(AliVEvent *event,Bool_t mc){
   if(!(event->GetEventType() == 7||event->GetEventType() == 0))return;
   
   fCounters.Count(Form("Event:triggered/Run:%d",runNumber));
-      
+   
   //Find V0AND
   AliTriggerAnalysis trAn; /// Trigger Analysis
   v0B = trAn.IsOfflineTriggerFired(eventESD , AliTriggerAnalysis::kV0C);
   v0A = trAn.IsOfflineTriggerFired(eventESD , AliTriggerAnalysis::kV0A);
   if(v0A&&v0B){fCounters.Count(Form("Event:V0AND/Run:%d",runNumber));}
   
- //FindPrimary vertex  
-  AliAODEvent *eventAOD = (AliAODEvent*)event;
-  AliVVertex *vtrc =  (AliVVertex*)event->GetPrimaryVertex();
-  if(vtrc && vtrc->GetNContributors()>0){
-    fCounters.Count(Form("Event:PrimaryV/Run:%d",runNumber));
-    flagPV=kTRUE;
-  }
-
-  AliAODVertex *vrtcSPD = (AliAODVertex*)eventAOD->GetPrimaryVertexSPD();
-  if(vrtcSPD){
-    if(vrtcSPD->GetNContributors()>0)fCounters.Count(Form("Event:PrimaryVSPD/Run:%d",runNumber));
-  }
-  
-  if(fESD){
-    const AliESDVertex *vtrc1 =  eventESD->GetPrimaryVertexTracks();
-    if(vtrc1 && vtrc1->GetNContributors()>0){
-      fCounters.Count(Form("Event:PrimaryVTracks/Run:%d",runNumber));
-      flagPVT=kTRUE;
-    }
-  }
+  //FindPrimary vertex  
+  // AliVVertex *vtrc =  (AliVVertex*)event->GetPrimaryVertex();
+  // if(vtrc && vtrc->GetNContributors()>0){
+  //   fCounters.Count(Form("Event:PrimaryV/Run:%d",runNumber));
+  //   flagPV=kTRUE;
+  // }
 
   //trigger
+  AliAODEvent *eventAOD = (AliAODEvent*)event;
   TString trigclass=eventAOD->GetFiredTriggerClasses();
   if(trigclass.Contains("C0SMH-B-NOPF-ALLNOTRD")||trigclass.Contains("C0SMH-B-NOPF-ALL"))fCounters.Count(Form("Event:PbPbC0SMH-B-NOPF-ALLNOTRD/Run:%d",runNumber));
 
-  //PileUp
-  if(eventAOD->IsPileupFromSPD()){
-    fCounters.Count(Form("Event:PileUp/Run:%d",runNumber));
-    if(fRejectPileUp==1)return;
+  //FindPrimary vertex  
+  if(rdCut->IsEventSelected(event)){
+    fCounters.Count(Form("Event:PrimaryV/Run:%d",runNumber));
+    flagPV=kTRUE;
+  }else{
+    if(rdCut->GetWhyRejection()==0)fCounters.Count(Form("Event:noPrimaryV/Run:%d",runNumber));
+    //find good vtx outside range
+    if(rdCut->GetWhyRejection()==6){
+      fCounters.Count(Form("Event:zvtxGT10/Run:%d",runNumber));
+      fCounters.Count(Form("Event:PrimaryV/Run:%d",runNumber));
+      flagPV=kTRUE;
+    }
+    if(rdCut->GetWhyRejection()==1)fCounters.Count(Form("Event:PileUp/Run:%d",runNumber));
   }
+  //to be counted for normalization
+  if(rdCut->CountEventForNormalization())fCounters.Count(Form("Event:countForNorm/Run:%d",runNumber));
+  
 
   //Find Candle
   Int_t trkEntries = (Int_t)event->GetNumberOfTracks();
-  
-  for(Int_t i=0;i<trkEntries;i++){
+  for(Int_t i=0;i<trkEntries&&!flag03;i++){
     AliAODTrack *track=(AliAODTrack*)event->GetTrack(i);
-    UShort_t nClusTPC=track->GetTPCNcls();
-    Int_t nSPD=0;
-    if(TESTBIT(track->GetITSClusterMap(),1))nSPD++;
-    if(TESTBIT(track->GetITSClusterMap(),0))nSPD++;
-    if(nClusTPC==0&&(track->GetStatus()&AliESDtrack::kITSrefit)&&!flagITSsa){
-      flagITSsa=kTRUE;
-      fCounters.Count(Form("Event:CandleITSsa/Run:%d",runNumber));
-    }
-    if((nClusTPC>=35)&&(track->GetStatus()&AliESDtrack::kITSrefit)&&(track->GetStatus()&AliESDtrack::kTPCrefit)&&(track->Pt()>0.2)&&(!flag35cls)){
-      fCounters.Count(Form("Event:Candle35clsTPC/Run:%d",runNumber));
-      flag35cls=kTRUE;
+    if((track->Pt()>0.3)&&(!flag03)){
+      fCounters.Count(Form("Event:Candles0.3/Run:%d",runNumber));
+      flag03=kTRUE;
+      break;
     }
-    if((nClusTPC>=70)&&(track->GetStatus()&AliESDtrack::kITSrefit)&&(track->GetStatus()&AliESDtrack::kTPCrefit)){
-      
-      if((track->Pt()>0.2)&&flag0202<2){
-       if(!flag02)fCounters.Count(Form("Event:Candles0.2/Run:%d",runNumber));
-       flag02=kTRUE;
-       flag0202++;
-      }
-      if((track->Pt()>0.2)&&!flag02spd&&nSPD>=1){
-       fCounters.Count(Form("Event:Candles0.2spd1/Run:%d",runNumber));
-       flag02spd=kTRUE;
-      }
-      if((track->Pt()>0.3)&&(!flag03)){
-       fCounters.Count(Form("Event:Candles0.3/Run:%d",runNumber));
-       flag03=kTRUE;
-      }
-    }
-    if((flag02)&&(flag03)&&flag0202>=2&&flag35cls&&flagITSsa) break; 
   }
   
-  if(!(v0A&&v0B)&&(flag02))fCounters.Count(Form("Event:!V0A&Candle02/Run:%d",runNumber));
   if(!(v0A&&v0B)&&(flag03))fCounters.Count(Form("Event:!V0A&Candle03/Run:%d",runNumber));
-  if(!(v0A&&v0B)&&flagPVT)fCounters.Count(Form("Event:!V0A&PrimaryVTracks/Run:%d",runNumber));
   if(!(v0A&&v0B)&&flagPV)fCounters.Count(Form("Event:!V0A&PrimaryV/Run:%d",runNumber));
-  if(flag0202>1)fCounters.Count(Form("Event:2xCandles0.2/Run:%d",runNumber));
-  if(!(v0A&&v0B)&&flag0202>1)fCounters.Count(Form("Event:!V0A&2xCandles02/Run:%d",runNumber));
   
-  //delete eventESD;
-
   return;
 }
 //_____________________________________________________________________
@@ -336,3 +301,90 @@ TH2F* AliNormalizationCounter::GetHist(Bool_t filtercuts,Bool_t spdtracklets,Boo
     }
   }
 }
+//___________________________________________________________________________
+Double_t AliNormalizationCounter::GetNEventsForNorm(){
+  Double_t noVtxzGT10=GetSum("noPrimaryV")*GetSum("zvtxGT10")/GetSum("PrimaryV");
+  return GetSum("countForNorm")-noVtxzGT10;
+}
+//___________________________________________________________________________
+Double_t AliNormalizationCounter::GetNEventsForNorm(Int_t runnumber){
+  TString listofruns = fCounters.GetKeyWords("RUN");
+  if(!listofruns.Contains(Form("%d",runnumber))){
+    printf("WARNING: %d is not a valid run number\n",runnumber);
+    fCounters.Print("Run","",kTRUE);
+    return 0.;
+  }
+  TString suffix;suffix.Form("/RUN:%d",runnumber);
+  TString zvtx;zvtx.Form("zvtxGT10%s",suffix.Data());
+  TString noPV;noPV.Form("noPrimaryV%s",suffix.Data());
+  TString pV;pV.Form("PrimaryV%s",suffix.Data());
+  TString tbc;tbc.Form("countForNorm%s",suffix.Data());
+  Double_t noVtxzGT10=GetSum(noPV.Data())*GetSum(zvtx.Data())/GetSum(pV.Data());
+  return GetSum(tbc.Data())-noVtxzGT10;
+}
+//___________________________________________________________________________
+TH1D* AliNormalizationCounter::DrawNEventsForNorm(){
+  //usare algebra histos
+  fCounters.SortRubric("Run");
+  TString selection;
+
+  selection.Form("event:noPrimaryV");
+  TH1D* hnoPrimV = fCounters.Get("run",selection.Data());
+  hnoPrimV->Sumw2();
+
+  selection.Form("event:zvtxGT10");
+  TH1D*  hzvtx= fCounters.Get("run",selection.Data());
+  hzvtx->Sumw2();
+
+  selection.Form("event:PrimaryV");
+  TH1D* hPrimV = fCounters.Get("run",selection.Data());
+  hPrimV->Sumw2();
+
+  hzvtx->Multiply(hnoPrimV);
+  hzvtx->Divide(hPrimV);
+  hnoPrimV->Add(hzvtx,-1.);
+
+  selection.Form("event:countForNorm");
+  TH1D* hCountForNorm = fCounters.Get("run",selection.Data());
+  hCountForNorm->Sumw2();
+
+  hCountForNorm->Add(hnoPrimV,-1.);
+  hCountForNorm->DrawClone();
+  return hCountForNorm;
+}
+//___________________________________________________________________________
+TH1D* AliNormalizationCounter::DrawNEventsForNormRatio(){
+   //usare algebra histos
+  fCounters.SortRubric("Run");
+  TString selection;
+
+  selection.Form("event:noPrimaryV");
+  TH1D* hnoPrimV = fCounters.Get("run",selection.Data());
+  hnoPrimV->Sumw2();
+
+  selection.Form("event:zvtxGT10");
+  TH1D*  hzvtx= fCounters.Get("run",selection.Data());
+  hzvtx->Sumw2();
+
+  selection.Form("event:PrimaryV");
+  TH1D* hPrimV = fCounters.Get("run",selection.Data());
+  hPrimV->Sumw2();
+
+  hzvtx->Multiply(hnoPrimV);
+  hzvtx->Divide(hPrimV);
+  hnoPrimV->Add(hzvtx,-1.);
+
+  selection.Form("event:countForNorm");
+  TH1D* hCountForNorm = fCounters.Get("run",selection.Data());
+  hCountForNorm->Sumw2();
+
+  hCountForNorm->Add(hnoPrimV,-1.);
+
+  selection.Form("event:triggered");
+  TH1D* htriggered = fCounters.Get("run",selection.Data());
+  htriggered->Sumw2();
+  hCountForNorm->Divide(htriggered);
+
+  hCountForNorm->DrawClone();
+  return hCountForNorm;
+}
index fadfc97..29a1e55 100644 (file)
@@ -42,6 +42,7 @@
 #include "AliCounterCollection.h"
 #include "AliAnalysisDataSlot.h"
 #include "AliAnalysisDataContainer.h"
+#include "AliRDHFCuts.h"
 //#include "AliAnalysisVertexingHF.h"
 
 class AliNormalizationCounter : public TNamed
@@ -56,28 +57,29 @@ class AliNormalizationCounter : public TNamed
   AliCounterCollection* GetCounter(){return &fCounters;}
   void Add(const AliNormalizationCounter*);
   void SetESD(Bool_t flag){fESD=flag;}
-  void StoreEvent(AliVEvent*,Bool_t mc=kFALSE);
+  void StoreEvent(AliVEvent*,AliRDHFCuts *,Bool_t mc=kFALSE);
   void StoreCandidates(AliVEvent*, Int_t nCand=0,Bool_t flagFilter=kTRUE);
   TH1D* DrawAgainstRuns(TString candle="candid(filter)",Bool_t drawHist=kTRUE);
   TH1D* DrawRatio(TString candle1="candid(filter)",TString candle2="triggered");
   void PrintRubrics();
   Double_t GetSum(TString candle="triggered");
-  Bool_t GetRejectPileUp(){return fRejectPileUp;}
-  void SetRejectPileUp(Int_t reject=kTRUE){fRejectPileUp=reject;}
   TH2F* GetHist(Bool_t filtercuts=kTRUE,Bool_t spdtracklets=kTRUE,Bool_t drawHist=kFALSE);
+  Double_t GetNEventsForNorm();
+  Double_t GetNEventsForNorm(Int_t runnumber);
+  TH1D* DrawNEventsForNorm();
+  TH1D* DrawNEventsForNormRatio();
 
  private:
   AliNormalizationCounter(const AliNormalizationCounter &source);
   AliNormalizationCounter& operator=(const AliNormalizationCounter& source);
   AliCounterCollection fCounters; //internal counter
   Bool_t fESD; //flag for ESD vs AOD
-  Int_t fRejectPileUp; //flag to reject candles in pile up events
   TH2F *fHistTrackFilterEvMult; //hist to store no of filter candidates vs no of tracks in the event 
   TH2F *fHistTrackAnaEvMult;//hist to store no of analysis candidates vs no of tracks in the event 
   TH2F *fHistTrackFilterSpdMult; //hist to store no of filter candidates vs  SPD multiplicity 
   TH2F *fHistTrackAnaSpdMult;//hist to store no of analysis candidates vs SPD multiplicity 
 
-  ClassDef(AliNormalizationCounter,3);
+  ClassDef(AliNormalizationCounter,4);
 
 };
 #endif