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)
27 #include "TIterator.h"
28 #include "AliAODEvent.h"
29 #include "AliAODHeader.h"
30 #include "AliAODVertex.h"
31 #include "AliCentrality.h"
32 #include "AliAnalysisManager.h"
33 #include "AliInputEventHandler.h"
34 #include "AliAODEventCutsDiHadronPID.h"
38 ClassImp(AliAODEventCutsDiHadronPID);
40 // -----------------------------------------------------------------------
41 AliAODEventCutsDiHadronPID::AliAODEventCutsDiHadronPID():
45 fTrigger(AliVEvent::kMB),
48 fCentralityEstimator("V0M"),
52 fTestCentrality(kFALSE),
54 fTestMinRefMult(kFALSE),
55 fSelectedEventQAHistos(0x0),
56 fAllEventQAHistos(0x0),
58 fHistRefMultiplicity(0x0),
60 fHistCentralityQuality(0x0),
67 // Default Constructor
70 cout<<"AliAODEventCutsDiHadronPID Default Constructor Called."<<endl;
71 if (fDebug > 1) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
75 // -----------------------------------------------------------------------
76 AliAODEventCutsDiHadronPID::AliAODEventCutsDiHadronPID(const char* name):
77 TNamed(name,"AOD Event Cuts"),
80 fTrigger(AliVEvent::kMB),
83 fCentralityEstimator("V0M"),
87 fTestCentrality(kFALSE),
89 fTestMinRefMult(kFALSE),
90 fSelectedEventQAHistos(0x0),
91 fAllEventQAHistos(0x0),
93 fHistRefMultiplicity(0x0),
95 fHistCentralityQuality(0x0),
105 cout<<"AliAODEventCutsDiHadronPID Named Constructor Called."<<endl;
106 if (fDebug > 1) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
110 // -----------------------------------------------------------------------
111 AliAODEventCutsDiHadronPID::~AliAODEventCutsDiHadronPID() {
117 cout<<"AliAODEventCutsDiHadronPID Destructor Called."<<endl;
118 if (fDebug > 1) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
120 if (fSelectedEventQAHistos) delete fSelectedEventQAHistos;
121 fSelectedEventQAHistos = 0x0;
122 if (fAllEventQAHistos) delete fAllEventQAHistos;
123 fAllEventQAHistos = 0x0;
127 // -----------------------------------------------------------------------
128 Long64_t AliAODEventCutsDiHadronPID::Merge(TCollection* list) {
134 cout<<"AliAODEventCutsDiHadronPID Merger Called."<<endl;
135 if (fDebug > 1) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
138 if (list->IsEmpty()) return 1;
140 if (!fSelectedEventQAHistos||!fAllEventQAHistos) {
141 cout<<"AliAODEventCutsDiHadronPID::Merge() - Warning, current object's histograms are missing... Generating."<<endl;
145 TIterator* iter = list->MakeIterator();
148 // List of collections
149 TList collection_fSelectedEventQAHistos;
150 TList collection_fAllEventQAHistos;
154 while ((obj = iter->Next())) {
155 AliAODEventCutsDiHadronPID* entry = dynamic_cast<AliAODEventCutsDiHadronPID*> (obj);
156 if (entry == 0) continue;
158 // Check if the object to be merged really has the same name! (FIXME!)
160 // Getting the lists from obj.
161 TList* list_fSelectedEventQAHistos = entry->GetListOfSelectedEventQAHistos();
162 TList* list_fAllEventQAHistos = entry->GetListOfAllEventQAHistos();
164 // Adding the retrieved lists to the collection.
165 if (list_fSelectedEventQAHistos) collection_fSelectedEventQAHistos.Add(list_fSelectedEventQAHistos);
166 if (list_fAllEventQAHistos) collection_fAllEventQAHistos.Add(list_fAllEventQAHistos);
171 // Merging. Note that we require the original list to exist.
172 // * Assume that if the collection happens to be empty, then nothing will happen.
173 // * All other variables are taken from the original object.
174 if (fSelectedEventQAHistos) fSelectedEventQAHistos->Merge(&collection_fSelectedEventQAHistos);
175 if (fAllEventQAHistos) fAllEventQAHistos->Merge(&collection_fAllEventQAHistos);
183 // -----------------------------------------------------------------------
184 void AliAODEventCutsDiHadronPID::CreateHistos() {
186 cout<<"AliAODEventCutsDiHadronPID - Creating histograms"<<endl;
187 if (fDebug > 1) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
189 // Create list of Event related QA histograms (selected events).
190 fSelectedEventQAHistos = new TList();
191 fSelectedEventQAHistos->SetName("SelectedEventQAHistos");
192 fSelectedEventQAHistos->SetOwner(kTRUE);
194 // The same, but for all events.
195 fAllEventQAHistos = new TList();
196 fAllEventQAHistos->SetName("AllEventQAHistos");
197 fAllEventQAHistos->SetOwner(kTRUE);
199 // Creating arrays of pointers to the QA histos.
200 fHistTrigger = new TH1F*[2];
201 fHistRefMultiplicity = new TH1F*[2];
202 fHistCentrality = new TH1F*[2];
203 fHistCentralityQuality = new TH1F*[2];
204 fHistVertexZ = new TH1F*[2];
206 const char* HistType[2] = {"Selected","All"};
208 for (Int_t iHistType = 0; iHistType < 2; iHistType++) {
210 // Trigger Histogram.
211 fHistTrigger[iHistType] = new TH1F(Form("fHistTrigger%s",HistType[iHistType]),"Trigger;;Count",2,-0.5,1.5);
212 fHistTrigger[iHistType]->GetXaxis()->SetBinLabel(1,"kMB");
213 fHistTrigger[iHistType]->GetXaxis()->SetBinLabel(2,"Other");
214 if (iHistType == 0) fSelectedEventQAHistos->Add(fHistTrigger[iHistType]);
215 else fAllEventQAHistos->Add(fHistTrigger[iHistType]);
217 // Ref Multiplicity Histogram.
218 fHistRefMultiplicity[iHistType] = new TH1F(Form("fHistRefMultiplicity%s",HistType[iHistType]),"Reference Multiplicity;N_{tracks};Count",100,0.,10000.);
219 if (iHistType == 0) fSelectedEventQAHistos->Add(fHistRefMultiplicity[iHistType]);
220 else fAllEventQAHistos->Add(fHistRefMultiplicity[iHistType]);
222 // Centrality Histogram.
223 fHistCentrality[iHistType] = new TH1F(Form("fHistCentrality%s",HistType[iHistType]),"Centrality;Centrality;Count",20,0,100);
224 if (iHistType == 0) fSelectedEventQAHistos->Add(fHistCentrality[iHistType]);
225 else fAllEventQAHistos->Add(fHistCentrality[iHistType]);
227 // Centrality Quality.
228 fHistCentralityQuality[iHistType] = new TH1F(Form("fHistCentralityQuality%s",HistType[iHistType]),"Centrality Quality;Quality;Count",2,-0.5,1.5);
229 fHistCentralityQuality[iHistType]->GetXaxis()->SetBinLabel(1,"0");
230 fHistCentralityQuality[iHistType]->GetXaxis()->SetBinLabel(2,"Other");
231 if (iHistType == 0) fSelectedEventQAHistos->Add(fHistCentralityQuality[iHistType]);
232 else fAllEventQAHistos->Add(fHistCentralityQuality[iHistType]);
234 // VertexZ Histogram.
235 fHistVertexZ[iHistType] = new TH1F(Form("fHistVertexZ%s",HistType[iHistType]),"VertexZ;z (cm);Count",60,-15.,15.);
236 if (iHistType == 0) fSelectedEventQAHistos->Add(fHistVertexZ[iHistType]);
237 else fAllEventQAHistos->Add(fHistVertexZ[iHistType]);
243 // -----------------------------------------------------------------------
244 Bool_t AliAODEventCutsDiHadronPID::IsSelected(AliAODEvent* event) {
246 if (fDebug > 1) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
248 if (!event) return kFALSE;
250 if (!fAllEventQAHistos||!fSelectedEventQAHistos) {cout<<"AliAODEventCutsDiHadronPID - Histograms were not created, you should have called CreateHistos()..."<<endl;}
252 // Input the event handler.
253 AliInputEventHandler* InputHandler = (AliInputEventHandler*)((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
254 if (!InputHandler) return kFALSE;
256 Bool_t select = kTRUE;
259 UInt_t trigger = InputHandler->IsEventSelected();
260 Int_t triggerselect = 0; // 0 = selected.
262 if (!(trigger & fTrigger)) {
264 triggerselect = 1; // 1 = not selected.
268 AliCentrality* CurrentCentrality = 0x0;
269 Int_t CurrentCentralityQuality = -999;
270 Float_t percentile = -999.;
274 // Get the centrality object.
275 CurrentCentrality = event->GetCentrality();
276 if (!CurrentCentrality) {select = kFALSE; return select;}
278 // Check the quality of the centrality estimation.
279 // If 0 then quality is OK, c.f. TOF/PbPb276/macros/TOFmatchEff.C
280 CurrentCentralityQuality = CurrentCentrality->GetQuality();
281 //cout<<"Centrality: "<<CurrentCentrality->GetCentralityPercentile(fCentralityEstimator.Data())<<" Quality: "<<CurrentCentrality->GetQuality()<<endl;
282 if (CurrentCentralityQuality) select = kFALSE;
285 percentile = CurrentCentrality->GetCentralityPercentile(fCentralityEstimator.Data());
286 if (fTestCentrality) {
287 if ((percentile < fMaxCentrality)||(percentile > fMinCentrality)) select = kFALSE;
292 // Get the primary vertex.
293 AliAODVertex* CurrentPrimaryVertex = event->GetPrimaryVertex();
294 if (!CurrentPrimaryVertex) {select = kFALSE; return select;}
297 Double_t vtxz = CurrentPrimaryVertex->GetZ();
299 if (TMath::Abs(vtxz) > fMaxVertexZ) select = kFALSE;
302 // Get the event header.
303 AliAODHeader* CurrentHeader = event->GetHeader();
305 // Test minimum reference multiplicity.
306 Int_t CurrentRefMultiplicity = CurrentHeader->GetRefMultiplicity();
307 if (fTestMinRefMult) {
308 if (CurrentRefMultiplicity < fMinRefMult) select = kFALSE;
311 // Fill the histograms for selected events.
313 fHistTrigger[0]->Fill(triggerselect);
314 fHistRefMultiplicity[0]->Fill(CurrentHeader->GetRefMultiplicity());
315 if (fIsPbPb) fHistCentrality[0]->Fill(percentile);
316 if (fIsPbPb) fHistCentralityQuality[0]->Fill(CurrentCentralityQuality);
317 fHistVertexZ[0]->Fill(vtxz);
320 // Fill the histograms for all events.
321 fHistTrigger[1]->Fill(triggerselect);
322 fHistRefMultiplicity[1]->Fill(CurrentHeader->GetRefMultiplicity());
323 if (fIsPbPb) fHistCentrality[1]->Fill(percentile);
324 if (fIsPbPb) fHistCentralityQuality[1]->Fill(CurrentCentralityQuality);
325 fHistVertexZ[1]->Fill(vtxz);
327 //cout<<"Event Selected: "<<select<<endl;
333 // -----------------------------------------------------------------------
334 void AliAODEventCutsDiHadronPID::PrintCuts() {
337 if (fDebug > 1) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}