- fix an if condition (Hege)
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AliNormalizationCounter.cxx
CommitLineData
a96083b9 1#include "AliNormalizationCounter.h"
2#include <AliESDEvent.h>
3#include <AliESDtrack.h>
4#include <AliAODEvent.h>
5#include <AliVParticle.h>
6#include <AliTriggerAnalysis.h>
7#include <TH1F.h>
8#include <TH2D.h>
9#include <TList.h>
10#include <TString.h>
11#include <TCanvas.h>
12#include <AliPhysicsSelection.h>
13
14ClassImp(AliNormalizationCounter)
15
16//____________________________________________
17AliNormalizationCounter::AliNormalizationCounter():
18AliCounterCollection(),
19fESD(kFALSE)
20{
21 // empty constructor
22}
23
24//__________________________________________________
25AliNormalizationCounter::AliNormalizationCounter(const char *name):
26AliCounterCollection(name),
27fESD(kFALSE)
28{
29 //default constructor
ea3defa4 30 AddRubric("Event","triggered/V0AND/PileUp/Candles0.2/Candles0.25/Candles0.3/2xCandles0.2/PrimaryVTracks/PrimaryV/!V0A&Candle02/!V0A&Candle025/!V0A&Candle03/!V0A&PrimaryVTracks/!V0A&PrimaryV/!V0A&2xCandles02/Candid(Filter)/Candid(Analysis)/NCandid(Filter)/NCandid(Analysis)");//new line
a96083b9 31 AddRubric("Run", 10000000);//new line
32 Init();//new line
33}
34//______________________________________________
35AliNormalizationCounter::~AliNormalizationCounter()
36{
37 //destructor
38}
39
40
41//_______________________________________
42void AliNormalizationCounter::StoreEvent(AliVEvent *event,Bool_t mc){
43 //
44
45 Bool_t v0A=kFALSE;
46 Bool_t v0B=kFALSE;
47 Bool_t flag02=kFALSE;
48 Bool_t flag025=kFALSE;
49 Bool_t flag03=kFALSE;
50 Int_t flag0202=0;
51 Bool_t flagPV=kFALSE;
52 Bool_t flagPVT=kFALSE;
53
54 //Run Number
55 Int_t runNumber = event->GetRunNumber();
56
57 //Find CINT1B
a96083b9 58 AliESDEvent *eventESD = (AliESDEvent*)event;
59 if(!eventESD){AliError("ESD event not available");return;}
60 if(mc&&event->GetEventType() != 0)return;
61 //event must be either physics or MC
62 if(!(event->GetEventType() == 7||event->GetEventType() == 0))return;
63
64 Count(Form("Event:triggered/Run:%d",runNumber));
65
66 //Find V0AND
67 AliTriggerAnalysis trAn; /// Trigger Analysis
68 v0B = trAn.IsOfflineTriggerFired(eventESD , AliTriggerAnalysis::kV0C);
69 v0A = trAn.IsOfflineTriggerFired(eventESD , AliTriggerAnalysis::kV0A);
70 if(v0A&&v0B){Count(Form("Event:V0AND/Run:%d",runNumber));}
71
ea3defa4 72 //PileUp
73 AliAODEvent *eventAOD = (AliAODEvent*)event;
74 if(eventAOD->IsPileupFromSPD())Count(Form("Event:PileUp/Run:%d",runNumber));
75
a96083b9 76 //Find Candle
77 Int_t trkEntries = (Int_t)event->GetNumberOfTracks();
78
79 for(Int_t i=0;i<trkEntries;i++){
80 AliAODTrack *track=(AliAODTrack*)event->GetTrack(i);
81 UShort_t nClusTPC=track->GetTPCNcls();
82 if((nClusTPC>=70)&&(track->GetStatus()&AliESDtrack::kITSrefit)&&(track->GetStatus()&AliESDtrack::kTPCrefit)){
83
84 if((track->Pt()>0.2)&&flag0202<2){
85 if(!flag02)Count(Form("Event:Candles0.2/Run:%d",runNumber));
86 flag02=kTRUE;
87 flag0202++;
88 }
89 if((track->Pt()>0.25)&&(!flag025)){
90 Count(Form("Event:Candles0.25/Run:%d",runNumber));
91 flag025=kTRUE;
92 }
93 if((track->Pt()>0.3)&&(!flag03)){
94 Count(Form("Event:Candles0.3/Run:%d",runNumber));
95 flag03=kTRUE;
96 }
97 }
98 if((flag02)&&(flag025)&&(flag03)&&flag0202>=2) break; //i=trkEntries+1;
99 }
100
101 //FindPrimary vertex
102 AliVVertex *vtrc = (AliVVertex*)event->GetPrimaryVertex();
103 if(vtrc && vtrc->GetNContributors()>0){
104 Count(Form("Event:PrimaryV/Run:%d",runNumber));
105 flagPV=kTRUE;
106 }
107
108 if(fESD){
109 const AliESDVertex *vtrc1 = eventESD->GetPrimaryVertexTracks();
110 if(vtrc1 && vtrc1->GetNContributors()>0){
111 Count(Form("Event:PrimaryVTracks/Run:%d",runNumber));
112 flagPVT=kTRUE;
113 }
114 }
115
116 if(!(v0A&&v0B)&&(flag02))Count(Form("Event:!V0A&Candle02/Run:%d",runNumber));
117 if(!(v0A&&v0B)&&(flag025))Count(Form("Event:!V0A&Candle025/Run:%d",runNumber));
118 if(!(v0A&&v0B)&&(flag03))Count(Form("Event:!V0A&Candle03/Run:%d",runNumber));
119 if(!(v0A&&v0B)&&flagPVT)Count(Form("Event:!V0A&PrimaryVTracks/Run:%d",runNumber));
120 if(!(v0A&&v0B)&&flagPV)Count(Form("Event:!V0A&PrimaryV/Run:%d",runNumber));
121 if(flag0202>1)Count(Form("Event:2xCandles0.2/Run:%d",runNumber));
122 if(!(v0A&&v0B)&&flag0202>1)Count(Form("Event:!V0A&2xCandles02/Run:%d",runNumber));
123
124 //delete eventESD;
125
126 return;
127}
128//_____________________________________________________________________
129void AliNormalizationCounter::StoreCandidates(AliVEvent *event,Int_t nCand,Bool_t flagFilter){
130 //
131
132 Int_t runNumber = event->GetRunNumber();
133 if(nCand==0)return;
134 if(flagFilter){
135 Count(Form("Event:Candid(Filter)/Run:%d",runNumber));
136 for(Int_t i=0;i<nCand;i++)Count(Form("Event:NCandid(Filter)/Run:%d",runNumber));
137 }else{
138 Count(Form("Event:Candid(Analysis)/Run:%d",runNumber));
139 for(Int_t i=0;i<nCand;i++)Count(Form("Event:NCandid(Analysis)/Run:%d",runNumber));
140 }
141 return;
142}
143//_______________________________________________________________________
144TH1D* AliNormalizationCounter::DrawAgainstRuns(TString candle="candid(filter)"){
145 //
ea3defa4 146 SortRubric("Run");
a96083b9 147 TString selection;
148 selection.Form("event:%s",candle.Data());
149 TH2D* hist = Draw("event","run",selection.Data());
150 TH1D* histoneD =(TH1D*)(hist->ProjectionX()->Clone());
ea3defa4 151 histoneD->Sumw2();
a96083b9 152 histoneD->DrawClone();
153 return histoneD;
154}
155//___________________________________________________________________________
156TH1D* AliNormalizationCounter::DrawRatio(TString candle1="candid(filter)",TString candle2="triggered"){
157 //
ea3defa4 158 SortRubric("Run");
a96083b9 159 TString name;
160 name.Form("%s/%s",candle1.Data(),candle2.Data());
161 TH1D* num=(TH1D*)(DrawAgainstRuns(candle1.Data())->Clone(name.Data()));
162 TH1D* den=DrawAgainstRuns(candle2.Data());
ea3defa4 163 num->Sumw2();
164 den->Sumw2();
a96083b9 165 den->SetTitle(candle2.Data());
166 den->SetName(candle2.Data());
167 printf("%f %f",num->GetEntries(),den->GetEntries());
168 num->Divide(num,den,1,1,"B");
169 num->DrawClone();
170 return num;
171}
172