1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 #include "AliTwoParticlePIDCorr.h"
17 #include "AliVParticle.h"
30 #include "AliCentrality.h"
31 #include "Riostream.h"
34 #include "AliCFContainer.h"
36 #include "THnSparse.h"
40 #include "AliESDpid.h"
41 #include "AliAODpidUtil.h"
42 #include <AliPIDResponse.h>
44 #include <AliAnalysisManager.h>
45 #include <AliInputEventHandler.h>
46 #include "AliAODInputHandler.h"
48 #include "AliAnalysisTaskSE.h"
49 #include "AliAnalysisManager.h"
50 #include "AliCentrality.h"
52 #include "AliVEvent.h"
53 #include "AliAODEvent.h"
54 #include "AliAODTrack.h"
55 #include "AliVTrack.h"
57 #include "THnSparse.h"
59 #include "AliAODMCHeader.h"
60 #include "AliAODMCParticle.h"
61 #include "AliMCEventHandler.h"
62 #include "AliMCEvent.h"
63 #include "AliMCParticle.h"
64 #include "TParticle.h"
65 #include <TDatabasePDG.h>
66 #include <TParticlePDG.h>
68 #include "AliGenCocktailEventHeader.h"
69 #include "AliGenEventHeader.h"
71 #include "AliEventPoolManager.h"
72 #include "AliAnalysisUtils.h"
73 using namespace AliPIDNameSpace;
76 ClassImp(AliTwoParticlePIDCorr)
77 ClassImp(LRCParticlePID)
79 const char * kPIDTypeName[]={"TPC","TOF","TPC-TOF"} ;
80 const char * kDetectorName[]={"ITS","TPC","TOF"} ;
81 const char * kParticleSpeciesName[]={"Pions","Kaons","Protons","Undefined"} ;
83 //________________________________________________________________________
84 AliTwoParticlePIDCorr::AliTwoParticlePIDCorr() // All data members should be initialised here
87 fCentralityMethod("V0A"),
89 fnTracksVertex(1), // QA tracks pointing to principal vertex (= 3 default)
94 fSharedClusterCut(-1),
97 ffilltrigassoUNID(kFALSE),
98 ffilltrigUNIDassoID(kFALSE),
99 ffilltrigIDassoUNID(kTRUE),
100 ffilltrigIDassoID(kFALSE),
101 ffilltrigIDassoIDMCTRUTH(kFALSE),
102 fMaxNofMixingTracks(50000),
103 fPtOrderMCTruth(kTRUE),
104 fPtOrderDataReco(kTRUE),
105 fWeightPerEvent(kFALSE),
106 fTriggerSpeciesSelection(kFALSE),
107 fAssociatedSpeciesSelection(kFALSE),
108 fTriggerSpecies(SpPion),
109 fAssociatedSpecies(SpPion),
112 fSelectHighestPtTrig(kFALSE),
113 fcontainPIDtrig(kTRUE),
114 fcontainPIDasso(kFALSE),
115 frejectPileUp(kFALSE),
120 fminprotonsigmacut(-6.0),
121 fmaxprotonsigmacut(-3.0),
122 fminpionsigmacut(0.0),
123 fmaxpionsigmacut(4.0),
124 fselectprimaryTruth(kTRUE),
125 fonlyprimarydatareco(kFALSE),
128 ffillhistQAReco(kFALSE),
129 ffillhistQATruth(kFALSE),
130 kTrackVariablesPair(0),
159 fhistJetTrigestimate(0),
160 fCentralityCorrelation(0x0),
175 fCorrelatonTruthPrimary(0),
176 fCorrelatonTruthPrimarymix(0),
182 fTHnCorrIDUNIDmix(0),
184 fTHnTrigcountMCTruthPrim(0),
187 fAnalysisType("AOD"),
189 twoTrackEfficiencyCutValue(0.02),
190 //fControlConvResoncances(0),
195 fRequestTOFPID(kTRUE),
196 fPIDType(NSigmaTPCTOF),
197 fFIllPIDQAHistos(kTRUE),
199 fUseExclusiveNSigma(kFALSE),
200 fRemoveTracksT0Fill(kFALSE),
202 fTriggerSelectCharge(0),
203 fAssociatedSelectCharge(0),
204 fTriggerRestrictEta(-1),
205 fEtaOrdering(kFALSE),
206 fCutConversions(kFALSE),
207 fCutResonances(kFALSE),
208 fRejectResonanceDaughters(-1),
210 fInjectedSignals(kFALSE),
211 fRemoveWeakDecays(kFALSE),
212 fRemoveDuplicates(kFALSE),
213 fapplyTrigefficiency(kFALSE),
214 fapplyAssoefficiency(kFALSE),
215 ffillefficiency(kFALSE),
216 fmesoneffrequired(kFALSE),
217 fkaonprotoneffrequired(kFALSE),
222 for ( Int_t i = 0; i < 16; i++) {
226 for ( Int_t i = 0; i < 6; i++ ){
227 fTrackHistEfficiency[i] = NULL;
228 effcorection[i]=NULL;
233 for(Int_t ipart=0;ipart<NSpecies;ipart++)
234 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++)
235 fnsigmas[ipart][ipid]=999.;
237 for(Int_t ipart=0;ipart<NSpecies;ipart++) {fHasDoubleCounting[ipart]=kFALSE;}
240 //________________________________________________________________________
241 AliTwoParticlePIDCorr::AliTwoParticlePIDCorr(const char *name) // All data members should be initialised here
242 :AliAnalysisTaskSE(name),
244 fCentralityMethod("V0A"),
246 fnTracksVertex(1), // QA tracks pointing to principal vertex (= 3 default)
251 fSharedClusterCut(-1),
254 ffilltrigassoUNID(kFALSE),
255 ffilltrigUNIDassoID(kFALSE),
256 ffilltrigIDassoUNID(kTRUE),
257 ffilltrigIDassoID(kFALSE),
258 ffilltrigIDassoIDMCTRUTH(kFALSE),
259 fMaxNofMixingTracks(50000),
260 fPtOrderMCTruth(kTRUE),
261 fPtOrderDataReco(kTRUE),
262 fWeightPerEvent(kFALSE),
263 fTriggerSpeciesSelection(kFALSE),
264 fAssociatedSpeciesSelection(kFALSE),
265 fTriggerSpecies(SpPion),
266 fAssociatedSpecies(SpPion),
269 fSelectHighestPtTrig(kFALSE),
270 fcontainPIDtrig(kTRUE),
271 fcontainPIDasso(kFALSE),
272 frejectPileUp(kFALSE),
277 fminprotonsigmacut(-6.0),
278 fmaxprotonsigmacut(-3.0),
279 fminpionsigmacut(0.0),
280 fmaxpionsigmacut(4.0),
281 fselectprimaryTruth(kTRUE),
282 fonlyprimarydatareco(kFALSE),
285 ffillhistQAReco(kFALSE),
286 ffillhistQATruth(kFALSE),
287 kTrackVariablesPair(0),
316 fhistJetTrigestimate(0),
317 fCentralityCorrelation(0x0),
332 fCorrelatonTruthPrimary(0),
333 fCorrelatonTruthPrimarymix(0),
339 fTHnCorrIDUNIDmix(0),
341 fTHnTrigcountMCTruthPrim(0),
344 fAnalysisType("AOD"),
346 twoTrackEfficiencyCutValue(0.02),
347 //fControlConvResoncances(0),
352 fRequestTOFPID(kTRUE),
353 fPIDType(NSigmaTPCTOF),
354 fFIllPIDQAHistos(kTRUE),
356 fUseExclusiveNSigma(kFALSE),
357 fRemoveTracksT0Fill(kFALSE),
359 fTriggerSelectCharge(0),
360 fAssociatedSelectCharge(0),
361 fTriggerRestrictEta(-1),
362 fEtaOrdering(kFALSE),
363 fCutConversions(kFALSE),
364 fCutResonances(kFALSE),
365 fRejectResonanceDaughters(-1),
367 fInjectedSignals(kFALSE),
368 fRemoveWeakDecays(kFALSE),
369 fRemoveDuplicates(kFALSE),
370 fapplyTrigefficiency(kFALSE),
371 fapplyAssoefficiency(kFALSE),
372 ffillefficiency(kFALSE),
373 fmesoneffrequired(kFALSE),
374 fkaonprotoneffrequired(kFALSE),
379 for ( Int_t i = 0; i < 16; i++) {
383 for ( Int_t i = 0; i < 6; i++ ){
384 fTrackHistEfficiency[i] = NULL;
385 effcorection[i]=NULL;
389 for(Int_t ipart=0;ipart<NSpecies;ipart++)
390 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++)
391 fnsigmas[ipart][ipid]=999.;
393 for(Int_t ipart=0;ipart<NSpecies;ipart++) {fHasDoubleCounting[ipart]=kFALSE;}
395 // The last in the above list should not have a comma after it
398 // Define input and output slots here (never in the dummy constructor)
399 // Input slot #0 works with a TChain - it is connected to the default input container
400 // Output slot #1 writes into a TH1 container
402 DefineOutput(1, TList::Class()); // for output list
403 DefineOutput(2, TList::Class());
407 //________________________________________________________________________
408 AliTwoParticlePIDCorr::~AliTwoParticlePIDCorr()
410 // Destructor. Clean-up the output list, but not the histograms that are put inside
411 // (the list is owner and will clean-up these histograms). Protect in PROOF case.
412 if (fOutput && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
417 if (fOutputList && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
422 if (fPID) delete fPID;
425 //________________________________________________________________________
427 //////////////////////////////////////////////////////////////////////////////////////////////////
429 TH2F* AliTwoParticlePIDCorr::GetHistogram2D(const char * name){
430 // returns histo named name
431 return (TH2F*) fOutputList->FindObject(name);
434 //////////////////////////////////////////////////////////////////////////////////////////////////
436 Float_t AliTwoParticlePIDCorr::PhiRange(Float_t DPhi)
440 // Puts the argument in the range [-pi/2,3 pi/2].
443 if (DPhi < -TMath::Pi()/2) DPhi += 2*TMath::Pi();
444 if (DPhi > 3*TMath::Pi()/2) DPhi -= 2*TMath::Pi();
449 //________________________________________________________________________
450 void AliTwoParticlePIDCorr::UserCreateOutputObjects()
453 // Called once (on the worker node)
454 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
455 AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
456 fPID = inputHandler->GetPIDResponse();
458 //AliAnalysisUtils *fUtils = new AliAnalysisUtils();
460 //get the efficiency correction map
462 // global switch disabling the reference
463 // (to avoid "Replacing existing TH1" if several wagons are created in train)
464 Bool_t oldStatus = TH1::AddDirectoryStatus();
465 TH1::AddDirectory(kFALSE);
467 fOutput = new TList();
468 fOutput->SetOwner(); // IMPORTANT!
470 fOutputList = new TList;
471 fOutputList->SetOwner();
472 fOutputList->SetName("PIDQAList");
475 Int_t centmultbins=10;
476 Double_t centmultmin=0.0;
477 Double_t centmultmax=100.0;
478 if(fSampleType=="pPb" || fSampleType=="PbPb")
484 if(fSampleType=="pp")
491 fhistcentrality=new TH1F("fhistcentrality","fhistcentrality",centmultbins*4,centmultmin,centmultmax);
492 fOutput->Add(fhistcentrality);
494 fEventCounter = new TH1F("fEventCounter","EventCounter", 10, 0.5,10.5);
495 fEventCounter->GetXaxis()->SetBinLabel(1,"Event Accesed");
496 fEventCounter->GetXaxis()->SetBinLabel(2,"NOT PileUP Event");
497 fEventCounter->GetXaxis()->SetBinLabel(3,"Have A Vertex");
498 fEventCounter->GetXaxis()->SetBinLabel(4,"After vertex Cut");
499 fEventCounter->GetXaxis()->SetBinLabel(5,"Within 0-100% centrality");
500 fEventCounter->GetXaxis()->SetBinLabel(6,"Event Analyzed");
501 //fEventCounter->GetXaxis()->SetBinLabel(8,"Event Analysis finished");
502 fOutput->Add(fEventCounter);
504 fEtaSpectrasso=new TH2F("fEtaSpectraasso","fEtaSpectraasso",180,-0.9,0.9,100,0.,20. );
505 fOutput->Add(fEtaSpectrasso);
507 fphiSpectraasso=new TH2F("fphiSpectraasso","fphiSpectraasso",72,0,2*TMath::Pi(),100,0.,20.);
508 fOutput->Add(fphiSpectraasso);
510 if(fSampleType=="pPb" || fSampleType=="PbPb"){ fCentralityCorrelation = new TH2D("fCentralityCorrelation", ";centrality;multiplicity", 101, 0, 101, 20000, 0,40000);
511 fOutput->Add(fCentralityCorrelation);
514 fHistoTPCdEdx = new TH2F("hHistoTPCdEdx", ";p_{T} (GeV/c);dE/dx (au.)",200,0.0,10.0,500, 0., 500.);
515 fOutputList->Add(fHistoTPCdEdx);
516 fHistoTOFbeta = new TH2F(Form("hHistoTOFbeta"), ";p_{T} (GeV/c);v/c",100, 0., fmaxPt, 500, 0.1, 1.1);
517 fOutputList->Add(fHistoTOFbeta);
519 fTPCTOFPion3d=new TH3F ("fTPCTOFpion3d", "fTPCTOFpion3d",100,0., 10., 120,-60.,60.,120,-60.,60);
520 fOutputList->Add(fTPCTOFPion3d);
522 fTPCTOFKaon3d=new TH3F ("fTPCTOFKaon3d", "fTPCTOFKaon3d",100,0., 10., 120,-60.,60.,120,-60.,60);
523 fOutputList->Add(fTPCTOFKaon3d);
525 fTPCTOFProton3d=new TH3F ("fTPCTOFProton3d", "fTPCTOFProton3d",100,0., 10., 120,-60.,60.,120,-60.,60);
526 fOutputList->Add(fTPCTOFProton3d);
530 fPionPt = new TH1F("fHistQAPionPt","p_{T} distribution",200,0.,10.);
531 fOutputList->Add(fPionPt);
532 fPionEta= new TH1F("fHistQAPionEta","#eta distribution",360,-1.8,1.8);
533 fOutputList->Add(fPionEta);
534 fPionPhi = new TH1F("fHistQAPionPhi","#phi distribution",340,0,6.8);
535 fOutputList->Add(fPionPhi);
537 fKaonPt = new TH1F("fHistQAKaonPt","p_{T} distribution",200,0.,10.);
538 fOutputList->Add(fKaonPt);
539 fKaonEta= new TH1F("fHistQAKaonEta","#eta distribution",360,-1.8,1.8);
540 fOutputList->Add(fKaonEta);
541 fKaonPhi = new TH1F("fHistQAKaonPhi","#phi distribution",340,0,6.8);
542 fOutputList->Add(fKaonPhi);
544 fProtonPt = new TH1F("fHistQAProtonPt","p_{T} distribution",200,0.,10.);
545 fOutputList->Add(fProtonPt);
546 fProtonEta= new TH1F("fHistQAProtonEta","#eta distribution",360,-1.8,1.8);
547 fOutputList->Add(fProtonEta);
548 fProtonPhi= new TH1F("fHistQAProtonPhi","#phi distribution",340,0,6.8);
549 fOutputList->Add(fProtonPhi);
552 fHistQA[0] = new TH1F("fHistQAvx", "Histo Vx All ", 50, -5., 5.);
553 fHistQA[1] = new TH1F("fHistQAvy", "Histo Vy All", 50, -5., 5.);
554 fHistQA[2] = new TH1F("fHistQAvz", "Histo Vz All", 50, -25., 25.);
555 fHistQA[3] = new TH1F("fHistQAvxA", "Histo Vx After Cut ", 50, -5., 5.);
556 fHistQA[4] = new TH1F("fHistQAvyA", "Histo Vy After Cut", 50, -5., 5.);
557 fHistQA[5] = new TH1F("fHistQAvzA", "Histo Vz After Cut", 50, -25., 25.);
558 fHistQA[6] = new TH1F("fHistQADcaXyC", "Histo DCAxy after cut", 50, -5., 5.);
559 fHistQA[7] = new TH1F("fHistQADcaZC", "Histo DCAz after cut", 50, -5., 5.);
560 fHistQA[8] = new TH1F("fHistQAPt","p_{T} distribution",200,0.,10.);
561 fHistQA[9] = new TH1F("fHistQAEta","#eta distribution",360,-1.8,1.8);
562 fHistQA[10] = new TH1F("fHistQAPhi","#phi distribution",340,0,6.8);
563 fHistQA[11] = new TH1F("fHistQANCls","Number of TPC cluster",200,0,200);
564 fHistQA[13] = new TH1F("fHistQAChi2","Chi2 per NDF",100,0,10);
565 fHistQA[12] = new TH1F("fHistQANCls1","Number of TPC cluster1",200,0,200);
566 fHistQA[14] = new TH1F("nCrossedRowsTPC","Number of TPC ccrossed rows",200,0,200);
567 fHistQA[15] = new TH1F("ratioCrossedRowsOverFindableClustersTPC","Number of TPC ccrossed rows find clusters",200,0,2);
569 for(Int_t i = 0; i < 16; i++)
571 fOutput->Add(fHistQA[i]);
574 kTrackVariablesPair=6 ;
576 if(fcontainPIDtrig && !fcontainPIDasso) kTrackVariablesPair=7;
578 if(!fcontainPIDtrig && fcontainPIDasso) kTrackVariablesPair=7;
580 if(fcontainPIDtrig && fcontainPIDasso) kTrackVariablesPair=8;
583 // two particle histograms
584 Int_t anaSteps = 1; // analysis steps
585 const char* title = "d^{2}N_{ch}/d#varphid#eta";
587 Int_t iBinPair[kTrackVariablesPair]; // binning for track variables
588 Double_t* dBinsPair[kTrackVariablesPair]; // bins for track variables
589 TString* axisTitlePair; // axis titles for track variables
590 axisTitlePair=new TString[kTrackVariablesPair];
592 TString defaultBinningStr;
593 defaultBinningStr = "eta: -1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0\n"
594 "p_t_assoc: 0.5, 0.75, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 8.0,10.0\n"
595 "p_t_leading_course: 0.5, 1.0, 2.0, 3.0, 4.0, 6.0, 8.0,10.0\n"
596 "p_t_eff:0.0,0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.5, 5.0,5.5, 6.0, 7.0, 8.0,9.0,10.0\n"
597 "vertex: -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10\n"
598 "delta_phi: -1.570796, -1.483530, -1.396263, -1.308997, -1.221730, -1.134464, -1.047198, -0.959931, -0.872665, -0.785398, -0.698132, -0.610865, -0.523599, -0.436332, -0.349066, -0.261799, -0.174533, -0.087266, 0.0, 0.087266, 0.174533, 0.261799, 0.349066, 0.436332, 0.523599, 0.610865, 0.698132, 0.785398, 0.872665, 0.959931, 1.047198, 1.134464, 1.221730, 1.308997, 1.396263, 1.483530, 1.570796, 1.658063, 1.745329, 1.832596, 1.919862, 2.007129, 2.094395, 2.181662, 2.268928, 2.356194, 2.443461, 2.530727, 2.617994, 2.705260, 2.792527, 2.879793, 2.967060, 3.054326, 3.141593, 3.228859, 3.316126, 3.403392, 3.490659, 3.577925, 3.665191, 3.752458, 3.839724, 3.926991, 4.014257, 4.101524, 4.188790, 4.276057, 4.363323, 4.450590, 4.537856, 4.625123, 4.712389\n" // this binning starts at -pi/2 and is modulo 3
599 "delta_eta: -2.4, -2.3, -2.2, -2.1, -2.0, -1.9, -1.8, -1.7, -1.6, -1.5, -1.4, -1.3, -1.2, -1.1, -1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0,2.1, 2.2, 2.3, 2.4\n"
600 "multiplicity: 0, 1, 2, 3, 4, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100.1\n";
603 defaultBinningStr += "PIDTrig: -0.5,0.5,1.5,2.5,3.5\n"; // course
606 defaultBinningStr += "PIDAsso: -0.5,0.5,1.5,2.5,3.5\n"; // course
608 // =========================================================
609 // Customization (adopted from AliUEHistograms)
610 // =========================================================
612 TObjArray* lines = defaultBinningStr.Tokenize("\n");
613 for (Int_t i=0; i<lines->GetEntriesFast(); i++)
615 TString line(lines->At(i)->GetName());
616 TString tag = line(0, line.Index(":")+1);
617 if (!fCustomBinning.BeginsWith(tag) && !fCustomBinning.Contains(TString("\n") + tag))
618 fBinningString += line + "\n";
620 AliInfo(Form("Using custom binning for %s", tag.Data()));
623 fBinningString += fCustomBinning;
625 AliInfo(Form("Used AliTHn Binning:\n%s",fBinningString.Data()));
627 // =========================================================
629 // =========================================================
631 dBinsPair[0] = GetBinning(fBinningString, "multiplicity", iBinPair[0]);
632 axisTitlePair[0] = " multiplicity";
634 dBinsPair[1] = GetBinning(fBinningString, "vertex", iBinPair[1]);
635 axisTitlePair[1] = "v_{Z} (cm)";
637 dBinsPair[2] = GetBinning(fBinningString, "p_t_leading_course", iBinPair[2]);
638 axisTitlePair[2] = "p_{T,trig.} (GeV/c)";
640 dBinsPair[3] = GetBinning(fBinningString, "p_t_assoc", iBinPair[3]);
641 axisTitlePair[3] = "p_{T,assoc.} (GeV/c)";
643 dBinsPair[4] = GetBinning(fBinningString, "delta_eta", iBinPair[4]);
644 axisTitlePair[4] = "#Delta#eta";
646 dBinsPair[5] = GetBinning(fBinningString, "delta_phi", iBinPair[5]);
647 axisTitlePair[5] = "#Delta#varphi (rad)";
649 if(fcontainPIDtrig && !fcontainPIDasso){
650 dBinsPair[6] = GetBinning(fBinningString, "PIDTrig", iBinPair[6]);
651 axisTitlePair[6] = "PIDTrig";
654 if(!fcontainPIDtrig && fcontainPIDasso){
655 dBinsPair[6] = GetBinning(fBinningString, "PIDAsso", iBinPair[6]);
656 axisTitlePair[6] = "PIDAsso";
659 if(fcontainPIDtrig && fcontainPIDasso){
661 dBinsPair[6] = GetBinning(fBinningString, "PIDTrig", iBinPair[6]);
662 axisTitlePair[6] = "PIDTrig";
664 dBinsPair[7] = GetBinning(fBinningString, "PIDAsso", iBinPair[7]);
665 axisTitlePair[7] = "PIDAsso";
669 Double_t* EtaBin = GetBinning(fBinningString, "eta", nEtaBin);
671 Int_t nPteffbin = -1;
672 Double_t* Pteff = GetBinning(fBinningString, "p_t_eff", nPteffbin);
675 fminPtTrig=dBinsPair[2][0];
676 fmaxPtTrig=dBinsPair[2][iBinPair[2]];
677 fminPtAsso=dBinsPair[3][0];
678 fmaxPtAsso=dBinsPair[3][iBinPair[3]];
680 //fminPtComboeff=fminPtTrig;***then this value will be fixed ,even Setter can't change it's value
681 //fmaxPtComboeff=fmaxPtTrig;
682 //THnSparses for calculation of efficiency
684 if((fAnalysisType =="MCAOD") && ffillefficiency) {
687 effbin[0]=iBinPair[0];
688 effbin[1]=iBinPair[1];
692 for(Int_t jj=0;jj<6;jj++)//PID type binning
694 if(jj==5) effsteps=3;//for unidentified particles
695 Histrename="fTrackHistEfficiency";Histrename+=jj;
696 fTrackHistEfficiency[jj] = new AliTHn(Histrename.Data(), "Tracking efficiency", effsteps, 4, effbin);
697 fTrackHistEfficiency[jj]->SetBinLimits(0, dBinsPair[0]);
698 fTrackHistEfficiency[jj]->SetVarTitle(0, "Centrality");
699 fTrackHistEfficiency[jj]->SetBinLimits(1, dBinsPair[1]);
700 fTrackHistEfficiency[jj]->SetVarTitle(1, "zvtx");
701 fTrackHistEfficiency[jj]->SetBinLimits(2, Pteff);
702 fTrackHistEfficiency[jj]->SetVarTitle(2, "p_{T} (GeV/c)");
703 fTrackHistEfficiency[jj]->SetBinLimits(3, EtaBin);
704 fTrackHistEfficiency[jj]->SetVarTitle(3, "#eta");
705 fOutput->Add(fTrackHistEfficiency[jj]);
709 //AliThns for Correlation plots(data & MC)
711 if(ffilltrigassoUNID)
713 fTHnCorrUNID = new AliTHn("fTHnCorrUNID", title, anaSteps, kTrackVariablesPair, iBinPair);
714 for (Int_t j=0; j<kTrackVariablesPair; j++) {
715 fTHnCorrUNID->SetBinLimits(j, dBinsPair[j]);
716 fTHnCorrUNID->SetVarTitle(j, axisTitlePair[j]);
718 fOutput->Add(fTHnCorrUNID);
720 fTHnCorrUNIDmix = new AliTHn("fTHnCorrUNIDmix", title, anaSteps, kTrackVariablesPair, iBinPair);
721 for (Int_t j=0; j<kTrackVariablesPair; j++) {
722 fTHnCorrUNIDmix->SetBinLimits(j, dBinsPair[j]);
723 fTHnCorrUNIDmix->SetVarTitle(j, axisTitlePair[j]);
725 fOutput->Add(fTHnCorrUNIDmix);
728 if(ffilltrigIDassoID)
730 fTHnCorrID = new AliTHn("fTHnCorrID", title, anaSteps, kTrackVariablesPair, iBinPair);
731 for (Int_t j=0; j<kTrackVariablesPair; j++) {
732 fTHnCorrID->SetBinLimits(j, dBinsPair[j]);
733 fTHnCorrID->SetVarTitle(j, axisTitlePair[j]);
735 fOutput->Add(fTHnCorrID);
737 fTHnCorrIDmix = new AliTHn("fTHnCorrIDmix", title, anaSteps, kTrackVariablesPair, iBinPair);
738 for (Int_t j=0; j<kTrackVariablesPair; j++) {
739 fTHnCorrIDmix->SetBinLimits(j, dBinsPair[j]);
740 fTHnCorrIDmix->SetVarTitle(j, axisTitlePair[j]);
742 fOutput->Add(fTHnCorrIDmix);
745 if(ffilltrigUNIDassoID || ffilltrigIDassoUNID)//***********a bit tricky, be careful
747 fTHnCorrIDUNID = new AliTHn("fTHnCorrIDUNID", title, anaSteps, kTrackVariablesPair, iBinPair);
748 for (Int_t j=0; j<kTrackVariablesPair; j++) {
749 fTHnCorrIDUNID->SetBinLimits(j, dBinsPair[j]);
750 fTHnCorrIDUNID->SetVarTitle(j, axisTitlePair[j]);
752 fOutput->Add(fTHnCorrIDUNID);
755 fTHnCorrIDUNIDmix = new AliTHn("fTHnCorrIDUNIDmix", title, anaSteps, kTrackVariablesPair, iBinPair);
756 for (Int_t j=0; j<kTrackVariablesPair; j++) {
757 fTHnCorrIDUNIDmix->SetBinLimits(j, dBinsPair[j]);
758 fTHnCorrIDUNIDmix->SetVarTitle(j, axisTitlePair[j]);
760 fOutput->Add(fTHnCorrIDUNIDmix);
765 //ThnSparse for Correlation plots(truth MC)
766 if((fAnalysisType == "MCAOD") && ffilltrigIDassoIDMCTRUTH) {//remember that in this case uidentified means other than pions, kaons, protons
768 fCorrelatonTruthPrimary = new AliTHn("fCorrelatonTruthPrimary", title, anaSteps, kTrackVariablesPair, iBinPair);
769 for (Int_t j=0; j<kTrackVariablesPair; j++) {
770 fCorrelatonTruthPrimary->SetBinLimits(j, dBinsPair[j]);
771 fCorrelatonTruthPrimary->SetVarTitle(j, axisTitlePair[j]);
773 fOutput->Add(fCorrelatonTruthPrimary);
776 fCorrelatonTruthPrimarymix = new AliTHn("fCorrelatonTruthPrimarymix", title, anaSteps, kTrackVariablesPair, iBinPair);
777 for (Int_t j=0; j<kTrackVariablesPair; j++) {
778 fCorrelatonTruthPrimarymix->SetBinLimits(j, dBinsPair[j]);
779 fCorrelatonTruthPrimarymix->SetVarTitle(j, axisTitlePair[j]);
781 fOutput->Add(fCorrelatonTruthPrimarymix);
784 //binning for trigger no. counting
788 if(fcontainPIDtrig) dims=4;
789 fBinst= new Int_t[dims];
790 for(Int_t i=0; i<3;i++)
792 fBinst[i]=iBinPair[i];
795 fBinst[3]=iBinPair[6];
798 //ThSparse for trigger counting(data & reco MC)
799 if(ffilltrigassoUNID || ffilltrigUNIDassoID || ffilltrigIDassoUNID || ffilltrigIDassoID)
801 fTHnTrigcount = new AliTHn("fTHnTrigcount", "fTHnTrigcount", 2, dims, fBinst); //2 steps;;;;0->same event;;;;;1->mixed event
802 for(Int_t i=0; i<3;i++){
803 fTHnTrigcount->SetBinLimits(i, dBinsPair[i]);
804 fTHnTrigcount->SetVarTitle(i, axisTitlePair[i]);
808 fTHnTrigcount->SetBinLimits(3, dBinsPair[6]);
809 fTHnTrigcount->SetVarTitle(3, axisTitlePair[6]);
811 fOutput->Add(fTHnTrigcount);
814 if((fAnalysisType =="MCAOD") && ffilltrigIDassoIDMCTRUTH) {
815 //AliTHns for trigger counting(truth MC)
816 fTHnTrigcountMCTruthPrim = new AliTHn("fTHnTrigcountMCTruthPrim", "fTHnTrigcountMCTruthPrim", 2, dims, fBinst); //2 steps;;;;0->same event;;;;;1->mixed event
817 for(Int_t i=0; i<3;i++){
818 fTHnTrigcountMCTruthPrim->SetBinLimits(i, dBinsPair[i]);
819 fTHnTrigcountMCTruthPrim->SetVarTitle(i, axisTitlePair[i]);
823 fTHnTrigcountMCTruthPrim->SetBinLimits(3, dBinsPair[6]);
824 fTHnTrigcountMCTruthPrim->SetVarTitle(3, axisTitlePair[6]);
826 fOutput->Add(fTHnTrigcountMCTruthPrim);
829 if(fAnalysisType=="MCAOD"){
832 MCtruthpt=new TH1F ("MCtruthpt","ptdistributiontruthprim",100,0.,10.);
833 fOutputList->Add(MCtruthpt);
835 MCtrutheta=new TH1F ("MCtrutheta","etadistributiontruthprim",360,-1.8,1.8);
836 fOutputList->Add(MCtrutheta);
838 MCtruthphi=new TH1F ("MCtruthphi","phidisttruthprim",340,0,6.8);
839 fOutputList->Add(MCtruthphi);
841 MCtruthpionpt=new TH1F ("MCtruthpionpt","MCtruthpionpt",100,0.,10.);
842 fOutputList->Add(MCtruthpionpt);
844 MCtruthpioneta=new TH1F ("MCtruthpioneta","MCtruthpioneta",360,-1.8,1.8);
845 fOutputList->Add(MCtruthpioneta);
847 MCtruthpionphi=new TH1F ("MCtruthpionphi","MCtruthpionphi",340,0,6.8);
848 fOutputList->Add(MCtruthpionphi);
850 MCtruthkaonpt=new TH1F ("MCtruthkaonpt","MCtruthkaonpt",100,0.,10.);
851 fOutputList->Add(MCtruthkaonpt);
853 MCtruthkaoneta=new TH1F ("MCtruthkaoneta","MCtruthkaoneta",360,-1.8,1.8);
854 fOutputList->Add(MCtruthkaoneta);
856 MCtruthkaonphi=new TH1F ("MCtruthkaonphi","MCtruthkaonphi",340,0,6.8);
857 fOutputList->Add(MCtruthkaonphi);
859 MCtruthprotonpt=new TH1F ("MCtruthprotonpt","MCtruthprotonpt",100,0.,10.);
860 fOutputList->Add(MCtruthprotonpt);
862 MCtruthprotoneta=new TH1F ("MCtruthprotoneta","MCtruthprotoneta",360,-1.8,1.8);
863 fOutputList->Add(MCtruthprotoneta);
865 MCtruthprotonphi=new TH1F ("MCtruthprotonphi","MCtruthprotonphi",340,0,6.8);
866 fOutputList->Add(MCtruthprotonphi);
868 fPioncont=new TH2F("fPioncont", "fPioncont",10,-0.5,9.5,100,0.,10.);
869 fOutputList->Add(fPioncont);
871 fKaoncont=new TH2F("fKaoncont","fKaoncont",10,-0.5,9.5,100,0.,10.);
872 fOutputList->Add(fKaoncont);
874 fProtoncont=new TH2F("fProtoncont","fProtoncont",10,-0.5,9.5,100,0.,10.);
875 fOutputList->Add(fProtoncont);
878 fEventno=new TH2F("fEventno","fEventno",iBinPair[0], dBinsPair[0],iBinPair[1],dBinsPair[1]);
879 fEventno->GetXaxis()->SetTitle("Centrality");
880 fEventno->GetYaxis()->SetTitle("Z_Vtx");
881 fOutput->Add(fEventno);
882 fEventnobaryon=new TH2F("fEventnobaryon","fEventnobaryon",iBinPair[0], dBinsPair[0],iBinPair[1],dBinsPair[1]);
883 fEventnobaryon->GetXaxis()->SetTitle("Centrality");
884 fEventnobaryon->GetYaxis()->SetTitle("Z_Vtx");
885 fOutput->Add(fEventnobaryon);
886 fEventnomeson=new TH2F("fEventnomeson","fEventnomeson",iBinPair[0], dBinsPair[0],iBinPair[1],dBinsPair[1]);
887 fEventnomeson->GetXaxis()->SetTitle("Centrality");
888 fEventnomeson->GetYaxis()->SetTitle("Z_Vtx");
889 fOutput->Add(fEventnomeson);
891 fhistJetTrigestimate=new TH2F("fhistJetTrigestimate","fhistJetTrigestimate",iBinPair[0],dBinsPair[0],6,-0.5,5.5);
892 fOutput->Add(fhistJetTrigestimate);
898 if(fapplyTrigefficiency || fapplyAssoefficiency)
900 const Int_t nDimt = 4;// cent zvtx pt eta
901 Int_t fBinsCht[nDimt] = {iBinPair[0], iBinPair[1], nPteffbin ,nEtaBin};//*************change it
902 Double_t fMinCht[nDimt] = { dBinsPair[0][0],dBinsPair[1][0], Pteff[0], EtaBin[0] };
903 Double_t fMaxCht[nDimt] = {dBinsPair[0][iBinPair[0]], dBinsPair[1][iBinPair[1]], Pteff[nPteffbin], EtaBin[nEtaBin]};
906 for(Int_t jj=0;jj<6;jj++)// PID type binning
908 Histrexname="effcorection";Histrexname+=jj;
909 effcorection[jj] = new THnSparseF(Histrexname.Data(),"cent:zvtx::Pt:eta", nDimt, fBinsCht, fMinCht, fMaxCht);
910 effcorection[jj]->Sumw2();
911 effcorection[jj]->GetAxis(0)->Set(iBinPair[0], dBinsPair[0]);
912 effcorection[jj]->GetAxis(0)->SetTitle("Centrality");
913 effcorection[jj]->GetAxis(1)->Set( iBinPair[1],dBinsPair[1]);
914 effcorection[jj]->GetAxis(1)->SetTitle("zvtx");
915 effcorection[jj]->GetAxis(2)->Set(nPteffbin, Pteff);
916 effcorection[jj]->GetAxis(2)->SetTitle("p_{T} (GeV/c)");
917 effcorection[jj]->GetAxis(3)->Set( nEtaBin,EtaBin);
918 effcorection[jj]->GetAxis(3)->SetTitle("#eta");
919 fOutput->Add(effcorection[jj]);
921 // TFile *fsifile = new TFile(fefffilename,"READ");
923 if (TString(fefffilename).BeginsWith("alien:"))
924 TGrid::Connect("alien:");
925 TFile *fileT=TFile::Open(fefffilename);
927 for(Int_t jj=0;jj<6;jj++)//type binning
929 Nameg="effmap";Nameg+=jj;
930 //effcorection[jj] = (THnSparseF*)fsifile->Get(Nameg.Data());
931 effcorection[jj] = (THnSparseF*)fileT->Get(Nameg.Data());
933 //effcorection[jj]->SetDirectory(0);//****************************not present in case oh THnF
940 //fControlConvResoncances = new TH2F("fControlConvResoncances", ";id;delta mass", 3, -0.5, 2.5, 100, -0.1, 0.1);
941 // fOutput->Add(fControlConvResoncances);
947 //*****************************************************PIDQA histos*****************************************************//
951 for(Int_t ipart=0;ipart<NSpecies;ipart++){
952 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
955 if(ipid==NSigmaTPCTOF){miny=0;maxy=50;}
956 TH2F *fHistoNSigma=new TH2F(Form("NSigma_%d_%d",ipart,ipid),Form("n#sigma %s %s",kParticleSpeciesName[ipart],kPIDTypeName[ipid]),200,0,10,500,miny,maxy);
957 fHistoNSigma->GetXaxis()->SetTitle("P_{T} (GeV / c)");
958 fHistoNSigma->GetYaxis()->SetTitle(Form("n#sigma %s %s",kParticleSpeciesName[ipart],kPIDTypeName[ipid]));
959 fOutputList->Add(fHistoNSigma);
964 for(Int_t ipart=0;ipart<NSpecies;ipart++){
965 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
968 if(ipid==NSigmaTPCTOF){miny=0;maxy=20;}
969 TH2F *fHistoNSigma=new TH2F(Form("NSigmaRec_%d_%d",ipart,ipid),
970 Form("n#sigma for reconstructed %s %s",kParticleSpeciesName[ipart],kPIDTypeName[ipid]),200,0,10,500,miny,maxy);
971 fHistoNSigma->GetXaxis()->SetTitle("P_{T} (GeV / c)");
972 fHistoNSigma->GetYaxis()->SetTitle(Form("n#sigma %s %s",kParticleSpeciesName[ipart],kPIDTypeName[ipid]));
973 fOutputList->Add(fHistoNSigma);
978 if(fUseExclusiveNSigma) {
979 for(Int_t ipart=0;ipart<NSpecies;ipart++){
980 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
983 if(ipid==NSigmaTPCTOF){miny=0;maxy=20;}
984 TH2F *fHistoNSigma=new TH2F(Form("NSigmaDC_%d_%d",ipart,ipid),
985 Form("n#sigma for double counting %s %s",kParticleSpeciesName[ipart],kPIDTypeName[ipid]),200,0,10,500,miny,maxy);
986 fHistoNSigma->GetXaxis()->SetTitle("P_{T} (GeV / c)");
987 fHistoNSigma->GetYaxis()->SetTitle(Form("n#sigma %s %s",kParticleSpeciesName[ipart],kPIDTypeName[ipid]));
988 fOutputList->Add(fHistoNSigma);
993 if (fAnalysisType == "MCAOD"){
994 for(Int_t ipart=0;ipart<NSpecies;ipart++){
995 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
998 if(ipid==NSigmaTPCTOF){miny=0;maxy=50;}
999 TH2F *fHistoNSigma=new TH2F(Form("NSigmaMC_%d_%d",ipart,ipid),
1000 Form("n#sigma for MC %s %s",kParticleSpeciesName[ipart],kPIDTypeName[ipid]),200,0,10,500,miny,maxy);
1001 fHistoNSigma->GetXaxis()->SetTitle("P_{T} (GeV / c)");
1002 fHistoNSigma->GetYaxis()->SetTitle(Form("n#sigma %s %s",kParticleSpeciesName[ipart],kPIDTypeName[ipid]));
1003 fOutputList->Add(fHistoNSigma);
1008 for(Int_t idet=0;idet<fNDetectors;idet++){
1009 for(Int_t ipart=0;ipart<NSpecies;ipart++){
1011 if(idet==fTOF)maxy=1.1;
1012 TH2F *fHistoPID=new TH2F(Form("PID_%d_%d",idet,ipart),Form("%s signal - %s",kDetectorName[idet],kParticleSpeciesName[ipart]),200,0,10,500,-maxy,maxy);
1013 fHistoPID->GetXaxis()->SetTitle("P (GeV / c)");
1014 fHistoPID->GetYaxis()->SetTitle(Form("%s signal",kDetectorName[idet]));
1015 fOutputList->Add(fHistoPID);
1018 //PID signal plot, before PID cut
1019 for(Int_t idet=0;idet<fNDetectors;idet++){
1021 if(idet==fTOF)maxy=1.1;
1022 TH2F *fHistoPID=new TH2F(Form("PIDAll_%d",idet),Form("%s signal",kDetectorName[idet]),200,0,10,500,-maxy,maxy);
1023 fHistoPID->GetXaxis()->SetTitle("P (GeV / c)");
1024 fHistoPID->GetYaxis()->SetTitle(Form("%s signal",kDetectorName[idet]));
1025 fOutputList->Add(fHistoPID);
1028 PostData(1, fOutput); // Post data for ALL output slots >0 here, to get at least an empty histogram
1029 PostData(2, fOutputList);
1031 AliInfo("Finished setting up the Output");
1033 TH1::AddDirectory(oldStatus);
1038 //-------------------------------------------------------------------------------
1039 void AliTwoParticlePIDCorr::UserExec( Option_t * ){
1042 if(fAnalysisType == "AOD") {
1046 }//AOD--analysis-----
1048 else if(fAnalysisType == "MCAOD") {
1057 //-------------------------------------------------------------------------
1058 void AliTwoParticlePIDCorr::doMCAODevent()
1060 AliVEvent *event = InputEvent();
1061 if (!event) { Printf("ERROR: Could not retrieve event"); return; }
1062 AliAODEvent* aod = dynamic_cast<AliAODEvent*>(event);
1064 AliError("Cannot get the AOD event");
1068 // count all events(physics triggered)
1069 fEventCounter->Fill(1);
1071 // get centrality object and check quality(valid for p-Pb and Pb-Pb)
1072 Double_t cent_v0=0.0;
1074 if(fSampleType=="pPb" || fSampleType=="PbPb")
1076 AliCentrality *centrality=0;
1078 centrality = aod->GetHeader()->GetCentralityP();
1079 // if (centrality->GetQuality() != 0) return ;
1083 cent_v0 = centrality->GetCentralityPercentile(fCentralityMethod);
1091 //check the PIDResponse handler
1094 // get mag. field required for twotrack efficiency cut
1096 bSign = (aod->GetMagneticField() > 0) ? 1 : -1;
1098 //check for TClonesArray(truth track MC information)
1099 fArrayMC = dynamic_cast<TClonesArray*>(aod->FindListObject(AliAODMCParticle::StdBranchName()));
1101 AliFatal("Error: MC particles branch not found!\n");
1105 //check for AliAODMCHeader(truth event MC information)
1106 AliAODMCHeader *header=NULL;
1107 header=(AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
1109 printf("MC header branch not found!\n");
1113 //Only consider MC events within the vtx-z region used also as cut on the reconstructed vertex
1114 Float_t zVtxmc =header->GetVtxZ();
1115 if(TMath::Abs(zVtxmc)>fzvtxcut) return;
1117 // For productions with injected signals, figure out above which label to skip particles/tracks
1118 Int_t skipParticlesAbove = 0;
1120 if (fInjectedSignals)
1122 AliGenEventHeader* eventHeader = 0;
1127 AliFatal("fInjectedSignals set but no MC header found");
1129 headers = header->GetNCocktailHeaders();
1130 eventHeader = header->GetCocktailHeader(0);
1134 // We avoid AliFatal here, because the AOD productions sometimes have events where the MC header is missing
1135 // (due to unreadable Kinematics) and we don't want to loose the whole job because of a few events
1136 AliError("First event header not found. Skipping this event.");
1137 //fHistos->FillEvent(centrality, AliUEHist::kCFStepAnaTopology);
1140 skipParticlesAbove = eventHeader->NProduced();
1141 AliInfo(Form("Injected signals in this event (%d headers). Keeping events of %s. Will skip particles/tracks above %d.", headers, eventHeader->ClassName(), skipParticlesAbove));
1144 //vertex selection(is it fine for PP?)
1145 if ( fVertextype==1){
1146 trkVtx = aod->GetPrimaryVertex();
1147 if (!trkVtx || trkVtx->GetNContributors()<=0) return;
1148 TString vtxTtl = trkVtx->GetTitle();
1149 if (!vtxTtl.Contains("VertexerTracks")) return;
1150 zvtx = trkVtx->GetZ();
1151 const AliAODVertex* spdVtx = aod->GetPrimaryVertexSPD();
1152 if (!spdVtx || spdVtx->GetNContributors()<=0) return;
1153 TString vtxTyp = spdVtx->GetTitle();
1154 Double_t cov[6]={0};
1155 spdVtx->GetCovarianceMatrix(cov);
1156 Double_t zRes = TMath::Sqrt(cov[5]);
1157 if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) return;
1158 if (TMath::Abs(spdVtx->GetZ() - trkVtx->GetZ())>0.5) return;
1160 else if(fVertextype==2) {//for pp and pb-pb case
1161 Int_t nVertex = aod->GetNumberOfVertices();
1163 trkVtx = aod->GetPrimaryVertex();
1164 Int_t nTracksPrim = trkVtx->GetNContributors();
1165 zvtx = trkVtx->GetZ();
1166 //if (fDebug > 1)AliInfo(Form(" Vertex in = %f with %d particles by %s data ...",zVertex,nTracksPrim,vertex->GetName()));
1167 // Reject TPC only vertex
1168 TString name(trkVtx->GetName());
1169 if (name.CompareTo("PrimaryVertex") && name.CompareTo("SPDVertex"))return;
1171 // Select a quality vertex by number of tracks?
1172 if( nTracksPrim < fnTracksVertex ) {
1173 //if (fDebug > 1) AliInfo(" Primary-vertex Selection: event REJECTED ...");
1176 // TODO remove vertexer Z events with dispersion > 0.02: Doesn't work for AOD at present
1177 //if (strcmp(vertex->GetTitle(), "AliVertexerZ") == 0 && vertex->GetDispersion() > 0.02)
1179 // if (fDebug > 1) AliInfo(" Primary-vertex Selection: event ACCEPTED...");
1184 else if(fVertextype==0){//default case
1185 trkVtx = aod->GetPrimaryVertex();
1186 if (!trkVtx || trkVtx->GetNContributors()<=0) return;//proper number of contributors
1187 zvtx = trkVtx->GetZ();
1189 trkVtx->GetCovarianceMatrix(fCov);
1190 if(fCov[5] == 0) return;//proper vertex resolution
1193 AliInfo("Wrong Vertextype set for Primary-vertex Selection: event REJECTED ...");
1194 return;//as there is no proper sample type
1198 fHistQA[0]->Fill((trkVtx->GetX()));fHistQA[1]->Fill((trkVtx->GetY()));fHistQA[2]->Fill((trkVtx->GetZ())); //for trkVtx only before vertex cut |zvtx|<10 cm
1200 //count events having a proper vertex
1201 fEventCounter->Fill(3);
1203 if (TMath::Abs(zvtx) > fzvtxcut) return;
1205 fHistQA[3]->Fill((trkVtx->GetX()));fHistQA[4]->Fill((trkVtx->GetY()));fHistQA[5]->Fill((trkVtx->GetZ()));//after vertex cut for trkVtx only
1207 //now we have events passed physics trigger, centrality,eventzvtx cut
1209 //count events after vertex cut
1210 fEventCounter->Fill(4);
1212 if(!aod) return; //for safety
1214 if (fSampleType=="pPb" || fSampleType=="PbPb") if (cent_v0 < 0) return;//for pp case it is the multiplicity
1216 Double_t nooftrackstruth=0.0;//in case of pp this will give the multiplicity(for truth case) after the track loop(only for unidentified particles that pass kinematic cuts)
1218 Double_t cent_v0_truth=0.0;
1220 //TObjArray* tracksMCtruth=0;
1221 TObjArray* tracksMCtruth=new TObjArray;//for truth MC particles with PID,here unidentified means any particle other than pion, kaon or proton(Basicaly Spundefined of AliHelperPID)******WARNING::different from data and reco MC
1222 tracksMCtruth->SetOwner(kTRUE); //***********************************IMPORTANT!
1226 //There is a small difference between zvtx and zVtxmc??????
1227 //cout<<"***********************************************zVtxmc="<<zVtxmc<<endl;
1228 //cout<<"***********************************************zvtx="<<zvtx<<endl;
1230 //now process the truth particles(for both efficiency & correlation function)
1231 Int_t nMCTrack = fArrayMC->GetEntriesFast();
1233 for (Int_t iMC = 0; iMC < nMCTrack; iMC++)
1234 { //MC truth track loop starts
1236 AliAODMCParticle *partMC = (AliAODMCParticle*) fArrayMC->At(iMC);
1239 AliError(Form("ERROR: Could not retrieve AODMCtrack %d",iMC));
1243 //consider only charged particles
1244 if(partMC->Charge() == 0) continue;
1246 //consider only primary particles; neglect all secondary particles including from weak decays
1247 if(fselectprimaryTruth && !partMC->IsPhysicalPrimary()) continue;
1250 //remove injected signals(primaries above <maxLabel>)
1251 if (fInjectedSignals && partMC->GetLabel() >= skipParticlesAbove) continue;
1254 Bool_t isduplicate=kFALSE;
1255 if (fRemoveDuplicates)
1257 for (Int_t j=iMC+1; j<nMCTrack; ++j)
1258 {//2nd trutuh loop starts
1259 AliAODMCParticle *partMC2 = (AliAODMCParticle*) fArrayMC->At(j);
1261 AliError(Form("ERROR: Could not retrieve AODMCtrack %d",j));
1264 if (partMC->GetLabel() == partMC2->GetLabel())
1269 }//2nd truth loop ends
1271 if(fRemoveDuplicates && isduplicate) continue;//remove duplicates
1273 //give only kinematic cuts at the truth level
1274 if (partMC->Eta() < fmineta || partMC->Eta() > fmaxeta) continue;
1275 if (partMC->Pt() < fminPt || partMC->Pt() > fmaxPt) continue;
1277 if(!partMC) continue;//for safety
1279 //To determine multiplicity in case of PP
1281 //cout<<"**************************************"<<TMath::Abs(partMC->GetLabel())<<endl;
1282 //only physical primary(all/unidentified)
1283 if(ffillhistQATruth)
1285 MCtruthpt->Fill(partMC->Pt());
1286 MCtrutheta->Fill(partMC->Eta());
1287 MCtruthphi->Fill(partMC->Phi());
1290 Int_t pdgtruth=((AliAODMCParticle*)partMC)->GetPdgCode();
1291 Int_t particletypeTruth=-999;
1292 if (TMath::Abs(pdgtruth)==211)
1294 particletypeTruth=SpPion;
1295 if(ffillhistQATruth)
1297 MCtruthpionpt->Fill(partMC->Pt());
1298 MCtruthpioneta->Fill(partMC->Eta());
1299 MCtruthpionphi->Fill(partMC->Phi());
1302 if (TMath::Abs(pdgtruth)==321)
1304 particletypeTruth=SpKaon;
1305 if(ffillhistQATruth)
1307 MCtruthkaonpt->Fill(partMC->Pt());
1308 MCtruthkaoneta->Fill(partMC->Eta());
1309 MCtruthkaonphi->Fill(partMC->Phi());
1312 if(TMath::Abs(pdgtruth)==2212)
1314 particletypeTruth=SpProton;
1315 if(ffillhistQATruth)
1317 MCtruthprotonpt->Fill(partMC->Pt());
1318 MCtruthprotoneta->Fill(partMC->Eta());
1319 MCtruthprotonphi->Fill(partMC->Phi());
1322 if(TMath::Abs(pdgtruth)!=211 && TMath::Abs(pdgtruth)!=321 && TMath::Abs(pdgtruth)!=2212) particletypeTruth=unidentified;//*********************WARNING:: situation is different from reco MC and data case(here we don't have SpUndefined particles,because here unidentified=SpUndefined)
1324 // -- Fill THnSparse for efficiency and contamination calculation
1325 if (fSampleType=="pp") cent_v0=15.0;//integrated over multiplicity(so put any fixed value for each track so that practically means there is only one bin in multiplicity i.e. multiplicity intregated out )**************Important
1327 Double_t primmctruth[4] = {cent_v0, zVtxmc,partMC->Pt(), partMC->Eta()};
1330 fTrackHistEfficiency[5]->Fill(primmctruth,0);//for all primary truth particles(4)
1331 if (TMath::Abs(pdgtruth)==211 || TMath::Abs(pdgtruth)==321) fTrackHistEfficiency[3]->Fill(primmctruth,0);//for primary truth mesons(3)
1332 if (TMath::Abs(pdgtruth)==2212 || TMath::Abs(pdgtruth)==321) fTrackHistEfficiency[4]->Fill(primmctruth,0);//for primary truth kaons+protons(4)
1333 if (TMath::Abs(pdgtruth)==211) fTrackHistEfficiency[0]->Fill(primmctruth,0);//for pions
1334 if (TMath::Abs(pdgtruth)==321) fTrackHistEfficiency[1]->Fill(primmctruth,0);//for kaons
1335 if(TMath::Abs(pdgtruth)==2212) fTrackHistEfficiency[2]->Fill(primmctruth,0);//for protons
1338 Float_t effmatrixtruth=1.0;//In Truth MC, no case of efficiency correction so it should be always 1.0
1339 if((partMC->Pt()>=fminPtAsso && partMC->Pt()<=fmaxPtAsso) || (partMC->Pt()>=fminPtTrig && partMC->Pt()<=fmaxPtTrig))//to reduce memory consumption in pool
1341 LRCParticlePID* copy6 = new LRCParticlePID(particletypeTruth,partMC->Charge(),partMC->Pt(),partMC->Eta(), partMC->Phi(),effmatrixtruth);
1342 //copy6->SetUniqueID(eventno * 100000 + TMath::Abs(partMC->GetLabel()));
1343 copy6->SetUniqueID(eventno * 100000 + (Int_t)nooftrackstruth);
1344 tracksMCtruth->Add(copy6);//************** TObjArray used for truth correlation function calculation
1346 }//MC truth track loop ends
1348 //*********************still in event loop
1349 Float_t weghtval=1.0;
1351 if (fSampleType=="pp") cent_v0_truth=nooftrackstruth;
1352 else cent_v0_truth=cent_v0;//the notation cent_v0 is reserved for reco/data case
1354 //now cent_v0_truth should be used for all correlation function calculation
1356 if(nooftrackstruth>0.0 && ffilltrigIDassoIDMCTRUTH)
1358 //Fill Correlations for MC truth particles(same event)
1359 if(tracksMCtruth && tracksMCtruth->GetEntriesFast()>0)//hadron triggered correlation
1360 Fillcorrelation(tracksMCtruth,0,cent_v0_truth,zVtxmc,weghtval,kFALSE,bSign,fPtOrderMCTruth,kFALSE,kFALSE,"trigIDassoIDMCTRUTH");//mixcase=kFALSE for same event case
1363 AliEventPool* pool2 = fPoolMgr->GetEventPool(cent_v0_truth, zVtxmc+200);
1364 if (pool2 && pool2->IsReady())
1365 {//start mixing only when pool->IsReady
1366 if(tracksMCtruth && tracksMCtruth->GetEntriesFast()>0)
1367 {//proceed only when no. of trigger particles >0 in current event
1368 Float_t nmix=(Float_t)pool2->GetCurrentNEvents();
1369 for (Int_t jMix=0; jMix<pool2->GetCurrentNEvents(); jMix++)
1370 { //pool event loop start
1371 TObjArray* bgTracks6 = pool2->GetEvent(jMix);
1372 if(!bgTracks6) continue;
1373 Fillcorrelation(tracksMCtruth,bgTracks6,cent_v0_truth,zVtxmc,nmix,(jMix == 0),bSign,fPtOrderMCTruth,kFALSE,kTRUE,"trigIDassoIDMCTRUTH");//mixcase=kTRUE for mixing case
1375 }// pool event loop ends mixing case
1376 }//if(trackstrig && trackstrig->GetEntriesFast()>0) condition ends mixing case
1377 } //if pool->IsReady() condition ends mixing case
1379 //still in main event loop
1382 if(pool2) pool2->UpdatePool(CloneAndReduceTrackList(tracksMCtruth));//ownership of tracksasso is with pool now, don't delete it
1386 //still in main event loop
1388 if(tracksMCtruth) delete tracksMCtruth;
1390 //now deal with reco tracks
1391 //TObjArray* tracksUNID=0;
1392 TObjArray* tracksUNID = new TObjArray;
1393 tracksUNID->SetOwner(kTRUE);
1395 //TObjArray* tracksID=0;
1396 TObjArray* tracksID = new TObjArray;
1397 tracksID->SetOwner(kTRUE);
1400 Float_t bSign1=aod->GetHeader()->GetMagneticField() ;//used for reconstructed track dca cut
1402 Double_t trackscount=0.0;
1404 // loop over reconstructed tracks
1405 for (Int_t itrk = 0; itrk < aod->GetNumberOfTracks(); itrk++)
1406 { // reconstructed track loop starts
1407 AliAODTrack* track = dynamic_cast<AliAODTrack*>(aod->GetTrack(itrk));
1408 if (!track) continue;
1409 //get the corresponding MC track at the truth level (doing reco matching)
1410 AliAODMCParticle* recomatched = static_cast<AliAODMCParticle*>(fArrayMC->At(TMath::Abs(track->GetLabel())));
1411 if(!recomatched) continue;//if a reco track doesn't have corresponding truth track at generated level is a fake track(label==0), ignore it
1413 //remove injected signals
1414 if(fInjectedSignals)
1416 AliAODMCParticle* mother = recomatched;
1418 while (!mother->IsPhysicalPrimary())
1419 {// find the primary mother;the first stable mother is searched and checked if it is <= <maxLabel>
1420 if (mother->GetMother() < 0)
1426 mother =(AliAODMCParticle*) fArrayMC->At(((AliAODMCParticle*)mother)->GetMother());
1432 Printf("WARNING: No mother found for particle %d:", recomatched->GetLabel());
1435 if (mother->GetLabel() >= skipParticlesAbove) continue;//remove injected signals(primaries above <maxLabel>)
1436 }//remove injected signals
1438 if (fRemoveWeakDecays && ((AliAODMCParticle*) recomatched)->IsSecondaryFromWeakDecay()) continue;//remove weak decays
1440 Bool_t isduplicate2=kFALSE;
1441 if (fRemoveDuplicates)
1443 for (Int_t j =itrk+1; j < aod->GetNumberOfTracks(); j++)
1445 AliAODTrack* track2 = dynamic_cast<AliAODTrack*>(aod->GetTrack(j));
1446 if (!track2) continue;
1447 AliAODMCParticle* recomatched2 = static_cast<AliAODMCParticle*>(fArrayMC->At(TMath::Abs(track2->GetLabel())));
1448 if(!recomatched2) continue;
1450 if (track->GetLabel() == track2->GetLabel())
1457 if(fRemoveDuplicates && isduplicate2) continue;//remove duplicates
1459 fHistQA[11]->Fill(track->GetTPCNcls());
1460 Int_t tracktype=ClassifyTrack(track,trkVtx,bSign1);//dcacut=kFALSE,onlyprimary=kFALSE
1462 if(tracktype==0) continue;
1463 if(tracktype==1)//tracks "not" passed AliAODTrack::kPrimary at reconstructed level & have proper TPC PID response(?)
1465 if(!track) continue;//for safety
1466 //accepted all(primaries+secondary) reconstructed tracks(pt 0.2 to 10.0,,eta -0.8 to 0.8)
1469 //check for eta , phi holes
1470 fEtaSpectrasso->Fill(track->Eta(),track->Pt());
1471 fphiSpectraasso->Fill(track->Phi(),track->Pt());
1473 Int_t particletypeMC=-9999;
1475 //tag all particles as unidentified
1476 particletypeMC=unidentified;
1478 Float_t effmatrix=1.;
1480 // -- Fill THnSparse for efficiency calculation
1481 if (fSampleType=="pp") cent_v0=15.0;//integrated over multiplicity(so put any fixed value for each track so that practically means there is only one bin in multiplicityi.e multiplicity intregated out )**************Important
1482 //NOTE:: this will be used for fillinfg THnSparse of efficiency & also to get the the track by track eff. factor on the fly(only in case of pp)
1484 //Clone & Reduce track list(TObjArray) for unidentified particles
1485 if((track->Pt()>=fminPtAsso && track->Pt()<=fmaxPtAsso) || (track->Pt()>=fminPtTrig && track->Pt()<=fmaxPtTrig))//to reduce memory consumption in pool
1487 if (fapplyTrigefficiency || fapplyAssoefficiency)//get the trackingefficiency x contamination factor for unidentified particles
1488 effmatrix=GetTrackbyTrackeffvalue(track,cent_v0,zvtx,particletypeMC);
1489 LRCParticlePID* copy = new LRCParticlePID(particletypeMC,track->Charge(),track->Pt(),track->Eta(), track->Phi(),effmatrix);
1490 copy->SetUniqueID(eventno * 100000 +(Int_t)trackscount);
1491 tracksUNID->Add(copy);//track information Storage for UNID correlation function(tracks that pass the filterbit & kinematic cuts only)
1494 //get the pdg code of the corresponding truth particle
1495 Int_t pdgCode = ((AliAODMCParticle*)recomatched)->GetPdgCode();
1497 Double_t allrecomatchedpid[4] = {cent_v0, zVtxmc,recomatched->Pt(), recomatched->Eta()};
1498 if(ffillefficiency) {
1499 fTrackHistEfficiency[5]->Fill(allrecomatchedpid,2);//for allreco matched
1500 if(TMath::Abs(pdgCode)==211 || TMath::Abs(pdgCode)==321) fTrackHistEfficiency[3]->Fill(allrecomatchedpid,2);//for mesons
1501 if(TMath::Abs(pdgCode)==321 || TMath::Abs(pdgCode)==2212) fTrackHistEfficiency[4]->Fill(allrecomatchedpid,2);//for kaons+protons
1502 if(TMath::Abs(pdgCode)==211) fTrackHistEfficiency[0]->Fill(allrecomatchedpid,2);//for pions
1503 if(TMath::Abs(pdgCode)==321) fTrackHistEfficiency[1]->Fill(allrecomatchedpid,2);//for kaons
1504 if(TMath::Abs(pdgCode)==2212) fTrackHistEfficiency[2]->Fill(allrecomatchedpid,2);//for protons
1506 if (((AliAODMCParticle*)recomatched)->IsPhysicalPrimary()) {
1507 fTrackHistEfficiency[5]->Fill(allrecomatchedpid,1);//for primreco matched
1508 if(TMath::Abs(pdgCode)==211 || TMath::Abs(pdgCode)==321) fTrackHistEfficiency[3]->Fill(allrecomatchedpid,1);//for mesons
1509 if(TMath::Abs(pdgCode)==321 || TMath::Abs(pdgCode)==2212) fTrackHistEfficiency[4]->Fill(allrecomatchedpid,1);//for kaons+protons
1510 if( TMath::Abs(pdgCode)==211) fTrackHistEfficiency[0]->Fill(allrecomatchedpid,1);//for pions
1511 if( TMath::Abs(pdgCode)==321) fTrackHistEfficiency[1]->Fill(allrecomatchedpid,1);//for kaons
1512 if( TMath::Abs(pdgCode)==2212) fTrackHistEfficiency[2]->Fill(allrecomatchedpid,1);//for protons
1517 //now start the particle identification process:)
1518 switch(TMath::Abs(pdgCode)){
1520 if(fFIllPIDQAHistos){
1521 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
1522 if((ipid!=NSigmaTPC) && (!HasTOFPID(track)) && track->Pt()<fPtTOFPIDmin)continue;//not filling TOF and combined if no TOF PID
1523 TH2F *h=GetHistogram2D(Form("NSigmaMC_%d_%d",SpProton,ipid));
1524 h->Fill(track->Pt(),fnsigmas[SpProton][ipid]);
1529 if(fFIllPIDQAHistos){
1530 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
1531 if((ipid!=NSigmaTPC) && (!HasTOFPID(track)) && track->Pt()<fPtTOFPIDmin)continue;//not filling TOF and combined if no TOF PID
1532 TH2F *h=GetHistogram2D(Form("NSigmaMC_%d_%d",SpKaon,ipid));
1533 h->Fill(track->Pt(),fnsigmas[SpKaon][ipid]);
1538 if(fFIllPIDQAHistos){
1539 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
1540 if((ipid!=NSigmaTPC) && (!HasTOFPID(track)) && track->Pt()<fPtTOFPIDmin)continue;//not filling TOF and combined if no TOF PID
1541 TH2F *h=GetHistogram2D(Form("NSigmaMC_%d_%d",SpPion,ipid));
1542 h->Fill(track->Pt(),fnsigmas[SpPion][ipid]);
1549 Float_t dEdx = track->GetTPCsignal();
1550 fHistoTPCdEdx->Fill(track->Pt(), dEdx);
1552 if(HasTOFPID(track))
1554 Double_t beta = GetBeta(track);
1555 fHistoTOFbeta->Fill(track->Pt(), beta);
1558 //do track identification(nsigma method)
1559 particletypeMC=GetParticle(track,fFIllPIDQAHistos);//******************************problem is here
1561 //2-d TPCTOF map(for each Pt interval)
1562 if(HasTOFPID(track)){
1563 fTPCTOFPion3d->Fill(track->Pt(),fnsigmas[SpPion][NSigmaTOF],fnsigmas[SpPion][NSigmaTPC]);
1564 fTPCTOFKaon3d->Fill(track->Pt(),fnsigmas[SpKaon][NSigmaTOF],fnsigmas[SpKaon][NSigmaTPC]);
1565 fTPCTOFProton3d->Fill(track->Pt(),fnsigmas[SpProton][NSigmaTOF],fnsigmas[SpProton][NSigmaTPC]);
1567 if(particletypeMC==SpUndefined) continue;
1569 //Pt, Eta , Phi distribution of the reconstructed identified particles
1572 if (particletypeMC==SpPion)
1574 fPionPt->Fill(track->Pt());
1575 fPionEta->Fill(track->Eta());
1576 fPionPhi->Fill(track->Phi());
1578 if (particletypeMC==SpKaon)
1580 fKaonPt->Fill(track->Pt());
1581 fKaonEta->Fill(track->Eta());
1582 fKaonPhi->Fill(track->Phi());
1584 if (particletypeMC==SpProton)
1586 fProtonPt->Fill(track->Pt());
1587 fProtonEta->Fill(track->Eta());
1588 fProtonPhi->Fill(track->Phi());
1592 //for misidentification fraction calculation(do it with tuneonPID)
1593 if(particletypeMC==SpPion )
1595 if(TMath::Abs(pdgCode)==211) fPioncont->Fill(1.,track->Pt());
1596 if(TMath::Abs(pdgCode)==321) fPioncont->Fill(3.,track->Pt());
1597 if(TMath::Abs(pdgCode)==2212) fPioncont->Fill(5.,track->Pt());
1598 if(TMath::Abs(pdgCode)!=211 && TMath::Abs(pdgCode)!=321 && TMath::Abs(pdgCode)!=2212) fPioncont->Fill(7.,track->Pt());
1600 if(particletypeMC==SpKaon )
1602 if(TMath::Abs(pdgCode)==211) fKaoncont->Fill(1.,track->Pt());
1603 if(TMath::Abs(pdgCode)==321) fKaoncont->Fill(3.,track->Pt());
1604 if(TMath::Abs(pdgCode)==2212) fKaoncont->Fill(5.,track->Pt());
1605 if(TMath::Abs(pdgCode)!=211 && TMath::Abs(pdgCode)!=321 && TMath::Abs(pdgCode)!=2212) fKaoncont->Fill(7.,track->Pt());
1607 if(particletypeMC==SpProton )
1609 if(TMath::Abs(pdgCode)==211) fProtoncont->Fill(1.,track->Pt());
1610 if(TMath::Abs(pdgCode)==321) fProtoncont->Fill(3.,track->Pt());
1611 if(TMath::Abs(pdgCode)==2212) fProtoncont->Fill(5.,track->Pt());
1612 if(TMath::Abs(pdgCode)!=211 && TMath::Abs(pdgCode)!=321 && TMath::Abs(pdgCode)!=2212) fProtoncont->Fill(7.,track->Pt());
1615 //fill tracking efficiency
1618 if(particletypeMC==SpPion || particletypeMC==SpKaon)
1620 if(TMath::Abs(pdgCode)==211 || TMath::Abs(pdgCode)==321) {
1621 fTrackHistEfficiency[3]->Fill(allrecomatchedpid,4);//for mesons
1622 if (((AliAODMCParticle*)recomatched)->IsPhysicalPrimary()) fTrackHistEfficiency[3]->Fill(allrecomatchedpid,3);//for mesons
1625 if(particletypeMC==SpKaon || particletypeMC==SpProton)
1627 if(TMath::Abs(pdgCode)==321 || TMath::Abs(pdgCode)==2212) {
1628 fTrackHistEfficiency[4]->Fill(allrecomatchedpid,4);//for kaons+protons
1629 if (((AliAODMCParticle*)recomatched)->IsPhysicalPrimary()) fTrackHistEfficiency[4]->Fill(allrecomatchedpid,3);
1632 if(particletypeMC==SpPion && TMath::Abs(pdgCode)==211) {
1633 fTrackHistEfficiency[0]->Fill(allrecomatchedpid,4);//for pions
1634 if (((AliAODMCParticle*)recomatched)->IsPhysicalPrimary()) fTrackHistEfficiency[0]->Fill(allrecomatchedpid,3);
1636 if(particletypeMC==SpKaon && TMath::Abs(pdgCode)==321) {
1637 fTrackHistEfficiency[1]->Fill(allrecomatchedpid,4);//for kaons
1638 if (((AliAODMCParticle*)recomatched)->IsPhysicalPrimary()) fTrackHistEfficiency[1]->Fill(allrecomatchedpid,3);
1640 if(particletypeMC==SpProton && TMath::Abs(pdgCode)==2212){
1641 fTrackHistEfficiency[2]->Fill(allrecomatchedpid,4);//for protons
1642 if (((AliAODMCParticle*)recomatched)->IsPhysicalPrimary()) fTrackHistEfficiency[2]->Fill(allrecomatchedpid,3);
1646 if((track->Pt()>=fminPtAsso && track->Pt()<=fmaxPtAsso) || (track->Pt()>=fminPtTrig && track->Pt()<=fmaxPtTrig))//to reduce memory consumption in pool
1648 if (fapplyTrigefficiency || fapplyAssoefficiency)
1649 effmatrix=GetTrackbyTrackeffvalue(track,cent_v0,zvtx,particletypeMC);//get the tracking eff x TOF matching eff x PID eff x contamination factor for identified particles
1650 LRCParticlePID* copy1 = new LRCParticlePID(particletypeMC,track->Charge(),track->Pt(),track->Eta(), track->Phi(),effmatrix);
1651 copy1->SetUniqueID(eventno * 100000 + (Int_t)trackscount);
1652 tracksID->Add(copy1);
1654 }// if(tracktype==1) condition structure ands
1656 }//reco track loop ends
1658 //*************************************************************still in event loop
1660 //same event delta-eta-deltaphi plot
1661 if(fSampleType=="pp") cent_v0=trackscount;//multiplicity
1665 //fill the centrality/multiplicity distribution of the selected events
1666 fhistcentrality->Fill(cent_v0);//*********************************WARNING::binning of cent_v0 is different for pp and pPb/PbPb case
1668 if (fSampleType=="pPb" || fSampleType=="PbPb") fCentralityCorrelation->Fill(cent_v0, trackscount);//only with unidentified tracks(i.e before PID selection);;;;;can be used to remove centrality outliers??????
1670 //count selected events having centrality betn 0-100%
1671 fEventCounter->Fill(5);
1673 //***************************************event no. counting
1674 Bool_t isbaryontrig=kFALSE;
1675 Bool_t ismesontrig=kFALSE;
1676 if(tracksUNID && tracksUNID->GetEntriesFast()>0) fEventno->Fill(cent_v0,zvtx);
1678 if(tracksID && tracksID->GetEntriesFast()>0)
1680 for(Int_t i=0;i<tracksID->GetEntriesFast();i++)
1681 { //trigger loop starts
1682 LRCParticlePID *trig=(LRCParticlePID*)(tracksID->UncheckedAt(i));
1684 if(trig->Pt()<fminPtTrig || trig->Pt()>fmaxPtTrig) continue;
1685 Int_t particlepidtrig=trig->getparticle(); //either 1 or 2
1686 if(particlepidtrig==SpProton) isbaryontrig=kTRUE;
1687 if(particlepidtrig==SpPion) ismesontrig=kTRUE;
1689 if (isbaryontrig) fEventnobaryon->Fill(cent_v0,zvtx);
1690 if (ismesontrig) fEventnomeson->Fill(cent_v0,zvtx);
1693 //same event delte-eta, delta-phi plot
1694 if(tracksUNID && tracksUNID->GetEntriesFast()>0)//hadron triggered correlation
1695 {//same event calculation starts
1696 if(ffilltrigassoUNID) Fillcorrelation(tracksUNID,0,cent_v0,zvtx,weghtval,kFALSE,bSign,fPtOrderDataReco,kTRUE,kFALSE,"trigassoUNID");//mixcase=kFALSE (hadron-hadron correlation)
1697 if(tracksID && tracksID->GetEntriesFast()>0 && ffilltrigUNIDassoID) Fillcorrelation(tracksUNID,tracksID,cent_v0,zvtx,weghtval,kFALSE,bSign,fPtOrderDataReco,kTRUE,kFALSE,"trigUNIDassoID");//mixcase=kFALSE (hadron-ID correlation)
1700 if(tracksID && tracksID->GetEntriesFast()>0)//ID triggered correlation
1701 {//same event calculation starts
1702 if(tracksUNID && tracksUNID->GetEntriesFast()>0 && ffilltrigIDassoUNID) Fillcorrelation(tracksID,tracksUNID,cent_v0,zvtx,weghtval,kFALSE,bSign,fPtOrderDataReco,kTRUE,kFALSE,"trigIDassoUNID");//mixcase=kFALSE (ID-hadron correlation)
1703 if(ffilltrigIDassoID) Fillcorrelation(tracksID,0,cent_v0,zvtx,weghtval,kFALSE,bSign,fPtOrderDataReco,kTRUE,kFALSE,"trigIDassoID");//mixcase=kFALSE (ID-ID correlation)
1706 //still in main event loop
1708 if(ffilltrigassoUNID || ffilltrigIDassoUNID){//mixing with unidentified particles
1709 AliEventPool* pool = fPoolMgr->GetEventPool(cent_v0, zvtx);//In the pool there is tracksUNID(i.e associateds are unidentified)
1710 if (pool && pool->IsReady())
1711 {//start mixing only when pool->IsReady
1712 Float_t nmix1=(Float_t)pool->GetCurrentNEvents();
1713 for (Int_t jMix=0; jMix<pool->GetCurrentNEvents(); jMix++)
1714 { //pool event loop start
1715 TObjArray* bgTracks = pool->GetEvent(jMix);
1716 if(!bgTracks) continue;
1717 if(ffilltrigassoUNID && tracksUNID && tracksUNID->GetEntriesFast()>0)//*******************************hadron trggered mixing
1718 Fillcorrelation(tracksUNID,bgTracks,cent_v0,zvtx,nmix1,(jMix == 0),bSign,fPtOrderDataReco,kTRUE,kTRUE,"trigassoUNID");//mixcase=kTRUE
1719 if(ffilltrigIDassoUNID && tracksID && tracksID->GetEntriesFast()>0)//***********************************ID trggered mixing
1720 Fillcorrelation(tracksID,bgTracks,cent_v0,zvtx,nmix1,(jMix == 0),bSign,fPtOrderDataReco,kTRUE,kTRUE,"trigIDassoUNID");//mixcase=kTRUE
1721 }// pool event loop ends mixing case
1723 } //if pool->IsReady() condition ends mixing case
1726 pool->UpdatePool(CloneAndReduceTrackList(tracksUNID));
1728 }//mixing with unidentified particles
1730 if(ffilltrigUNIDassoID || ffilltrigIDassoID){//mixing with identified particles
1731 AliEventPool* pool1 = fPoolMgr->GetEventPool(cent_v0, zvtx+100);//In the pool1 there is tracksID(i.e associateds are identified)
1732 if (pool1 && pool1->IsReady())
1733 {//start mixing only when pool->IsReady
1734 Float_t nmix2=(Float_t)pool1->GetCurrentNEvents();
1735 for (Int_t jMix=0; jMix<pool1->GetCurrentNEvents(); jMix++)
1736 { //pool event loop start
1737 TObjArray* bgTracks2 = pool1->GetEvent(jMix);
1738 if(!bgTracks2) continue;
1739 if(ffilltrigUNIDassoID && tracksUNID && tracksUNID->GetEntriesFast()>0)
1740 Fillcorrelation(tracksUNID,bgTracks2,cent_v0,zvtx,nmix2,(jMix == 0),bSign,fPtOrderDataReco,kTRUE,kTRUE,"trigUNIDassoID");//mixcase=kTRUE
1741 if(ffilltrigIDassoID && tracksID && tracksID->GetEntriesFast()>0)
1742 Fillcorrelation(tracksID,bgTracks2,cent_v0,zvtx,nmix2,(jMix == 0),bSign,fPtOrderDataReco,kTRUE,kTRUE,"trigIDassoID");//mixcase=kTRUE
1744 }// pool event loop ends mixing case
1745 } //if pool1->IsReady() condition ends mixing case
1749 pool1->UpdatePool(CloneAndReduceTrackList(tracksID));//ownership of tracksasso is with pool now, don't delete it(tracksUNID is with pool)
1751 }//mixing with identified particles
1753 //no. of events analyzed
1754 fEventCounter->Fill(6);
1757 if(tracksUNID) delete tracksUNID;
1759 if(tracksID) delete tracksID;
1762 PostData(1, fOutput);
1765 //________________________________________________________________________
1766 void AliTwoParticlePIDCorr::doAODevent()
1770 AliVEvent *event = InputEvent();
1771 if (!event) { Printf("ERROR: Could not retrieve event"); return; }
1772 AliAODEvent* aod = dynamic_cast<AliAODEvent*>(event);
1774 AliError("Cannot get the AOD event");
1779 fEventCounter->Fill(1);
1781 // get centrality object and check quality
1784 if(fSampleType=="pPb" || fSampleType=="PbPb")
1786 AliCentrality *centrality=0;
1788 centrality = aod->GetHeader()->GetCentralityP();
1789 // if (centrality->GetQuality() != 0) return ;
1793 cent_v0 = centrality->GetCentralityPercentile(fCentralityMethod);
1801 Float_t bSign = (aod->GetMagneticField() > 0) ? 1 : -1;//for two track efficiency cut in correlation function calculation
1802 Float_t bSign1=aod->GetHeader()->GetMagneticField() ;//for dca cut in ClassifyTrack(), i.e in track loop
1804 // Pileup selection ************************************************
1805 if(frejectPileUp) //applicable only for TPC only tracks,not for hybrid tracks?.
1807 if (fAnalysisUtils && fAnalysisUtils->IsPileUpEvent(aod)) return;
1810 //count events after PileUP cut
1811 fEventCounter->Fill(2);
1813 if (!fPID) return;//this should be available with each event even if we don't do PID selection
1815 //vertex selection(is it fine for PP?)
1816 if ( fVertextype==1){//for pPb basically if(!fAnalysisUtils->IsVertexSelected2013pA(aod)) return;
1817 trkVtx = aod->GetPrimaryVertex();
1818 if (!trkVtx || trkVtx->GetNContributors()<=0) return;
1819 TString vtxTtl = trkVtx->GetTitle();
1820 if (!vtxTtl.Contains("VertexerTracks")) return;
1821 zvtx = trkVtx->GetZ();
1822 const AliAODVertex* spdVtx = aod->GetPrimaryVertexSPD();
1823 if (!spdVtx || spdVtx->GetNContributors()<=0) return;
1824 TString vtxTyp = spdVtx->GetTitle();
1825 Double_t cov[6]={0};
1826 spdVtx->GetCovarianceMatrix(cov);
1827 Double_t zRes = TMath::Sqrt(cov[5]);
1828 if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) return;
1829 if (TMath::Abs(spdVtx->GetZ() - trkVtx->GetZ())>0.5) return;
1831 else if(fVertextype==2) {//for pp and pb-pb case , taken from Jan's code
1832 Int_t nVertex = aod->GetNumberOfVertices();
1834 trkVtx = aod->GetPrimaryVertex();
1835 Int_t nTracksPrim = trkVtx->GetNContributors();
1836 zvtx = trkVtx->GetZ();
1837 //if (fDebug > 1)AliInfo(Form(" Vertex in = %f with %d particles by %s data ...",zVertex,nTracksPrim,vertex->GetName()));
1838 // Reject TPC only vertex
1839 TString name(trkVtx->GetName());
1840 if (name.CompareTo("PrimaryVertex") && name.CompareTo("SPDVertex"))return;
1842 // Select a quality vertex by number of tracks?
1843 if( nTracksPrim < fnTracksVertex ) {
1844 //if (fDebug > 1) AliInfo(" Primary-vertex Selection: event REJECTED ...");
1847 // TODO remove vertexer Z events with dispersion > 0.02: Doesn't work for AOD at present
1848 //if (strcmp(vertex->GetTitle(), "AliVertexerZ") == 0 && vertex->GetDispersion() > 0.02)
1850 // if (fDebug > 1) AliInfo(" Primary-vertex Selection: event ACCEPTED...");
1855 else if(fVertextype==0){//default case
1856 trkVtx = aod->GetPrimaryVertex();
1857 if (!trkVtx || trkVtx->GetNContributors()<=0) return;//proper number of contributors
1858 zvtx = trkVtx->GetZ();
1860 trkVtx->GetCovarianceMatrix(fCov);
1861 if(fCov[5] == 0) return;//proper vertex resolution
1864 AliInfo("Wrong Vertextype set for Primary-vertex Selection: event REJECTED ...");
1865 return;//as there is no proper sample type
1868 fHistQA[0]->Fill((trkVtx->GetX()));fHistQA[1]->Fill((trkVtx->GetY()));fHistQA[2]->Fill((trkVtx->GetZ())); //for trkVtx only before vertex cut |zvtx|<10 cm
1870 //count events having a proper vertex
1871 fEventCounter->Fill(3);
1873 if (TMath::Abs(zvtx) > fzvtxcut) return;
1875 //count events after vertex cut
1876 fEventCounter->Fill(4);
1879 //if(!fAnalysisUtils->IsVertexSelected2013pA(aod)) return;
1881 fHistQA[3]->Fill((trkVtx->GetX()));fHistQA[4]->Fill((trkVtx->GetY()));fHistQA[5]->Fill((trkVtx->GetZ()));//after vertex cut,for trkVtx only
1884 if(!aod) return; //for safety
1886 if(fSampleType=="pPb" || fSampleType=="PbPb") if (cent_v0 < 0) return;//for pp case it is the multiplicity
1888 TObjArray* tracksUNID= new TObjArray;//track info before doing PID
1889 tracksUNID->SetOwner(kTRUE); // IMPORTANT!
1891 TObjArray* tracksID= new TObjArray;//only pions, kaons,protonsi.e. after doing the PID selection
1892 tracksID->SetOwner(kTRUE); // IMPORTANT!
1894 Double_t trackscount=0.0;//in case of pp this will give the multiplicity after the track loop(only for unidentified particles that pass the filterbit and kinematic cuts)
1898 Bool_t fTrigPtmin1=kFALSE;
1899 Bool_t fTrigPtmin2=kFALSE;
1900 Bool_t fTrigPtJet=kFALSE;
1902 for (Int_t itrk = 0; itrk < aod->GetNumberOfTracks(); itrk++)
1903 { //track loop starts for TObjArray(containing track and event information) filling; used for correlation function calculation
1904 AliAODTrack* track = dynamic_cast<AliAODTrack*>(aod->GetTrack(itrk));
1905 if (!track) continue;
1906 fHistQA[11]->Fill(track->GetTPCNcls());
1907 Int_t particletype=-9999;//required for PID filling
1908 Int_t tracktype=ClassifyTrack(track,trkVtx,bSign1);//dcacut=kFALSE,onlyprimary=kFALSE
1909 if(tracktype!=1) continue;
1911 if(!track) continue;//for safety
1913 //check for eta , phi holes
1914 fEtaSpectrasso->Fill(track->Eta(),track->Pt());
1915 fphiSpectraasso->Fill(track->Phi(),track->Pt());
1919 //if no applyefficiency , set the eff factor=1.0
1920 Float_t effmatrix=1.0;
1922 //tag all particles as unidentified that passed filterbit & kinematic cuts
1923 particletype=unidentified;
1926 if(track->Pt()>=fminPtTrig) fTrigPtmin1=kTRUE;
1927 if(track->Pt()>=(fminPtTrig+0.5)) fTrigPtmin2=kTRUE;
1928 if(track->Pt()>=fmaxPtTrig) fTrigPtJet=kTRUE;
1931 if (fSampleType=="pp") cent_v0=15.0;//integrated over multiplicity [i.e each track has multiplicity 15.0](so put any fixed value for each track so that practically means there is only one bin in multiplicityi.e multiplicity intregated out )**************Important for efficiency related issues
1934 //to reduce memory consumption in pool
1935 if((track->Pt()>=fminPtAsso && track->Pt()<=fmaxPtAsso) || (track->Pt()>=fminPtTrig && track->Pt()<=fmaxPtTrig))
1937 //Clone & Reduce track list(TObjArray) for unidentified particles
1938 if (fapplyTrigefficiency || fapplyAssoefficiency)//get the trackingefficiency x contamination factor for unidentified particles
1939 effmatrix=GetTrackbyTrackeffvalue(track,cent_v0,zvtx,particletype);
1940 LRCParticlePID* copy = new LRCParticlePID(particletype,track->Charge(),track->Pt(),track->Eta(), track->Phi(),effmatrix);
1941 copy->SetUniqueID(eventno * 100000 + (Int_t)trackscount);
1942 tracksUNID->Add(copy);//track information Storage for UNID correlation function(tracks that pass the filterbit & kinematic cuts only)
1945 //now start the particle identificaion process:)
1947 //track passing filterbit 768 have proper TPC response,or need to be checked explicitly before doing PID????
1949 Float_t dEdx = track->GetTPCsignal();
1950 fHistoTPCdEdx->Fill(track->Pt(), dEdx);
1952 //fill beta vs Pt plots only for tracks having proper TOF response(much less tracks compared to the no. that pass the filterbit & kinematic cuts)
1953 if(HasTOFPID(track))
1955 Double_t beta = GetBeta(track);
1956 fHistoTOFbeta->Fill(track->Pt(), beta);
1960 //track identification(using nsigma method)
1961 particletype=GetParticle(track,fFIllPIDQAHistos);//*******************************change may be required(It should return only pion,kaon, proton and Spundefined; NOT unidentifed***************be careful)
1964 //2-d TPCTOF map(for each Pt interval)
1965 if(HasTOFPID(track)){
1966 fTPCTOFPion3d->Fill(track->Pt(),fnsigmas[SpPion][NSigmaTOF],fnsigmas[SpPion][NSigmaTPC]);
1967 fTPCTOFKaon3d->Fill(track->Pt(),fnsigmas[SpKaon][NSigmaTOF],fnsigmas[SpKaon][NSigmaTPC]);
1968 fTPCTOFProton3d->Fill(track->Pt(),fnsigmas[SpProton][NSigmaTOF],fnsigmas[SpProton][NSigmaTPC]);
1971 //ignore the Spundefined particles as they also contain pion, kaon, proton outside the nsigma cut(also if tracks don't have proper TOF PID in a certain Pt interval) & these tracks are actually counted when we do the the efficiency correction, so considering them as unidentified particles & doing the efficiency correction(i.e defining unidentified=pion+Kaon+proton+SpUndefined is right only without efficiency correction) for them will be two times wrong!!!!!
1972 if (particletype==SpUndefined) continue;//this condition creating a modulated structure in delphi projection in mixed event case(only when we are dealing with identified particles i.e. tracksID)!!!!!!!!!!!
1974 //Pt, Eta , Phi distribution of the reconstructed identified particles
1977 if (particletype==SpPion)
1979 fPionPt->Fill(track->Pt());
1980 fPionEta->Fill(track->Eta());
1981 fPionPhi->Fill(track->Phi());
1983 if (particletype==SpKaon)
1985 fKaonPt->Fill(track->Pt());
1986 fKaonEta->Fill(track->Eta());
1987 fKaonPhi->Fill(track->Phi());
1989 if (particletype==SpProton)
1991 fProtonPt->Fill(track->Pt());
1992 fProtonEta->Fill(track->Eta());
1993 fProtonPhi->Fill(track->Phi());
1997 if((track->Pt()>=fminPtAsso && track->Pt()<=fmaxPtAsso) || (track->Pt()>=fminPtTrig && track->Pt()<=fmaxPtTrig))
1999 if (fapplyTrigefficiency || fapplyAssoefficiency)
2000 effmatrix=GetTrackbyTrackeffvalue(track,cent_v0,zvtx,particletype);//get the tracking eff x TOF matching eff x PID eff x contamination factor for identified particles; Bool_t mesoneffrequired=kFALSE
2001 LRCParticlePID* copy1 = new LRCParticlePID(particletype,track->Charge(),track->Pt(),track->Eta(), track->Phi(),effmatrix);
2002 copy1->SetUniqueID(eventno * 100000 + (Int_t)trackscount);
2003 tracksID->Add(copy1);
2005 } //track loop ends but still in event loop
2007 if(trackscount<1.0){
2008 if(tracksUNID) delete tracksUNID;
2009 if(tracksID) delete tracksID;
2013 if (fTrigPtmin1) fhistJetTrigestimate->Fill(cent_v0,0.0);
2014 if (fTrigPtmin2) fhistJetTrigestimate->Fill(cent_v0,2.0);
2015 if (fTrigPtJet) fhistJetTrigestimate->Fill(cent_v0,4.0);
2017 Float_t weightval=1.0;
2020 // cout<<fminPtAsso<<"***"<<fmaxPtAsso<<"*********************"<<fminPtTrig<<"***"<<fmaxPtTrig<<"*****************"<<kTrackVariablesPair<<endl;
2021 if(fSampleType=="pp") cent_v0=trackscount;//multiplicity
2023 //fill the centrality/multiplicity distribution of the selected events
2024 fhistcentrality->Fill(cent_v0);//*********************************WARNING::binning of cent_v0 is different for pp and pPb/PbPb case
2026 if(fSampleType=="pPb" || fSampleType=="PbPb") fCentralityCorrelation->Fill(cent_v0, trackscount);//only with unidentified tracks(i.e before PID selection);;;;;can be used to remove centrality outliers??????
2028 //count selected events having centrality betn 0-100%
2029 fEventCounter->Fill(5);
2031 //***************************************event no. counting
2032 Bool_t isbaryontrig=kFALSE;
2033 Bool_t ismesontrig=kFALSE;
2034 if(tracksUNID && tracksUNID->GetEntriesFast()>0) fEventno->Fill(cent_v0,zvtx);
2036 if(tracksID && tracksID->GetEntriesFast()>0)
2038 for(Int_t i=0;i<tracksID->GetEntriesFast();i++)
2039 { //trigger loop starts
2040 LRCParticlePID *trig=(LRCParticlePID*)(tracksID->UncheckedAt(i));
2042 if(trig->Pt()<fminPtTrig || trig->Pt()>fmaxPtTrig) continue;
2043 Int_t particlepidtrig=trig->getparticle(); //either 1 or 2
2044 if(particlepidtrig==SpProton) isbaryontrig=kTRUE;
2045 if(particlepidtrig==SpPion) ismesontrig=kTRUE;
2047 if (isbaryontrig) fEventnobaryon->Fill(cent_v0,zvtx);
2048 if (ismesontrig) fEventnomeson->Fill(cent_v0,zvtx);
2052 //same event delta-eta-deltaphi plot
2054 if(tracksUNID && tracksUNID->GetEntriesFast()>0)//hadron triggered correlation
2055 {//same event calculation starts
2056 if(ffilltrigassoUNID) Fillcorrelation(tracksUNID,0,cent_v0,zvtx,weightval,kFALSE,bSign,fPtOrderDataReco,kTRUE,kFALSE,"trigassoUNID");//mixcase=kFALSE (hadron-hadron correlation)
2057 if(tracksID && tracksID->GetEntriesFast()>0 && ffilltrigUNIDassoID) Fillcorrelation(tracksUNID,tracksID,cent_v0,zvtx,weightval,kFALSE,bSign,fPtOrderDataReco,kTRUE,kFALSE,"trigUNIDassoID");//mixcase=kFALSE (hadron-ID correlation)
2060 if(tracksID && tracksID->GetEntriesFast()>0)//ID triggered correlation
2061 {//same event calculation starts
2062 if(tracksUNID && tracksUNID->GetEntriesFast()>0 && ffilltrigIDassoUNID) Fillcorrelation(tracksID,tracksUNID,cent_v0,zvtx,weightval,kFALSE,bSign,fPtOrderDataReco,kTRUE,kFALSE,"trigIDassoUNID");//mixcase=kFALSE (ID-hadron correlation)
2063 if(ffilltrigIDassoID) Fillcorrelation(tracksID,0,cent_v0,zvtx,weightval,kFALSE,bSign,fPtOrderDataReco,kTRUE,kFALSE,"trigIDassoID");//mixcase=kFALSE (ID-ID correlation)
2066 //still in main event loop
2070 if(ffilltrigassoUNID || ffilltrigIDassoUNID){//mixing with unidentified particles
2071 AliEventPool* pool = fPoolMgr->GetEventPool(cent_v0, zvtx);//In the pool there is tracksUNID(i.e associateds are unidentified)
2072 if (pool && pool->IsReady())
2073 {//start mixing only when pool->IsReady
2074 Float_t nmix1=(Float_t)pool->GetCurrentNEvents();
2075 for (Int_t jMix=0; jMix<pool->GetCurrentNEvents(); jMix++)
2076 { //pool event loop start
2077 TObjArray* bgTracks = pool->GetEvent(jMix);
2078 if(!bgTracks) continue;
2079 if(ffilltrigassoUNID && tracksUNID && tracksUNID->GetEntriesFast()>0)//*******************************hadron trggered mixing
2080 Fillcorrelation(tracksUNID,bgTracks,cent_v0,zvtx,nmix1,(jMix == 0),bSign,fPtOrderDataReco,kTRUE,kTRUE,"trigassoUNID");//mixcase=kTRUE
2081 if(ffilltrigIDassoUNID && tracksID && tracksID->GetEntriesFast()>0)//***********************************ID trggered mixing
2082 Fillcorrelation(tracksID,bgTracks,cent_v0,zvtx,nmix1,(jMix == 0),bSign,fPtOrderDataReco,kTRUE,kTRUE,"trigIDassoUNID");//mixcase=kTRUE
2083 }// pool event loop ends mixing case
2084 } //if pool->IsReady() condition ends mixing case
2087 pool->UpdatePool(CloneAndReduceTrackList(tracksUNID));
2089 }//mixing with unidentified particles
2092 if(ffilltrigUNIDassoID || ffilltrigIDassoID){//mixing with identified particles
2093 AliEventPool* pool1 = fPoolMgr->GetEventPool(cent_v0, zvtx+100);//In the pool1 there is tracksID(i.e associateds are identified)
2094 if (pool1 && pool1->IsReady())
2095 {//start mixing only when pool->IsReady
2096 Float_t nmix2=(Float_t)pool1->GetCurrentNEvents();
2097 for (Int_t jMix=0; jMix<pool1->GetCurrentNEvents(); jMix++)
2098 { //pool event loop start
2099 TObjArray* bgTracks2 = pool1->GetEvent(jMix);
2100 if(!bgTracks2) continue;
2101 if(ffilltrigUNIDassoID && tracksUNID && tracksUNID->GetEntriesFast()>0)
2102 Fillcorrelation(tracksUNID,bgTracks2,cent_v0,zvtx,nmix2,(jMix == 0),bSign,fPtOrderDataReco,kTRUE,kTRUE,"trigUNIDassoID");//mixcase=kTRUE
2103 if(ffilltrigIDassoID && tracksID && tracksID->GetEntriesFast()>0)
2104 Fillcorrelation(tracksID,bgTracks2,cent_v0,zvtx,nmix2,(jMix == 0),bSign,fPtOrderDataReco,kTRUE,kTRUE,"trigIDassoID");//mixcase=kTRUE
2106 }// pool event loop ends mixing case
2107 } //if pool1->IsReady() condition ends mixing case
2111 pool1->UpdatePool(CloneAndReduceTrackList(tracksID));//ownership of tracksasso is with pool now, don't delete it(tracksUNID is with pool)
2113 }//mixing with identified particles
2116 //no. of events analyzed
2117 fEventCounter->Fill(6);
2119 //still in main event loop
2122 if(tracksUNID) delete tracksUNID;
2124 if(tracksID) delete tracksID;
2127 PostData(1, fOutput);
2129 } // *************************event loop ends******************************************//_______________________________________________________________________
2130 TObjArray* AliTwoParticlePIDCorr::CloneAndReduceTrackList(TObjArray* tracks)
2132 // clones a track list by using AliDPhiBasicParticle which uses much less memory (used for event mixing)
2134 TObjArray* tracksClone = new TObjArray;
2135 tracksClone->SetOwner(kTRUE);
2137 for (Int_t i=0; i<tracks->GetEntriesFast(); i++)
2139 LRCParticlePID* particle = (LRCParticlePID*) tracks->UncheckedAt(i);
2140 LRCParticlePID* copy100 = new LRCParticlePID(particle->getparticle(),particle->Charge(), particle->Pt(),particle->Eta(), particle->Phi(), particle->geteffcorrectionval());
2141 copy100->SetUniqueID(particle->GetUniqueID());
2142 tracksClone->Add(copy100);
2148 //--------------------------------------------------------------------------------
2149 void AliTwoParticlePIDCorr::Fillcorrelation(TObjArray *trackstrig,TObjArray *tracksasso,Double_t cent,Float_t vtx,Float_t weight,Bool_t firstTime,Float_t bSign,Bool_t fPtOrder,Bool_t twoTrackEfficiencyCut,Bool_t mixcase,TString fillup)
2152 //before calling this function check that either trackstrig & tracksasso are available
2154 // Eta() is extremely time consuming, therefore cache it for the inner loop here:
2155 TObjArray* input = (tracksasso) ? tracksasso : trackstrig;
2156 TArrayF eta(input->GetEntriesFast());
2157 for (Int_t i=0; i<input->GetEntriesFast(); i++)
2158 eta[i] = ((LRCParticlePID*) input->UncheckedAt(i))->Eta();
2161 Int_t jmax=trackstrig->GetEntriesFast();
2163 jmax=tracksasso->GetEntriesFast();
2165 // identify K, Lambda candidates and flag those particles
2166 // a TObject bit is used for this
2167 const UInt_t kResonanceDaughterFlag = 1 << 14;
2168 if (fRejectResonanceDaughters > 0)
2170 Double_t resonanceMass = -1;
2171 Double_t massDaughter1 = -1;
2172 Double_t massDaughter2 = -1;
2173 const Double_t interval = 0.02;
2174 switch (fRejectResonanceDaughters)
2176 case 1: resonanceMass = 0.9; massDaughter1 = 0.1396; massDaughter2 = 0.9383; break; // method test
2177 case 2: resonanceMass = 0.4976; massDaughter1 = 0.1396; massDaughter2 = massDaughter1; break; // k0
2178 case 3: resonanceMass = 1.115; massDaughter1 = 0.1396; massDaughter2 = 0.9383; break; // lambda
2179 default: AliFatal(Form("Invalid setting %d", fRejectResonanceDaughters));
2182 for (Int_t i=0; i<trackstrig->GetEntriesFast(); i++)
2183 trackstrig->UncheckedAt(i)->ResetBit(kResonanceDaughterFlag);
2184 for (Int_t i=0; tracksasso->GetEntriesFast(); i++)
2185 tracksasso->UncheckedAt(i)->ResetBit(kResonanceDaughterFlag);
2187 for (Int_t i=0; i<trackstrig->GetEntriesFast(); i++)
2189 LRCParticlePID *trig=(LRCParticlePID*)(trackstrig->UncheckedAt(i));
2190 for (Int_t j=0; tracksasso->GetEntriesFast(); j++)
2192 LRCParticlePID *asso=(LRCParticlePID*)(tracksasso->UncheckedAt(j));
2194 // check if both particles point to the same element (does not occur for mixed events, but if subsets are mixed within the same event)
2195 if (trig->IsEqual(asso)) continue;
2197 if (trig->Charge() * asso->Charge() > 0) continue;
2199 Float_t mass = GetInvMassSquaredCheap(trig->Pt(), trig->Eta(), trig->Phi(), asso->Pt(), asso->Eta(), asso->Phi(), massDaughter1, massDaughter2);
2201 if (TMath::Abs(mass - resonanceMass*resonanceMass) < interval*5)
2203 mass = GetInvMassSquared(trig->Pt(), trig->Eta(), trig->Phi(), asso->Pt(), asso->Eta(), asso->Phi(), massDaughter1, massDaughter2);
2205 if (mass > (resonanceMass-interval)*(resonanceMass-interval) && mass < (resonanceMass+interval)*(resonanceMass+interval))
2207 trig->SetBit(kResonanceDaughterFlag);
2208 asso->SetBit(kResonanceDaughterFlag);
2210 // Printf("Flagged %d %d %f", i, j, TMath::Sqrt(mass));
2217 //Select the highest Pt trigger particle in an event (within a given Pt trigger range)
2219 Float_t TriggerPtMin=fminPtTrig;
2220 Float_t TriggerPtMax=fmaxPtTrig;
2221 Int_t HighestPtTriggerIndx=-99999;
2222 TH1* triggerWeighting = 0;
2224 if(fSelectHighestPtTrig || fWeightPerEvent)//**************add this data member to the constructor
2226 if (fWeightPerEvent)
2229 if(ffilltrigassoUNID || ffilltrigUNIDassoID || ffilltrigIDassoUNID || ffilltrigIDassoID) axis = fTHnTrigcount->GetGrid(0)->GetGrid()->GetAxis(2);
2230 if((fAnalysisType =="MCAOD") && ffilltrigIDassoIDMCTRUTH) axis = fTHnTrigcountMCTruthPrim->GetGrid(0)->GetGrid()->GetAxis(2);
2231 triggerWeighting = new TH1F("triggerWeighting", "", axis->GetNbins(), axis->GetXbins()->GetArray());
2233 for(Int_t i=0;i<trackstrig->GetEntriesFast();i++)
2234 { //trigger loop starts(highest Pt trigger selection)
2235 LRCParticlePID *trig=(LRCParticlePID*)(trackstrig->UncheckedAt(i));
2237 Float_t trigpt=trig->Pt();
2238 //to avoid overflow qnd underflow
2239 if(trigpt<fminPtTrig || trigpt>fmaxPtTrig) continue;
2240 Int_t particlepidtrig=trig->getparticle();
2241 if(fTriggerSpeciesSelection){ if (particlepidtrig!=fTriggerSpecies) continue;}
2243 Float_t trigeta=trig->Eta();
2245 // some optimization
2246 if (fTriggerRestrictEta > 0 && TMath::Abs(trigeta) > fTriggerRestrictEta)
2249 if (fOnlyOneEtaSide != 0)
2251 if (fOnlyOneEtaSide * trigeta < 0)
2254 if (fTriggerSelectCharge != 0)
2255 if (trig->Charge() * fTriggerSelectCharge < 0)
2258 if (fRejectResonanceDaughters > 0)
2259 if (trig->TestBit(kResonanceDaughterFlag)) continue;
2261 if(fSelectHighestPtTrig){
2262 if(trigpt>TriggerPtMin && trigpt<=TriggerPtMax)
2264 HighestPtTriggerIndx=(Int_t)trig->GetUniqueID();
2265 TriggerPtMin=trigpt;
2269 if (fWeightPerEvent) triggerWeighting->Fill(trigpt);
2271 }//trigger loop ends(highest Pt trigger selection)
2273 }//******************(fSelectHighestPtTrig || fWeightPerEvent) condition ends
2276 //two particle correlation filling
2277 for(Int_t i=0;i<trackstrig->GetEntriesFast();i++)
2278 { //trigger loop starts
2279 LRCParticlePID *trig=(LRCParticlePID*)(trackstrig->UncheckedAt(i));
2281 Float_t trigpt=trig->Pt();
2282 //to avoid overflow qnd underflow
2283 if(trigpt<fminPtTrig || trigpt>fmaxPtTrig) continue;
2284 Int_t particlepidtrig=trig->getparticle();
2285 if(fTriggerSpeciesSelection){ if (particlepidtrig!=fTriggerSpecies) continue;}
2287 Float_t trigeta=trig->Eta();
2289 // some optimization
2290 if (fTriggerRestrictEta > 0 && TMath::Abs(trigeta) > fTriggerRestrictEta)
2293 if (fOnlyOneEtaSide != 0)
2295 if (fOnlyOneEtaSide * trigeta < 0)
2298 if (fTriggerSelectCharge != 0)
2299 if (trig->Charge() * fTriggerSelectCharge < 0)
2302 if (fRejectResonanceDaughters > 0)
2303 if (trig->TestBit(kResonanceDaughterFlag)) continue;
2305 if(fSelectHighestPtTrig && HighestPtTriggerIndx!=-99999) {
2306 if(trig->GetUniqueID()!=(UInt_t)HighestPtTriggerIndx) continue;
2309 Float_t trigphi=trig->Phi();
2310 Float_t trackefftrig=1.0;
2311 if(fapplyTrigefficiency) trackefftrig=trig->geteffcorrectionval();
2312 //cout<<"*******************trackefftrig="<<trackefftrig<<endl;
2315 if(fcontainPIDtrig) dim=4;
2316 trigval= new Double_t[dim];
2319 trigval[2] = trigpt;
2320 if(fcontainPIDtrig) trigval[3] = particlepidtrig;
2322 if (fWeightPerEvent)
2324 // leads effectively to a filling of one entry per filled trigger particle pT bin
2325 Int_t weightBin = triggerWeighting->GetXaxis()->FindBin(trigval[2]);
2326 // Printf("Using weight %f", triggerWeighting->GetBinContent(weightBin));
2327 trackefftrig *= triggerWeighting->GetBinContent(weightBin);
2331 //trigger particle counting for both same and mixed event case;;;;;step=0->same event case;;;;;step=1->mixed event case;;;;;;
2332 if(ffilltrigassoUNID==kTRUE && ffilltrigUNIDassoID==kTRUE){
2333 if(fillup=="trigassoUNID" ) {
2334 if(mixcase==kFALSE) fTHnTrigcount->Fill(trigval,0,1.0/trackefftrig);
2335 if(mixcase==kTRUE && firstTime) fTHnTrigcount->Fill(trigval,1,1.0/trackefftrig);
2338 if(ffilltrigassoUNID==kTRUE && ffilltrigUNIDassoID==kFALSE){
2339 if(fillup=="trigassoUNID" )
2341 if(mixcase==kFALSE) fTHnTrigcount->Fill(trigval,0,1.0/trackefftrig);
2342 if(mixcase==kTRUE && firstTime) fTHnTrigcount->Fill(trigval,1,1.0/trackefftrig);
2345 if(ffilltrigassoUNID==kFALSE && ffilltrigUNIDassoID==kTRUE){
2346 if(fillup=="trigUNIDassoID")
2348 if(mixcase==kFALSE) fTHnTrigcount->Fill(trigval,0,1.0/trackefftrig);
2349 if(mixcase==kTRUE && firstTime) fTHnTrigcount->Fill(trigval,1,1.0/trackefftrig);
2352 //ensure that trigIDassoID , trigassoUNID, trigIDassoUNID & trigUNIDassoID case FillCorrelation called only once in the event loop for same event correlation function calculation, otherwise there will be multiple counting of pion, kaon,proton,unidentified
2353 if(ffilltrigIDassoUNID==kTRUE && ffilltrigIDassoID==kTRUE){
2354 if(fillup=="trigIDassoID")
2356 if(mixcase==kFALSE) fTHnTrigcount->Fill(trigval,0,1.0/trackefftrig);
2357 if(mixcase==kTRUE && firstTime) fTHnTrigcount->Fill(trigval,1,1.0/trackefftrig);
2360 if(ffilltrigIDassoUNID==kTRUE && ffilltrigIDassoID==kFALSE){
2361 if(fillup=="trigIDassoUNID" )
2363 if(mixcase==kFALSE) fTHnTrigcount->Fill(trigval,0,1.0/trackefftrig);
2364 if(mixcase==kTRUE && firstTime) fTHnTrigcount->Fill(trigval,1,1.0/trackefftrig);
2367 if(ffilltrigIDassoUNID==kFALSE && ffilltrigIDassoID==kTRUE){
2368 if(fillup=="trigIDassoID")
2370 if(mixcase==kFALSE) fTHnTrigcount->Fill(trigval,0,1.0/trackefftrig);
2371 if(mixcase==kTRUE && firstTime) fTHnTrigcount->Fill(trigval,1,1.0/trackefftrig);
2375 if(fillup=="trigIDassoIDMCTRUTH") { //In truth MC case "Unidentified" means any particle other than pion,kaon or proton and no efficiency correction(default value 1.0)************************be careful!!!!
2376 if(mixcase==kFALSE) fTHnTrigcountMCTruthPrim->Fill(trigval,0,1.0/trackefftrig);
2377 if(mixcase==kTRUE && firstTime) fTHnTrigcountMCTruthPrim->Fill(trigval,1,1.0/trackefftrig);
2380 //asso loop starts within trigger loop
2381 for(Int_t j=0;j<jmax;j++)
2383 LRCParticlePID *asso=0;
2385 asso=(LRCParticlePID*)(trackstrig->UncheckedAt(j));
2387 asso=(LRCParticlePID*)(tracksasso->UncheckedAt(j));
2391 //to avoid overflow qnd underflow
2392 if(asso->Pt()<fminPtAsso || asso->Pt()>fmaxPtAsso) continue;//***********************Important
2394 //if(fmaxPtAsso==fminPtTrig) {if(asso->Pt()==fminPtTrig) continue;}//******************Think about it!
2396 if(!tracksasso && j==i) continue;
2398 // check if both particles point to the same element (does not occur for mixed events, but if subsets are mixed within the same event,i.e. both Trig and asso TObjArray belongs to the same Pi range but say Trig is Unidentified but asso is identified then the serial no. wise particles are not same and and j==i doesn't aplly)
2399 // if (tracksasso && trig->IsEqual(asso)) continue;
2401 if (tracksasso && (trig->GetUniqueID()==asso->GetUniqueID())) continue;
2404 if (asso->Pt() >= trig->Pt()) continue;
2406 Int_t particlepidasso=asso->getparticle();
2407 if(fAssociatedSpeciesSelection){ if (particlepidasso!=fAssociatedSpecies) continue;}
2410 if (fAssociatedSelectCharge != 0)
2411 if (asso->Charge() * fAssociatedSelectCharge < 0) continue;
2413 if (fSelectCharge > 0)
2416 if (fSelectCharge == 1 && asso->Charge() * trig->Charge() > 0)
2420 if (fSelectCharge == 2 && asso->Charge() * trig->Charge() < 0)
2426 if (trigeta < 0 && asso->Eta() < trigeta)
2428 if (trigeta > 0 && asso->Eta() > trigeta)
2432 if (fRejectResonanceDaughters > 0)
2433 if (asso->TestBit(kResonanceDaughterFlag))
2435 // Printf("Skipped j=%d", j);
2440 if (fCutConversions && asso->Charge() * trig->Charge() < 0)
2442 Float_t mass = GetInvMassSquaredCheap(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j], asso->Phi(), 0.510e-3, 0.510e-3);
2446 mass = GetInvMassSquared(trig->Pt(), trigeta, trig->Phi(), asso->Pt(), eta[j], asso->Phi(), 0.510e-3, 0.510e-3);
2448 //fControlConvResoncances->Fill(0.0, mass);
2450 if (mass < 0.04*0.04)
2456 if (fCutResonances && asso->Charge() * trig->Charge() < 0)
2458 Float_t mass = GetInvMassSquaredCheap(trig->Pt(), trigeta, trig->Phi(), asso->Pt(), eta[j], asso->Phi(), 0.1396, 0.1396);
2460 const Float_t kK0smass = 0.4976;
2462 if (TMath::Abs(mass - kK0smass*kK0smass) < 0.1)
2464 mass = GetInvMassSquared(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j], asso->Phi(), 0.1396, 0.1396);
2466 //fControlConvResoncances->Fill(1, mass - kK0smass*kK0smass);
2468 if (mass > (kK0smass-0.02)*(kK0smass-0.02) && mass < (kK0smass+0.02)*(kK0smass+0.02))
2474 if (fCutResonances && asso->Charge() * trig->Charge() < 0)
2476 Float_t mass1 = GetInvMassSquaredCheap(trig->Pt(), trigeta, trig->Phi(), asso->Pt(), eta[j], asso->Phi(), 0.1396, 0.9383);
2477 Float_t mass2 = GetInvMassSquaredCheap(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j] , asso->Phi(), 0.9383, 0.1396);
2479 const Float_t kLambdaMass = 1.115;
2481 if (TMath::Abs(mass1 - kLambdaMass*kLambdaMass) < 0.1)
2483 mass1 = GetInvMassSquared(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j], asso->Phi(), 0.1396, 0.9383);
2485 //fControlConvResoncances->Fill(2, mass1 - kLambdaMass*kLambdaMass);
2487 if (mass1 > (kLambdaMass-0.02)*(kLambdaMass-0.02) && mass1 < (kLambdaMass+0.02)*(kLambdaMass+0.02))
2490 if (TMath::Abs(mass2 - kLambdaMass*kLambdaMass) < 0.1)
2492 mass2 = GetInvMassSquared(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j] , asso->Phi(), 0.9383, 0.1396);
2494 //fControlConvResoncances->Fill(2, mass2 - kLambdaMass*kLambdaMass);
2496 if (mass2 > (kLambdaMass-0.02)*(kLambdaMass-0.02) && mass2 < (kLambdaMass+0.02)*(kLambdaMass+0.02))
2501 if (twoTrackEfficiencyCut)
2503 // the variables & cuthave been developed by the HBT group
2504 // see e.g. https://indico.cern.ch/materialDisplay.py?contribId=36&sessionId=6&materialId=slides&confId=142700
2505 Float_t phi1 = trig->Phi();
2506 Float_t pt1 = trig->Pt();
2507 Float_t charge1 = trig->Charge();
2508 Float_t phi2 = asso->Phi();
2509 Float_t pt2 = asso->Pt();
2510 Float_t charge2 = asso->Charge();
2512 Float_t deta= trigeta - eta[j];
2515 if (TMath::Abs(deta) < twoTrackEfficiencyCutValue * 2.5 * 3)
2518 // check first boundaries to see if is worth to loop and find the minimum
2519 Float_t dphistar1 = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, 0.8, bSign);
2520 Float_t dphistar2 = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, 2.5, bSign);
2522 const Float_t kLimit = twoTrackEfficiencyCutValue * 3;
2524 Float_t dphistarminabs = 1e5;
2525 Float_t dphistarmin = 1e5;
2527 if (TMath::Abs(dphistar1) < kLimit || TMath::Abs(dphistar2) < kLimit || dphistar1 * dphistar2 < 0)
2529 for (Double_t rad=0.8; rad<2.51; rad+=0.01)
2531 Float_t dphistar = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, rad, bSign);
2533 Float_t dphistarabs = TMath::Abs(dphistar);
2535 if (dphistarabs < dphistarminabs)
2537 dphistarmin = dphistar;
2538 dphistarminabs = dphistarabs;
2542 if (dphistarminabs < twoTrackEfficiencyCutValue && TMath::Abs(deta) < twoTrackEfficiencyCutValue)
2544 // Printf("Removed track pair %d %d with %f %f %f %f %f %f %f %f %f", i, j, deta, dphistarminabs, phi1, pt1, charge1, phi2, pt2, charge2, bSign);
2547 //fTwoTrackDistancePt[1]->Fill(deta, dphistarmin, TMath::Abs(pt1 - pt2));
2553 Float_t weightperevent=weight;
2554 Float_t trackeffasso=1.0;
2555 if(fapplyAssoefficiency) trackeffasso=asso->geteffcorrectionval();
2556 //cout<<"*******************trackeffasso="<<trackeffasso<<endl;
2557 Float_t deleta=trigeta-eta[j];
2558 Float_t delphi=PhiRange(trigphi-asso->Phi());
2560 //here get the two particle efficiency correction factor
2561 Float_t effweight=trackefftrig*trackeffasso*weightperevent;
2562 // if(mixcase==kFALSE) cout<<"*******************effweight="<<effweight<<endl;
2564 vars= new Double_t[kTrackVariablesPair];
2571 if(fcontainPIDtrig && !fcontainPIDasso) vars[6]=particlepidtrig;
2572 if(!fcontainPIDtrig && fcontainPIDasso) vars[6]=particlepidasso;
2573 if(fcontainPIDtrig && fcontainPIDasso){
2574 vars[6]=particlepidtrig;
2575 vars[7]=particlepidasso;
2578 if (fWeightPerEvent)
2580 Int_t weightBin = triggerWeighting->GetXaxis()->FindBin(vars[2]);
2581 // Printf("Using weight %f", triggerWeighting->GetBinContent(weightBin));
2582 effweight *= triggerWeighting->GetBinContent(weightBin);
2586 //Fill Correlation ThnSparses
2587 if(fillup=="trigassoUNID")
2589 if(mixcase==kFALSE) fTHnCorrUNID->Fill(vars,0,1.0/effweight);
2590 if(mixcase==kTRUE) fTHnCorrUNIDmix->Fill(vars,0,1.0/effweight);
2592 if(fillup=="trigIDassoID")
2594 if(mixcase==kFALSE) fTHnCorrID->Fill(vars,0,1.0/effweight);
2595 if(mixcase==kTRUE) fTHnCorrIDmix->Fill(vars,0,1.0/effweight);
2597 if(fillup=="trigIDassoIDMCTRUTH")//******************************************for TRUTH MC particles
2598 {//in this case effweight should be 1 always
2599 if(mixcase==kFALSE) fCorrelatonTruthPrimary->Fill(vars,0,1.0/effweight);
2600 if(mixcase==kTRUE) fCorrelatonTruthPrimarymix->Fill(vars,0,1.0/effweight);
2602 if(fillup=="trigIDassoUNID" || fillup=="trigUNIDassoID")//****************************be careful
2604 if(mixcase==kFALSE) fTHnCorrIDUNID->Fill(vars,0,1.0/effweight);
2605 if(mixcase==kTRUE) fTHnCorrIDUNIDmix->Fill(vars,0,1.0/effweight);
2611 }//trigger loop ends
2613 if (triggerWeighting)
2615 delete triggerWeighting;
2616 triggerWeighting = 0;
2620 //--------------------------------------------------------------------------------
2621 Float_t AliTwoParticlePIDCorr::GetTrackbyTrackeffvalue(AliAODTrack* track,Double_t cent,Float_t evzvtx, Int_t parpid)
2623 //This function is called only when applyefficiency=kTRUE; also ensure that "track" is present before calling that function
2625 Float_t effvalue=1.;
2627 if(parpid==unidentified)
2629 effVars[0] = effcorection[5]->GetAxis(0)->FindBin(cent);
2630 effVars[1] = effcorection[5]->GetAxis(1)->FindBin(evzvtx);
2631 effVars[2] = effcorection[5]->GetAxis(2)->FindBin(track->Pt());
2632 effVars[3] = effcorection[5]->GetAxis(3)->FindBin(track->Eta());
2633 effvalue=effcorection[5]->GetBinContent(effVars);
2635 if(parpid==SpPion || parpid==SpKaon)
2637 if(fmesoneffrequired && !fkaonprotoneffrequired && track->Pt()>=fminPtComboeff && track->Pt()<=fmaxPtComboeff)
2639 effVars[0] = effcorection[3]->GetAxis(0)->FindBin(cent);
2640 effVars[1] = effcorection[3]->GetAxis(1)->FindBin(evzvtx);
2641 effVars[2] = effcorection[3]->GetAxis(2)->FindBin(track->Pt());
2642 effVars[3] = effcorection[3]->GetAxis(3)->FindBin(track->Eta());
2643 effvalue=effcorection[3]->GetBinContent(effVars);
2648 effVars[0] = effcorection[0]->GetAxis(0)->FindBin(cent);
2649 effVars[1] = effcorection[0]->GetAxis(1)->FindBin(evzvtx);
2650 effVars[2] = effcorection[0]->GetAxis(2)->FindBin(track->Pt());
2651 effVars[3] = effcorection[0]->GetAxis(3)->FindBin(track->Eta());
2652 effvalue=effcorection[0]->GetBinContent(effVars);
2657 effVars[0] = effcorection[1]->GetAxis(0)->FindBin(cent);
2658 effVars[1] = effcorection[1]->GetAxis(1)->FindBin(evzvtx);
2659 effVars[2] = effcorection[1]->GetAxis(2)->FindBin(track->Pt());
2660 effVars[3] = effcorection[1]->GetAxis(3)->FindBin(track->Eta());
2661 effvalue=effcorection[1]->GetBinContent(effVars);
2666 if(parpid==SpProton)
2668 effVars[0] = effcorection[2]->GetAxis(0)->FindBin(cent);
2669 effVars[1] = effcorection[2]->GetAxis(1)->FindBin(evzvtx);
2670 effVars[2] = effcorection[2]->GetAxis(2)->FindBin(track->Pt());
2671 effVars[3] = effcorection[2]->GetAxis(3)->FindBin(track->Eta());
2672 effvalue=effcorection[2]->GetBinContent(effVars);
2675 if(fkaonprotoneffrequired && !fmesoneffrequired && track->Pt()>=fminPtComboeff && track->Pt()<=fmaxPtComboeff)
2677 if(parpid==SpProton || parpid==SpKaon)
2679 effVars[0] = effcorection[4]->GetAxis(0)->FindBin(cent);
2680 effVars[1] = effcorection[4]->GetAxis(1)->FindBin(evzvtx);
2681 effVars[2] = effcorection[4]->GetAxis(2)->FindBin(track->Pt());
2682 effVars[3] = effcorection[4]->GetAxis(3)->FindBin(track->Eta());
2683 effvalue=effcorection[4]->GetBinContent(effVars);
2686 // Printf("%d %d %d %d %f", effVars[0], effVars[1], effVars[2], effVars[3], fEfficiencyCorrectionAssociated->GetBinContent(effVars));
2687 if(effvalue==0.) effvalue=1.;
2692 //-----------------------------------------------------------------------
2694 Int_t AliTwoParticlePIDCorr::ClassifyTrack(AliAODTrack* track,AliAODVertex* vertex,Float_t magfield)
2697 if(!track) return 0;
2698 Bool_t trackOK = track->TestFilterBit(fFilterBit);
2699 if(!trackOK) return 0;
2700 if (fTrackStatus != 0 && !CheckTrack(track)) return 0;
2701 //select only primary traks(for data & reco MC tracks)
2702 if(fonlyprimarydatareco && track->GetType()!=AliAODTrack::kPrimary) return 0;
2703 if(track->Charge()==0) return 0;
2704 fHistQA[12]->Fill(track->GetTPCNcls());
2707 dz = track->ZAtDCA();
2708 fHistQA[6]->Fill(dxy);
2709 fHistQA[7]->Fill(dz);
2710 Float_t chi2ndf = track->Chi2perNDF();
2711 fHistQA[13]->Fill(chi2ndf);
2712 Float_t nCrossedRowsTPC = track->GetTPCClusterInfo(2,1);
2713 fHistQA[14]->Fill(nCrossedRowsTPC);
2714 //Float_t ratioCrossedRowsOverFindableClustersTPC = 1.0;
2715 if (track->GetTPCNclsF()>0) {
2716 Float_t ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC/track->GetTPCNclsF();
2717 fHistQA[15]->Fill(ratioCrossedRowsOverFindableClustersTPC);
2720 Float_t pt=track->Pt();
2721 if(pt< fminPt || pt> fmaxPt) return 0;
2722 if(TMath::Abs(track->Eta())> fmaxeta) return 0;
2723 if(track->Phi()<0. || track->Phi()>2*TMath::Pi()) return 0;
2724 //if (!HasTPCPID(track)) return 0;//trigger & associated particles must have TPC PID,Is it required
2726 if (fdcacut && fDCAXYCut)
2733 AliAODTrack* clone =(AliAODTrack*) track->Clone();
2734 Bool_t success = clone->PropagateToDCA(vertex, magfield, fdcacutvalue, pos, covar);
2739 // Printf("%f", ((AliAODTrack*)part)->DCA());
2740 // Printf("%f", pos[0]);
2741 if (TMath::Abs(pos[0]) > fDCAXYCut->Eval(track->Pt()))
2745 if (fSharedClusterCut >= 0)
2747 Double_t frac = Double_t(((AliAODTrack*)track)->GetTPCnclsS()) / Double_t(((AliAODTrack*)track)->GetTPCncls());
2748 if (frac > fSharedClusterCut)
2751 fHistQA[8]->Fill(pt);
2752 fHistQA[9]->Fill(track->Eta());
2753 fHistQA[10]->Fill(track->Phi());
2756 //________________________________________________________________________________
2757 void AliTwoParticlePIDCorr::CalculateNSigmas(AliAODTrack *track, Bool_t FIllQAHistos)
2759 //This function is called within the func GetParticle() for accepted tracks only i.e.after call of Classifytrack() & for those tracks which have proper TPC PID response . combined nsigma(circular) cut only for particles having pt upto 4.0 Gev/c and beyond that use the asymmetric nsigma cut around pion's mean position in TPC ( while filling the TObjArray for trig & asso )
2760 Float_t pt=track->Pt();
2762 //it is assumed that every track that passed the filterbit have proper TPC response(!!)
2763 Float_t nsigmaTPCkPion =fPID->NumberOfSigmasTPC(track, AliPID::kPion);
2764 Float_t nsigmaTPCkKaon =fPID->NumberOfSigmasTPC(track, AliPID::kKaon);
2765 Float_t nsigmaTPCkProton =fPID->NumberOfSigmasTPC(track, AliPID::kProton);
2767 Float_t nsigmaTOFkProton=999.,nsigmaTOFkKaon=999.,nsigmaTOFkPion=999.;
2768 Float_t nsigmaTPCTOFkProton=999.,nsigmaTPCTOFkKaon=999.,nsigmaTPCTOFkPion=999.;
2770 if(HasTOFPID(track) && pt>fPtTOFPIDmin)
2773 nsigmaTOFkPion =fPID->NumberOfSigmasTOF(track, AliPID::kPion);
2774 nsigmaTOFkKaon =fPID->NumberOfSigmasTOF(track, AliPID::kKaon);
2775 nsigmaTOFkProton =fPID->NumberOfSigmasTOF(track, AliPID::kProton);
2777 nsigmaTPCTOFkPion = TMath::Sqrt(nsigmaTPCkPion*nsigmaTPCkPion+nsigmaTOFkPion*nsigmaTOFkPion);
2778 nsigmaTPCTOFkKaon = TMath::Sqrt(nsigmaTPCkKaon*nsigmaTPCkKaon+nsigmaTOFkKaon*nsigmaTOFkKaon);
2779 nsigmaTPCTOFkProton = TMath::Sqrt(nsigmaTPCkProton*nsigmaTPCkProton+nsigmaTOFkProton*nsigmaTOFkProton);
2785 // if TOF is missing and below fPtTOFPID only the TPC information is used
2786 nsigmaTPCTOFkProton = TMath::Abs(nsigmaTPCkProton);
2787 nsigmaTPCTOFkKaon = TMath::Abs(nsigmaTPCkKaon);
2788 nsigmaTPCTOFkPion = TMath::Abs(nsigmaTPCkPion);
2792 //set data member fnsigmas
2793 fnsigmas[SpPion][NSigmaTPC]=nsigmaTPCkPion;
2794 fnsigmas[SpKaon][NSigmaTPC]=nsigmaTPCkKaon;
2795 fnsigmas[SpProton][NSigmaTPC]=nsigmaTPCkProton;
2797 //for all tracks below fPtTOFPIDmin and also for tracks above fPtTOFPIDmin without proper TOF response these TOF nsigma values will be 999.
2798 fnsigmas[SpPion][NSigmaTOF]=nsigmaTOFkPion;
2799 fnsigmas[SpKaon][NSigmaTOF]=nsigmaTOFkKaon;
2800 fnsigmas[SpProton][NSigmaTOF]=nsigmaTOFkProton;
2802 //for all tracks below fPtTOFPIDmin and also for tracks above fPtTOFPIDmin without proper TOF response these TPCTOF nsigma values will be TMath::Abs(TPC only nsigma)
2803 fnsigmas[SpPion][NSigmaTPCTOF]=nsigmaTPCTOFkPion;
2804 fnsigmas[SpKaon][NSigmaTPCTOF]=nsigmaTPCTOFkKaon;
2805 fnsigmas[SpProton][NSigmaTPCTOF]=nsigmaTPCTOFkProton;
2808 //Fill NSigma SeparationPlot
2809 for(Int_t ipart=0;ipart<NSpecies;ipart++){
2810 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
2811 if((ipid!=NSigmaTPC) && (!HasTOFPID(track)) && track->Pt()<fPtTOFPIDmin)continue;//not filling TOF and combined if no TOF PID
2812 TH2F *h=GetHistogram2D(Form("NSigma_%d_%d",ipart,ipid));
2813 h->Fill(track->Pt(),fnsigmas[ipart][ipid]);
2819 //----------------------------------------------------------------------------
2820 Int_t AliTwoParticlePIDCorr::FindMinNSigma(AliAODTrack *track,Bool_t FillQAHistos)
2822 //this function is always called after calling the function CalculateNSigmas(AliAODTrack *track)
2823 if(fRequestTOFPID && track->Pt()>fPtTOFPIDmin && track->Pt()<=fPtTOFPIDmax && (!HasTOFPID(track)) )return SpUndefined;//so any track having Pt>0.6 && Pt<=4.0 Gev withot having proper TOF response will be defined as SpUndefined
2824 //get the identity of the particle with the minimum Nsigma
2825 Float_t nsigmaPion=999., nsigmaKaon=999., nsigmaProton=999.;
2828 nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTPC]);
2829 nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTPC]) ;
2830 nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTPC]) ;
2833 nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTOF]);
2834 nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTOF]) ;
2835 nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTOF]) ;
2837 case NSigmaTPCTOF://In case of no TOF matching the combined nsigma is the TPC one
2838 nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTPCTOF]);
2839 nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTPCTOF]) ;
2840 nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTPCTOF]) ;
2844 if(track->Pt()<=fPtTOFPIDmax) {
2845 // guess the particle based on the smaller nsigma (within fNSigmaPID)
2846 if( ( nsigmaKaon==nsigmaPion ) && ( nsigmaKaon==nsigmaProton )) return SpUndefined;//it is the default value for the three
2847 if( ( nsigmaKaon < nsigmaPion ) && ( nsigmaKaon < nsigmaProton ) && (nsigmaKaon < fNSigmaPID)){
2849 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
2850 if((ipid!=NSigmaTPC) && (!HasTOFPID(track)) && (track->Pt()<fPtTOFPIDmin))continue;//not filling TOF and combined if no TOF PID
2851 TH2F *h=GetHistogram2D(Form("NSigmaRec_%d_%d",SpKaon,ipid));
2852 h->Fill(track->Pt(),fnsigmas[SpKaon][ipid]);
2857 if( ( nsigmaPion < nsigmaKaon ) && ( nsigmaPion < nsigmaProton ) && (nsigmaPion < fNSigmaPID)) {
2859 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
2860 if((ipid!=NSigmaTPC) && (!HasTOFPID(track)) && (track->Pt()<fPtTOFPIDmin))continue;//not filling TOF and combined if no TOF PID
2861 TH2F *h=GetHistogram2D(Form("NSigmaRec_%d_%d",SpPion,ipid));
2862 h->Fill(track->Pt(),fnsigmas[SpPion][ipid]);
2867 if( ( nsigmaProton < nsigmaKaon ) && ( nsigmaProton < nsigmaPion ) && (nsigmaProton < fNSigmaPID)) {
2869 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
2870 if((ipid!=NSigmaTPC) && (!HasTOFPID(track)) && (track->Pt()<fPtTOFPIDmin))continue;//not filling TOF and combined if no TOF PID
2871 TH2F *h=GetHistogram2D(Form("NSigmaRec_%d_%d",SpProton,ipid));
2872 h->Fill(track->Pt(),fnsigmas[SpProton][ipid]);
2878 // else, return undefined
2881 else {//asymmetric nsigma cut around pion's mean position for tracks having Pt>4.0 Gev
2882 if(fminprotonsigmacut<fnsigmas[SpPion][NSigmaTPC] && fnsigmas[SpPion][NSigmaTPC]<fmaxprotonsigmacut) return SpProton;
2883 if(fminpionsigmacut<fnsigmas[SpPion][NSigmaTPC] && fnsigmas[SpPion][NSigmaTPC]<fmaxpionsigmacut) return SpPion;
2884 // else, return undefined(here we don't detect kaons)
2890 //------------------------------------------------------------------------------------------
2891 Bool_t* AliTwoParticlePIDCorr::GetDoubleCounting(AliAODTrack * trk,Bool_t FIllQAHistos){
2892 //this function is always called after calling the function CalculateNSigmas(AliAODTrack *track)
2894 //if a particle has double counting set fHasDoubleCounting[ipart]=kTRUE
2896 for(Int_t ipart=0;ipart<NSpecies;ipart++)fHasDoubleCounting[ipart]=kFALSE;//array with kTRUE for second (or third) identity of the track
2898 Int_t MinNSigma=FindMinNSigma(trk,kFALSE);//not filling the NSigmaRec histos
2901 if(MinNSigma==SpUndefined)return fHasDoubleCounting;//in case of undefined no Double counting
2903 Float_t nsigmaPion=999., nsigmaKaon=999., nsigmaProton=999.;
2906 nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTPC]);
2907 nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTPC]) ;
2908 nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTPC]) ;
2911 nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTOF]);
2912 nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTOF]) ;
2913 nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTOF]) ;
2915 case NSigmaTPCTOF://In case of no TOF matching the combined nsigma is the TPC one
2916 nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTPCTOF]);
2917 nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTPCTOF]) ;
2918 nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTPCTOF]) ;
2922 //there is chance of overlapping only for particles having pt below 4.0 GEv
2924 if(nsigmaPion<fNSigmaPID && MinNSigma!=SpPion)fHasDoubleCounting[SpPion]=kTRUE;
2925 if(nsigmaKaon<fNSigmaPID && MinNSigma!=SpKaon)fHasDoubleCounting[SpKaon]=kTRUE;
2926 if(nsigmaProton<fNSigmaPID && MinNSigma!=SpProton)fHasDoubleCounting[SpProton]=kTRUE;
2931 //fill NSigma distr for double counting
2932 for(Int_t ipart=0;ipart<NSpecies;ipart++){
2933 if(fHasDoubleCounting[ipart]){
2934 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
2935 if((ipid!=NSigmaTPC) && (!HasTOFPID(trk)) && (trk->Pt()<fPtTOFPIDmin))continue;//not filling TOF and combined if no TOF PID
2936 TH2F *h=GetHistogram2D(Form("NSigmaDC_%d_%d",ipart,ipid));
2937 h->Fill(trk->Pt(),fnsigmas[ipart][ipid]);
2944 return fHasDoubleCounting;
2947 //////////////////////////////////////////////////////////////////////////////////////////////////
2948 Int_t AliTwoParticlePIDCorr::GetParticle(AliAODTrack * trk, Bool_t FIllQAHistos){
2949 //return the specie according to the minimum nsigma value
2950 //no double counting, this has to be evaluated using CheckDoubleCounting()
2952 Int_t ID=SpUndefined;
2954 CalculateNSigmas(trk,FIllQAHistos);//fill the data member fnsigmas with the nsigmas value [ipart][iPID]
2956 ID=FindMinNSigma(trk,FIllQAHistos);
2958 if(fUseExclusiveNSigma){ //if one particle has double counting and exclusive nsigma is requested ID = kSpUndefined
2960 HasDC=GetDoubleCounting(trk,FIllQAHistos);
2961 for(Int_t ipart=0;ipart<NSpecies;ipart++){
2962 if(HasDC[ipart]==kTRUE) ID = SpUndefined;
2966 //Fill PID signal plot
2967 if(ID != SpUndefined){
2968 for(Int_t idet=0;idet<fNDetectors;idet++){
2969 TH2F *h=GetHistogram2D(Form("PID_%d_%d",idet,ID));
2970 if(idet==fITS)h->Fill(trk->P(),trk->GetITSsignal()*trk->Charge());
2971 if(idet==fTPC)h->Fill(trk->P(),trk->GetTPCsignal()*trk->Charge());
2972 if(idet==fTOF && HasTOFPID(trk))h->Fill(trk->P(),GetBeta(trk)*trk->Charge());
2975 //Fill PID signal plot without cuts
2976 for(Int_t idet=0;idet<fNDetectors;idet++){
2977 TH2F *h=GetHistogram2D(Form("PIDAll_%d",idet));
2978 if(idet==fITS)h->Fill(trk->P(),trk->GetITSsignal()*trk->Charge());
2979 if(idet==fTPC)h->Fill(trk->P(),trk->GetTPCsignal()*trk->Charge());
2980 if(idet==fTOF && HasTOFPID(trk))h->Fill(trk->P(),GetBeta(trk)*trk->Charge());
2986 //-------------------------------------------------------------------------------------
2988 AliTwoParticlePIDCorr::HasTPCPID(AliAODTrack *track) const
2991 AliPIDResponse::EDetPidStatus statustpc = fPID->CheckPIDStatus(AliPIDResponse::kTPC,track);
2992 if(statustpc!=AliPIDResponse::kDetPidOk) return kFALSE;
2993 //ULong_t status=track->GetStatus();
2994 //if (!( (status & AliAODTrack::kTPCpid ) == AliAODTrack::kTPCpid )) return kFALSE;//remove light nuclei
2995 //if (track->GetTPCsignal() <= 0.) return kFALSE;
2996 // if(track->GetTPCsignalN() < 60) return kFALSE;//tracks with TPCsignalN< 60 have questionable dEdx,cutting on TPCsignalN > 70 or > 60 shouldn't make too much difference in statistics,also it is IMO safe to use TPC also for MIPs.
3000 //___________________________________________________________
3003 AliTwoParticlePIDCorr::HasTOFPID(AliAODTrack *track) const
3005 // check TOF matched track
3006 //ULong_t status=track->GetStatus();
3007 //if (!( (status & AliAODTrack::kITSin ) == AliAODTrack::kITSin )) return kFALSE;
3008 AliPIDResponse::EDetPidStatus statustof = fPID->CheckPIDStatus(AliPIDResponse::kTOF,track);
3009 if(statustof!= AliPIDResponse::kDetPidOk) return kFALSE;
3010 if(track->Pt()<=fPtTOFPIDmin) return kFALSE;
3011 //if(!((status & AliAODTrack::kTOFpid ) == AliAODTrack::kTOFpid )) return kFALSE;
3012 //Float_t probMis = fPIDresponse->GetTOFMismatchProbability(track);
3013 // if (probMis > 0.01) return kFALSE;
3014 if(fRemoveTracksT0Fill)
3016 Int_t startTimeMask = fPID->GetTOFResponse().GetStartTimeMask(track->P());
3017 if (startTimeMask < 0)return kFALSE;
3022 //________________________________________________________________________
3023 Double_t AliTwoParticlePIDCorr :: GetBeta(AliAODTrack *track)
3025 //it is called only when TOF PID is available
3026 //TOF beta calculation
3027 Double_t tofTime=track->GetTOFsignal();
3029 Double_t c=TMath::C()*1.E-9;// m/ns
3030 Float_t startTime = fPID->GetTOFResponse().GetStartTime(((AliVTrack*)track)->P());//in ps
3031 Double_t length= fPID->GetTOFResponse().GetExpectedSignal(track,AliPID::kElectron)*1E-3*c;
3032 tofTime -= startTime; // subtract startTime to the signal
3033 Double_t tof= tofTime*1E-3; // ns, average T0 fill subtracted, no info from T0detector
3039 Double_t p = track->P();
3040 Double_t time=track->GetTOFsignal()-fPID->GetTOFResponse().GetStartTime(p);
3042 track->GetIntegratedTimes(timei);
3043 return timei[0]/time;
3046 //------------------------------------------------------------------------------------------------------
3048 Float_t AliTwoParticlePIDCorr::GetInvMassSquared(Float_t pt1, Float_t eta1, Float_t phi1, Float_t pt2, Float_t eta2, Float_t phi2, Float_t m0_1, Float_t m0_2)
3050 // calculate inv mass squared
3051 // same can be achieved, but with more computing time with
3052 /*TLorentzVector photon, p1, p2;
3053 p1.SetPtEtaPhiM(triggerParticle->Pt(), triggerEta, triggerParticle->Phi(), 0.510e-3);
3054 p2.SetPtEtaPhiM(particle->Pt(), eta[j], particle->Phi(), 0.510e-3);
3058 Float_t tantheta1 = 1e10;
3060 if (eta1 < -1e-10 || eta1 > 1e-10)
3061 tantheta1 = 2 * TMath::Exp(-eta1) / ( 1 - TMath::Exp(-2*eta1));
3063 Float_t tantheta2 = 1e10;
3064 if (eta2 < -1e-10 || eta2 > 1e-10)
3065 tantheta2 = 2 * TMath::Exp(-eta2) / ( 1 - TMath::Exp(-2*eta2));
3067 Float_t e1squ = m0_1 * m0_1 + pt1 * pt1 * (1.0 + 1.0 / tantheta1 / tantheta1);
3068 Float_t e2squ = m0_2 * m0_2 + pt2 * pt2 * (1.0 + 1.0 / tantheta2 / tantheta2);
3070 Float_t mass2 = m0_1 * m0_1 + m0_2 * m0_2 + 2 * ( TMath::Sqrt(e1squ * e2squ) - ( pt1 * pt2 * ( TMath::Cos(phi1 - phi2) + 1.0 / tantheta1 / tantheta2 ) ) );
3074 //---------------------------------------------------------------------------------
3076 Float_t AliTwoParticlePIDCorr::GetInvMassSquaredCheap(Float_t pt1, Float_t eta1, Float_t phi1, Float_t pt2, Float_t eta2, Float_t phi2, Float_t m0_1, Float_t m0_2)
3078 // calculate inv mass squared approximately
3080 Float_t tantheta1 = 1e10;
3082 if (eta1 < -1e-10 || eta1 > 1e-10)
3084 Float_t expTmp = 1.0-eta1+eta1*eta1/2-eta1*eta1*eta1/6+eta1*eta1*eta1*eta1/24;
3085 tantheta1 = 2.0 * expTmp / ( 1.0 - expTmp*expTmp);
3088 Float_t tantheta2 = 1e10;
3089 if (eta2 < -1e-10 || eta2 > 1e-10)
3091 Float_t expTmp = 1.0-eta2+eta2*eta2/2-eta2*eta2*eta2/6+eta2*eta2*eta2*eta2/24;
3092 tantheta2 = 2.0 * expTmp / ( 1.0 - expTmp*expTmp);
3095 Float_t e1squ = m0_1 * m0_1 + pt1 * pt1 * (1.0 + 1.0 / tantheta1 / tantheta1);
3096 Float_t e2squ = m0_2 * m0_2 + pt2 * pt2 * (1.0 + 1.0 / tantheta2 / tantheta2);
3099 Float_t deltaPhi = TMath::Abs(phi1 - phi2);
3100 while (deltaPhi > TMath::TwoPi())
3101 deltaPhi -= TMath::TwoPi();
3102 if (deltaPhi > TMath::Pi())
3103 deltaPhi = TMath::TwoPi() - deltaPhi;
3105 Float_t cosDeltaPhi = 0;
3106 if (deltaPhi < TMath::Pi()/3)
3107 cosDeltaPhi = 1.0 - deltaPhi*deltaPhi/2 + deltaPhi*deltaPhi*deltaPhi*deltaPhi/24;
3108 else if (deltaPhi < 2*TMath::Pi()/3)
3109 cosDeltaPhi = -(deltaPhi - TMath::Pi()/2) + 1.0/6 * TMath::Power((deltaPhi - TMath::Pi()/2), 3);
3111 cosDeltaPhi = -1.0 + 1.0/2.0*(deltaPhi - TMath::Pi())*(deltaPhi - TMath::Pi()) - 1.0/24.0 * TMath::Power(deltaPhi - TMath::Pi(), 4);
3113 Float_t mass2 = m0_1 * m0_1 + m0_2 * m0_2 + 2 * ( TMath::Sqrt(e1squ * e2squ) - ( pt1 * pt2 * ( cosDeltaPhi + 1.0 / tantheta1 / tantheta2 ) ) );
3115 // Printf(Form("%f %f %f %f %f %f %f %f %f", pt1, eta1, phi1, pt2, eta2, phi2, m0_1, m0_2, mass2));
3119 //--------------------------------------------------------------------------------
3120 Float_t AliTwoParticlePIDCorr::GetDPhiStar(Float_t phi1, Float_t pt1, Float_t charge1, Float_t phi2, Float_t pt2, Float_t charge2, Float_t radius, Float_t bSign)
3123 // calculates dphistar
3126 Float_t dphistar = phi1 - phi2 - charge1 * bSign * TMath::ASin(0.075 * radius / pt1) + charge2 * bSign * TMath::ASin(0.075 * radius / pt2);
3128 static const Double_t kPi = TMath::Pi();
3131 // if (dphistar > 2 * kPi)
3132 // dphistar -= 2 * kPi;
3133 // if (dphistar < -2 * kPi)
3134 // dphistar += 2 * kPi;
3137 dphistar = kPi * 2 - dphistar;
3138 if (dphistar < -kPi)
3139 dphistar = -kPi * 2 - dphistar;
3140 if (dphistar > kPi) // might look funny but is needed
3141 dphistar = kPi * 2 - dphistar;
3145 //_________________________________________________________________________
3146 void AliTwoParticlePIDCorr ::DefineEventPool()
3148 Int_t MaxNofEvents=1000;
3149 const Int_t NofVrtxBins=10+(1+10)*2;
3150 Double_t ZvrtxBins[NofVrtxBins+1]={ -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10,
3151 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110,
3152 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210
3154 if (fSampleType=="pp"){
3155 const Int_t NofCentBins=4;
3156 Double_t CentralityBins[NofCentBins+1]={0.,20., 40.,60.,200.1};//Is This binning is fine for pp, or we don't require them....
3157 fPoolMgr = new AliEventPoolManager(MaxNofEvents,fMaxNofMixingTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins);
3159 if (fSampleType=="pPb" || fSampleType=="PbPb")
3161 const Int_t NofCentBins=15;
3162 Double_t CentralityBins[NofCentBins+1]={0., 1., 2., 3., 4., 5., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100.1 };
3163 fPoolMgr = new AliEventPoolManager(MaxNofEvents,fMaxNofMixingTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins);
3165 fPoolMgr->SetTargetValues(fMaxNofMixingTracks, 0.1, 5);
3167 //if(!fPoolMgr) return kFALSE;
3171 //------------------------------------------------------------------------
3172 Double_t* AliTwoParticlePIDCorr::GetBinning(const char* configuration, const char* tag, Int_t& nBins)
3174 // This method is a copy from AliUEHist::GetBinning
3175 // takes the binning from <configuration> identified by <tag>
3176 // configuration syntax example:
3177 // eta: 2.4, -2.3, -2.2, -2.1, -2.0, -1.9, -1.8, -1.7, -1.6, -1.5, -1.4, -1.3, -1.2, -1.1, -1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4
3180 // returns bin edges which have to be deleted by the caller
3182 TString config(configuration);
3183 TObjArray* lines = config.Tokenize("\n");
3184 for (Int_t i=0; i<lines->GetEntriesFast(); i++)
3186 TString line(lines->At(i)->GetName());
3187 if (line.BeginsWith(TString(tag) + ":"))
3189 line.Remove(0, strlen(tag) + 1);
3190 line.ReplaceAll(" ", "");
3191 TObjArray* binning = line.Tokenize(",");
3192 Double_t* bins = new Double_t[binning->GetEntriesFast()];
3193 for (Int_t j=0; j<binning->GetEntriesFast(); j++)
3194 bins[j] = TString(binning->At(j)->GetName()).Atof();
3196 nBins = binning->GetEntriesFast() - 1;
3205 AliFatal(Form("Tag %s not found in %s", tag, configuration));
3209 //____________________________________________________________________
3211 Bool_t AliTwoParticlePIDCorr::CheckTrack(AliAODTrack * part)
3213 // check if the track status flags are set
3215 UInt_t status=((AliAODTrack*)part)->GetStatus();
3216 if ((status & fTrackStatus) == fTrackStatus)
3220 //________________________________________________________________________
3221 void AliTwoParticlePIDCorr::Terminate(Option_t *)
3223 // Draw result to screen, or perform fitting, normalizations
3224 // Called once at the end of the query
3225 fOutput = dynamic_cast<TList*> (GetOutputData(1));
3226 if(!fOutput) { Printf("ERROR: could not retrieve TList fOutput"); return; }
3230 //------------------------------------------------------------------