]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGCF/Correlations/DPhi/DiHadronPID/AliAODEventCutsDiHadronPID.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGCF / Correlations / DPhi / DiHadronPID / AliAODEventCutsDiHadronPID.cxx
CommitLineData
97724bd1 1/*************************************************************************
2* Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
7* Permission to use, copy, modify and distribute this software and its *
8* documentation strictly for non-commercial purposes is hereby granted *
9* without fee, provided that the above copyright notice appears in all *
10* copies and that both the copyright notice and this permission notice *
11* appear in the supporting documentation. The authors make no claims *
12* about the suitability of this software for any purpose. It is *
13* provided "as is" without express or implied warranty. *
14**************************************************************************/
15
16// -----------------------------------------------------------------------
17// Event Cut class for the DiHadronPID analysis.
18// -----------------------------------------------------------------------
19// Author: Misha Veldhoen (misha.veldhoen@cern.ch)
6788af99 20
a5422983 21#include "AliAODEventCutsDiHadronPID.h"
22
6788af99 23#include <iostream>
a5422983 24using namespace std;
25
6788af99 26#include "TList.h"
27#include "TMath.h"
28#include "TH1F.h"
29#include "TH2F.h"
30#include "TNamed.h"
31#include "TIterator.h"
6788af99 32#include "AliAODHeader.h"
33#include "AliAODVertex.h"
34#include "AliCentrality.h"
35#include "AliAnalysisManager.h"
36#include "AliInputEventHandler.h"
6788af99 37
38ClassImp(AliAODEventCutsDiHadronPID);
39
97724bd1 40// -----------------------------------------------------------------------
6788af99 41AliAODEventCutsDiHadronPID::AliAODEventCutsDiHadronPID():
42 TNamed(),
43 fIsPbPb(kTRUE),
44 fIsMC(kFALSE),
45 fTrigger(AliVEvent::kMB),
46 fMinCentrality(5.),
47 fMaxCentrality(0.),
48 fCentralityEstimator("V0M"),
49 fMaxVertexZ(10.),
50 fMinRefMult(0),
51 fTestTrigger(kFALSE),
52 fTestCentrality(kFALSE),
6214ec0c 53 fTestContributorsOrSPDVertex(kFALSE),
6788af99 54 fTestVertexZ(kFALSE),
55 fTestMinRefMult(kFALSE),
56 fSelectedEventQAHistos(0x0),
57 fAllEventQAHistos(0x0),
58 fHistTrigger(0x0),
59 fHistRefMultiplicity(0x0),
60 fHistCentrality(0x0),
61 fHistCentralityQuality(0x0),
62 fHistVertexZ(0x0),
63 fDebug(0)
64
65{
66
67 //
68 // Default Constructor
69 //
70
71 cout<<"AliAODEventCutsDiHadronPID Default Constructor Called."<<endl;
50dfda71 72 if (fDebug > 1) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
6788af99 73
74}
75
97724bd1 76// -----------------------------------------------------------------------
6788af99 77AliAODEventCutsDiHadronPID::AliAODEventCutsDiHadronPID(const char* name):
78 TNamed(name,"AOD Event Cuts"),
79 fIsPbPb(kTRUE),
80 fIsMC(kFALSE),
81 fTrigger(AliVEvent::kMB),
82 fMinCentrality(5.),
83 fMaxCentrality(0.),
84 fCentralityEstimator("V0M"),
85 fMaxVertexZ(10.),
86 fMinRefMult(0),
87 fTestTrigger(kFALSE),
88 fTestCentrality(kFALSE),
6214ec0c 89 fTestContributorsOrSPDVertex(kFALSE),
6788af99 90 fTestVertexZ(kFALSE),
91 fTestMinRefMult(kFALSE),
92 fSelectedEventQAHistos(0x0),
93 fAllEventQAHistos(0x0),
94 fHistTrigger(0x0),
95 fHistRefMultiplicity(0x0),
96 fHistCentrality(0x0),
97 fHistCentralityQuality(0x0),
98 fHistVertexZ(0x0),
99 fDebug(0)
100
101{
102
103 //
104 // Named Constructor
105 //
106
107 cout<<"AliAODEventCutsDiHadronPID Named Constructor Called."<<endl;
50dfda71 108 if (fDebug > 1) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
6788af99 109
110}
111
97724bd1 112// -----------------------------------------------------------------------
6788af99 113AliAODEventCutsDiHadronPID::~AliAODEventCutsDiHadronPID() {
114
115 //
116 // Destructor
117 //
118
119 cout<<"AliAODEventCutsDiHadronPID Destructor Called."<<endl;
50dfda71 120 if (fDebug > 1) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
6788af99 121
122 if (fSelectedEventQAHistos) delete fSelectedEventQAHistos;
123 fSelectedEventQAHistos = 0x0;
124 if (fAllEventQAHistos) delete fAllEventQAHistos;
125 fAllEventQAHistos = 0x0;
126
127}
128
97724bd1 129// -----------------------------------------------------------------------
6788af99 130Long64_t AliAODEventCutsDiHadronPID::Merge(TCollection* list) {
131
132 //
133 // Merger.
134 //
135
136 cout<<"AliAODEventCutsDiHadronPID Merger Called."<<endl;
50dfda71 137 if (fDebug > 1) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
6788af99 138
139 if (!list) return 0;
140 if (list->IsEmpty()) return 1;
141
142 if (!fSelectedEventQAHistos||!fAllEventQAHistos) {
143 cout<<"AliAODEventCutsDiHadronPID::Merge() - Warning, current object's histograms are missing... Generating."<<endl;
144 CreateHistos();
145 }
146
147 TIterator* iter = list->MakeIterator();
148 TObject* obj;
149
150 // List of collections
151 TList collection_fSelectedEventQAHistos;
152 TList collection_fAllEventQAHistos;
153
154 Int_t count = 0;
155
156 while ((obj = iter->Next())) {
157 AliAODEventCutsDiHadronPID* entry = dynamic_cast<AliAODEventCutsDiHadronPID*> (obj);
158 if (entry == 0) continue;
159
160 // Check if the object to be merged really has the same name! (FIXME!)
161
162 // Getting the lists from obj.
163 TList* list_fSelectedEventQAHistos = entry->GetListOfSelectedEventQAHistos();
164 TList* list_fAllEventQAHistos = entry->GetListOfAllEventQAHistos();
165
166 // Adding the retrieved lists to the collection.
167 if (list_fSelectedEventQAHistos) collection_fSelectedEventQAHistos.Add(list_fSelectedEventQAHistos);
168 if (list_fAllEventQAHistos) collection_fAllEventQAHistos.Add(list_fAllEventQAHistos);
169
170 count++;
171 }
172
173 // Merging. Note that we require the original list to exist.
174 // * Assume that if the collection happens to be empty, then nothing will happen.
175 // * All other variables are taken from the original object.
176 if (fSelectedEventQAHistos) fSelectedEventQAHistos->Merge(&collection_fSelectedEventQAHistos);
177 if (fAllEventQAHistos) fAllEventQAHistos->Merge(&collection_fAllEventQAHistos);
178
179 delete iter;
180
181 return count+1;
182
183}
184
97724bd1 185// -----------------------------------------------------------------------
6788af99 186void AliAODEventCutsDiHadronPID::CreateHistos() {
187
188 cout<<"AliAODEventCutsDiHadronPID - Creating histograms"<<endl;
50dfda71 189 if (fDebug > 1) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
6788af99 190
191 // Create list of Event related QA histograms (selected events).
192 fSelectedEventQAHistos = new TList();
193 fSelectedEventQAHistos->SetName("SelectedEventQAHistos");
194 fSelectedEventQAHistos->SetOwner(kTRUE);
195
196 // The same, but for all events.
197 fAllEventQAHistos = new TList();
198 fAllEventQAHistos->SetName("AllEventQAHistos");
199 fAllEventQAHistos->SetOwner(kTRUE);
200
201 // Creating arrays of pointers to the QA histos.
202 fHistTrigger = new TH1F*[2];
203 fHistRefMultiplicity = new TH1F*[2];
204 fHistCentrality = new TH1F*[2];
205 fHistCentralityQuality = new TH1F*[2];
206 fHistVertexZ = new TH1F*[2];
207
208 const char* HistType[2] = {"Selected","All"};
209
210 for (Int_t iHistType = 0; iHistType < 2; iHistType++) {
211
212 // Trigger Histogram.
a5422983 213 fHistTrigger[iHistType] = new TH1F(Form("fHistTrigger%s",HistType[iHistType]),"Trigger;;Count",5,-0.5,4.5);
6788af99 214 fHistTrigger[iHistType]->GetXaxis()->SetBinLabel(1,"kMB");
a5422983 215 fHistTrigger[iHistType]->GetXaxis()->SetBinLabel(2,"kCentral"); // Trigger only defined for period LHC11h.
216 fHistTrigger[iHistType]->GetXaxis()->SetBinLabel(3,"kSemiCentral"); // Trigger only defined for period LHC11h.
217 fHistTrigger[iHistType]->GetXaxis()->SetBinLabel(4,"kINT7");
218 fHistTrigger[iHistType]->GetXaxis()->SetBinLabel(5,"Other");
6788af99 219 if (iHistType == 0) fSelectedEventQAHistos->Add(fHistTrigger[iHistType]);
220 else fAllEventQAHistos->Add(fHistTrigger[iHistType]);
221
222 // Ref Multiplicity Histogram.
a5422983 223 if (fIsPbPb) {
224 fHistRefMultiplicity[iHistType] = new TH1F(Form("fHistRefMultiplicity%s",HistType[iHistType]),"Reference Multiplicity;N_{tracks};Count",100,0.,10000.);
225 } else {
226 fHistRefMultiplicity[iHistType] = new TH1F(Form("fHistRefMultiplicity%s",HistType[iHistType]),"Reference Multiplicity;N_{tracks};Count",100,0.,100.);
227 }
6788af99 228 if (iHistType == 0) fSelectedEventQAHistos->Add(fHistRefMultiplicity[iHistType]);
229 else fAllEventQAHistos->Add(fHistRefMultiplicity[iHistType]);
230
231 // Centrality Histogram.
232 fHistCentrality[iHistType] = new TH1F(Form("fHistCentrality%s",HistType[iHistType]),"Centrality;Centrality;Count",20,0,100);
233 if (iHistType == 0) fSelectedEventQAHistos->Add(fHistCentrality[iHistType]);
234 else fAllEventQAHistos->Add(fHistCentrality[iHistType]);
235
236 // Centrality Quality.
237 fHistCentralityQuality[iHistType] = new TH1F(Form("fHistCentralityQuality%s",HistType[iHistType]),"Centrality Quality;Quality;Count",2,-0.5,1.5);
238 fHistCentralityQuality[iHistType]->GetXaxis()->SetBinLabel(1,"0");
239 fHistCentralityQuality[iHistType]->GetXaxis()->SetBinLabel(2,"Other");
240 if (iHistType == 0) fSelectedEventQAHistos->Add(fHistCentralityQuality[iHistType]);
241 else fAllEventQAHistos->Add(fHistCentralityQuality[iHistType]);
242
243 // VertexZ Histogram.
244 fHistVertexZ[iHistType] = new TH1F(Form("fHistVertexZ%s",HistType[iHistType]),"VertexZ;z (cm);Count",60,-15.,15.);
245 if (iHistType == 0) fSelectedEventQAHistos->Add(fHistVertexZ[iHistType]);
246 else fAllEventQAHistos->Add(fHistVertexZ[iHistType]);
247
248 }
249
250}
251
97724bd1 252// -----------------------------------------------------------------------
6788af99 253Bool_t AliAODEventCutsDiHadronPID::IsSelected(AliAODEvent* event) {
254
50dfda71 255 if (fDebug > 1) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
a5422983 256
6788af99 257 if (!event) return kFALSE;
a5422983 258
6788af99 259 if (!fAllEventQAHistos||!fSelectedEventQAHistos) {cout<<"AliAODEventCutsDiHadronPID - Histograms were not created, you should have called CreateHistos()..."<<endl;}
a5422983 260
6788af99 261 // Input the event handler.
262 AliInputEventHandler* InputHandler = (AliInputEventHandler*)((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
263 if (!InputHandler) return kFALSE;
a5422983 264
6788af99 265 Bool_t select = kTRUE;
a5422983 266
6788af99 267 // Test Trigger.
a5422983 268 UInt_t trigger = InputHandler->IsEventSelected();
269 Int_t triggerclass = -1; // 0 = kMB, 1 = kCentral, 2 = kSemiCentral, 3 = Other.
6788af99 270 if (fTestTrigger) {
6788af99 271
a5422983 272 // Find Trigger class.
273 if (trigger & AliVEvent::kMB) {triggerclass = 0;}
274 else if (trigger & AliVEvent::kCentral) {triggerclass = 1;}
275 else if (trigger & AliVEvent::kSemiCentral) {triggerclass = 2;}
276 else if (trigger & AliVEvent::kINT7) {triggerclass = 3;}
277 else {triggerclass = 4;}
278
279 if (!(trigger & fTrigger)) {select = kFALSE;} // Event not selected if not matched with the any of the desired triggers.
280 }
281
6788af99 282 AliCentrality* CurrentCentrality = 0x0;
283 Int_t CurrentCentralityQuality = -999;
284 Float_t percentile = -999.;
a5422983 285
6788af99 286 if (fIsPbPb) {
287
288 // Get the centrality object.
289 CurrentCentrality = event->GetCentrality();
c905f765 290 //cout<<"Centrality object: "<<CurrentCentrality<<endl;
7fcceff8 291 if (!CurrentCentrality) {select = kFALSE; return select;}
6788af99 292
293 // Check the quality of the centrality estimation.
294 // If 0 then quality is OK, c.f. TOF/PbPb276/macros/TOFmatchEff.C
295 CurrentCentralityQuality = CurrentCentrality->GetQuality();
c905f765 296 //cout<<"Centrality: "<<CurrentCentrality->GetCentralityPercentile(fCentralityEstimator.Data())<<" Quality: "<<CurrentCentrality->GetQuality()<<endl;
6788af99 297 if (CurrentCentralityQuality) select = kFALSE;
298
299 // Test Centrality.
300 percentile = CurrentCentrality->GetCentralityPercentile(fCentralityEstimator.Data());
301 if (fTestCentrality) {
302 if ((percentile < fMaxCentrality)||(percentile > fMinCentrality)) select = kFALSE;
303 }
304
305 }
a5422983 306
6788af99 307 // Get the primary vertex.
308 AliAODVertex* CurrentPrimaryVertex = event->GetPrimaryVertex();
7fcceff8 309 if (!CurrentPrimaryVertex) {select = kFALSE; return select;}
6788af99 310
a5422983 311 // Get the Vertex_z value (improved by Peter Christiansen).
312 Double_t vtxz = -999.;
313 if (fIsPbPb) {vtxz = CurrentPrimaryVertex->GetZ();}
314 else if (CurrentPrimaryVertex->GetNContributors() > 0) {
315 vtxz = CurrentPrimaryVertex->GetZ();
316 }
317
6788af99 318 // Test Vertex Z.
6788af99 319 if (fTestVertexZ) {
320 if (TMath::Abs(vtxz) > fMaxVertexZ) select = kFALSE;
321 }
322
a5422983 323 // Test number of contributors.
6214ec0c 324 if (fTestContributorsOrSPDVertex) {
325 Int_t nContributors = CurrentPrimaryVertex->GetNContributors();
326 if (nContributors < 1) {
327 if (CurrentPrimaryVertex->GetType() != AliAODVertex::kMainSPD ) {select = kFALSE;}
328 }
329 }
a5422983 330
6788af99 331 // Get the event header.
0a918d8d 332 AliAODHeader* CurrentHeader = dynamic_cast<AliAODHeader*>(event->GetHeader());
333 if(!CurrentHeader) AliFatal("Not a standard AOD");
a5422983 334
6788af99 335 // Test minimum reference multiplicity.
336 Int_t CurrentRefMultiplicity = CurrentHeader->GetRefMultiplicity();
337 if (fTestMinRefMult) {
338 if (CurrentRefMultiplicity < fMinRefMult) select = kFALSE;
339 }
a5422983 340
6788af99 341 // Fill the histograms for selected events.
342 if (select) {
a5422983 343 fHistTrigger[0]->Fill(triggerclass);
6788af99 344 fHistRefMultiplicity[0]->Fill(CurrentHeader->GetRefMultiplicity());
345 if (fIsPbPb) fHistCentrality[0]->Fill(percentile);
346 if (fIsPbPb) fHistCentralityQuality[0]->Fill(CurrentCentralityQuality);
347 fHistVertexZ[0]->Fill(vtxz);
348 }
a5422983 349
6788af99 350 // Fill the histograms for all events.
a5422983 351 fHistTrigger[1]->Fill(triggerclass);
6788af99 352 fHistRefMultiplicity[1]->Fill(CurrentHeader->GetRefMultiplicity());
353 if (fIsPbPb) fHistCentrality[1]->Fill(percentile);
354 if (fIsPbPb) fHistCentralityQuality[1]->Fill(CurrentCentralityQuality);
355 fHistVertexZ[1]->Fill(vtxz);
a5422983 356
07d62e30 357 //cout<<"Event Selected: "<<select<<endl;
6788af99 358 return select;
359
360}
361
97724bd1 362// -----------------------------------------------------------------------
6788af99 363void AliAODEventCutsDiHadronPID::PrintCuts() {
364
365 // NOT IMPLEMENTED.
50dfda71 366 if (fDebug > 1) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
6788af99 367
368 return;
369
370}