e0331fd9 |
1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | /* $Id:$ */ |
17 | |
18 | #include <TROOT.h> |
19 | #include <TChain.h> |
20 | #include <TFile.h> |
21 | #include <TList.h> |
22 | #include <TMath.h> |
23 | #include <TTree.h> |
24 | #include <TH2F.h> |
25 | #include <TRandom.h> |
26 | |
27 | #include "AliAnalysisTaskPhiCorrelations.h" |
28 | #include "AliAnalyseLeadingTrackUE.h" |
29 | #include "AliUEHistograms.h" |
30 | #include "AliUEHist.h" |
31 | |
e0331fd9 |
32 | #include "AliAnalysisManager.h" |
33 | #include "AliAODHandler.h" |
34 | #include "AliAODInputHandler.h" |
35 | #include "AliAODMCParticle.h" |
e0331fd9 |
36 | #include "AliInputEventHandler.h" |
37 | #include "AliLog.h" |
38 | #include "AliMCEventHandler.h" |
39 | #include "AliVParticle.h" |
2a910c25 |
40 | #include "AliCFContainer.h" |
e0331fd9 |
41 | |
42 | #include "AliESDEvent.h" |
43 | #include "AliESDInputHandler.h" |
44 | #include "AliMultiplicity.h" |
2a910c25 |
45 | #include "AliCentrality.h" |
46 | #include "AliStack.h" |
e0331fd9 |
47 | |
2a910c25 |
48 | #include "AliEventPoolManager.h" |
e0331fd9 |
49 | |
50 | |
51 | //////////////////////////////////////////////////////////////////////// |
52 | // |
53 | // Analysis class for azimuthal correlation studies |
54 | // Based on the UE task from Sara Vallero and Jan Fiete |
55 | // |
56 | // This class needs input AODs. |
57 | // The output is a list of analysis-specific containers. |
58 | // |
59 | // The AOD can be either connected to the InputEventHandler |
60 | // for a chain of AOD files |
61 | // or |
62 | // to the OutputEventHandler |
63 | // for a chain of ESD files, |
64 | // in this case the class should be in the train after the jet-finder |
65 | // |
66 | // Authors: |
67 | // Jan Fiete Grosse-Oetringhaus |
68 | // |
69 | //////////////////////////////////////////////////////////////////////// |
70 | |
71 | |
72 | ClassImp( AliAnalysisTaskPhiCorrelations ) |
a1c31636 |
73 | ClassImp( AliDPhiBasicParticle ) |
e0331fd9 |
74 | |
75 | //____________________________________________________________________ |
76 | AliAnalysisTaskPhiCorrelations:: AliAnalysisTaskPhiCorrelations(const char* name): |
77 | AliAnalysisTask(name,""), |
78 | // general configuration |
79 | fDebug(0), |
80 | fMode(0), |
81 | fReduceMemoryFootprint(kFALSE), |
eed401dc |
82 | fFillMixed(kTRUE), |
ac647b0f |
83 | fMixingTracks(50000), |
c3294f09 |
84 | fCompareCentralities(kFALSE), |
1bba939a |
85 | fTwoTrackEfficiencyStudy(kFALSE), |
44af28f9 |
86 | fUseVtxAxis(kFALSE), |
e0331fd9 |
87 | // pointers to UE classes |
88 | fAnalyseUE(0x0), |
89 | fHistos(0x0), |
90 | fHistosMixed(0), |
91 | fkTrackingEfficiency(0x0), |
92 | // handlers and events |
85bfac17 |
93 | fAOD(0x0), |
94 | fESD(0x0), |
e0331fd9 |
95 | fArrayMC(0x0), |
96 | fInputHandler(0x0), |
97 | fMcEvent(0x0), |
98 | fMcHandler(0x0), |
2a910c25 |
99 | fPoolMgr(0x0), |
e0331fd9 |
100 | // histogram settings |
101 | fListOfHistos(0x0), |
102 | // event QA |
103 | fnTracksVertex(1), // QA tracks pointing to principal vertex (= 3 default) |
85bfac17 |
104 | fZVertex(7.), |
2a910c25 |
105 | fCentralityMethod("V0M"), |
e0331fd9 |
106 | // track cuts |
107 | fTrackEtaCut(0.8), |
108 | fPtMin(0.5), |
109 | fFilterBit(0xFF), |
110 | fSelectBit(0), |
2a910c25 |
111 | fUseChargeHadrons(kFALSE), |
c05ff6be |
112 | fSelectCharge(0), |
113 | fFillpT(kFALSE) |
e0331fd9 |
114 | { |
115 | // Default constructor |
116 | // Define input and output slots here |
117 | // Input slot #0 works with a TChain |
118 | DefineInput(0, TChain::Class()); |
119 | // Output slot #0 writes into a TList container |
120 | DefineOutput(0, TList::Class()); |
e0331fd9 |
121 | } |
122 | |
123 | AliAnalysisTaskPhiCorrelations::~AliAnalysisTaskPhiCorrelations() |
124 | { |
125 | // destructor |
126 | |
127 | if (fListOfHistos && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) |
128 | delete fListOfHistos; |
129 | } |
130 | |
131 | //____________________________________________________________________ |
132 | void AliAnalysisTaskPhiCorrelations::ConnectInputData(Option_t* /*option*/) |
133 | { |
134 | |
135 | // Connect the input data |
136 | if (fDebug > 1) AliInfo("ConnectInputData() "); |
137 | |
138 | // Since AODs can either be connected to the InputEventHandler |
139 | // or to the OutputEventHandler ( the AOD is created by a previus task in the train ) |
140 | // we need to get the pointer to the AODEvent correctly. |
141 | |
142 | // Delta AODs are also accepted. |
143 | |
144 | TObject* handler = AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler(); |
145 | |
85bfac17 |
146 | if( handler && handler->InheritsFrom("AliAODInputHandler") ) |
147 | { // input AOD |
148 | fAOD = ((AliAODInputHandler*)handler)->GetEvent(); |
149 | if (fDebug > 1) AliInfo(" ==== Tracks and Jets from AliAODInputHandler"); |
150 | } |
151 | else |
152 | { //output AOD |
153 | handler = AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler(); |
154 | if (handler && handler->InheritsFrom("AliAODHandler") ) |
155 | { |
156 | fAOD = ((AliAODHandler*)handler)->GetAOD(); |
157 | if (fDebug > 1) AliInfo(" ==== Tracks and Jets from AliAODHandler"); |
158 | } |
159 | else |
160 | { // no AOD |
161 | AliWarning("I can't get any AOD Event Handler"); |
162 | } |
163 | } |
164 | |
165 | if (handler && handler->InheritsFrom("AliESDInputHandler") ) |
166 | { // input ESD |
167 | // pointer received per event in ::Exec |
168 | if (fDebug > 1) AliInfo(" ==== Tracks and Jets from AliESDInputHandler"); |
169 | } |
e0331fd9 |
170 | |
171 | // Initialize common pointers |
172 | Initialize(); |
e0331fd9 |
173 | } |
174 | |
175 | //____________________________________________________________________ |
176 | void AliAnalysisTaskPhiCorrelations::CreateOutputObjects() |
177 | { |
178 | // Create the output container |
179 | |
180 | if (fDebug > 1) AliInfo("CreateOutputObjects()"); |
181 | |
182 | // Initialize class with main algorithms, event and track selection. |
183 | fAnalyseUE = new AliAnalyseLeadingTrackUE(); |
2a910c25 |
184 | fAnalyseUE->SetParticleSelectionCriteria(fFilterBit, fUseChargeHadrons, fTrackEtaCut, fPtMin); |
e0331fd9 |
185 | fAnalyseUE->SetDebug(fDebug); |
85bfac17 |
186 | fAnalyseUE->DefineESDCuts(fFilterBit); |
e0331fd9 |
187 | |
188 | // Initialize output list of containers |
189 | if (fListOfHistos != NULL){ |
190 | delete fListOfHistos; |
191 | fListOfHistos = NULL; |
192 | } |
193 | if (!fListOfHistos){ |
194 | fListOfHistos = new TList(); |
195 | fListOfHistos->SetOwner(kTRUE); |
196 | } |
197 | |
198 | // Initialize class to handle histograms |
44af28f9 |
199 | const char* histType = "4"; |
200 | if (fUseVtxAxis) |
201 | histType = "5"; |
202 | fHistos = new AliUEHistograms("AliUEHistogramsSame", histType); |
203 | fHistosMixed = new AliUEHistograms("AliUEHistogramsMixed", histType); |
e0331fd9 |
204 | |
2a910c25 |
205 | fHistos->SetSelectCharge(fSelectCharge); |
206 | fHistosMixed->SetSelectCharge(fSelectCharge); |
207 | |
e0331fd9 |
208 | // add histograms to list |
209 | fListOfHistos->Add(fHistos); |
210 | fListOfHistos->Add(fHistosMixed); |
211 | |
2a910c25 |
212 | fListOfHistos->Add(new TH2F("trackletsVsV0Cent", ";L1 clusters;v0 centrality", 100, -0.5, 9999.5, 101, 0, 101)); |
213 | fListOfHistos->Add(new TH2F("processIDs", ";#Delta#phi;process id", 100, -0.5 * TMath::Pi(), 1.5 * TMath::Pi(), kPNoProcess + 1, -0.5, kPNoProcess + 0.5)); |
c066889a |
214 | fListOfHistos->Add(new TH1F("eventStat", ";;events", 4, -0.5, 3.5)); |
215 | fListOfHistos->Add(new TH1F("mixedDist", ";tracks;events", 200, 0, fMixingTracks * 1.5)); |
e0331fd9 |
216 | |
1a32ecc0 |
217 | PostData(0,fListOfHistos); |
218 | |
e0331fd9 |
219 | // Add task configuration to output list |
220 | AddSettingsTree(); |
221 | |
2a910c25 |
222 | // event mixing |
ac647b0f |
223 | Int_t trackDepth = fMixingTracks; |
a1c31636 |
224 | Int_t poolsize = 1000; // Maximum number of events, ignored in the present implemented of AliEventPool |
c066889a |
225 | |
2a910c25 |
226 | Int_t nCentralityBins = fHistos->GetUEHist(2)->GetEventHist()->GetNBins(1); |
227 | Double_t* centralityBins = (Double_t*) fHistos->GetUEHist(2)->GetEventHist()->GetAxis(1, 0)->GetXbins()->GetArray(); |
228 | |
eb88bdfe |
229 | Int_t nZvtxBins = 7; |
230 | Double_t vertexBins[] = { -7, -5, -3, -1, 1, 3, 5, 7 }; |
231 | Double_t* zvtxbin = vertexBins; |
c066889a |
232 | |
eb88bdfe |
233 | if (fHistos->GetUEHist(2)->GetEventHist()->GetNVar() > 2) |
234 | { |
235 | nZvtxBins = fHistos->GetUEHist(2)->GetEventHist()->GetNBins(2); |
236 | zvtxbin = (Double_t*) fHistos->GetUEHist(2)->GetEventHist()->GetAxis(2, 0)->GetXbins()->GetArray(); |
237 | } |
85bfac17 |
238 | |
2a910c25 |
239 | fPoolMgr = new AliEventPoolManager(poolsize, trackDepth, nCentralityBins, centralityBins, nZvtxBins, zvtxbin); |
e0331fd9 |
240 | } |
241 | |
242 | //____________________________________________________________________ |
243 | void AliAnalysisTaskPhiCorrelations::Exec(Option_t */*option*/) |
244 | { |
245 | // array of MC particles |
85bfac17 |
246 | if (fMcHandler) { |
247 | if (fAOD) |
248 | { |
249 | fArrayMC = dynamic_cast<TClonesArray*>(fAOD->FindListObject(AliAODMCParticle::StdBranchName())); |
250 | if (!fArrayMC) |
251 | AliFatal("No array of MC particles found !!!"); |
252 | } |
2a910c25 |
253 | fMcEvent = fMcHandler->MCEvent(); |
254 | } |
e0331fd9 |
255 | |
85bfac17 |
256 | // receive ESD pointer if we are not running AOD analysis |
257 | if (!fAOD) |
258 | { |
259 | AliVEventHandler* handler = AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler(); |
260 | if (handler && handler->InheritsFrom("AliESDInputHandler")) |
261 | fESD = ((AliESDInputHandler*)handler)->GetEvent(); |
262 | } |
263 | |
e0331fd9 |
264 | // Analyse the event |
265 | if (fMode) AnalyseCorrectionMode(); |
266 | else AnalyseDataMode(); |
e0331fd9 |
267 | } |
268 | |
269 | /******************** ANALYSIS METHODS *****************************/ |
270 | |
271 | //____________________________________________________________________ |
272 | void AliAnalysisTaskPhiCorrelations::AddSettingsTree() |
273 | { |
274 | //Write settings to output list |
275 | TTree *settingsTree = new TTree("UEAnalysisSettings","Analysis Settings in UE estimation"); |
c05ff6be |
276 | settingsTree->Branch("fnTracksVertex", &fnTracksVertex,"nTracksVertex/I"); |
277 | settingsTree->Branch("fZVertex", &fZVertex,"ZVertex/D"); |
278 | //settingsTree->Branch("fCentralityMethod", fCentralityMethod.Data(),"CentralityMethod/C"); |
e0331fd9 |
279 | settingsTree->Branch("fTrackEtaCut", &fTrackEtaCut, "TrackEtaCut/D"); |
280 | settingsTree->Branch("fPtMin", &fPtMin, "PtMin/D"); |
c05ff6be |
281 | settingsTree->Branch("fFilterBit", &fFilterBit,"FilterBit/I"); |
282 | settingsTree->Branch("fSelectBit", &fSelectBit,"EventSelectionBit/I"); |
e0331fd9 |
283 | settingsTree->Branch("fUseChargeHadrons", &fUseChargeHadrons,"UseChHadrons/O"); |
c05ff6be |
284 | settingsTree->Branch("fSelectCharge", &fSelectCharge,"SelectCharge/I"); |
285 | settingsTree->Branch("fFillpT", &fFillpT,"FillpT/O"); |
e0331fd9 |
286 | settingsTree->Branch("fkTrackingEfficiency", "TH1D", &fkTrackingEfficiency); |
ac647b0f |
287 | settingsTree->Branch("fMixingTracks", &fMixingTracks,"MixingTracks/I"); |
e0331fd9 |
288 | settingsTree->Fill(); |
289 | fListOfHistos->Add(settingsTree); |
290 | } |
291 | |
292 | //____________________________________________________________________ |
293 | void AliAnalysisTaskPhiCorrelations::AnalyseCorrectionMode() |
294 | { |
295 | // Run the analysis on MC to get the correction maps |
296 | // |
297 | |
2a910c25 |
298 | if ( fDebug > 3 ) AliInfo( " Processing event in Corrections mode ..." ); |
299 | |
300 | Double_t centrality = 0; |
301 | |
302 | if (fCentralityMethod.Length() > 0) |
303 | { |
85bfac17 |
304 | AliCentrality *centralityObj = 0; |
305 | if (fAOD) |
306 | centralityObj = fAOD->GetHeader()->GetCentralityP(); |
307 | else if (fESD) |
308 | centralityObj = fESD->GetCentrality(); |
309 | |
2a910c25 |
310 | if (centralityObj) |
311 | { |
312 | centrality = centralityObj->GetCentralityPercentileUnchecked(fCentralityMethod); |
a8583211 |
313 | AliInfo(Form("Centrality is %f", centrality)); |
2a910c25 |
314 | } |
315 | else |
316 | { |
317 | Printf("WARNING: Centrality object is 0"); |
318 | centrality = -1; |
319 | } |
320 | } |
321 | |
85bfac17 |
322 | // Support for ESD and AOD based analysis |
323 | AliVEvent* inputEvent = fAOD; |
324 | if (!inputEvent) |
325 | inputEvent = fESD; |
326 | |
327 | TObject* mc = fArrayMC; |
328 | if (!mc) |
329 | mc = fMcEvent; |
330 | |
2a910c25 |
331 | // count all events |
332 | fHistos->FillEvent(centrality, -1); |
333 | |
334 | // Only consider MC events within the vtx-z region used also as cut on the reconstructed vertex |
335 | if (!fAnalyseUE->VertexSelection(fMcEvent, 0, fZVertex)) |
336 | return; |
85bfac17 |
337 | |
338 | Float_t zVtx = fMcEvent->GetPrimaryVertex()->GetZ(); |
c05ff6be |
339 | Float_t weight = 1; |
340 | if (fFillpT) |
341 | weight = -1; |
2a910c25 |
342 | |
343 | // Get MC primaries |
85bfac17 |
344 | TObjArray* tracksMC = fAnalyseUE->GetAcceptedParticles(mc, 0, kTRUE, -1, kTRUE); |
2a910c25 |
345 | |
346 | // (MC-true all particles) |
347 | // STEP 0 |
c05ff6be |
348 | fHistos->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepAll, tracksMC, 0, weight); |
2a910c25 |
349 | |
350 | // Trigger selection ************************************************ |
351 | if (fAnalyseUE->TriggerSelection(fInputHandler)) |
352 | { |
c32a0ca9 |
353 | // (MC-true all particles) |
354 | // STEP 1 |
355 | if (!fReduceMemoryFootprint) |
c05ff6be |
356 | fHistos->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepTriggered, tracksMC, 0, weight); |
c32a0ca9 |
357 | else |
358 | fHistos->FillEvent(centrality, AliUEHist::kCFStepTriggered); |
359 | |
872dc651 |
360 | if (!inputEvent) { |
c32a0ca9 |
361 | AliFatal("UNEXPECTED: inputEvent is 0. Trigger selection should have failed"); |
872dc651 |
362 | return; |
363 | } |
2a910c25 |
364 | |
365 | // Vertex selection ************************************************* |
85bfac17 |
366 | if (fAnalyseUE->VertexSelection(inputEvent, fnTracksVertex, fZVertex)) |
2a910c25 |
367 | { |
368 | // fill here for tracking efficiency |
369 | // loop over particle species |
370 | |
371 | for (Int_t particleSpecies = 0; particleSpecies < 4; particleSpecies++) |
372 | { |
85bfac17 |
373 | TObjArray* primMCParticles = fAnalyseUE->GetAcceptedParticles(mc, 0x0, kTRUE, particleSpecies, kTRUE); |
374 | TObjArray* primRecoTracksMatched = fAnalyseUE->GetAcceptedParticles(inputEvent, mc, kTRUE, particleSpecies, kTRUE); |
375 | TObjArray* allRecoTracksMatched = fAnalyseUE->GetAcceptedParticles(inputEvent, mc, kFALSE, particleSpecies, kTRUE); |
2a910c25 |
376 | |
377 | fHistos->FillTrackingEfficiency(primMCParticles, primRecoTracksMatched, allRecoTracksMatched, particleSpecies, centrality); |
378 | |
eed401dc |
379 | // Printf("%d --> %d %d %d", particleSpecies, primMCParticles->GetEntries(), primRecoTracksMatched->GetEntries(), allRecoTracksMatched->GetEntries()); |
380 | |
381 | delete primMCParticles; |
2a910c25 |
382 | delete primRecoTracksMatched; |
383 | delete allRecoTracksMatched; |
384 | } |
385 | |
386 | // (MC-true all particles) |
387 | // STEP 2 |
85bfac17 |
388 | if (!fReduceMemoryFootprint) |
c05ff6be |
389 | fHistos->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepVertex, tracksMC, 0, weight); |
c32a0ca9 |
390 | else |
391 | fHistos->FillEvent(centrality, AliUEHist::kCFStepVertex); |
2a910c25 |
392 | |
393 | // Get MC primaries that match reconstructed track |
85bfac17 |
394 | TObjArray* tracksRecoMatchedPrim = fAnalyseUE->GetAcceptedParticles(inputEvent, mc, kTRUE, -1, kTRUE); |
2a910c25 |
395 | |
396 | // (RECO-matched (quantities from MC particle) primary particles) |
397 | // STEP 4 |
c05ff6be |
398 | fHistos->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepTrackedOnlyPrim, tracksRecoMatchedPrim, 0, weight); |
2a910c25 |
399 | |
400 | // Get MC primaries + secondaries that match reconstructed track |
85bfac17 |
401 | TObjArray* tracksRecoMatchedAll = fAnalyseUE->GetAcceptedParticles(inputEvent, mc, kFALSE, -1, kTRUE); |
2a910c25 |
402 | |
403 | // (RECO-matched (quantities from MC particle) all particles) |
404 | // STEP 5 |
c05ff6be |
405 | fHistos->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepTracked, tracksRecoMatchedAll, 0, weight); |
2a910c25 |
406 | |
407 | // Get RECO tracks |
85bfac17 |
408 | TObjArray* tracks = fAnalyseUE->GetAcceptedParticles(inputEvent, 0, kTRUE, -1, kTRUE); |
2a910c25 |
409 | |
410 | // (RECO all tracks) |
411 | // STEP 6 |
c05ff6be |
412 | fHistos->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepReconstructed, tracks, 0, weight); |
2a910c25 |
413 | |
85bfac17 |
414 | if (0 && !fReduceMemoryFootprint) |
2a910c25 |
415 | { |
416 | // make list of secondaries (matched with MC) |
417 | TObjArray* tracksRecoMatchedSecondaries = new TObjArray; |
418 | for (Int_t i=0; i<tracksRecoMatchedAll->GetEntries(); i++) |
419 | if (((AliAODMCParticle*)tracksRecoMatchedAll->At(i))->IsPhysicalPrimary() == kFALSE) |
420 | tracksRecoMatchedSecondaries->Add(tracksRecoMatchedAll->At(i)); |
421 | |
422 | // Study: Use only secondaries as trigger particles and plot the correlation vs. all particles; store in step 9 |
c05ff6be |
423 | fHistos->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepBiasStudy2, tracksRecoMatchedSecondaries, tracksRecoMatchedAll, weight); |
2a910c25 |
424 | |
425 | // Study: Use only primaries as trigger particles and plot the correlation vs. secondaries; store in step 8 |
c05ff6be |
426 | fHistos->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepBiasStudy, tracksRecoMatchedPrim, tracksRecoMatchedSecondaries, weight); |
2a910c25 |
427 | |
428 | // plot delta phi vs process id of secondaries |
429 | // trigger particles: primaries in 4 < pT < 10 |
430 | // associated particles: secondaries in 1 < pT < 10 |
431 | |
432 | for (Int_t i=0; i<tracksRecoMatchedPrim->GetEntries(); i++) |
433 | { |
434 | AliVParticle* triggerParticle = (AliVParticle*) tracksRecoMatchedPrim->At(i); |
435 | |
436 | if (triggerParticle->Pt() < 4 || triggerParticle->Pt() > 10) |
437 | continue; |
438 | |
439 | for (Int_t j=0; j<tracksRecoMatchedSecondaries->GetEntries(); j++) |
440 | { |
441 | AliAODMCParticle* particle = (AliAODMCParticle*) tracksRecoMatchedSecondaries->At(j); |
442 | |
443 | if (particle->Pt() < 1 || particle->Pt() > 10) |
444 | continue; |
445 | |
446 | if (particle->Pt() > triggerParticle->Pt()) |
447 | continue; |
448 | |
449 | Double_t deltaPhi = triggerParticle->Phi() - particle->Phi(); |
450 | if (deltaPhi > 1.5 * TMath::Pi()) |
451 | deltaPhi -= TMath::TwoPi(); |
452 | if (deltaPhi < -0.5 * TMath::Pi()) |
453 | deltaPhi += TMath::TwoPi(); |
454 | |
455 | Int_t processID = fMcEvent->Stack()->Particle(particle->GetLabel())->GetUniqueID(); |
456 | |
457 | ((TH2F*) fListOfHistos->FindObject("processIDs"))->Fill(deltaPhi, processID); |
458 | } |
459 | } |
460 | |
461 | delete tracksRecoMatchedSecondaries; |
462 | } |
463 | |
464 | delete tracksRecoMatchedPrim; |
465 | delete tracksRecoMatchedAll; |
466 | delete tracks; |
467 | } |
468 | } |
469 | |
470 | delete tracksMC; |
e0331fd9 |
471 | } |
472 | |
473 | //____________________________________________________________________ |
474 | void AliAnalysisTaskPhiCorrelations::AnalyseDataMode() |
475 | { |
476 | |
477 | // Run the analysis on DATA or MC to get raw distributions |
478 | |
e0331fd9 |
479 | if ( fDebug > 3 ) AliInfo( " Processing event in Data mode ..." ); |
e0331fd9 |
480 | |
c066889a |
481 | ((TH1F*) fListOfHistos->FindObject("eventStat"))->Fill(0); |
482 | |
2a910c25 |
483 | // skip not selected events here (the AOD is not updated for those) |
484 | if (!fInputHandler) |
485 | return; |
486 | |
85bfac17 |
487 | if (!(fInputHandler->IsEventSelected() & (AliVEvent::kMB | AliVEvent::kUserDefined))) |
2a910c25 |
488 | return; |
e0331fd9 |
489 | |
2a910c25 |
490 | Double_t centrality = 0; |
491 | |
c3294f09 |
492 | AliCentrality *centralityObj = 0; |
2a910c25 |
493 | if (fCentralityMethod.Length() > 0) |
494 | { |
85bfac17 |
495 | if (fAOD) |
496 | centralityObj = fAOD->GetHeader()->GetCentralityP(); |
497 | else if (fESD) |
498 | centralityObj = fESD->GetCentrality(); |
499 | |
2a910c25 |
500 | if (centralityObj) |
501 | centrality = centralityObj->GetCentralityPercentile(fCentralityMethod); |
502 | //centrality = centralityObj->GetCentralityPercentileUnchecked(fCentralityMethod); |
503 | else |
504 | centrality = -1; |
a6d82f4e |
505 | |
506 | if (fAOD) |
507 | { |
508 | // remove outliers |
509 | if (centrality == 0) |
510 | { |
511 | if (fAOD->GetVZEROData()) |
512 | { |
513 | Float_t multV0 = 0; |
514 | for (Int_t i=0; i<64; i++) |
515 | multV0 += fAOD->GetVZEROData()->GetMultiplicity(i); |
516 | if (multV0 < 19500) |
517 | { |
518 | centrality = -1; |
519 | AliInfo("Rejecting event due to too small V0 multiplicity"); |
520 | } |
521 | } |
522 | } |
523 | } |
524 | |
a8583211 |
525 | AliInfo(Form("Centrality is %f", centrality)); |
2a910c25 |
526 | } |
527 | |
85bfac17 |
528 | // Support for ESD and AOD based analysis |
529 | AliVEvent* inputEvent = fAOD; |
530 | if (!inputEvent) |
531 | inputEvent = fESD; |
532 | |
533 | fHistos->SetRunNumber(inputEvent->GetRunNumber()); |
534 | |
2a910c25 |
535 | // Fill the "event-counting-container", it is needed to get the number of events remaining after each event-selection cut |
536 | fHistos->FillEvent(centrality, AliUEHist::kCFStepAll); |
537 | |
e0331fd9 |
538 | // Trigger selection ************************************************ |
539 | if (!fAnalyseUE->TriggerSelection(fInputHandler)) return; |
540 | |
541 | // Fill the "event-counting-container", it is needed to get the number of events remaining after each event-selection cut |
2a910c25 |
542 | fHistos->FillEvent(centrality, AliUEHist::kCFStepTriggered); |
e0331fd9 |
543 | |
544 | // Vertex selection ************************************************* |
85bfac17 |
545 | if(!fAnalyseUE->VertexSelection(inputEvent, fnTracksVertex, fZVertex)) return; |
e0331fd9 |
546 | |
547 | // Fill the "event-counting-container", it is needed to get the number of events remaining after each event-selection cut |
2a910c25 |
548 | fHistos->FillEvent(centrality, AliUEHist::kCFStepVertex); |
e0331fd9 |
549 | |
c3294f09 |
550 | // optimization |
551 | if (centrality < 0 && !fCompareCentralities) |
2a910c25 |
552 | return; |
e0331fd9 |
553 | |
85bfac17 |
554 | TObjArray* tracks = fAnalyseUE->GetAcceptedParticles(inputEvent, 0, kTRUE, -1, kTRUE); |
2a910c25 |
555 | //Printf("Accepted %d tracks", tracks->GetEntries()); |
e0331fd9 |
556 | |
85bfac17 |
557 | const AliVVertex* vertex = inputEvent->GetPrimaryVertex(); |
2a910c25 |
558 | Double_t zVtx = vertex->GetZ(); |
559 | |
c05ff6be |
560 | Float_t weight = 1; |
561 | if (fFillpT) |
562 | weight = -1; |
563 | |
c3294f09 |
564 | // fill two different centralities (syst study) |
565 | // the zvtx axis is used to distinguish the results of both centralities: configured centrality in zvtx = 0, SPD in zvtx = 2 |
566 | if (fCompareCentralities) |
567 | zVtx = 0; |
2a910c25 |
568 | |
c3294f09 |
569 | // Fill containers at STEP 6 (reconstructed) |
570 | if (centrality >= 0) |
c066889a |
571 | { |
c05ff6be |
572 | fHistos->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepReconstructed, tracks, 0, weight); |
c066889a |
573 | ((TH1F*) fListOfHistos->FindObject("eventStat"))->Fill(1); |
574 | } |
c3294f09 |
575 | |
1bba939a |
576 | // Two-track effect study |
577 | if (fTwoTrackEfficiencyStudy) |
578 | { |
6840ec31 |
579 | Float_t bSign = (fESD->GetMagneticField() > 0) ? 1 : -1; |
c5c840c5 |
580 | fHistos->TwoTrackEfficiency(tracks, 0, bSign); |
1bba939a |
581 | } |
582 | |
c3294f09 |
583 | // fill second time with SPD centrality |
584 | if (fCompareCentralities && centralityObj) |
585 | { |
586 | centrality = centralityObj->GetCentralityPercentile("CL1"); |
587 | if (centrality >= 0) |
c05ff6be |
588 | fHistos->FillCorrelations(centrality, 2, AliUEHist::kCFStepReconstructed, tracks, 0, weight); |
c3294f09 |
589 | } |
590 | |
eed401dc |
591 | if (fFillMixed) |
e0331fd9 |
592 | { |
eed401dc |
593 | // event mixing |
2a910c25 |
594 | |
eed401dc |
595 | // 1. First get an event pool corresponding in mult (cent) and |
596 | // zvertex to the current event. Once initialized, the pool |
597 | // should contain nMix (reduced) events. This routine does not |
598 | // pre-scan the chain. The first several events of every chain |
599 | // will be skipped until the needed pools are filled to the |
600 | // specified depth. If the pool categories are not too rare, this |
601 | // should not be a problem. If they are rare, you could lose |
602 | // statistics. |
603 | |
604 | // 2. Collect the whole pool's content of tracks into one TObjArray |
605 | // (bgTracks), which is effectively a single background super-event. |
606 | |
607 | // 3. The reduced and bgTracks arrays must both be passed into |
608 | // FillCorrelations(). Also nMix should be passed in, so a weight |
609 | // of 1./nMix can be applied. |
610 | |
611 | AliEventPool* pool = fPoolMgr->GetEventPool(centrality, zVtx); |
612 | |
613 | if (!pool) |
614 | AliFatal(Form("No pool found for centrality = %f, zVtx = %f", centrality, zVtx)); |
615 | |
616 | //pool->SetDebug(1); |
617 | |
ac647b0f |
618 | if (pool->IsReady() || pool->NTracksInPool() > fMixingTracks / 10) |
eed401dc |
619 | { |
620 | |
621 | Int_t nMix = pool->GetCurrentNEvents(); |
a1c31636 |
622 | // cout << "nMix = " << nMix << " tracks in pool = " << pool->NTracksInPool() << endl; |
c066889a |
623 | |
624 | ((TH1F*) fListOfHistos->FindObject("eventStat"))->Fill(2); |
625 | ((TH1F*) fListOfHistos->FindObject("mixedDist"))->Fill(pool->NTracksInPool()); |
626 | if (pool->IsReady()) |
627 | ((TH1F*) fListOfHistos->FindObject("eventStat"))->Fill(3); |
eed401dc |
628 | |
629 | // Fill mixed-event histos here |
c05ff6be |
630 | for (Int_t jMix=0; jMix<nMix; jMix++) |
631 | { |
eed401dc |
632 | TObjArray* bgTracks = pool->GetEvent(jMix); |
c5c840c5 |
633 | |
634 | if (fTwoTrackEfficiencyStudy) |
635 | { |
636 | Float_t bSign = (fESD->GetMagneticField() > 0) ? 1 : -1; |
637 | fHistos->TwoTrackEfficiency(tracks, bgTracks, bSign); |
638 | } |
639 | |
acc90d78 |
640 | fHistosMixed->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepReconstructed, tracks, bgTracks, 1.0 / nMix, (jMix == 0)); |
eed401dc |
641 | } |
e0331fd9 |
642 | } |
eed401dc |
643 | |
a1c31636 |
644 | // create a list of reduced objects (to reduce memory consumption) and give ownership to event pool |
645 | TObjArray* tracksClone = new TObjArray; |
eed401dc |
646 | tracksClone->SetOwner(kTRUE); |
647 | |
a1c31636 |
648 | for (Int_t i=0; i<tracks->GetEntries(); i++) |
649 | { |
650 | AliVParticle* particle = (AliVParticle*) tracks->At(i); |
651 | tracksClone->Add(new AliDPhiBasicParticle(particle->Eta(), particle->Phi(), particle->Pt(), particle->Charge())); |
652 | } |
653 | |
eed401dc |
654 | pool->UpdatePool(tracksClone); |
655 | //pool->PrintInfo(); |
e0331fd9 |
656 | } |
2a910c25 |
657 | |
e0331fd9 |
658 | delete tracks; |
e0331fd9 |
659 | } |
660 | |
661 | //____________________________________________________________________ |
662 | void AliAnalysisTaskPhiCorrelations::Initialize() |
663 | { |
664 | // input handler |
665 | fInputHandler = (AliInputEventHandler*) |
666 | ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler()); |
667 | // MC handler |
668 | fMcHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); |
669 | } |