]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/Correlations/DPhi/TriggerPID/AliAnalysisTaskPIDCORR.cxx
Merge branch 'master' into flatdev
[u/mrichter/AliRoot.git] / PWGCF / Correlations / DPhi / TriggerPID / AliAnalysisTaskPIDCORR.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 //Modified.....
17
18 #include "AliAnalysisTaskPIDCORR.h"
19
20 #include "Riostream.h"
21 #include "TChain.h"
22 #include "TTree.h"
23 #include "TH1F.h"
24 #include "TH2F.h"
25 #include "TCanvas.h"
26 #include "TList.h"
27
28 #include "AliAODEvent.h"
29 #include "AliAODTrack.h"
30 #include "AliPIDResponse.h"
31 #include "AliPID.h"
32 #include "AliAODInputHandler.h"
33 #include "AliVEvent.h"
34 #include "AliVParticle.h"
35
36 #include "AliAODMCHeader.h"
37 #include "AliAODMCParticle.h"
38 #include "AliMCEventHandler.h"
39 #include "AliMCEvent.h"
40 #include "TParticle.h"
41 #include <TDatabasePDG.h>
42 #include <TParticlePDG.h>
43
44 #include "AliAnalysisManager.h"
45 #include "AliAnalysisTaskSE.h"
46
47 #include "AliEventPoolManager.h"
48
49
50 ClassImp(AliAnalysisTaskPIDCORR)
51 ClassImp(AliPIDCorrParticle)
52
53 //________________________________________________________________________
54 AliAnalysisTaskPIDCORR::AliAnalysisTaskPIDCORR() // All data members should be initialised here
55 :AliAnalysisTaskSE(),
56   fAOD(0),
57   fAODVertex(0),
58   fPIDResponse(0),
59   fOutputList(0),
60   fHistPt(0),
61   fHistdEdx(0),
62   fTriggerPhiAll(0),
63   fTriggerPhiPion(0),
64   fTriggerPhiKaonProton(0),
65   fTriggerEtaAll(0),
66   fTriggerEtaPion(0),
67   fTriggerEtaKaonProton(0),
68   fAssoPhi(0),
69   fAssoEta(0),
70   fGlobalTracks(0),
71   fArrayMC(0),
72   fPoolMgr(0),
73   EffEtaTrigPr(1),
74   EffEtaTrigPi(1),
75   EffEtaTrigAll(1)
76   
77 {
78     
79   
80  
81
82         for(int i=0;i<10;i++)
83         {
84         fDihadronCorrelation[i]=NULL;
85         fDihadronCorrelationPion[i]=NULL;
86         fDihadronCorrelationProtonKaon[i]=NULL;
87         fHistNSigmaTPCPion[i]=NULL;
88         fMixedEvent[i]=NULL;
89         fMixedPion[i]=NULL;
90         fMixedProtonKaon[i]=NULL;
91         }
92
93         for(int j=0;j<3;j++)
94         {
95         fHistNSAll[j]=NULL;
96         fHistNSPion[j]=NULL;
97         fHistNSProton[j]=NULL;
98         fHistASAll[j]=NULL;
99         fHistASPion[j]=NULL;
100         fHistASProton[j]=NULL;
101         fHistBgAll[j]=NULL;
102         fHistBgPion[j]=NULL;
103         fHistBgProton[j]=NULL;
104         fHistBulkAll[j]=NULL;
105         fHistBulkPion[j]=NULL;
106         fHistBulkProton[j]=NULL;
107         
108         
109         }
110   
111   
112 }
113
114 //________________________________________________________________________
115 AliAnalysisTaskPIDCORR::AliAnalysisTaskPIDCORR(const char *name) // All data members should be initialised here
116   :AliAnalysisTaskSE(name),
117    fAOD(0),
118   fAODVertex(0),
119   fPIDResponse(0),
120   fOutputList(0),
121   fHistPt(0),
122   fHistdEdx(0),
123   fTriggerPhiAll(0),
124   fTriggerPhiPion(0),
125   fTriggerPhiKaonProton(0),
126   fTriggerEtaAll(0),
127   fTriggerEtaPion(0),
128   fTriggerEtaKaonProton(0),
129   fAssoPhi(0),
130   fAssoEta(0),
131   fGlobalTracks(0),
132   fArrayMC(0),
133   fPoolMgr(0),
134   EffEtaTrigPr(1),
135   EffEtaTrigPi(1),
136   EffEtaTrigAll(1)
137   
138 {
139
140    
141
142         for(int i=0;i<10;i++)
143         {
144         fDihadronCorrelation[i]=NULL;
145         fDihadronCorrelationPion[i]=NULL;
146         fDihadronCorrelationProtonKaon[i]=NULL;
147         fHistNSigmaTPCPion[i]=NULL;
148         fMixedEvent[i]=NULL;
149         fMixedPion[i]=NULL;
150         fMixedProtonKaon[i]=NULL;
151         }
152
153         for(int j=0;j<3;j++)
154         {
155         fHistNSAll[j]=NULL;
156         fHistNSPion[j]=NULL;
157         fHistNSProton[j]=NULL;
158         fHistASAll[j]=NULL;
159         fHistASPion[j]=NULL;
160         fHistASProton[j]=NULL;
161         fHistBgAll[j]=NULL;
162         fHistBgPion[j]=NULL;
163         fHistBgProton[j]=NULL;
164         fHistBulkAll[j]=NULL;
165         fHistBulkPion[j]=NULL;
166         fHistBulkProton[j]=NULL;
167         
168         
169         }
170     
171   
172   // The last in the above list should not have a comma after it
173   
174   // Constructor
175   // Define input and output slots here (never in the dummy constructor)
176   // Input slot #0 works with a TChain - it is connected to the default input container
177   // Output slot #1 writes into a TH1 container
178   
179   DefineOutput(1, TList::Class());                                        // for output list
180 }
181
182 //________________________________________________________________________
183 AliAnalysisTaskPIDCORR::~AliAnalysisTaskPIDCORR()
184 {
185   // Destructor. Clean-up the output list, but not the histograms that are put inside
186   // (the list is owner and will clean-up these histograms). Protect in PROOF case.
187   if (fOutputList && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
188     delete fOutputList;
189   }
190   
191 }
192
193 //________________________________________________________________________
194 void AliAnalysisTaskPIDCORR::UserCreateOutputObjects()
195 {
196   // Create histograms
197   // Called once (on the worker node)
198
199   AliAnalysisManager *man = AliAnalysisManager::GetAnalysisManager(); 
200   AliInputEventHandler *inputHandler = (AliInputEventHandler*)man->GetInputEventHandler(); 
201   fPIDResponse = inputHandler->GetPIDResponse();
202   
203   fOutputList = new TList();
204   fOutputList->SetOwner();  // IMPORTANT!
205
206  
207   
208   
209   
210
211   fHistPt = new TH1F("fHistPt", "P_{T} distribution", 15, 0.1, 3.1);
212   fHistdEdx = new TH2F("fHistdEdx","TPC signal distribution",1000,0.,50.,1000,0,500);
213
214   
215   TString HistName;
216   
217         for(int i=0;i<10;i++)
218         {
219         HistName="fDihadronCorrelation";HistName+=i;
220         fDihadronCorrelation[i]= new TH2F(HistName.Data(),"#delta#eta-#delta#phi correlation",36,-TMath::Pi()/2,3.*TMath::Pi()/2,32,-1.6,1.6);
221         fDihadronCorrelation[i]->Sumw2();
222         fOutputList->Add(fDihadronCorrelation[i]);
223
224         HistName="fDihadronCorrelationPion";HistName+=i;
225         fDihadronCorrelationPion[i]= new TH2F(HistName.Data(),"#delta#eta-#delta#phi correlation",36,-TMath::Pi()/2,3.*TMath::Pi()/2,32,-1.6,1.6);
226         fDihadronCorrelationPion[i]->Sumw2();
227         fOutputList->Add(fDihadronCorrelationPion[i]);
228
229         HistName="fDihadronCorrelationProtonKaon";HistName+=i;
230         fDihadronCorrelationProtonKaon[i]= new TH2F(HistName.Data(),"#delta#eta-#delta#phi correlation",36,-TMath::Pi()/2,3.*TMath::Pi()/2,32,-1.6,1.6);
231         fDihadronCorrelationProtonKaon[i]->Sumw2();
232         fOutputList->Add(fDihadronCorrelationProtonKaon[i]);
233
234         HistName="fMixedEvent";HistName+=i;
235         fMixedEvent[i]= new TH2F(HistName.Data(),"#delta#eta-#delta#phi correlation",36,-TMath::Pi()/2,3.*TMath::Pi()/2,32,-1.6,1.6);
236         fMixedEvent[i]->Sumw2();
237         fOutputList->Add(fMixedEvent[i]);
238
239         HistName="fMixedPion";HistName+=i;
240         fMixedPion[i]= new TH2F(HistName.Data(),"#delta#eta-#delta#phi correlation",36,-TMath::Pi()/2,3.*TMath::Pi()/2,32,-1.6,1.6);
241         fMixedPion[i]->Sumw2();
242         fOutputList->Add(fMixedPion[i]);
243
244         HistName="fMixedProtonKaon";HistName+=i;
245         fMixedProtonKaon[i]= new TH2F(HistName.Data(),"#delta#eta-#delta#phi correlation",36,-TMath::Pi()/2,3.*TMath::Pi()/2,32,-1.6,1.6);
246         fMixedProtonKaon[i]->Sumw2();
247         fOutputList->Add(fMixedProtonKaon[i]);
248         
249         HistName="fHistNSigmaTPCPion";HistName+=i;
250         fHistNSigmaTPCPion[i]= new TH1F(HistName.Data(),"NSigma distribution for all particles",200,-10,10);
251         fHistNSigmaTPCPion[i]->Sumw2();
252         fOutputList->Add(fHistNSigmaTPCPion[i]);
253         }
254
255         for(Int_t l=0;l<3;l++)
256         {
257         HistName="fHistNSPtSpectraAll";HistName+=l;
258         fHistNSAll[l]= new TH1F(HistName.Data(),"Pt_spectra of Associated",15,0.5,3.5);
259         fHistNSAll[l]->Sumw2();
260         fOutputList->Add(fHistNSAll[l]);
261         
262         HistName="fHistNSPtSpectraPion";HistName+=l;
263         fHistNSPion[l]= new TH1F(HistName.Data(),"Pt_spectra of Associated",15,0.5,3.5);
264         fHistNSPion[l]->Sumw2();
265         fOutputList->Add(fHistNSPion[l]);
266         
267         HistName="fHistNSPtSpectraProton";HistName+=l;
268         fHistNSProton[l]= new TH1F(HistName.Data(),"Pt_spectra of Associated",15,0.5,3.5);
269         fHistNSProton[l]->Sumw2();
270         fOutputList->Add(fHistNSProton[l]);
271
272         HistName="fHistASPtSpectraAll";HistName+=l;
273         fHistASAll[l]= new TH1F(HistName.Data(),"Pt_spectra of Associated",15,0.5,3.5);
274         fHistASAll[l]->Sumw2();
275         fOutputList->Add(fHistASAll[l]);
276
277         HistName="fHistASPtSpectraPion";HistName+=l;
278         fHistASPion[l]= new TH1F(HistName.Data(),"Pt_spectra of Associated",15,0.5,3.5);
279         fHistASPion[l]->Sumw2();
280         fOutputList->Add(fHistASPion[l]);
281
282         HistName="fHistASPtSpectraProton";HistName+=l;
283         fHistASProton[l]= new TH1F(HistName.Data(),"Pt_spectra of Associated",15,0.5,3.5);
284         fHistASProton[l]->Sumw2();
285         fOutputList->Add(fHistASProton[l]);
286
287         HistName="fHistBgPtSpectraAll";HistName+=l;
288         fHistBgAll[l]= new TH1F(HistName.Data(),"Pt_spectra of Associated",15,0.5,3.5);
289         fHistBgAll[l]->Sumw2();
290         fOutputList->Add(fHistBgAll[l]);
291
292         HistName="fHistBgPtSpectraPion";HistName+=l;
293         fHistBgPion[l]= new TH1F(HistName.Data(),"Pt_spectra of Associated",15,0.5,3.5);
294         fHistBgPion[l]->Sumw2();
295         fOutputList->Add(fHistBgPion[l]);
296
297         HistName="fHistBgPtSpectraProton";HistName+=l;
298         fHistBgProton[l]= new TH1F(HistName.Data(),"Pt_spectra of Associated",15,0.5,3.5);
299         fHistBgProton[l]->Sumw2();
300         fOutputList->Add(fHistBgProton[l]);
301
302         
303
304         HistName="fHistBulkPtSpectraAll";HistName+=l;
305         fHistBulkAll[l]= new TH1F(HistName.Data(),"Pt_spectra of Associated",15,0.5,3.5);
306         fHistBulkAll[l]->Sumw2();
307         fOutputList->Add(fHistBulkAll[l]);
308
309         HistName="fHistBulkPtSpectraPion";HistName+=l;
310         fHistBulkPion[l]= new TH1F(HistName.Data(),"Pt_spectra of Associated",15,0.5,3.5);
311         fHistBulkPion[l]->Sumw2();
312         fOutputList->Add(fHistBulkPion[l]);
313
314         HistName="fHistBulkPtSpectraProton";HistName+=l;
315         fHistBulkProton[l]= new TH1F(HistName.Data(),"Pt_spectra of Associated",15,0.5,3.5);
316         fHistBulkProton[l]->Sumw2();
317         fOutputList->Add(fHistBulkProton[l]);
318
319         }
320
321         fTriggerPhiAll = new TH1F("fTriggerPhiAll","Phi distribution of  All trigger particles",340,0.0,2*TMath::Pi());
322         fTriggerPhiPion = new TH1F("fTriggerPhiPion","Phi distribution of Pion trigger particles",340,0.0,2*TMath::Pi());
323         fTriggerPhiKaonProton = new TH1F("fTriggerPhiKaonProton","Phi distribution of Kaon & Proton trigger particles",340,0.0,2*TMath::Pi());
324
325         fTriggerEtaAll = new TH1F("fTriggerEtaAll","Eta distribution of  All trigger particles",16,-0.8,0.8);
326         fTriggerEtaPion = new TH1F("fTriggerEtaPion","Eta distribution of  Pion trigger particles",16,-0.8,0.8);
327         fTriggerEtaKaonProton = new TH1F("fTriggerEtaKaonProton","Eta distribution of  Kaon & Proton trigger particles",16,-0.8,0.8);
328
329         fAssoPhi = new TH1F("fAssoPhi","Phi distribution of  Associated particles",340,0.0,2*TMath::Pi());
330         fAssoEta = new TH1F("fAssoEta","Eta distribution of  Associated particles",16,-0.8,0.8); 
331
332
333
334   fOutputList->Add(fTriggerPhiAll);
335   fOutputList->Add(fTriggerPhiPion);
336   fOutputList->Add(fTriggerPhiKaonProton);
337   fOutputList->Add(fTriggerEtaAll);
338   fOutputList->Add(fTriggerEtaPion);
339   fOutputList->Add(fTriggerEtaKaonProton);
340   fOutputList->Add(fAssoPhi);
341   fOutputList->Add(fAssoEta);
342   fOutputList->Add(fHistPt);
343   fOutputList->Add(fHistdEdx);
344
345         
346         
347   
348
349   
350           
351      
352 //Mixing
353 DefineEventPool();
354         
355   
356   PostData(1, fOutputList);              // Post data for ALL output slots >0 here, to get at least an empty histogram
357 }
358
359 //________________________________________________________________________
360 Bool_t AliAnalysisTaskPIDCORR :: SelectEvent(AliAODVertex* vertex)
361
362 {
363
364         //
365         // Event Selection.
366         //
367         
368         
369         Double_t primVtx[3];
370         vertex->GetXYZ(primVtx);
371         if (TMath::Sqrt(primVtx[0]*primVtx[0] + primVtx[1]*primVtx[1])>1. || TMath::Abs(primVtx[2])>10.) {
372                 
373                 return kFALSE;
374         }
375         
376         return kTRUE;
377
378 }
379 //_______________________________________________________________________
380 Int_t AliAnalysisTaskPIDCORR::ClassifyTrack(AliAODTrack* track)
381 {
382 //Int_t Classification=999;
383 Double_t pt = track->Pt();
384 Double_t eta = track->Eta();
385 //Double_t phi = track->Phi();
386
387 if (!(track->TestFilterMask(1<<7))) {
388                 
389                 return 0;
390         }
391
392 if(pt< 0.2)
393         {
394          return 0;
395 }
396         
397 if (TMath::Abs(eta)>=0.8) {
398                 
399                 return 0;
400     }
401
402 //DCA cut
403
404 /*if(PtDependentCut)
405 {
406
407
408 }*/
409
410 if(track->Charge()==0) return 0;
411
412 AliAODTrack *globaltrack=GetGlobalTrack(track->GetID());
413 if(!globaltrack) return  0;
414
415
416 Float_t dxy, dz;
417                   
418 dxy = track->DCA();
419 dz  = track->ZAtDCA();
420 //cout<<dxy<<"   "<<dz<<endl;
421 if(TMath ::Abs(dxy) >2.4 || TMath ::Abs(dz)>3.2) return 0;
422
423 Double_t chi2ndf = track->Chi2perNDF();
424 if(chi2ndf>4.0) return 0;
425
426 Double_t nclus = track->GetTPCClusterInfo(2,1);
427 if(nclus<80) return 0;
428
429 //select primary:
430 if(track->GetType() != AliAODTrack::kPrimary) return 0;
431
432 return 1;
433 }
434 //________________________________________________________________
435 void AliAnalysisTaskPIDCORR::FillGlobalTracksArray() {
436
437         
438         
439         if (!fAOD) {
440         //if (fVerbose>0) cout << "AliAnalysisTaskDiHadronPID::FillGlobalTracksArray -> ERROR: fAODEvent not set." << endl;
441                 return;
442         }
443
444         
445         
446         fGlobalTracks = new TObjArray();
447         AliAODTrack* track = 0x0;
448                 
449         for (Int_t iTrack = 0; iTrack < fAOD->GetNumberOfTracks(); iTrack++) {
450                 
451                 track = fAOD->GetTrack(iTrack);
452                 
453                 // I.e., if it does NOT pass the filtermask.
454                 if (!(track->TestFilterMask(1<<7))) {
455             if (track->GetID()>-1) fGlobalTracks->AddAtAndExpand(track,track->GetID());
456             //cout<<"Track ID: "<<track->GetID()<<" Partner ID: "<<(-track->GetID()-1)<<endl;
457                 }
458         
459         }
460         }
461 //_______________________________________________________________________
462
463 AliAODTrack* AliAnalysisTaskPIDCORR::GetGlobalTrack(Int_t trackID) {
464         
465         
466         
467         AliAODTrack* partner = 0x0;
468             
469     partner = (AliAODTrack*)(fGlobalTracks->At(-trackID-1));
470           
471         
472         return partner;
473         
474 }
475
476
477 //________________________________________________________________________
478 void AliAnalysisTaskPIDCORR::UserExec(Option_t *) 
479 {
480   // Main loop
481   // Called for each event
482
483   // Post output data.
484         
485   AliVEvent *event = InputEvent();
486   if (!event) {  return; }
487
488  
489   fAOD = dynamic_cast<AliAODEvent*>(InputEvent());
490   if (!fAOD) {
491    // printf("ERROR: fAOD not available\n");
492     return;
493   }
494
495
496
497
498 Bool_t isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
499     if(!isSelected) return;
500
501 fAODVertex = fAOD->GetPrimaryVertex();
502         if (!fAODVertex) {
503                 //if (fVerbose>0) cout << "AliAnalysisTaskDiHadronPID::UserExec -> ERROR: No AliAODVertex pointer could be created." << endl;
504                 return;
505         }
506
507 //select vertex
508 if(!SelectEvent(fAODVertex)) return;
509
510 /*fHistVx->Fill(fAODVertex->GetX());
511 fHistVy->Fill(fAODVertex->GetY());
512 fHistVz->Fill(fAODVertex->GetZ());*/
513
514
515 //Float_t bSign = (fAOD->GetMagneticField() > 0) ? 1 : -1;
516
517 /*fArrayMC = (TClonesArray*)fAOD->GetList()->FindObject(AliAODMCParticle::StdBranchName());
518   if (!fArrayMC) {
519    // AliFatal("Error: MC particles branch not found!\n");
520 return;
521   }
522 */
523 /*AliAODMCHeader *mcHdr=NULL;
524   mcHdr=(AliAODMCHeader*)fAOD->GetList()->FindObject(AliAODMCHeader::StdBranchName());  
525   if(!mcHdr) {
526     //printf("MC header branch not found!\n");
527     return;
528         }
529 */
530 // Fill the TObjArray which holds Global tracks.
531         FillGlobalTracksArray();
532
533 // Create object arrays for associateds.
534         TObjArray *associateds  = new TObjArray();
535
536
537 Int_t TriggerIndx=-99999;
538 Double_t TriggerPtMin=4.00;
539 Double_t TriggerPtMax=8.00;
540 Double_t TriggerPhi=1e-10;
541 Double_t TriggerEta=1e-10;
542 Double_t TriggerPt=TriggerPtMin;
543
544
545
546
547
548   // Track loop to fill a pT spectrum
549   for (Int_t iTracks = 0; iTracks < fAOD->GetNumberOfTracks(); iTracks++)
550          {
551     AliAODTrack* track = fAOD->GetTrack(iTracks);
552     if (!track) {
553       //printf("ERROR: Could not receive track %d\n", iTracks);
554       continue;
555          }
556         
557         Int_t tracktype=ClassifyTrack(track);
558         
559         if(tracktype==0) continue;
560
561         if(tracktype==1)
562         {
563
564         AliAODTrack *globaltrack=GetGlobalTrack(track->GetID());
565         Double_t pT=globaltrack->Pt();
566         Double_t Eta=globaltrack->Eta();
567         
568         
569         Double_t dEdx=globaltrack->GetTPCsignal();
570         if(dEdx==0) continue;
571         
572
573         fHistdEdx->Fill(globaltrack->P(),dEdx);
574         fHistPt->Fill(pT);
575         
576
577         if(pT>TriggerPtMin && pT<=TriggerPtMax)
578         {
579         TriggerPt=pT;
580         TriggerPhi=globaltrack->Phi();
581         TriggerEta=globaltrack->Eta();
582         TriggerIndx=track->GetID();
583         TriggerPtMin=TriggerPt;
584         }
585         
586         if(pT>0.2 && TMath::Abs(Eta)<0.8)
587         associateds->AddLast(globaltrack);
588         
589         
590         }
591
592     
593   } //track loop 
594
595         
596         Bool_t IsPion=kFALSE;
597         Bool_t IsKaonProton=kFALSE;
598         //cout<<"***************************************************************************"<<TriggerEta<<endl;
599         if(TMath::Abs(TriggerEta)>0.8) return;
600         
601         if(TriggerIndx!=-99999)
602         {
603         
604         //Float_t bSign = (fAOD->GetMagneticField() > 0) ? 1 : -1;
605         
606         AliAODTrack *currentAssociateds=0x0;
607         
608         AliAODTrack *TriggerTrck=GetGlobalTrack(TriggerIndx);
609         
610         if(!TriggerTrck) return;
611         
612         
613                 
614         
615         
616         
617         
618         Int_t TrgrPtBin=GetTriggerPtBin(TriggerTrck);
619         
620         if(TrgrPtBin> 7) return;
621         
622         Bool_t CheckTrackPIDqa=GetTrackStatus(TriggerTrck);
623         if(!CheckTrackPIDqa) return;
624         
625         Double_t nSigma_TPC=(fPIDResponse->NumberOfSigmasTPC(TriggerTrck, (AliPID ::EParticleType)2));
626
627         
628         fHistNSigmaTPCPion[TrgrPtBin]->Fill(nSigma_TPC);
629         //if(nSigma_TPC >= 4.0 || nSigma_TPC< -7.5) return;
630         if(nSigma_TPC > 0.0 && nSigma_TPC< 4.0) IsPion=kTRUE;
631         if(nSigma_TPC > -6.0 && nSigma_TPC< -3.0) IsKaonProton=kTRUE;
632         //cout<<"NSigma_TPC********************************************************************************"<<nSigma_TPC<<"   "<<TriggerTrck->GetTPCsignalN()<<endl;
633         
634         EffEtaTrigAll=GetEtaCorrectionFactorTrigAll(TriggerEta) ;
635         fTriggerPhiAll->Fill(TriggerPhi);
636         fTriggerEtaAll->Fill(TriggerEta,1./(EffEtaTrigAll));
637         if(IsPion)
638         {
639         EffEtaTrigPi=GetEtaCorrectionFactorTrigPion(TriggerEta) ;
640         fTriggerPhiPion->Fill(TriggerPhi);
641         fTriggerEtaPion->Fill(TriggerEta,1./(EffEtaTrigPi));
642         }
643         if(IsKaonProton)
644         {
645         EffEtaTrigPr=GetEtaCorrectionFactorTrigProton(TriggerEta) ;//Eff value of triggers
646         fTriggerPhiKaonProton->Fill(TriggerPhi);
647         fTriggerEtaKaonProton->Fill(TriggerEta,1./(EffEtaTrigPr));
648         
649         //cout<<"PROTON TRIGGER***************************************************************"<<"   "<<EffEtaTrigP<<endl;
650         }
651
652         
653
654         for(Int_t iasso=0;iasso<associateds->GetEntriesFast();iasso++ )
655         {
656         currentAssociateds = (AliAODTrack*)(associateds->At(iasso));
657         Double_t assoPt=currentAssociateds->Pt();
658
659         Int_t AssoPtBin=(Int_t)(2*assoPt);
660
661         if(assoPt<4.0)
662         {
663         //Bool_t TwoTrackEff=TwoTrackEfficiency(TriggerTrck,currentAssociateds,0.02,bSign);
664
665         //if(!TwoTrackEff) continue;
666         
667 //Identify Associated**********************************************************************
668
669 IdentifyAssociated(TriggerEta,TriggerPhi,IsPion,IsKaonProton,currentAssociateds);
670
671 //Identify Associated***********************************************************************
672
673         fAssoPhi->Fill(currentAssociateds->Phi());
674         fAssoEta->Fill(currentAssociateds->Eta());
675
676         Double_t delphi= PhiRange(TriggerPhi - currentAssociateds->Phi());
677         Double_t deleta=TriggerEta - currentAssociateds->Eta();
678         
679         Float_t EffEtaAsso=GetEtaCorrectionFactorAsso(currentAssociateds->Eta());//Eff value of associateds 
680
681         Float_t WeightSAll=(1./(EffEtaAsso*EffEtaTrigAll));
682         fDihadronCorrelation[AssoPtBin]->Fill(delphi,deleta,WeightSAll);
683         if(IsPion)
684         {
685         Float_t WeightSPi=(1./(EffEtaAsso*EffEtaTrigPi));
686         fDihadronCorrelationPion[AssoPtBin]->Fill(delphi,deleta,WeightSPi);
687
688         }
689         if(IsKaonProton)
690         {
691         
692         Float_t WeightSPr=(1./(EffEtaAsso*EffEtaTrigPr));
693         //cout<<WeightS<<endl;
694         fDihadronCorrelationProtonKaon[AssoPtBin]->Fill(delphi,deleta,WeightSPr);//Applied Efficiency Correction
695         }
696
697         }
698
699         }
700         
701         }
702
703 //Mixing starts here----------------------------------------------------------------------------------------------------------------
704         
705         Double_t multiplicity=fAOD->GetNumberOfTracks();
706         Double_t MultipORcent=multiplicity;
707         AliAODVertex *vtx =fAOD->GetPrimaryVertex();
708         Double_t zvertex =vtx->GetZ();
709         Double_t poolmin=0;
710         Double_t poolmax=150;
711         if(TMath:: Abs(zvertex)>=10 || MultipORcent>poolmax || MultipORcent<poolmin) return ;
712         AliEventPool* pool =NULL; 
713         pool=fPoolMgr->GetEventPool(MultipORcent, zvertex);
714         if(pool==NULL)
715         {
716         //AliInfo(Form("No pool found for multiplicity = %f, zVtx = %f cm", MultipORcent, zvertex));
717          return;
718         }
719         if (pool->IsReady() || pool->NTracksInPool() > 50000/ 10 || pool->GetCurrentNEvents() >=5)
720         {
721         const Int_t nMix = pool->GetCurrentNEvents();
722         
723         for (Int_t jMix=0; jMix<nMix; jMix++)
724         {
725         TObjArray* bgTracks = NULL;
726         bgTracks=pool->GetEvent(jMix);
727         if(!bgTracks) continue;
728         for(Int_t itrack=0;itrack<bgTracks->GetEntriesFast();++itrack)
729         {
730         AliPIDCorrParticle *PIDCorrParticle =NULL;
731         PIDCorrParticle=(AliPIDCorrParticle*)(bgTracks->At(itrack));
732         Double_t assoPt=PIDCorrParticle->Pt();
733         Int_t Ptbinbg=(Int_t)(assoPt*2);
734         if(assoPt<4.0)
735         {
736         
737         Float_t EffEtaAssoMixed=GetEtaCorrectionFactorAsso(PIDCorrParticle->Eta());
738         
739         Double_t mixedDelPhi=PhiRange(TriggerPhi-PIDCorrParticle->Phi());
740         Double_t mixedDelEta=TriggerEta-PIDCorrParticle->Eta();
741
742         
743         if(TriggerIndx!=-99999)
744         {
745         Float_t WeightMAll=(1./(EffEtaAssoMixed*EffEtaTrigAll));
746         fMixedEvent[Ptbinbg]->Fill(mixedDelPhi,mixedDelEta,WeightMAll);
747         if(IsPion)
748         { 
749         Float_t WeightMPi=(1./(EffEtaAssoMixed*EffEtaTrigPi));
750         fMixedPion[Ptbinbg]->Fill(mixedDelPhi,mixedDelEta,WeightMPi);
751
752         }
753         if(IsKaonProton)
754         {
755         Float_t WeightMPr=(1./(EffEtaAssoMixed*EffEtaTrigPr));
756         //cout<<WeightM<<endl;
757         fMixedProtonKaon[Ptbinbg]->Fill(mixedDelPhi,mixedDelEta,WeightMPr);
758         }
759         }
760         }
761         }
762         }
763         }
764         
765         
766         
767         //Update pool
768         TObjArray* objArray = NULL;
769         objArray = (TObjArray*)AcceptTracksforMixing(fAOD);
770         if(!objArray) return;
771         if(objArray->GetEntriesFast()>0) {
772         pool->UpdatePool(objArray);
773         } 
774
775         
776
777   PostData(1, fOutputList);
778
779 //_______________________________________________________________________________________
780
781 Double_t AliAnalysisTaskPIDCORR::PhiRange(Double_t DPhi)
782
783 {
784         //
785         // Puts the argument in the range [-pi/2,3 pi/2].
786         //
787         
788         if (DPhi < -TMath::Pi()/2) DPhi += 2*TMath::Pi();
789         if (DPhi > 3*TMath::Pi()/2) DPhi -= 2*TMath::Pi();      
790
791         return DPhi;
792         
793
794  
795 //________________________________________________________________________
796 Int_t AliAnalysisTaskPIDCORR:: GetTriggerPtBin(AliAODTrack *track)
797 {
798 Int_t Bin;
799 Double_t Pt_Max=track->Pt();
800 if(Pt_Max<4.0) Bin=999;
801 if(Pt_Max>=4.0 && Pt_Max<4.5) Bin=0;
802 if(Pt_Max>=4.5 && Pt_Max<5.0) Bin=1;
803 if(Pt_Max>=5.0 && Pt_Max<5.5) Bin=2;
804 if(Pt_Max>=5.5 && Pt_Max<6.0) Bin=3;
805 if(Pt_Max>=6.0 && Pt_Max<6.5) Bin=4;
806 if(Pt_Max>=6.5 && Pt_Max<7.0) Bin=5;
807 if(Pt_Max>=7.0 && Pt_Max<7.5) Bin=6;
808 if(Pt_Max>=7.5 && Pt_Max<8.0) Bin=7;
809 if(Pt_Max>=8.0) Bin=999;
810 return Bin;
811
812
813 }
814
815 //______________________________________________________________________
816 Bool_t AliAnalysisTaskPIDCORR :: GetTrackStatus(AliAODTrack *track)
817 {
818   if ((track->GetStatus() & AliAODTrack::kTPCin   ) == 0) return kFALSE;
819   if ((track->GetStatus() & AliAODTrack::kTPCrefit) == 0) return kFALSE;
820   if ((track->GetStatus() & AliAODTrack::kITSrefit) == 0) return kFALSE;
821  return kTRUE;
822 }
823 //______________________________________________________________________
824
825 void AliAnalysisTaskPIDCORR ::DefineEventPool()
826 {
827 const Int_t MaxNofEvents=1000;
828 const Int_t MinNofTracks=50000;
829 const Int_t NofCentBins=3;
830 Double_t CentralityBins[NofCentBins+1]={2,20,50,150};
831 const Int_t NofVrtxBins=10;
832 Double_t ZvrtxBins[NofVrtxBins+1]={-10,-8,-6,-4,-2,0,2,4,6,8,10};
833
834
835 fPoolMgr = new AliEventPoolManager(MaxNofEvents,MinNofTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins);
836 }
837 //_______________________________________________________________________
838 TObjArray *AliAnalysisTaskPIDCORR::AcceptTracksforMixing(AliAODEvent *inputEvent)
839 {
840         Int_t nTracks = inputEvent->GetNumberOfTracks();
841         
842         
843
844         TObjArray* tracksClone = new TObjArray;
845         tracksClone->SetOwner(kTRUE);
846
847         for (Int_t iTrack=0; iTrack<nTracks; ++iTrack)
848 {
849         AliAODTrack* track = inputEvent->GetTrack(iTrack);
850         
851         Int_t trackclass=ClassifyTrack(track);
852         if (trackclass==1)
853         {
854         //AliAODTrack *globaltrack=GetGlobalTrack(track->GetID());
855         //Double_t MpT=globaltrack->Pt();
856         //Double_t MEta=globaltrack->Eta();
857         //if(MpT>0.2 && TMath::Abs(MEta)<=0.8)
858         tracksClone->Add(new AliPIDCorrParticle(track->Eta(), track->Phi(), track->Pt(),track->Charge()));
859         }
860 }
861
862 return tracksClone;
863 }
864 //_________________________________________________________________________________________________________________________
865
866
867 Bool_t AliAnalysisTaskPIDCORR::TwoTrackEfficiency(AliAODTrack *trig,AliAODTrack *asso,Float_t ftwoTrackEfficiencyCutValue,Float_t bSign) 
868 {
869  if(!trig || !asso) return kFALSE;
870  //if (twoTrackEfficiencyCut)
871  //{
872           // the variables & cuthave been developed by the HBT group 
873           // see e.g. https://indico.cern.ch/materialDisplay.py?contribId=36&sessionId=6&materialId=slides&confId=142700
874
875           Float_t phi1 = trig->Phi();
876           Float_t pt1 = trig->Pt();
877           Float_t charge1 = trig->Charge();
878           Float_t eta1=trig->Eta();
879   
880           Float_t phi2 = asso->Phi();
881           Float_t pt2 = asso->Pt();
882           Float_t charge2 = asso->Charge();
883           Float_t eta2=asso->Eta();
884
885           Float_t deta=eta1-eta2;     
886           // optimization
887           if (TMath::Abs(deta) < ftwoTrackEfficiencyCutValue * 2.5 * 3)
888           {
889             // check first boundaries to see if is worth to loop and find the minimum
890             Float_t dphistar1 = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, 0.8, bSign);
891             Float_t dphistar2 = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, 2.5, bSign);
892             
893             const Float_t kLimit = ftwoTrackEfficiencyCutValue * 3;
894
895             Float_t dphistarminabs = 1e5;
896             Float_t dphistarmin = 1e5;
897             if (TMath::Abs(dphistar1) < kLimit || TMath::Abs(dphistar2) < kLimit || dphistar1 * dphistar2 < 0)
898             {
899               for (Double_t rad=0.8; rad<2.51; rad+=0.01) 
900               {
901                 Float_t dphistar = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, rad, bSign);
902
903                 Float_t dphistarabs = TMath::Abs(dphistar);
904                 
905                 if (dphistarabs < dphistarminabs)
906                 {
907                   dphistarmin = dphistar;
908                   dphistarminabs = dphistarabs;
909                 }
910               }
911               
912               //fTwoTrackDistancePt[0]->Fill(deta, dphistarmin, TMath::Abs(pt1 - pt2));
913               
914               if (dphistarminabs < ftwoTrackEfficiencyCutValue && TMath::Abs(deta) < ftwoTrackEfficiencyCutValue)
915               {
916 //              Printf("Removed track pair %d %d with %f %f %f %f %f %f %f %f %f", i, j, deta, dphistarminabs, phi1, pt1, charge1, phi2, pt2, charge2, bSign);
917                 return kFALSE;
918               }
919
920               //fTwoTrackDistancePt[1]->Fill(deta, dphistarmin, TMath::Abs(pt1 - pt2));
921             }
922           }
923           //}
924           return kTRUE;
925 }
926 //_________________________________________________________________________________________________________________________________________
927
928 Bool_t AliAnalysisTaskPIDCORR::TwoTrackEfficiencyBg(AliAODTrack *trig,AliPIDCorrParticle *asso,Float_t ftwoTrackEfficiencyCutValue,Float_t bSign) 
929 {
930  if(!trig || !asso) return kFALSE;
931  //if (twoTrackEfficiencyCut)
932  //{
933           // the variables & cuthave been developed by the HBT group 
934           // see e.g. https://indico.cern.ch/materialDisplay.py?contribId=36&sessionId=6&materialId=slides&confId=142700
935
936           Float_t phi1 = trig->Phi();
937           Float_t pt1 = trig->Pt();
938           Float_t charge1 = trig->Charge();
939           Float_t eta1=trig->Eta();
940   
941           Float_t phi2 = asso->Phi();
942           Float_t pt2 = asso->Pt();
943           Float_t charge2 = asso->Charge();
944           Float_t eta2=asso->Eta();
945
946           Float_t deta=eta1-eta2;     
947           // optimization
948           if (TMath::Abs(deta) < ftwoTrackEfficiencyCutValue * 2.5 * 3)
949           {
950             // check first boundaries to see if is worth to loop and find the minimum
951             Float_t dphistar1 = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, 0.8, bSign);
952             Float_t dphistar2 = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, 2.5, bSign);
953             
954             const Float_t kLimit = ftwoTrackEfficiencyCutValue * 3;
955
956             Float_t dphistarminabs = 1e5;
957             Float_t dphistarmin = 1e5;
958             if (TMath::Abs(dphistar1) < kLimit || TMath::Abs(dphistar2) < kLimit || dphistar1 * dphistar2 < 0)
959             {
960               for (Double_t rad=0.8; rad<2.51; rad+=0.01) 
961               {
962                 Float_t dphistar = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, rad, bSign);
963
964                 Float_t dphistarabs = TMath::Abs(dphistar);
965                 
966                 if (dphistarabs < dphistarminabs)
967                 {
968                   dphistarmin = dphistar;
969                   dphistarminabs = dphistarabs;
970                 }
971               }
972               
973               //fTwoTrackDistancePt[0]->Fill(deta, dphistarmin, TMath::Abs(pt1 - pt2));
974               
975               if (dphistarminabs < ftwoTrackEfficiencyCutValue && TMath::Abs(deta) < ftwoTrackEfficiencyCutValue)
976               {
977 //              Printf("Removed track pair %d %d with %f %f %f %f %f %f %f %f %f", i, j, deta, dphistarminabs, phi1, pt1, charge1, phi2, pt2, charge2, bSign);
978                 return kFALSE;
979               }
980
981               //fTwoTrackDistancePt[1]->Fill(deta, dphistarmin, TMath::Abs(pt1 - pt2));
982             }
983           }
984           //}
985           return kTRUE;
986 }
987
988 //__________________________________________________________________________________________________________________________________________
989
990 Float_t  AliAnalysisTaskPIDCORR::GetDPhiStar(Float_t phi1, Float_t pt1, Float_t charge1, Float_t phi2, Float_t pt2, Float_t charge2, Float_t radius, Float_t bSign)
991
992   //
993   // calculates dphistar
994   //
995   
996   Float_t dphistar = phi1 - phi2 - charge1 * bSign * TMath::ASin(0.075 * radius / pt1) + charge2 * bSign * TMath::ASin(0.075 * radius / pt2);
997   
998   static const Double_t kPi = TMath::Pi();
999   
1000   // circularity
1001 //   if (dphistar > 2 * kPi)
1002 //     dphistar -= 2 * kPi;
1003 //   if (dphistar < -2 * kPi)
1004 //     dphistar += 2 * kPi;
1005   
1006   if (dphistar > kPi)
1007     dphistar = kPi * 2 - dphistar;
1008   if (dphistar < -kPi)
1009     dphistar = -kPi * 2 - dphistar;
1010   if (dphistar > kPi) // might look funny but is needed
1011     dphistar = kPi * 2 - dphistar;
1012   
1013   return dphistar;
1014 }
1015 //_______________________________________________________________________
1016 Float_t AliAnalysisTaskPIDCORR::GetEtaCorrectionFactorAsso(Double_t Eta)
1017 {
1018
1019
1020 Int_t Etabin=(16/1.6)*(-0.8-Eta);
1021 Int_t BIN=TMath::Abs(Etabin);
1022
1023 Float_t eff[16]={0.773274,0.783099,0.774943,0.769163,0.759582,0.74767,0.732028,0.724823,0.756575,0.780094,0.788648,0.79306,0.796114,0.801123,0.799477,0.779948};
1024
1025 return eff[BIN];
1026
1027
1028
1029 }
1030 //____________________________________________________________________________________
1031 Float_t AliAnalysisTaskPIDCORR::GetEtaCorrectionFactorTrigAll(Double_t Eta)
1032 {
1033
1034
1035 Int_t Etabin=(16/1.6)*(-0.8-Eta);
1036 Int_t BIN=TMath::Abs(Etabin);
1037
1038
1039
1040 Float_t EffAll[16]={0.705833,0.715773,0.72209,0.718895,0.703701,0.691354,0.679242,0.65723,0.698546,0.72464,0.730565,0.732914,0.733499,0.746637,0.738133,0.720495};
1041
1042 return EffAll[BIN];
1043
1044 }
1045
1046 //_____________________________________________________________________________________________
1047 Float_t AliAnalysisTaskPIDCORR::GetEtaCorrectionFactorTrigPion(Double_t Eta)
1048 {
1049
1050
1051 Int_t Etabin=(16/1.6)*(-0.8-Eta);
1052 Int_t BIN=TMath::Abs(Etabin);
1053
1054
1055 Float_t EffPion[16]={0.36819,0.369563,0.378747,0.378856,0.361426,0.372088,0.355179,0.344626,0.376348,0.387998,0.381553,0.373258,0.397368,0.380326,0.381536,0.369155};
1056
1057 return EffPion[BIN];
1058
1059
1060 }
1061
1062 //______________________________________________________________________________________________________
1063 Float_t AliAnalysisTaskPIDCORR::GetEtaCorrectionFactorTrigProton(Double_t Eta)
1064 {
1065
1066
1067 Int_t Etabin=(16/1.6)*(-0.8-Eta);
1068 Int_t BIN=TMath::Abs(Etabin);
1069
1070 Float_t EffProton[16]={0.698916,0.708791,0.686047,0.663609,0.621142,0.57571,0.556255,0.518182,0.54031,0.58828,0.62885,0.675739,0.686916,0.707395,0.714397,0.693769};
1071 return EffProton[BIN];
1072
1073
1074
1075
1076 }
1077 //_______________________________________________________________________
1078 Bool_t AliAnalysisTaskPIDCORR::CheckTOF(AliVTrack * trk)
1079 {
1080         //in addition to KTOFout and kTIME we look at the pt
1081   if(trk->Pt()<0.6)return kFALSE;
1082
1083 //check if the particle has TOF Matching
1084   UInt_t status;
1085   status=trk->GetStatus();
1086   if((status&AliVTrack::kTOFout)==0 || (status&AliVTrack::kTIME)==0)return kFALSE;
1087   else return kTRUE;
1088   
1089
1090
1091 }
1092 //________________________________________________________________________
1093 void AliAnalysisTaskPIDCORR::IdentifyAssociated(Double_t Eta_trig,Double_t Phi_trig,Bool_t PION,Bool_t PROTON,AliAODTrack *TRK)
1094 {
1095 Bool_t HasTOFPID=CheckTOF(TRK);
1096 //Bool_t HasTPCPID=GetTrackStatus(TRK);
1097
1098 if(HasTOFPID)
1099 {
1100 Double_t Eta_asso=TRK->Eta();
1101 Double_t Phi_asso=TRK->Phi();
1102
1103 Int_t Ptype=GetTOFPID(TRK);
1104 if(Ptype>2) return;
1105
1106 //cout<<"TOFPID"<<HasTOFPID<<"  "<<"ParticleType"<<Ptype<<endl;
1107 //Int_t Ptype=GetTPCTOFPID(TRK);
1108
1109 if(TMath::Abs(Eta_trig-Eta_asso)<=0.5)
1110         {
1111
1112         if(TMath::Abs(Phi_trig-Phi_asso)<=0.5)
1113         {
1114         fHistNSAll[Ptype]->Fill(TRK->Pt());
1115         if(PION)
1116         fHistNSPion[Ptype]->Fill(TRK->Pt());
1117         if(PROTON)
1118         fHistNSProton[Ptype]->Fill(TRK->Pt());
1119         }
1120
1121         if((Phi_trig-Phi_asso)>=TMath::Pi()-0.5 && (Phi_trig-Phi_asso)<=TMath::Pi()+0.5)
1122         {
1123         fHistASAll[Ptype]->Fill(TRK->Pt());
1124         if(PION)
1125         fHistASPion[Ptype]->Fill(TRK->Pt());
1126         if(PROTON)
1127         fHistASProton[Ptype]->Fill(TRK->Pt());
1128         }
1129
1130         if((Phi_trig-Phi_asso)>=0.5*TMath::Pi()-0.4 && (Phi_trig-Phi_asso)<=0.5*TMath::Pi()+0.2)
1131         {
1132         fHistBgAll[Ptype]->Fill(TRK->Pt());
1133         if(PION)
1134         fHistBgPion[Ptype]->Fill(TRK->Pt());
1135         if(PROTON)
1136         fHistBgProton[Ptype]->Fill(TRK->Pt());
1137         }
1138
1139
1140         }
1141
1142 if(TMath::Abs(Eta_trig-Eta_asso)>=1.0)
1143         {
1144         fHistBulkAll[Ptype]->Fill(TRK->Pt());
1145         if(PION)
1146         fHistBulkPion[Ptype]->Fill(TRK->Pt());
1147         if(PROTON)
1148         fHistBulkProton[Ptype]->Fill(TRK->Pt());
1149         }
1150
1151
1152
1153
1154
1155 }
1156
1157
1158 }
1159
1160 //_______________________________________________________________________
1161 Int_t AliAnalysisTaskPIDCORR::GetTOFPID(AliAODTrack *track)
1162 {
1163
1164 Double_t nsigmaTOFkProton=999.,nsigmaTOFkKaon=999.,nsigmaTOFkPion=999.;
1165
1166     nsigmaTOFkProton = fPIDResponse->NumberOfSigmasTOF(track, AliPID::kProton);
1167     nsigmaTOFkKaon   = fPIDResponse->NumberOfSigmasTOF(track, AliPID::kKaon); 
1168     nsigmaTOFkPion   = fPIDResponse->NumberOfSigmasTOF(track, AliPID::kPion);
1169
1170 //cout<<nsigmaTOFkProton<<"   "<<nsigmaTOFkKaon<<"    "<< nsigmaTOFkPion<<endl;
1171
1172         if(TMath::Abs(nsigmaTOFkPion)<= 2.0) return 0;
1173         if(TMath::Abs(nsigmaTOFkKaon)<= 2.0) return 1;
1174         if(TMath::Abs(nsigmaTOFkProton)<= 2.0) return 2;
1175 else return 999;
1176
1177
1178 }
1179 //_______________________________________________________________________
1180 Int_t AliAnalysisTaskPIDCORR::GetTPCTOFPID(AliAODTrack *track)
1181 {
1182
1183 //___TPC
1184   Double_t nsigmaTPCkProton = fPIDResponse->NumberOfSigmasTPC(track, AliPID::kProton);
1185   Double_t nsigmaTPCkKaon   = fPIDResponse->NumberOfSigmasTPC(track, AliPID::kKaon); 
1186   Double_t nsigmaTPCkPion   = fPIDResponse->NumberOfSigmasTPC(track, AliPID::kPion); 
1187 //___TOF
1188
1189 Double_t nsigmaTOFkProton=999.,nsigmaTOFkKaon=999.,nsigmaTOFkPion=999.;
1190
1191     nsigmaTOFkProton = fPIDResponse->NumberOfSigmasTOF(track, AliPID::kProton);
1192     nsigmaTOFkKaon   = fPIDResponse->NumberOfSigmasTOF(track, AliPID::kKaon); 
1193     nsigmaTOFkPion   = fPIDResponse->NumberOfSigmasTOF(track, AliPID::kPion);
1194
1195 //__TPCTOF
1196
1197  Double_t nsigmaTPCTOFkProton=999.,nsigmaTPCTOFkKaon=999.,nsigmaTPCTOFkPion=999.;
1198     nsigmaTPCTOFkProton = TMath::Sqrt((nsigmaTPCkProton*nsigmaTPCkProton+nsigmaTOFkProton*nsigmaTOFkProton));
1199     nsigmaTPCTOFkKaon   = TMath::Sqrt((nsigmaTPCkKaon*nsigmaTPCkKaon+nsigmaTOFkKaon*nsigmaTOFkKaon));
1200     nsigmaTPCTOFkPion   = TMath::Sqrt((nsigmaTPCkPion*nsigmaTPCkPion+nsigmaTOFkPion*nsigmaTOFkPion));
1201
1202     if(TMath::Abs(nsigmaTPCTOFkPion)<= 3.0) return 0;
1203     if(TMath::Abs(nsigmaTPCTOFkKaon)<= 3.0) return 1;
1204     if(TMath::Abs(nsigmaTPCTOFkProton)<= 3.0) return 2;
1205
1206     return -1;
1207 }
1208
1209
1210
1211 //________________________________________________________________________
1212 void AliAnalysisTaskPIDCORR::Terminate(Option_t *) 
1213 {
1214   // Draw result to screen, or perform fitting, normalizations
1215   // Called once at the end of the query
1216   fOutputList = dynamic_cast<TList*> (GetOutputData(1));
1217   if(!fOutputList) { Printf("ERROR: could not retrieve TList fOutput"); return; }
1218   
1219   
1220 }
1221  
1222