1 /*************************************************************************
2 * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 // -----------------------------------------------------------------------
17 // Event Cut class for the DiHadronPID analysis.
18 // -----------------------------------------------------------------------
19 // Author: Misha Veldhoen (misha.veldhoen@cern.ch)
21 #include "AliAODEventCutsDiHadronPID.h"
31 #include "TIterator.h"
32 #include "AliAODHeader.h"
33 #include "AliAODVertex.h"
34 #include "AliCentrality.h"
35 #include "AliAnalysisManager.h"
36 #include "AliInputEventHandler.h"
38 ClassImp(AliAODEventCutsDiHadronPID);
40 // -----------------------------------------------------------------------
41 AliAODEventCutsDiHadronPID::AliAODEventCutsDiHadronPID():
45 fTrigger(AliVEvent::kMB),
48 fCentralityEstimator("V0M"),
52 fTestCentrality(kFALSE),
53 fTestContributorsOrSPDVertex(kFALSE),
55 fTestMinRefMult(kFALSE),
56 fSelectedEventQAHistos(0x0),
57 fAllEventQAHistos(0x0),
59 fHistRefMultiplicity(0x0),
61 fHistCentralityQuality(0x0),
68 // Default Constructor
71 cout<<"AliAODEventCutsDiHadronPID Default Constructor Called."<<endl;
72 if (fDebug > 1) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
76 // -----------------------------------------------------------------------
77 AliAODEventCutsDiHadronPID::AliAODEventCutsDiHadronPID(const char* name):
78 TNamed(name,"AOD Event Cuts"),
81 fTrigger(AliVEvent::kMB),
84 fCentralityEstimator("V0M"),
88 fTestCentrality(kFALSE),
89 fTestContributorsOrSPDVertex(kFALSE),
91 fTestMinRefMult(kFALSE),
92 fSelectedEventQAHistos(0x0),
93 fAllEventQAHistos(0x0),
95 fHistRefMultiplicity(0x0),
97 fHistCentralityQuality(0x0),
107 cout<<"AliAODEventCutsDiHadronPID Named Constructor Called."<<endl;
108 if (fDebug > 1) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
112 // -----------------------------------------------------------------------
113 AliAODEventCutsDiHadronPID::~AliAODEventCutsDiHadronPID() {
119 cout<<"AliAODEventCutsDiHadronPID Destructor Called."<<endl;
120 if (fDebug > 1) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
122 if (fSelectedEventQAHistos) delete fSelectedEventQAHistos;
123 fSelectedEventQAHistos = 0x0;
124 if (fAllEventQAHistos) delete fAllEventQAHistos;
125 fAllEventQAHistos = 0x0;
129 // -----------------------------------------------------------------------
130 Long64_t AliAODEventCutsDiHadronPID::Merge(TCollection* list) {
136 cout<<"AliAODEventCutsDiHadronPID Merger Called."<<endl;
137 if (fDebug > 1) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
140 if (list->IsEmpty()) return 1;
142 if (!fSelectedEventQAHistos||!fAllEventQAHistos) {
143 cout<<"AliAODEventCutsDiHadronPID::Merge() - Warning, current object's histograms are missing... Generating."<<endl;
147 TIterator* iter = list->MakeIterator();
150 // List of collections
151 TList collection_fSelectedEventQAHistos;
152 TList collection_fAllEventQAHistos;
156 while ((obj = iter->Next())) {
157 AliAODEventCutsDiHadronPID* entry = dynamic_cast<AliAODEventCutsDiHadronPID*> (obj);
158 if (entry == 0) continue;
160 // Check if the object to be merged really has the same name! (FIXME!)
162 // Getting the lists from obj.
163 TList* list_fSelectedEventQAHistos = entry->GetListOfSelectedEventQAHistos();
164 TList* list_fAllEventQAHistos = entry->GetListOfAllEventQAHistos();
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);
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);
185 // -----------------------------------------------------------------------
186 void AliAODEventCutsDiHadronPID::CreateHistos() {
188 cout<<"AliAODEventCutsDiHadronPID - Creating histograms"<<endl;
189 if (fDebug > 1) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
191 // Create list of Event related QA histograms (selected events).
192 fSelectedEventQAHistos = new TList();
193 fSelectedEventQAHistos->SetName("SelectedEventQAHistos");
194 fSelectedEventQAHistos->SetOwner(kTRUE);
196 // The same, but for all events.
197 fAllEventQAHistos = new TList();
198 fAllEventQAHistos->SetName("AllEventQAHistos");
199 fAllEventQAHistos->SetOwner(kTRUE);
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];
208 const char* HistType[2] = {"Selected","All"};
210 for (Int_t iHistType = 0; iHistType < 2; iHistType++) {
212 // Trigger Histogram.
213 fHistTrigger[iHistType] = new TH1F(Form("fHistTrigger%s",HistType[iHistType]),"Trigger;;Count",5,-0.5,4.5);
214 fHistTrigger[iHistType]->GetXaxis()->SetBinLabel(1,"kMB");
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");
219 if (iHistType == 0) fSelectedEventQAHistos->Add(fHistTrigger[iHistType]);
220 else fAllEventQAHistos->Add(fHistTrigger[iHistType]);
222 // Ref Multiplicity Histogram.
224 fHistRefMultiplicity[iHistType] = new TH1F(Form("fHistRefMultiplicity%s",HistType[iHistType]),"Reference Multiplicity;N_{tracks};Count",100,0.,10000.);
226 fHistRefMultiplicity[iHistType] = new TH1F(Form("fHistRefMultiplicity%s",HistType[iHistType]),"Reference Multiplicity;N_{tracks};Count",100,0.,100.);
228 if (iHistType == 0) fSelectedEventQAHistos->Add(fHistRefMultiplicity[iHistType]);
229 else fAllEventQAHistos->Add(fHistRefMultiplicity[iHistType]);
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]);
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]);
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]);
252 // -----------------------------------------------------------------------
253 Bool_t AliAODEventCutsDiHadronPID::IsSelected(AliAODEvent* event) {
255 if (fDebug > 1) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
257 if (!event) return kFALSE;
259 if (!fAllEventQAHistos||!fSelectedEventQAHistos) {cout<<"AliAODEventCutsDiHadronPID - Histograms were not created, you should have called CreateHistos()..."<<endl;}
261 // Input the event handler.
262 AliInputEventHandler* InputHandler = (AliInputEventHandler*)((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
263 if (!InputHandler) return kFALSE;
265 Bool_t select = kTRUE;
268 UInt_t trigger = InputHandler->IsEventSelected();
269 Int_t triggerclass = -1; // 0 = kMB, 1 = kCentral, 2 = kSemiCentral, 3 = Other.
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;}
279 if (!(trigger & fTrigger)) {select = kFALSE;} // Event not selected if not matched with the any of the desired triggers.
282 AliCentrality* CurrentCentrality = 0x0;
283 Int_t CurrentCentralityQuality = -999;
284 Float_t percentile = -999.;
288 // Get the centrality object.
289 CurrentCentrality = event->GetCentrality();
290 //cout<<"Centrality object: "<<CurrentCentrality<<endl;
291 if (!CurrentCentrality) {select = kFALSE; return select;}
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();
296 //cout<<"Centrality: "<<CurrentCentrality->GetCentralityPercentile(fCentralityEstimator.Data())<<" Quality: "<<CurrentCentrality->GetQuality()<<endl;
297 if (CurrentCentralityQuality) select = kFALSE;
300 percentile = CurrentCentrality->GetCentralityPercentile(fCentralityEstimator.Data());
301 if (fTestCentrality) {
302 if ((percentile < fMaxCentrality)||(percentile > fMinCentrality)) select = kFALSE;
307 // Get the primary vertex.
308 AliAODVertex* CurrentPrimaryVertex = event->GetPrimaryVertex();
309 if (!CurrentPrimaryVertex) {select = kFALSE; return select;}
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();
320 if (TMath::Abs(vtxz) > fMaxVertexZ) select = kFALSE;
323 // Test number of contributors.
324 if (fTestContributorsOrSPDVertex) {
325 Int_t nContributors = CurrentPrimaryVertex->GetNContributors();
326 if (nContributors < 1) {
327 if (CurrentPrimaryVertex->GetType() != AliAODVertex::kMainSPD ) {select = kFALSE;}
331 // Get the event header.
332 AliAODHeader* CurrentHeader = dynamic_cast<AliAODHeader*>(event->GetHeader());
333 if(!CurrentHeader) AliFatal("Not a standard AOD");
335 // Test minimum reference multiplicity.
336 Int_t CurrentRefMultiplicity = CurrentHeader->GetRefMultiplicity();
337 if (fTestMinRefMult) {
338 if (CurrentRefMultiplicity < fMinRefMult) select = kFALSE;
341 // Fill the histograms for selected events.
343 fHistTrigger[0]->Fill(triggerclass);
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);
350 // Fill the histograms for all events.
351 fHistTrigger[1]->Fill(triggerclass);
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);
357 //cout<<"Event Selected: "<<select<<endl;
362 // -----------------------------------------------------------------------
363 void AliAODEventCutsDiHadronPID::PrintCuts() {
366 if (fDebug > 1) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}