changes from Misha
authoraadare <aadare@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 12 Apr 2012 19:44:07 +0000 (19:44 +0000)
committeraadare <aadare@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 12 Apr 2012 19:44:07 +0000 (19:44 +0000)
PWGCF/Correlations/DPhi/AliAnalysisTaskDiHadronPID.cxx
PWGCF/Correlations/DPhi/AliAnalysisTaskDiHadronPID.h

index 856dfb9..303895f 100644 (file)
-// ----------------------------------------------------------------------------
-// This class makes di-hadron correlations, with TOF and TPC signals for
-// the associated particles. It runs on AOD049 and AOD73 productions.
-// ----------------------------------------------------------------------------
-// Author: Misha Veldhoen (misha.veldhoen@cern.ch)
-// Start: July 21st, 2011.
-// Last edit: Mar 2nd 2012. (v 8.00)
-// ----------------------------------------------------------------------------
-//
-
-#include <iostream>
-#include "TChain.h"
-#include "TTree.h"
-#include "TH1F.h"
-#include "TH2F.h"
-#include "TH3F.h"
-#include "TCanvas.h"
-#include "TFile.h"
-
-#include "AliAODTrack.h"
-#include "AliAODEvent.h"
-#include "AliAODInputHandler.h"
-#include "AliAODVertex.h"
-//#include "AliAODPid.h"
-
-#include "AliAnalysisManager.h"
-#include "AliInputEventHandler.h"
-#include "AliPIDResponse.h"
-#include "AliTPCPIDResponse.h"
-//#include "AliTOFPIDResponse.h"
-
-#include "AliAnalysisTaskDiHadronPID.h"
-
-using namespace std;
-
-ClassImp(AliAnalysisTaskDiHadronPID);
-
-//_____________________________________________________________________________
-AliAnalysisTaskDiHadronPID::AliAnalysisTaskDiHadronPID():
-       AliAnalysisTaskSE(),
-       fPIDResponse(0x0),
-       fAODEvent(0x0),
-       fAODHeader(0x0),
-       fAODVertex(0x0),
-       fAODTrack(0x0),
-       fPIDPartners(0x0),
-       fCentrality(0x0),
-       fVertexZ(0x0),
-    fTrackCuts(0x0),
-       fPtSpectrum(0x0),
-       fAssociatedDistribution(0x0),
-       fTPCnSigmaProton(0x0),
-       fTOFnSigmaProton(0x0),
-       fTPCnSigmaPion(0x0),
-       fTOFnSigmaPion(0x0),
-       fTPCnSigmaKaon(0x0),
-       fTOFnSigmaKaon(0x0),
-       fTPCSignal(0x0),
-       fTOFSignal(0x0),
-       fDiHadron(0x0),
-       fMixedEvents(0x0),
-       fHistoList(0x0),
-       fVerbose(kFALSE),
-       fMask(0),       
-       fCalculateMixedEvents(kFALSE),
-       fTrigBufferIndex(0),    
-       fTrigBufferSize(0)
-
-{
-       //
-       // Default Constructor.
-       //
-       
-       // Trigger buffer.
-       for(Int_t i=0; i<25000; i++) {
-               for(Int_t j=0; j<4; j++) {
-                       fTrigBuffer[i][j]=0;
-               }                               
-       }       
-
-       
-       fMask = 1<<7;
-       
-    // The identified di-hadron correlations.
-       for (Int_t i = 0; i < 3; i++) {
-               for (Int_t j = 0; j < 10; j++) {
-            fDiHadronTPC[i][j]=0x0;
-            fDiHadronTOF[i][j]=0x0;
-                       fDiHadronTPCTOF[i][j]=0x0;
-               }
-       }
-    
-}
-
-//_____________________________________________________________________________
-AliAnalysisTaskDiHadronPID::AliAnalysisTaskDiHadronPID(const char *name):
-       AliAnalysisTaskSE(name),
-       fPIDResponse(0x0),
-       fAODEvent(0x0),
-       fAODHeader(0x0),
-       fAODVertex(0x0),
-       fAODTrack(0x0),
-       fPIDPartners(0x0),
-       fCentrality(0x0),
-       fVertexZ(0x0),
-    fTrackCuts(0x0),
-       fPtSpectrum(0x0),
-    fAssociatedDistribution(0x0),
-       fTPCnSigmaProton(0x0),
-       fTOFnSigmaProton(0x0),
-       fTPCnSigmaPion(0x0),
-       fTOFnSigmaPion(0x0),
-       fTPCnSigmaKaon(0x0),
-       fTOFnSigmaKaon(0x0),
-       fTPCSignal(0x0),
-       fTOFSignal(0x0),
-       fDiHadron(0x0),
-       fMixedEvents(0x0),
-       fHistoList(0x0),
-       fVerbose(kFALSE),
-       fMask(0),
-       fCalculateMixedEvents(kFALSE),
-       fTrigBufferIndex(0),    
-       fTrigBufferSize(0)
-
-{
-       //
-       // Named Constructor.
-       //
-       
-       DefineInput(0, TChain::Class());
-       DefineOutput(1, TList::Class());
-       
-       // Trigger buffer.
-       for(Int_t i=0; i<25000; i++) {
-               for(Int_t j=0; j<4; j++) {
-                       fTrigBuffer[i][j]=0;
-               }                               
-       }       
-       
-       fMask = 1<<7;
-    
-    // The identified di-hadron correlations.
-       for (Int_t i = 0; i < 3; i++) {
-               for (Int_t j = 0; j < 10; j++) {
-            fDiHadronTPC[i][j]=0x0;
-            fDiHadronTOF[i][j]=0x0;
-                       fDiHadronTPCTOF[i][j]=0x0;
-               }
-       }
-
-}
-
-//_____________________________________________________________________________
-AliAnalysisTaskDiHadronPID::~AliAnalysisTaskDiHadronPID() {
-
-       //
-       // Destructor.
-       //
-       
-    if(fPIDPartners) {
-        delete fPIDPartners;
-        fPIDPartners=0;
-    }
-
-}
-
-//_____________________________________________________________________________
-void AliAnalysisTaskDiHadronPID::UserCreateOutputObjects() 
-
-{
-       //
-       // Output objects.
-       //
-    
-       // The Analysis Manager.
-       AliAnalysisManager* manager = AliAnalysisManager::GetAnalysisManager();
-       AliInputEventHandler* inputHandler = dynamic_cast<AliInputEventHandler*> (manager->GetInputEventHandler());
-
-       // Pointers to PID Response objects.    
-       fPIDResponse = inputHandler->GetPIDResponse(); 
-       cout << "PID Response object: " << fPIDResponse << endl;
-
-       // Create the output of the task.       
-       fHistoList = new TList();
-       fHistoList->SetOwner(kTRUE); 
-       
-       // Ranges in dPhi, dEta, and the number of bins for di-hadron correlations.
-       Int_t binsHisto[4] = {36,25};
-       Double_t minHisto[4] = {-TMath::Pi()/2.,-1.8};
-       Double_t maxHisto[4] = {3.*TMath::Pi()/2,1.8};
-       
-    // --- EVENT SAMPLE PLOTS (PER EVENT) ---
-    
-       // Centrality Histogram.
-       fCentrality = new TH1F("fCentrality","Centrality;Centrality;N_{evt}",10,0,100);
-       fHistoList->Add(fCentrality);
-       
-       // Vertex Z Histogram.
-       fVertexZ = new TH1F("fVertexZ","Vertex Z position;z (cm);N_{evt}",30,-15,15);
-       fHistoList->Add(fVertexZ);
-       
-       // --- UNIDENTIFIED SPECTRA ---
-       
-       fPtSpectrum = new TH1F("fPtSpectrum","p_{T} Spectrum Unidentified;p_{T}",100,0,50);
-       fHistoList->Add(fPtSpectrum);
-       
-       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.);
-    fAssociatedDistribution->Sumw2();
-    fHistoList->Add(fAssociatedDistribution);
-    
-    // --- TRACK CUTS ---
-    
-    fTrackCuts = new TH1F("fTrackCuts","Track Cuts;Cut;Count",4,0,4);
-    (fTrackCuts->GetXaxis())->SetBinLabel(1,"Standard Cuts");
-    (fTrackCuts->GetXaxis())->SetBinLabel(2,"+ TPCpid");
-    (fTrackCuts->GetXaxis())->SetBinLabel(3,"+ TOFpid");
-    (fTrackCuts->GetXaxis())->SetBinLabel(4,"+ no TOFmismatch");
-    fHistoList->Add(fTrackCuts);
-       
-    // --- QA PLOTS PID ---
-    
-       fTPCnSigmaProton = new TH2F("fTPCnSigmaProton","n#sigma plot for the TPC (Protons);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);
-       fHistoList->Add(fTPCnSigmaProton);
-       
-       fTOFnSigmaProton = new TH2F("fTOFnSigmaProton","n#sigma plot for the TOF (Protons);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);
-       fHistoList->Add(fTOFnSigmaProton);
-
-       fTPCnSigmaPion = new TH2F("fTPCnSigmaPion","n#sigma plot for the TPC (Pions);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);
-       fHistoList->Add(fTPCnSigmaPion);
-       
-       fTOFnSigmaPion = new TH2F("fTOFnSigmaPion","n#sigma plot for the TOF (Pions);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);
-       fHistoList->Add(fTOFnSigmaPion);
-       
-       fTPCnSigmaKaon = new TH2F("fTPCnSigmaKaon","n#sigma plot for the TPC (Kaons);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);
-       fHistoList->Add(fTPCnSigmaKaon);
-       
-       fTOFnSigmaKaon = new TH2F("fTOFnSigmaKaon","n#sigma plot for the TOF (Kaons);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);
-       fHistoList->Add(fTOFnSigmaKaon);        
-       
-       // --- PID SIGNALS ---
-       
-       fTPCSignal = new TH3F("fTPCSignal","TPC Signal;#eta;p_{T} GeV/c;dE/dx",25,-.9,.9,100.,0.,5.,150,0.,300.);
-       fHistoList->Add(fTPCSignal);
-       
-       fTOFSignal = new TH3F("fTOFSignal","TOF Signal;#eta;p_{T} GeV/c;t",25,-.9,.9,100.,0.,5.,150,10000.,25000.);
-       fHistoList->Add(fTOFSignal);
-       
-       // --- UNIDENTIFIED DI-HADRON CORRELATIONS & MIXED EVENTS ---
-               
-       // Di Hadron Correlations, unidentified. (Dphi,Deta,p_T_assoc)
-       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.);
-       fHistoList->Add(fDiHadron);
-               
-    if (fCalculateMixedEvents) {
-        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.);
-        fMixedEvents->Sumw2();
-        fHistoList->Add(fMixedEvents);
-    }
-               
-    // --- DI-HADRON CORRELATIONS WITH TPC AND TOF SIGNALS ---
-    
-       // Di Hadron Correlations with two PID signals, for each p_T bin and particle species separately. (i.e. 30 histo's) 
-       // Axes: {Dphi, Deta, TPC signal, TOF signal}
-    TString basenameTPC("fDiHadronTPC");
-    TString basenameTOF("fDiHadronTOF");
-       TString basenameTPCTOF("fDiHadronTPCTOF");
-       TString basetitle("Di-Hadron correlation");
-       TString finalname, finaltitle;
-       TString species[3] = {"Pion","Kaon","Proton"};
-       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"};
-    
-    // Unzoomed pictures.
-       /*
-       Int_t binsTPC[3][10] = {{100,100,100,100,100,100,100,100,100,100},
-                            {100,100,100,100,100,100,100,100,100,100},
-                            {100,100,100,100,100,100,100,100,100,100}};
-               
-       Double_t minTPC[3][10] =    {{   -50., -50.,-30.,-30.,-30.,-30.,-30.,-30.,-30.,-30.},
-                                 {     -100., -50.,-20.,-20.,-20.,-20.,-20.,-20.,-20.,-20.},
-                                 {  -200.,-150.,-50.,-30.,-20.,-20.,-20.,-20.,-20.,-20.}};
-       Double_t maxTPC[3][10] =    {{ 150., 100., 50., 30., 25., 25., 25., 25., 25., 25.},
-                                 {  50., 100., 40., 30., 30., 30., 30., 30., 30., 30.},
-                                 { 100.,  50., 50., 30., 30., 30., 30., 30., 30., 30.}};
-       
-       Int_t binsTOF[3][10] = {{100,100,100,100,100,100,100,100,100,100},
-                            {100,100,100,100,100,100,100,100,100,100},
-                            {100,100,100,100,100,100,100,100,100,100}};
-       
-       Double_t minTOF[3][10] =    {{-2000.,-2000.,-1000., -500., -500., -500., -500., -500., -500., -500.},
-                                 {-2000.,-2000.,-2000.,-1000.,-1000.,-1000.,-1000.,-1000.,-1000.,-1000.},
-                                 {-2000.,-2000.,-6000.,-3000.,-2000.,-1500.,-1500.,-1500.,-1500.,-1500.}};
-       Double_t maxTOF[3][10] =    {{ 2000., 2000., 5000., 3000., 2000., 1500., 1500., 1500., 1500., 1500.},
-                                 { 2000., 2000., 5000., 2000., 1500., 1500., 1500., 1500., 1500., 1500.},
-                                 { 2000., 2000., 2000., 1000., 1000., 1000., 1000., 1000., 1000., 1000.}};
-       */
-    
-    // Zoomed pictures.
-    Int_t binsTPC[3][10] = {{100,100,100,100,100,100,100,100,100,100},
-                            {100,100,100,100,100,100,100,100,100,100},
-                            {100,100,100,100,100,100,100,100,100,100}};
-    
-       Double_t minTPC[3][10] =    {{   -20., -20.,-20.,-20.,-20.,-20.,-20.,-20.,-20.,-20.},
-                                 {      -20., -20.,-20.,-20.,-20.,-20.,-20.,-20.,-20.,-20.},
-                                 {   -40., -20.,-20.,-20.,-20.,-20.,-20.,-20.,-20.,-20.}};
-       Double_t maxTPC[3][10] =    {{  20.,  20., 20., 20., 20., 20., 20., 20., 20., 20.},
-                                 {  20.,  20., 20., 20., 20., 20., 20., 20., 20., 20.},
-                                 {  40.,  20., 20., 20., 20., 30., 30., 30., 30., 30.}};
-       
-       Int_t binsTOF[3][10] = {{100,100,100,100,100,100,100,100,100,100},
-                            {100,100,100,100,100,100,100,100,100,100},
-                            {100,100,100,100,100,100,100,100,100,100}};
-       
-       Double_t minTOF[3][10] =    {{-1000.,-1000.,-500.,  -500., -500., -400., -400., -400., -400., -400.},
-                                 { -800., -800., -800., -800., -800., -600., -500., -500., -400., -400.},
-                                 {-1000.,-1000.,-1000.,-1000., -800.,-1000.,-1000., -800., -700., -700.}};
-       Double_t maxTOF[3][10] =    {{ 1000., 1000., 1000., 1000., 1000., 1000., 1000.,  900.,  800.,  700.},
-                                 { 1000., 1000.,  500.,  500.,  500.,  900.,  700.,  700.,  600.,  500.},
-                                 { 1000., 1000., 1000.,  500.,  500.,  500.,  500.,  500.,  500.,  500.}};
-    
-       // Recall that AliPID::kPion = 2, AliPID::kKaon = 3, AliPID::kProton = 4.
-       for (Int_t iSpecies = 0; iSpecies < 3; iSpecies++) {
-                               
-               for (Int_t iPtBin = 0; iPtBin < 10; iPtBin++) {
-                       
-                       // setting the variables for each histogram.
-                       finaltitle = basetitle;
-                       (((((finaltitle += " (") += species[iSpecies]) += ") ") += ptbins[iPtBin]) += " < P_t < ") += ptbins[iPtBin+1];
-            finaltitle+=";#Delta#phi;#Delta#eta;TPC signal;TOF signal;";
-            
-                       binsHisto[2] = binsTPC[iSpecies][iPtBin];
-                       binsHisto[3] = binsTOF[iSpecies][iPtBin];
-                       minHisto[2] = minTPC[iSpecies][iPtBin];
-                       minHisto[3] = minTOF[iSpecies][iPtBin];
-                       maxHisto[2] = maxTPC[iSpecies][iPtBin];
-                       maxHisto[3] = maxTOF[iSpecies][iPtBin];
-                
-            // Make the di-hadron correlations with different pid signals.
-            finalname = basenameTPC;
-                       (((finalname += "_") += species[iSpecies]) += "_") += iPtBin;
-            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]);
-            fHistoList->Add(fDiHadronTPC[iSpecies][iPtBin]);
-
-            finalname = basenameTOF;
-                       (((finalname += "_") += species[iSpecies]) += "_") += iPtBin;
-            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]);
-            fHistoList->Add(fDiHadronTOF[iSpecies][iPtBin]);
-
-            finalname = basenameTPCTOF;
-                       (((finalname += "_") += species[iSpecies]) += "_") += iPtBin;
-            fDiHadronTPCTOF[iSpecies][iPtBin] = new THnSparseF(finalname,finaltitle,4,binsHisto,minHisto,maxHisto);
-            fHistoList->Add(fDiHadronTPCTOF[iSpecies][iPtBin]);
-            
-               }
-       }
-    
-       PostData(1, fHistoList);
-       
-}
-
-//_____________________________________________________________________________
-Bool_t AliAnalysisTaskDiHadronPID::SelectTrack(AliAODTrack *track, Int_t cuts)
-
-{
-       
-    // This selects tracks with three different kinds of track cuts:
-    //
-    //  Case 0: 
-    //   - Tracks must pass the filterbit,
-    //   - Tracks must have eta < 0.9.
-    //  Case 1:
-    //   - TPCpid hit is demanded.
-    //  Case 2:
-    //   - TOFpid hit is demanded.
-    //  Case 3:
-    //   - no TOFmismatch is demanded.
-    //
-    
-    ULong_t status;
-    
-    switch (cuts) {
-        case 0:
-            //cout<<"test0"<<endl;
-            if (!(track->TestFilterMask(fMask))) {return kFALSE;}
-            if (!(TMath::Abs(track->Eta())<0.9)) {return kFALSE;}
-            break;
-        case 1:
-            //cout<<"test1"<<endl;
-            status=GetTrackPartner(track)->GetStatus();  
-            if (!((status&AliAODTrack::kTPCpid)==AliAODTrack::kTPCpid)) {return kFALSE;}
-            break;
-        case 2:
-            //cout<<"test2"<<endl;
-            status=GetTrackPartner(track)->GetStatus();  
-            if (!((status&AliAODTrack::kTOFpid)==AliAODTrack::kTOFpid)) {return kFALSE;}
-            break;
-        case 3:
-            //cout<<"test3"<<endl;
-            status=GetTrackPartner(track)->GetStatus();  
-            if ((status&AliAODTrack::kTOFmismatch)==AliAODTrack::kTOFmismatch) {return kFALSE;}
-            break;
-        default:
-            return kFALSE;
-            break;
-    }
-
-    return kTRUE;
-    
-}
-
-//____________________________________________________________________________
-Bool_t AliAnalysisTaskDiHadronPID::SelectEvent(AliAODVertex* vertex)
-
-{
-       
-       //
-       // Event Selection.
-       //
-       
-       Double_t primVtx[3];
-       vertex->GetXYZ(primVtx);
-       if (TMath::Sqrt(primVtx[0]*primVtx[0] + primVtx[1]*primVtx[1])>1. || TMath::Abs(primVtx[2])>10.) {
-               if (fVerbose) cout << "AliAnalysisTaskDiHadronPID::SelectEvent: Vertex Out of Range." << endl;
-        if (fVerbose) cout << "AliAnalysisTaskDiHadronPID::SelectEvent: Event not selected." << endl;
-               return kFALSE;
-       }
-       if (fVerbose) cout << "AliAnalysisTaskDiHadronPID::SelectEvent: Vertex is OK." << endl;
-    
-    // We also wish to make a 0-10% centrality cut.
-    if (fAODHeader->GetCentrality()>10.) {
-        if (fVerbose) cout << "AliAnalysisTaskDiHadronPID::SelectEvent: Non-central event." << endl;
-        if (fVerbose) cout << "AliAnalysisTaskDiHadronPID::SelectEvent: Event not selected." << endl;
-               return kFALSE;
-    }
-       if (fVerbose) cout << "AliAnalysisTaskDiHadronPID::SelectEvent: Central Event." << endl;
-    
-    if (fVerbose) cout << "AliAnalysisTaskDiHadronPID::SelectEvent: Event selected." << endl;
-       return kTRUE;
-       
-}
-
-//_____________________________________________________________________________
-void AliAnalysisTaskDiHadronPID::FillPIDPartnersArray() {
-
-       // Initialize the mapping for corresponding PID tracks. (see
-       // GetTrackPartner(AliAODTrack* track)). 
-       //
-       
-       if (!fAODEvent) {
-        cout << "ERROR in CreatePIDPartersArray(): fAODEvent not set." << endl;
-               return;
-       }
-       
-       if (!fMask) {
-               cout << "ERROR in CreatePIDPartersArray(): fMask not set." << endl;
-               return;
-       }
-       
-       fPIDPartners = new TObjArray();
-       AliAODTrack* track = 0x0;
-               
-       for (Int_t iTrack = 0; iTrack < fAODEvent->GetNumberOfTracks(); iTrack++) {
-               
-               track = fAODEvent->GetTrack(iTrack);
-               
-               // cout << "Track: " << iTrack << " FilterMaskPass: "<< track->TestFilterMask(fMask) << " Track ID: " << track->GetID() << endl;
-               
-               // I.e., if it does NOT pass the filtermask.
-               if (!(track->TestFilterMask(fMask))) {
-            fPIDPartners->AddAtAndExpand(track,track->GetID());
-            if (track->GetID()<1) cout<<"Track ID: "<<track->GetID()<<" Partner ID: "<<(-track->GetID()-1)<<endl;
-               }
-        
-       }
-       
-}
-
-//_____________________________________________________________________________
-AliAODTrack* AliAnalysisTaskDiHadronPID::GetTrackPartner(AliAODTrack* track) {
-       
-       //
-       // Returns the "parner track" of track, which contains the pid information.
-       //
-       
-       AliAODTrack* partner = 0x0;
-           
-    partner = (AliAODTrack*)(fPIDPartners->At(-track->GetID()-1));
-           
-       if (!partner&&fVerbose) cout<<"GetTrackPartner: No Partner found!"<<endl;
-       
-       return partner;
-       
-}
-
-//_____________________________________________________________________________
-Double_t AliAnalysisTaskDiHadronPID::PhiRange(Double_t DPhi)
-
-{
-       //
-       // Puts the argument in the range [-pi/2,3 pi/2].
-       //
-       
-       if (DPhi < -TMath::Pi()/2) DPhi += 2*TMath::Pi();
-       if (DPhi > 3*TMath::Pi()/2) DPhi -= 2*TMath::Pi();      
-
-       return DPhi;
-       
-}
-
-//_____________________________________________________________________________
-void AliAnalysisTaskDiHadronPID::UserExec(Option_t *)
-
-{
-       //
-       // UserExec.
-       //
-       
-       // Input the event.
-       fAODEvent = dynamic_cast<AliAODEvent*>(InputEvent());
-       
-       if (!fAODEvent) {
-               cout << "ERROR: No AliAODEvent pointer could be created." << endl;
-               return;
-       }
-       
-       // Get the event header.
-       fAODHeader = fAODEvent->GetHeader();
-       
-       if (!fAODHeader) {
-               cout << "ERROR: No AliAODHeader pointer could be created."<<endl;
-               return;
-       }
-       
-       // Get the event vertex.
-       fAODVertex = fAODEvent->GetPrimaryVertex();
-       
-       if (!fAODVertex) {
-               cout << "ERROR: No AliAODVertex pointer could be created." << endl;
-               return;
-       }
-               
-       // Display basic event information.
-       if (fVerbose) cout << endl;
-       if (fVerbose) cout << "Event centrality: " << fAODHeader->GetCentrality() << endl;
-       if (fVerbose) cout << "Event Vertex Z: " << fAODVertex->GetZ() << endl;
-       if (fVerbose) cout << "Event tracks in AOD: " << fAODEvent->GetNumberOfTracks() << endl;
-       if (fVerbose) cout << endl;
-
-    if (!SelectEvent(fAODVertex)) return;
-       // Fill the TObjArray which holds PID partners.
-       FillPIDPartnersArray();
-       
-       // Filling Centrality/ VertexZ Hisogram.
-       fCentrality->Fill(fAODHeader->GetCentrality());
-       fVertexZ->Fill(fAODVertex->GetZ());
-       
-       TObjArray *triggers             = new TObjArray();
-       TObjArray *associateds  = new TObjArray();
-       
-       // 1. Identifying sets of triggers and associateds. OK!
-       // 2. Filling Pt distribution (UnID). OK!
-       // 3. Making the nSigma plots for TPC and TOF.
-           
-       for (Int_t iTrack = 0; iTrack < fAODEvent->GetNumberOfTracks(); iTrack++) {
-        
-               fAODTrack = fAODEvent->GetTrack(iTrack);
-
-        // Skip track if there is no pointer, or if it doesn't pass the strandard track cuts.
-               if ((!fAODTrack)||(!SelectTrack(fAODTrack,0))) continue;
-        
-        if (fAODTrack->GetID()>-1) cout<<"Track ID: "<<fAODTrack->GetID()<<endl;
-        
-        // Make the pT spectrum with only standard track cuts.
-        fPtSpectrum->Fill(fAODTrack->Pt());  
-        
-               if (fAODTrack->Pt() > 5.0) {
-                       if (fVerbose) cout << "AliAnalysisTaskDiHadronPID::UserExec: Trigger found!" << endl;
-                       triggers->AddLast(fAODTrack);
-               }
-               
-               if (fAODTrack->Pt() < 5.0) {
-        
-            fTrackCuts->AddBinContent(1);
-        
-            // Now we demand a TPC hit.            
-            if (!SelectTrack(fAODTrack,1)) continue;
-            //cout<<"Passed Track cuts 1"<<endl;
-            fTrackCuts->AddBinContent(2);
-                        
-                       // the associateds array contains tracks pT < 5.0 GeV/c && TPC hit.
-                       associateds->AddLast(fAODTrack);
-            if (fVerbose&&(fAODTrack->GetID()>-1)) cout<<"Assoc. Track ID: "<<fAODTrack->GetID()<<endl;
-
-                       // Make the nSigma plots.
-                       Double_t mom, nSigma;
-
-                       mom = GetTrackPartner(fAODTrack)->GetTPCmomentum();
-                       nSigma = fPIDResponse->NumberOfSigmasTPC(GetTrackPartner(fAODTrack),AliPID::kProton);
-                       fTPCnSigmaProton->Fill(mom,nSigma);
-                       nSigma = fPIDResponse->NumberOfSigmasTPC(GetTrackPartner(fAODTrack),AliPID::kPion);
-                       fTPCnSigmaPion->Fill(mom,nSigma);
-            nSigma = fPIDResponse->NumberOfSigmasTPC(GetTrackPartner(fAODTrack),AliPID::kKaon);
-                       fTPCnSigmaKaon->Fill(mom,nSigma);
-
-                       fTPCSignal->Fill(fAODTrack->Eta(),fAODTrack->Pt(),GetTrackPartner(fAODTrack)->GetTPCsignal());
-                       
-            if (!SelectTrack(fAODTrack,2)) continue;
-            fTrackCuts->AddBinContent(3);
-            if (!SelectTrack(fAODTrack,3)) continue;
-            fTrackCuts->AddBinContent(4);
-            
-                       mom = GetTrackPartner(fAODTrack)->P();
-                       nSigma = fPIDResponse->NumberOfSigmasTOF(GetTrackPartner(fAODTrack),AliPID::kProton);
-                       fTOFnSigmaProton->Fill(mom,nSigma);                     
-            nSigma = fPIDResponse->NumberOfSigmasTOF(GetTrackPartner(fAODTrack),AliPID::kPion);
-                       fTOFnSigmaPion->Fill(mom,nSigma);       
-            nSigma = fPIDResponse->NumberOfSigmasTOF(GetTrackPartner(fAODTrack),AliPID::kKaon);
-                       fTOFnSigmaKaon->Fill(mom,nSigma);
-            
-                       fTOFSignal->Fill(fAODTrack->Eta(),fAODTrack->Pt(),GetTrackPartner(fAODTrack)->GetTOFsignal());
-
-               }
-                               
-       }
-       
-    //cout<<"Done with the first loop."<<endl;
-    
-       // 1. Making the di-hadron correlations. (to do: set this up a bit nicer!)
-    // {Dphi, Deta, TPC signal, TOF signal}
-       Double_t histoFill[4];
-       AliAODTrack* currentTrigger = 0x0;
-       AliAODTrack* currentAssociated = 0x0;
-       AliAODTrack* currentPIDPartner = 0x0;
-       //AliAODPid* currentPIDObject = 0x0;
-       
-       AliTPCPIDResponse& TPCPIDResponse = fPIDResponse->GetTPCResponse();
-       //AliTOFPIDResponse& TOFPIDResponse = fPIDResponse->GetTOFResponse();
-        
-       for (Int_t iTrig = 0; iTrig < triggers->GetEntriesFast(); iTrig++){
-       
-               currentTrigger = (AliAODTrack*)(triggers->At(iTrig));
-               
-               for (Int_t iAssoc = 0; iAssoc < associateds->GetEntriesFast(); iAssoc++) {
-               
-                       currentAssociated = (AliAODTrack*)(associateds->At(iAssoc));
-                                               
-                       histoFill[0] = PhiRange(currentTrigger->Phi() - currentAssociated->Phi());
-                       histoFill[1] = currentTrigger->Eta() - currentAssociated->Eta();
-                       Double_t pt = currentAssociated->Pt();
-
-                       // Be aware that there may be a caveat here when Pt = 5.00000000
-                       const Int_t ptbin = (Int_t)(2*currentAssociated->Pt());
-                       
-            fDiHadron->Fill(histoFill[0],histoFill[1],pt);
-                       
-                       currentPIDPartner = GetTrackPartner(currentAssociated);
-            //currentPIDObject = currentPIDPartner->GetDetPid();
-                       
-                       if (currentPIDPartner/*&&currentPIDObject*/) {
-                               
-                               Double_t TPCmom = currentPIDPartner->GetTPCmomentum();
-                Double_t TPCsignal = currentPIDPartner->GetTPCsignal();
-                Double_t TOFsignal = -999.;
-                Double_t expectedTOFsignalKaon=0,expectedTOFsignalPion=0,expectedTOFsignalProton=0;
-                Double_t times[AliPID::kSPECIES]; // For the expected time per particle species. 
-            
-                               if (SelectTrack(currentAssociated,2)) {
-                    TOFsignal = currentPIDPartner->GetTOFsignal();
-                    
-                    //currentPIDObject->GetIntegratedTimes(times);
-                    currentPIDPartner->GetIntegratedTimes(times);
-                    
-                    expectedTOFsignalPion = times[AliPID::kPion];
-                    expectedTOFsignalKaon = times[AliPID::kKaon];
-                    expectedTOFsignalProton = times[AliPID::kProton]; 
-                }
-                
-                               Double_t expectedTPCsignalPion = TPCPIDResponse.GetExpectedSignal(TPCmom,AliPID::kPion);
-                Double_t expectedTPCsignalKaon = TPCPIDResponse.GetExpectedSignal(TPCmom,AliPID::kKaon);
-                               Double_t expectedTPCsignalProton = TPCPIDResponse.GetExpectedSignal(TPCmom,AliPID::kProton);
-                               
-                histoFill[2] = TPCsignal - expectedTPCsignalPion;
-                fDiHadronTPC[0][ptbin]->Fill(histoFill[0],histoFill[1],histoFill[2]);                
-                if (SelectTrack(currentAssociated,2)&&SelectTrack(currentAssociated,3)) {
-                    histoFill[3] = TOFsignal - expectedTOFsignalPion;
-                    fDiHadronTOF[0][ptbin]->Fill(histoFill[0],histoFill[1],histoFill[3]);
-                    fDiHadronTPCTOF[0][ptbin]->Fill(histoFill);
-                }
-
-                histoFill[2] = TPCsignal - expectedTPCsignalKaon;
-                fDiHadronTPC[1][ptbin]->Fill(histoFill[0],histoFill[1],histoFill[2]);                
-                if (SelectTrack(currentAssociated,2)&&SelectTrack(currentAssociated,3)) {
-                    histoFill[3] = TOFsignal - expectedTOFsignalKaon;
-                    fDiHadronTOF[1][ptbin]->Fill(histoFill[0],histoFill[1],histoFill[3]);
-                    fDiHadronTPCTOF[1][ptbin]->Fill(histoFill);
-                }
-                
-                histoFill[2] = TPCsignal - expectedTPCsignalProton;
-                fDiHadronTPC[2][ptbin]->Fill(histoFill[0],histoFill[1],histoFill[2]);                
-                if (SelectTrack(currentAssociated,2)&&SelectTrack(currentAssociated,3)) {
-                    histoFill[3] = TOFsignal - expectedTOFsignalProton;
-                    fDiHadronTOF[2][ptbin]->Fill(histoFill[0],histoFill[1],histoFill[3]);
-                    fDiHadronTPCTOF[2][ptbin]->Fill(histoFill);
-                }
-                                
-                fAssociatedDistribution->Fill(currentAssociated->Phi(),currentAssociated->Eta(),currentAssociated->Pt());
-                       }
-               }
-       }
-       
-    if (fCalculateMixedEvents) {
-        
-        
-        // Loop over the trigger buffer.
-        if (fVerbose) cout << "AliAnalysisTaskDiHadronPID::UserExec: Mixing the events with "<<fTrigBufferSize<<" triggers from the buffer." <<endl;
-        if (fVerbose) cout << "AliAnalysisTaskDiHadronPID::UserExec: Buffer size: "<<fTrigBufferIndex<<endl;
-        
-        for (Int_t iTrig=0;iTrig<fTrigBufferSize;iTrig++) {
-            
-            // Check if the trigger and the associated have a reconstructed
-            // vertext no further than 2cm apart.
-            
-            // fTrigBuffer[i][0] = z
-            // fTrigBuffer[i][1] = phi
-            // fTrigBuffer[i][2] = eta
-            // fTrigBuffer[i][3] = p_t
-            
-            if (TMath::Abs(fTrigBuffer[iTrig][0]-fAODVertex->GetZ())<2.) {
-                
-                if (fVerbose) cout<<"AliAnalysisTaskDiHadronPID::UserExec: Mixing with trigger Z: "<<fTrigBuffer[iTrig][0]<<", Pt: "<<fTrigBuffer[iTrig][3]<<endl;
-                
-                for (Int_t iAssoc = 0; iAssoc < associateds->GetEntriesFast(); iAssoc++) {
-                    
-                    currentAssociated = (AliAODTrack*)(associateds->At(iAssoc));
-                    currentPIDPartner = GetTrackPartner(currentAssociated);
-                    //currentPIDObject = currentPIDPartner->GetDetPid();
-                    
-                    if (currentPIDPartner/*&&currentPIDObject*/) {
-                        
-                        Double_t DPhi = PhiRange(fTrigBuffer[iTrig][1] - currentAssociated->Phi());
-                        Double_t DEta = fTrigBuffer[iTrig][2] - currentAssociated->Eta();
-                        Double_t Ptassoc = currentAssociated->Pt();
-                        
-                        fMixedEvents->Fill(DPhi,DEta,Ptassoc);
-                    }
-                }
-            }
-        }
-    
-        // Copy the triggers from the current event into the buffer.
-        if (fAODVertex->GetZ()<10.) {
-        
-            if (fVerbose) cout<<"AliAnalysisTaskDiHadronPID::UserExec: Copying "<<triggers->GetEntriesFast()<<" triggers to the buffer with vertex z = "<<fAODVertex->GetZ()<<endl;
-        
-            for (Int_t iTrig = 0; iTrig<triggers->GetEntriesFast(); iTrig++) {
-            
-                currentTrigger = (AliAODTrack*)(triggers->At(iTrig));
-                if (fVerbose) cout<<"AliAnalysisTaskDiHadronPID::UserExec: Trigger pt = "<<currentTrigger->Pt()<<endl;
-            
-                fTrigBuffer[fTrigBufferIndex][0] = fAODVertex->GetZ();
-                fTrigBuffer[fTrigBufferIndex][1] = currentTrigger->Phi();
-                fTrigBuffer[fTrigBufferIndex][2] = currentTrigger->Eta();
-                fTrigBuffer[fTrigBufferIndex][3] = currentTrigger->Pt();
-                fTrigBufferIndex++;
-                if (fTrigBufferSize<25000) {fTrigBufferSize++;}
-                if (fTrigBufferIndex==25000) {fTrigBufferIndex=0;}
-            }
-        }
-    }        
-        
-    if (fVerbose) cout<<"AliAnalysisTaskDiHadronPID::UserExec: Trigger buffer index: "<<fTrigBufferIndex<<", and size: "<<fTrigBufferSize<<endl;
-    
-       delete triggers;
-       delete associateds;
-        
-       PostData(1,fHistoList);
-       
-}
-
-//_____________________________________________________________________________
-void AliAnalysisTaskDiHadronPID::Terminate(Option_t *)
-
-{
-       //
-       // Terminate.
-    //
-    
-}
-
+// ----------------------------------------------------------------------------\r
+// This class makes di-hadron correlations, with TOF and TPC signals for\r
+// the associated particles.\r
+//\r
+//   Last Update:\r
+//     - Added a number of setters/getters.\r
+//     - Added spectra in pt, eta and phi as a function of performed cuts.\r
+//     - Added DCA histogram.\r
+//     - Added pp functionality.\r
+//     - Added the option to make a DCA cut and an ITS cut.\r
+//     - Variable centrality.\r
+//     - Variable maximum p_T for triggers.\r
+//     - Removed di-hadron correlations with one PID signal.\r
+//\r
+// ----------------------------------------------------------------------------\r
+// Author: Misha Veldhoen (misha.veldhoen@cern.ch)\r
+// Last edit: Apr 12th 2012. (v 8.00)\r
+// ----------------------------------------------------------------------------\r
+\r
+#include <iostream>\r
+#include "TChain.h"\r
+#include "TTree.h"\r
+#include "TH1F.h"\r
+#include "TH2F.h"\r
+#include "TH3F.h"\r
+#include "TCanvas.h"\r
+#include "TFile.h"\r
+\r
+#include "AliAODTrack.h"\r
+#include "AliAODEvent.h"\r
+#include "AliAODInputHandler.h"\r
+#include "AliAODVertex.h"\r
+//#include "AliAODPid.h"\r
+\r
+#include "AliAnalysisManager.h"\r
+#include "AliInputEventHandler.h"\r
+#include "AliPIDResponse.h"\r
+#include "AliTPCPIDResponse.h"\r
+//#include "AliTOFPIDResponse.h"\r
+\r
+using namespace std;\r
+\r
+#include "AliAnalysisTaskDiHadronPID.h"\r
+\r
+ClassImp(AliAnalysisTaskDiHadronPID);\r
+\r
+//_____________________________________________________________________________\r
+AliAnalysisTaskDiHadronPID::AliAnalysisTaskDiHadronPID():\r
+       AliAnalysisTaskSE(),\r
+       fPIDResponse(0x0),\r
+       fAODEvent(0x0),\r
+       fAODHeader(0x0),\r
+       fAODVertex(0x0),\r
+       fAODTrack(0x0),\r
+       fGlobalTracks(0x0),\r
+       fCentrality(0x0),\r
+       fVertexZ(0x0),\r
+    fDCA(0x0),\r
+    fDCAZoomed(0x0),\r
+    fDCAZoomedTwice(0x0),\r
+    fDCACut(0x0),\r
+    fDCAZoomedCut(0x0),\r
+    fDCAZoomedTwiceCut(0x0),\r
+    fITSHits(0x0),\r
+    fTrackCutsCount(0x0),\r
+    fTrackCutsPt(0x0),\r
+    fTrackCutsEta(0x0),\r
+    fTrackCutsPhi(0x0),\r
+    fEtaSpectrumTrig(0x0),\r
+    fEtaSpectrumAssoc(0x0),\r
+    fPhiSpectrumAssoc(0x0),\r
+       fTPCnSigmaProton(0x0),\r
+       fTOFnSigmaProton(0x0),\r
+       fTPCnSigmaPion(0x0),\r
+       fTOFnSigmaPion(0x0),\r
+       fTPCnSigmaKaon(0x0),\r
+       fTOFnSigmaKaon(0x0),\r
+       fTPCSignal(0x0),\r
+       fTOFSignal(0x0),\r
+    fMixedEvents(0x0),\r
+       fHistoList(0x0),\r
+    fCalculateMixedEvents(kFALSE),\r
+    fBeamType("PbPb"),\r
+    fMaxEta(0.8),\r
+    fMaxPlotEta(0.9),\r
+    fMaxPt(10.),\r
+    fNEtaBins(25),\r
+    fNPhiBins(36),\r
+    fVertexZMixedEvents(2.),\r
+    fCentralityCutMax(0.),\r
+    fCentralityCutMin(10.),\r
+    fZoomed(kFALSE),\r
+    fDoITSCut(kFALSE),\r
+    fDoDCACut(kFALSE),\r
+    fDemandNoMismatch(kFALSE),\r
+    fVerbose(0),\r
+    fPrintBufferSize(kFALSE),\r
+       fTrigBufferIndex(0),    \r
+       fTrigBufferSize(0),\r
+       fTrigBufferMaxSize(1000)\r
+\r
+{\r
+    \r
+       //\r
+       // Default Constructor.\r
+       //\r
+       \r
+       // Trigger buffer.\r
+       for(Int_t ii=0; ii<25000; ii++) {\r
+               for(Int_t jj=0; jj<4; jj++) {\r
+                       fTrigBuffer[ii][jj]=0;\r
+               }                               \r
+       }       \r
+       \r
+    // The identified di-hadron correlations.\r
+       for (Int_t ii = 0; ii < 3; ii++) {\r
+               for (Int_t jj = 0; jj < 10; jj++) {\r
+                       fDiHadronTPCTOF[ii][jj]=0x0;\r
+               }\r
+       }\r
+    \r
+    // Track cut labels.\r
+    for (Int_t ii=0; ii<8; ii++) {\r
+        fTrackCutLabelNumbers[ii]=ii+1;\r
+    }\r
+}\r
+\r
+//_____________________________________________________________________________\r
+AliAnalysisTaskDiHadronPID::AliAnalysisTaskDiHadronPID(const char *name):\r
+       AliAnalysisTaskSE(name),\r
+    fPIDResponse(0x0),\r
+    fAODEvent(0x0),\r
+    fAODHeader(0x0),\r
+    fAODVertex(0x0),\r
+    fAODTrack(0x0),\r
+    fGlobalTracks(0x0),\r
+    fCentrality(0x0),\r
+    fVertexZ(0x0),\r
+    fDCA(0x0),\r
+    fDCAZoomed(0x0),\r
+    fDCAZoomedTwice(0x0),\r
+    fDCACut(0x0),\r
+    fDCAZoomedCut(0x0),\r
+    fDCAZoomedTwiceCut(0x0),\r
+    fITSHits(0x0),\r
+    fTrackCutsCount(0x0),\r
+    fTrackCutsPt(0x0),\r
+    fTrackCutsEta(0x0),\r
+    fTrackCutsPhi(0x0),\r
+    fEtaSpectrumTrig(0x0),\r
+    fEtaSpectrumAssoc(0x0),\r
+    fPhiSpectrumAssoc(0x0),\r
+    fTPCnSigmaProton(0x0),\r
+    fTOFnSigmaProton(0x0),\r
+    fTPCnSigmaPion(0x0),\r
+    fTOFnSigmaPion(0x0),\r
+    fTPCnSigmaKaon(0x0),\r
+    fTOFnSigmaKaon(0x0),\r
+    fTPCSignal(0x0),\r
+    fTOFSignal(0x0),\r
+    fMixedEvents(0x0),\r
+    fHistoList(0x0),\r
+    fCalculateMixedEvents(kFALSE),\r
+    fBeamType("PbPb"),\r
+    fMaxEta(0.8),\r
+    fMaxPlotEta(0.9),\r
+    fMaxPt(10.),\r
+    fNEtaBins(25),\r
+    fNPhiBins(36),\r
+    fVertexZMixedEvents(2.),\r
+    fCentralityCutMax(0.),\r
+    fCentralityCutMin(10.),\r
+    fZoomed(kFALSE),\r
+    fDoITSCut(kFALSE),\r
+    fDoDCACut(kFALSE),\r
+    fDemandNoMismatch(kFALSE),\r
+    fVerbose(0),\r
+    fPrintBufferSize(kFALSE),\r
+    fTrigBufferIndex(0),       \r
+    fTrigBufferSize(0),\r
+       fTrigBufferMaxSize(1000)\r
+\r
+{\r
+    \r
+       //\r
+       // Named Constructor.\r
+       //\r
+       \r
+       DefineInput(0, TChain::Class());\r
+       DefineOutput(1, TList::Class());\r
+       \r
+       // Trigger buffer.\r
+       for(Int_t ii=0; ii<25000; ii++) {\r
+               for(Int_t jj=0; jj<4; jj++) {\r
+                       fTrigBuffer[ii][jj]=0;\r
+               }                               \r
+       }       \r
+       \r
+    // The identified di-hadron correlations.\r
+       for (Int_t ii = 0; ii < 3; ii++) {\r
+               for (Int_t jj = 0; jj < 10; jj++) {\r
+                       fDiHadronTPCTOF[ii][jj]=0x0;\r
+               }\r
+       }\r
+    \r
+    // Track cut labels.\r
+    for (Int_t ii=0; ii<8; ii++) {\r
+        fTrackCutLabelNumbers[ii]=ii+1;\r
+    }\r
+}\r
+\r
+//_____________________________________________________________________________\r
+AliAnalysisTaskDiHadronPID::~AliAnalysisTaskDiHadronPID() {\r
+\r
+       //\r
+       // Destructor.\r
+       //\r
+       \r
+    if(fGlobalTracks) {\r
+        delete fGlobalTracks;\r
+        fGlobalTracks=0;\r
+    }\r
+\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AliAnalysisTaskDiHadronPID::UserCreateOutputObjects() \r
+\r
+{\r
+       //\r
+       // Output objects.\r
+       //\r
+    \r
+    // Print the settings of the analysis task.\r
+    cout<<endl;\r
+    cout<<"-----------------------------------------------"<<endl;\r
+    cout<<" AliAnalysisTaskDiHadronPID Settings:"<<endl;\r
+    cout<<"-----------------------------------------------"<<endl;\r
+    cout<<"Verbose Level: "<<fVerbose<<endl;\r
+    cout<<"Mixed Events Calculated: "<<fCalculateMixedEvents<<endl;\r
+    cout<<"Beam Type: "<<fBeamType<<endl;\r
+    cout<<Form("Max eta: %3.1f",fMaxEta)<<endl;\r
+    cout<<Form("Max eta plotted: %3.1f",fMaxPlotEta)<<endl;\r
+    cout<<Form("Max p_T for the triggers: %3.1f GeV/c.",fMaxPt)<<endl;\r
+    cout<<"Nbins in eta and delta eta: "<<fNEtaBins<<endl;\r
+    cout<<"Nbins in phi and delta phi: "<<fNPhiBins<<endl;\r
+    cout<<Form("Events mixed if vertices differ %3.1f cm.",fVertexZMixedEvents)<<endl;\r
+    cout<<Form("Centrality between %3.1f and %3.1f percent.",fCentralityCutMax,fCentralityCutMin)<<endl;\r
+    cout<<"Tracks are cut if less than 2 SPD hits: "<<fDoITSCut<<endl;\r
+    cout<<"Tracks cut if DCA is too big: "<<fDoDCACut<<endl;\r
+    cout<<"Tracks cut if there is a TPC-TOF mismatch: "<<fDemandNoMismatch<<endl;\r
+    cout<<"Maximum number of triggers stored: "<<fTrigBufferMaxSize<<endl;\r
+    cout<<"-----------------------------------------------"<<endl;\r
+    cout<<endl;\r
+    \r
+       // Obtain a pointer to the analysis manager.\r
+       AliAnalysisManager* manager = AliAnalysisManager::GetAnalysisManager();\r
+    if (!manager) {\r
+        if (fVerbose>0) cout<<"AliAnalysisTaskDiHadronPID::UserCreateOutputObjects -> ERROR: Analysis manager not found."<<endl;\r
+        return;\r
+    }\r
+    if (fVerbose>1) {\r
+        cout<<"AliAnalysisTaskDiHadronPID::UserCreateOutputObjects -> Analysis manager found."<<endl;\r
+    }\r
+    \r
+    // Obtain a pointer to the input handler.\r
+    AliInputEventHandler* inputHandler = dynamic_cast<AliInputEventHandler*> (manager->GetInputEventHandler());\r
+    if (!inputHandler) {\r
+        if (fVerbose>0) cout<<"AliAnalysisTaskDiHadronPID::UserCreateOutputObjects -> ERROR: Input handler not found."<<endl;\r
+        return;\r
+    }\r
+    if (fVerbose>1) {\r
+        cout<<"AliAnalysisTaskDiHadronPID::UserCreateOutputObjects -> Input handler found."<<endl;\r
+    }\r
+    \r
+       // Obtain a pointer to the PID response object. \r
+       fPIDResponse = inputHandler->GetPIDResponse();\r
+    if (!fPIDResponse) {\r
+        if (fVerbose>0) cout<<"AliAnalysisTaskDiHadronPID::UserCreateOutputObjects -> ERROR: PID response object not found."<<endl;\r
+        return;\r
+    }\r
+    if (fVerbose>1) {\r
+        cout<<"AliAnalysisTaskDiHadronPID::UserCreateOutputObjects -> PID response object found."<<endl;\r
+    }\r
+\r
+       // Create the output of the task.       \r
+       fHistoList = new TList();\r
+       fHistoList->SetOwner(kTRUE); \r
+       \r
+       // Ranges in dPhi, dEta, and the number of bins for di-hadron correlations.\r
+       Int_t binsHisto[4] = {fNPhiBins,fNEtaBins};\r
+       Double_t minHisto[4] = {-TMath::Pi()/2.,-2*fMaxPlotEta};\r
+       Double_t maxHisto[4] = {3.*TMath::Pi()/2,2*fMaxPlotEta};\r
+       \r
+    // --- EVENT QA PLOTS ---\r
+    \r
+       fCentrality = new TH1F("fCentrality","Centrality;Centrality;N_{evt}",100,0,100);\r
+       fHistoList->Add(fCentrality);\r
+       fVertexZ = new TH1F("fVertexZ","Vertex Z position;z (cm);N_{evt}",30,-15,15);\r
+       fHistoList->Add(fVertexZ);\r
+       \r
+    // --- TRACK QA PLOTS ---\r
+    \r
+    fDCA = new TH2F("fDCA","DCA positions TPC only cuts;xy (cm);z (cm)",100,-5,5,100,-5,5);\r
+    fHistoList->Add(fDCA);\r
+    fDCAZoomed = new TH2F("fDCAZoomed","DCA positions TPC only cuts;xy (cm);z (cm)",100,-.5,.5,100,-.5,.5);\r
+    fHistoList->Add(fDCAZoomed);\r
+    fDCAZoomedTwice = new TH2F("fDCAZoomedTwice","DCA positions TPC only cuts;xy (cm);z (cm)",100,-.05,.05,100,-.05,.05);\r
+    fHistoList->Add(fDCAZoomedTwice);\r
+    fDCACut = new TH2F("fDCACut","DCA positions after DCA cut;xy (cm);z (cm)",100,-5,5,100,-5,5);\r
+    fHistoList->Add(fDCACut);\r
+    fDCAZoomedCut = new TH2F("fDCAZoomedCut","DCA positions after DCA cut;xy (cm);z (cm)",100,-.5,.5,100,-.5,.5);\r
+    fHistoList->Add(fDCAZoomedCut);\r
+    fDCAZoomedTwiceCut = new TH2F("fDCAZoomedTwiceCut","DCA positions after DCA cut;xy (cm);z (cm)",100,-.05,.05,100,-.05,.05);\r
+    fHistoList->Add(fDCAZoomedTwiceCut);\r
+    \r
+    fITSHits = new TH1F("fITSHits","ITS hits",3,0,3);\r
+    (fITSHits->GetXaxis())->SetBinLabel(1,"No SPD hit");\r
+    (fITSHits->GetXaxis())->SetBinLabel(2,"One SPD hit");\r
+    (fITSHits->GetXaxis())->SetBinLabel(3,"Two SPD hits");\r
+    fHistoList->Add(fITSHits);\r
+    \r
+    // Determine the bins used in the track cut histograms.\r
+    const Int_t ncuts = 5 + fDoITSCut + fDoDCACut + fDemandNoMismatch;\r
+    \r
+    if (!fDoITSCut) {\r
+        fTrackCutLabelNumbers[3]--;\r
+        fTrackCutLabelNumbers[4]--;\r
+        fTrackCutLabelNumbers[5]--;\r
+        fTrackCutLabelNumbers[6]--;\r
+        fTrackCutLabelNumbers[7]--;\r
+    }\r
+    \r
+    if (!fDoDCACut) {\r
+        fTrackCutLabelNumbers[4]--;\r
+        fTrackCutLabelNumbers[5]--;\r
+        fTrackCutLabelNumbers[6]--;\r
+        fTrackCutLabelNumbers[7]--;\r
+    }\r
+    \r
+    fTrackCutsCount = new TH1F("fTrackCutsCount","Track Cuts;;Count",ncuts,0,ncuts);\r
+    (fTrackCutsCount->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[0],"Std. TPC Only");\r
+    (fTrackCutsCount->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[1],Form("#eta < %3.1f",fMaxEta));\r
+    if (fDoITSCut) (fTrackCutsCount->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[2],"1-2 SPD hits");\r
+    if (fDoDCACut) (fTrackCutsCount->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[3],"DCA cut");\r
+    (fTrackCutsCount->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[4],"p_{T} < 5.0 GeV/c");\r
+    (fTrackCutsCount->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[5],"TPCpid (p_{T} < 5.0 GeV/c)");\r
+    (fTrackCutsCount->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[6],"TOFpid (p_{T} < 5.0 GeV/c)");\r
+    if (fDemandNoMismatch) (fTrackCutsCount->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[7],"No Mismatch (p_{T} < 5.0 GeV/c)");\r
+    fHistoList->Add(fTrackCutsCount);\r
+    \r
+    fTrackCutsPt = new TH2F("fTrackCutsPt","Track Cuts vs p_{T};;p_{T};Count",ncuts,0,ncuts,40,0,fMaxPt);\r
+    (fTrackCutsPt->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[0],"Std. TPC Only");\r
+    (fTrackCutsPt->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[1],Form("#eta < %3.1f",fMaxEta));\r
+    if (fDoITSCut) (fTrackCutsPt->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[2],"1-2 SPD hits");\r
+    if (fDoDCACut) (fTrackCutsPt->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[3],"DCA cut");\r
+    (fTrackCutsPt->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[4],"p_{T} < 5.0 GeV/c");\r
+    (fTrackCutsPt->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[5],"TPCpid (p_{T} < 5.0 GeV/c)");\r
+    (fTrackCutsPt->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[6],"TOFpid (p_{T} < 5.0 GeV/c)");\r
+    if (fDemandNoMismatch) (fTrackCutsPt->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[7],"No Mismatch (p_{T} < 5.0 GeV/c)");\r
+    fHistoList->Add(fTrackCutsPt);\r
+    \r
+    fTrackCutsEta = new TH2F("fTrackCutsEta","Track Cuts vs #eta;;#eta;Count",ncuts,0,ncuts,4*binsHisto[1],-fMaxPlotEta,fMaxPlotEta);\r
+    (fTrackCutsEta->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[0],"Std. TPC Only");\r
+    (fTrackCutsEta->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[1],Form("#eta < %3.1f",fMaxEta));\r
+    if (fDoITSCut) (fTrackCutsEta->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[2],"1-2 SPD hits");\r
+    if (fDoDCACut) (fTrackCutsEta->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[3],"DCA cut");\r
+    (fTrackCutsEta->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[4],"p_{T} < 5.0 GeV/c");\r
+    (fTrackCutsEta->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[5],"TPCpid (p_{T} < 5.0 GeV/c)");\r
+    (fTrackCutsEta->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[6],"TOFpid (p_{T} < 5.0 GeV/c)");\r
+    if (fDemandNoMismatch) (fTrackCutsEta->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[7],"No Mismatch (p_{T} < 5.0 GeV/c)");\r
+    fHistoList->Add(fTrackCutsEta);\r
+    \r
+    fTrackCutsPhi = new TH2F("fTrackCutsPhi","Track Cuts vs #phi;;#phi;Count",ncuts,0,ncuts,72,0,2.*TMath::Pi());\r
+    (fTrackCutsPhi->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[0],"Std. TPC Only");\r
+    (fTrackCutsPhi->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[1],Form("#eta < %3.1f",fMaxEta));\r
+    if (fDoITSCut) (fTrackCutsPhi->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[2],"1-2 SPD hits");\r
+    if (fDoDCACut) (fTrackCutsPhi->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[3],"DCA cut");\r
+    (fTrackCutsPhi->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[4],"p_{T} < 5.0 GeV/c");\r
+    (fTrackCutsPhi->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[5],"TPCpid (p_{T} < 5.0 GeV/c)");\r
+    (fTrackCutsPhi->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[6],"TOFpid (p_{T} < 5.0 GeV/c)");\r
+    if (fDemandNoMismatch) (fTrackCutsPhi->GetXaxis())->SetBinLabel(fTrackCutLabelNumbers[7],"No Mismatch (p_{T} < 5.0 GeV/c)");\r
+    fHistoList->Add(fTrackCutsPhi);\r
+    \r
+    fEtaSpectrumTrig = new TH1F("fEtaSpectrumTrig","#eta Spectrum Triggers;#eta;Count",4*binsHisto[1],-fMaxPlotEta,fMaxPlotEta);\r
+    fHistoList->Add(fEtaSpectrumTrig);\r
+    fEtaSpectrumAssoc = new TH2F("fEtaSpectrumAssoc","#eta Spectrum Associateds;#eta;p_{T};Count",4*binsHisto[1],-fMaxPlotEta,fMaxPlotEta,10,0.,5.);\r
+    fHistoList->Add(fEtaSpectrumAssoc); \r
+    fPhiSpectrumAssoc = new TH2F("fPhiSpectrumAssoc","#phi Spectrum Associateds;#phi;p_{T};Count",72,0,2.*TMath::Pi(),10,0.,5.);\r
+    fHistoList->Add(fPhiSpectrumAssoc);\r
+       \r
+    // --- QA PLOTS PID ---\r
+    \r
+       fTPCnSigmaProton = new TH2F("fTPCnSigmaProton","n#sigma plot for the TPC (Protons);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);\r
+       fHistoList->Add(fTPCnSigmaProton);\r
+       fTOFnSigmaProton = new TH2F("fTOFnSigmaProton","n#sigma plot for the TOF (Protons);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);\r
+       fHistoList->Add(fTOFnSigmaProton);\r
+       fTPCnSigmaPion = new TH2F("fTPCnSigmaPion","n#sigma plot for the TPC (Pions);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);\r
+       fHistoList->Add(fTPCnSigmaPion);\r
+       fTOFnSigmaPion = new TH2F("fTOFnSigmaPion","n#sigma plot for the TOF (Pions);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);\r
+       fHistoList->Add(fTOFnSigmaPion);\r
+       fTPCnSigmaKaon = new TH2F("fTPCnSigmaKaon","n#sigma plot for the TPC (Kaons);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);\r
+       fHistoList->Add(fTPCnSigmaKaon);\r
+       fTOFnSigmaKaon = new TH2F("fTOFnSigmaKaon","n#sigma plot for the TOF (Kaons);p (GeV/c);n#sigma",100,0.,5.,100,-10.,10.);\r
+       fHistoList->Add(fTOFnSigmaKaon);        \r
+       fTPCSignal = new TH3F("fTPCSignal","TPC Signal;#eta;p_{T} GeV/c;dE/dx",25,-fMaxEta,fMaxEta,100,0.,5.,150,0.,300.);\r
+       fHistoList->Add(fTPCSignal);\r
+       fTOFSignal = new TH3F("fTOFSignal","TOF Signal;#eta;p_{T} GeV/c;t",25,-fMaxEta,fMaxEta,100,0.,5.,150,10000.,25000.);\r
+       fHistoList->Add(fTOFSignal);\r
+                       \r
+    // --- DI-HADRON CORRELATIONS WITH TPC AND TOF SIGNALS ---\r
+    \r
+       // Di Hadron Correlations with two PID signals, for each p_T bin and particle species separately. (i.e. 30 histo's) \r
+       // Axes: {Dphi, Deta, TPC signal, TOF signal}\r
+    \r
+    // Unzoomed pictures.\r
+       Int_t binsTPCnoZoom[3][10] = {{100,100,100,100,100,100,100,100,100,100},\r
+                                  {100,100,100,100,100,100,100,100,100,100},\r
+                                  {100,100,100,100,100,100,100,100,100,100}};\r
+               \r
+       Double_t minTPCnoZoom[3][10] = {{   -50., -50.,-30.,-30.,-30.,-30.,-30.,-30.,-30.,-30.},\r
+                                    {  -100., -50.,-20.,-20.,-20.,-20.,-20.,-20.,-20.,-20.},\r
+                                    {  -200.,-150.,-50.,-30.,-20.,-20.,-20.,-20.,-20.,-20.}};\r
+       Double_t maxTPCnoZoom[3][10] = {{ 150., 100., 50., 30., 25., 25., 25., 25., 25., 25.},\r
+                                    {  50., 100., 40., 30., 30., 30., 30., 30., 30., 30.},\r
+                                    { 100.,  50., 50., 30., 30., 30., 30., 30., 30., 30.}};\r
+       \r
+       Int_t binsTOFnoZoom[3][10] = {{100,100,100,100,100,100,100,100,100,100},\r
+                                  {100,100,100,100,100,100,100,100,100,100},\r
+                                  {100,100,100,100,100,100,100,100,100,100}};\r
+       \r
+       Double_t minTOFnoZoom[3][10] = {{-2000.,-2000.,-1000., -500., -500., -500., -500.,      -500., -500., -500.},\r
+                                    {-2000.,-2000.,-2000.,-1000.,-1000.,-1000.,-1000.,-1000.,-1000.,-1000.},\r
+                                    {-2000.,-2000.,-6000.,-3000.,-2000.,-1500.,-1500.,-1500.,-1500.,-1500.}};\r
+       Double_t maxTOFnoZoom[3][10] = {{ 2000., 2000., 5000., 3000., 2000., 1500., 1500., 1500., 1500., 1500.},\r
+                                    { 2000., 2000., 5000., 2000., 1500., 1500., 1500., 1500., 1500., 1500.},\r
+                                    { 2000., 2000., 2000., 1000., 1000., 1000., 1000., 1000., 1000., 1000.}};\r
+    \r
+    // Zoomed pictures.\r
+    Int_t binsTPCZoom[3][10] = {{100,100,100,100,100,100,100,100,100,100},\r
+                                {100,100,100,100,100,100,100,100,100,100},\r
+                                {100,100,100,100,100,100,100,100,100,100}};\r
+    \r
+       Double_t minTPCZoom[3][10] = {{   -20., -20.,-20.,-20.,-20.,-20.,-20.,-20.,-20.,-20.},\r
+                                  {     -20., -20.,-20.,-20.,-20.,-20.,-20.,-20.,-20.,-20.},\r
+                                  {   -40., -20.,-20.,-20.,-20.,-20.,-20.,-20.,-20.,-20.}};\r
+       Double_t maxTPCZoom[3][10] = {{  20.,  20., 20., 20., 20., 20., 20., 20., 20., 20.},\r
+                                  {  20.,  20., 20., 20., 20., 20., 20., 20., 20., 20.},\r
+                                  {  40.,  20., 20., 20., 20., 30., 30., 30., 30., 30.}};\r
+       \r
+       Int_t binsTOFZoom[3][10] = {{100,100,100,100,100,100,100,100,100,100},\r
+                                {100,100,100,100,100,100,100,100,100,100},\r
+                                {100,100,100,100,100,100,100,100,100,100}};\r
+       \r
+       Double_t minTOFZoom[3][10] = {{-1000.,-1000., -500., -500., -500., -400., -400., -400., -400., -400.},\r
+                                  { -800., -800., -800., -800., -800., -600., -500., -500., -400., -400.},\r
+                                  {-1000.,-1000.,-1000.,-1000., -800.,-1000.,-1000., -800., -700., -700.}};\r
+       Double_t maxTOFZoom[3][10] = {{ 1000., 1000., 1000., 1000., 1000., 1000., 1000.,  900.,  800.,  700.},\r
+                                  { 1000., 1000.,  500.,  500.,  500.,  900.,  700.,  700.,  600.,  500.},\r
+                                  { 1000., 1000., 1000.,  500.,  500.,  500.,  500.,  500.,  500.,  500.}};\r
+    \r
+       TString basenameTPCTOF("fDiHadronTPCTOF");\r
+       TString basetitle("Di-Hadron correlation");\r
+       TString finalname, finaltitle;\r
+       TString species[3] = {"Pion","Kaon","Proton"};\r
+       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"};\r
+    \r
+       // Recall that AliPID::kPion = 2, AliPID::kKaon = 3, AliPID::kProton = 4.\r
+       for (Int_t iSpecies = 0; iSpecies < 3; iSpecies++) {\r
+                               \r
+               for (Int_t iPtBin = 0; iPtBin < 10; iPtBin++) {\r
+                       \r
+            if (fZoomed) {\r
+                binsHisto[2] = binsTPCZoom[iSpecies][iPtBin];\r
+                binsHisto[3] = binsTOFZoom[iSpecies][iPtBin];\r
+                minHisto[2] = minTPCZoom[iSpecies][iPtBin];\r
+                minHisto[3] = minTOFZoom[iSpecies][iPtBin];\r
+                maxHisto[2] = maxTPCZoom[iSpecies][iPtBin];\r
+                maxHisto[3] = maxTOFZoom[iSpecies][iPtBin];\r
+            } else {\r
+                binsHisto[2] = binsTPCnoZoom[iSpecies][iPtBin];\r
+                binsHisto[3] = binsTOFnoZoom[iSpecies][iPtBin];\r
+                minHisto[2] = minTPCnoZoom[iSpecies][iPtBin];\r
+                minHisto[3] = minTOFnoZoom[iSpecies][iPtBin];\r
+                maxHisto[2] = maxTPCnoZoom[iSpecies][iPtBin];\r
+                maxHisto[3] = maxTOFnoZoom[iSpecies][iPtBin];\r
+            }\r
+\r
+            // Make the di-hadron correlations with different pid signals.\r
+            // TODO: Rewrite this with Form().\r
+            finaltitle = basetitle;\r
+                       (((((finaltitle += " (") += species[iSpecies]) += ") ") += ptbins[iPtBin]) += " < P_t < ") += ptbins[iPtBin+1];\r
+            finaltitle+=";#Delta#phi;#Delta#eta;dE/dx;t (ms)";\r
+            finalname = basenameTPCTOF;\r
+                       (((finalname += "_") += species[iSpecies]) += "_") += iPtBin;\r
+            \r
+            fDiHadronTPCTOF[iSpecies][iPtBin] = new THnSparseF(finalname,finaltitle,4,binsHisto,minHisto,maxHisto);\r
+            fHistoList->Add(fDiHadronTPCTOF[iSpecies][iPtBin]);\r
+            \r
+               }\r
+       }\r
+    \r
+    // --- MIXED EVENTS ---\r
+    \r
+    if (fCalculateMixedEvents) {\r
+        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.);\r
+        fMixedEvents->Sumw2();\r
+        fHistoList->Add(fMixedEvents);\r
+    }\r
+    \r
+       PostData(1, fHistoList);\r
+       \r
+}\r
+\r
+//_____________________________________________________________________________\r
+Int_t AliAnalysisTaskDiHadronPID::ClassifyTrack(AliAODTrack *track)\r
+\r
+{\r
+       //\r
+    // This function both classifies tracks, and fills the track QA histograms.\r
+    //\r
+    // Classifies the track in:\r
+    //  0 -> Not Useful,\r
+    //  1 -> Associated,\r
+    //  2 -> Trigger.\r
+    //\r
+    // IDEA: later we can do this with filterbits.\r
+    //\r
+    // The following track cuts are applied for triggers:\r
+    //\r
+    // 1a) pT > 5.0 GeV/c, pT < fPtMax,\r
+    //  2) StandardTPCOnlyTrackCuts (filterbit 7 for AOD's),\r
+    //  3) eta < fMaxEta,\r
+    //  4) ITS track cut, a track is only selected if it has at least one hit in the SPD,\r
+    //     that is, in one of the first two layers of the ITS. (can be switched on and off\r
+    //     using (Bool_t)fDoITSCut),\r
+    //  5) DCA track cut, of all tracks with at least one SPD hit, the DCA is constrained as\r
+    //     a function of pT, in order to remove lots of the secondaries. (can be switched on and \r
+    //     off by using (Bool_t)fDoDCACut),\r
+    //\r
+    // For associateds all the same track cuts are applied, except 1a is\r
+    // replaced by 2b. Moreover the following cuts are applied too:\r
+    //\r
+    // 1b) pT < 5.0 GeV/c,\r
+    //  6) TPCpid,\r
+    //  7) TOFpid,\r
+    //  8) no TPCTOF mismatch.\r
+    //\r
+    \r
+    // Check if a track is supplied.\r
+    if (!track) {\r
+        if (fVerbose>0) cout<<"AliAnalysisTaskDiHadronPID::SelectTrack -> ERROR: No track found."<<endl;\r
+        return 0;\r
+    }\r
+    \r
+    // Get basic track information.\r
+    Int_t classification=0;\r
+    Double_t pt = track->Pt();\r
+    Double_t eta = track->Eta();\r
+    Double_t phi = track->Phi();\r
+       \r
+    // 1) pT cut: First separation between triggers and associateds.\r
+    if (pt<5.0) classification=1;\r
+    if ((pt>5.0)&&(pt<fMaxPt)) classification = 2;\r
+    if (!classification) return 0;\r
+    \r
+    // 2) StandardTPCOnlyTrackCuts.\r
+    if (!(track->TestFilterMask(1<<7))) {\r
+               //if (fVerbose>3) cout<<"Track Ignored: Did Not pass filterbit."<<endl;\r
+               return 0;\r
+       }\r
+       \r
+       if (fVerbose>3) {\r
+               cout<<endl;\r
+               cout<<"pt: "<<pt<<" eta: "<<eta<<" phi: "<<phi<<endl;\r
+       }\r
+       \r
+    fTrackCutsCount->Fill(fTrackCutLabelNumbers[0]-.5);\r
+    fTrackCutsPt->Fill(fTrackCutLabelNumbers[0]-.5,pt);\r
+    fTrackCutsEta->Fill(fTrackCutLabelNumbers[0]-.5,eta);\r
+    fTrackCutsPhi->Fill(fTrackCutLabelNumbers[0]-.5,phi);\r
+    \r
+    // 3) eta cut.\r
+    if (TMath::Abs(eta)>fMaxEta) {\r
+               if (fVerbose>3) cout<<"Track Ignored: Eta too large."<<endl;\r
+               return 0;\r
+    }\r
+       \r
+    fTrackCutsCount->Fill(fTrackCutLabelNumbers[1]-.5);\r
+    fTrackCutsPt->Fill(fTrackCutLabelNumbers[1]-.5,pt);\r
+    fTrackCutsEta->Fill(fTrackCutLabelNumbers[1]-.5,eta);\r
+    fTrackCutsPhi->Fill(fTrackCutLabelNumbers[1]-.5,phi);\r
+    \r
+    // Obtaining ITS information.\r
+    AliAODTrack* globaltrack = GetGlobalTrack(track);\r
+    Bool_t ITSLayerHit[6];\r
+    for (Int_t iITSLayer=0; iITSLayer<6; iITSLayer++) {\r
+        ITSLayerHit[iITSLayer] = globaltrack->HasPointOnITSLayer(iITSLayer);\r
+    }\r
+    Int_t SPDHits=ITSLayerHit[0]+ITSLayerHit[1];\r
+    \r
+       if (fVerbose>3) cout<<"SPD hits: "<<SPDHits<<endl;\r
+       \r
+    // Fill the ITS hist.\r
+    fITSHits->Fill(SPDHits+0.5);\r
+\r
+    // 4) ITS cut.\r
+    if (fDoITSCut) {\r
+        if (!SPDHits) {\r
+                       if (fVerbose>3) cout<<"Track Ignored: Not enough SPD hits."<<endl;\r
+                       return 0;\r
+               }\r
+        fTrackCutsCount->Fill(fTrackCutLabelNumbers[2]-.5);\r
+        fTrackCutsPt->Fill(fTrackCutLabelNumbers[2]-.5,pt);\r
+        fTrackCutsEta->Fill(fTrackCutLabelNumbers[2]-.5,eta);\r
+        fTrackCutsPhi->Fill(fTrackCutLabelNumbers[2]-.5,phi);\r
+    }\r
+        \r
+    // Propagate the global track to the DCA.\r
+    Double_t PosAtDCA[2] = {-999,-999};\r
+    Double_t covar[3] = {-999,-999,-999};\r
+    globaltrack->PropagateToDCA(fAODVertex,fAODEvent->GetMagneticField(),100.,PosAtDCA,covar);\r
+        \r
+    // Fill the DCA hist (before cut)\r
+    fDCA->Fill(PosAtDCA[0],PosAtDCA[1]);\r
+    fDCAZoomed->Fill(PosAtDCA[0],PosAtDCA[1]);\r
+    fDCAZoomedTwice->Fill(PosAtDCA[0],PosAtDCA[1]);\r
+    \r
+    // 5) DCA cut (See R_AA paper).\r
+    Double_t DCAcutvalue[2];\r
+    DCAcutvalue[0] = 0.018 + 0.035*TMath::Power(pt,-1.01);\r
+    DCAcutvalue[1] = 2.; \r
+    if (fDoDCACut) {\r
+        if (SPDHits&&((TMath::Abs(PosAtDCA[0])>DCAcutvalue[0])||(TMath::Abs(PosAtDCA[1])>DCAcutvalue[1]))) {\r
+                       if (fVerbose>3) cout<<"Track Ignored: Enough SPD hits, but out of DCA range."<<endl;\r
+                       return 0;\r
+               }\r
+        fTrackCutsCount->Fill(fTrackCutLabelNumbers[3]-.5);\r
+        fTrackCutsPt->Fill(fTrackCutLabelNumbers[3]-.5,pt);\r
+        fTrackCutsEta->Fill(fTrackCutLabelNumbers[3]-.5,eta);\r
+        fTrackCutsPhi->Fill(fTrackCutLabelNumbers[3]-.5,phi);\r
+        \r
+        // Fill the DCA hist (after cut)\r
+        fDCACut->Fill(PosAtDCA[0],PosAtDCA[1]);\r
+        fDCAZoomedCut->Fill(PosAtDCA[0],PosAtDCA[1]);\r
+        fDCAZoomedTwiceCut->Fill(PosAtDCA[0],PosAtDCA[1]);\r
+    }\r
+    \r
+    // Now all the common cuts have been performed. Tracks identified as a trigger will\r
+    // be returned. Note that they will not appear in the histograms after track cut 5.\r
+    if (classification==2) return 2;\r
+    \r
+    // Now we're left with only tracks with pT < 5.0 GeV/c. \r
+    fTrackCutsCount->Fill(fTrackCutLabelNumbers[4]-.5);\r
+    fTrackCutsPt->Fill(fTrackCutLabelNumbers[4]-.5,pt);\r
+    fTrackCutsEta->Fill(fTrackCutLabelNumbers[4]-.5,eta);\r
+    fTrackCutsPhi->Fill(fTrackCutLabelNumbers[4]-.5,phi);\r
+    \r
+    // Obtain the status of the track.\r
+    ULong_t status = globaltrack->GetStatus();\r
+    \r
+    // 6) TPCpid\r
+    if (!((status&AliAODTrack::kTPCpid)==AliAODTrack::kTPCpid)) {\r
+               if (fVerbose>3) cout<<"Track Ignored: No TPC pid."<<endl;\r
+               return 0;\r
+       }\r
+    \r
+    fTrackCutsCount->Fill(fTrackCutLabelNumbers[5]-.5);\r
+    fTrackCutsPt->Fill(fTrackCutLabelNumbers[5]-.5,pt);\r
+    fTrackCutsEta->Fill(fTrackCutLabelNumbers[5]-.5,eta);\r
+    fTrackCutsPhi->Fill(fTrackCutLabelNumbers[5]-.5,phi);\r
+    \r
+    // 7) TOFpid\r
+    if (!((status&AliAODTrack::kTOFpid)==AliAODTrack::kTOFpid)) {\r
+               if (fVerbose>3) cout<<"Track Ignored: No TOF pid."<<endl;\r
+               return 0;\r
+       }\r
+    \r
+    fTrackCutsCount->Fill(fTrackCutLabelNumbers[6]-.5);\r
+    fTrackCutsPt->Fill(fTrackCutLabelNumbers[6]-.5,pt);\r
+    fTrackCutsEta->Fill(fTrackCutLabelNumbers[6]-.5,eta);\r
+    fTrackCutsPhi->Fill(fTrackCutLabelNumbers[6]-.5,phi);\r
+    \r
+    // 8) TPC, TOF mismatch.\r
+    if (fDemandNoMismatch) {\r
+        if ((status&AliAODTrack::kTOFmismatch)==AliAODTrack::kTOFmismatch) {\r
+                       if (fVerbose>3) cout<<"Track Ignored: TOF mismatch found."<<endl;\r
+                       return 0;\r
+               }\r
+        fTrackCutsCount->Fill(fTrackCutLabelNumbers[7]-.5);\r
+        fTrackCutsPt->Fill(fTrackCutLabelNumbers[7]-.5,pt);\r
+        fTrackCutsEta->Fill(fTrackCutLabelNumbers[7]-.5,eta);\r
+        fTrackCutsPhi->Fill(fTrackCutLabelNumbers[7]-.5,phi);\r
+    }\r
+    \r
+    // All tracks which made it up to here are classified as associateds.\r
+    \r
+    // Fill the PID QA histograms.\r
+    Double_t mom, nSigma;\r
+    \r
+    mom = globaltrack->GetTPCmomentum();\r
+    nSigma = fPIDResponse->NumberOfSigmasTPC(globaltrack,AliPID::kProton);\r
+    fTPCnSigmaProton->Fill(mom,nSigma);\r
+    nSigma = fPIDResponse->NumberOfSigmasTPC(globaltrack,AliPID::kPion);\r
+    fTPCnSigmaPion->Fill(mom,nSigma);\r
+    nSigma = fPIDResponse->NumberOfSigmasTPC(globaltrack,AliPID::kKaon);\r
+    fTPCnSigmaKaon->Fill(mom,nSigma);\r
+    \r
+    fTPCSignal->Fill(eta,pt,globaltrack->GetTPCsignal());\r
+    \r
+    mom =globaltrack->P();\r
+    nSigma = fPIDResponse->NumberOfSigmasTOF(globaltrack,AliPID::kProton);\r
+    fTOFnSigmaProton->Fill(mom,nSigma);                        \r
+    nSigma = fPIDResponse->NumberOfSigmasTOF(globaltrack,AliPID::kPion);\r
+    fTOFnSigmaPion->Fill(mom,nSigma);  \r
+    nSigma = fPIDResponse->NumberOfSigmasTOF(globaltrack,AliPID::kKaon);\r
+    fTOFnSigmaKaon->Fill(mom,nSigma);\r
+    \r
+    fTOFSignal->Fill(eta,pt,globaltrack->GetTOFsignal());\r
+    \r
+    // Return associated.\r
+    return 1;\r
+    \r
+} \r
+    \r
+//____________________________________________________________________________\r
+Bool_t AliAnalysisTaskDiHadronPID::SelectEvent(AliAODVertex* vertex)\r
+\r
+{\r
+       \r
+       //\r
+       // Event Selection.\r
+       //\r
+       \r
+       Double_t primVtx[3];\r
+       vertex->GetXYZ(primVtx);\r
+       if (TMath::Sqrt(primVtx[0]*primVtx[0] + primVtx[1]*primVtx[1])>1. || TMath::Abs(primVtx[2])>10.) {\r
+               if (fVerbose>2) cout << "AliAnalysisTaskDiHadronPID::SelectEvent -> Vertex Out of Range." << endl;\r
+        if (fVerbose>2) cout << "AliAnalysisTaskDiHadronPID::SelectEvent -> Event not selected." << endl;\r
+               return kFALSE;\r
+       }\r
+       if (fVerbose>2) cout << "AliAnalysisTaskDiHadronPID::SelectEvent -> Vertex is OK." << endl;\r
+    \r
+    // We also wish to make centrality cut, but only if run on Pb+Pb.\r
+    if (fBeamType=="PbPb") {\r
+        Double_t cent = fAODHeader->GetCentrality();\r
+        if (cent>fCentralityCutMin||cent<fCentralityCutMax) {\r
+            if (fVerbose>2) cout<<"AliAnalysisTaskDiHadronPID::SelectEvent -> Event did not pass centaltity cut."<<endl;\r
+            return kFALSE;\r
+        }\r
+    }\r
+\r
+    if (fVerbose>2) cout << "AliAnalysisTaskDiHadronPID::SelectEvent -> Event selected." << endl;\r
+       return kTRUE;\r
+       \r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AliAnalysisTaskDiHadronPID::FillGlobalTracksArray() {\r
+\r
+       // Initialize the mapping for corresponding PID tracks. (see\r
+       // GetGlobalTrack(AliAODTrack* track)). \r
+       //\r
+       \r
+       if (!fAODEvent) {\r
+        if (fVerbose>0) cout << "AliAnalysisTaskDiHadronPID::FillGlobalTracksArray -> ERROR: fAODEvent not set." << endl;\r
+               return;\r
+       }\r
+       \r
+       fGlobalTracks = new TObjArray();\r
+       AliAODTrack* track = 0x0;\r
+               \r
+       for (Int_t iTrack = 0; iTrack < fAODEvent->GetNumberOfTracks(); iTrack++) {\r
+               \r
+               track = fAODEvent->GetTrack(iTrack);\r
+               \r
+               // I.e., if it does NOT pass the filtermask.\r
+               if (!(track->TestFilterMask(1<<7))) {\r
+            if (track->GetID()>-1) fGlobalTracks->AddAtAndExpand(track,track->GetID());\r
+            //if (track->GetID()<1) cout<<"Track ID: "<<track->GetID()<<" Partner ID: "<<(-track->GetID()-1)<<endl;\r
+               }\r
+        \r
+       }\r
+       \r
+}\r
+\r
+//_____________________________________________________________________________\r
+AliAODTrack* AliAnalysisTaskDiHadronPID::GetGlobalTrack(AliAODTrack* track) {\r
+       \r
+       //\r
+       // Returns the "parner track" of track, which contains the pid information.\r
+       //\r
+       \r
+       AliAODTrack* partner = 0x0;\r
+           \r
+    partner = (AliAODTrack*)(fGlobalTracks->At(-track->GetID()-1));\r
+           \r
+       if (!partner&&(fVerbose>3)) cout<<"AliAnalysisTaskDiHadronPID::GetGlobalTrack -> No Global Track Found!"<<endl;\r
+       \r
+       return partner;\r
+       \r
+}\r
+\r
+//_____________________________________________________________________________\r
+Double_t AliAnalysisTaskDiHadronPID::PhiRange(Double_t DPhi)\r
+\r
+{\r
+       //\r
+       // Puts the argument in the range [-pi/2,3 pi/2].\r
+       //\r
+       \r
+       if (DPhi < -TMath::Pi()/2) DPhi += 2*TMath::Pi();\r
+       if (DPhi > 3*TMath::Pi()/2) DPhi -= 2*TMath::Pi();      \r
+\r
+       return DPhi;\r
+       \r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AliAnalysisTaskDiHadronPID::UserExec(Option_t *)\r
+\r
+{\r
+       //\r
+       // UserExec.\r
+       //\r
+       \r
+       // Input the event.\r
+       fAODEvent = dynamic_cast<AliAODEvent*>(InputEvent());\r
+       if (!fAODEvent) {\r
+               if (fVerbose>0) cout << "AliAnalysisTaskDiHadronPID::UserExec -> ERROR: No AliAODEvent pointer could be created." << endl;\r
+               return;\r
+       }\r
+       \r
+       // Get the event header.\r
+       fAODHeader = fAODEvent->GetHeader();\r
+       if (!fAODHeader) {\r
+               if (fVerbose>0) cout << "AliAnalysisTaskDiHadronPID::UserExec -> ERROR: No AliAODHeader pointer could be created."<<endl;\r
+               return;\r
+       }\r
+       \r
+       // Get the event vertex.\r
+       fAODVertex = fAODEvent->GetPrimaryVertex();\r
+       if (!fAODVertex) {\r
+               if (fVerbose>0) cout << "AliAnalysisTaskDiHadronPID::UserExec -> ERROR: No AliAODVertex pointer could be created." << endl;\r
+               return;\r
+       }\r
+\r
+    // See if the event passes the event selection.\r
+    if (!SelectEvent(fAODVertex)) return;\r
+    \r
+       // Display basic event information.\r
+       if ((fVerbose>2)) cout << endl;\r
+       if ((fVerbose>2)&&(fBeamType=="PbPb")) cout << "Event centrality: " << fAODHeader->GetCentrality() << endl;\r
+       if ((fVerbose>2)) cout << "Event Vertex Z: " << fAODVertex->GetZ() << endl;\r
+       if ((fVerbose>2)) cout << "Event tracks in AOD: " << fAODEvent->GetNumberOfTracks() << endl;\r
+       if ((fVerbose>2)) cout << endl;\r
+\r
+    // Filling Event QA plots.\r
+       if (fBeamType=="PbPb") fCentrality->Fill(fAODHeader->GetCentrality());\r
+       fVertexZ->Fill(fAODVertex->GetZ());\r
+    \r
+       // Fill the TObjArray which holds Global tracks.\r
+       FillGlobalTracksArray();\r
+       \r
+       // Create object arrays for triggers and associateds.\r
+       TObjArray *triggers             = new TObjArray();\r
+       TObjArray *associateds  = new TObjArray();\r
+                   \r
+    // In this loop the triggers and associateds will be identified, track QA and PID QA histograms will be filled.\r
+       for (Int_t iTrack = 0; iTrack < fAODEvent->GetNumberOfTracks(); iTrack++) {\r
+        \r
+        // Obtain a pointer to the track.\r
+               fAODTrack = fAODEvent->GetTrack(iTrack);\r
+        if (!fAODTrack&&(fVerbose>0)) {\r
+            cout << "AliAnalysisTaskDiHadronPID::UserExec -> ERROR: Track object not found." << endl;\r
+            continue;\r
+        }\r
+        \r
+        // Find the track classification.\r
+        Int_t tracktype = ClassifyTrack(fAODTrack);\r
+               \r
+        if (tracktype==0) {\r
+                       continue;\r
+               }\r
+               \r
+        if (tracktype==1) {\r
+                       if (fVerbose>3) cout<<"Track added to associated buffer."<<endl;\r
+            associateds->AddLast(fAODTrack);\r
+            fEtaSpectrumAssoc->Fill(fAODTrack->Eta(),fAODTrack->Pt());\r
+            fPhiSpectrumAssoc->Fill(fAODTrack->Phi(),fAODTrack->Pt());\r
+        }\r
+        \r
+        if (tracktype==2) {\r
+                       if (fVerbose>3) cout<<"Track added to trigger buffer."<<endl;\r
+            triggers->AddLast(fAODTrack);\r
+            fEtaSpectrumTrig->Fill(fAODTrack->Eta());\r
+        }\r
+        \r
+        \r
+    }\r
+    \r
+    // In This Loop the di-hadron correlation will be made.\r
+    Double_t histoFill[4];                  // {Dphi, Deta, TPC signal, TOF signal}\r
+    AliAODTrack* currentTrigger = 0x0;\r
+       AliAODTrack* currentAssociated = 0x0;\r
+       AliAODTrack* currentAssociatedGlobal = 0x0;\r
+    \r
+    AliTPCPIDResponse& TPCPIDResponse = fPIDResponse->GetTPCResponse();\r
+    \r
+    for (Int_t iTrig = 0; iTrig < triggers->GetEntriesFast(); iTrig++){\r
+        \r
+               currentTrigger = (AliAODTrack*)(triggers->At(iTrig));\r
+               \r
+               for (Int_t iAssoc = 0; iAssoc < associateds->GetEntriesFast(); iAssoc++) {\r
+            \r
+                       currentAssociated = (AliAODTrack*)(associateds->At(iAssoc));\r
+                       currentAssociatedGlobal = GetGlobalTrack(currentAssociated);\r
+            \r
+                       Double_t pt = currentAssociated->Pt();\r
+                       histoFill[0] = PhiRange(currentTrigger->Phi() - currentAssociated->Phi());\r
+                       histoFill[1] = currentTrigger->Eta() - currentAssociated->Eta();\r
+\r
+                       // Is there a caveat here when Pt = 5.00000000?\r
+                       const Int_t ptbin = (Int_t)(2*pt);\r
+                       \r
+                       if (currentAssociatedGlobal) {\r
+                               \r
+                // Get TPC (expected) signals.\r
+                               Double_t TPCmom = currentAssociatedGlobal->GetTPCmomentum();\r
+                Double_t TPCsignal = currentAssociatedGlobal->GetTPCsignal();\r
+                               Double_t expectedTPCsignalPion = TPCPIDResponse.GetExpectedSignal(TPCmom,AliPID::kPion);\r
+                Double_t expectedTPCsignalKaon = TPCPIDResponse.GetExpectedSignal(TPCmom,AliPID::kKaon);\r
+                               Double_t expectedTPCsignalProton = TPCPIDResponse.GetExpectedSignal(TPCmom,AliPID::kProton);\r
+\r
+                // Get TOF (expected) signals.\r
+                Double_t TOFsignal = currentAssociatedGlobal->GetTOFsignal();\r
+                Double_t times[AliPID::kSPECIES];\r
+                currentAssociatedGlobal->GetIntegratedTimes(times);\r
+                Double_t expectedTOFsignalPion = times[AliPID::kPion];\r
+                Double_t expectedTOFsignalKaon = times[AliPID::kKaon];\r
+                Double_t expectedTOFsignalProton = times[AliPID::kProton]; \r
+            \r
+                // Fill the histograms.\r
+                histoFill[2] = TPCsignal - expectedTPCsignalPion;\r
+                histoFill[3] = TOFsignal - expectedTOFsignalPion;\r
+                fDiHadronTPCTOF[0][ptbin]->Fill(histoFill);\r
+                \r
+                histoFill[2] = TPCsignal - expectedTPCsignalKaon;\r
+                histoFill[3] = TOFsignal - expectedTOFsignalKaon;\r
+                fDiHadronTPCTOF[1][ptbin]->Fill(histoFill);\r
+                \r
+                histoFill[2] = TPCsignal - expectedTPCsignalProton;\r
+                histoFill[3] = TOFsignal - expectedTOFsignalProton;\r
+                fDiHadronTPCTOF[2][ptbin]->Fill(histoFill);\r
+                \r
+                       }\r
+               }\r
+       }\r
+\r
+    // In this loop we calculate the mixed events.\r
+    if (fCalculateMixedEvents) {\r
+        \r
+        // Loop over the trigger buffer.\r
+        if (fVerbose>3) cout << "AliAnalysisTaskDiHadronPID::UserExec -> Mixing the events with "<<fTrigBufferSize<<" triggers from the buffer." <<endl;\r
+        if (fVerbose>3) cout << "AliAnalysisTaskDiHadronPID::UserExec -> Buffer size: "<<fTrigBufferIndex<<endl;\r
+        \r
+        for (Int_t iTrig=0;iTrig<fTrigBufferSize;iTrig++) {\r
+            \r
+            // Check if the trigger and the associated have a reconstructed\r
+            // vertext no further than 2cm apart.\r
+            \r
+            // fTrigBuffer[i][0] = z\r
+            // fTrigBuffer[i][1] = phi\r
+            // fTrigBuffer[i][2] = eta\r
+            // fTrigBuffer[i][3] = p_t\r
+            \r
+            if (TMath::Abs(fTrigBuffer[iTrig][0]-fAODVertex->GetZ())<fVertexZMixedEvents) {\r
+                \r
+                if (fVerbose>3) cout<<"AliAnalysisTaskDiHadronPID::UserExec -> Mixing with trigger Z: "<<fTrigBuffer[iTrig][0]<<", Pt: "<<fTrigBuffer[iTrig][3]<<endl;\r
+                \r
+                for (Int_t iAssoc = 0; iAssoc < associateds->GetEntriesFast(); iAssoc++) {\r
+                    \r
+                    currentAssociated = (AliAODTrack*)(associateds->At(iAssoc));\r
+                    currentAssociatedGlobal = GetGlobalTrack(currentAssociated);\r
+                    \r
+                    if (currentAssociatedGlobal) {\r
+                        \r
+                        Double_t DPhi = PhiRange(fTrigBuffer[iTrig][1] - currentAssociated->Phi());\r
+                        Double_t DEta = fTrigBuffer[iTrig][2] - currentAssociated->Eta();\r
+                        Double_t pt = currentAssociated->Pt();\r
+                        \r
+                        fMixedEvents->Fill(DPhi,DEta,pt);\r
+                       \r
+                    }\r
+                }\r
+            }\r
+        }\r
+    \r
+        // Copy the triggers from the current event into the buffer.\r
+        if (fAODVertex->GetZ()<10.) {\r
+        \r
+            if (fVerbose>3) cout<<"AliAnalysisTaskDiHadronPID::UserExec -> Copying "<<triggers->GetEntriesFast()<<" triggers with vertex z = "<<fAODVertex->GetZ()<<" to the buffer."<<endl;\r
+        \r
+            for (Int_t iTrig = 0; iTrig<triggers->GetEntriesFast(); iTrig++) {\r
+            \r
+                currentTrigger = (AliAODTrack*)(triggers->At(iTrig));\r
+                if (fVerbose>3) cout<<"AliAnalysisTaskDiHadronPID::UserExec -> Trigger pt = "<<currentTrigger->Pt()<<endl;\r
+            \r
+                fTrigBuffer[fTrigBufferIndex][0] = fAODVertex->GetZ();\r
+                fTrigBuffer[fTrigBufferIndex][1] = currentTrigger->Phi();\r
+                fTrigBuffer[fTrigBufferIndex][2] = currentTrigger->Eta();\r
+                fTrigBuffer[fTrigBufferIndex][3] = currentTrigger->Pt();\r
+                fTrigBufferIndex++;\r
+                if (fTrigBufferSize<fTrigBufferMaxSize) {fTrigBufferSize++;} // 250 triggers should be enough to get 10 times more data in mixed events.\r
+                if (fTrigBufferIndex==fTrigBufferMaxSize) {fTrigBufferIndex=0;}\r
+            }\r
+        }\r
+    }        \r
+        \r
+    if (fPrintBufferSize) cout<<"AliAnalysisTaskDiHadronPID::UserExec -> Trigger buffer index: "<<fTrigBufferIndex<<", and size: "<<fTrigBufferSize<<endl;\r
+    \r
+       delete triggers;\r
+       delete associateds;\r
+                          \r
+       PostData(1,fHistoList);\r
+       \r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AliAnalysisTaskDiHadronPID::Terminate(Option_t *)\r
+\r
+{\r
+       //\r
+       // Terminate.\r
+    //\r
+    \r
+}\r
+\r
index 2f7bda7..8a9ab4e 100644 (file)
-// ----------------------------------------------------------------------------
-// Header file.
-// ----------------------------------------------------------------------------
-// Last Rev.: Mar. 2nd 2012. (v 8.00)
-// ----------------------------------------------------------------------------
-
-#ifndef ALIANALYSISTASKDIHADRONPID_H
-#define ALIANALYSISTASKDIHADRONPID_H
-
-#include "AliAnalysisTaskSE.h"
-#include "THnSparse.h"
-
-class TH1F;
-class TH2F;
-class TH3F;
-//class THnSparseF;
-class TList;
-class TObjArray;
-class TString;
-
-class AliAODTrack;
-class AliAODEvent;
-class AliAODVertex;
-
-class AliPIDResponse;
-
-class AliAnalysisTaskDiHadronPID: public AliAnalysisTaskSE {
-
-public:
-       // Required functions.
-       AliAnalysisTaskDiHadronPID();
-       AliAnalysisTaskDiHadronPID(const char *name);
-       virtual ~AliAnalysisTaskDiHadronPID();
-       
-       virtual void UserCreateOutputObjects();
-       virtual void UserExec(Option_t *option);
-       virtual void Terminate(Option_t *);
-    
-    // Setters
-    void SetVerbose(Bool_t verbose=kTRUE) {fVerbose=verbose;}
-    void SetCalculateMixedEvents(Bool_t mixedevents=kTRUE) {fCalculateMixedEvents=mixedevents;}
-    
-    // Getters
-    Bool_t GetVerbose() {return fVerbose;}
-    Bool_t GetCalculateMixedEvents() {return fCalculateMixedEvents;}
-    
-private:
-       // Private Functions.   
-       AliAnalysisTaskDiHadronPID(const AliAnalysisTaskDiHadronPID&); // NOT IMPLEMENTED.
-       AliAnalysisTaskDiHadronPID& operator=(const AliAnalysisTaskDiHadronPID&); // NOT IMPLEMENTED.
-       
-       Bool_t SelectTrack(AliAODTrack *track, Int_t cuts=0);
-       Bool_t SelectEvent(AliAODVertex *vertex);
-       
-       void FillPIDPartnersArray();
-       AliAODTrack* GetTrackPartner(AliAODTrack* track);
-
-       Double_t PhiRange(Double_t DPhi);
-       
-private:
-       // PID object.
-       AliPIDResponse          *fPIDResponse;              //! PID Response Handler.
-       
-       // Event and Track related objects.
-       AliAODEvent                     *fAODEvent;                 //! The AOD Event.
-       AliAODHeader            *fAODHeader;                //! The AOD Header.
-       AliAODVertex            *fAODVertex;                //! The AOD Vertex.
-       
-       AliAODTrack                     *fAODTrack;                 //! Current AOD Track.
-
-       TObjArray                       *fPIDPartners;              //! Partner Tracks.
-       
-       // HISTOGRAMS.
-
-       // Event Sample Plots.
-       TH1F                        *fCentrality;               //! Centrality Histogram.
-       TH1F                        *fVertexZ;                  //! Vertex Z position.
-
-    // Track cuts counts.
-    TH1F                *fTrackCuts;                //! Different Track cuts.
-    
-       // Unidentified Spectra.
-       TH1F                        *fPtSpectrum;               //! Unidentified Pt-spectrum (after standard track cuts).
-    TH3F                *fAssociatedDistribution;   //! Associated distribution. 
-
-       // QA plots PID.
-       TH2F                            *fTPCnSigmaProton;          //! TPC nSigma plot for Protons.
-       TH2F                            *fTOFnSigmaProton;          //! TOF nSigma plot for Protons.
-       TH2F                            *fTPCnSigmaPion;            //! TPC nSigma plot for Pions.
-       TH2F                            *fTOFnSigmaPion;            //! TOF nSigma plot for Pions.      
-       TH2F                            *fTPCnSigmaKaon;            //! TPC nSigma plot for Kaons.
-       TH2F                            *fTOFnSigmaKaon;            //! TOF nSigma plot for Kaons.
-       
-    // PID signals as function of pT and Eta
-       TH3F                            *fTPCSignal;                            //! TPC signal (pt,eta).
-       TH3F                            *fTOFSignal;                            //! TOF signal (pT,eta).
-    
-       // Unidentified Di-Hadron Correlations & Mixed Events.
-       TH3F                            *fDiHadron;                 //! Di-Hadron correlations. 
-       TH3F                            *fMixedEvents;              //! Mixed Events.
-       
-       // Di-Hadron Correlations with TPC and TOF signals.
-    TH3F                *fDiHadronTPC[3][10];       //! Di-Hadron correlations with TPC signal.
-    TH3F                *fDiHadronTOF[3][10];       //! Di-Hadron correlations with TOF signal.
-       THnSparseF                      *fDiHadronTPCTOF[3][10];        //! Di-Hadron correlations with both TPC and TOF signal.
-
-       // List of Histograms.
-       TList                       *fHistoList;                //! List of Histograms.
-       
-       // Other data members.
-       Bool_t                          fVerbose;                   // Generates verbal output if kTRUE.
-       UInt_t                          fMask;                      // PID efficiency graphs will be made for this mask.
-    Bool_t              fCalculateMixedEvents;      // 
-    
-    // Trigger buffer.
-    Double_t            fTrigBuffer[25000][4];      //!
-       Int_t               fTrigBufferIndex;           //!
-    Int_t               fTrigBufferSize;            //!
-    
-    
-       ClassDef(AliAnalysisTaskDiHadronPID,1);
-       
-};
-
-#endif
-
+// ----------------------------------------------------------------------------\r
+// AliAnalysisTaskDiHadronPID.h\r
+// ----------------------------------------------------------------------------\r
+// Author: Misha Veldhoen (misha.veldhoen@cern.ch)\r
+// Last Rev.: Apr. 12th 2012. (v 8.00)\r
+// ----------------------------------------------------------------------------\r
+\r
+#ifndef ALIANALYSISTASKDIHADRONPID_H\r
+#define ALIANALYSISTASKDIHADRONPID_H\r
+\r
+#include <iostream>\r
+#include "AliAnalysisTaskSE.h"\r
+#include "THnSparse.h"\r
+#include "TMath.h"\r
+\r
+using namespace std;\r
+\r
+class TH1F;\r
+class TH2F;\r
+class TH3F;\r
+class TList;\r
+class TObjArray;\r
+class TString;\r
+\r
+class AliAODTrack;\r
+class AliAODEvent;\r
+class AliAODVertex;\r
+\r
+class AliPIDResponse;\r
+\r
+class AliAnalysisTaskDiHadronPID: public AliAnalysisTaskSE {\r
+\r
+public:\r
+       // Required functions.\r
+       AliAnalysisTaskDiHadronPID();\r
+       AliAnalysisTaskDiHadronPID(const char *name);\r
+       virtual ~AliAnalysisTaskDiHadronPID();\r
+       \r
+       virtual void UserCreateOutputObjects();\r
+       virtual void UserExec(Option_t *option);\r
+       virtual void Terminate(Option_t *);\r
+    \r
+    // Setters\r
+    void SetVerbose(Int_t verbose) {fVerbose=verbose;}\r
+    void SetPrintBufferSize(Bool_t printbuffersize=kTRUE) {fPrintBufferSize=printbuffersize;}\r
+    void SetCalculateMixedEvents(Bool_t mixedevents=kTRUE) {fCalculateMixedEvents=mixedevents;}\r
+    void SetBeamType(TString beamtype) {\r
+               if ((beamtype!="pp")&&(beamtype!="PbPb")) {\r
+                       cout<<"SetBeamType -> Beamtype must be pp or PbPb"<<endl;\r
+                       return;\r
+               }\r
+               fBeamType=beamtype;\r
+       }\r
+    \r
+       void SetMaxEta(Double_t maxeta) {\r
+               if (TMath::Abs(maxeta)>0.9) {\r
+                       cout<<"SetMaxEta -> |eta| must be < 0.9"<<endl;\r
+                       return;\r
+               }\r
+        fMaxEta = maxeta;\r
+       }\r
+    \r
+    void SetMaxPlotEta(Double_t maxploteta) {\r
+               if (TMath::Abs(maxploteta)>1.0) {\r
+                       cout<<"SetMaxPlotEta -> |eta| must be < 1.0"<<endl;\r
+                       return;\r
+               }\r
+        fMaxPlotEta = maxploteta;\r
+       }\r
+    \r
+    void SetMaxPt(Double_t maxpt) {\r
+        if (maxpt<5.) {\r
+            cout<<"SetMaxPt -> Maximum pT must be > 5.0 GeV/c."<<endl;\r
+            return;\r
+        }\r
+        fMaxPt = maxpt;\r
+    }\r
+    \r
+    void SetNEtaBins(Int_t netabins) {\r
+        if (netabins<1||netabins>72) {\r
+            cout<<"SetNEtaBins -> Number of bins must be between 1 and 72"<<endl;\r
+            return;\r
+        }\r
+        fNEtaBins = netabins;\r
+    }\r
+    \r
+    void SetNPhiBins(Int_t nphibins) {\r
+        if (nphibins<1||nphibins>72) {\r
+            cout<<"SetNPhiBins -> Number of bins must be between 1 and 72"<<endl;\r
+            return;\r
+        }\r
+        fNPhiBins = nphibins;\r
+\r
+    }\r
+    \r
+    void SetVertexZMixedEvents(Double_t vertexzmixedevents) {\r
+        if (vertexzmixedevents<0.||vertexzmixedevents>10.) {\r
+            cout<<"SetVertexZMixedEvents -> must be 0 < z < 10"<<endl;\r
+            return;\r
+        } \r
+        fVertexZMixedEvents=vertexzmixedevents;\r
+    } \r
+    \r
+    void SetZoomed(Bool_t zoomed=kTRUE) {fZoomed=zoomed;}\r
+       void SetDoDCACut(Bool_t dodcacut=kTRUE) {fDoDCACut=dodcacut;}\r
+    void SetDoITSCut(Bool_t doitscut=kTRUE) {fDoITSCut=doitscut;}\r
+    void SetDemandNoMismatch(Bool_t demandnomismatch=kTRUE) {fDemandNoMismatch=demandnomismatch;}\r
+    void SetTrigBufferMaxSize(Int_t trigbuffermaxsize) {\r
+        if (trigbuffermaxsize<10||trigbuffermaxsize>25000) {\r
+            cout<<"SetTrigBufferMaxSize -> Max buffer size must be between 10 and 25000."<<endl;\r
+            return;\r
+        }\r
+        fTrigBufferMaxSize=trigbuffermaxsize;\r
+    }\r
+    \r
+    void SetCentralityCut(Double_t centralitycutmax, Double_t centralitycutmin) {\r
+        if (centralitycutmax<0.) {\r
+            cout<<"SetCentralityCut -> Centrality cannot be lower than 0."<<endl;\r
+            return;\r
+        }\r
+        if (centralitycutmin<centralitycutmax) {\r
+            cout<<"SetCentralityCut -> Maximum centrality needs to be smaller than the minimum centrality. (It's confusing I know)"<<endl;\r
+            return;\r
+        }\r
+        if (centralitycutmin>100.) {\r
+            cout<<"SetCentralityCut -> Minimum centrality cannot exceed 100%."<<endl;\r
+            return;\r
+        }\r
+        fCentralityCutMax=centralitycutmax;\r
+        fCentralityCutMin=centralitycutmin;\r
+    \r
+    }\r
+       \r
+    // Getters\r
+    Bool_t GetVerbose() {return fVerbose;}\r
+    Bool_t GetPrintBufferSize() {return fPrintBufferSize;}\r
+    Bool_t GetCalculateMixedEvents() {return fCalculateMixedEvents;}\r
+    TString GetBeamType() {return fBeamType;}\r
+    Double_t GetMaxEta() {return fMaxEta;}\r
+    Double_t GetMaxPlotEta() {return fMaxPlotEta;}\r
+    Double_t GetMaxPt() {return fMaxPt;}\r
+    Int_t GetNEtaBins() {return fNEtaBins;}\r
+    Int_t GetNPhiBins() {return fNPhiBins;}\r
+    Double_t GetVertexZMixedEvents() {return fVertexZMixedEvents;}\r
+    Bool_t GetZoomed() {return fZoomed;}\r
+    Bool_t GetDoDCACut() {return fDoDCACut;}\r
+    Bool_t GetDoITSCut() {return fDoITSCut;}\r
+    Bool_t GetDemandNoMismatch() {return fDemandNoMismatch;}\r
+       Int_t GetTrigBufferMaxSize() {return fTrigBufferMaxSize;}\r
+    Double_t GetCentralityCutMax() {return fCentralityCutMax;}\r
+    Double_t GetCentralityCutMin() {return fCentralityCutMin;}\r
+    \r
+private:\r
+       // Private Functions.   \r
+       AliAnalysisTaskDiHadronPID(const AliAnalysisTaskDiHadronPID&); // NOT IMPLEMENTED.\r
+       AliAnalysisTaskDiHadronPID& operator=(const AliAnalysisTaskDiHadronPID&); // NOT IMPLEMENTED.\r
+\r
+    void FillGlobalTracksArray();\r
+       AliAODTrack* GetGlobalTrack(AliAODTrack* track);\r
+    \r
+       Bool_t SelectEvent(AliAODVertex *vertex);\r
+    Int_t ClassifyTrack(AliAODTrack* track);\r
+\r
+       Double_t PhiRange(Double_t DPhi);\r
+       \r
+private:\r
+       // PID object.\r
+       AliPIDResponse          *fPIDResponse;              //! PID Response Handler.\r
+       \r
+       // Event and Track related objects.\r
+       AliAODEvent                     *fAODEvent;                 //! The AOD Event.\r
+       AliAODHeader            *fAODHeader;                //! The AOD Header.\r
+       AliAODVertex            *fAODVertex;                //! The AOD Vertex.\r
+       \r
+       AliAODTrack                     *fAODTrack;                 //! Current AOD Track.\r
+\r
+       TObjArray                       *fGlobalTracks;              //! Partner Tracks.\r
+       \r
+       // HISTOGRAMS.\r
+\r
+       // Event QA plots.\r
+       TH1F                        *fCentrality;               //! Centrality Histogram.\r
+       TH1F                        *fVertexZ;                  //! Vertex Z position.\r
+\r
+    // Track QA plots.\r
+    TH2F                *fDCA;                      //! DCA XY vs Z before DCA cut.\r
+    TH2F                *fDCAZoomed;                //!\r
+    TH2F                *fDCAZoomedTwice;           //!\r
+    TH2F                *fDCACut;                   //! DCA XY vs Z after DCA cut (if performed!).\r
+    TH2F                *fDCAZoomedCut;             //!\r
+    TH2F                *fDCAZoomedTwiceCut;        //!\r
+    \r
+    TH1F                *fITSHits;                  //! 3 bins, [no hits in first 2 layers, 1 hit, 2 hits]\r
+    \r
+    TH1F                *fTrackCutsCount;           //! Counts of used tracks after cuts\r
+    TH2F                *fTrackCutsPt;              //! pT spectrum after cuts.\r
+    TH2F                *fTrackCutsEta;             //! eta spectrum after cuts.\r
+    TH2F                *fTrackCutsPhi;             //! phi spectrum after cuts.\r
+    \r
+    TH1F                *fEtaSpectrumTrig;          //! eta spectrum of triggers (pT > 5.0 tracks, trigger track cuts.)\r
+    TH2F                *fEtaSpectrumAssoc;         //! eta spectrum of associateds as a function of pT\r
+    TH2F                *fPhiSpectrumAssoc;         //! phi spectrum of associateds as a function of pT\r
+\r
+       // PID QA plots.\r
+       TH2F                            *fTPCnSigmaProton;          //! TPC nSigma plot for Protons.\r
+       TH2F                            *fTOFnSigmaProton;          //! TOF nSigma plot for Protons.\r
+       TH2F                            *fTPCnSigmaPion;            //! TPC nSigma plot for Pions.\r
+       TH2F                            *fTOFnSigmaPion;            //! TOF nSigma plot for Pions.      \r
+       TH2F                            *fTPCnSigmaKaon;            //! TPC nSigma plot for Kaons.\r
+       TH2F                            *fTOFnSigmaKaon;            //! TOF nSigma plot for Kaons.\r
+       \r
+       TH3F                            *fTPCSignal;                            //! TPC signal (pt,eta).\r
+       TH3F                            *fTOFSignal;                            //! TOF signal (pt,eta).\r
+       \r
+       // Di-Hadron Correlations with TPC and TOF signals.\r
+       THnSparseF                      *fDiHadronTPCTOF[3][10];        //! Di-Hadron correlations with both TPC and TOF signal.\r
+\r
+    // Mixed Events.\r
+    TH3F                               *fMixedEvents;              //! Mixed Events, associated track cuts.\r
+    \r
+       // List of Histograms.\r
+       TList                       *fHistoList;                //! List of Histograms.\r
+       \r
+       // Analysis Task Configuration Variables.\r
+    Bool_t              fCalculateMixedEvents;      // \r
+       TString                         fBeamType;                                      // pp or PbPb\r
+       Double_t                        fMaxEta;                    // Q: Do we need to take extra care of the binning?\r
+    Double_t            fMaxPlotEta;                //\r
+    Double_t            fMaxPt;                     //\r
+    Int_t               fNEtaBins;                  // Number of bins in eta\r
+    Int_t               fNPhiBins;                  // Number of bins in phi\r
+    Double_t            fVertexZMixedEvents;        // Events with a vertex z difference smaller than \r
+                                                    // this number (standard 2cm) will be mixed.\r
+    \r
+    Double_t            fCentralityCutMax;          // Maximum centrality (standard 0%)\r
+    Double_t            fCentralityCutMin;          // Minimum centrality (standard 10%)\r
+    Bool_t              fZoomed;                    //\r
+    Bool_t              fDoITSCut;                  // Cut the tracks with not at least one SPD hit.\r
+       Bool_t              fDoDCACut;                  // Perform a DCA cut to get rid of secondaries.\r
+    Bool_t              fDemandNoMismatch;          // \r
+    \r
+    Int_t               fTrackCutLabelNumbers[8];   // Track Cut labels.\r
+    \r
+    // Level of verbal output.\r
+    //  0 -> No output.\r
+    //  1 -> Only error messages.\r
+    //  2 -> Information about output creation (beginning of the job)\r
+    //  3 -> Event information.\r
+    //  4 -> Track information.\r
+    Int_t               fVerbose;                   //\r
+    Bool_t              fPrintBufferSize;           //\r
+\r
+    // Trigger buffer.\r
+    Double_t            fTrigBuffer[25000][4];      //!\r
+       Int_t               fTrigBufferIndex;           //!\r
+    Int_t               fTrigBufferSize;            //!\r
+       Int_t                           fTrigBufferMaxSize;                     //!\r
+    \r
+    \r
+       ClassDef(AliAnalysisTaskDiHadronPID,1);\r
+       \r
+};\r
+\r
+#endif\r
+\r