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 // 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)
32 #include "TObjArray.h"
35 #include "AliAnalysisManager.h"
36 #include "AliInputEventHandler.h"
38 // Event pool includes.
39 #include "AliEventPoolManager.h"
42 #include "AliPIDResponse.h"
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"
53 // Additional includes.
54 #include "AliTrackDiHadronPID.h"
55 #include "AliAODTrackCutsDiHadronPID.h"
56 #include "AliAODEventCutsDiHadronPID.h"
57 #include "AliHistToolsDiHadronPID.h"
58 #include "AliFunctionsDiHadronPID.h"
60 // AnalysisTask headers.
61 #include "AliAnalysisTaskSE.h"
62 #include "AliAnalysisTaskDiHadronPID.h"
66 ClassImp(AliAnalysisTaskDiHadronPID);
68 // -----------------------------------------------------------------------
69 AliAnalysisTaskDiHadronPID::AliAnalysisTaskDiHadronPID():
73 fTrackCutsTrigger(0x0),
74 fTrackCutsAssociated(0x0),
77 fAssociatedTracks(0x0),
78 fCurrentAODEvent(0x0),
89 fMinNEventsForMixing(5),
90 fPoolTrackDepth(2000),
94 fCalculateTOFmismatch(kTRUE),
97 fLvsEtaProjections(0x0),
98 fMakeTOFcorrelations(kTRUE),
99 fMakeTOFTPCcorrelations(kFALSE),
105 // Default Constructor.
108 if (fDebug > 0) {AliInfo("AliAnalysisTaskDiHadronPID Default Constructor.");}
112 // -----------------------------------------------------------------------
113 AliAnalysisTaskDiHadronPID::AliAnalysisTaskDiHadronPID(const char* name):
114 AliAnalysisTaskSE(name),
117 fTrackCutsTrigger(0x0),
118 fTrackCutsAssociated(0x0),
121 fAssociatedTracks(0x0),
122 fCurrentAODEvent(0x0),
133 fMinNEventsForMixing(5),
134 fPoolTrackDepth(2000),
137 fMixTriggers(kFALSE),
138 fCalculateTOFmismatch(kTRUE),
141 fLvsEtaProjections(0x0),
142 fMakeTOFcorrelations(kTRUE),
143 fMakeTOFTPCcorrelations(kFALSE),
149 // Named Constructor.
152 if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
154 DefineInput(0,TChain::Class());
155 DefineOutput(1,TList::Class());
159 // -----------------------------------------------------------------------
160 AliAnalysisTaskDiHadronPID::~AliAnalysisTaskDiHadronPID() {;
166 if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
168 if (fPoolMgr) {delete fPoolMgr; fPoolMgr = 0x0;}
169 if (fOutputList) {delete fOutputList; fOutputList = 0x0;}
173 // -----------------------------------------------------------------------
174 void AliAnalysisTaskDiHadronPID::UserCreateOutputObjects() {
177 // Create Output objects.
180 if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
182 // --- BEGIN: Initialization on the worker nodes ---
183 AliAnalysisManager* manager = AliAnalysisManager::GetAnalysisManager();
184 AliInputEventHandler* inputHandler = dynamic_cast<AliInputEventHandler*> (manager->GetInputEventHandler());
186 // Getting the pointer to the PID response object.
187 fPIDResponse = inputHandler->GetPIDResponse();
189 // Not very neat - only set up for 0-5% analysis.
190 Int_t nCentralityBins = 15;
191 Double_t centralityBins[] = {0., 1., 2., 3., 4., 5., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100.1 };
194 Double_t vertexBins[] = {-7., -5., -3., -1., 1., 3., 5., 7.};
196 fPoolMgr = new AliEventPoolManager(fPoolSize, fPoolTrackDepth, nCentralityBins, (Double_t*) centralityBins, nZvtxBins, (Double_t*) vertexBins);
199 // Create the output list.
200 fOutputList = new TList();
201 fOutputList->SetOwner(kTRUE);
203 // Creating all requested histograms locally.
204 fEventCuts->CreateHistos();
205 fOutputList->Add(fEventCuts);
207 fTrackCutsTrigger->CreateHistos();
208 fOutputList->Add(fTrackCutsTrigger);
210 fTrackCutsAssociated->CreateHistos();
211 fOutputList->Add(fTrackCutsAssociated);
213 // Get the pT axis for the TOF PID correlations.
214 Double_t* ptaxis = fTrackCutsAssociated->GetPtAxisPID();
215 Int_t nptbins = fTrackCutsAssociated->GetNPtBinsPID();
216 fTOFPtAxis = new TAxis(nptbins, ptaxis);
217 fTOFPtAxis->SetName("fTOFPtAxis");
218 fTOFPtAxis->SetTitle("p_{T} GeV/c");
219 fOutputList->Add(fTOFPtAxis);
221 // Create Pt spectrum histogram.
222 fPtSpectrum = new TH1F("fPtSpectrum","p_{T} Spectrum;p_{T} (GeV/c);Count",nptbins,ptaxis);
223 fOutputList->Add(fPtSpectrum);
225 // Create unidentified correlations histogram.
226 fCorrelations = AliHistToolsDiHadronPID::MakeHist3D("fCorrelations","Correlations;#Delta#phi;#Delta#eta;p_{T} (GeV/c)",
227 fNDPhiBins,-TMath::Pi()/2.,3.*TMath::Pi()/2.,
230 fOutputList->Add(fCorrelations);
232 // Create unidentified mixed events histogram.
233 fMixedEvents = AliHistToolsDiHadronPID::MakeHist3D("fMixedEvents","Mixed Events;#Delta#phi;#Delta#eta;p_{T} (GeV/c)",
234 fNDPhiBins,-TMath::Pi()/2.,3.*TMath::Pi()/2.,
237 fOutputList->Add(fMixedEvents);
239 TString speciesname[] = {"Pion","Kaon","Proton"};
241 // Create TOF correlations histograms (DPhi,DEta,TOF).
242 if (fMakeTOFcorrelations) {
244 fTOFhistos = new TObjArray(3);
245 fTOFhistos->SetOwner(kTRUE);
246 fTOFhistos->SetName("CorrelationsTOF");
248 for (Int_t iSpecies = 0; iSpecies < 3; iSpecies++) {
250 TObjArray* atmp = new TObjArray(fTOFPtAxis->GetNbins());
251 atmp->SetOwner(kTRUE);
252 atmp->SetName(speciesname[iSpecies].Data());
254 for (Int_t iBinPt = 1; iBinPt < (fTOFPtAxis->GetNbins() + 1); iBinPt++) {
256 Int_t iPtClass = fTrackCutsAssociated->GetPtClass(iBinPt);
258 Int_t NBinsTOF = fTrackCutsAssociated->GetNTOFbins(iPtClass,iSpecies);
259 Double_t TOFmin = fTrackCutsAssociated->GetTOFmin(iPtClass,iSpecies);
260 Double_t TOFmax = fTrackCutsAssociated->GetTOFmax(iPtClass,iSpecies);
262 cout << "ptbin: "<< iBinPt << " class: " << iPtClass << " TOFBins: " << NBinsTOF << " min: " << TOFmin << " max: " << TOFmax << endl;
264 TH3F* htmp = new TH3F(Form("fCorrelationsTOF_%i",iBinPt),
265 Form("%5.3f < p_{T} < %5.3f; #Delta#phi; #Delta#eta; t_{TOF} (ps)", fTOFPtAxis->GetBinLowEdge(iBinPt), fTOFPtAxis->GetBinUpEdge(iBinPt)),
266 fNDPhiBins, -TMath::Pi()/2., 3.*TMath::Pi()/2.,
267 fNDEtaBins, -1.6, 1.6, NBinsTOF, TOFmin, TOFmax);
268 htmp->SetDirectory(0);
274 fTOFhistos->Add(atmp);
278 fOutputList->Add(fTOFhistos);
282 // Create TOF/TPC correlation histograms. (DPhi,DEta,TOF,TPC).
283 if (fMakeTOFTPCcorrelations) {
285 Double_t ptarrayTOFTPC[16] = {2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6,
286 2.8, 3.0, 3.2, 3.4, 3.6, 3.8,
288 fTOFTPCPtAxis = new TAxis(15, ptarrayTOFTPC);
289 fTOFTPCPtAxis->SetName("fTOFTPCPtAxis");
290 fTOFTPCPtAxis->SetTitle("p_{T} GeV/c");
291 fOutputList->Add(fTOFTPCPtAxis);
293 Int_t NBinsTOFTPC[4] = {32, 32, 60, 40};
294 Double_t minTOFTPC[4] = {-TMath::Pi()/2., -1.6, -1., -1.};
295 Double_t maxTOFTPC[4] = {3.*TMath::Pi()/2., 1.6, -1., -1.};
297 Double_t sTOFest = 110.;
298 Double_t sTPCest = 4.5;
300 fTOFTPChistos = new TObjArray(3);
301 fTOFTPChistos->SetOwner(kTRUE);
302 fTOFTPChistos->SetName("TOFTPChistos");
304 for (Int_t iSpecies = 0; iSpecies < 3; iSpecies++) {
306 TObjArray* atmp = new TObjArray(fTOFTPCPtAxis->GetNbins());
307 atmp->SetOwner(kTRUE);
308 atmp->SetName(speciesname[iSpecies].Data());
310 for (Int_t iBinPt = 1; iBinPt < (fTOFTPCPtAxis->GetNbins() + 1); iBinPt++) {
312 // Determine PID ranges.
314 // Set range +/- 5 sigma of main peak. (+ 10 sigma for TOF max, for mismatches.)
315 Double_t TOFmin = -5. * sTOFest;
316 Double_t TOFmax = 10. * sTOFest;
317 Double_t TPCmin = -4. * sTPCest;
318 Double_t TPCmax = 4. * sTPCest;
320 Double_t TOFexp = AliFunctionsDiHadronPID::TOFExpTime(fTOFTPCPtAxis->GetBinLowEdge(iBinPt), 0.4, AliFunctionsDiHadronPID::M(iSpecies));
321 Double_t TPCexp = AliFunctionsDiHadronPID::TPCExpdEdX(fTOFTPCPtAxis->GetBinLowEdge(iBinPt), 0.4, AliFunctionsDiHadronPID::M(iSpecies));
323 for (Int_t jSpecies = 0; jSpecies < 3; jSpecies++) {
325 if (iSpecies == jSpecies) {continue;}
327 Double_t TOFexpOther = AliFunctionsDiHadronPID::TOFExpTime(fTOFTPCPtAxis->GetBinLowEdge(iBinPt), 0.4, AliFunctionsDiHadronPID::M(jSpecies));
328 Double_t TPCexpOther = AliFunctionsDiHadronPID::TPCExpdEdX(fTOFTPCPtAxis->GetBinLowEdge(iBinPt), 0.4, AliFunctionsDiHadronPID::M(jSpecies));
330 // If any peak is within +/- 7 sigma, then also add this peak.
331 if ( (TMath::Abs(TOFexp - TOFexpOther) < 7. * sTOFest) ||
332 (TMath::Abs(TPCexp - TPCexpOther) < 7. * sTPCest) ) {
334 TOFmin = TMath::Min(TOFmin, (TOFexpOther - TOFexp - 2. * sTOFest) );
335 TOFmax = TMath::Max(TOFmax, (TOFexpOther - TOFexp + 10. * sTOFest) );
336 TPCmin = TMath::Min(TPCmin, (TPCexpOther - TPCexp - 2. * sTPCest) );
337 TPCmax = TMath::Max(TPCmax, (TPCexpOther - TPCexp + 2. * sTPCest) );
343 minTOFTPC[2] = TOFmin;
344 maxTOFTPC[2] = TOFmax;
345 minTOFTPC[3] = TPCmin;
346 maxTOFTPC[3] = TPCmax;
348 THnF* htmp = new THnF(Form("fCorrelationsTOF_%i",iBinPt),
349 Form("%5.3f < p_{T} < %5.3f", fTOFTPCPtAxis->GetBinLowEdge(iBinPt), fTOFTPCPtAxis->GetBinUpEdge(iBinPt)),
350 4, NBinsTOFTPC, minTOFTPC, maxTOFTPC);
352 (htmp->GetAxis(0))->SetTitle("#Delta#phi");
353 (htmp->GetAxis(1))->SetTitle("#Delta#eta");
354 (htmp->GetAxis(2))->SetTitle("t_{TOF} (ps)");
355 (htmp->GetAxis(3))->SetTitle("dE/dx (a.u.)");
361 fTOFTPChistos->Add(atmp);
365 fOutputList->Add(fTOFTPChistos);
369 // Load external TOF histograms if flag is set.
370 if (fCalculateTOFmismatch) {LoadExtMismatchHistos();}
372 PostData(1,fOutputList);
376 // -----------------------------------------------------------------------
377 void AliAnalysisTaskDiHadronPID::LocalInit() {
380 // Initialize on the this computer.
383 if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
387 // -----------------------------------------------------------------------
388 void AliAnalysisTaskDiHadronPID::UserExec(Option_t*) {
394 if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
396 // Input Current Event.
397 fCurrentAODEvent = dynamic_cast<AliAODEvent*>(InputEvent());
398 if (!fCurrentAODEvent) AliFatal("No Event Found!");
400 if (!fEventCuts->IsSelected(fCurrentAODEvent)) {return;}
402 // Fill the global tracks array. - NOT NEEDED I THINK, since we're not using
403 // bit 1<<7 for the associated tracks!
405 // Let the track cut objects know that a new event will start.
406 fTrackCutsTrigger->StartNewEvent();
407 fTrackCutsAssociated->StartNewEvent();
409 // Create arrays for trigger/associated particles.
410 fTriggerTracks = new TObjArray(350);
411 fTriggerTracks->SetOwner(kTRUE);
413 fAssociatedTracks = new TObjArray(3500);
414 fAssociatedTracks->SetOwner(kTRUE);
416 for (Int_t iTrack = 0; iTrack < fCurrentAODEvent->GetNumberOfTracks(); iTrack++) {
418 AliAODTrack* track = (AliAODTrack*)fCurrentAODEvent->GetTrack(iTrack);
419 AliTrackDiHadronPID* pidtrack = new AliTrackDiHadronPID(track,0x0,0x0,fPIDResponse);
420 pidtrack->ForgetAboutPointers();
421 pidtrack->SetDebugLevel(fDebug);
423 Double_t rndhittime = -1.e21;
424 if (fCalculateTOFmismatch) rndhittime = GenerateRandomHit(pidtrack->Eta());
426 // Fill p_T spectrum.
427 fPtSpectrum->Fill(pidtrack->Pt());
429 // Fill the trigger/associated tracks array.
430 if (fTrackCutsTrigger->IsSelectedData(pidtrack,rndhittime)) {fTriggerTracks->AddLast(pidtrack);}
431 else if (fTrackCutsAssociated->IsSelectedData(pidtrack,rndhittime)) {fAssociatedTracks->AddLast(pidtrack);}
432 else {delete pidtrack;}
436 // Fill Correlation histograms.
437 for (Int_t iTrigger = 0; iTrigger < fTriggerTracks->GetEntriesFast(); iTrigger++) {
438 AliTrackDiHadronPID* triggertrack = (AliTrackDiHadronPID*)fTriggerTracks->At(iTrigger);
440 for (Int_t iAssociated = 0; iAssociated < fAssociatedTracks->GetEntriesFast(); iAssociated++) {
441 AliTrackDiHadronPID* associatedtrack = (AliTrackDiHadronPID*)fAssociatedTracks->At(iAssociated);
443 Double_t DPhi = triggertrack->Phi() - associatedtrack->Phi();
444 if (DPhi < -TMath::Pi()/2.) {DPhi += 2.*TMath::Pi();}
445 if (DPhi > 3.*TMath::Pi()/2.) {DPhi -= 2.*TMath::Pi();}
447 Double_t DEta = triggertrack->Eta() - associatedtrack->Eta();
448 fCorrelations->Fill(DPhi,DEta,associatedtrack->Pt());
450 for (Int_t iSpecies = 0; iSpecies < 3; iSpecies++) {
452 Double_t apt = associatedtrack->Pt();
454 // Fill TOF correlations.
455 if (fMakeTOFcorrelations) {
457 TObjArray* atmp = (TObjArray*)fTOFhistos->At(iSpecies);
458 Int_t ptbin = fTOFPtAxis->FindBin(apt);
460 // Only fill if histogram exists in fTOFhistos.
461 if ( !(ptbin < 1) && !(ptbin > fTOFPtAxis->GetNbins()) ) {
463 TH3F* htmp = (TH3F*)atmp->At(ptbin - 1);
464 htmp->Fill(DPhi, DEta, associatedtrack->GetTOFsignalMinusExpected(iSpecies));
469 // Fill TOF/ TPC Correlations.
470 if (fMakeTOFTPCcorrelations) {
472 TObjArray* atmp = (TObjArray*)fTOFTPChistos->At(iSpecies);
473 Int_t ptbin = fTOFTPCPtAxis->FindBin(apt);
475 // Only fill if histogram exists in fTOFhistos.
476 if ( !(ptbin < 1) && !(ptbin > fTOFTPCPtAxis->GetNbins()) ) {
478 THnF* htmp = (THnF*)atmp->At(ptbin - 1);
479 Double_t TOFTPCfill[4] = {DPhi, DEta,
480 associatedtrack->GetTOFsignalMinusExpected(iSpecies), associatedtrack->GetTPCsignalMinusExpected(iSpecies)};
482 htmp->Fill(TOFTPCfill);
490 cout<<"Triggers: "<<fTriggerTracks->GetEntriesFast()<<" Associateds: "<<fAssociatedTracks->GetEntriesFast()<<endl;
492 // Determine centrality of current event.
493 TString centralityestimator = fEventCuts->GetCentralityEstimator();
494 AliCentrality* currentcentrality = fCurrentAODEvent->GetCentrality();
495 Float_t percentile = currentcentrality->GetCentralityPercentile(centralityestimator.Data());
497 // Determine vtxz of current event.
498 AliAODVertex* currentprimaryvertex = fCurrentAODEvent->GetPrimaryVertex();
499 Double_t vtxz = currentprimaryvertex->GetZ();
501 AliEventPool* poolin = fPoolMgr->GetEventPool(percentile, vtxz);
502 if (!poolin) {AliFatal(Form("No pool found for centrality = %f, vtxz = %f", percentile, vtxz));}
503 // TObjArray* fGlobalTracksArray;
505 // Give a print out of the pool manager's contents.
506 if (fDebug > 0) PrintPoolManagerContents();
508 // Mix events if there are enough events in the pool.
509 if (poolin->GetCurrentNEvents() >= fMinNEventsForMixing) {
510 {cout << "Mixing Events." << endl;}
512 // Loop over all events in the event pool.
513 for (Int_t iMixEvent = 0; iMixEvent < poolin->GetCurrentNEvents(); iMixEvent++) {
514 TObjArray* mixtracks = poolin->GetEvent(iMixEvent);
516 // Mix either the triggers or the associateds.
519 // Loop over all associateds in this event.
520 for (Int_t iAssociated = 0; iAssociated < fAssociatedTracks->GetEntriesFast(); iAssociated++) {
521 AliTrackDiHadronPID* associatedtrack = (AliTrackDiHadronPID*)fAssociatedTracks->At(iAssociated);
523 // Loop over all mixed tracks.
524 for (Int_t iMixTrack = 0; iMixTrack < mixtracks->GetEntriesFast(); iMixTrack++) {
525 AliTrackDiHadronPID* mixtrack = (AliTrackDiHadronPID*)mixtracks->At(iMixTrack);
527 Double_t DPhi = mixtrack->Phi() - associatedtrack->Phi();
528 if (DPhi < -TMath::Pi()/2.) {DPhi += 2.*TMath::Pi();}
529 if (DPhi > 3.*TMath::Pi()/2.) {DPhi -= 2.*TMath::Pi();}
531 Double_t DEta = mixtrack->Eta() - associatedtrack->Eta();
532 fMixedEvents->Fill(DPhi,DEta,associatedtrack->Pt());
539 // Loop over all triggers in this event.
540 for (Int_t iTrigger = 0; iTrigger < fTriggerTracks->GetEntriesFast(); iTrigger++) {
541 AliTrackDiHadronPID* triggertrack = (AliTrackDiHadronPID*)fTriggerTracks->At(iTrigger);
543 // Loop over all mixed tracks.
544 for (Int_t iMixTrack = 0; iMixTrack < mixtracks->GetEntriesFast(); iMixTrack++) {
545 AliTrackDiHadronPID* mixtrack = (AliTrackDiHadronPID*)mixtracks->At(iMixTrack);
547 Double_t DPhi = triggertrack->Phi() - mixtrack->Phi();
548 if (DPhi < -TMath::Pi()/2.) {DPhi += 2.*TMath::Pi();}
549 if (DPhi > 3.*TMath::Pi()/2.) {DPhi -= 2.*TMath::Pi();}
551 Double_t DEta = triggertrack->Eta() - mixtrack->Eta();
552 fMixedEvents->Fill(DPhi,DEta,mixtrack->Pt());
561 // Update the event pool.
562 AliEventPool* poolout = fPoolMgr->GetEventPool(percentile, vtxz); // Get the buffer associated with the current centrality and z-vtx
563 if (!poolout) AliFatal(Form("No pool found for centrality = %f, vtx_z = %f", percentile, vtxz));
565 // Q: is it a problem that the fAssociatedTracks array can be bigger than the number of tracks inside?
567 poolout->UpdatePool(fTriggerTracks);
568 fAssociatedTracks->Delete();
569 delete fAssociatedTracks;
572 poolout->UpdatePool(fAssociatedTracks);
573 fTriggerTracks->Delete();
574 delete fTriggerTracks;
577 fTriggerTracks = 0x0;
578 fAssociatedTracks = 0x0;
580 // Tell the track cut object that the event is done.
581 fTrackCutsTrigger->EventIsDone(0);
582 fTrackCutsAssociated->EventIsDone(0);
584 PostData(1,fOutputList);
588 // -----------------------------------------------------------------------
589 Bool_t AliAnalysisTaskDiHadronPID::LoadExtMismatchHistos() {
592 // Attempting to load a root file containing information needed
593 // to generate random TOF hits.
596 if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
598 // Opening external TOF file.
599 if (fDebug > 0) cout<<"Trying to open TOFmismatchHistos.root ..."<<endl;
601 fin = TFile::Open("alien:///alice/cern.ch/user/m/mveldhoe/rootfiles/TOFmismatchHistos.root");
603 AliWarning("Couln't open TOFmismatchHistos, will not calculate mismatches...");
604 fCalculateTOFmismatch = kFALSE;
608 // Check if the required histograms are present.
609 TH1F* tmp1 = (TH1F*)fin->Get("hNewT0Fill");
611 AliWarning("Couln't find hNewT0Fill, will not calculate mismatches...");
612 fCalculateTOFmismatch = kFALSE;
615 TH2F* tmp2 = (TH2F*)fin->Get("hLvsEta");
617 AliWarning("Couln't find hLvsEta, will not calculate mismatches...");
618 fCalculateTOFmismatch = kFALSE;
622 // Make a deep copy of the files in the histogram.
623 fT0Fill = (TH1F*)tmp1->Clone("fT0Fill");
624 fLvsEta = (TH2F*)tmp2->Clone("fLvsEta");
626 // Close the external file.
627 AliInfo("Closing external file.");
630 // Creating a TObjArray for LvsEta projections.
631 const Int_t nbinseta = fLvsEta->GetNbinsX();
632 fLvsEtaProjections = new TObjArray(nbinseta);
633 fLvsEtaProjections->SetOwner(kTRUE);
635 // Making the projections needed (excluding underflow/ overflow).
636 for (Int_t iEtaBin = 1; iEtaBin < (nbinseta + 1); iEtaBin++) {
637 TH1F* tmp = (TH1F*)fLvsEta->ProjectionY(Form("LvsEtaProjection_%i",iEtaBin),iEtaBin,iEtaBin);
638 tmp->SetDirectory(0);
639 fLvsEtaProjections->AddAt(tmp,iEtaBin);
646 // -----------------------------------------------------------------------
647 Double_t AliAnalysisTaskDiHadronPID::GenerateRandomHit(Double_t eta) {
650 // Returns a random TOF time.
653 if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
655 // Default (error) value:
656 Double_t rndhittime = -1.e21;
658 // TOF mismatch flag is not turned on.
659 if (!fCalculateTOFmismatch) {
660 AliFatal("Called GenerateRandomHit() method, but flag fCalculateTOFmismatch not set.");
664 // TOF doesn't extend much further than 0.8.
665 if (TMath::Abs(eta) > 0.8) {
666 if (fDebug) {AliInfo("Tried to get a random hit for a track with eta > 0.8.");}
670 // Finding the bin of the eta.
671 TAxis* etaAxis = fLvsEta->GetXaxis();
672 Int_t etaBin = etaAxis->FindBin(eta);
673 //cout<<"Eta: "<<eta<<" bin: "<<etaBin<<endl;
674 const TH1F* lengthDistribution = (const TH1F*)fLvsEtaProjections->At(etaBin);
676 if (!lengthDistribution) {
677 AliFatal("length Distribution not found.");
681 Double_t currentRndLength = lengthDistribution->GetRandom(); // in cm.
683 // Similar to Roberto's code.
684 Double_t currentRndTime = currentRndLength / (TMath::C() * 1.e2 / 1.e12);
685 Double_t t0fill = -1.26416e+04;
686 rndhittime = fT0Fill->GetRandom() - t0fill + currentRndTime;
692 // -----------------------------------------------------------------------
693 void AliAnalysisTaskDiHadronPID::PrintPoolManagerContents() {
696 // Prints out the current contents of the event pool manager.
699 // Determine the number of pools in the pool manager.
700 AliEventPool* poolin = fPoolMgr->GetEventPool(0,0);
701 Int_t NPoolsCentrality = 0;
704 poolin = fPoolMgr->GetEventPool(NPoolsCentrality,0);
707 poolin = fPoolMgr->GetEventPool(0,0);
708 Int_t NPoolsVtxZ = 0;
711 poolin = fPoolMgr->GetEventPool(0,NPoolsVtxZ);
714 // Loop over all Pools in the matrix of the pool manager.
715 cout<<" Pool manager contents: (Nevt,NTrack)"<<endl;
716 for (Int_t iCentrality = 0; iCentrality < NPoolsCentrality; iCentrality++) {
717 cout<<Form("Centrality Bin: %2i --> ", iCentrality);
719 for (Int_t iVtxZ = 0; iVtxZ < NPoolsVtxZ; iVtxZ++) {
721 poolin = fPoolMgr->GetEventPool(iCentrality, iVtxZ);
723 cout<<Form("(%2i,%4i) ",poolin->GetCurrentNEvents(), poolin->NTracksInPool());
732 // -----------------------------------------------------------------------
733 void AliAnalysisTaskDiHadronPID::Terminate(Option_t*) {;
736 // Called when task is done.
739 if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;}
745 delete fLvsEtaProjections;
746 fLvsEtaProjections = 0x0;