]>
Commit | Line | Data |
---|---|---|
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 | // This analysis task fills histograms with PID information of tracks | |
18 | // associated to a high p_T trigger. | |
19 | // ----------------------------------------------------------------------- | |
20 | // Author: Misha Veldhoen (misha.veldhoen@cern.ch) | |
6788af99 | 21 | |
22 | #include <iostream> | |
23 | ||
24 | // Basic Includes | |
25 | #include "TH1F.h" | |
26 | #include "TH2F.h" | |
27 | #include "TH3F.h" | |
28 | #include "THn.h" | |
29 | #include "TFile.h" | |
30 | #include "TChain.h" | |
31 | #include "TObject.h" | |
32 | #include "TObjArray.h" | |
33 | ||
34 | // Manager/ Handler | |
35 | #include "AliAnalysisManager.h" | |
36 | #include "AliInputEventHandler.h" | |
37 | ||
38 | // Event pool includes. | |
39 | #include "AliEventPoolManager.h" | |
40 | ||
41 | // PID includes. | |
42 | #include "AliPIDResponse.h" | |
43 | ||
44 | // AOD includes. | |
45 | #include "AliAODEvent.h" | |
46 | #include "AliAODTrack.h" | |
47 | #include "AliAODHandler.h" | |
48 | #include "AliAODVertex.h" | |
49 | #include "AliAODInputHandler.h" | |
50 | #include "AliAODMCParticle.h" | |
51 | #include "AliAODMCHeader.h" | |
52 | ||
53 | // Additional includes. | |
54 | #include "AliTrackDiHadronPID.h" | |
55 | #include "AliAODTrackCutsDiHadronPID.h" | |
56 | #include "AliAODEventCutsDiHadronPID.h" | |
57 | #include "AliHistToolsDiHadronPID.h" | |
58 | ||
59 | // AnalysisTask headers. | |
60 | #include "AliAnalysisTaskSE.h" | |
61 | #include "AliAnalysisTaskDiHadronPID.h" | |
62 | ||
63 | using namespace std; | |
64 | ||
65 | ClassImp(AliAnalysisTaskDiHadronPID); | |
66 | ||
97724bd1 | 67 | // ----------------------------------------------------------------------- |
6788af99 | 68 | AliAnalysisTaskDiHadronPID::AliAnalysisTaskDiHadronPID(): |
69 | AliAnalysisTaskSE(), | |
70 | fPIDResponse(0x0), | |
71 | fEventCuts(0x0), | |
72 | fTrackCutsTrigger(0x0), | |
73 | fTrackCutsAssociated(0x0), | |
74 | fPoolMgr(0x0), | |
75 | fTriggerTracks(0x0), | |
76 | fAssociatedTracks(0x0), | |
77 | fCurrentAODEvent(0x0), | |
78 | fOutputList(0x0), | |
79 | fPtSpectrum(0x0), | |
80 | fCorrelations(0x0), | |
81 | fMixedEvents(0x0), | |
82 | fTOFhistos(0x0), | |
83 | fNDEtaBins(32), | |
84 | fNDPhiBins(32), | |
85 | fMinNEventsForMixing(5), | |
86 | fPoolTrackDepth(2000), | |
87 | fPoolSize(1000), | |
50dfda71 | 88 | fMixEvents(kTRUE), |
89 | fMixTriggers(kFALSE), | |
6788af99 | 90 | fCalculateTOFmismatch(kTRUE), |
91 | fT0Fill(0x0), | |
92 | fLvsEta(0x0), | |
93 | fLvsEtaProjections(0x0), | |
94 | fDebug(0) | |
95 | ||
96 | { | |
97 | ||
98 | // | |
99 | // Default Constructor. | |
100 | // | |
101 | ||
102 | if (fDebug > 0) {AliInfo("AliAnalysisTaskDiHadronPID Default Constructor.");} | |
103 | ||
104 | for (Int_t iPtClass = 0; iPtClass < 5; iPtClass++) { | |
105 | for (Int_t iSpecies = 0; iSpecies < 3; iSpecies++) { | |
106 | fCorrelationsTOF[iPtClass][iSpecies] = 0x0; | |
107 | fCorrelationsTOFTPC[iPtClass][iSpecies] = 0x0; | |
108 | } | |
109 | } | |
110 | ||
111 | ||
112 | } | |
113 | ||
97724bd1 | 114 | // ----------------------------------------------------------------------- |
6788af99 | 115 | AliAnalysisTaskDiHadronPID::AliAnalysisTaskDiHadronPID(const char* name): |
116 | AliAnalysisTaskSE(name), | |
117 | fPIDResponse(0x0), | |
118 | fEventCuts(0x0), | |
119 | fTrackCutsTrigger(0x0), | |
120 | fTrackCutsAssociated(0x0), | |
121 | fPoolMgr(0x0), | |
122 | fTriggerTracks(0x0), | |
123 | fAssociatedTracks(0x0), | |
124 | fCurrentAODEvent(0x0), | |
125 | fOutputList(0x0), | |
126 | fPtSpectrum(0x0), | |
127 | fCorrelations(0x0), | |
128 | fMixedEvents(0x0), | |
129 | fTOFhistos(0x0), | |
130 | fNDEtaBins(32), | |
131 | fNDPhiBins(32), | |
132 | fMinNEventsForMixing(5), | |
133 | fPoolTrackDepth(2000), | |
134 | fPoolSize(1000), | |
50dfda71 | 135 | fMixEvents(kTRUE), |
136 | fMixTriggers(kFALSE), | |
6788af99 | 137 | fCalculateTOFmismatch(kTRUE), |
138 | fT0Fill(0x0), | |
139 | fLvsEta(0x0), | |
140 | fLvsEtaProjections(0x0), | |
141 | fDebug(0) | |
142 | ||
143 | { | |
144 | ||
145 | // | |
146 | // Named Constructor. | |
147 | // | |
148 | ||
50dfda71 | 149 | if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;} |
6788af99 | 150 | |
151 | for (Int_t iPtClass = 0; iPtClass < 5; iPtClass++) { | |
152 | for (Int_t iSpecies = 0; iSpecies < 3; iSpecies++) { | |
153 | fCorrelationsTOF[iPtClass][iSpecies] = 0x0; | |
154 | fCorrelationsTOFTPC[iPtClass][iSpecies] = 0x0; | |
155 | } | |
156 | } | |
157 | ||
158 | DefineInput(0,TChain::Class()); | |
159 | DefineOutput(1,TList::Class()); | |
160 | ||
161 | } | |
162 | ||
97724bd1 | 163 | // ----------------------------------------------------------------------- |
6788af99 | 164 | AliAnalysisTaskDiHadronPID::~AliAnalysisTaskDiHadronPID() {; |
165 | ||
166 | // | |
167 | // Destructor. | |
168 | // | |
169 | ||
50dfda71 | 170 | if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;} |
6788af99 | 171 | |
172 | } | |
173 | ||
97724bd1 | 174 | // ----------------------------------------------------------------------- |
6788af99 | 175 | void AliAnalysisTaskDiHadronPID::UserCreateOutputObjects() { |
176 | ||
177 | // | |
178 | // Create Output objects. | |
179 | // | |
180 | ||
50dfda71 | 181 | if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;} |
6788af99 | 182 | |
183 | // --- BEGIN: Initialization on the worker nodes --- | |
184 | AliAnalysisManager* manager = AliAnalysisManager::GetAnalysisManager(); | |
185 | AliInputEventHandler* inputHandler = dynamic_cast<AliInputEventHandler*> (manager->GetInputEventHandler()); | |
186 | ||
187 | // Getting the pointer to the PID response object. | |
188 | fPIDResponse = inputHandler->GetPIDResponse(); | |
189 | ||
190 | // Not very neat - only set up for 0-5% analysis. | |
191 | Int_t nCentralityBins = 5; | |
192 | Double_t centralityBins[] = {0.,1.,2.,3.,4.,5.}; | |
193 | ||
194 | Int_t nZvtxBins = 7; | |
195 | Double_t vertexBins[] = {-7.,-5.,-3.,-1.,1.,3.,5.,7.}; | |
196 | ||
197 | fPoolMgr = new AliEventPoolManager(fPoolSize, fPoolTrackDepth, nCentralityBins, (Double_t*) centralityBins, nZvtxBins, (Double_t*) vertexBins); | |
198 | // --- END --- | |
199 | ||
200 | // Create the output list. | |
201 | fOutputList = new TList(); | |
202 | fOutputList->SetOwner(kTRUE); | |
203 | ||
204 | // Creating all requested histograms locally. | |
205 | fEventCuts->CreateHistos(); | |
206 | fOutputList->Add(fEventCuts); | |
207 | ||
208 | fTrackCutsTrigger->CreateHistos(); | |
209 | fOutputList->Add(fTrackCutsTrigger); | |
210 | ||
211 | fTrackCutsAssociated->CreateHistos(); | |
212 | fOutputList->Add(fTrackCutsAssociated); | |
213 | ||
214 | // Get the pT axis for the PID histograms. | |
50dfda71 | 215 | Double_t* ptaxis = fTrackCutsAssociated->GetPtAxisPID(); |
6788af99 | 216 | Int_t nptbins = fTrackCutsAssociated->GetNPtBinsPID(); |
217 | ||
218 | // Create Pt spectrum histogram. | |
219 | fPtSpectrum = new TH1F("fPtSpectrum","p_{T} Spectrum;p_{T} (GeV/c);Count",nptbins,ptaxis); | |
220 | fOutputList->Add(fPtSpectrum); | |
221 | ||
222 | // Create unidentified correlations histogram. | |
223 | fCorrelations = AliHistToolsDiHadronPID::MakeHist3D("fCorrelations","Correlations;#Delta#phi;#Delta#eta;p_{T} (GeV/c)", | |
224 | fNDPhiBins,-TMath::Pi()/2.,3.*TMath::Pi()/2., | |
225 | fNDEtaBins,-1.6,1.6, | |
226 | nptbins, ptaxis); | |
227 | fOutputList->Add(fCorrelations); | |
228 | ||
229 | // Create unidentified mixed events histogram. | |
230 | fMixedEvents = AliHistToolsDiHadronPID::MakeHist3D("fMixedEvents","Mixed Events;#Delta#phi;#Delta#eta;p_{T} (GeV/c)", | |
231 | fNDPhiBins,-TMath::Pi()/2.,3.*TMath::Pi()/2., | |
232 | fNDEtaBins,-1.6,1.6, | |
233 | nptbins, ptaxis); | |
234 | fOutputList->Add(fMixedEvents); | |
235 | ||
236 | // Create TOF correlations histograms (DPhi,DEta,pt,TOF). | |
237 | fTOFhistos = new TObjArray(15); | |
238 | fTOFhistos->SetName("CorrelationsTOF"); | |
7fcceff8 | 239 | fTOFhistos->SetOwner(kTRUE); |
6788af99 | 240 | |
f054df96 | 241 | Int_t nbins[4] = {fNDPhiBins,fNDEtaBins,0,0}; |
6788af99 | 242 | Double_t min[4] = {-TMath::Pi()/2.,-1.6,0.,0.}; |
243 | Double_t max[4] = {3.*TMath::Pi()/2.,1.6,0.,0.}; | |
244 | ||
245 | for (Int_t iPtClass = 0; iPtClass < 5; iPtClass++) { | |
246 | ||
247 | nbins[2] = fTrackCutsAssociated->GetNPtBinsPID(iPtClass); | |
248 | min[2] = fTrackCutsAssociated->GetPtClassMin(iPtClass); | |
249 | max[2] = fTrackCutsAssociated->GetPtClassMax(iPtClass); | |
250 | ||
251 | for (Int_t iSpecies = 0; iSpecies < 3; iSpecies++) { | |
252 | ||
253 | nbins[3] = fTrackCutsAssociated->GetNTOFbins(iPtClass,iSpecies); | |
254 | min[3] = fTrackCutsAssociated->GetTOFmin(iPtClass,iSpecies); | |
255 | max[3] = fTrackCutsAssociated->GetTOFmax(iPtClass,iSpecies); | |
256 | ||
257 | fCorrelationsTOF[iPtClass][iSpecies] = new THnF( | |
258 | Form("fCorrelationsTOF_%i_%i",iPtClass,iSpecies), | |
259 | Form("CorrelationsTOF_%i_%i",iPtClass,iSpecies), | |
260 | 4,nbins,min,max); | |
261 | ||
262 | fTOFhistos->Add(fCorrelationsTOF[iPtClass][iSpecies]); | |
263 | ||
264 | } | |
265 | } | |
266 | ||
267 | fOutputList->Add(fTOFhistos); | |
268 | ||
269 | // TODO: Create TOF/TPC correlations histogram. | |
270 | ||
271 | // Load external TOF histograms if flag is set. | |
272 | if (fCalculateTOFmismatch) {LoadExtMismatchHistos();} | |
273 | ||
274 | PostData(1,fOutputList); | |
275 | ||
276 | } | |
277 | ||
97724bd1 | 278 | // ----------------------------------------------------------------------- |
6788af99 | 279 | void AliAnalysisTaskDiHadronPID::LocalInit() { |
280 | ||
281 | // | |
282 | // Initialize on the client. (or on my computer?? - I think so...) | |
283 | // | |
284 | ||
50dfda71 | 285 | if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;} |
6788af99 | 286 | |
287 | } | |
288 | ||
97724bd1 | 289 | // ----------------------------------------------------------------------- |
6788af99 | 290 | void AliAnalysisTaskDiHadronPID::UserExec(Option_t*) { |
291 | ||
292 | // | |
293 | // Main Loop. | |
294 | // | |
295 | ||
50dfda71 | 296 | if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;} |
6788af99 | 297 | |
298 | // Input Current Event. | |
299 | fCurrentAODEvent = dynamic_cast<AliAODEvent*>(InputEvent()); | |
300 | if (!fCurrentAODEvent) AliFatal("No Event Found!"); | |
301 | ||
302 | if (!fEventCuts->IsSelected(fCurrentAODEvent)) {return;} | |
303 | ||
304 | // Fill the global tracks array. - NOT NEEDED I THINK, since we're not using | |
305 | // bit 1<<7 for the associated tracks! | |
306 | ||
307 | // Let the track cut objects know that a new event will start. | |
308 | fTrackCutsTrigger->StartNewEvent(); | |
309 | fTrackCutsAssociated->StartNewEvent(); | |
310 | ||
311 | // Create arrays for trigger/associated particles. | |
312 | fTriggerTracks = new TObjArray(350); | |
313 | fTriggerTracks->SetOwner(kTRUE); | |
314 | ||
315 | fAssociatedTracks = new TObjArray(3500); | |
316 | fAssociatedTracks->SetOwner(kTRUE); | |
317 | ||
318 | for (Int_t iTrack = 0; iTrack < fCurrentAODEvent->GetNumberOfTracks(); iTrack++) { | |
319 | ||
320 | AliAODTrack* track = (AliAODTrack*)fCurrentAODEvent->GetTrack(iTrack); | |
321 | AliTrackDiHadronPID* pidtrack = new AliTrackDiHadronPID(track,0x0,0x0,fPIDResponse); | |
322 | pidtrack->ForgetAboutPointers(); | |
323 | pidtrack->SetDebugLevel(fDebug); | |
324 | ||
325 | Double_t rndhittime = -1.e21; | |
326 | if (fCalculateTOFmismatch) rndhittime = GenerateRandomHit(pidtrack->Eta()); | |
327 | ||
328 | // Fill p_T spectrum. | |
329 | fPtSpectrum->Fill(pidtrack->Pt()); | |
330 | ||
331 | // Fill the trigger/associated tracks array. | |
332 | if (fTrackCutsTrigger->IsSelectedData(pidtrack,rndhittime)) {fTriggerTracks->AddLast(pidtrack);} | |
333 | else if (fTrackCutsAssociated->IsSelectedData(pidtrack,rndhittime)) {fAssociatedTracks->AddLast(pidtrack);} | |
334 | else {delete pidtrack;} | |
335 | ||
336 | } | |
337 | ||
338 | // Fill Correlation histograms. | |
339 | for (Int_t iTrigger = 0; iTrigger < fTriggerTracks->GetEntriesFast(); iTrigger++) { | |
340 | AliTrackDiHadronPID* triggertrack = (AliTrackDiHadronPID*)fTriggerTracks->At(iTrigger); | |
341 | ||
342 | for (Int_t iAssociated = 0; iAssociated < fAssociatedTracks->GetEntriesFast(); iAssociated++) { | |
343 | AliTrackDiHadronPID* associatedtrack = (AliTrackDiHadronPID*)fAssociatedTracks->At(iAssociated); | |
344 | ||
345 | Double_t DPhi = triggertrack->Phi() - associatedtrack->Phi(); | |
346 | if (DPhi < -TMath::Pi()/2.) {DPhi += 2.*TMath::Pi();} | |
347 | if (DPhi > 3.*TMath::Pi()/2.) {DPhi -= 2.*TMath::Pi();} | |
348 | ||
349 | Double_t DEta = triggertrack->Eta() - associatedtrack->Eta(); | |
350 | fCorrelations->Fill(DPhi,DEta,associatedtrack->Pt()); | |
351 | ||
352 | Double_t tofhistfill[4] = {DPhi,DEta,associatedtrack->Pt(),-999.}; | |
353 | ||
354 | for (Int_t iSpecies = 0; iSpecies < 3; iSpecies++) { | |
355 | tofhistfill[3] = associatedtrack->GetTOFsignalMinusExpected(iSpecies); | |
356 | ||
357 | for (Int_t iPtClass = 0; iPtClass < 5; iPtClass++) { | |
358 | ||
359 | // prevent under/over-flow bins to be filled. | |
360 | Double_t ptmin = fTrackCutsAssociated->GetPtClassMin(iPtClass); | |
361 | Double_t ptmax = fTrackCutsAssociated->GetPtClassMax(iPtClass); | |
362 | Double_t apt = associatedtrack->Pt(); | |
363 | ||
364 | if ( (apt > ptmin) && (apt < ptmax) ) { | |
365 | fCorrelationsTOF[iPtClass][iSpecies]->Fill(tofhistfill); | |
366 | } | |
367 | ||
368 | } | |
369 | } | |
370 | } | |
371 | } | |
372 | ||
373 | cout<<"Triggers: "<<fTriggerTracks->GetEntriesFast()<<" Associateds: "<<fAssociatedTracks->GetEntriesFast()<<endl; | |
374 | ||
375 | // Determine centrality of current event. | |
376 | TString centralityestimator = fEventCuts->GetCentralityEstimator(); | |
377 | AliCentrality* currentcentrality = fCurrentAODEvent->GetCentrality(); | |
378 | Float_t percentile = currentcentrality->GetCentralityPercentile(centralityestimator.Data()); | |
379 | ||
380 | // Determine vtxz of current event. | |
381 | AliAODVertex* currentprimaryvertex = fCurrentAODEvent->GetPrimaryVertex(); | |
382 | Double_t vtxz = currentprimaryvertex->GetZ(); | |
383 | ||
6788af99 | 384 | AliEventPool* poolin = fPoolMgr->GetEventPool(percentile, vtxz); |
385 | if (!poolin) {AliFatal(Form("No pool found for centrality = %f, vtxz = %f", percentile, vtxz));} | |
386 | // TObjArray* fGlobalTracksArray; | |
387 | ||
50dfda71 | 388 | // Give a print out of the pool manager's contents. |
f054df96 | 389 | if (fDebug > 0) PrintPoolManagerContents(); |
50dfda71 | 390 | |
391 | // Mix events if there are enough events in the pool. | |
6788af99 | 392 | if (poolin->GetCurrentNEvents() >= fMinNEventsForMixing) { |
50dfda71 | 393 | {cout << "Mixing Events." << endl;} |
394 | ||
395 | // Loop over all events in the event pool. | |
396 | for (Int_t iMixEvent = 0; iMixEvent < poolin->GetCurrentNEvents(); iMixEvent++) { | |
397 | TObjArray* mixtracks = poolin->GetEvent(iMixEvent); | |
398 | ||
399 | // Mix either the triggers or the associateds. | |
400 | if (fMixTriggers) { | |
401 | ||
402 | // Loop over all associateds in this event. | |
403 | for (Int_t iAssociated = 0; iAssociated < fAssociatedTracks->GetEntriesFast(); iAssociated++) { | |
404 | AliTrackDiHadronPID* associatedtrack = (AliTrackDiHadronPID*)fAssociatedTracks->At(iAssociated); | |
405 | ||
406 | // Loop over all mixed tracks. | |
407 | for (Int_t iMixTrack = 0; iMixTrack < mixtracks->GetEntriesFast(); iMixTrack++) { | |
408 | AliTrackDiHadronPID* mixtrack = (AliTrackDiHadronPID*)mixtracks->At(iMixTrack); | |
409 | ||
410 | Double_t DPhi = mixtrack->Phi() - associatedtrack->Phi(); | |
411 | if (DPhi < -TMath::Pi()/2.) {DPhi += 2.*TMath::Pi();} | |
412 | if (DPhi > 3.*TMath::Pi()/2.) {DPhi -= 2.*TMath::Pi();} | |
413 | ||
414 | Double_t DEta = mixtrack->Eta() - associatedtrack->Eta(); | |
415 | fMixedEvents->Fill(DPhi,DEta,associatedtrack->Pt()); | |
416 | ||
417 | } | |
418 | } | |
6788af99 | 419 | |
50dfda71 | 420 | } else { |
6788af99 | 421 | |
50dfda71 | 422 | // Loop over all triggers in this event. |
423 | for (Int_t iTrigger = 0; iTrigger < fTriggerTracks->GetEntriesFast(); iTrigger++) { | |
424 | AliTrackDiHadronPID* triggertrack = (AliTrackDiHadronPID*)fTriggerTracks->At(iTrigger); | |
6788af99 | 425 | |
50dfda71 | 426 | // Loop over all mixed tracks. |
427 | for (Int_t iMixTrack = 0; iMixTrack < mixtracks->GetEntriesFast(); iMixTrack++) { | |
428 | AliTrackDiHadronPID* mixtrack = (AliTrackDiHadronPID*)mixtracks->At(iMixTrack); | |
429 | ||
430 | Double_t DPhi = triggertrack->Phi() - mixtrack->Phi(); | |
431 | if (DPhi < -TMath::Pi()/2.) {DPhi += 2.*TMath::Pi();} | |
432 | if (DPhi > 3.*TMath::Pi()/2.) {DPhi -= 2.*TMath::Pi();} | |
6788af99 | 433 | |
50dfda71 | 434 | Double_t DEta = triggertrack->Eta() - mixtrack->Eta(); |
435 | fMixedEvents->Fill(DPhi,DEta,mixtrack->Pt()); | |
6788af99 | 436 | |
50dfda71 | 437 | } |
438 | } | |
439 | ||
440 | } // End if | |
6788af99 | 441 | } |
442 | } | |
443 | ||
444 | // Update the event pool. | |
445 | AliEventPool* poolout = fPoolMgr->GetEventPool(percentile, vtxz); // Get the buffer associated with the current centrality and z-vtx | |
446 | if (!poolout) AliFatal(Form("No pool found for centrality = %f, vtx_z = %f", percentile, vtxz)); | |
447 | ||
448 | // Q: is it a problem that the fAssociatedTracks array can be bigger than the number of tracks inside? | |
50dfda71 | 449 | if (fMixTriggers) { |
450 | poolout->UpdatePool(fTriggerTracks); | |
451 | fAssociatedTracks->Delete(); | |
452 | delete fAssociatedTracks; | |
453 | } | |
454 | else { | |
455 | poolout->UpdatePool(fAssociatedTracks); | |
456 | fTriggerTracks->Delete(); | |
457 | delete fTriggerTracks; | |
458 | } | |
6788af99 | 459 | |
6788af99 | 460 | fTriggerTracks = 0x0; |
461 | fAssociatedTracks = 0x0; | |
462 | ||
463 | // Tell the track cut object that the event is done. | |
464 | fTrackCutsTrigger->EventIsDone(0); | |
465 | fTrackCutsAssociated->EventIsDone(0); | |
466 | ||
467 | PostData(1,fOutputList); | |
468 | ||
469 | } | |
470 | ||
97724bd1 | 471 | // ----------------------------------------------------------------------- |
6788af99 | 472 | Bool_t AliAnalysisTaskDiHadronPID::LoadExtMismatchHistos() { |
473 | ||
474 | // | |
475 | // Attempting to load a root file containing information needed | |
476 | // to generate random TOF hits. | |
477 | // | |
478 | ||
50dfda71 | 479 | if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;} |
6788af99 | 480 | |
481 | // Opening external TOF file. | |
482 | if (fDebug > 0) cout<<"Trying to open TOFmismatchHistos.root ..."<<endl; | |
483 | TFile* fin = 0x0; | |
484 | fin = TFile::Open("alien:///alice/cern.ch/user/m/mveldhoe/rootfiles/TOFmismatchHistos.root"); | |
485 | if (!fin) { | |
486 | AliWarning("Couln't open TOFmismatchHistos, will not calculate mismatches..."); | |
487 | fCalculateTOFmismatch = kFALSE; | |
488 | return kFALSE; | |
489 | } | |
490 | ||
491 | // Check if the required histograms are present. | |
492 | TH1F* tmp1 = (TH1F*)fin->Get("hNewT0Fill"); | |
493 | if (!tmp1) { | |
494 | AliWarning("Couln't find hNewT0Fill, will not calculate mismatches..."); | |
495 | fCalculateTOFmismatch = kFALSE; | |
496 | return kFALSE; | |
497 | } | |
498 | TH2F* tmp2 = (TH2F*)fin->Get("hLvsEta"); | |
499 | if (!tmp2) { | |
500 | AliWarning("Couln't find hLvsEta, will not calculate mismatches..."); | |
501 | fCalculateTOFmismatch = kFALSE; | |
502 | return kFALSE; | |
503 | } | |
504 | ||
505 | // Make a deep copy of the files in the histogram. | |
506 | fT0Fill = (TH1F*)tmp1->Clone("fT0Fill"); | |
507 | fLvsEta = (TH2F*)tmp2->Clone("fLvsEta"); | |
508 | ||
509 | // Close the external file. | |
510 | AliInfo("Closing external file."); | |
511 | fin->Close(); | |
512 | ||
513 | // Creating a TObjArray for LvsEta projections. | |
514 | const Int_t nbinseta = fLvsEta->GetNbinsX(); | |
515 | fLvsEtaProjections = new TObjArray(nbinseta); | |
516 | fLvsEtaProjections->SetOwner(kTRUE); | |
517 | ||
518 | // Making the projections needed (excluding underflow/ overflow). | |
519 | for (Int_t iEtaBin = 1; iEtaBin < (nbinseta + 1); iEtaBin++) { | |
520 | TH1F* tmp = (TH1F*)fLvsEta->ProjectionY(Form("LvsEtaProjection_%i",iEtaBin),iEtaBin,iEtaBin); | |
521 | tmp->SetDirectory(0); | |
522 | fLvsEtaProjections->AddAt(tmp,iEtaBin); | |
523 | } | |
524 | ||
525 | return kTRUE; | |
526 | ||
527 | } | |
528 | ||
97724bd1 | 529 | // ----------------------------------------------------------------------- |
6788af99 | 530 | Double_t AliAnalysisTaskDiHadronPID::GenerateRandomHit(Double_t eta) { |
531 | ||
532 | // | |
533 | // Returns a random TOF time. | |
534 | // | |
535 | ||
50dfda71 | 536 | if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;} |
6788af99 | 537 | |
538 | // Default (error) value: | |
539 | Double_t rndhittime = -1.e21; | |
540 | ||
541 | // TOF mismatch flag is not turned on. | |
542 | if (!fCalculateTOFmismatch) { | |
543 | AliFatal("Called GenerateRandomHit() method, but flag fCalculateTOFmismatch not set."); | |
544 | return rndhittime; | |
545 | } | |
546 | ||
547 | // TOF doesn't extend much further than 0.8. | |
548 | if (TMath::Abs(eta) > 0.8) { | |
549 | if (fDebug) {AliInfo("Tried to get a random hit for a track with eta > 0.8.");} | |
550 | return rndhittime; | |
551 | } | |
552 | ||
553 | // Finding the bin of the eta. | |
554 | TAxis* etaAxis = fLvsEta->GetXaxis(); | |
555 | Int_t etaBin = etaAxis->FindBin(eta); | |
556 | //cout<<"Eta: "<<eta<<" bin: "<<etaBin<<endl; | |
557 | const TH1F* lengthDistribution = (const TH1F*)fLvsEtaProjections->At(etaBin); | |
558 | ||
559 | if (!lengthDistribution) { | |
560 | AliFatal("length Distribution not found."); | |
561 | return rndhittime; | |
562 | } | |
563 | ||
564 | Double_t currentRndLength = lengthDistribution->GetRandom(); // in cm. | |
565 | ||
566 | // Similar to Roberto's code. | |
567 | Double_t currentRndTime = currentRndLength / (TMath::C() * 1.e2 / 1.e12); | |
568 | Double_t t0fill = -1.26416e+04; | |
569 | rndhittime = fT0Fill->GetRandom() - t0fill + currentRndTime; | |
570 | ||
571 | return rndhittime; | |
572 | ||
573 | } | |
574 | ||
97724bd1 | 575 | // ----------------------------------------------------------------------- |
50dfda71 | 576 | void AliAnalysisTaskDiHadronPID::PrintPoolManagerContents() { |
577 | ||
578 | // | |
579 | // Prints out the current contents of the event pool manager. | |
580 | // | |
581 | ||
582 | // Determine the number of pools in the pool manager. | |
583 | AliEventPool* poolin = fPoolMgr->GetEventPool(0,0); | |
584 | Int_t NPoolsCentrality = 0; | |
585 | while (poolin) { | |
586 | NPoolsCentrality++; | |
587 | poolin = fPoolMgr->GetEventPool(NPoolsCentrality,0); | |
588 | } | |
589 | ||
590 | poolin = fPoolMgr->GetEventPool(0,0); | |
591 | Int_t NPoolsVtxZ = 0; | |
592 | while (poolin) { | |
593 | NPoolsVtxZ++; | |
594 | poolin = fPoolMgr->GetEventPool(0,NPoolsVtxZ); | |
595 | } | |
596 | ||
597 | // Loop over all Pools in the matrix of the pool manager. | |
598 | cout<<" Pool manager contents: (Nevt,NTrack)"<<endl; | |
599 | for (Int_t iCentrality = 0; iCentrality < NPoolsCentrality; iCentrality++) { | |
600 | cout<<Form("Centrality Bin: %2i --> ", iCentrality); | |
601 | ||
602 | for (Int_t iVtxZ = 0; iVtxZ < NPoolsVtxZ; iVtxZ++) { | |
603 | ||
604 | poolin = fPoolMgr->GetEventPool(iCentrality, iVtxZ); | |
605 | ||
606 | cout<<Form("(%2i,%4i) ",poolin->GetCurrentNEvents(), poolin->NTracksInPool()); | |
607 | ||
608 | } | |
609 | ||
610 | cout<<endl; | |
611 | } | |
612 | ||
613 | } | |
614 | ||
97724bd1 | 615 | // ----------------------------------------------------------------------- |
6788af99 | 616 | void AliAnalysisTaskDiHadronPID::Terminate(Option_t*) {; |
617 | ||
618 | // | |
619 | // Called when task is done. | |
620 | // | |
621 | ||
50dfda71 | 622 | if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;} |
6788af99 | 623 | |
624 | delete fT0Fill; | |
625 | fT0Fill = 0x0; | |
626 | delete fLvsEta; | |
627 | fLvsEta = 0x0; | |
628 | delete fLvsEtaProjections; | |
629 | fLvsEtaProjections = 0x0; | |
630 | ||
631 | } |