1 // ----------------------------------------------------------------------------
2 // This class makes di-hadron correlations, with TOF and TPC signals for
3 // the associated particles.
5 // ----------------------------------------------------------------------------
6 // Author: Misha Veldhoen (misha.veldhoen@cern.ch)
7 // Last edit: May 2nd 2012. (v 8.00)
8 // ----------------------------------------------------------------------------
18 #include "TClonesArray.h"
20 #include "AliAODTrack.h"
21 #include "AliAODEvent.h"
22 #include "AliAODInputHandler.h"
23 #include "AliAODVertex.h"
24 //#include "AliAODPid.h"
26 #include "AliAnalysisManager.h"
27 #include "AliInputEventHandler.h"
28 #include "AliPIDResponse.h"
29 #include "AliTPCPIDResponse.h"
30 //#include "AliTOFPIDResponse.h"
32 // Includes for a MC run.
33 #include "AliAODMCParticle.h"
37 #include "AliAnalysisTaskDiHadronPID.h"
39 ClassImp(AliAnalysisTaskDiHadronPID);
41 //_____________________________________________________________________________
42 AliAnalysisTaskDiHadronPID::AliAnalysisTaskDiHadronPID():
58 fDCAZoomedTwiceCut(0x0),
64 fEtaSpectrumTrig(0x0),
65 fEtaSpectrumAssoc(0x0),
66 fPhiSpectrumAssoc(0x0),
67 fTPCnSigmaProton(0x0),
68 fTOFnSigmaProton(0x0),
78 fCalculateMixedEvents(kFALSE),
87 fVertexZMixedEvents(2.),
88 fCentralityCutMax(0.),
89 fCentralityCutMin(10.),
93 fDemandNoMismatch(kFALSE),
95 fPrintBufferSize(kFALSE),
98 fTrigBufferMaxSize(100)
103 // Default Constructor.
107 for(Int_t ii=0; ii<25000; ii++) {
108 for(Int_t jj=0; jj<4; jj++) {
109 fTrigBuffer[ii][jj]=0;
113 // The identified di-hadron correlations.
114 for (Int_t ii = 0; ii < 3; ii++) {
115 //fMixedEventsTPCTOFCut[ii]=0x0;
116 for (Int_t jj = 0; jj < 10; jj++) {
117 fDiHadronTPCTOF[ii][jj]=0x0;
118 fMixedEventsTPCTOF[ii][jj]=0x0;
119 fInclusiveTPCTOF[ii][jj]=0x0;
120 fInclusiveTPCTOFRap[ii][jj]=0x0;
125 for (Int_t ii=0; ii<8; ii++) {
126 fTrackCutLabelNumbers[ii]=ii+1;
129 // Monte Carlo Efficiency Histograms.
130 for (Int_t iSpecies=0; iSpecies<6; iSpecies++) {
131 fPtEtaDistrDataPrim[iSpecies]=0x0;
132 fPtEtaDistrDataSec[iSpecies]=0x0;
133 fPtRapDistrDataPrimRapCut[iSpecies]=0x0;
134 fPtRapDistrDataSecRapCut[iSpecies]=0x0;
136 fPtEtaDistrMCPrim[iSpecies]=0x0;
137 fPtEtaDistrMCSec[iSpecies]=0x0;
138 fPtRapDistrMCPrimRapCut[iSpecies]=0x0;
139 fPtRapDistrMCSecRapCut[iSpecies]=0x0;
141 fDiHadronMC[iSpecies]=0x0;
147 //_____________________________________________________________________________
148 AliAnalysisTaskDiHadronPID::AliAnalysisTaskDiHadronPID(const char *name):
149 AliAnalysisTaskSE(name),
161 fDCAZoomedTwice(0x0),
164 fDCAZoomedTwiceCut(0x0),
166 fTrackCutsCount(0x0),
170 fEtaSpectrumTrig(0x0),
171 fEtaSpectrumAssoc(0x0),
172 fPhiSpectrumAssoc(0x0),
173 fTPCnSigmaProton(0x0),
174 fTOFnSigmaProton(0x0),
184 fCalculateMixedEvents(kFALSE),
193 fVertexZMixedEvents(2.),
194 fCentralityCutMax(0.),
195 fCentralityCutMin(10.),
199 fDemandNoMismatch(kFALSE),
201 fPrintBufferSize(kFALSE),
204 fTrigBufferMaxSize(100)
209 // Named Constructor.
212 DefineInput(0, TChain::Class());
213 DefineOutput(1, TList::Class());
216 for(Int_t ii=0; ii<25000; ii++) {
217 for(Int_t jj=0; jj<4; jj++) {
218 fTrigBuffer[ii][jj]=0;
222 // The identified di-hadron correlations.
223 for (Int_t ii = 0; ii < 3; ii++) {
224 //fMixedEventsTPCTOFCut[ii]=0x0;
225 for (Int_t jj = 0; jj < 10; jj++) {
226 fDiHadronTPCTOF[ii][jj]=0x0;
227 fMixedEventsTPCTOF[ii][jj]=0x0;
228 fInclusiveTPCTOF[ii][jj]=0x0;
229 fInclusiveTPCTOFRap[ii][jj]=0x0;
234 for (Int_t ii=0; ii<8; ii++) {
235 fTrackCutLabelNumbers[ii]=ii+1;
238 // Monte Carlo Efficiency Histograms.
239 for (Int_t iSpecies=0; iSpecies<6; iSpecies++) {
240 fPtEtaDistrDataPrim[iSpecies]=0x0;
241 fPtEtaDistrDataSec[iSpecies]=0x0;
242 fPtRapDistrDataPrimRapCut[iSpecies]=0x0;
243 fPtRapDistrDataSecRapCut[iSpecies]=0x0;
245 fPtEtaDistrMCPrim[iSpecies]=0x0;
246 fPtEtaDistrMCSec[iSpecies]=0x0;
247 fPtRapDistrMCPrimRapCut[iSpecies]=0x0;
248 fPtRapDistrMCSecRapCut[iSpecies]=0x0;
250 fDiHadronMC[iSpecies]=0x0;
256 //_____________________________________________________________________________
257 AliAnalysisTaskDiHadronPID::~AliAnalysisTaskDiHadronPID() {
264 delete fGlobalTracks;
275 //_____________________________________________________________________________
276 void AliAnalysisTaskDiHadronPID::UserCreateOutputObjects()
283 // Print the settings of the analysis task.
285 cout<<"-----------------------------------------------"<<endl;
286 cout<<" AliAnalysisTaskDiHadronPID Settings:"<<endl;
287 cout<<"-----------------------------------------------"<<endl;
288 cout<<"Verbose Level: "<<fVerbose<<endl;
289 cout<<"Mixed Events Calculated: "<<fCalculateMixedEvents<<endl;
290 cout<<"Beam Type: "<<fBeamType<<endl;
291 cout<<"Run over MC: "<<fMC<<endl;
292 cout<<Form("Max eta: %3.1f",fMaxEta)<<endl;
293 cout<<Form("Max eta plotted: %3.1f",fMaxPlotEta)<<endl;
294 cout<<Form("Max rapidity in spectra: %3.1f",fMaxRap)<<endl;
295 cout<<Form("Max p_T for the triggers: %3.1f GeV/c.",fMaxPt)<<endl;
296 cout<<"Nbins in eta and delta eta: "<<fNEtaBins<<endl;
297 cout<<"Nbins in phi and delta phi: "<<fNPhiBins<<endl;
298 cout<<Form("Events mixed if vertices differ %3.1f cm.",fVertexZMixedEvents)<<endl;
299 cout<<Form("Centrality between %3.1f and %3.1f percent.",fCentralityCutMax,fCentralityCutMin)<<endl;
300 cout<<"Tracks are cut if less than 2 SPD hits: "<<fDoITSCut<<endl;
301 cout<<"Tracks cut if DCA is too big: "<<fDoDCACut<<endl;
302 cout<<"Tracks cut if there is a TPC-TOF mismatch: "<<fDemandNoMismatch<<endl;
303 cout<<"Maximum number of triggers stored: "<<fTrigBufferMaxSize<<endl;
304 cout<<"-----------------------------------------------"<<endl;
307 // Obtain a pointer to the analysis manager.
308 AliAnalysisManager* manager = AliAnalysisManager::GetAnalysisManager();
310 if (fVerbose>0) cout<<"AliAnalysisTaskDiHadronPID::UserCreateOutputObjects -> ERROR: Analysis manager not found."<<endl;
314 cout<<"AliAnalysisTaskDiHadronPID::UserCreateOutputObjects -> Analysis manager found."<<endl;
317 // Obtain a pointer to the input handler.
318 AliInputEventHandler* inputHandler = dynamic_cast<AliInputEventHandler*> (manager->GetInputEventHandler());
320 if (fVerbose>0) cout<<"AliAnalysisTaskDiHadronPID::UserCreateOutputObjects -> ERROR: Input handler not found."<<endl;
324 cout<<"AliAnalysisTaskDiHadronPID::UserCreateOutputObjects -> Input handler found."<<endl;
327 // Obtain a pointer to the PID response object.
328 fPIDResponse = inputHandler->GetPIDResponse();
330 if (fVerbose>0) cout<<"AliAnalysisTaskDiHadronPID::UserCreateOutputObjects -> ERROR: PID response object not found."<<endl;
334 cout<<"AliAnalysisTaskDiHadronPID::UserCreateOutputObjects -> PID response object found."<<endl;
337 // Create the output of the task.
338 fHistoList = new TList();
339 fHistoList->SetOwner(kTRUE);
341 // Ranges in dPhi, dEta, and the number of bins for di-hadron correlations.
342 Int_t binsHisto[4] = {fNPhiBins,fNEtaBins};
343 Double_t minHisto[4] = {-TMath::Pi()/2.,-2*fMaxPlotEta};
344 Double_t maxHisto[4] = {3.*TMath::Pi()/2,2*fMaxPlotEta};
346 // --- EVENT QA PLOTS ---
348 fCentrality = new TH1F("fCentrality","Centrality;Centrality;N_{evt}",100,0,100);
349 fHistoList->Add(fCentrality);
350 fVertexZ = new TH1F("fVertexZ","Vertex Z position;z (cm);N_{evt}",30,-15,15);
351 fHistoList->Add(fVertexZ);
353 // --- TRACK QA PLOTS ---
355 fDCA = new TH2F("fDCA","DCA positions TPC only cuts;xy (cm);z (cm)",100,-5,5,100,-5,5);
356 fHistoList->Add(fDCA);
357 fDCAZoomed = new TH2F("fDCAZoomed","DCA positions TPC only cuts;xy (cm);z (cm)",100,-.5,.5,100,-.5,.5);
358 fHistoList->Add(fDCAZoomed);
359 fDCAZoomedTwice = new TH2F("fDCAZoomedTwice","DCA positions TPC only cuts;xy (cm);z (cm)",100,-.05,.05,100,-.05,.05);
360 fHistoList->Add(fDCAZoomedTwice);
361 fDCACut = new TH2F("fDCACut","DCA positions after DCA cut;xy (cm);z (cm)",100,-5,5,100,-5,5);
362 fHistoList->Add(fDCACut);
363 fDCAZoomedCut = new TH2F("fDCAZoomedCut","DCA positions after DCA cut;xy (cm);z (cm)",100,-.5,.5,100,-.5,.5);
364 fHistoList->Add(fDCAZoomedCut);
365 fDCAZoomedTwiceCut = new TH2F("fDCAZoomedTwiceCut","DCA positions after DCA cut;xy (cm);z (cm)",100,-.05,.05,100,-.05,.05);
366 fHistoList->Add(fDCAZoomedTwiceCut);
368 fITSHits = new TH1F("fITSHits","ITS hits",3,0,3);
369 (fITSHits->GetXaxis())->SetBinLabel(1,"No SPD hit");
370 (fITSHits->GetXaxis())->SetBinLabel(2,"One SPD hit");
371 (fITSHits->GetXaxis())->SetBinLabel(3,"Two SPD hits");
372 fHistoList->Add(fITSHits);
374 // Determine the bins used in the track cut histograms.
375 const Int_t ncuts = 5 + fDoITSCut + fDoDCACut + fDemandNoMismatch;
378 fTrackCutLabelNumbers[3]--;
379 fTrackCutLabelNumbers[4]--;
380 fTrackCutLabelNumbers[5]--;
381 fTrackCutLabelNumbers[6]--;
382 fTrackCutLabelNumbers[7]--;
386 fTrackCutLabelNumbers[4]--;
387 fTrackCutLabelNumbers[5]--;
388 fTrackCutLabelNumbers[6]--;
389 fTrackCutLabelNumbers[7]--;
392 fTrackCutsCount = new TH1F("fTrackCutsCount","Track Cuts;;Count",ncuts,0,ncuts);
393 (fTrackCutsCount->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[0],"Std. TPC Only");
394 (fTrackCutsCount->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[1],Form("#eta < %3.1f",fMaxEta));
395 if (fDoITSCut) (fTrackCutsCount->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[2],"1-2 SPD hits");
396 if (fDoDCACut) (fTrackCutsCount->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[3],"DCA cut");
397 (fTrackCutsCount->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[4],"p_{T} < 5.0 GeV/c");
398 (fTrackCutsCount->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[5],"TPCpid (p_{T} < 5.0 GeV/c)");
399 (fTrackCutsCount->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[6],"TOFpid (p_{T} < 5.0 GeV/c)");
400 if (fDemandNoMismatch) (fTrackCutsCount->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[7],"No Mismatch (p_{T} < 5.0 GeV/c)");
401 fHistoList->Add(fTrackCutsCount);
403 fTrackCutsPt = new TH2F("fTrackCutsPt","Track Cuts vs p_{T};;p_{T};Count",ncuts,0,ncuts,40,0,fMaxPt);
404 (fTrackCutsPt->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[0],"Std. TPC Only");
405 (fTrackCutsPt->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[1],Form("#eta < %3.1f",fMaxEta));
406 if (fDoITSCut) (fTrackCutsPt->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[2],"1-2 SPD hits");
407 if (fDoDCACut) (fTrackCutsPt->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[3],"DCA cut");
408 (fTrackCutsPt->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[4],"p_{T} < 5.0 GeV/c");
409 (fTrackCutsPt->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[5],"TPCpid (p_{T} < 5.0 GeV/c)");
410 (fTrackCutsPt->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[6],"TOFpid (p_{T} < 5.0 GeV/c)");
411 if (fDemandNoMismatch) (fTrackCutsPt->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[7],"No Mismatch (p_{T} < 5.0 GeV/c)");
412 fHistoList->Add(fTrackCutsPt);
414 fTrackCutsEta = new TH2F("fTrackCutsEta","Track Cuts vs #eta;;#eta;Count",ncuts,0,ncuts,4*binsHisto[1],-fMaxPlotEta,fMaxPlotEta);
415 (fTrackCutsEta->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[0],"Std. TPC Only");
416 (fTrackCutsEta->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[1],Form("#eta < %3.1f",fMaxEta));
417 if (fDoITSCut) (fTrackCutsEta->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[2],"1-2 SPD hits");
418 if (fDoDCACut) (fTrackCutsEta->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[3],"DCA cut");
419 (fTrackCutsEta->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[4],"p_{T} < 5.0 GeV/c");
420 (fTrackCutsEta->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[5],"TPCpid (p_{T} < 5.0 GeV/c)");
421 (fTrackCutsEta->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[6],"TOFpid (p_{T} < 5.0 GeV/c)");
422 if (fDemandNoMismatch) (fTrackCutsEta->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[7],"No Mismatch (p_{T} < 5.0 GeV/c)");
423 fHistoList->Add(fTrackCutsEta);
425 fTrackCutsPhi = new TH2F("fTrackCutsPhi","Track Cuts vs #phi;;#phi;Count",ncuts,0,ncuts,72,0,2.*TMath::Pi());
426 (fTrackCutsPhi->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[0],"Std. TPC Only");
427 (fTrackCutsPhi->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[1],Form("#eta < %3.1f",fMaxEta));
428 if (fDoITSCut) (fTrackCutsPhi->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[2],"1-2 SPD hits");
429 if (fDoDCACut) (fTrackCutsPhi->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[3],"DCA cut");
430 (fTrackCutsPhi->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[4],"p_{T} < 5.0 GeV/c");
431 (fTrackCutsPhi->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[5],"TPCpid (p_{T} < 5.0 GeV/c)");
432 (fTrackCutsPhi->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[6],"TOFpid (p_{T} < 5.0 GeV/c)");
433 if (fDemandNoMismatch) (fTrackCutsPhi->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[7],"No Mismatch (p_{T} < 5.0 GeV/c)");
434 fHistoList->Add(fTrackCutsPhi);
436 fEtaSpectrumTrig = new TH1F("fEtaSpectrumTrig","#eta Spectrum Triggers;#eta;Count",4*binsHisto[1],-fMaxPlotEta,fMaxPlotEta);
437 fHistoList->Add(fEtaSpectrumTrig);
438 fEtaSpectrumAssoc = new TH2F("fEtaSpectrumAssoc","#eta Spectrum Associateds;#eta;p_{T};Count",4*binsHisto[1],-fMaxPlotEta,fMaxPlotEta,10,0.,5.);
439 fHistoList->Add(fEtaSpectrumAssoc);
440 fPhiSpectrumAssoc = new TH2F("fPhiSpectrumAssoc","#phi Spectrum Associateds;#phi;p_{T};Count",72,0,2.*TMath::Pi(),10,0.,5.);
441 fHistoList->Add(fPhiSpectrumAssoc);
443 // --- QA PLOTS PID ---
445 fTPCnSigmaProton = new TH2F("fTPCnSigmaProton","n#sigma plot for the TPC (Protons);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);
446 fHistoList->Add(fTPCnSigmaProton);
447 fTOFnSigmaProton = new TH2F("fTOFnSigmaProton","n#sigma plot for the TOF (Protons);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);
448 fHistoList->Add(fTOFnSigmaProton);
449 fTPCnSigmaPion = new TH2F("fTPCnSigmaPion","n#sigma plot for the TPC (Pions);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);
450 fHistoList->Add(fTPCnSigmaPion);
451 fTOFnSigmaPion = new TH2F("fTOFnSigmaPion","n#sigma plot for the TOF (Pions);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);
452 fHistoList->Add(fTOFnSigmaPion);
453 fTPCnSigmaKaon = new TH2F("fTPCnSigmaKaon","n#sigma plot for the TPC (Kaons);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);
454 fHistoList->Add(fTPCnSigmaKaon);
455 fTOFnSigmaKaon = new TH2F("fTOFnSigmaKaon","n#sigma plot for the TOF (Kaons);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);
456 fHistoList->Add(fTOFnSigmaKaon);
457 fTPCSignal = new TH3F("fTPCSignal","TPC Signal;#eta;p_{T} GeV/c;dE/dx",25,-fMaxEta,fMaxEta,100,0.,5.,150,0.,300.);
458 fHistoList->Add(fTPCSignal);
459 fTOFSignal = new TH3F("fTOFSignal","TOF Signal;#eta;p_{T} GeV/c;t",25,-fMaxEta,fMaxEta,100,0.,5.,150,10000.,25000.);
460 fHistoList->Add(fTOFSignal);
462 // --- DI-HADRON CORRELATIONS AND MIXED EVENTS WITH TPC AND TOF SIGNALS ---
464 // Unzoomed pictures.
465 Int_t binsTPCnoZoom[3][10] = {{100,100,100,100,100,100,100,100,100,100},
466 {100,100,100,100,100,100,100,100,100,100},
467 {100,100,100,100,100,100,100,100,100,100}};
469 Double_t minTPCnoZoom[3][10] = {{ -50., -50.,-30.,-30.,-30.,-30.,-30.,-30.,-30.,-30.},
470 { -100., -50.,-20.,-20.,-20.,-20.,-20.,-20.,-20.,-20.},
471 { -200.,-150.,-50.,-30.,-20.,-20.,-20.,-20.,-20.,-20.}};
472 Double_t maxTPCnoZoom[3][10] = {{ 150., 100., 50., 30., 25., 25., 25., 25., 25., 25.},
473 { 50., 100., 40., 30., 30., 30., 30., 30., 30., 30.},
474 { 100., 50., 50., 30., 30., 30., 30., 30., 30., 30.}};
476 Int_t binsTOFnoZoom[3][10] = {{100,100,100,100,100,100,100,100,100,100},
477 {100,100,100,100,100,100,100,100,100,100},
478 {100,100,100,100,100,100,100,100,100,100}};
480 Double_t minTOFnoZoom[3][10] = {{-2000.,-2000.,-1000., -500., -500., -500., -500., -500., -500., -500.},
481 {-2000.,-2000.,-2000.,-1000.,-1000.,-1000.,-1000.,-1000.,-1000.,-1000.},
482 {-2000.,-2000.,-6000.,-3000.,-2000.,-1500.,-1500.,-1500.,-1500.,-1500.}};
483 Double_t maxTOFnoZoom[3][10] = {{ 2000., 2000., 5000., 3000., 2000., 1500., 1500., 1500., 1500., 1500.},
484 { 2000., 2000., 5000., 2000., 1500., 1500., 1500., 1500., 1500., 1500.},
485 { 2000., 2000., 2000., 1000., 1000., 1000., 1000., 1000., 1000., 1000.}};
488 Int_t binsTPCZoom[3][10] = {{100,100,100,100,100,100,100,100,100,100},
489 {100,100,100,100,100,100,100,100,100,100},
490 {100,100,100,100,100,100,100,100,100,100}};
492 Double_t minTPCZoom[3][10] = {{ -20., -20.,-20.,-20.,-20.,-20.,-20.,-20.,-20.,-20.},
493 { -20., -20.,-20.,-20.,-20.,-20.,-20.,-20.,-20.,-20.},
494 { -40., -20.,-20.,-20.,-20.,-20.,-20.,-20.,-20.,-20.}};
495 Double_t maxTPCZoom[3][10] = {{ 20., 20., 20., 20., 20., 20., 20., 20., 20., 20.},
496 { 20., 20., 20., 20., 20., 20., 20., 20., 20., 20.},
497 { 40., 20., 20., 20., 20., 30., 30., 30., 30., 30.}};
499 Int_t binsTOFZoom[3][10] = {{100,100,100,100,100,100,100,100,100,100},
500 {100,100,100,100,100,100,100,100,100,100},
501 {100,100,100,100,100,100,100,100,100,100}};
503 Double_t minTOFZoom[3][10] = {{-1000.,-1000., -500., -500., -500., -400., -400., -400., -400., -400.},
504 { -800., -800., -800., -800., -800., -600., -500., -500., -400., -400.},
505 {-1000.,-1000.,-1000.,-1000., -800.,-1000.,-1000., -800., -700., -700.}};
506 Double_t maxTOFZoom[3][10] = {{ 1000., 1000., 1000., 1000., 1000., 1000., 1000., 900., 800., 700.},
507 { 1000., 1000., 500., 500., 500., 900., 700., 700., 600., 500.},
508 { 1000., 1000., 1000., 500., 500., 500., 500., 500., 500., 500.}};
510 const char* species[3] = {"Pion","Kaon","Proton"};
512 for (Int_t iSpecies = 0; iSpecies < 3; iSpecies++) {
514 for (Int_t iPtBin = 0; iPtBin < 10; iPtBin++) {
517 binsHisto[2] = binsTPCZoom[iSpecies][iPtBin];
518 binsHisto[3] = binsTOFZoom[iSpecies][iPtBin];
519 minHisto[2] = minTPCZoom[iSpecies][iPtBin];
520 minHisto[3] = minTOFZoom[iSpecies][iPtBin];
521 maxHisto[2] = maxTPCZoom[iSpecies][iPtBin];
522 maxHisto[3] = maxTOFZoom[iSpecies][iPtBin];
524 binsHisto[2] = binsTPCnoZoom[iSpecies][iPtBin];
525 binsHisto[3] = binsTOFnoZoom[iSpecies][iPtBin];
526 minHisto[2] = minTPCnoZoom[iSpecies][iPtBin];
527 minHisto[3] = minTOFnoZoom[iSpecies][iPtBin];
528 maxHisto[2] = maxTPCnoZoom[iSpecies][iPtBin];
529 maxHisto[3] = maxTOFnoZoom[iSpecies][iPtBin];
532 // Di-Hadron Correlations
533 fDiHadronTPCTOF[iSpecies][iPtBin] = new THnSparseF(Form("fDiHadronTPCTOF_%s_%i",species[iSpecies],iPtBin),
534 Form("Di-Hadron Correlation (%s) %3.1f < p_{T} < %3.1f;#Delta#phi;#Delta#eta;dE/dx;t (ms);",species[iSpecies],iPtBin*0.5,(iPtBin+1)*0.5),
535 4,binsHisto,minHisto,maxHisto);
536 fHistoList->Add(fDiHadronTPCTOF[iSpecies][iPtBin]);
539 fMixedEventsTPCTOF[iSpecies][iPtBin] = new THnSparseF(Form("fMixedEventsTPCTOF_%s_%i",species[iSpecies],iPtBin),
540 Form("Mixed Events (%s) %3.1f < p_{T} < %3.1f;#Delta#phi;#Delta#eta;dE/dx;t (ms);",species[iSpecies],iPtBin*0.5,(iPtBin+1)*0.5),
541 4,binsHisto,minHisto,maxHisto);
542 //fHistoList->Add(fMixedEventsTPCTOF[iSpecies][iPtBin]);
544 // Inclusive spectra.
545 fInclusiveTPCTOF[iSpecies][iPtBin] = new TH3F(Form("fInclusiveTPCTOF_%s_%i",species[iSpecies],iPtBin),
546 Form("Inclusive Spectrum (%s) %3.1f < p_{T} < %3.1f;dE/dx;t (ms);#eta",species[iSpecies],iPtBin*0.5,(iPtBin+1)*0.5),
547 binsHisto[2],minHisto[2],maxHisto[2],binsHisto[3],minHisto[3],maxHisto[3],fNEtaBins,-fMaxEta,fMaxEta);
548 fHistoList->Add(fInclusiveTPCTOF[iSpecies][iPtBin]);
550 // Inclusive spectra with additional rapidity cut.
551 fInclusiveTPCTOFRap[iSpecies][iPtBin] = new TH3F(Form("fInclusiveTPCTOFRap_%s_%i",species[iSpecies],iPtBin),
552 Form("Inclusive Spectrum (%s) %3.1f < p_{T} < %3.1f |Y| < %3.1f;dE/dx;t (ms);Y",species[iSpecies],iPtBin*0.5,(iPtBin+1)*0.5,fMaxRap),
553 binsHisto[2],minHisto[2],maxHisto[2],binsHisto[3],minHisto[3],maxHisto[3],20,-fMaxRap,fMaxRap);
554 fHistoList->Add(fInclusiveTPCTOFRap[iSpecies][iPtBin]);
560 // Correlations without PID signals
561 fDiHadron = new TH3F("fDiHadron","Di-Hadron Correlations;#Delta#phi;#Delta#eta;p_{T_assoc}",binsHisto[0],minHisto[0],maxHisto[0],binsHisto[1],minHisto[1],maxHisto[1],10,0.,5.);
563 fHistoList->Add(fDiHadron);
565 fMixedEvents = new TH3F("fMixedEvents","Mixed Events;#Delta#phi;#Delta#eta;p_{T_assoc}",binsHisto[0],minHisto[0],maxHisto[0],binsHisto[1],minHisto[1],maxHisto[1],10,0.,5.);
566 fMixedEvents->Sumw2();
567 fHistoList->Add(fMixedEvents);
569 const char* MCSpeciesName[6] = {"piplus","pimin","Kplus","Kmin","p","pbar"};
570 const char* MCSpeciesTitle[6] = {"#pi^{+}","#pi^{-}","K^{+}","K^{-}","p","#bar{p}"};
571 //const char* Cuts[3] = {"nocut","DCAcut","PIDandDCAcut"};
573 // Efficiency Plots (Monte Carlo)
576 for (Int_t iSpecies=0; iSpecies<6; iSpecies++) {
578 // Without rapidity cut.
579 fPtEtaDistrDataPrim[iSpecies]=new TH2F(Form("fPtEtaDistrDataPrim_%s",MCSpeciesName[iSpecies]),
580 Form("p_{T}-#eta distribution Data Primaries (%s);p_{T};#eta;Count",MCSpeciesTitle[iSpecies]),
581 20,0.0,5.0,fNEtaBins,-fMaxEta,fMaxEta);
582 fPtEtaDistrDataPrim[iSpecies]->Sumw2();
583 fHistoList->Add(fPtEtaDistrDataPrim[iSpecies]);
585 fPtEtaDistrDataSec[iSpecies]=new TH2F(Form("fPtEtaDistrDataSec_%s",MCSpeciesName[iSpecies]),
586 Form("p_{T}-#eta distribution Data Secondaries (%s);p_{T};#eta;Count",MCSpeciesTitle[iSpecies]),
587 20,0.0,5.0,fNEtaBins,-fMaxEta,fMaxEta);
588 fPtEtaDistrDataSec[iSpecies]->Sumw2();
589 fHistoList->Add(fPtEtaDistrDataSec[iSpecies]);
591 fPtEtaDistrMCPrim[iSpecies]=new TH2F(Form("fPtEtaDistrMCPrim_%s",MCSpeciesName[iSpecies]),
592 Form("p_{T}-#eta distribution MC Primaries (%s);p_{T};#eta;Count",MCSpeciesTitle[iSpecies]),
593 20,0.0,5.0,fNEtaBins,-fMaxEta,fMaxEta);
594 fPtEtaDistrMCPrim[iSpecies]->Sumw2();
595 fHistoList->Add(fPtEtaDistrMCPrim[iSpecies]);
597 fPtEtaDistrMCSec[iSpecies]=new TH2F(Form("fPtEtaDistrMCSec_%s",MCSpeciesName[iSpecies]),
598 Form("p_{T}-#eta distribution MC Secondaries (%s);p_{T};#eta;Count",MCSpeciesTitle[iSpecies]),
599 20,0.0,5.0,fNEtaBins,-fMaxEta,fMaxEta);
600 fPtEtaDistrMCSec[iSpecies]->Sumw2();
601 fHistoList->Add(fPtEtaDistrMCSec[iSpecies]);
603 //fDiHadronMC[iSpecies]=new TH3F(Form("fDiHadronMC_%s",MCSpeciesName[iSpecies]),
604 // Form("Di-Hadron Correlations MC (%s);#Delta#phi;#Delta#eta;p_{T_assoc}",MCSpeciesTitle[iSpecies]),
605 // binsHisto[0],minHisto[0],maxHisto[0],binsHisto[1],minHisto[1],maxHisto[1],10,0.,5.);
606 //fHistoList->Add(fDiHadronMC[iSpecies]);
608 // With rapidity cut.
609 fPtRapDistrDataPrimRapCut[iSpecies]=new TH2F(Form("fPtRapDistrDataPrimRapCut_%s",MCSpeciesName[iSpecies]),
610 Form("p_{T}-Y distribution Data Primaries (%s) |Y| < %3.1f;p_{T};Y;Count",MCSpeciesTitle[iSpecies],fMaxRap),
611 20,0.0,5.0,20,-fMaxRap,fMaxRap);
612 fPtRapDistrDataPrimRapCut[iSpecies]->Sumw2();
613 fHistoList->Add(fPtRapDistrDataPrimRapCut[iSpecies]);
615 fPtRapDistrDataSecRapCut[iSpecies]=new TH2F(Form("fPtRapDistrDataSecRapCut_%s",MCSpeciesName[iSpecies]),
616 Form("p_{T}-Y distribution Data Secondaries (%s) |Y| < %3.1f;p_{T};Y;Count",MCSpeciesTitle[iSpecies],fMaxRap),
617 20,0.0,5.0,20,-fMaxRap,fMaxRap);
618 fPtRapDistrDataSecRapCut[iSpecies]->Sumw2();
619 fHistoList->Add(fPtRapDistrDataSecRapCut[iSpecies]);
621 fPtRapDistrMCPrimRapCut[iSpecies]=new TH2F(Form("fPtRapDistrMCPrimRapCut_%s",MCSpeciesName[iSpecies]),
622 Form("p_{T}-Y distribution MC Primaries (%s) |Y| < %3.1f;p_{T};Y;Count",MCSpeciesTitle[iSpecies],fMaxRap),
623 20,0.0,5.0,20,-fMaxRap,fMaxRap);
624 fPtRapDistrMCPrimRapCut[iSpecies]->Sumw2();
625 fHistoList->Add(fPtRapDistrMCPrimRapCut[iSpecies]);
627 fPtRapDistrMCSecRapCut[iSpecies]=new TH2F(Form("fPtRapDistrMCSecRapCut_%s",MCSpeciesName[iSpecies]),
628 Form("p_{T}-Y distribution MC Secondaries (%s) |Y| < %3.1f;p_{T};Y;Count",MCSpeciesTitle[iSpecies],fMaxRap),
629 20,0.0,5.0,20,-fMaxRap,fMaxRap);
630 fPtRapDistrMCSecRapCut[iSpecies]->Sumw2();
631 fHistoList->Add(fPtRapDistrMCSecRapCut[iSpecies]);
636 PostData(1, fHistoList);
640 //_____________________________________________________________________________
641 Int_t AliAnalysisTaskDiHadronPID::ClassifyTrack(AliAODTrack *track)
645 // This function both classifies tracks, and fills the track QA histograms.
647 // Classifies the track in:
652 // IDEA: later we can do this with filterbits.
654 // The following track cuts are applied for triggers:
656 // 1a) pT > 5.0 GeV/c, pT < fPtMax,
657 // 2) StandardTPCOnlyTrackCuts (filterbit 7 for AOD's),
659 // 4) ITS track cut, a track is only selected if it has at least one hit in the SPD,
660 // that is, in one of the first two layers of the ITS. (can be switched on and off
661 // using (Bool_t)fDoITSCut),
662 // 5) DCA track cut, of all tracks with at least one SPD hit, the DCA is constrained as
663 // a function of pT, in order to remove lots of the secondaries. (can be switched on and
664 // off by using (Bool_t)fDoDCACut),
666 // For associateds all the same track cuts are applied, except 1a is
667 // replaced by 2b. Moreover the following cuts are applied too:
669 // 1b) pT < 5.0 GeV/c,
672 // 8) no TPCTOF mismatch.
675 // Check if a track is supplied.
677 if (fVerbose>0) cout<<"AliAnalysisTaskDiHadronPID::SelectTrack -> ERROR: No track found."<<endl;
681 // Get basic track information.
682 Int_t classification=0;
683 Double_t pt = track->Pt();
684 Double_t eta = track->Eta();
685 Double_t phi = track->Phi();
687 // 1) pT cut: First separation between triggers and associateds.
688 if (pt<5.0) classification=1;
689 if ((pt>5.0)&&(pt<fMaxPt)) classification = 2;
690 if (!classification) return 0;
692 // 2) StandardTPCOnlyTrackCuts.
693 if (!(track->TestFilterMask(1<<7))) {
694 //if (fVerbose>3) cout<<"Track Ignored: Did Not pass filterbit."<<endl;
700 cout<<"pt: "<<pt<<" eta: "<<eta<<" phi: "<<phi<<endl;
703 fTrackCutsCount->Fill(fTrackCutLabelNumbers[0]-.5);
704 fTrackCutsPt->Fill(fTrackCutLabelNumbers[0]-.5,pt);
705 fTrackCutsEta->Fill(fTrackCutLabelNumbers[0]-.5,eta);
706 fTrackCutsPhi->Fill(fTrackCutLabelNumbers[0]-.5,phi);
709 if (TMath::Abs(eta)>fMaxEta) {
710 if (fVerbose>3) cout<<"Track Ignored: Eta too large."<<endl;
714 fTrackCutsCount->Fill(fTrackCutLabelNumbers[1]-.5);
715 fTrackCutsPt->Fill(fTrackCutLabelNumbers[1]-.5,pt);
716 fTrackCutsEta->Fill(fTrackCutLabelNumbers[1]-.5,eta);
717 fTrackCutsPhi->Fill(fTrackCutLabelNumbers[1]-.5,phi);
719 // Obtaining ITS information.
720 AliAODTrack* globaltrack = GetGlobalTrack(track);
725 Bool_t ITSLayerHit[6];
726 for (Int_t iITSLayer=0; iITSLayer<6; iITSLayer++) {
727 ITSLayerHit[iITSLayer] = globaltrack->HasPointOnITSLayer(iITSLayer);
729 Int_t SPDHits=ITSLayerHit[0]+ITSLayerHit[1];
731 if (fVerbose>3) cout<<"SPD hits: "<<SPDHits<<endl;
733 // Fill the ITS hist.
734 fITSHits->Fill(SPDHits+0.5);
739 if (fVerbose>3) cout<<"Track Ignored: Not enough SPD hits."<<endl;
742 fTrackCutsCount->Fill(fTrackCutLabelNumbers[2]-.5);
743 fTrackCutsPt->Fill(fTrackCutLabelNumbers[2]-.5,pt);
744 fTrackCutsEta->Fill(fTrackCutLabelNumbers[2]-.5,eta);
745 fTrackCutsPhi->Fill(fTrackCutLabelNumbers[2]-.5,phi);
748 // Propagate the global track to the DCA.
749 Double_t PosAtDCA[2] = {-999,-999};
750 Double_t covar[3] = {-999,-999,-999};
751 globaltrack->PropagateToDCA(fAODVertex,fAODEvent->GetMagneticField(),100.,PosAtDCA,covar);
753 // Fill the DCA hist (before cut)
754 fDCA->Fill(PosAtDCA[0],PosAtDCA[1]);
755 fDCAZoomed->Fill(PosAtDCA[0],PosAtDCA[1]);
756 fDCAZoomedTwice->Fill(PosAtDCA[0],PosAtDCA[1]);
758 // 5) DCA cut (See R_AA paper).
759 Double_t DCAcutvalue[2];
760 DCAcutvalue[0] = 0.018 + 0.035*TMath::Power(pt,-1.01);
763 if (SPDHits&&((TMath::Abs(PosAtDCA[0])>DCAcutvalue[0])||(TMath::Abs(PosAtDCA[1])>DCAcutvalue[1]))) {
764 if (fVerbose>3) cout<<"Track Ignored: Enough SPD hits, but out of DCA range."<<endl;
767 fTrackCutsCount->Fill(fTrackCutLabelNumbers[3]-.5);
768 fTrackCutsPt->Fill(fTrackCutLabelNumbers[3]-.5,pt);
769 fTrackCutsEta->Fill(fTrackCutLabelNumbers[3]-.5,eta);
770 fTrackCutsPhi->Fill(fTrackCutLabelNumbers[3]-.5,phi);
772 // Fill the DCA hist (after cut)
773 fDCACut->Fill(PosAtDCA[0],PosAtDCA[1]);
774 fDCAZoomedCut->Fill(PosAtDCA[0],PosAtDCA[1]);
775 fDCAZoomedTwiceCut->Fill(PosAtDCA[0],PosAtDCA[1]);
778 // Now all the common cuts have been performed. Tracks identified as a trigger will
779 // be returned. Note that they will not appear in the histograms after track cut 5.
780 if (classification==2) return 2;
782 // Now we're left with only tracks with pT < 5.0 GeV/c.
783 fTrackCutsCount->Fill(fTrackCutLabelNumbers[4]-.5);
784 fTrackCutsPt->Fill(fTrackCutLabelNumbers[4]-.5,pt);
785 fTrackCutsEta->Fill(fTrackCutLabelNumbers[4]-.5,eta);
786 fTrackCutsPhi->Fill(fTrackCutLabelNumbers[4]-.5,phi);
788 // Obtain the status of the track.
789 ULong_t status = globaltrack->GetStatus();
792 if (!((status&AliAODTrack::kTPCpid)==AliAODTrack::kTPCpid)) {
793 if (fVerbose>3) cout<<"Track Ignored: No TPC pid."<<endl;
797 fTrackCutsCount->Fill(fTrackCutLabelNumbers[5]-.5);
798 fTrackCutsPt->Fill(fTrackCutLabelNumbers[5]-.5,pt);
799 fTrackCutsEta->Fill(fTrackCutLabelNumbers[5]-.5,eta);
800 fTrackCutsPhi->Fill(fTrackCutLabelNumbers[5]-.5,phi);
803 if (!((status&AliAODTrack::kTOFpid)==AliAODTrack::kTOFpid)) {
804 if (fVerbose>3) cout<<"Track Ignored: No TOF pid."<<endl;
808 fTrackCutsCount->Fill(fTrackCutLabelNumbers[6]-.5);
809 fTrackCutsPt->Fill(fTrackCutLabelNumbers[6]-.5,pt);
810 fTrackCutsEta->Fill(fTrackCutLabelNumbers[6]-.5,eta);
811 fTrackCutsPhi->Fill(fTrackCutLabelNumbers[6]-.5,phi);
813 // 8) TPC, TOF mismatch.
814 if (fDemandNoMismatch) {
815 if ((status&AliAODTrack::kTOFmismatch)==AliAODTrack::kTOFmismatch) {
816 if (fVerbose>3) cout<<"Track Ignored: TOF mismatch found."<<endl;
819 fTrackCutsCount->Fill(fTrackCutLabelNumbers[7]-.5);
820 fTrackCutsPt->Fill(fTrackCutLabelNumbers[7]-.5,pt);
821 fTrackCutsEta->Fill(fTrackCutLabelNumbers[7]-.5,eta);
822 fTrackCutsPhi->Fill(fTrackCutLabelNumbers[7]-.5,phi);
825 // All tracks which made it up to here are classified as associateds.
827 // Return associated.
832 //____________________________________________________________________________
833 Bool_t AliAnalysisTaskDiHadronPID::SelectEvent(AliAODVertex* vertex)
842 vertex->GetXYZ(primVtx);
843 if (TMath::Sqrt(primVtx[0]*primVtx[0] + primVtx[1]*primVtx[1])>1. || TMath::Abs(primVtx[2])>10.) {
844 if (fVerbose>2) cout << "AliAnalysisTaskDiHadronPID::SelectEvent -> Vertex Out of Range." << endl;
845 if (fVerbose>2) cout << "AliAnalysisTaskDiHadronPID::SelectEvent -> Event not selected." << endl;
848 if (fVerbose>2) cout << "AliAnalysisTaskDiHadronPID::SelectEvent -> Vertex is OK." << endl;
850 // We also wish to make centrality cut, but only if run on Pb+Pb.
851 if (fBeamType=="PbPb") {
852 Double_t cent = fAODHeader->GetCentrality();
853 if (cent>fCentralityCutMin||cent<fCentralityCutMax) {
854 if (fVerbose>2) cout<<"AliAnalysisTaskDiHadronPID::SelectEvent -> Event did not pass centaltity cut."<<endl;
859 if (fVerbose>2) cout << "AliAnalysisTaskDiHadronPID::SelectEvent -> Event selected." << endl;
864 //_____________________________________________________________________________
865 void AliAnalysisTaskDiHadronPID::FillGlobalTracksArray() {
867 // Initialize the mapping for corresponding PID tracks. (see
868 // GetGlobalTrack(AliAODTrack* track)).
872 if (fVerbose>0) cout << "AliAnalysisTaskDiHadronPID::FillGlobalTracksArray -> ERROR: fAODEvent not set." << endl;
876 fGlobalTracks = new TObjArray();
877 AliAODTrack* track = 0x0;
879 for (Int_t iTrack = 0; iTrack < fAODEvent->GetNumberOfTracks(); iTrack++) {
881 track = fAODEvent->GetTrack(iTrack);
883 // I.e., if it does NOT pass the filtermask.
884 if (!(track->TestFilterMask(1<<7))) {
885 if (track->GetID()>-1) fGlobalTracks->AddAtAndExpand(track,track->GetID());
886 //if (track->GetID()<1) cout<<"Track ID: "<<track->GetID()<<" Partner ID: "<<(-track->GetID()-1)<<endl;
893 //_____________________________________________________________________________
894 AliAODTrack* AliAnalysisTaskDiHadronPID::GetGlobalTrack(AliAODTrack* track) {
897 // Returns the "parner track" of track, which contains the pid information.
900 AliAODTrack* partner = 0x0;
902 partner = (AliAODTrack*)(fGlobalTracks->At(-track->GetID()-1));
904 if (!partner&&(fVerbose>3)) cout<<"AliAnalysisTaskDiHadronPID::GetGlobalTrack -> No Global Track Found!"<<endl;
910 //_____________________________________________________________________________
911 Double_t AliAnalysisTaskDiHadronPID::PhiRange(Double_t DPhi)
915 // Puts the argument in the range [-pi/2,3 pi/2].
918 if (DPhi < -TMath::Pi()/2) DPhi += 2*TMath::Pi();
919 if (DPhi > 3*TMath::Pi()/2) DPhi -= 2*TMath::Pi();
925 //_____________________________________________________________________________
926 Int_t AliAnalysisTaskDiHadronPID::ConvertPdgCode(Int_t pdgcode) {
929 // Converts the pdg code to the bin number (0-5)
932 if (pdgcode==211) return 0; // Pi +
933 if (pdgcode==-211) return 1; // Pi -
934 if (pdgcode==321) return 2; // K +
935 if (pdgcode==-321) return 3; // K -
936 if (pdgcode==2212) return 4; // p +
937 if (pdgcode==-2212) return 5; // p -
939 return -999; // Any other particle.
943 //_____________________________________________________________________________
944 void AliAnalysisTaskDiHadronPID::UserExec(Option_t *)
952 fAODEvent = dynamic_cast<AliAODEvent*>(InputEvent());
954 if (fVerbose>0) cout << "AliAnalysisTaskDiHadronPID::UserExec -> ERROR: No AliAODEvent pointer could be created." << endl;
958 // Get the event header.
959 fAODHeader = fAODEvent->GetHeader();
961 if (fVerbose>0) cout << "AliAnalysisTaskDiHadronPID::UserExec -> ERROR: No AliAODHeader pointer could be created."<<endl;
965 // Get the event vertex.
966 fAODVertex = fAODEvent->GetPrimaryVertex();
968 if (fVerbose>0) cout << "AliAnalysisTaskDiHadronPID::UserExec -> ERROR: No AliAODVertex pointer could be created." << endl;
972 // Get the MC tracks if ran on MC.
974 fMCTracks = dynamic_cast<TClonesArray*>(fAODEvent->FindListObject(AliAODMCParticle::StdBranchName()));
977 cout<<"AliAnalysisTaskDiHadronPID::UserExec -> ERROR: No MC particles found."<<endl;
983 AliTPCPIDResponse& TPCPIDResponse = fPIDResponse->GetTPCResponse();
985 // See if the event passes the event selection.
986 if (!SelectEvent(fAODVertex)) return;
988 // Display basic event information.
989 if ((fVerbose>2)) cout << endl;
990 if ((fVerbose>2)&&(fBeamType=="PbPb")) cout << "Event centrality: " << fAODHeader->GetCentrality() << endl;
991 if ((fVerbose>2)) cout << "Event Vertex Z: " << fAODVertex->GetZ() << endl;
992 if ((fVerbose>2)) cout << "Event tracks in AOD: " << fAODEvent->GetNumberOfTracks() << endl;
993 if ((fVerbose>2)) cout << endl;
995 // Filling Event QA plots.
996 if (fBeamType=="PbPb") fCentrality->Fill(fAODHeader->GetCentrality());
997 fVertexZ->Fill(fAODVertex->GetZ());
999 // Fill the TObjArray which holds Global tracks.
1000 FillGlobalTracksArray();
1002 // Create object arrays for triggers and associateds.
1003 TObjArray *triggers = new TObjArray();
1004 TObjArray *associateds = new TObjArray();
1006 // Loop over MC tracks to fill the spectra if ran on MC.
1008 for (Int_t iTrack=0; iTrack<fMCTracks->GetEntriesFast(); iTrack++) {
1010 AliAODMCParticle* mcparticle = (AliAODMCParticle*)fMCTracks->At(iTrack);
1011 Double_t mcPt = mcparticle->Pt();
1012 Double_t mcEta = mcparticle->Eta();
1013 //Double_t mcPhi = mcparticle->Phi();
1014 Double_t mcY = mcparticle->Y();
1015 Int_t mcPDG = mcparticle->PdgCode();
1016 Int_t mcSpeciesBin = ConvertPdgCode(mcPDG);
1017 if (mcSpeciesBin==-999) continue;
1019 if (mcparticle->IsPhysicalPrimary()) {
1020 fPtEtaDistrMCPrim[mcSpeciesBin]->Fill(mcPt,mcEta);
1021 if (TMath::Abs(mcY)<fMaxRap) fPtRapDistrMCPrimRapCut[mcSpeciesBin]->Fill(mcPt,mcY);
1023 fPtEtaDistrMCSec[mcSpeciesBin]->Fill(mcPt,mcEta);
1024 if (TMath::Abs(mcY)<fMaxRap) fPtRapDistrMCSecRapCut[mcSpeciesBin]->Fill(mcPt,mcY);
1029 // In this loop the triggers and associateds will be identified, track QA and PID QA histograms will be filled.
1030 for (Int_t iTrack = 0; iTrack < fAODEvent->GetNumberOfTracks(); iTrack++) {
1032 // Obtain a pointer to the track.
1033 fAODTrack = fAODEvent->GetTrack(iTrack);
1034 if (!fAODTrack&&(fVerbose>0)) {
1035 cout << "AliAnalysisTaskDiHadronPID::UserExec -> ERROR: Track object not found." << endl;
1039 //if (TMath::Abs(fAODTrack->Eta())>0.8&&fAODTrack->Pt()>0.5&&TMath::Abs(fAODTrack->Y(AliAODTrack::kProton))<0.5) cout<<"Eta: "<<fAODTrack->Eta()<<" Pt: "<<fAODTrack->Pt()<<" Ypion: "<<fAODTrack->Y(AliAODTrack::kPion)<<" Ykaon: "<<fAODTrack->Y(AliAODTrack::kKaon)<<" Yproton: "<<fAODTrack->Y(AliAODTrack::kProton)<<endl;
1041 // Find the track classification.
1042 Int_t tracktype = ClassifyTrack(fAODTrack);
1049 if (fVerbose>3) cout<<"Track added to associated buffer."<<endl;
1050 associateds->AddLast(fAODTrack);
1051 fEtaSpectrumAssoc->Fill(fAODTrack->Eta(),fAODTrack->Pt());
1052 fPhiSpectrumAssoc->Fill(fAODTrack->Phi(),fAODTrack->Pt());
1056 if (fVerbose>3) cout<<"Track added to trigger buffer."<<endl;
1057 triggers->AddLast(fAODTrack);
1058 fEtaSpectrumTrig->Fill(fAODTrack->Eta());
1064 // Fill the PID QA histograms for the associateds
1065 AliAODTrack* globaltrack = GetGlobalTrack(fAODTrack);
1066 Double_t mom, nSigma;
1068 Double_t pt = fAODTrack->Pt();
1069 Double_t eta = fAODTrack->Eta();
1070 const Int_t ptbin = (Int_t)(2*pt);
1072 //cout<<pt<<" "<<ptbin<<endl;
1074 mom = globaltrack->GetTPCmomentum();
1075 nSigma = fPIDResponse->NumberOfSigmasTPC(globaltrack,AliPID::kProton);
1076 fTPCnSigmaProton->Fill(mom,nSigma);
1077 nSigma = fPIDResponse->NumberOfSigmasTPC(globaltrack,AliPID::kPion);
1078 fTPCnSigmaPion->Fill(mom,nSigma);
1079 nSigma = fPIDResponse->NumberOfSigmasTPC(globaltrack,AliPID::kKaon);
1080 fTPCnSigmaKaon->Fill(mom,nSigma);
1082 fTPCSignal->Fill(eta,pt,globaltrack->GetTPCsignal());
1084 mom =globaltrack->P();
1085 nSigma = fPIDResponse->NumberOfSigmasTOF(globaltrack,AliPID::kProton);
1086 fTOFnSigmaProton->Fill(mom,nSigma);
1087 nSigma = fPIDResponse->NumberOfSigmasTOF(globaltrack,AliPID::kPion);
1088 fTOFnSigmaPion->Fill(mom,nSigma);
1089 nSigma = fPIDResponse->NumberOfSigmasTOF(globaltrack,AliPID::kKaon);
1090 fTOFnSigmaKaon->Fill(mom,nSigma);
1092 fTOFSignal->Fill(eta,pt,globaltrack->GetTOFsignal());
1094 // Fill the inclusives.
1095 Double_t TPCmom = globaltrack->GetTPCmomentum();
1096 Double_t TPCsignal = globaltrack->GetTPCsignal();
1097 Double_t expectedTPCsignalPion = TPCPIDResponse.GetExpectedSignal(TPCmom,AliPID::kPion);
1098 Double_t expectedTPCsignalKaon = TPCPIDResponse.GetExpectedSignal(TPCmom,AliPID::kKaon);
1099 Double_t expectedTPCsignalProton = TPCPIDResponse.GetExpectedSignal(TPCmom,AliPID::kProton);
1101 Double_t TOFsignal = globaltrack->GetTOFsignal();
1102 Double_t times[AliPID::kSPECIES];
1103 globaltrack->GetIntegratedTimes(times);
1104 Double_t expectedTOFsignalPion = times[AliPID::kPion];
1105 Double_t expectedTOFsignalKaon = times[AliPID::kKaon];
1106 Double_t expectedTOFsignalProton = times[AliPID::kProton];
1108 Double_t TPCsignalSubtracted = TPCsignal - expectedTPCsignalPion;
1109 Double_t TOFsignalSubtracted = TOFsignal - expectedTOFsignalPion;
1110 fInclusiveTPCTOF[0][ptbin]->Fill(TPCsignalSubtracted,TOFsignalSubtracted,eta);
1111 if (fAODTrack->Y(AliAODTrack::kPion)<fMaxRap) fInclusiveTPCTOFRap[0][ptbin]->Fill(TPCsignalSubtracted,TOFsignalSubtracted,fAODTrack->Y(AliAODTrack::kPion));
1113 TPCsignalSubtracted = TPCsignal - expectedTPCsignalKaon;
1114 TOFsignalSubtracted = TOFsignal - expectedTOFsignalKaon;
1115 fInclusiveTPCTOF[1][ptbin]->Fill(TPCsignalSubtracted,TOFsignalSubtracted,eta);
1116 if (fAODTrack->Y(AliAODTrack::kKaon)<fMaxRap) fInclusiveTPCTOFRap[1][ptbin]->Fill(TPCsignalSubtracted,TOFsignalSubtracted,fAODTrack->Y(AliAODTrack::kKaon));
1118 TPCsignalSubtracted = TPCsignal - expectedTPCsignalProton;
1119 TOFsignalSubtracted = TOFsignal - expectedTOFsignalProton;
1120 fInclusiveTPCTOF[2][ptbin]->Fill(TPCsignalSubtracted,TOFsignalSubtracted,eta);
1121 if (fAODTrack->Y(AliAODTrack::kProton)<fMaxRap) fInclusiveTPCTOFRap[2][ptbin]->Fill(TPCsignalSubtracted,TOFsignalSubtracted,fAODTrack->Y(AliAODTrack::kProton));
1123 // Fill the MC reconstructed spectra histograms.
1126 Int_t aodlabel = TMath::Abs(fAODTrack->GetLabel());
1127 AliAODMCParticle* mcparticle = (AliAODMCParticle*)fMCTracks->At(aodlabel);
1128 Int_t mcPDG = mcparticle->PdgCode();
1129 Int_t mcSpeciesBin = ConvertPdgCode(mcPDG);
1131 // Only fill hisotos for pions, kaons and protons.
1132 if (mcSpeciesBin!=-999) {
1133 Double_t dataPt = fAODTrack->Pt();
1134 Double_t dataY=-999;
1135 if (mcSpeciesBin==0||mcSpeciesBin==1) {dataY = fAODTrack->Y(AliAODTrack::kPion);}
1136 if (mcSpeciesBin==2||mcSpeciesBin==3) {dataY = fAODTrack->Y(AliAODTrack::kKaon);}
1137 if (mcSpeciesBin==4||mcSpeciesBin==5) {dataY = fAODTrack->Y(AliAODTrack::kProton);}
1139 //if (TMath::Abs(fAODTrack->Eta())>0.8) cout<<"Eta: "<<fAODTrack->Eta()<<" Ypion: "<<fAODTrack->Y(AliAODTrack::kPion)<<" Ykaon: "<<fAODTrack->Y(AliAODTrack::kKaon)<<" Yproton: "<<fAODTrack->Y(AliAODTrack::kProton)<<endl;
1141 if (mcparticle->IsPhysicalPrimary()) {
1142 fPtEtaDistrDataPrim[mcSpeciesBin]->Fill(dataPt,eta);
1143 if (TMath::Abs(dataY)<fMaxRap) fPtRapDistrDataPrimRapCut[mcSpeciesBin]->Fill(dataPt,dataY);
1145 fPtEtaDistrDataSec[mcSpeciesBin]->Fill(dataPt,eta);
1146 if (TMath::Abs(dataY)<fMaxRap) fPtRapDistrDataSecRapCut[mcSpeciesBin]->Fill(dataPt,dataY);
1156 // In This Loop the di-hadron correlation will be made.
1157 Double_t histoFill[4]; // {Dphi, Deta, TPC signal, TOF signal}
1158 AliAODTrack* currentTrigger = 0x0;
1159 AliAODTrack* currentAssociated = 0x0;
1160 AliAODTrack* currentAssociatedGlobal = 0x0;
1162 for (Int_t iTrig = 0; iTrig < triggers->GetEntriesFast(); iTrig++){
1164 currentTrigger = (AliAODTrack*)(triggers->At(iTrig));
1166 for (Int_t iAssoc = 0; iAssoc < associateds->GetEntriesFast(); iAssoc++) {
1168 currentAssociated = (AliAODTrack*)(associateds->At(iAssoc));
1169 currentAssociatedGlobal = GetGlobalTrack(currentAssociated);
1171 Double_t pt = currentAssociated->Pt();
1172 histoFill[0] = PhiRange(currentTrigger->Phi() - currentAssociated->Phi());
1173 histoFill[1] = currentTrigger->Eta() - currentAssociated->Eta();
1175 // Is there a caveat here when Pt = 5.00000000?
1176 const Int_t ptbin = (Int_t)(2*pt);
1177 // cout<<"pt: "<<pt<<" ptbin: "<<ptbin<<endl; // Works OK!
1179 if (currentAssociatedGlobal) {
1181 // Get TPC (expected) signals.
1182 Double_t TPCmom = currentAssociatedGlobal->GetTPCmomentum();
1183 Double_t TPCsignal = currentAssociatedGlobal->GetTPCsignal();
1184 Double_t expectedTPCsignalPion = TPCPIDResponse.GetExpectedSignal(TPCmom,AliPID::kPion);
1185 Double_t expectedTPCsignalKaon = TPCPIDResponse.GetExpectedSignal(TPCmom,AliPID::kKaon);
1186 Double_t expectedTPCsignalProton = TPCPIDResponse.GetExpectedSignal(TPCmom,AliPID::kProton);
1188 // Get TOF (expected) signals.
1189 Double_t TOFsignal = currentAssociatedGlobal->GetTOFsignal();
1190 Double_t times[AliPID::kSPECIES];
1191 currentAssociatedGlobal->GetIntegratedTimes(times);
1192 Double_t expectedTOFsignalPion = times[AliPID::kPion];
1193 Double_t expectedTOFsignalKaon = times[AliPID::kKaon];
1194 Double_t expectedTOFsignalProton = times[AliPID::kProton];
1196 // Fill the histograms.
1197 histoFill[2] = TPCsignal - expectedTPCsignalPion;
1198 histoFill[3] = TOFsignal - expectedTOFsignalPion;
1199 fDiHadronTPCTOF[0][ptbin]->Fill(histoFill);
1201 histoFill[2] = TPCsignal - expectedTPCsignalKaon;
1202 histoFill[3] = TOFsignal - expectedTOFsignalKaon;
1203 fDiHadronTPCTOF[1][ptbin]->Fill(histoFill);
1205 histoFill[2] = TPCsignal - expectedTPCsignalProton;
1206 histoFill[3] = TOFsignal - expectedTOFsignalProton;
1207 fDiHadronTPCTOF[2][ptbin]->Fill(histoFill);
1209 fDiHadron->Fill(histoFill[0],histoFill[1],pt);
1215 // In this loop we calculate the mixed events.
1216 if (fCalculateMixedEvents) {
1218 // Loop over the trigger buffer.
1219 if (fVerbose>3) cout << "AliAnalysisTaskDiHadronPID::UserExec -> Mixing the events with "<<fTrigBufferSize<<" triggers from the buffer." <<endl;
1220 if (fVerbose>3) cout << "AliAnalysisTaskDiHadronPID::UserExec -> Buffer size: "<<fTrigBufferIndex<<endl;
1222 for (Int_t iTrig=0;iTrig<fTrigBufferSize;iTrig++) {
1224 // Check if the trigger and the associated have a reconstructed
1225 // vertext no further than 2cm apart.
1227 // fTrigBuffer[i][0] = z
1228 // fTrigBuffer[i][1] = phi
1229 // fTrigBuffer[i][2] = eta
1230 // fTrigBuffer[i][3] = p_t
1232 if (TMath::Abs(fTrigBuffer[iTrig][0]-fAODVertex->GetZ())<fVertexZMixedEvents) {
1234 if (fVerbose>3) cout<<"AliAnalysisTaskDiHadronPID::UserExec -> Mixing with trigger Z: "<<fTrigBuffer[iTrig][0]<<", Pt: "<<fTrigBuffer[iTrig][3]<<endl;
1236 for (Int_t iAssoc = 0; iAssoc < associateds->GetEntriesFast(); iAssoc++) {
1238 currentAssociated = (AliAODTrack*)(associateds->At(iAssoc));
1239 currentAssociatedGlobal = GetGlobalTrack(currentAssociated);
1241 if (currentAssociatedGlobal) {
1243 Double_t pt = currentAssociated->Pt();
1244 histoFill[0] = PhiRange(fTrigBuffer[iTrig][1] - currentAssociated->Phi());
1245 histoFill[1] = fTrigBuffer[iTrig][2] - currentAssociated->Eta();
1247 //const Int_t ptbin = (Int_t)(2*pt);
1249 // Get TPC (expected) signals.
1250 Double_t TPCmom = currentAssociatedGlobal->GetTPCmomentum();
1251 Double_t TPCsignal = currentAssociatedGlobal->GetTPCsignal();
1252 Double_t expectedTPCsignalPion = TPCPIDResponse.GetExpectedSignal(TPCmom,AliPID::kPion);
1253 Double_t expectedTPCsignalKaon = TPCPIDResponse.GetExpectedSignal(TPCmom,AliPID::kKaon);
1254 Double_t expectedTPCsignalProton = TPCPIDResponse.GetExpectedSignal(TPCmom,AliPID::kProton);
1256 // Get TOF (expected) signals.
1257 Double_t TOFsignal = currentAssociatedGlobal->GetTOFsignal();
1258 Double_t times[AliPID::kSPECIES];
1259 currentAssociatedGlobal->GetIntegratedTimes(times);
1260 Double_t expectedTOFsignalPion = times[AliPID::kPion];
1261 Double_t expectedTOFsignalKaon = times[AliPID::kKaon];
1262 Double_t expectedTOFsignalProton = times[AliPID::kProton];
1264 // Fill the histograms.
1265 histoFill[2] = TPCsignal - expectedTPCsignalPion;
1266 histoFill[3] = TOFsignal - expectedTOFsignalPion;
1267 //if (ptbin==1) fMixedEventsTPCTOF[0][ptbin]->Fill(histoFill);
1269 histoFill[2] = TPCsignal - expectedTPCsignalKaon;
1270 histoFill[3] = TOFsignal - expectedTOFsignalKaon;
1271 //if (ptbin==1) fMixedEventsTPCTOF[1][ptbin]->Fill(histoFill);
1273 histoFill[2] = TPCsignal - expectedTPCsignalProton;
1274 histoFill[3] = TOFsignal - expectedTOFsignalProton;
1275 //if (ptbin==1) fMixedEventsTPCTOF[2][ptbin]->Fill(histoFill);
1277 fMixedEvents->Fill(histoFill[0],histoFill[1],pt);
1280 Double_t PionFillTPC = TPCsignal - expectedTPCsignalPion;
1281 Double_t PionFillTOF = TOFsignal - expectedTOFsignalPion;
1283 Int_t PionMinTPC = (fDiHadronTPCTOF[0][ptbin]->GetAxis(2))->GetXmin();
1284 Int_t PionMaxTPC = (fDiHadronTPCTOF[0][ptbin]->GetAxis(2))->GetXmax();
1285 Int_t PionMinTOF = (fDiHadronTPCTOF[0][ptbin]->GetAxis(3))->GetXmin();
1286 Int_t PionMaxTOF = (fDiHadronTPCTOF[0][ptbin]->GetAxis(3))->GetXmax();
1288 //cout<<PionMinTPC<<"<"<<PionFillTPC<<"<"<<PionMaxTPC<<"? "<<PionMinTOF<<"<"<<PionFillTOF<<"<"<<PionMaxTOF<<"?"<<endl;
1289 if (PionFillTPC<PionMaxTPC&&PionFillTPC>PionMinTPC&&PionFillTOF<PionMaxTOF&&PionFillTOF>PionMinTOF) {
1290 fMixedEventsTPCTOFCut[0]->Fill(DPhi,DEta,pt);
1291 //cout<<"Yes! Histogram will be filled."<<endl;
1294 Double_t KaonFillTPC = TPCsignal - expectedTPCsignalKaon;
1295 Double_t KaonFillTOF = TOFsignal - expectedTOFsignalKaon;
1297 Int_t KaonMinTPC = (fDiHadronTPCTOF[1][ptbin]->GetAxis(2))->GetXmin();
1298 Int_t KaonMaxTPC = (fDiHadronTPCTOF[1][ptbin]->GetAxis(2))->GetXmax();
1299 Int_t KaonMinTOF = (fDiHadronTPCTOF[1][ptbin]->GetAxis(3))->GetXmin();
1300 Int_t KaonMaxTOF = (fDiHadronTPCTOF[1][ptbin]->GetAxis(3))->GetXmax();
1301 if (KaonFillTPC<KaonMaxTPC&&KaonFillTPC>KaonMinTPC&&KaonFillTOF<KaonMaxTOF&&KaonFillTOF>KaonMinTOF) {
1302 fMixedEventsTPCTOFCut[1]->Fill(DPhi,DEta,pt);
1305 Double_t ProtonFillTPC = TPCsignal - expectedTPCsignalProton;
1306 Double_t ProtonFillTOF = TOFsignal - expectedTOFsignalProton;
1307 Int_t ProtonMinTPC = (fDiHadronTPCTOF[2][ptbin]->GetAxis(2))->GetXmin();
1308 Int_t ProtonMaxTPC = (fDiHadronTPCTOF[2][ptbin]->GetAxis(2))->GetXmax();
1309 Int_t ProtonMinTOF = (fDiHadronTPCTOF[2][ptbin]->GetAxis(3))->GetXmin();
1310 Int_t ProtonMaxTOF = (fDiHadronTPCTOF[2][ptbin]->GetAxis(3))->GetXmax();
1311 if (ProtonFillTPC<ProtonMaxTPC&&ProtonFillTPC>ProtonMinTPC&&ProtonFillTOF<ProtonMaxTOF&&ProtonFillTOF>ProtonMinTOF) {
1312 fMixedEventsTPCTOFCut[2]->Fill(DPhi,DEta,pt);
1321 // Copy the triggers from the current event into the buffer.
1322 if (fAODVertex->GetZ()<10.) {
1324 if (fVerbose>3) cout<<"AliAnalysisTaskDiHadronPID::UserExec -> Copying "<<triggers->GetEntriesFast()<<" triggers with vertex z = "<<fAODVertex->GetZ()<<" to the buffer."<<endl;
1326 for (Int_t iTrig = 0; iTrig<triggers->GetEntriesFast(); iTrig++) {
1328 currentTrigger = (AliAODTrack*)(triggers->At(iTrig));
1329 if (fVerbose>3) cout<<"AliAnalysisTaskDiHadronPID::UserExec -> Trigger pt = "<<currentTrigger->Pt()<<endl;
1331 fTrigBuffer[fTrigBufferIndex][0] = fAODVertex->GetZ();
1332 fTrigBuffer[fTrigBufferIndex][1] = currentTrigger->Phi();
1333 fTrigBuffer[fTrigBufferIndex][2] = currentTrigger->Eta();
1334 fTrigBuffer[fTrigBufferIndex][3] = currentTrigger->Pt();
1336 if (fTrigBufferSize<fTrigBufferMaxSize) {fTrigBufferSize++;} // 250 triggers should be enough to get 10 times more data in mixed events.
1337 if (fTrigBufferIndex==fTrigBufferMaxSize) {fTrigBufferIndex=0;}
1342 if (fPrintBufferSize) cout<<"AliAnalysisTaskDiHadronPID::UserExec -> Trigger buffer index: "<<fTrigBufferIndex<<", and size: "<<fTrigBufferSize<<endl;
1347 PostData(1,fHistoList);
1351 //_____________________________________________________________________________
1352 void AliAnalysisTaskDiHadronPID::Terminate(Option_t *)