]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGCF/Correlations/DPhi/AliAnalysisTaskDiHadronPID.cxx
Coverity 19490
[u/mrichter/AliRoot.git] / PWGCF / Correlations / DPhi / AliAnalysisTaskDiHadronPID.cxx
CommitLineData
75bac3c4 1// ----------------------------------------------------------------------------
2// This class makes di-hadron correlations, with TOF and TPC signals for
3// the associated particles. It runs on AOD049 and AOD73 productions.
4// ----------------------------------------------------------------------------
5// Author: Misha Veldhoen (misha.veldhoen@cern.ch)
6// Start: July 21st, 2011.
7// Last edit: Feb. 17th 2012. (v08)
8// ----------------------------------------------------------------------------
9//
10
11#include <iostream>
12#include "TChain.h"
13#include "TTree.h"
14#include "TH1F.h"
15#include "TH2F.h"
16#include "TH3F.h"
17#include "TCanvas.h"
18#include "TFile.h"
19
20#include "AliAODTrack.h"
21#include "AliAODEvent.h"
22#include "AliAODInputHandler.h"
23#include "AliAODVertex.h"
24//#include "AliAODPid.h"
25
26#include "AliAnalysisManager.h"
27#include "AliInputEventHandler.h"
28#include "AliPIDResponse.h"
29#include "AliTPCPIDResponse.h"
30//#include "AliTOFPIDResponse.h"
31
32#include "AliAnalysisTaskDiHadronPID.h"
33
34using namespace std;
35
36ClassImp(AliAnalysisTaskDiHadronPID);
37
38//_____________________________________________________________________________
39AliAnalysisTaskDiHadronPID::AliAnalysisTaskDiHadronPID():
40 AliAnalysisTaskSE(),
41 fPIDResponse(0x0),
42 fAODEvent(0x0),
43 fAODHeader(0x0),
44 fAODVertex(0x0),
45 fAODTrack(0x0),
46 fPIDPartners(0x0),
47 fCentrality(0x0),
48 fVertexZ(0x0),
49 fTrackCuts(0x0),
50 fPtSpectrum(0x0),
51 fAssociatedDistribution(0x0),
52 fTPCnSigmaProton(0x0),
53 fTOFnSigmaProton(0x0),
54 fTPCnSigmaPion(0x0),
55 fTOFnSigmaPion(0x0),
56 fTPCnSigmaKaon(0x0),
57 fTOFnSigmaKaon(0x0),
58 fTPCSignal(0x0),
59 fTOFSignal(0x0),
60 fDiHadron(0x0),
61 fMixedEvents(0x0),
62 fHistoList(0x0),
63 fVerbose(kFALSE),
64 fMask(0),
65 fCalculateMixedEvents(kFALSE),
66 fTrigBufferIndex(0),
67 fTrigBufferSize(0)
68
69{
70 //
71 // Default Constructor.
72 //
73
74 // Trigger buffer.
75 for(Int_t i=0; i<25000; i++) {
76 for(Int_t j=0; j<4; j++) {
77 fTrigBuffer[i][j]=0;
78 }
79 }
80
81
82 fMask = 1<<7;
83
84 // The identified di-hadron correlations.
85 for (Int_t i = 0; i < 3; i++) {
86 for (Int_t j = 0; j < 10; j++) {
87 fDiHadronTPC[i][j]=0x0;
88 fDiHadronTOF[i][j]=0x0;
89 fDiHadronTPCTOF[i][j]=0x0;
90 }
91 }
92
93}
94
95//_____________________________________________________________________________
96AliAnalysisTaskDiHadronPID::AliAnalysisTaskDiHadronPID(const char *name):
97 AliAnalysisTaskSE(name),
98 fPIDResponse(0x0),
99 fAODEvent(0x0),
100 fAODHeader(0x0),
101 fAODVertex(0x0),
102 fAODTrack(0x0),
103 fPIDPartners(0x0),
104 fCentrality(0x0),
105 fVertexZ(0x0),
106 fTrackCuts(0x0),
107 fPtSpectrum(0x0),
108 fAssociatedDistribution(0x0),
109 fTPCnSigmaProton(0x0),
110 fTOFnSigmaProton(0x0),
111 fTPCnSigmaPion(0x0),
112 fTOFnSigmaPion(0x0),
113 fTPCnSigmaKaon(0x0),
114 fTOFnSigmaKaon(0x0),
115 fTPCSignal(0x0),
116 fTOFSignal(0x0),
117 fDiHadron(0x0),
118 fMixedEvents(0x0),
119 fHistoList(0x0),
120 fVerbose(kFALSE),
121 fMask(0),
122 fCalculateMixedEvents(kFALSE),
123 fTrigBufferIndex(0),
124 fTrigBufferSize(0)
125
126{
127 //
128 // Named Constructor.
129 //
130
131 DefineInput(0, TChain::Class());
132 DefineOutput(1, TList::Class());
133
134 // Trigger buffer.
135 for(Int_t i=0; i<25000; i++) {
136 for(Int_t j=0; j<4; j++) {
137 fTrigBuffer[i][j]=0;
138 }
139 }
140
141 fMask = 1<<7;
142
143 // The identified di-hadron correlations.
144 for (Int_t i = 0; i < 3; i++) {
145 for (Int_t j = 0; j < 10; j++) {
146 fDiHadronTPC[i][j]=0x0;
147 fDiHadronTOF[i][j]=0x0;
148 fDiHadronTPCTOF[i][j]=0x0;
149 }
150 }
151
152}
153
154//_____________________________________________________________________________
155AliAnalysisTaskDiHadronPID::~AliAnalysisTaskDiHadronPID() {
156
157 //
158 // Destructor.
159 //
160
161 if(fPIDPartners) {
162 delete fPIDPartners;
163 fPIDPartners=0;
164 }
165
166}
167
168//_____________________________________________________________________________
169void AliAnalysisTaskDiHadronPID::UserCreateOutputObjects()
170
171{
172 //
173 // Output objects.
174 //
175
176 // The Analysis Manager.
177 AliAnalysisManager* manager = AliAnalysisManager::GetAnalysisManager();
178 AliInputEventHandler* inputHandler = dynamic_cast<AliInputEventHandler*> (manager->GetInputEventHandler());
179
65d8627e 180 if(!inputHandler) {
181 AliFatal("Error getting AliInputEventHandler");
182 }
183
75bac3c4 184 // Pointers to PID Response objects.
185 fPIDResponse = inputHandler->GetPIDResponse();
186 cout << "PID Response object: " << fPIDResponse << endl;
187
188 // Create the output of the task.
189 fHistoList = new TList();
190 fHistoList->SetOwner(kTRUE);
191
192 // Ranges in dPhi, dEta, and the number of bins for di-hadron correlations.
193 Int_t binsHisto[4] = {36,25};
194 Double_t minHisto[4] = {-TMath::Pi()/2.,-1.8};
195 Double_t maxHisto[4] = {3.*TMath::Pi()/2,1.8};
196
197 // --- EVENT SAMPLE PLOTS (PER EVENT) ---
198
199 // Centrality Histogram.
200 fCentrality = new TH1F("fCentrality","Centrality;Centrality;N_{evt}",10,0,100);
201 fHistoList->Add(fCentrality);
202
203 // Vertex Z Histogram.
204 fVertexZ = new TH1F("fVertexZ","Vertex Z position;z (cm);N_{evt}",30,-15,15);
205 fHistoList->Add(fVertexZ);
206
207 // --- UNIDENTIFIED SPECTRA ---
208
209 fPtSpectrum = new TH1F("fPtSpectrum","p_{T} Spectrum Unidentified;p_{T}",100,0,50);
210 fHistoList->Add(fPtSpectrum);
211
212 fAssociatedDistribution = new TH3F("fAssociatedDistribution","Associated Distribution;#phi;#eta;p_{T_assoc}",binsHisto[0],0.,2.*TMath::Pi(),binsHisto[1],-0.9,0.9,10,0.,5.);
213 fAssociatedDistribution->Sumw2();
214 fHistoList->Add(fAssociatedDistribution);
215
216 // --- TRACK CUTS ---
217
218 fTrackCuts = new TH1F("fTrackCuts","Track Cuts;Cut;Count",4,0,4);
219 (fTrackCuts->GetXaxis())->SetBinLabel(1,"Standard Cuts");
220 (fTrackCuts->GetXaxis())->SetBinLabel(2,"+ TPCpid");
221 (fTrackCuts->GetXaxis())->SetBinLabel(3,"+ TOFpid");
222 (fTrackCuts->GetXaxis())->SetBinLabel(4,"+ no TOFmismatch");
223 fHistoList->Add(fTrackCuts);
224
225 // --- QA PLOTS PID ---
226
227 fTPCnSigmaProton = new TH2F("fTPCnSigmaProton","n#sigma plot for the TPC (Protons);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);
228 fHistoList->Add(fTPCnSigmaProton);
229
230 fTOFnSigmaProton = new TH2F("fTOFnSigmaProton","n#sigma plot for the TOF (Protons);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);
231 fHistoList->Add(fTOFnSigmaProton);
232
233 fTPCnSigmaPion = new TH2F("fTPCnSigmaPion","n#sigma plot for the TPC (Pions);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);
234 fHistoList->Add(fTPCnSigmaPion);
235
236 fTOFnSigmaPion = new TH2F("fTOFnSigmaPion","n#sigma plot for the TOF (Pions);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);
237 fHistoList->Add(fTOFnSigmaPion);
238
239 fTPCnSigmaKaon = new TH2F("fTPCnSigmaKaon","n#sigma plot for the TPC (Kaons);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);
240 fHistoList->Add(fTPCnSigmaKaon);
241
242 fTOFnSigmaKaon = new TH2F("fTOFnSigmaKaon","n#sigma plot for the TOF (Kaons);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);
243 fHistoList->Add(fTOFnSigmaKaon);
244
245 // --- PID SIGNALS ---
246
247 fTPCSignal = new TH3F("fTPCSignal","TPC Signal;#eta;p_{T} GeV/c;dE/dx",25,-.9,.9,100.,0.,5.,150,0.,300.);
248 fHistoList->Add(fTPCSignal);
249
250 fTOFSignal = new TH3F("fTOFSignal","TOF Signal;#eta;p_{T} GeV/c;t",25,-.9,.9,100.,0.,5.,150,10000.,25000.);
251 fHistoList->Add(fTOFSignal);
252
253 // --- UNIDENTIFIED DI-HADRON CORRELATIONS & MIXED EVENTS ---
254
255 // Di Hadron Correlations, unidentified. (Dphi,Deta,p_T_assoc)
256 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.);
257 fHistoList->Add(fDiHadron);
258
259 if (fCalculateMixedEvents) {
260 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.);
261 fMixedEvents->Sumw2();
262 fHistoList->Add(fMixedEvents);
263 }
264
265 // --- DI-HADRON CORRELATIONS WITH TPC AND TOF SIGNALS ---
266
267 // Di Hadron Correlations with two PID signals, for each p_T bin and particle species separately. (i.e. 30 histo's)
268 // Axes: {Dphi, Deta, TPC signal, TOF signal}
269 TString basenameTPC("fDiHadronTPC");
270 TString basenameTOF("fDiHadronTOF");
271 TString basenameTPCTOF("fDiHadronTPCTOF");
272 TString basetitle("Di-Hadron correlation");
273 TString finalname, finaltitle;
274 TString species[3] = {"Pion","Kaon","Proton"};
275 TString ptbins[11] = {"0.0","0.5","1.0","1.5","2.0","2.5","3.0","3.5","4.0","4.5","5.0"};
276
277 Int_t binsTPC[3][10] = {{100,100,100,100,100,100,100,100,100,100},
278 {100,100,100,100,100,100,100,100,100,100},
279 {100,100,100,100,100,100,100,100,100,100}};
280
281 Double_t minTPC[3][10] = {{ -50., -50.,-30.,-30.,-30.,-30.,-30.,-30.,-30.,-30.},
282 { -100., -50.,-20.,-20.,-20.,-20.,-20.,-20.,-20.,-20.},
283 { -200.,-150.,-50.,-30.,-20.,-20.,-20.,-20.,-20.,-20.}};
284 Double_t maxTPC[3][10] = {{ 150., 100., 50., 30., 25., 25., 25., 25., 25., 25.},
285 { 50., 100., 40., 30., 30., 30., 30., 30., 30., 30.},
286 { 100., 50., 50., 30., 30., 30., 30., 30., 30., 30.}};
287
288 Int_t binsTOF[3][10] = {{100,100,100,100,100,100,100,100,100,100},
289 {100,100,100,100,100,100,100,100,100,100},
290 {100,100,100,100,100,100,100,100,100,100}};
291
292 Double_t minTOF[3][10] = {{-2000.,-2000.,-1000., -500., -500., -500., -500., -500., -500., -500.},
293 {-2000.,-2000.,-2000.,-1000.,-1000.,-1000.,-1000.,-1000.,-1000.,-1000.},
294 {-2000.,-2000.,-6000.,-3000.,-2000.,-1500.,-1500.,-1500.,-1500.,-1500.}};
295 Double_t maxTOF[3][10] = {{ 2000., 2000., 5000., 3000., 2000., 1500., 1500., 1500., 1500., 1500.},
296 { 2000., 2000., 5000., 2000., 1500., 1500., 1500., 1500., 1500., 1500.},
297 { 2000., 2000., 2000., 1000., 1000., 1000., 1000., 1000., 1000., 1000.}};
298
299 // Recall that AliPID::kPion = 2, AliPID::kKaon = 3, AliPID::kProton = 4.
300 for (Int_t iSpecies = 0; iSpecies < 3; iSpecies++) {
301
302 for (Int_t iPtBin = 0; iPtBin < 10; iPtBin++) {
303
304 // setting the variables for each histogram.
305 finaltitle = basetitle;
306 (((((finaltitle += " (") += species[iSpecies]) += ") ") += ptbins[iPtBin]) += " < P_t < ") += ptbins[iPtBin+1];
307 finaltitle+=";#Delta#phi;#Delta#eta;TPC signal;TOF signal;";
308
309 binsHisto[2] = binsTPC[iSpecies][iPtBin];
310 binsHisto[3] = binsTOF[iSpecies][iPtBin];
311 minHisto[2] = minTPC[iSpecies][iPtBin];
312 minHisto[3] = minTOF[iSpecies][iPtBin];
313 maxHisto[2] = maxTPC[iSpecies][iPtBin];
314 maxHisto[3] = maxTOF[iSpecies][iPtBin];
315
316 // Make the di-hadron correlations with different pid signals.
317 finalname = basenameTPC;
318 (((finalname += "_") += species[iSpecies]) += "_") += iPtBin;
319 fDiHadronTPC[iSpecies][iPtBin] = new TH3F(finalname,finaltitle,binsHisto[0],minHisto[0],maxHisto[0],binsHisto[1],minHisto[1],maxHisto[1],binsHisto[2],minHisto[2],maxHisto[2]);
320 fHistoList->Add(fDiHadronTPC[iSpecies][iPtBin]);
321
322 finalname = basenameTOF;
323 (((finalname += "_") += species[iSpecies]) += "_") += iPtBin;
324 fDiHadronTOF[iSpecies][iPtBin] = new TH3F(finalname,finaltitle,binsHisto[0],minHisto[0],maxHisto[0],binsHisto[1],minHisto[1],maxHisto[1],binsHisto[3],minHisto[3],maxHisto[3]);
325 fHistoList->Add(fDiHadronTOF[iSpecies][iPtBin]);
326
327 finalname = basenameTPCTOF;
328 (((finalname += "_") += species[iSpecies]) += "_") += iPtBin;
329 fDiHadronTPCTOF[iSpecies][iPtBin] = new THnSparseF(finalname,finaltitle,4,binsHisto,minHisto,maxHisto);
330 fHistoList->Add(fDiHadronTPCTOF[iSpecies][iPtBin]);
331
332 }
333 }
334
335 PostData(1, fHistoList);
336
337}
338
339//_____________________________________________________________________________
340Bool_t AliAnalysisTaskDiHadronPID::SelectTrack(AliAODTrack *track, Int_t cuts)
341
342{
343
344 // This selects tracks with three different kinds of track cuts:
345 //
346 // Case 0:
347 // - Tracks must pass the filterbit,
348 // - Tracks must have eta < 0.9.
349 // Case 1:
350 // - TPCpid hit is demanded.
351 // Case 2:
352 // - TOFpid hit is demanded.
353 // Case 3:
354 // - no TOFmismatch is demanded.
355 //
356
357 ULong_t status;
358
359 switch (cuts) {
360 case 0:
361 //cout<<"test0"<<endl;
362 if (!(track->TestFilterMask(fMask))) {return kFALSE;}
363 if (!(TMath::Abs(track->Eta())<0.9)) {return kFALSE;}
364 break;
365 case 1:
366 //cout<<"test1"<<endl;
367 status=GetTrackPartner(track)->GetStatus();
368 if (!((status&AliAODTrack::kTPCpid)==AliAODTrack::kTPCpid)) {return kFALSE;}
369 break;
370 case 2:
371 //cout<<"test2"<<endl;
372 status=GetTrackPartner(track)->GetStatus();
373 if (!((status&AliAODTrack::kTOFpid)==AliAODTrack::kTOFpid)) {return kFALSE;}
374 break;
375 case 3:
376 //cout<<"test3"<<endl;
377 status=GetTrackPartner(track)->GetStatus();
378 if ((status&AliAODTrack::kTOFmismatch)==AliAODTrack::kTOFmismatch) {return kFALSE;}
379 break;
380 default:
381 return kFALSE;
382 break;
383 }
384
385 return kTRUE;
386
387}
388
389//____________________________________________________________________________
390Bool_t AliAnalysisTaskDiHadronPID::SelectEvent(AliAODVertex* vertex)
391
392{
393
394 //
395 // Event Selection.
396 //
397
398 Double_t primVtx[3];
399 vertex->GetXYZ(primVtx);
400 if (TMath::Sqrt(primVtx[0]*primVtx[0] + primVtx[1]*primVtx[1])>1. || TMath::Abs(primVtx[2])>10.) {
401 cout << "AliAnalysisTaskDiHadronPID::SelectEvent: Vertex Out of Range." << endl;
402 cout << "AliAnalysisTaskDiHadronPID::SelectEvent: Event not selected." << endl;
403 return kFALSE;
404 }
405 cout << "AliAnalysisTaskDiHadronPID::SelectEvent: Vertex is OK." << endl;
406
407 // We also wish to make a 0-10% centrality cut.
408 if (fAODHeader->GetCentrality()>10.) {
409 cout << "AliAnalysisTaskDiHadronPID::SelectEvent: Non-central event." << endl;
410 cout << "AliAnalysisTaskDiHadronPID::SelectEvent: Event not selected." << endl;
411 return kFALSE;
412 }
413 cout << "AliAnalysisTaskDiHadronPID::SelectEvent: Central Event." << endl;
414
415 cout << "AliAnalysisTaskDiHadronPID::SelectEvent: Event selected." << endl;
416 return kTRUE;
417
418}
419
420//_____________________________________________________________________________
421void AliAnalysisTaskDiHadronPID::FillPIDPartnersArray() {
422
423 // Initialize the mapping for corresponding PID tracks. (see
424 // GetTrackPartner(AliAODTrack* track)).
425 //
426
427 if (!fAODEvent) {
428 cout << "ERROR in CreatePIDPartersArray(): fAODEvent not set." << endl;
429 return;
430 }
431
432 if (!fMask) {
433 cout << "ERROR in CreatePIDPartersArray(): fMask not set." << endl;
434 return;
435 }
436
437 fPIDPartners = new TObjArray();
438 AliAODTrack* track = 0x0;
439
440 for (Int_t iTrack = 0; iTrack < fAODEvent->GetNumberOfTracks(); iTrack++) {
441
442 track = fAODEvent->GetTrack(iTrack);
443
444 // cout << "Track: " << iTrack << " FilterMaskPass: "<< track->TestFilterMask(fMask) << " Track ID: " << track->GetID() << endl;
445
446 // I.e., if it does NOT pass the filtermask.
447 if (!(track->TestFilterMask(fMask))) {
448 fPIDPartners->AddAtAndExpand(track,track->GetID());
449 if (track->GetID()<1) cout<<"Track ID: "<<track->GetID()<<" Partner ID: "<<(-track->GetID()-1)<<endl;
450 }
451
452 }
453
454}
455
456//_____________________________________________________________________________
457AliAODTrack* AliAnalysisTaskDiHadronPID::GetTrackPartner(AliAODTrack* track) {
458
459 //
460 // Returns the "parner track" of track, which contains the pid information.
461 //
462
463 AliAODTrack* partner = 0x0;
464
465 partner = (AliAODTrack*)(fPIDPartners->At(-track->GetID()-1));
466
467 if (!partner&&fVerbose) cout<<"GetTrackPartner: No Partner found!"<<endl;
468
469 return partner;
470
471}
472
473//_____________________________________________________________________________
474Double_t AliAnalysisTaskDiHadronPID::PhiRange(Double_t DPhi)
475
476{
477 //
478 // Puts the argument in the range [-pi/2,3 pi/2].
479 //
480
481 if (DPhi < -TMath::Pi()/2) DPhi += 2*TMath::Pi();
482 if (DPhi > 3*TMath::Pi()/2) DPhi -= 2*TMath::Pi();
483
484 return DPhi;
485
486}
487
488//_____________________________________________________________________________
489void AliAnalysisTaskDiHadronPID::UserExec(Option_t *)
490
491{
492 //
493 // UserExec.
494 //
495
496 // Input the event.
497 fAODEvent = dynamic_cast<AliAODEvent*>(InputEvent());
498
499 if (!fAODEvent) {
500 cout << "ERROR: No AliAODEvent pointer could be created." << endl;
501 return;
502 }
503
504 // Get the event header.
505 fAODHeader = fAODEvent->GetHeader();
506
507 if (!fAODHeader) {
508 cout << "ERROR: No AliAODHeader pointer could be created."<<endl;
509 return;
510 }
511
512 // Get the event vertex.
513 fAODVertex = fAODEvent->GetPrimaryVertex();
514
515 if (!fAODVertex) {
516 cout << "ERROR: No AliAODVertex pointer could be created." << endl;
517 return;
518 }
519
520 // Display basic event information.
521 cout << endl;
522 cout << "Event centrality: " << fAODHeader->GetCentrality() << endl;
523 cout << "Event Vertex Z: " << fAODVertex->GetZ() << endl;
524 cout << "Event tracks in AOD: " << fAODEvent->GetNumberOfTracks() << endl;
525 cout << endl;
526
527 if (!SelectEvent(fAODVertex)) return;
528 // Fill the TObjArray which holds PID partners.
529 FillPIDPartnersArray();
530
531 // Filling Centrality/ VertexZ Hisogram.
532 fCentrality->Fill(fAODHeader->GetCentrality());
533 fVertexZ->Fill(fAODVertex->GetZ());
534
535 TObjArray *triggers = new TObjArray();
536 TObjArray *associateds = new TObjArray();
537
538 // 1. Identifying sets of triggers and associateds. OK!
539 // 2. Filling Pt distribution (UnID). OK!
540 // 3. Making the nSigma plots for TPC and TOF.
541
542 for (Int_t iTrack = 0; iTrack < fAODEvent->GetNumberOfTracks(); iTrack++) {
543
544 fAODTrack = fAODEvent->GetTrack(iTrack);
545
546 // Skip track if there is no pointer, or if it doesn't pass the strandard track cuts.
547 if ((!fAODTrack)||(!SelectTrack(fAODTrack,0))) continue;
548
549 if (fAODTrack->GetID()>-1) cout<<"Track ID: "<<fAODTrack->GetID()<<endl;
550
551 // Make the pT spectrum with only standard track cuts.
552 fPtSpectrum->Fill(fAODTrack->Pt());
553
554 if (fAODTrack->Pt() > 5.0) {
555 if (fVerbose) cout << "AliAnalysisTaskDiHadronPID::UserExec: Trigger found!" << endl;
556 triggers->AddLast(fAODTrack);
557 }
558
559 if (fAODTrack->Pt() < 5.0) {
560
561 fTrackCuts->AddBinContent(1);
562
563 // Now we demand a TPC hit.
564 if (!SelectTrack(fAODTrack,1)) continue;
565 //cout<<"Passed Track cuts 1"<<endl;
566 fTrackCuts->AddBinContent(2);
567
568 // the associateds array contains tracks pT < 5.0 GeV/c && TPC hit.
569 associateds->AddLast(fAODTrack);
570 if (fAODTrack->GetID()>-1) cout<<"Assoc. Track ID: "<<fAODTrack->GetID()<<endl;
571
572 // Make the nSigma plots.
573 Double_t mom, nSigma;
574
575 mom = GetTrackPartner(fAODTrack)->GetTPCmomentum();
576 nSigma = fPIDResponse->NumberOfSigmasTPC(GetTrackPartner(fAODTrack),AliPID::kProton);
577 fTPCnSigmaProton->Fill(mom,nSigma);
578 nSigma = fPIDResponse->NumberOfSigmasTPC(GetTrackPartner(fAODTrack),AliPID::kPion);
579 fTPCnSigmaPion->Fill(mom,nSigma);
580 nSigma = fPIDResponse->NumberOfSigmasTPC(GetTrackPartner(fAODTrack),AliPID::kKaon);
581 fTPCnSigmaKaon->Fill(mom,nSigma);
582
583 fTPCSignal->Fill(fAODTrack->Eta(),fAODTrack->Pt(),GetTrackPartner(fAODTrack)->GetTPCsignal());
584
585 if (!SelectTrack(fAODTrack,2)) continue;
586 fTrackCuts->AddBinContent(3);
587 if (!SelectTrack(fAODTrack,3)) continue;
588 fTrackCuts->AddBinContent(4);
589
590 mom = GetTrackPartner(fAODTrack)->P();
591 nSigma = fPIDResponse->NumberOfSigmasTOF(GetTrackPartner(fAODTrack),AliPID::kProton);
592 fTOFnSigmaProton->Fill(mom,nSigma);
593 nSigma = fPIDResponse->NumberOfSigmasTOF(GetTrackPartner(fAODTrack),AliPID::kPion);
594 fTOFnSigmaPion->Fill(mom,nSigma);
595 nSigma = fPIDResponse->NumberOfSigmasTOF(GetTrackPartner(fAODTrack),AliPID::kKaon);
596 fTOFnSigmaKaon->Fill(mom,nSigma);
597
598 fTOFSignal->Fill(fAODTrack->Eta(),fAODTrack->Pt(),GetTrackPartner(fAODTrack)->GetTOFsignal());
599
600 }
601
602 }
603
604 //cout<<"Done with the first loop."<<endl;
605
606 // 1. Making the di-hadron correlations. (to do: set this up a bit nicer!)
607 // {Dphi, Deta, TPC signal, TOF signal}
608 Double_t histoFill[4];
609 AliAODTrack* currentTrigger = 0x0;
610 AliAODTrack* currentAssociated = 0x0;
611 AliAODTrack* currentPIDPartner = 0x0;
612 //AliAODPid* currentPIDObject = 0x0;
613
614 AliTPCPIDResponse& TPCPIDResponse = fPIDResponse->GetTPCResponse();
615 //AliTOFPIDResponse& TOFPIDResponse = fPIDResponse->GetTOFResponse();
616
617 for (Int_t iTrig = 0; iTrig < triggers->GetEntriesFast(); iTrig++){
618
619 currentTrigger = (AliAODTrack*)(triggers->At(iTrig));
620
621 for (Int_t iAssoc = 0; iAssoc < associateds->GetEntriesFast(); iAssoc++) {
622
623 currentAssociated = (AliAODTrack*)(associateds->At(iAssoc));
624
625 histoFill[0] = PhiRange(currentTrigger->Phi() - currentAssociated->Phi());
626 histoFill[1] = currentTrigger->Eta() - currentAssociated->Eta();
627 Double_t pt = currentAssociated->Pt();
628
629 // Be aware that there may be a caveat here when Pt = 5.00000000
630 const Int_t ptbin = (Int_t)(2*currentAssociated->Pt());
631
632 fDiHadron->Fill(histoFill[0],histoFill[1],pt);
633
634 currentPIDPartner = GetTrackPartner(currentAssociated);
635 //currentPIDObject = currentPIDPartner->GetDetPid();
636
637 if (currentPIDPartner/*&&currentPIDObject*/) {
638
639 Double_t TPCmom = currentPIDPartner->GetTPCmomentum();
640 Double_t TPCsignal = currentPIDPartner->GetTPCsignal();
641 Double_t TOFsignal = -999.;
642 Double_t expectedTOFsignalKaon=0,expectedTOFsignalPion=0,expectedTOFsignalProton=0;
643 Double_t times[AliPID::kSPECIES]; // For the expected time per particle species.
644
645 if (SelectTrack(currentAssociated,2)) {
646 TOFsignal = currentPIDPartner->GetTOFsignal();
647
648 //currentPIDObject->GetIntegratedTimes(times);
649 currentPIDPartner->GetIntegratedTimes(times);
650
651 expectedTOFsignalPion = times[AliPID::kPion];
652 expectedTOFsignalKaon = times[AliPID::kKaon];
653 expectedTOFsignalProton = times[AliPID::kProton];
654 }
655
656 Double_t expectedTPCsignalPion = TPCPIDResponse.GetExpectedSignal(TPCmom,AliPID::kPion);
657 Double_t expectedTPCsignalKaon = TPCPIDResponse.GetExpectedSignal(TPCmom,AliPID::kKaon);
658 Double_t expectedTPCsignalProton = TPCPIDResponse.GetExpectedSignal(TPCmom,AliPID::kProton);
659
660 histoFill[2] = TPCsignal - expectedTPCsignalPion;
661 fDiHadronTPC[0][ptbin]->Fill(histoFill[0],histoFill[1],histoFill[2]);
662 if (SelectTrack(currentAssociated,2)&&SelectTrack(currentAssociated,3)) {
663 histoFill[3] = TOFsignal - expectedTOFsignalPion;
664 fDiHadronTOF[0][ptbin]->Fill(histoFill[0],histoFill[1],histoFill[3]);
665 fDiHadronTPCTOF[0][ptbin]->Fill(histoFill);
666 }
667
668 histoFill[2] = TPCsignal - expectedTPCsignalKaon;
669 fDiHadronTPC[1][ptbin]->Fill(histoFill[0],histoFill[1],histoFill[2]);
670 if (SelectTrack(currentAssociated,2)&&SelectTrack(currentAssociated,3)) {
671 histoFill[3] = TOFsignal - expectedTOFsignalKaon;
672 fDiHadronTOF[1][ptbin]->Fill(histoFill[0],histoFill[1],histoFill[3]);
673 fDiHadronTPCTOF[1][ptbin]->Fill(histoFill);
674 }
675
676 histoFill[2] = TPCsignal - expectedTPCsignalProton;
677 fDiHadronTPC[2][ptbin]->Fill(histoFill[0],histoFill[1],histoFill[2]);
678 if (SelectTrack(currentAssociated,2)&&SelectTrack(currentAssociated,3)) {
679 histoFill[3] = TOFsignal - expectedTOFsignalProton;
680 fDiHadronTOF[2][ptbin]->Fill(histoFill[0],histoFill[1],histoFill[3]);
681 fDiHadronTPCTOF[2][ptbin]->Fill(histoFill);
682 }
683
684 fAssociatedDistribution->Fill(currentAssociated->Phi(),currentAssociated->Eta(),currentAssociated->Pt());
685 }
686 }
687 }
688
689 if (fCalculateMixedEvents) {
690
691
692 // Loop over the trigger buffer.
693 if (fVerbose) cout << "AliAnalysisTaskDiHadronPID::UserExec: Mixing the events with "<<fTrigBufferSize<<" triggers from the buffer." <<endl;
694 if (fVerbose) cout << "AliAnalysisTaskDiHadronPID::UserExec: Buffer size: "<<fTrigBufferIndex<<endl;
695
696 for (Int_t iTrig=0;iTrig<fTrigBufferSize;iTrig++) {
697
698 // Check if the trigger and the associated have a reconstructed
699 // vertext no further than 2cm apart.
700
701 // fTrigBuffer[i][0] = z
702 // fTrigBuffer[i][1] = phi
703 // fTrigBuffer[i][2] = eta
704 // fTrigBuffer[i][3] = p_t
705
706 if (TMath::Abs(fTrigBuffer[iTrig][0]-fAODVertex->GetZ())<2.) {
707
708 cout<<"AliAnalysisTaskDiHadronPID::UserExec: Mixing with trigger Z: "<<fTrigBuffer[iTrig][0]<<", Pt: "<<fTrigBuffer[iTrig][3]<<endl;
709
710 for (Int_t iAssoc = 0; iAssoc < associateds->GetEntriesFast(); iAssoc++) {
711
712 currentAssociated = (AliAODTrack*)(associateds->At(iAssoc));
713 currentPIDPartner = GetTrackPartner(currentAssociated);
714 //currentPIDObject = currentPIDPartner->GetDetPid();
715
716 if (currentPIDPartner/*&&currentPIDObject*/) {
717
718 Double_t DPhi = PhiRange(fTrigBuffer[iTrig][1] - currentAssociated->Phi());
719 Double_t DEta = fTrigBuffer[iTrig][2] - currentAssociated->Eta();
720 Double_t Ptassoc = currentAssociated->Pt();
721
722 fMixedEvents->Fill(DPhi,DEta,Ptassoc);
723 }
724 }
725 }
726 }
727
728 // Copy the triggers from the current event into the buffer.
729 if (fAODVertex->GetZ()<10.) {
730
731 if (fVerbose) cout<<"AliAnalysisTaskDiHadronPID::UserExec: Copying "<<triggers->GetEntriesFast()<<" triggers to the buffer with vertex z = "<<fAODVertex->GetZ()<<endl;
732
733 for (Int_t iTrig = 0; iTrig<triggers->GetEntriesFast(); iTrig++) {
734
735 currentTrigger = (AliAODTrack*)(triggers->At(iTrig));
736 if (fVerbose) cout<<"AliAnalysisTaskDiHadronPID::UserExec: Trigger pt = "<<currentTrigger->Pt()<<endl;
737
738 fTrigBuffer[fTrigBufferIndex][0] = fAODVertex->GetZ();
739 fTrigBuffer[fTrigBufferIndex][1] = currentTrigger->Phi();
740 fTrigBuffer[fTrigBufferIndex][2] = currentTrigger->Eta();
741 fTrigBuffer[fTrigBufferIndex][3] = currentTrigger->Pt();
742 fTrigBufferIndex++;
743 if (fTrigBufferSize<25000) {fTrigBufferSize++;}
744 if (fTrigBufferIndex==25000) {fTrigBufferIndex=0;}
745 }
746 }
747 }
748
749 if (fVerbose) cout<<"AliAnalysisTaskDiHadronPID::UserExec: Trigger buffer index: "<<fTrigBufferIndex<<", and size: "<<fTrigBufferSize<<endl;
750
751 delete triggers;
752 delete associateds;
753
754 PostData(1,fHistoList);
755
756}
757
758//_____________________________________________________________________________
759void AliAnalysisTaskDiHadronPID::Terminate(Option_t *)
760
761{
762 //
763 // Terminate.
764 //
765
766}
767