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"
29 #include "AliCentrality.h"
30 #include "Riostream.h"
33 #include "AliCFContainer.h"
35 #include "THnSparse.h"
39 #include "AliESDpid.h"
40 #include "AliAODpidUtil.h"
41 #include <AliPIDResponse.h>
43 #include <AliAnalysisManager.h>
44 #include <AliInputEventHandler.h>
45 #include "AliAODInputHandler.h"
47 #include "AliAnalysisTaskSE.h"
48 #include "AliAnalysisManager.h"
49 #include "AliCentrality.h"
51 #include "AliVEvent.h"
52 #include "AliAODEvent.h"
53 #include "AliAODTrack.h"
54 #include "AliVTrack.h"
56 #include "THnSparse.h"
58 #include "AliAODMCHeader.h"
59 #include "AliAODMCParticle.h"
60 #include "AliMCEventHandler.h"
61 #include "AliMCEvent.h"
62 #include "AliMCParticle.h"
63 #include "TParticle.h"
64 #include <TDatabasePDG.h>
65 #include <TParticlePDG.h>
67 #include "AliGenCocktailEventHeader.h"
68 #include "AliGenEventHeader.h"
70 #include "AliEventPoolManager.h"
71 #include "AliAnalysisUtils.h"
72 using namespace AliPIDNameSpace;
75 ClassImp(AliTwoParticlePIDCorr)
76 ClassImp(LRCParticlePID)
78 const char * kPIDTypeName[]={"TPC","TOF","TPC-TOF"} ;
79 const char * kDetectorName[]={"ITS","TPC","TOF"} ;
80 const char * kParticleSpeciesName[]={"Pions","Kaons","Protons","Undefined"} ;
82 //________________________________________________________________________
83 AliTwoParticlePIDCorr::AliTwoParticlePIDCorr() // All data members should be initialised here
86 fCentralityMethod("V0A"),
88 fnTracksVertex(1), // QA tracks pointing to principal vertex (= 3 default)
93 fSharedClusterCut(-1),
96 ffilltrigassoUNID(kFALSE),
97 ffilltrigUNIDassoID(kFALSE),
98 ffilltrigIDassoUNID(kTRUE),
99 ffilltrigIDassoID(kFALSE),
100 ffilltrigIDassoIDMCTRUTH(kFALSE),
101 fMaxNofMixingTracks(50000),
102 fPtOrderMCTruth(kTRUE),
103 fPtOrderDataReco(kTRUE),
104 fWeightPerEvent(kFALSE),
105 fTriggerSpeciesSelection(kFALSE),
106 fAssociatedSpeciesSelection(kFALSE),
107 fTriggerSpecies(SpPion),
108 fAssociatedSpecies(SpPion),
111 fSelectHighestPtTrig(kFALSE),
112 fcontainPIDtrig(kTRUE),
113 fcontainPIDasso(kFALSE),
114 frejectPileUp(kFALSE),
119 fminprotonsigmacut(-6.0),
120 fmaxprotonsigmacut(-3.0),
121 fminpionsigmacut(0.0),
122 fmaxpionsigmacut(4.0),
123 fselectprimaryTruth(kTRUE),
124 fonlyprimarydatareco(kFALSE),
127 ffillhistQAReco(kFALSE),
128 ffillhistQATruth(kFALSE),
129 kTrackVariablesPair(0),
158 fhistJetTrigestimate(0),
159 fCentralityCorrelation(0x0),
174 fCorrelatonTruthPrimary(0),
175 fCorrelatonTruthPrimarymix(0),
181 fTHnCorrIDUNIDmix(0),
183 fTHnTrigcountMCTruthPrim(0),
186 fAnalysisType("AOD"),
188 twoTrackEfficiencyCutValue(0.02),
189 //fControlConvResoncances(0),
194 fRequestTOFPID(kTRUE),
195 fPIDType(NSigmaTPCTOF),
196 fFIllPIDQAHistos(kTRUE),
198 fUseExclusiveNSigma(kFALSE),
199 fRemoveTracksT0Fill(kFALSE),
201 fTriggerSelectCharge(0),
202 fAssociatedSelectCharge(0),
203 fTriggerRestrictEta(-1),
204 fEtaOrdering(kFALSE),
205 fCutConversions(kFALSE),
206 fCutResonances(kFALSE),
207 fRejectResonanceDaughters(-1),
209 fInjectedSignals(kFALSE),
210 fRemoveWeakDecays(kFALSE),
211 fRemoveDuplicates(kFALSE),
212 fapplyTrigefficiency(kFALSE),
213 fapplyAssoefficiency(kFALSE),
214 ffillefficiency(kFALSE),
215 fmesoneffrequired(kFALSE),
216 fkaonprotoneffrequired(kFALSE),
221 for ( Int_t i = 0; i < 16; i++) {
225 for ( Int_t i = 0; i < 6; i++ ){
226 fTrackHistEfficiency[i] = NULL;
227 effcorection[i]=NULL;
232 for(Int_t ipart=0;ipart<NSpecies;ipart++)
233 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++)
234 fnsigmas[ipart][ipid]=999.;
236 for(Int_t ipart=0;ipart<NSpecies;ipart++) {fHasDoubleCounting[ipart]=kFALSE;}
239 //________________________________________________________________________
240 AliTwoParticlePIDCorr::AliTwoParticlePIDCorr(const char *name) // All data members should be initialised here
241 :AliAnalysisTaskSE(name),
243 fCentralityMethod("V0A"),
245 fnTracksVertex(1), // QA tracks pointing to principal vertex (= 3 default)
250 fSharedClusterCut(-1),
253 ffilltrigassoUNID(kFALSE),
254 ffilltrigUNIDassoID(kFALSE),
255 ffilltrigIDassoUNID(kTRUE),
256 ffilltrigIDassoID(kFALSE),
257 ffilltrigIDassoIDMCTRUTH(kFALSE),
258 fMaxNofMixingTracks(50000),
259 fPtOrderMCTruth(kTRUE),
260 fPtOrderDataReco(kTRUE),
261 fWeightPerEvent(kFALSE),
262 fTriggerSpeciesSelection(kFALSE),
263 fAssociatedSpeciesSelection(kFALSE),
264 fTriggerSpecies(SpPion),
265 fAssociatedSpecies(SpPion),
268 fSelectHighestPtTrig(kFALSE),
269 fcontainPIDtrig(kTRUE),
270 fcontainPIDasso(kFALSE),
271 frejectPileUp(kFALSE),
276 fminprotonsigmacut(-6.0),
277 fmaxprotonsigmacut(-3.0),
278 fminpionsigmacut(0.0),
279 fmaxpionsigmacut(4.0),
280 fselectprimaryTruth(kTRUE),
281 fonlyprimarydatareco(kFALSE),
284 ffillhistQAReco(kFALSE),
285 ffillhistQATruth(kFALSE),
286 kTrackVariablesPair(0),
315 fhistJetTrigestimate(0),
316 fCentralityCorrelation(0x0),
331 fCorrelatonTruthPrimary(0),
332 fCorrelatonTruthPrimarymix(0),
338 fTHnCorrIDUNIDmix(0),
340 fTHnTrigcountMCTruthPrim(0),
343 fAnalysisType("AOD"),
345 twoTrackEfficiencyCutValue(0.02),
346 //fControlConvResoncances(0),
351 fRequestTOFPID(kTRUE),
352 fPIDType(NSigmaTPCTOF),
353 fFIllPIDQAHistos(kTRUE),
355 fUseExclusiveNSigma(kFALSE),
356 fRemoveTracksT0Fill(kFALSE),
358 fTriggerSelectCharge(0),
359 fAssociatedSelectCharge(0),
360 fTriggerRestrictEta(-1),
361 fEtaOrdering(kFALSE),
362 fCutConversions(kFALSE),
363 fCutResonances(kFALSE),
364 fRejectResonanceDaughters(-1),
366 fInjectedSignals(kFALSE),
367 fRemoveWeakDecays(kFALSE),
368 fRemoveDuplicates(kFALSE),
369 fapplyTrigefficiency(kFALSE),
370 fapplyAssoefficiency(kFALSE),
371 ffillefficiency(kFALSE),
372 fmesoneffrequired(kFALSE),
373 fkaonprotoneffrequired(kFALSE),
378 for ( Int_t i = 0; i < 16; i++) {
382 for ( Int_t i = 0; i < 6; i++ ){
383 fTrackHistEfficiency[i] = NULL;
384 effcorection[i]=NULL;
388 for(Int_t ipart=0;ipart<NSpecies;ipart++)
389 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++)
390 fnsigmas[ipart][ipid]=999.;
392 for(Int_t ipart=0;ipart<NSpecies;ipart++) {fHasDoubleCounting[ipart]=kFALSE;}
394 // The last in the above list should not have a comma after it
397 // Define input and output slots here (never in the dummy constructor)
398 // Input slot #0 works with a TChain - it is connected to the default input container
399 // Output slot #1 writes into a TH1 container
401 DefineOutput(1, TList::Class()); // for output list
402 DefineOutput(2, TList::Class());
406 //________________________________________________________________________
407 AliTwoParticlePIDCorr::~AliTwoParticlePIDCorr()
409 // Destructor. Clean-up the output list, but not the histograms that are put inside
410 // (the list is owner and will clean-up these histograms). Protect in PROOF case.
411 if (fOutput && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
416 if (fOutputList && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
421 if (fPID) delete fPID;
424 //________________________________________________________________________
426 //////////////////////////////////////////////////////////////////////////////////////////////////
428 TH2F* AliTwoParticlePIDCorr::GetHistogram2D(const char * name){
429 // returns histo named name
430 return (TH2F*) fOutputList->FindObject(name);
433 //////////////////////////////////////////////////////////////////////////////////////////////////
435 Float_t AliTwoParticlePIDCorr::PhiRange(Float_t DPhi)
439 // Puts the argument in the range [-pi/2,3 pi/2].
442 if (DPhi < -TMath::Pi()/2) DPhi += 2*TMath::Pi();
443 if (DPhi > 3*TMath::Pi()/2) DPhi -= 2*TMath::Pi();
448 //________________________________________________________________________
449 void AliTwoParticlePIDCorr::UserCreateOutputObjects()
452 // Called once (on the worker node)
453 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
454 AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
455 fPID = inputHandler->GetPIDResponse();
457 //AliAnalysisUtils *fUtils = new AliAnalysisUtils();
459 //get the efficiency correction map
461 // global switch disabling the reference
462 // (to avoid "Replacing existing TH1" if several wagons are created in train)
463 Bool_t oldStatus = TH1::AddDirectoryStatus();
464 TH1::AddDirectory(kFALSE);
466 fOutput = new TList();
467 fOutput->SetOwner(); // IMPORTANT!
469 fOutputList = new TList;
470 fOutputList->SetOwner();
471 fOutputList->SetName("PIDQAList");
474 Int_t centmultbins=10;
475 Double_t centmultmin=0.0;
476 Double_t centmultmax=100.0;
477 if(fSampleType=="pPb" || fSampleType=="PbPb")
483 if(fSampleType=="pp")
490 fhistcentrality=new TH1F("fhistcentrality","fhistcentrality",centmultbins*4,centmultmin,centmultmax);
491 fOutput->Add(fhistcentrality);
493 fEventCounter = new TH1F("fEventCounter","EventCounter", 10, 0.5,10.5);
494 fEventCounter->GetXaxis()->SetBinLabel(1,"Event Accesed");
495 fEventCounter->GetXaxis()->SetBinLabel(2,"NOT PileUP Event");
496 fEventCounter->GetXaxis()->SetBinLabel(3,"Have A Vertex");
497 fEventCounter->GetXaxis()->SetBinLabel(4,"After vertex Cut");
498 fEventCounter->GetXaxis()->SetBinLabel(5,"Within 0-100% centrality");
499 fEventCounter->GetXaxis()->SetBinLabel(6,"Event Analyzed");
500 //fEventCounter->GetXaxis()->SetBinLabel(8,"Event Analysis finished");
501 fOutput->Add(fEventCounter);
503 fEtaSpectrasso=new TH2F("fEtaSpectraasso","fEtaSpectraasso",180,-0.9,0.9,100,0.,20. );
504 fOutput->Add(fEtaSpectrasso);
506 fphiSpectraasso=new TH2F("fphiSpectraasso","fphiSpectraasso",72,0,2*TMath::Pi(),100,0.,20.);
507 fOutput->Add(fphiSpectraasso);
509 if(fSampleType=="pPb" || fSampleType=="PbPb"){ fCentralityCorrelation = new TH2D("fCentralityCorrelation", ";centrality;multiplicity", 101, 0, 101, 20000, 0,40000);
510 fOutput->Add(fCentralityCorrelation);
513 fHistoTPCdEdx = new TH2F("hHistoTPCdEdx", ";p_{T} (GeV/c);dE/dx (au.)",200,0.0,10.0,500, 0., 500.);
514 fOutputList->Add(fHistoTPCdEdx);
515 fHistoTOFbeta = new TH2F(Form("hHistoTOFbeta"), ";p_{T} (GeV/c);v/c",100, 0., fmaxPt, 500, 0.1, 1.1);
516 fOutputList->Add(fHistoTOFbeta);
518 fTPCTOFPion3d=new TH3F ("fTPCTOFpion3d", "fTPCTOFpion3d",100,0., 10., 120,-60.,60.,120,-60.,60);
519 fOutputList->Add(fTPCTOFPion3d);
521 fTPCTOFKaon3d=new TH3F ("fTPCTOFKaon3d", "fTPCTOFKaon3d",100,0., 10., 120,-60.,60.,120,-60.,60);
522 fOutputList->Add(fTPCTOFKaon3d);
524 fTPCTOFProton3d=new TH3F ("fTPCTOFProton3d", "fTPCTOFProton3d",100,0., 10., 120,-60.,60.,120,-60.,60);
525 fOutputList->Add(fTPCTOFProton3d);
529 fPionPt = new TH1F("fHistQAPionPt","p_{T} distribution",200,0.,10.);
530 fOutputList->Add(fPionPt);
531 fPionEta= new TH1F("fHistQAPionEta","#eta distribution",360,-1.8,1.8);
532 fOutputList->Add(fPionEta);
533 fPionPhi = new TH1F("fHistQAPionPhi","#phi distribution",340,0,6.8);
534 fOutputList->Add(fPionPhi);
536 fKaonPt = new TH1F("fHistQAKaonPt","p_{T} distribution",200,0.,10.);
537 fOutputList->Add(fKaonPt);
538 fKaonEta= new TH1F("fHistQAKaonEta","#eta distribution",360,-1.8,1.8);
539 fOutputList->Add(fKaonEta);
540 fKaonPhi = new TH1F("fHistQAKaonPhi","#phi distribution",340,0,6.8);
541 fOutputList->Add(fKaonPhi);
543 fProtonPt = new TH1F("fHistQAProtonPt","p_{T} distribution",200,0.,10.);
544 fOutputList->Add(fProtonPt);
545 fProtonEta= new TH1F("fHistQAProtonEta","#eta distribution",360,-1.8,1.8);
546 fOutputList->Add(fProtonEta);
547 fProtonPhi= new TH1F("fHistQAProtonPhi","#phi distribution",340,0,6.8);
548 fOutputList->Add(fProtonPhi);
551 fHistQA[0] = new TH1F("fHistQAvx", "Histo Vx All ", 50, -5., 5.);
552 fHistQA[1] = new TH1F("fHistQAvy", "Histo Vy All", 50, -5., 5.);
553 fHistQA[2] = new TH1F("fHistQAvz", "Histo Vz All", 50, -25., 25.);
554 fHistQA[3] = new TH1F("fHistQAvxA", "Histo Vx After Cut ", 50, -5., 5.);
555 fHistQA[4] = new TH1F("fHistQAvyA", "Histo Vy After Cut", 50, -5., 5.);
556 fHistQA[5] = new TH1F("fHistQAvzA", "Histo Vz After Cut", 50, -25., 25.);
557 fHistQA[6] = new TH1F("fHistQADcaXyC", "Histo DCAxy after cut", 50, -5., 5.);
558 fHistQA[7] = new TH1F("fHistQADcaZC", "Histo DCAz after cut", 50, -5., 5.);
559 fHistQA[8] = new TH1F("fHistQAPt","p_{T} distribution",200,0.,10.);
560 fHistQA[9] = new TH1F("fHistQAEta","#eta distribution",360,-1.8,1.8);
561 fHistQA[10] = new TH1F("fHistQAPhi","#phi distribution",340,0,6.8);
562 fHistQA[11] = new TH1F("fHistQANCls","Number of TPC cluster",200,0,200);
563 fHistQA[13] = new TH1F("fHistQAChi2","Chi2 per NDF",100,0,10);
564 fHistQA[12] = new TH1F("fHistQANCls1","Number of TPC cluster1",200,0,200);
565 fHistQA[14] = new TH1F("nCrossedRowsTPC","Number of TPC ccrossed rows",200,0,200);
566 fHistQA[15] = new TH1F("ratioCrossedRowsOverFindableClustersTPC","Number of TPC ccrossed rows find clusters",200,0,2);
568 for(Int_t i = 0; i < 16; i++)
570 fOutput->Add(fHistQA[i]);
573 kTrackVariablesPair=6 ;
575 if(fcontainPIDtrig && !fcontainPIDasso) kTrackVariablesPair=7;
577 if(!fcontainPIDtrig && fcontainPIDasso) kTrackVariablesPair=7;
579 if(fcontainPIDtrig && fcontainPIDasso) kTrackVariablesPair=8;
582 // two particle histograms
583 Int_t anaSteps = 1; // analysis steps
584 const char* title = "d^{2}N_{ch}/d#varphid#eta";
586 Int_t iBinPair[kTrackVariablesPair]; // binning for track variables
587 Double_t* dBinsPair[kTrackVariablesPair]; // bins for track variables
588 TString* axisTitlePair; // axis titles for track variables
589 axisTitlePair=new TString[kTrackVariablesPair];
591 TString defaultBinningStr;
592 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"
593 "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"
594 "p_t_leading_course: 0.5, 1.0, 2.0, 3.0, 4.0, 6.0, 8.0,10.0\n"
595 "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"
596 "vertex: -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10\n"
597 "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
598 "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"
599 "multiplicity: 0, 1, 2, 3, 4, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100.1\n";
602 defaultBinningStr += "PIDTrig: -0.5,0.5,1.5,2.5,3.5\n"; // course
605 defaultBinningStr += "PIDAsso: -0.5,0.5,1.5,2.5,3.5\n"; // course
607 // =========================================================
608 // Customization (adopted from AliUEHistograms)
609 // =========================================================
611 TObjArray* lines = defaultBinningStr.Tokenize("\n");
612 for (Int_t i=0; i<lines->GetEntriesFast(); i++)
614 TString line(lines->At(i)->GetName());
615 TString tag = line(0, line.Index(":")+1);
616 if (!fCustomBinning.BeginsWith(tag) && !fCustomBinning.Contains(TString("\n") + tag))
617 fBinningString += line + "\n";
619 AliInfo(Form("Using custom binning for %s", tag.Data()));
622 fBinningString += fCustomBinning;
624 AliInfo(Form("Used AliTHn Binning:\n%s",fBinningString.Data()));
626 // =========================================================
628 // =========================================================
630 dBinsPair[0] = GetBinning(fBinningString, "multiplicity", iBinPair[0]);
631 axisTitlePair[0] = " multiplicity";
633 dBinsPair[1] = GetBinning(fBinningString, "vertex", iBinPair[1]);
634 axisTitlePair[1] = "v_{Z} (cm)";
636 dBinsPair[2] = GetBinning(fBinningString, "p_t_leading_course", iBinPair[2]);
637 axisTitlePair[2] = "p_{T,trig.} (GeV/c)";
639 dBinsPair[3] = GetBinning(fBinningString, "p_t_assoc", iBinPair[3]);
640 axisTitlePair[3] = "p_{T,assoc.} (GeV/c)";
642 dBinsPair[4] = GetBinning(fBinningString, "delta_eta", iBinPair[4]);
643 axisTitlePair[4] = "#Delta#eta";
645 dBinsPair[5] = GetBinning(fBinningString, "delta_phi", iBinPair[5]);
646 axisTitlePair[5] = "#Delta#varphi (rad)";
648 if(fcontainPIDtrig && !fcontainPIDasso){
649 dBinsPair[6] = GetBinning(fBinningString, "PIDTrig", iBinPair[6]);
650 axisTitlePair[6] = "PIDTrig";
653 if(!fcontainPIDtrig && fcontainPIDasso){
654 dBinsPair[6] = GetBinning(fBinningString, "PIDAsso", iBinPair[6]);
655 axisTitlePair[6] = "PIDAsso";
658 if(fcontainPIDtrig && fcontainPIDasso){
660 dBinsPair[6] = GetBinning(fBinningString, "PIDTrig", iBinPair[6]);
661 axisTitlePair[6] = "PIDTrig";
663 dBinsPair[7] = GetBinning(fBinningString, "PIDAsso", iBinPair[7]);
664 axisTitlePair[7] = "PIDAsso";
668 Double_t* EtaBin = GetBinning(fBinningString, "eta", nEtaBin);
670 Int_t nPteffbin = -1;
671 Double_t* Pteff = GetBinning(fBinningString, "p_t_eff", nPteffbin);
674 fminPtTrig=dBinsPair[2][0];
675 fmaxPtTrig=dBinsPair[2][iBinPair[2]];
676 fminPtAsso=dBinsPair[3][0];
677 fmaxPtAsso=dBinsPair[3][iBinPair[3]];
679 //fminPtComboeff=fminPtTrig;***then this value will be fixed ,even Setter can't change it's value
680 //fmaxPtComboeff=fmaxPtTrig;
681 //THnSparses for calculation of efficiency
683 if((fAnalysisType =="MCAOD") && ffillefficiency) {
686 effbin[0]=iBinPair[0];
687 effbin[1]=iBinPair[1];
691 for(Int_t jj=0;jj<6;jj++)//PID type binning
693 if(jj==5) effsteps=3;//for unidentified particles
694 Histrename="fTrackHistEfficiency";Histrename+=jj;
695 fTrackHistEfficiency[jj] = new AliTHn(Histrename.Data(), "Tracking efficiency", effsteps, 4, effbin);
696 fTrackHistEfficiency[jj]->SetBinLimits(0, dBinsPair[0]);
697 fTrackHistEfficiency[jj]->SetVarTitle(0, "Centrality");
698 fTrackHistEfficiency[jj]->SetBinLimits(1, dBinsPair[1]);
699 fTrackHistEfficiency[jj]->SetVarTitle(1, "zvtx");
700 fTrackHistEfficiency[jj]->SetBinLimits(2, Pteff);
701 fTrackHistEfficiency[jj]->SetVarTitle(2, "p_{T} (GeV/c)");
702 fTrackHistEfficiency[jj]->SetBinLimits(3, EtaBin);
703 fTrackHistEfficiency[jj]->SetVarTitle(3, "#eta");
704 fOutput->Add(fTrackHistEfficiency[jj]);
708 //AliThns for Correlation plots(data & MC)
710 if(ffilltrigassoUNID)
712 fTHnCorrUNID = new AliTHn("fTHnCorrUNID", title, anaSteps, kTrackVariablesPair, iBinPair);
713 for (Int_t j=0; j<kTrackVariablesPair; j++) {
714 fTHnCorrUNID->SetBinLimits(j, dBinsPair[j]);
715 fTHnCorrUNID->SetVarTitle(j, axisTitlePair[j]);
717 fOutput->Add(fTHnCorrUNID);
719 fTHnCorrUNIDmix = new AliTHn("fTHnCorrUNIDmix", title, anaSteps, kTrackVariablesPair, iBinPair);
720 for (Int_t j=0; j<kTrackVariablesPair; j++) {
721 fTHnCorrUNIDmix->SetBinLimits(j, dBinsPair[j]);
722 fTHnCorrUNIDmix->SetVarTitle(j, axisTitlePair[j]);
724 fOutput->Add(fTHnCorrUNIDmix);
727 if(ffilltrigIDassoID)
729 fTHnCorrID = new AliTHn("fTHnCorrID", title, anaSteps, kTrackVariablesPair, iBinPair);
730 for (Int_t j=0; j<kTrackVariablesPair; j++) {
731 fTHnCorrID->SetBinLimits(j, dBinsPair[j]);
732 fTHnCorrID->SetVarTitle(j, axisTitlePair[j]);
734 fOutput->Add(fTHnCorrID);
736 fTHnCorrIDmix = new AliTHn("fTHnCorrIDmix", title, anaSteps, kTrackVariablesPair, iBinPair);
737 for (Int_t j=0; j<kTrackVariablesPair; j++) {
738 fTHnCorrIDmix->SetBinLimits(j, dBinsPair[j]);
739 fTHnCorrIDmix->SetVarTitle(j, axisTitlePair[j]);
741 fOutput->Add(fTHnCorrIDmix);
744 if(ffilltrigUNIDassoID || ffilltrigIDassoUNID)//***********a bit tricky, be careful
746 fTHnCorrIDUNID = new AliTHn("fTHnCorrIDUNID", title, anaSteps, kTrackVariablesPair, iBinPair);
747 for (Int_t j=0; j<kTrackVariablesPair; j++) {
748 fTHnCorrIDUNID->SetBinLimits(j, dBinsPair[j]);
749 fTHnCorrIDUNID->SetVarTitle(j, axisTitlePair[j]);
751 fOutput->Add(fTHnCorrIDUNID);
754 fTHnCorrIDUNIDmix = new AliTHn("fTHnCorrIDUNIDmix", title, anaSteps, kTrackVariablesPair, iBinPair);
755 for (Int_t j=0; j<kTrackVariablesPair; j++) {
756 fTHnCorrIDUNIDmix->SetBinLimits(j, dBinsPair[j]);
757 fTHnCorrIDUNIDmix->SetVarTitle(j, axisTitlePair[j]);
759 fOutput->Add(fTHnCorrIDUNIDmix);
764 //ThnSparse for Correlation plots(truth MC)
765 if((fAnalysisType == "MCAOD") && ffilltrigIDassoIDMCTRUTH) {//remember that in this case uidentified means other than pions, kaons, protons
767 fCorrelatonTruthPrimary = new AliTHn("fCorrelatonTruthPrimary", title, anaSteps, kTrackVariablesPair, iBinPair);
768 for (Int_t j=0; j<kTrackVariablesPair; j++) {
769 fCorrelatonTruthPrimary->SetBinLimits(j, dBinsPair[j]);
770 fCorrelatonTruthPrimary->SetVarTitle(j, axisTitlePair[j]);
772 fOutput->Add(fCorrelatonTruthPrimary);
775 fCorrelatonTruthPrimarymix = new AliTHn("fCorrelatonTruthPrimarymix", title, anaSteps, kTrackVariablesPair, iBinPair);
776 for (Int_t j=0; j<kTrackVariablesPair; j++) {
777 fCorrelatonTruthPrimarymix->SetBinLimits(j, dBinsPair[j]);
778 fCorrelatonTruthPrimarymix->SetVarTitle(j, axisTitlePair[j]);
780 fOutput->Add(fCorrelatonTruthPrimarymix);
783 //binning for trigger no. counting
787 if(fcontainPIDtrig) dims=4;
788 fBinst= new Int_t[dims];
789 for(Int_t i=0; i<3;i++)
791 fBinst[i]=iBinPair[i];
794 fBinst[3]=iBinPair[6];
797 //ThSparse for trigger counting(data & reco MC)
798 if(ffilltrigassoUNID || ffilltrigUNIDassoID || ffilltrigIDassoUNID || ffilltrigIDassoID)
800 fTHnTrigcount = new AliTHn("fTHnTrigcount", "fTHnTrigcount", 2, dims, fBinst); //2 steps;;;;0->same event;;;;;1->mixed event
801 for(Int_t i=0; i<3;i++){
802 fTHnTrigcount->SetBinLimits(i, dBinsPair[i]);
803 fTHnTrigcount->SetVarTitle(i, axisTitlePair[i]);
807 fTHnTrigcount->SetBinLimits(3, dBinsPair[6]);
808 fTHnTrigcount->SetVarTitle(3, axisTitlePair[6]);
810 fOutput->Add(fTHnTrigcount);
813 if((fAnalysisType =="MCAOD") && ffilltrigIDassoIDMCTRUTH) {
814 //AliTHns for trigger counting(truth MC)
815 fTHnTrigcountMCTruthPrim = new AliTHn("fTHnTrigcountMCTruthPrim", "fTHnTrigcountMCTruthPrim", 2, dims, fBinst); //2 steps;;;;0->same event;;;;;1->mixed event
816 for(Int_t i=0; i<3;i++){
817 fTHnTrigcountMCTruthPrim->SetBinLimits(i, dBinsPair[i]);
818 fTHnTrigcountMCTruthPrim->SetVarTitle(i, axisTitlePair[i]);
822 fTHnTrigcountMCTruthPrim->SetBinLimits(3, dBinsPair[6]);
823 fTHnTrigcountMCTruthPrim->SetVarTitle(3, axisTitlePair[6]);
825 fOutput->Add(fTHnTrigcountMCTruthPrim);
828 if(fAnalysisType=="MCAOD"){
831 MCtruthpt=new TH1F ("MCtruthpt","ptdistributiontruthprim",100,0.,10.);
832 fOutputList->Add(MCtruthpt);
834 MCtrutheta=new TH1F ("MCtrutheta","etadistributiontruthprim",360,-1.8,1.8);
835 fOutputList->Add(MCtrutheta);
837 MCtruthphi=new TH1F ("MCtruthphi","phidisttruthprim",340,0,6.8);
838 fOutputList->Add(MCtruthphi);
840 MCtruthpionpt=new TH1F ("MCtruthpionpt","MCtruthpionpt",100,0.,10.);
841 fOutputList->Add(MCtruthpionpt);
843 MCtruthpioneta=new TH1F ("MCtruthpioneta","MCtruthpioneta",360,-1.8,1.8);
844 fOutputList->Add(MCtruthpioneta);
846 MCtruthpionphi=new TH1F ("MCtruthpionphi","MCtruthpionphi",340,0,6.8);
847 fOutputList->Add(MCtruthpionphi);
849 MCtruthkaonpt=new TH1F ("MCtruthkaonpt","MCtruthkaonpt",100,0.,10.);
850 fOutputList->Add(MCtruthkaonpt);
852 MCtruthkaoneta=new TH1F ("MCtruthkaoneta","MCtruthkaoneta",360,-1.8,1.8);
853 fOutputList->Add(MCtruthkaoneta);
855 MCtruthkaonphi=new TH1F ("MCtruthkaonphi","MCtruthkaonphi",340,0,6.8);
856 fOutputList->Add(MCtruthkaonphi);
858 MCtruthprotonpt=new TH1F ("MCtruthprotonpt","MCtruthprotonpt",100,0.,10.);
859 fOutputList->Add(MCtruthprotonpt);
861 MCtruthprotoneta=new TH1F ("MCtruthprotoneta","MCtruthprotoneta",360,-1.8,1.8);
862 fOutputList->Add(MCtruthprotoneta);
864 MCtruthprotonphi=new TH1F ("MCtruthprotonphi","MCtruthprotonphi",340,0,6.8);
865 fOutputList->Add(MCtruthprotonphi);
867 fPioncont=new TH2F("fPioncont", "fPioncont",10,-0.5,9.5,100,0.,10.);
868 fOutputList->Add(fPioncont);
870 fKaoncont=new TH2F("fKaoncont","fKaoncont",10,-0.5,9.5,100,0.,10.);
871 fOutputList->Add(fKaoncont);
873 fProtoncont=new TH2F("fProtoncont","fProtoncont",10,-0.5,9.5,100,0.,10.);
874 fOutputList->Add(fProtoncont);
877 fEventno=new TH2F("fEventno","fEventno",iBinPair[0], dBinsPair[0],iBinPair[1],dBinsPair[1]);
878 fEventno->GetXaxis()->SetTitle("Centrality");
879 fEventno->GetYaxis()->SetTitle("Z_Vtx");
880 fOutput->Add(fEventno);
881 fEventnobaryon=new TH2F("fEventnobaryon","fEventnobaryon",iBinPair[0], dBinsPair[0],iBinPair[1],dBinsPair[1]);
882 fEventnobaryon->GetXaxis()->SetTitle("Centrality");
883 fEventnobaryon->GetYaxis()->SetTitle("Z_Vtx");
884 fOutput->Add(fEventnobaryon);
885 fEventnomeson=new TH2F("fEventnomeson","fEventnomeson",iBinPair[0], dBinsPair[0],iBinPair[1],dBinsPair[1]);
886 fEventnomeson->GetXaxis()->SetTitle("Centrality");
887 fEventnomeson->GetYaxis()->SetTitle("Z_Vtx");
888 fOutput->Add(fEventnomeson);
890 fhistJetTrigestimate=new TH2F("fhistJetTrigestimate","fhistJetTrigestimate",iBinPair[0],dBinsPair[0],6,-0.5,5.5);
891 fOutput->Add(fhistJetTrigestimate);
897 if(fapplyTrigefficiency || fapplyAssoefficiency)
899 const Int_t nDimt = 4;// cent zvtx pt eta
900 Int_t fBinsCht[nDimt] = {iBinPair[0], iBinPair[1], nPteffbin ,nEtaBin};//*************change it
901 Double_t fMinCht[nDimt] = { dBinsPair[0][0],dBinsPair[1][0], Pteff[0], EtaBin[0] };
902 Double_t fMaxCht[nDimt] = {dBinsPair[0][iBinPair[0]], dBinsPair[1][iBinPair[1]], Pteff[nPteffbin], EtaBin[nEtaBin]};
905 for(Int_t jj=0;jj<6;jj++)// PID type binning
907 Histrexname="effcorection";Histrexname+=jj;
908 effcorection[jj] = new THnSparseF(Histrexname.Data(),"cent:zvtx::Pt:eta", nDimt, fBinsCht, fMinCht, fMaxCht);
909 effcorection[jj]->Sumw2();
910 effcorection[jj]->GetAxis(0)->Set(iBinPair[0], dBinsPair[0]);
911 effcorection[jj]->GetAxis(0)->SetTitle("Centrality");
912 effcorection[jj]->GetAxis(1)->Set( iBinPair[1],dBinsPair[1]);
913 effcorection[jj]->GetAxis(1)->SetTitle("zvtx");
914 effcorection[jj]->GetAxis(2)->Set(nPteffbin, Pteff);
915 effcorection[jj]->GetAxis(2)->SetTitle("p_{T} (GeV/c)");
916 effcorection[jj]->GetAxis(3)->Set( nEtaBin,EtaBin);
917 effcorection[jj]->GetAxis(3)->SetTitle("#eta");
918 fOutput->Add(effcorection[jj]);
920 // TFile *fsifile = new TFile(fefffilename,"READ");
922 if (TString(fefffilename).BeginsWith("alien:"))
923 TGrid::Connect("alien:");
924 TFile *fileT=TFile::Open(fefffilename);
926 for(Int_t jj=0;jj<6;jj++)//type binning
928 Nameg="effmap";Nameg+=jj;
929 //effcorection[jj] = (THnSparseF*)fsifile->Get(Nameg.Data());
930 effcorection[jj] = (THnSparseF*)fileT->Get(Nameg.Data());
932 //effcorection[jj]->SetDirectory(0);//****************************not present in case oh THnF
939 //fControlConvResoncances = new TH2F("fControlConvResoncances", ";id;delta mass", 3, -0.5, 2.5, 100, -0.1, 0.1);
940 // fOutput->Add(fControlConvResoncances);
946 //*****************************************************PIDQA histos*****************************************************//
950 for(Int_t ipart=0;ipart<NSpecies;ipart++){
951 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
954 if(ipid==NSigmaTPCTOF){miny=0;maxy=50;}
955 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);
956 fHistoNSigma->GetXaxis()->SetTitle("P_{T} (GeV / c)");
957 fHistoNSigma->GetYaxis()->SetTitle(Form("n#sigma %s %s",kParticleSpeciesName[ipart],kPIDTypeName[ipid]));
958 fOutputList->Add(fHistoNSigma);
963 for(Int_t ipart=0;ipart<NSpecies;ipart++){
964 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
967 if(ipid==NSigmaTPCTOF){miny=0;maxy=20;}
968 TH2F *fHistoNSigma=new TH2F(Form("NSigmaRec_%d_%d",ipart,ipid),
969 Form("n#sigma for reconstructed %s %s",kParticleSpeciesName[ipart],kPIDTypeName[ipid]),200,0,10,500,miny,maxy);
970 fHistoNSigma->GetXaxis()->SetTitle("P_{T} (GeV / c)");
971 fHistoNSigma->GetYaxis()->SetTitle(Form("n#sigma %s %s",kParticleSpeciesName[ipart],kPIDTypeName[ipid]));
972 fOutputList->Add(fHistoNSigma);
977 if(fUseExclusiveNSigma) {
978 for(Int_t ipart=0;ipart<NSpecies;ipart++){
979 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
982 if(ipid==NSigmaTPCTOF){miny=0;maxy=20;}
983 TH2F *fHistoNSigma=new TH2F(Form("NSigmaDC_%d_%d",ipart,ipid),
984 Form("n#sigma for double counting %s %s",kParticleSpeciesName[ipart],kPIDTypeName[ipid]),200,0,10,500,miny,maxy);
985 fHistoNSigma->GetXaxis()->SetTitle("P_{T} (GeV / c)");
986 fHistoNSigma->GetYaxis()->SetTitle(Form("n#sigma %s %s",kParticleSpeciesName[ipart],kPIDTypeName[ipid]));
987 fOutputList->Add(fHistoNSigma);
992 if (fAnalysisType == "MCAOD"){
993 for(Int_t ipart=0;ipart<NSpecies;ipart++){
994 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
997 if(ipid==NSigmaTPCTOF){miny=0;maxy=50;}
998 TH2F *fHistoNSigma=new TH2F(Form("NSigmaMC_%d_%d",ipart,ipid),
999 Form("n#sigma for MC %s %s",kParticleSpeciesName[ipart],kPIDTypeName[ipid]),200,0,10,500,miny,maxy);
1000 fHistoNSigma->GetXaxis()->SetTitle("P_{T} (GeV / c)");
1001 fHistoNSigma->GetYaxis()->SetTitle(Form("n#sigma %s %s",kParticleSpeciesName[ipart],kPIDTypeName[ipid]));
1002 fOutputList->Add(fHistoNSigma);
1007 for(Int_t idet=0;idet<fNDetectors;idet++){
1008 for(Int_t ipart=0;ipart<NSpecies;ipart++){
1010 if(idet==fTOF)maxy=1.1;
1011 TH2F *fHistoPID=new TH2F(Form("PID_%d_%d",idet,ipart),Form("%s signal - %s",kDetectorName[idet],kParticleSpeciesName[ipart]),200,0,10,500,-maxy,maxy);
1012 fHistoPID->GetXaxis()->SetTitle("P (GeV / c)");
1013 fHistoPID->GetYaxis()->SetTitle(Form("%s signal",kDetectorName[idet]));
1014 fOutputList->Add(fHistoPID);
1017 //PID signal plot, before PID cut
1018 for(Int_t idet=0;idet<fNDetectors;idet++){
1020 if(idet==fTOF)maxy=1.1;
1021 TH2F *fHistoPID=new TH2F(Form("PIDAll_%d",idet),Form("%s signal",kDetectorName[idet]),200,0,10,500,-maxy,maxy);
1022 fHistoPID->GetXaxis()->SetTitle("P (GeV / c)");
1023 fHistoPID->GetYaxis()->SetTitle(Form("%s signal",kDetectorName[idet]));
1024 fOutputList->Add(fHistoPID);
1027 PostData(1, fOutput); // Post data for ALL output slots >0 here, to get at least an empty histogram
1028 PostData(2, fOutputList);
1030 AliInfo("Finished setting up the Output");
1032 TH1::AddDirectory(oldStatus);
1037 //-------------------------------------------------------------------------------
1038 void AliTwoParticlePIDCorr::UserExec( Option_t * ){
1041 if(fAnalysisType == "AOD") {
1045 }//AOD--analysis-----
1047 else if(fAnalysisType == "MCAOD") {
1056 //-------------------------------------------------------------------------
1057 void AliTwoParticlePIDCorr::doMCAODevent()
1059 AliVEvent *event = InputEvent();
1060 if (!event) { Printf("ERROR: Could not retrieve event"); return; }
1061 AliAODEvent* aod = dynamic_cast<AliAODEvent*>(event);
1063 AliError("Cannot get the AOD event");
1067 // count all events(physics triggered)
1068 fEventCounter->Fill(1);
1070 // get centrality object and check quality(valid for p-Pb and Pb-Pb)
1071 Double_t cent_v0=0.0;
1073 if(fSampleType=="pPb" || fSampleType=="PbPb")
1075 AliCentrality *centrality=0;
1077 centrality = aod->GetHeader()->GetCentralityP();
1078 // if (centrality->GetQuality() != 0) return ;
1082 cent_v0 = centrality->GetCentralityPercentile(fCentralityMethod);
1090 //check the PIDResponse handler
1093 // get mag. field required for twotrack efficiency cut
1095 bSign = (aod->GetMagneticField() > 0) ? 1 : -1;
1097 //check for TClonesArray(truth track MC information)
1098 fArrayMC = dynamic_cast<TClonesArray*>(aod->FindListObject(AliAODMCParticle::StdBranchName()));
1100 AliFatal("Error: MC particles branch not found!\n");
1104 //check for AliAODMCHeader(truth event MC information)
1105 AliAODMCHeader *header=NULL;
1106 header=(AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
1108 printf("MC header branch not found!\n");
1112 //Only consider MC events within the vtx-z region used also as cut on the reconstructed vertex
1113 Float_t zVtxmc =header->GetVtxZ();
1114 if(TMath::Abs(zVtxmc)>fzvtxcut) return;
1116 // For productions with injected signals, figure out above which label to skip particles/tracks
1117 Int_t skipParticlesAbove = 0;
1119 if (fInjectedSignals)
1121 AliGenEventHeader* eventHeader = 0;
1126 AliFatal("fInjectedSignals set but no MC header found");
1128 headers = header->GetNCocktailHeaders();
1129 eventHeader = header->GetCocktailHeader(0);
1133 // We avoid AliFatal here, because the AOD productions sometimes have events where the MC header is missing
1134 // (due to unreadable Kinematics) and we don't want to loose the whole job because of a few events
1135 AliError("First event header not found. Skipping this event.");
1136 //fHistos->FillEvent(centrality, AliUEHist::kCFStepAnaTopology);
1139 skipParticlesAbove = eventHeader->NProduced();
1140 AliInfo(Form("Injected signals in this event (%d headers). Keeping events of %s. Will skip particles/tracks above %d.", headers, eventHeader->ClassName(), skipParticlesAbove));
1143 //vertex selection(is it fine for PP?)
1144 if ( fVertextype==1){
1145 trkVtx = aod->GetPrimaryVertex();
1146 if (!trkVtx || trkVtx->GetNContributors()<=0) return;
1147 TString vtxTtl = trkVtx->GetTitle();
1148 if (!vtxTtl.Contains("VertexerTracks")) return;
1149 zvtx = trkVtx->GetZ();
1150 const AliAODVertex* spdVtx = aod->GetPrimaryVertexSPD();
1151 if (!spdVtx || spdVtx->GetNContributors()<=0) return;
1152 TString vtxTyp = spdVtx->GetTitle();
1153 Double_t cov[6]={0};
1154 spdVtx->GetCovarianceMatrix(cov);
1155 Double_t zRes = TMath::Sqrt(cov[5]);
1156 if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) return;
1157 if (TMath::Abs(spdVtx->GetZ() - trkVtx->GetZ())>0.5) return;
1159 else if(fVertextype==2) {//for pp and pb-pb case
1160 Int_t nVertex = aod->GetNumberOfVertices();
1162 trkVtx = aod->GetPrimaryVertex();
1163 Int_t nTracksPrim = trkVtx->GetNContributors();
1164 zvtx = trkVtx->GetZ();
1165 //if (fDebug > 1)AliInfo(Form(" Vertex in = %f with %d particles by %s data ...",zVertex,nTracksPrim,vertex->GetName()));
1166 // Reject TPC only vertex
1167 TString name(trkVtx->GetName());
1168 if (name.CompareTo("PrimaryVertex") && name.CompareTo("SPDVertex"))return;
1170 // Select a quality vertex by number of tracks?
1171 if( nTracksPrim < fnTracksVertex ) {
1172 //if (fDebug > 1) AliInfo(" Primary-vertex Selection: event REJECTED ...");
1175 // TODO remove vertexer Z events with dispersion > 0.02: Doesn't work for AOD at present
1176 //if (strcmp(vertex->GetTitle(), "AliVertexerZ") == 0 && vertex->GetDispersion() > 0.02)
1178 // if (fDebug > 1) AliInfo(" Primary-vertex Selection: event ACCEPTED...");
1183 else if(fVertextype==0){//default case
1184 trkVtx = aod->GetPrimaryVertex();
1185 if (!trkVtx || trkVtx->GetNContributors()<=0) return;//proper number of contributors
1186 zvtx = trkVtx->GetZ();
1188 trkVtx->GetCovarianceMatrix(fCov);
1189 if(fCov[5] == 0) return;//proper vertex resolution
1192 AliInfo("Wrong Vertextype set for Primary-vertex Selection: event REJECTED ...");
1193 return;//as there is no proper sample type
1197 fHistQA[0]->Fill((trkVtx->GetX()));fHistQA[1]->Fill((trkVtx->GetY()));fHistQA[2]->Fill((trkVtx->GetZ())); //for trkVtx only before vertex cut |zvtx|<10 cm
1199 //count events having a proper vertex
1200 fEventCounter->Fill(3);
1202 if (TMath::Abs(zvtx) > fzvtxcut) return;
1204 fHistQA[3]->Fill((trkVtx->GetX()));fHistQA[4]->Fill((trkVtx->GetY()));fHistQA[5]->Fill((trkVtx->GetZ()));//after vertex cut for trkVtx only
1206 //now we have events passed physics trigger, centrality,eventzvtx cut
1208 //count events after vertex cut
1209 fEventCounter->Fill(4);
1211 if(!aod) return; //for safety
1213 if (fSampleType=="pPb" || fSampleType=="PbPb") if (cent_v0 < 0) return;//for pp case it is the multiplicity
1215 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)
1217 Double_t cent_v0_truth=0.0;
1219 //TObjArray* tracksMCtruth=0;
1220 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
1221 tracksMCtruth->SetOwner(kTRUE); //***********************************IMPORTANT!
1225 //There is a small difference between zvtx and zVtxmc??????
1226 //cout<<"***********************************************zVtxmc="<<zVtxmc<<endl;
1227 //cout<<"***********************************************zvtx="<<zvtx<<endl;
1229 //now process the truth particles(for both efficiency & correlation function)
1230 Int_t nMCTrack = fArrayMC->GetEntriesFast();
1232 for (Int_t iMC = 0; iMC < nMCTrack; iMC++)
1233 { //MC truth track loop starts
1235 AliAODMCParticle *partMC = (AliAODMCParticle*) fArrayMC->At(iMC);
1238 AliError(Form("ERROR: Could not retrieve AODMCtrack %d",iMC));
1242 //consider only charged particles
1243 if(partMC->Charge() == 0) continue;
1245 //consider only primary particles; neglect all secondary particles including from weak decays
1246 if(fselectprimaryTruth && !partMC->IsPhysicalPrimary()) continue;
1249 //remove injected signals(primaries above <maxLabel>)
1250 if (fInjectedSignals && partMC->GetLabel() >= skipParticlesAbove) continue;
1253 Bool_t isduplicate=kFALSE;
1254 if (fRemoveDuplicates)
1256 for (Int_t j=iMC+1; j<nMCTrack; ++j)
1257 {//2nd trutuh loop starts
1258 AliAODMCParticle *partMC2 = (AliAODMCParticle*) fArrayMC->At(j);
1260 AliError(Form("ERROR: Could not retrieve AODMCtrack %d",j));
1263 if (partMC->GetLabel() == partMC2->GetLabel())
1268 }//2nd truth loop ends
1270 if(fRemoveDuplicates && isduplicate) continue;//remove duplicates
1272 //give only kinematic cuts at the truth level
1273 if (partMC->Eta() < fmineta || partMC->Eta() > fmaxeta) continue;
1274 if (partMC->Pt() < fminPt || partMC->Pt() > fmaxPt) continue;
1276 if(!partMC) continue;//for safety
1278 //To determine multiplicity in case of PP
1280 //cout<<"**************************************"<<TMath::Abs(partMC->GetLabel())<<endl;
1281 //only physical primary(all/unidentified)
1282 if(ffillhistQATruth)
1284 MCtruthpt->Fill(partMC->Pt());
1285 MCtrutheta->Fill(partMC->Eta());
1286 MCtruthphi->Fill(partMC->Phi());
1289 Int_t pdgtruth=((AliAODMCParticle*)partMC)->GetPdgCode();
1290 Int_t particletypeTruth=-999;
1291 if (TMath::Abs(pdgtruth)==211)
1293 particletypeTruth=SpPion;
1294 if(ffillhistQATruth)
1296 MCtruthpionpt->Fill(partMC->Pt());
1297 MCtruthpioneta->Fill(partMC->Eta());
1298 MCtruthpionphi->Fill(partMC->Phi());
1301 if (TMath::Abs(pdgtruth)==321)
1303 particletypeTruth=SpKaon;
1304 if(ffillhistQATruth)
1306 MCtruthkaonpt->Fill(partMC->Pt());
1307 MCtruthkaoneta->Fill(partMC->Eta());
1308 MCtruthkaonphi->Fill(partMC->Phi());
1311 if(TMath::Abs(pdgtruth)==2212)
1313 particletypeTruth=SpProton;
1314 if(ffillhistQATruth)
1316 MCtruthprotonpt->Fill(partMC->Pt());
1317 MCtruthprotoneta->Fill(partMC->Eta());
1318 MCtruthprotonphi->Fill(partMC->Phi());
1321 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)
1323 // -- Fill THnSparse for efficiency and contamination calculation
1324 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
1326 Double_t primmctruth[4] = {cent_v0, zVtxmc,partMC->Pt(), partMC->Eta()};
1329 fTrackHistEfficiency[5]->Fill(primmctruth,0);//for all primary truth particles(4)
1330 if (TMath::Abs(pdgtruth)==211 || TMath::Abs(pdgtruth)==321) fTrackHistEfficiency[3]->Fill(primmctruth,0);//for primary truth mesons(3)
1331 if (TMath::Abs(pdgtruth)==2212 || TMath::Abs(pdgtruth)==321) fTrackHistEfficiency[4]->Fill(primmctruth,0);//for primary truth kaons+protons(4)
1332 if (TMath::Abs(pdgtruth)==211) fTrackHistEfficiency[0]->Fill(primmctruth,0);//for pions
1333 if (TMath::Abs(pdgtruth)==321) fTrackHistEfficiency[1]->Fill(primmctruth,0);//for kaons
1334 if(TMath::Abs(pdgtruth)==2212) fTrackHistEfficiency[2]->Fill(primmctruth,0);//for protons
1337 Float_t effmatrixtruth=1.0;//In Truth MC, no case of efficiency correction so it should be always 1.0
1338 if((partMC->Pt()>=fminPtAsso && partMC->Pt()<=fmaxPtAsso) || (partMC->Pt()>=fminPtTrig && partMC->Pt()<=fmaxPtTrig))//to reduce memory consumption in pool
1340 LRCParticlePID* copy6 = new LRCParticlePID(particletypeTruth,partMC->Charge(),partMC->Pt(),partMC->Eta(), partMC->Phi(),effmatrixtruth);
1341 //copy6->SetUniqueID(eventno * 100000 + TMath::Abs(partMC->GetLabel()));
1342 copy6->SetUniqueID(eventno * 100000 + (Int_t)nooftrackstruth);
1343 tracksMCtruth->Add(copy6);//************** TObjArray used for truth correlation function calculation
1345 }//MC truth track loop ends
1347 //*********************still in event loop
1348 Float_t weghtval=1.0;
1350 if (fSampleType=="pp") cent_v0_truth=nooftrackstruth;
1351 else cent_v0_truth=cent_v0;//the notation cent_v0 is reserved for reco/data case
1353 //now cent_v0_truth should be used for all correlation function calculation
1355 if(nooftrackstruth>0.0 && ffilltrigIDassoIDMCTRUTH)
1357 //Fill Correlations for MC truth particles(same event)
1358 if(tracksMCtruth && tracksMCtruth->GetEntriesFast()>0)//hadron triggered correlation
1359 Fillcorrelation(tracksMCtruth,0,cent_v0_truth,zVtxmc,weghtval,kFALSE,bSign,fPtOrderMCTruth,kFALSE,kFALSE,"trigIDassoIDMCTRUTH");//mixcase=kFALSE for same event case
1362 AliEventPool* pool2 = fPoolMgr->GetEventPool(cent_v0_truth, zVtxmc+200);
1363 if (pool2 && pool2->IsReady())
1364 {//start mixing only when pool->IsReady
1365 if(tracksMCtruth && tracksMCtruth->GetEntriesFast()>0)
1366 {//proceed only when no. of trigger particles >0 in current event
1367 Float_t nmix=(Float_t)pool2->GetCurrentNEvents();
1368 for (Int_t jMix=0; jMix<pool2->GetCurrentNEvents(); jMix++)
1369 { //pool event loop start
1370 TObjArray* bgTracks6 = pool2->GetEvent(jMix);
1371 if(!bgTracks6) continue;
1372 Fillcorrelation(tracksMCtruth,bgTracks6,cent_v0_truth,zVtxmc,nmix,(jMix == 0),bSign,fPtOrderMCTruth,kFALSE,kTRUE,"trigIDassoIDMCTRUTH");//mixcase=kTRUE for mixing case
1374 }// pool event loop ends mixing case
1375 }//if(trackstrig && trackstrig->GetEntriesFast()>0) condition ends mixing case
1376 } //if pool->IsReady() condition ends mixing case
1378 //still in main event loop
1381 if(pool2) pool2->UpdatePool(CloneAndReduceTrackList(tracksMCtruth));//ownership of tracksasso is with pool now, don't delete it
1385 //still in main event loop
1387 if(tracksMCtruth) delete tracksMCtruth;
1389 //now deal with reco tracks
1390 //TObjArray* tracksUNID=0;
1391 TObjArray* tracksUNID = new TObjArray;
1392 tracksUNID->SetOwner(kTRUE);
1394 //TObjArray* tracksID=0;
1395 TObjArray* tracksID = new TObjArray;
1396 tracksID->SetOwner(kTRUE);
1399 Float_t bSign1=aod->GetHeader()->GetMagneticField() ;//used for reconstructed track dca cut
1401 Double_t trackscount=0.0;
1403 // loop over reconstructed tracks
1404 for (Int_t itrk = 0; itrk < aod->GetNumberOfTracks(); itrk++)
1405 { // reconstructed track loop starts
1406 AliAODTrack* track = dynamic_cast<AliAODTrack*>(aod->GetTrack(itrk));
1407 if (!track) continue;
1408 //get the corresponding MC track at the truth level (doing reco matching)
1409 AliAODMCParticle* recomatched = static_cast<AliAODMCParticle*>(fArrayMC->At(TMath::Abs(track->GetLabel())));
1410 if(!recomatched) continue;//if a reco track doesn't have corresponding truth track at generated level is a fake track(label==0), ignore it
1412 //remove injected signals
1413 if(fInjectedSignals)
1415 AliAODMCParticle* mother = recomatched;
1417 while (!mother->IsPhysicalPrimary())
1418 {// find the primary mother;the first stable mother is searched and checked if it is <= <maxLabel>
1419 if (mother->GetMother() < 0)
1425 mother =(AliAODMCParticle*) fArrayMC->At(((AliAODMCParticle*)mother)->GetMother());
1431 Printf("WARNING: No mother found for particle %d:", recomatched->GetLabel());
1434 if (mother->GetLabel() >= skipParticlesAbove) continue;//remove injected signals(primaries above <maxLabel>)
1435 }//remove injected signals
1437 if (fRemoveWeakDecays && ((AliAODMCParticle*) recomatched)->IsSecondaryFromWeakDecay()) continue;//remove weak decays
1439 Bool_t isduplicate2=kFALSE;
1440 if (fRemoveDuplicates)
1442 for (Int_t j =itrk+1; j < aod->GetNumberOfTracks(); j++)
1444 AliAODTrack* track2 = dynamic_cast<AliAODTrack*>(aod->GetTrack(j));
1445 if (!track2) continue;
1446 AliAODMCParticle* recomatched2 = static_cast<AliAODMCParticle*>(fArrayMC->At(TMath::Abs(track2->GetLabel())));
1447 if(!recomatched2) continue;
1449 if (track->GetLabel() == track2->GetLabel())
1456 if(fRemoveDuplicates && isduplicate2) continue;//remove duplicates
1458 fHistQA[11]->Fill(track->GetTPCNcls());
1459 Int_t tracktype=ClassifyTrack(track,trkVtx,bSign1);//dcacut=kFALSE,onlyprimary=kFALSE
1461 if(tracktype==0) continue;
1462 if(tracktype==1)//tracks "not" passed AliAODTrack::kPrimary at reconstructed level & have proper TPC PID response(?)
1464 if(!track) continue;//for safety
1465 //accepted all(primaries+secondary) reconstructed tracks(pt 0.2 to 10.0,,eta -0.8 to 0.8)
1468 //check for eta , phi holes
1469 fEtaSpectrasso->Fill(track->Eta(),track->Pt());
1470 fphiSpectraasso->Fill(track->Phi(),track->Pt());
1472 Int_t particletypeMC=-9999;
1474 //tag all particles as unidentified
1475 particletypeMC=unidentified;
1477 Float_t effmatrix=1.;
1479 // -- Fill THnSparse for efficiency calculation
1480 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
1481 //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)
1483 //Clone & Reduce track list(TObjArray) for unidentified particles
1484 if((track->Pt()>=fminPtAsso && track->Pt()<=fmaxPtAsso) || (track->Pt()>=fminPtTrig && track->Pt()<=fmaxPtTrig))//to reduce memory consumption in pool
1486 if (fapplyTrigefficiency || fapplyAssoefficiency)//get the trackingefficiency x contamination factor for unidentified particles
1487 effmatrix=GetTrackbyTrackeffvalue(track,cent_v0,zvtx,particletypeMC);
1488 LRCParticlePID* copy = new LRCParticlePID(particletypeMC,track->Charge(),track->Pt(),track->Eta(), track->Phi(),effmatrix);
1489 copy->SetUniqueID(eventno * 100000 +(Int_t)trackscount);
1490 tracksUNID->Add(copy);//track information Storage for UNID correlation function(tracks that pass the filterbit & kinematic cuts only)
1493 //get the pdg code of the corresponding truth particle
1494 Int_t pdgCode = ((AliAODMCParticle*)recomatched)->GetPdgCode();
1496 Double_t allrecomatchedpid[4] = {cent_v0, zVtxmc,recomatched->Pt(), recomatched->Eta()};
1497 if(ffillefficiency) {
1498 fTrackHistEfficiency[5]->Fill(allrecomatchedpid,2);//for allreco matched
1499 if(TMath::Abs(pdgCode)==211 || TMath::Abs(pdgCode)==321) fTrackHistEfficiency[3]->Fill(allrecomatchedpid,2);//for mesons
1500 if(TMath::Abs(pdgCode)==321 || TMath::Abs(pdgCode)==2212) fTrackHistEfficiency[4]->Fill(allrecomatchedpid,2);//for kaons+protons
1501 if(TMath::Abs(pdgCode)==211) fTrackHistEfficiency[0]->Fill(allrecomatchedpid,2);//for pions
1502 if(TMath::Abs(pdgCode)==321) fTrackHistEfficiency[1]->Fill(allrecomatchedpid,2);//for kaons
1503 if(TMath::Abs(pdgCode)==2212) fTrackHistEfficiency[2]->Fill(allrecomatchedpid,2);//for protons
1505 if (((AliAODMCParticle*)recomatched)->IsPhysicalPrimary()) {
1506 fTrackHistEfficiency[5]->Fill(allrecomatchedpid,1);//for primreco matched
1507 if(TMath::Abs(pdgCode)==211 || TMath::Abs(pdgCode)==321) fTrackHistEfficiency[3]->Fill(allrecomatchedpid,1);//for mesons
1508 if(TMath::Abs(pdgCode)==321 || TMath::Abs(pdgCode)==2212) fTrackHistEfficiency[4]->Fill(allrecomatchedpid,1);//for kaons+protons
1509 if( TMath::Abs(pdgCode)==211) fTrackHistEfficiency[0]->Fill(allrecomatchedpid,1);//for pions
1510 if( TMath::Abs(pdgCode)==321) fTrackHistEfficiency[1]->Fill(allrecomatchedpid,1);//for kaons
1511 if( TMath::Abs(pdgCode)==2212) fTrackHistEfficiency[2]->Fill(allrecomatchedpid,1);//for protons
1516 //now start the particle identification process:)
1517 switch(TMath::Abs(pdgCode)){
1519 if(fFIllPIDQAHistos){
1520 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
1521 if((ipid!=NSigmaTPC) && (!HasTOFPID(track)) && track->Pt()<fPtTOFPIDmin)continue;//not filling TOF and combined if no TOF PID
1522 TH2F *h=GetHistogram2D(Form("NSigmaMC_%d_%d",SpProton,ipid));
1523 h->Fill(track->Pt(),fnsigmas[SpProton][ipid]);
1528 if(fFIllPIDQAHistos){
1529 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
1530 if((ipid!=NSigmaTPC) && (!HasTOFPID(track)) && track->Pt()<fPtTOFPIDmin)continue;//not filling TOF and combined if no TOF PID
1531 TH2F *h=GetHistogram2D(Form("NSigmaMC_%d_%d",SpKaon,ipid));
1532 h->Fill(track->Pt(),fnsigmas[SpKaon][ipid]);
1537 if(fFIllPIDQAHistos){
1538 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
1539 if((ipid!=NSigmaTPC) && (!HasTOFPID(track)) && track->Pt()<fPtTOFPIDmin)continue;//not filling TOF and combined if no TOF PID
1540 TH2F *h=GetHistogram2D(Form("NSigmaMC_%d_%d",SpPion,ipid));
1541 h->Fill(track->Pt(),fnsigmas[SpPion][ipid]);
1548 Float_t dEdx = track->GetTPCsignal();
1549 fHistoTPCdEdx->Fill(track->Pt(), dEdx);
1551 if(HasTOFPID(track))
1553 Double_t beta = GetBeta(track);
1554 fHistoTOFbeta->Fill(track->Pt(), beta);
1557 //do track identification(nsigma method)
1558 particletypeMC=GetParticle(track,fFIllPIDQAHistos);//******************************problem is here
1560 //2-d TPCTOF map(for each Pt interval)
1561 if(HasTOFPID(track)){
1562 fTPCTOFPion3d->Fill(track->Pt(),fnsigmas[SpPion][NSigmaTOF],fnsigmas[SpPion][NSigmaTPC]);
1563 fTPCTOFKaon3d->Fill(track->Pt(),fnsigmas[SpKaon][NSigmaTOF],fnsigmas[SpKaon][NSigmaTPC]);
1564 fTPCTOFProton3d->Fill(track->Pt(),fnsigmas[SpProton][NSigmaTOF],fnsigmas[SpProton][NSigmaTPC]);
1566 if(particletypeMC==SpUndefined) continue;
1568 //Pt, Eta , Phi distribution of the reconstructed identified particles
1571 if (particletypeMC==SpPion)
1573 fPionPt->Fill(track->Pt());
1574 fPionEta->Fill(track->Eta());
1575 fPionPhi->Fill(track->Phi());
1577 if (particletypeMC==SpKaon)
1579 fKaonPt->Fill(track->Pt());
1580 fKaonEta->Fill(track->Eta());
1581 fKaonPhi->Fill(track->Phi());
1583 if (particletypeMC==SpProton)
1585 fProtonPt->Fill(track->Pt());
1586 fProtonEta->Fill(track->Eta());
1587 fProtonPhi->Fill(track->Phi());
1591 //for misidentification fraction calculation(do it with tuneonPID)
1592 if(particletypeMC==SpPion )
1594 if(TMath::Abs(pdgCode)==211) fPioncont->Fill(1.,track->Pt());
1595 if(TMath::Abs(pdgCode)==321) fPioncont->Fill(3.,track->Pt());
1596 if(TMath::Abs(pdgCode)==2212) fPioncont->Fill(5.,track->Pt());
1597 if(TMath::Abs(pdgCode)!=211 && TMath::Abs(pdgCode)!=321 && TMath::Abs(pdgCode)!=2212) fPioncont->Fill(7.,track->Pt());
1599 if(particletypeMC==SpKaon )
1601 if(TMath::Abs(pdgCode)==211) fKaoncont->Fill(1.,track->Pt());
1602 if(TMath::Abs(pdgCode)==321) fKaoncont->Fill(3.,track->Pt());
1603 if(TMath::Abs(pdgCode)==2212) fKaoncont->Fill(5.,track->Pt());
1604 if(TMath::Abs(pdgCode)!=211 && TMath::Abs(pdgCode)!=321 && TMath::Abs(pdgCode)!=2212) fKaoncont->Fill(7.,track->Pt());
1606 if(particletypeMC==SpProton )
1608 if(TMath::Abs(pdgCode)==211) fProtoncont->Fill(1.,track->Pt());
1609 if(TMath::Abs(pdgCode)==321) fProtoncont->Fill(3.,track->Pt());
1610 if(TMath::Abs(pdgCode)==2212) fProtoncont->Fill(5.,track->Pt());
1611 if(TMath::Abs(pdgCode)!=211 && TMath::Abs(pdgCode)!=321 && TMath::Abs(pdgCode)!=2212) fProtoncont->Fill(7.,track->Pt());
1614 //fill tracking efficiency
1617 if(particletypeMC==SpPion || particletypeMC==SpKaon)
1619 if(TMath::Abs(pdgCode)==211 || TMath::Abs(pdgCode)==321) {
1620 fTrackHistEfficiency[3]->Fill(allrecomatchedpid,4);//for mesons
1621 if (((AliAODMCParticle*)recomatched)->IsPhysicalPrimary()) fTrackHistEfficiency[3]->Fill(allrecomatchedpid,3);//for mesons
1624 if(particletypeMC==SpKaon || particletypeMC==SpProton)
1626 if(TMath::Abs(pdgCode)==321 || TMath::Abs(pdgCode)==2212) {
1627 fTrackHistEfficiency[4]->Fill(allrecomatchedpid,4);//for kaons+protons
1628 if (((AliAODMCParticle*)recomatched)->IsPhysicalPrimary()) fTrackHistEfficiency[4]->Fill(allrecomatchedpid,3);
1631 if(particletypeMC==SpPion && TMath::Abs(pdgCode)==211) {
1632 fTrackHistEfficiency[0]->Fill(allrecomatchedpid,4);//for pions
1633 if (((AliAODMCParticle*)recomatched)->IsPhysicalPrimary()) fTrackHistEfficiency[0]->Fill(allrecomatchedpid,3);
1635 if(particletypeMC==SpKaon && TMath::Abs(pdgCode)==321) {
1636 fTrackHistEfficiency[1]->Fill(allrecomatchedpid,4);//for kaons
1637 if (((AliAODMCParticle*)recomatched)->IsPhysicalPrimary()) fTrackHistEfficiency[1]->Fill(allrecomatchedpid,3);
1639 if(particletypeMC==SpProton && TMath::Abs(pdgCode)==2212){
1640 fTrackHistEfficiency[2]->Fill(allrecomatchedpid,4);//for protons
1641 if (((AliAODMCParticle*)recomatched)->IsPhysicalPrimary()) fTrackHistEfficiency[2]->Fill(allrecomatchedpid,3);
1645 if((track->Pt()>=fminPtAsso && track->Pt()<=fmaxPtAsso) || (track->Pt()>=fminPtTrig && track->Pt()<=fmaxPtTrig))//to reduce memory consumption in pool
1647 if (fapplyTrigefficiency || fapplyAssoefficiency)
1648 effmatrix=GetTrackbyTrackeffvalue(track,cent_v0,zvtx,particletypeMC);//get the tracking eff x TOF matching eff x PID eff x contamination factor for identified particles
1649 LRCParticlePID* copy1 = new LRCParticlePID(particletypeMC,track->Charge(),track->Pt(),track->Eta(), track->Phi(),effmatrix);
1650 copy1->SetUniqueID(eventno * 100000 + (Int_t)trackscount);
1651 tracksID->Add(copy1);
1653 }// if(tracktype==1) condition structure ands
1655 }//reco track loop ends
1657 //*************************************************************still in event loop
1659 //same event delta-eta-deltaphi plot
1660 if(fSampleType=="pp") cent_v0=trackscount;//multiplicity
1664 //fill the centrality/multiplicity distribution of the selected events
1665 fhistcentrality->Fill(cent_v0);//*********************************WARNING::binning of cent_v0 is different for pp and pPb/PbPb case
1667 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??????
1669 //count selected events having centrality betn 0-100%
1670 fEventCounter->Fill(5);
1672 //***************************************event no. counting
1673 Bool_t isbaryontrig=kFALSE;
1674 Bool_t ismesontrig=kFALSE;
1675 if(tracksUNID && tracksUNID->GetEntriesFast()>0) fEventno->Fill(cent_v0,zvtx);
1677 if(tracksID && tracksID->GetEntriesFast()>0)
1679 for(Int_t i=0;i<tracksID->GetEntriesFast();i++)
1680 { //trigger loop starts
1681 LRCParticlePID *trig=(LRCParticlePID*)(tracksID->UncheckedAt(i));
1683 if(trig->Pt()<fminPtTrig || trig->Pt()>fmaxPtTrig) continue;
1684 Int_t particlepidtrig=trig->getparticle(); //either 1 or 2
1685 if(particlepidtrig==SpProton) isbaryontrig=kTRUE;
1686 if(particlepidtrig==SpPion) ismesontrig=kTRUE;
1688 if (isbaryontrig) fEventnobaryon->Fill(cent_v0,zvtx);
1689 if (ismesontrig) fEventnomeson->Fill(cent_v0,zvtx);
1692 //same event delte-eta, delta-phi plot
1693 if(tracksUNID && tracksUNID->GetEntriesFast()>0)//hadron triggered correlation
1694 {//same event calculation starts
1695 if(ffilltrigassoUNID) Fillcorrelation(tracksUNID,0,cent_v0,zvtx,weghtval,kFALSE,bSign,fPtOrderDataReco,kTRUE,kFALSE,"trigassoUNID");//mixcase=kFALSE (hadron-hadron correlation)
1696 if(tracksID && tracksID->GetEntriesFast()>0 && ffilltrigUNIDassoID) Fillcorrelation(tracksUNID,tracksID,cent_v0,zvtx,weghtval,kFALSE,bSign,fPtOrderDataReco,kTRUE,kFALSE,"trigUNIDassoID");//mixcase=kFALSE (hadron-ID correlation)
1699 if(tracksID && tracksID->GetEntriesFast()>0)//ID triggered correlation
1700 {//same event calculation starts
1701 if(tracksUNID && tracksUNID->GetEntriesFast()>0 && ffilltrigIDassoUNID) Fillcorrelation(tracksID,tracksUNID,cent_v0,zvtx,weghtval,kFALSE,bSign,fPtOrderDataReco,kTRUE,kFALSE,"trigIDassoUNID");//mixcase=kFALSE (ID-hadron correlation)
1702 if(ffilltrigIDassoID) Fillcorrelation(tracksID,0,cent_v0,zvtx,weghtval,kFALSE,bSign,fPtOrderDataReco,kTRUE,kFALSE,"trigIDassoID");//mixcase=kFALSE (ID-ID correlation)
1705 //still in main event loop
1707 if(ffilltrigassoUNID || ffilltrigIDassoUNID){//mixing with unidentified particles
1708 AliEventPool* pool = fPoolMgr->GetEventPool(cent_v0, zvtx);//In the pool there is tracksUNID(i.e associateds are unidentified)
1709 if (pool && pool->IsReady())
1710 {//start mixing only when pool->IsReady
1711 Float_t nmix1=(Float_t)pool->GetCurrentNEvents();
1712 for (Int_t jMix=0; jMix<pool->GetCurrentNEvents(); jMix++)
1713 { //pool event loop start
1714 TObjArray* bgTracks = pool->GetEvent(jMix);
1715 if(!bgTracks) continue;
1716 if(ffilltrigassoUNID && tracksUNID && tracksUNID->GetEntriesFast()>0)//*******************************hadron trggered mixing
1717 Fillcorrelation(tracksUNID,bgTracks,cent_v0,zvtx,nmix1,(jMix == 0),bSign,fPtOrderDataReco,kTRUE,kTRUE,"trigassoUNID");//mixcase=kTRUE
1718 if(ffilltrigIDassoUNID && tracksID && tracksID->GetEntriesFast()>0)//***********************************ID trggered mixing
1719 Fillcorrelation(tracksID,bgTracks,cent_v0,zvtx,nmix1,(jMix == 0),bSign,fPtOrderDataReco,kTRUE,kTRUE,"trigIDassoUNID");//mixcase=kTRUE
1720 }// pool event loop ends mixing case
1722 } //if pool->IsReady() condition ends mixing case
1725 pool->UpdatePool(CloneAndReduceTrackList(tracksUNID));
1727 }//mixing with unidentified particles
1729 if(ffilltrigUNIDassoID || ffilltrigIDassoID){//mixing with identified particles
1730 AliEventPool* pool1 = fPoolMgr->GetEventPool(cent_v0, zvtx+100);//In the pool1 there is tracksID(i.e associateds are identified)
1731 if (pool1 && pool1->IsReady())
1732 {//start mixing only when pool->IsReady
1733 Float_t nmix2=(Float_t)pool1->GetCurrentNEvents();
1734 for (Int_t jMix=0; jMix<pool1->GetCurrentNEvents(); jMix++)
1735 { //pool event loop start
1736 TObjArray* bgTracks2 = pool1->GetEvent(jMix);
1737 if(!bgTracks2) continue;
1738 if(ffilltrigUNIDassoID && tracksUNID && tracksUNID->GetEntriesFast()>0)
1739 Fillcorrelation(tracksUNID,bgTracks2,cent_v0,zvtx,nmix2,(jMix == 0),bSign,fPtOrderDataReco,kTRUE,kTRUE,"trigUNIDassoID");//mixcase=kTRUE
1740 if(ffilltrigIDassoID && tracksID && tracksID->GetEntriesFast()>0)
1741 Fillcorrelation(tracksID,bgTracks2,cent_v0,zvtx,nmix2,(jMix == 0),bSign,fPtOrderDataReco,kTRUE,kTRUE,"trigIDassoID");//mixcase=kTRUE
1743 }// pool event loop ends mixing case
1744 } //if pool1->IsReady() condition ends mixing case
1748 pool1->UpdatePool(CloneAndReduceTrackList(tracksID));//ownership of tracksasso is with pool now, don't delete it(tracksUNID is with pool)
1750 }//mixing with identified particles
1752 //no. of events analyzed
1753 fEventCounter->Fill(6);
1756 if(tracksUNID) delete tracksUNID;
1758 if(tracksID) delete tracksID;
1761 PostData(1, fOutput);
1764 //________________________________________________________________________
1765 void AliTwoParticlePIDCorr::doAODevent()
1769 AliVEvent *event = InputEvent();
1770 if (!event) { Printf("ERROR: Could not retrieve event"); return; }
1771 AliAODEvent* aod = dynamic_cast<AliAODEvent*>(event);
1773 AliError("Cannot get the AOD event");
1778 fEventCounter->Fill(1);
1780 // get centrality object and check quality
1783 if(fSampleType=="pPb" || fSampleType=="PbPb")
1785 AliCentrality *centrality=0;
1787 centrality = aod->GetHeader()->GetCentralityP();
1788 // if (centrality->GetQuality() != 0) return ;
1792 cent_v0 = centrality->GetCentralityPercentile(fCentralityMethod);
1800 Float_t bSign = (aod->GetMagneticField() > 0) ? 1 : -1;//for two track efficiency cut in correlation function calculation
1801 Float_t bSign1=aod->GetHeader()->GetMagneticField() ;//for dca cut in ClassifyTrack(), i.e in track loop
1803 // Pileup selection ************************************************
1804 if(frejectPileUp) //applicable only for TPC only tracks,not for hybrid tracks?.
1806 if (fAnalysisUtils && fAnalysisUtils->IsPileUpEvent(aod)) return;
1809 //count events after PileUP cut
1810 fEventCounter->Fill(2);
1812 if (!fPID) return;//this should be available with each event even if we don't do PID selection
1814 //vertex selection(is it fine for PP?)
1815 if ( fVertextype==1){//for pPb basically if(!fAnalysisUtils->IsVertexSelected2013pA(aod)) return;
1816 trkVtx = aod->GetPrimaryVertex();
1817 if (!trkVtx || trkVtx->GetNContributors()<=0) return;
1818 TString vtxTtl = trkVtx->GetTitle();
1819 if (!vtxTtl.Contains("VertexerTracks")) return;
1820 zvtx = trkVtx->GetZ();
1821 const AliAODVertex* spdVtx = aod->GetPrimaryVertexSPD();
1822 if (!spdVtx || spdVtx->GetNContributors()<=0) return;
1823 TString vtxTyp = spdVtx->GetTitle();
1824 Double_t cov[6]={0};
1825 spdVtx->GetCovarianceMatrix(cov);
1826 Double_t zRes = TMath::Sqrt(cov[5]);
1827 if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) return;
1828 if (TMath::Abs(spdVtx->GetZ() - trkVtx->GetZ())>0.5) return;
1830 else if(fVertextype==2) {//for pp and pb-pb case , taken from Jan's code
1831 Int_t nVertex = aod->GetNumberOfVertices();
1833 trkVtx = aod->GetPrimaryVertex();
1834 Int_t nTracksPrim = trkVtx->GetNContributors();
1835 zvtx = trkVtx->GetZ();
1836 //if (fDebug > 1)AliInfo(Form(" Vertex in = %f with %d particles by %s data ...",zVertex,nTracksPrim,vertex->GetName()));
1837 // Reject TPC only vertex
1838 TString name(trkVtx->GetName());
1839 if (name.CompareTo("PrimaryVertex") && name.CompareTo("SPDVertex"))return;
1841 // Select a quality vertex by number of tracks?
1842 if( nTracksPrim < fnTracksVertex ) {
1843 //if (fDebug > 1) AliInfo(" Primary-vertex Selection: event REJECTED ...");
1846 // TODO remove vertexer Z events with dispersion > 0.02: Doesn't work for AOD at present
1847 //if (strcmp(vertex->GetTitle(), "AliVertexerZ") == 0 && vertex->GetDispersion() > 0.02)
1849 // if (fDebug > 1) AliInfo(" Primary-vertex Selection: event ACCEPTED...");
1854 else if(fVertextype==0){//default case
1855 trkVtx = aod->GetPrimaryVertex();
1856 if (!trkVtx || trkVtx->GetNContributors()<=0) return;//proper number of contributors
1857 zvtx = trkVtx->GetZ();
1859 trkVtx->GetCovarianceMatrix(fCov);
1860 if(fCov[5] == 0) return;//proper vertex resolution
1863 AliInfo("Wrong Vertextype set for Primary-vertex Selection: event REJECTED ...");
1864 return;//as there is no proper sample type
1867 fHistQA[0]->Fill((trkVtx->GetX()));fHistQA[1]->Fill((trkVtx->GetY()));fHistQA[2]->Fill((trkVtx->GetZ())); //for trkVtx only before vertex cut |zvtx|<10 cm
1869 //count events having a proper vertex
1870 fEventCounter->Fill(3);
1872 if (TMath::Abs(zvtx) > fzvtxcut) return;
1874 //count events after vertex cut
1875 fEventCounter->Fill(4);
1878 //if(!fAnalysisUtils->IsVertexSelected2013pA(aod)) return;
1880 fHistQA[3]->Fill((trkVtx->GetX()));fHistQA[4]->Fill((trkVtx->GetY()));fHistQA[5]->Fill((trkVtx->GetZ()));//after vertex cut,for trkVtx only
1883 if(!aod) return; //for safety
1885 if(fSampleType=="pPb" || fSampleType=="PbPb") if (cent_v0 < 0) return;//for pp case it is the multiplicity
1887 TObjArray* tracksUNID= new TObjArray;//track info before doing PID
1888 tracksUNID->SetOwner(kTRUE); // IMPORTANT!
1890 TObjArray* tracksID= new TObjArray;//only pions, kaons,protonsi.e. after doing the PID selection
1891 tracksID->SetOwner(kTRUE); // IMPORTANT!
1893 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)
1897 Bool_t fTrigPtmin1=kFALSE;
1898 Bool_t fTrigPtmin2=kFALSE;
1899 Bool_t fTrigPtJet=kFALSE;
1901 for (Int_t itrk = 0; itrk < aod->GetNumberOfTracks(); itrk++)
1902 { //track loop starts for TObjArray(containing track and event information) filling; used for correlation function calculation
1903 AliAODTrack* track = dynamic_cast<AliAODTrack*>(aod->GetTrack(itrk));
1904 if (!track) continue;
1905 fHistQA[11]->Fill(track->GetTPCNcls());
1906 Int_t particletype=-9999;//required for PID filling
1907 Int_t tracktype=ClassifyTrack(track,trkVtx,bSign1);//dcacut=kFALSE,onlyprimary=kFALSE
1908 if(tracktype!=1) continue;
1910 if(!track) continue;//for safety
1912 //check for eta , phi holes
1913 fEtaSpectrasso->Fill(track->Eta(),track->Pt());
1914 fphiSpectraasso->Fill(track->Phi(),track->Pt());
1918 //if no applyefficiency , set the eff factor=1.0
1919 Float_t effmatrix=1.0;
1921 //tag all particles as unidentified that passed filterbit & kinematic cuts
1922 particletype=unidentified;
1925 if(track->Pt()>=fminPtTrig) fTrigPtmin1=kTRUE;
1926 if(track->Pt()>=(fminPtTrig+0.5)) fTrigPtmin2=kTRUE;
1927 if(track->Pt()>=fmaxPtTrig) fTrigPtJet=kTRUE;
1930 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
1933 //to reduce memory consumption in pool
1934 if((track->Pt()>=fminPtAsso && track->Pt()<=fmaxPtAsso) || (track->Pt()>=fminPtTrig && track->Pt()<=fmaxPtTrig))
1936 //Clone & Reduce track list(TObjArray) for unidentified particles
1937 if (fapplyTrigefficiency || fapplyAssoefficiency)//get the trackingefficiency x contamination factor for unidentified particles
1938 effmatrix=GetTrackbyTrackeffvalue(track,cent_v0,zvtx,particletype);
1939 LRCParticlePID* copy = new LRCParticlePID(particletype,track->Charge(),track->Pt(),track->Eta(), track->Phi(),effmatrix);
1940 copy->SetUniqueID(eventno * 100000 + (Int_t)trackscount);
1941 tracksUNID->Add(copy);//track information Storage for UNID correlation function(tracks that pass the filterbit & kinematic cuts only)
1944 //now start the particle identificaion process:)
1946 //track passing filterbit 768 have proper TPC response,or need to be checked explicitly before doing PID????
1948 Float_t dEdx = track->GetTPCsignal();
1949 fHistoTPCdEdx->Fill(track->Pt(), dEdx);
1951 //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)
1952 if(HasTOFPID(track))
1954 Double_t beta = GetBeta(track);
1955 fHistoTOFbeta->Fill(track->Pt(), beta);
1959 //track identification(using nsigma method)
1960 particletype=GetParticle(track,fFIllPIDQAHistos);//*******************************change may be required(It should return only pion,kaon, proton and Spundefined; NOT unidentifed***************be careful)
1963 //2-d TPCTOF map(for each Pt interval)
1964 if(HasTOFPID(track)){
1965 fTPCTOFPion3d->Fill(track->Pt(),fnsigmas[SpPion][NSigmaTOF],fnsigmas[SpPion][NSigmaTPC]);
1966 fTPCTOFKaon3d->Fill(track->Pt(),fnsigmas[SpKaon][NSigmaTOF],fnsigmas[SpKaon][NSigmaTPC]);
1967 fTPCTOFProton3d->Fill(track->Pt(),fnsigmas[SpProton][NSigmaTOF],fnsigmas[SpProton][NSigmaTPC]);
1970 //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!!!!!
1971 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)!!!!!!!!!!!
1973 //Pt, Eta , Phi distribution of the reconstructed identified particles
1976 if (particletype==SpPion)
1978 fPionPt->Fill(track->Pt());
1979 fPionEta->Fill(track->Eta());
1980 fPionPhi->Fill(track->Phi());
1982 if (particletype==SpKaon)
1984 fKaonPt->Fill(track->Pt());
1985 fKaonEta->Fill(track->Eta());
1986 fKaonPhi->Fill(track->Phi());
1988 if (particletype==SpProton)
1990 fProtonPt->Fill(track->Pt());
1991 fProtonEta->Fill(track->Eta());
1992 fProtonPhi->Fill(track->Phi());
1996 if((track->Pt()>=fminPtAsso && track->Pt()<=fmaxPtAsso) || (track->Pt()>=fminPtTrig && track->Pt()<=fmaxPtTrig))
1998 if (fapplyTrigefficiency || fapplyAssoefficiency)
1999 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
2000 LRCParticlePID* copy1 = new LRCParticlePID(particletype,track->Charge(),track->Pt(),track->Eta(), track->Phi(),effmatrix);
2001 copy1->SetUniqueID(eventno * 100000 + (Int_t)trackscount);
2002 tracksID->Add(copy1);
2004 } //track loop ends but still in event loop
2006 if(trackscount<1.0){
2007 if(tracksUNID) delete tracksUNID;
2008 if(tracksID) delete tracksID;
2012 if (fTrigPtmin1) fhistJetTrigestimate->Fill(cent_v0,0.0);
2013 if (fTrigPtmin2) fhistJetTrigestimate->Fill(cent_v0,2.0);
2014 if (fTrigPtJet) fhistJetTrigestimate->Fill(cent_v0,4.0);
2016 Float_t weightval=1.0;
2019 // cout<<fminPtAsso<<"***"<<fmaxPtAsso<<"*********************"<<fminPtTrig<<"***"<<fmaxPtTrig<<"*****************"<<kTrackVariablesPair<<endl;
2020 if(fSampleType=="pp") cent_v0=trackscount;//multiplicity
2022 //fill the centrality/multiplicity distribution of the selected events
2023 fhistcentrality->Fill(cent_v0);//*********************************WARNING::binning of cent_v0 is different for pp and pPb/PbPb case
2025 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??????
2027 //count selected events having centrality betn 0-100%
2028 fEventCounter->Fill(5);
2030 //***************************************event no. counting
2031 Bool_t isbaryontrig=kFALSE;
2032 Bool_t ismesontrig=kFALSE;
2033 if(tracksUNID && tracksUNID->GetEntriesFast()>0) fEventno->Fill(cent_v0,zvtx);
2035 if(tracksID && tracksID->GetEntriesFast()>0)
2037 for(Int_t i=0;i<tracksID->GetEntriesFast();i++)
2038 { //trigger loop starts
2039 LRCParticlePID *trig=(LRCParticlePID*)(tracksID->UncheckedAt(i));
2041 if(trig->Pt()<fminPtTrig || trig->Pt()>fmaxPtTrig) continue;
2042 Int_t particlepidtrig=trig->getparticle(); //either 1 or 2
2043 if(particlepidtrig==SpProton) isbaryontrig=kTRUE;
2044 if(particlepidtrig==SpPion) ismesontrig=kTRUE;
2046 if (isbaryontrig) fEventnobaryon->Fill(cent_v0,zvtx);
2047 if (ismesontrig) fEventnomeson->Fill(cent_v0,zvtx);
2051 //same event delta-eta-deltaphi plot
2053 if(tracksUNID && tracksUNID->GetEntriesFast()>0)//hadron triggered correlation
2054 {//same event calculation starts
2055 if(ffilltrigassoUNID) Fillcorrelation(tracksUNID,0,cent_v0,zvtx,weightval,kFALSE,bSign,fPtOrderDataReco,kTRUE,kFALSE,"trigassoUNID");//mixcase=kFALSE (hadron-hadron correlation)
2056 if(tracksID && tracksID->GetEntriesFast()>0 && ffilltrigUNIDassoID) Fillcorrelation(tracksUNID,tracksID,cent_v0,zvtx,weightval,kFALSE,bSign,fPtOrderDataReco,kTRUE,kFALSE,"trigUNIDassoID");//mixcase=kFALSE (hadron-ID correlation)
2059 if(tracksID && tracksID->GetEntriesFast()>0)//ID triggered correlation
2060 {//same event calculation starts
2061 if(tracksUNID && tracksUNID->GetEntriesFast()>0 && ffilltrigIDassoUNID) Fillcorrelation(tracksID,tracksUNID,cent_v0,zvtx,weightval,kFALSE,bSign,fPtOrderDataReco,kTRUE,kFALSE,"trigIDassoUNID");//mixcase=kFALSE (ID-hadron correlation)
2062 if(ffilltrigIDassoID) Fillcorrelation(tracksID,0,cent_v0,zvtx,weightval,kFALSE,bSign,fPtOrderDataReco,kTRUE,kFALSE,"trigIDassoID");//mixcase=kFALSE (ID-ID correlation)
2065 //still in main event loop
2069 if(ffilltrigassoUNID || ffilltrigIDassoUNID){//mixing with unidentified particles
2070 AliEventPool* pool = fPoolMgr->GetEventPool(cent_v0, zvtx);//In the pool there is tracksUNID(i.e associateds are unidentified)
2071 if (pool && pool->IsReady())
2072 {//start mixing only when pool->IsReady
2073 Float_t nmix1=(Float_t)pool->GetCurrentNEvents();
2074 for (Int_t jMix=0; jMix<pool->GetCurrentNEvents(); jMix++)
2075 { //pool event loop start
2076 TObjArray* bgTracks = pool->GetEvent(jMix);
2077 if(!bgTracks) continue;
2078 if(ffilltrigassoUNID && tracksUNID && tracksUNID->GetEntriesFast()>0)//*******************************hadron trggered mixing
2079 Fillcorrelation(tracksUNID,bgTracks,cent_v0,zvtx,nmix1,(jMix == 0),bSign,fPtOrderDataReco,kTRUE,kTRUE,"trigassoUNID");//mixcase=kTRUE
2080 if(ffilltrigIDassoUNID && tracksID && tracksID->GetEntriesFast()>0)//***********************************ID trggered mixing
2081 Fillcorrelation(tracksID,bgTracks,cent_v0,zvtx,nmix1,(jMix == 0),bSign,fPtOrderDataReco,kTRUE,kTRUE,"trigIDassoUNID");//mixcase=kTRUE
2082 }// pool event loop ends mixing case
2083 } //if pool->IsReady() condition ends mixing case
2086 pool->UpdatePool(CloneAndReduceTrackList(tracksUNID));
2088 }//mixing with unidentified particles
2091 if(ffilltrigUNIDassoID || ffilltrigIDassoID){//mixing with identified particles
2092 AliEventPool* pool1 = fPoolMgr->GetEventPool(cent_v0, zvtx+100);//In the pool1 there is tracksID(i.e associateds are identified)
2093 if (pool1 && pool1->IsReady())
2094 {//start mixing only when pool->IsReady
2095 Float_t nmix2=(Float_t)pool1->GetCurrentNEvents();
2096 for (Int_t jMix=0; jMix<pool1->GetCurrentNEvents(); jMix++)
2097 { //pool event loop start
2098 TObjArray* bgTracks2 = pool1->GetEvent(jMix);
2099 if(!bgTracks2) continue;
2100 if(ffilltrigUNIDassoID && tracksUNID && tracksUNID->GetEntriesFast()>0)
2101 Fillcorrelation(tracksUNID,bgTracks2,cent_v0,zvtx,nmix2,(jMix == 0),bSign,fPtOrderDataReco,kTRUE,kTRUE,"trigUNIDassoID");//mixcase=kTRUE
2102 if(ffilltrigIDassoID && tracksID && tracksID->GetEntriesFast()>0)
2103 Fillcorrelation(tracksID,bgTracks2,cent_v0,zvtx,nmix2,(jMix == 0),bSign,fPtOrderDataReco,kTRUE,kTRUE,"trigIDassoID");//mixcase=kTRUE
2105 }// pool event loop ends mixing case
2106 } //if pool1->IsReady() condition ends mixing case
2110 pool1->UpdatePool(CloneAndReduceTrackList(tracksID));//ownership of tracksasso is with pool now, don't delete it(tracksUNID is with pool)
2112 }//mixing with identified particles
2115 //no. of events analyzed
2116 fEventCounter->Fill(6);
2118 //still in main event loop
2121 if(tracksUNID) delete tracksUNID;
2123 if(tracksID) delete tracksID;
2126 PostData(1, fOutput);
2128 } // *************************event loop ends******************************************//_______________________________________________________________________
2129 TObjArray* AliTwoParticlePIDCorr::CloneAndReduceTrackList(TObjArray* tracks)
2131 // clones a track list by using AliDPhiBasicParticle which uses much less memory (used for event mixing)
2133 TObjArray* tracksClone = new TObjArray;
2134 tracksClone->SetOwner(kTRUE);
2136 for (Int_t i=0; i<tracks->GetEntriesFast(); i++)
2138 LRCParticlePID* particle = (LRCParticlePID*) tracks->UncheckedAt(i);
2139 LRCParticlePID* copy100 = new LRCParticlePID(particle->getparticle(),particle->Charge(), particle->Pt(),particle->Eta(), particle->Phi(), particle->geteffcorrectionval());
2140 copy100->SetUniqueID(particle->GetUniqueID());
2141 tracksClone->Add(copy100);
2147 //--------------------------------------------------------------------------------
2148 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)
2151 //before calling this function check that either trackstrig & tracksasso are available
2153 // Eta() is extremely time consuming, therefore cache it for the inner loop here:
2154 TObjArray* input = (tracksasso) ? tracksasso : trackstrig;
2155 TArrayF eta(input->GetEntriesFast());
2156 for (Int_t i=0; i<input->GetEntriesFast(); i++)
2157 eta[i] = ((LRCParticlePID*) input->UncheckedAt(i))->Eta();
2160 Int_t jmax=trackstrig->GetEntriesFast();
2162 jmax=tracksasso->GetEntriesFast();
2164 // identify K, Lambda candidates and flag those particles
2165 // a TObject bit is used for this
2166 const UInt_t kResonanceDaughterFlag = 1 << 14;
2167 if (fRejectResonanceDaughters > 0)
2169 Double_t resonanceMass = -1;
2170 Double_t massDaughter1 = -1;
2171 Double_t massDaughter2 = -1;
2172 const Double_t interval = 0.02;
2173 switch (fRejectResonanceDaughters)
2175 case 1: resonanceMass = 0.9; massDaughter1 = 0.1396; massDaughter2 = 0.9383; break; // method test
2176 case 2: resonanceMass = 0.4976; massDaughter1 = 0.1396; massDaughter2 = massDaughter1; break; // k0
2177 case 3: resonanceMass = 1.115; massDaughter1 = 0.1396; massDaughter2 = 0.9383; break; // lambda
2178 default: AliFatal(Form("Invalid setting %d", fRejectResonanceDaughters));
2181 for (Int_t i=0; i<trackstrig->GetEntriesFast(); i++)
2182 trackstrig->UncheckedAt(i)->ResetBit(kResonanceDaughterFlag);
2183 for (Int_t i=0; tracksasso->GetEntriesFast(); i++)
2184 tracksasso->UncheckedAt(i)->ResetBit(kResonanceDaughterFlag);
2186 for (Int_t i=0; i<trackstrig->GetEntriesFast(); i++)
2188 LRCParticlePID *trig=(LRCParticlePID*)(trackstrig->UncheckedAt(i));
2189 for (Int_t j=0; tracksasso->GetEntriesFast(); j++)
2191 LRCParticlePID *asso=(LRCParticlePID*)(tracksasso->UncheckedAt(j));
2193 // check if both particles point to the same element (does not occur for mixed events, but if subsets are mixed within the same event)
2194 if (trig->IsEqual(asso)) continue;
2196 if (trig->Charge() * asso->Charge() > 0) continue;
2198 Float_t mass = GetInvMassSquaredCheap(trig->Pt(), trig->Eta(), trig->Phi(), asso->Pt(), asso->Eta(), asso->Phi(), massDaughter1, massDaughter2);
2200 if (TMath::Abs(mass - resonanceMass*resonanceMass) < interval*5)
2202 mass = GetInvMassSquared(trig->Pt(), trig->Eta(), trig->Phi(), asso->Pt(), asso->Eta(), asso->Phi(), massDaughter1, massDaughter2);
2204 if (mass > (resonanceMass-interval)*(resonanceMass-interval) && mass < (resonanceMass+interval)*(resonanceMass+interval))
2206 trig->SetBit(kResonanceDaughterFlag);
2207 asso->SetBit(kResonanceDaughterFlag);
2209 // Printf("Flagged %d %d %f", i, j, TMath::Sqrt(mass));
2216 //Select the highest Pt trigger particle in an event (within a given Pt trigger range)
2218 Float_t TriggerPtMin=fminPtTrig;
2219 Float_t TriggerPtMax=fmaxPtTrig;
2220 Int_t HighestPtTriggerIndx=-99999;
2221 TH1* triggerWeighting = 0;
2223 if(fSelectHighestPtTrig || fWeightPerEvent)//**************add this data member to the constructor
2225 if (fWeightPerEvent)
2228 if(ffilltrigassoUNID || ffilltrigUNIDassoID || ffilltrigIDassoUNID || ffilltrigIDassoID) axis = fTHnTrigcount->GetGrid(0)->GetGrid()->GetAxis(2);
2229 if((fAnalysisType =="MCAOD") && ffilltrigIDassoIDMCTRUTH) axis = fTHnTrigcountMCTruthPrim->GetGrid(0)->GetGrid()->GetAxis(2);
2230 triggerWeighting = new TH1F("triggerWeighting", "", axis->GetNbins(), axis->GetXbins()->GetArray());
2232 for(Int_t i=0;i<trackstrig->GetEntriesFast();i++)
2233 { //trigger loop starts(highest Pt trigger selection)
2234 LRCParticlePID *trig=(LRCParticlePID*)(trackstrig->UncheckedAt(i));
2236 Float_t trigpt=trig->Pt();
2237 //to avoid overflow qnd underflow
2238 if(trigpt<fminPtTrig || trigpt>fmaxPtTrig) continue;
2239 Int_t particlepidtrig=trig->getparticle();
2240 if(fTriggerSpeciesSelection){ if (particlepidtrig!=fTriggerSpecies) continue;}
2242 Float_t trigeta=trig->Eta();
2244 // some optimization
2245 if (fTriggerRestrictEta > 0 && TMath::Abs(trigeta) > fTriggerRestrictEta)
2248 if (fOnlyOneEtaSide != 0)
2250 if (fOnlyOneEtaSide * trigeta < 0)
2253 if (fTriggerSelectCharge != 0)
2254 if (trig->Charge() * fTriggerSelectCharge < 0)
2257 if (fRejectResonanceDaughters > 0)
2258 if (trig->TestBit(kResonanceDaughterFlag)) continue;
2260 if(fSelectHighestPtTrig){
2261 if(trigpt>TriggerPtMin && trigpt<=TriggerPtMax)
2263 HighestPtTriggerIndx=(Int_t)trig->GetUniqueID();
2264 TriggerPtMin=trigpt;
2268 if (fWeightPerEvent) triggerWeighting->Fill(trigpt);
2270 }//trigger loop ends(highest Pt trigger selection)
2272 }//******************(fSelectHighestPtTrig || fWeightPerEvent) condition ends
2275 //two particle correlation filling
2276 for(Int_t i=0;i<trackstrig->GetEntriesFast();i++)
2277 { //trigger loop starts
2278 LRCParticlePID *trig=(LRCParticlePID*)(trackstrig->UncheckedAt(i));
2280 Float_t trigpt=trig->Pt();
2281 //to avoid overflow qnd underflow
2282 if(trigpt<fminPtTrig || trigpt>fmaxPtTrig) continue;
2283 Int_t particlepidtrig=trig->getparticle();
2284 if(fTriggerSpeciesSelection){ if (particlepidtrig!=fTriggerSpecies) continue;}
2286 Float_t trigeta=trig->Eta();
2288 // some optimization
2289 if (fTriggerRestrictEta > 0 && TMath::Abs(trigeta) > fTriggerRestrictEta)
2292 if (fOnlyOneEtaSide != 0)
2294 if (fOnlyOneEtaSide * trigeta < 0)
2297 if (fTriggerSelectCharge != 0)
2298 if (trig->Charge() * fTriggerSelectCharge < 0)
2301 if (fRejectResonanceDaughters > 0)
2302 if (trig->TestBit(kResonanceDaughterFlag)) continue;
2304 if(fSelectHighestPtTrig && HighestPtTriggerIndx!=-99999) {
2305 if(trig->GetUniqueID()!=(UInt_t)HighestPtTriggerIndx) continue;
2308 Float_t trigphi=trig->Phi();
2309 Float_t trackefftrig=1.0;
2310 if(fapplyTrigefficiency) trackefftrig=trig->geteffcorrectionval();
2311 //cout<<"*******************trackefftrig="<<trackefftrig<<endl;
2314 if(fcontainPIDtrig) dim=4;
2315 trigval= new Double_t[dim];
2318 trigval[2] = trigpt;
2319 if(fcontainPIDtrig) trigval[3] = particlepidtrig;
2321 if (fWeightPerEvent)
2323 // leads effectively to a filling of one entry per filled trigger particle pT bin
2324 Int_t weightBin = triggerWeighting->GetXaxis()->FindBin(trigval[2]);
2325 // Printf("Using weight %f", triggerWeighting->GetBinContent(weightBin));
2326 trackefftrig *= triggerWeighting->GetBinContent(weightBin);
2330 //trigger particle counting for both same and mixed event case;;;;;step=0->same event case;;;;;step=1->mixed event case;;;;;;
2331 if(ffilltrigassoUNID==kTRUE && ffilltrigUNIDassoID==kTRUE){
2332 if(fillup=="trigassoUNID" ) {
2333 if(mixcase==kFALSE) fTHnTrigcount->Fill(trigval,0,1.0/trackefftrig);
2334 if(mixcase==kTRUE && firstTime) fTHnTrigcount->Fill(trigval,1,1.0/trackefftrig);
2337 if(ffilltrigassoUNID==kTRUE && ffilltrigUNIDassoID==kFALSE){
2338 if(fillup=="trigassoUNID" )
2340 if(mixcase==kFALSE) fTHnTrigcount->Fill(trigval,0,1.0/trackefftrig);
2341 if(mixcase==kTRUE && firstTime) fTHnTrigcount->Fill(trigval,1,1.0/trackefftrig);
2344 if(ffilltrigassoUNID==kFALSE && ffilltrigUNIDassoID==kTRUE){
2345 if(fillup=="trigUNIDassoID")
2347 if(mixcase==kFALSE) fTHnTrigcount->Fill(trigval,0,1.0/trackefftrig);
2348 if(mixcase==kTRUE && firstTime) fTHnTrigcount->Fill(trigval,1,1.0/trackefftrig);
2351 //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
2352 if(ffilltrigIDassoUNID==kTRUE && ffilltrigIDassoID==kTRUE){
2353 if(fillup=="trigIDassoID")
2355 if(mixcase==kFALSE) fTHnTrigcount->Fill(trigval,0,1.0/trackefftrig);
2356 if(mixcase==kTRUE && firstTime) fTHnTrigcount->Fill(trigval,1,1.0/trackefftrig);
2359 if(ffilltrigIDassoUNID==kTRUE && ffilltrigIDassoID==kFALSE){
2360 if(fillup=="trigIDassoUNID" )
2362 if(mixcase==kFALSE) fTHnTrigcount->Fill(trigval,0,1.0/trackefftrig);
2363 if(mixcase==kTRUE && firstTime) fTHnTrigcount->Fill(trigval,1,1.0/trackefftrig);
2366 if(ffilltrigIDassoUNID==kFALSE && ffilltrigIDassoID==kTRUE){
2367 if(fillup=="trigIDassoID")
2369 if(mixcase==kFALSE) fTHnTrigcount->Fill(trigval,0,1.0/trackefftrig);
2370 if(mixcase==kTRUE && firstTime) fTHnTrigcount->Fill(trigval,1,1.0/trackefftrig);
2374 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!!!!
2375 if(mixcase==kFALSE) fTHnTrigcountMCTruthPrim->Fill(trigval,0,1.0/trackefftrig);
2376 if(mixcase==kTRUE && firstTime) fTHnTrigcountMCTruthPrim->Fill(trigval,1,1.0/trackefftrig);
2379 //asso loop starts within trigger loop
2380 for(Int_t j=0;j<jmax;j++)
2382 LRCParticlePID *asso=0;
2384 asso=(LRCParticlePID*)(trackstrig->UncheckedAt(j));
2386 asso=(LRCParticlePID*)(tracksasso->UncheckedAt(j));
2390 //to avoid overflow qnd underflow
2391 if(asso->Pt()<fminPtAsso || asso->Pt()>fmaxPtAsso) continue;//***********************Important
2393 //if(fmaxPtAsso==fminPtTrig) {if(asso->Pt()==fminPtTrig) continue;}//******************Think about it!
2395 if(!tracksasso && j==i) continue;
2397 // 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)
2398 // if (tracksasso && trig->IsEqual(asso)) continue;
2400 if (tracksasso && (trig->GetUniqueID()==asso->GetUniqueID())) continue;
2403 if (asso->Pt() >= trig->Pt()) continue;
2405 Int_t particlepidasso=asso->getparticle();
2406 if(fAssociatedSpeciesSelection){ if (particlepidasso!=fAssociatedSpecies) continue;}
2409 if (fAssociatedSelectCharge != 0)
2410 if (asso->Charge() * fAssociatedSelectCharge < 0) continue;
2412 if (fSelectCharge > 0)
2415 if (fSelectCharge == 1 && asso->Charge() * trig->Charge() > 0)
2419 if (fSelectCharge == 2 && asso->Charge() * trig->Charge() < 0)
2425 if (trigeta < 0 && asso->Eta() < trigeta)
2427 if (trigeta > 0 && asso->Eta() > trigeta)
2431 if (fRejectResonanceDaughters > 0)
2432 if (asso->TestBit(kResonanceDaughterFlag))
2434 // Printf("Skipped j=%d", j);
2439 if (fCutConversions && asso->Charge() * trig->Charge() < 0)
2441 Float_t mass = GetInvMassSquaredCheap(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j], asso->Phi(), 0.510e-3, 0.510e-3);
2445 mass = GetInvMassSquared(trig->Pt(), trigeta, trig->Phi(), asso->Pt(), eta[j], asso->Phi(), 0.510e-3, 0.510e-3);
2447 //fControlConvResoncances->Fill(0.0, mass);
2449 if (mass < 0.04*0.04)
2455 if (fCutResonances && asso->Charge() * trig->Charge() < 0)
2457 Float_t mass = GetInvMassSquaredCheap(trig->Pt(), trigeta, trig->Phi(), asso->Pt(), eta[j], asso->Phi(), 0.1396, 0.1396);
2459 const Float_t kK0smass = 0.4976;
2461 if (TMath::Abs(mass - kK0smass*kK0smass) < 0.1)
2463 mass = GetInvMassSquared(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j], asso->Phi(), 0.1396, 0.1396);
2465 //fControlConvResoncances->Fill(1, mass - kK0smass*kK0smass);
2467 if (mass > (kK0smass-0.02)*(kK0smass-0.02) && mass < (kK0smass+0.02)*(kK0smass+0.02))
2473 if (fCutResonances && asso->Charge() * trig->Charge() < 0)
2475 Float_t mass1 = GetInvMassSquaredCheap(trig->Pt(), trigeta, trig->Phi(), asso->Pt(), eta[j], asso->Phi(), 0.1396, 0.9383);
2476 Float_t mass2 = GetInvMassSquaredCheap(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j] , asso->Phi(), 0.9383, 0.1396);
2478 const Float_t kLambdaMass = 1.115;
2480 if (TMath::Abs(mass1 - kLambdaMass*kLambdaMass) < 0.1)
2482 mass1 = GetInvMassSquared(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j], asso->Phi(), 0.1396, 0.9383);
2484 //fControlConvResoncances->Fill(2, mass1 - kLambdaMass*kLambdaMass);
2486 if (mass1 > (kLambdaMass-0.02)*(kLambdaMass-0.02) && mass1 < (kLambdaMass+0.02)*(kLambdaMass+0.02))
2489 if (TMath::Abs(mass2 - kLambdaMass*kLambdaMass) < 0.1)
2491 mass2 = GetInvMassSquared(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j] , asso->Phi(), 0.9383, 0.1396);
2493 //fControlConvResoncances->Fill(2, mass2 - kLambdaMass*kLambdaMass);
2495 if (mass2 > (kLambdaMass-0.02)*(kLambdaMass-0.02) && mass2 < (kLambdaMass+0.02)*(kLambdaMass+0.02))
2500 if (twoTrackEfficiencyCut)
2502 // the variables & cuthave been developed by the HBT group
2503 // see e.g. https://indico.cern.ch/materialDisplay.py?contribId=36&sessionId=6&materialId=slides&confId=142700
2504 Float_t phi1 = trig->Phi();
2505 Float_t pt1 = trig->Pt();
2506 Float_t charge1 = trig->Charge();
2507 Float_t phi2 = asso->Phi();
2508 Float_t pt2 = asso->Pt();
2509 Float_t charge2 = asso->Charge();
2511 Float_t deta= trigeta - eta[j];
2514 if (TMath::Abs(deta) < twoTrackEfficiencyCutValue * 2.5 * 3)
2517 // check first boundaries to see if is worth to loop and find the minimum
2518 Float_t dphistar1 = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, 0.8, bSign);
2519 Float_t dphistar2 = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, 2.5, bSign);
2521 const Float_t kLimit = twoTrackEfficiencyCutValue * 3;
2523 Float_t dphistarminabs = 1e5;
2524 Float_t dphistarmin = 1e5;
2526 if (TMath::Abs(dphistar1) < kLimit || TMath::Abs(dphistar2) < kLimit || dphistar1 * dphistar2 < 0)
2528 for (Double_t rad=0.8; rad<2.51; rad+=0.01)
2530 Float_t dphistar = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, rad, bSign);
2532 Float_t dphistarabs = TMath::Abs(dphistar);
2534 if (dphistarabs < dphistarminabs)
2536 dphistarmin = dphistar;
2537 dphistarminabs = dphistarabs;
2541 if (dphistarminabs < twoTrackEfficiencyCutValue && TMath::Abs(deta) < twoTrackEfficiencyCutValue)
2543 // 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);
2546 //fTwoTrackDistancePt[1]->Fill(deta, dphistarmin, TMath::Abs(pt1 - pt2));
2552 Float_t weightperevent=weight;
2553 Float_t trackeffasso=1.0;
2554 if(fapplyAssoefficiency) trackeffasso=asso->geteffcorrectionval();
2555 //cout<<"*******************trackeffasso="<<trackeffasso<<endl;
2556 Float_t deleta=trigeta-eta[j];
2557 Float_t delphi=PhiRange(trigphi-asso->Phi());
2559 //here get the two particle efficiency correction factor
2560 Float_t effweight=trackefftrig*trackeffasso*weightperevent;
2561 // if(mixcase==kFALSE) cout<<"*******************effweight="<<effweight<<endl;
2563 vars= new Double_t[kTrackVariablesPair];
2570 if(fcontainPIDtrig && !fcontainPIDasso) vars[6]=particlepidtrig;
2571 if(!fcontainPIDtrig && fcontainPIDasso) vars[6]=particlepidasso;
2572 if(fcontainPIDtrig && fcontainPIDasso){
2573 vars[6]=particlepidtrig;
2574 vars[7]=particlepidasso;
2577 if (fWeightPerEvent)
2579 Int_t weightBin = triggerWeighting->GetXaxis()->FindBin(vars[2]);
2580 // Printf("Using weight %f", triggerWeighting->GetBinContent(weightBin));
2581 effweight *= triggerWeighting->GetBinContent(weightBin);
2585 //Fill Correlation ThnSparses
2586 if(fillup=="trigassoUNID")
2588 if(mixcase==kFALSE) fTHnCorrUNID->Fill(vars,0,1.0/effweight);
2589 if(mixcase==kTRUE) fTHnCorrUNIDmix->Fill(vars,0,1.0/effweight);
2591 if(fillup=="trigIDassoID")
2593 if(mixcase==kFALSE) fTHnCorrID->Fill(vars,0,1.0/effweight);
2594 if(mixcase==kTRUE) fTHnCorrIDmix->Fill(vars,0,1.0/effweight);
2596 if(fillup=="trigIDassoIDMCTRUTH")//******************************************for TRUTH MC particles
2597 {//in this case effweight should be 1 always
2598 if(mixcase==kFALSE) fCorrelatonTruthPrimary->Fill(vars,0,1.0/effweight);
2599 if(mixcase==kTRUE) fCorrelatonTruthPrimarymix->Fill(vars,0,1.0/effweight);
2601 if(fillup=="trigIDassoUNID" || fillup=="trigUNIDassoID")//****************************be careful
2603 if(mixcase==kFALSE) fTHnCorrIDUNID->Fill(vars,0,1.0/effweight);
2604 if(mixcase==kTRUE) fTHnCorrIDUNIDmix->Fill(vars,0,1.0/effweight);
2610 }//trigger loop ends
2612 if (triggerWeighting)
2614 delete triggerWeighting;
2615 triggerWeighting = 0;
2619 //--------------------------------------------------------------------------------
2620 Float_t AliTwoParticlePIDCorr::GetTrackbyTrackeffvalue(AliAODTrack* track,Double_t cent,Float_t evzvtx, Int_t parpid)
2622 //This function is called only when applyefficiency=kTRUE; also ensure that "track" is present before calling that function
2624 Float_t effvalue=1.;
2626 if(parpid==unidentified)
2628 effVars[0] = effcorection[5]->GetAxis(0)->FindBin(cent);
2629 effVars[1] = effcorection[5]->GetAxis(1)->FindBin(evzvtx);
2630 effVars[2] = effcorection[5]->GetAxis(2)->FindBin(track->Pt());
2631 effVars[3] = effcorection[5]->GetAxis(3)->FindBin(track->Eta());
2632 effvalue=effcorection[5]->GetBinContent(effVars);
2634 if(parpid==SpPion || parpid==SpKaon)
2636 if(fmesoneffrequired && !fkaonprotoneffrequired && track->Pt()>=fminPtComboeff && track->Pt()<=fmaxPtComboeff)
2638 effVars[0] = effcorection[3]->GetAxis(0)->FindBin(cent);
2639 effVars[1] = effcorection[3]->GetAxis(1)->FindBin(evzvtx);
2640 effVars[2] = effcorection[3]->GetAxis(2)->FindBin(track->Pt());
2641 effVars[3] = effcorection[3]->GetAxis(3)->FindBin(track->Eta());
2642 effvalue=effcorection[3]->GetBinContent(effVars);
2647 effVars[0] = effcorection[0]->GetAxis(0)->FindBin(cent);
2648 effVars[1] = effcorection[0]->GetAxis(1)->FindBin(evzvtx);
2649 effVars[2] = effcorection[0]->GetAxis(2)->FindBin(track->Pt());
2650 effVars[3] = effcorection[0]->GetAxis(3)->FindBin(track->Eta());
2651 effvalue=effcorection[0]->GetBinContent(effVars);
2656 effVars[0] = effcorection[1]->GetAxis(0)->FindBin(cent);
2657 effVars[1] = effcorection[1]->GetAxis(1)->FindBin(evzvtx);
2658 effVars[2] = effcorection[1]->GetAxis(2)->FindBin(track->Pt());
2659 effVars[3] = effcorection[1]->GetAxis(3)->FindBin(track->Eta());
2660 effvalue=effcorection[1]->GetBinContent(effVars);
2665 if(parpid==SpProton)
2667 effVars[0] = effcorection[2]->GetAxis(0)->FindBin(cent);
2668 effVars[1] = effcorection[2]->GetAxis(1)->FindBin(evzvtx);
2669 effVars[2] = effcorection[2]->GetAxis(2)->FindBin(track->Pt());
2670 effVars[3] = effcorection[2]->GetAxis(3)->FindBin(track->Eta());
2671 effvalue=effcorection[2]->GetBinContent(effVars);
2674 if(fkaonprotoneffrequired && !fmesoneffrequired && track->Pt()>=fminPtComboeff && track->Pt()<=fmaxPtComboeff)
2676 if(parpid==SpProton || parpid==SpKaon)
2678 effVars[0] = effcorection[4]->GetAxis(0)->FindBin(cent);
2679 effVars[1] = effcorection[4]->GetAxis(1)->FindBin(evzvtx);
2680 effVars[2] = effcorection[4]->GetAxis(2)->FindBin(track->Pt());
2681 effVars[3] = effcorection[4]->GetAxis(3)->FindBin(track->Eta());
2682 effvalue=effcorection[4]->GetBinContent(effVars);
2685 // Printf("%d %d %d %d %f", effVars[0], effVars[1], effVars[2], effVars[3], fEfficiencyCorrectionAssociated->GetBinContent(effVars));
2686 if(effvalue==0.) effvalue=1.;
2691 //-----------------------------------------------------------------------
2693 Int_t AliTwoParticlePIDCorr::ClassifyTrack(AliAODTrack* track,AliAODVertex* vertex,Float_t magfield)
2696 if(!track) return 0;
2697 Bool_t trackOK = track->TestFilterBit(fFilterBit);
2698 if(!trackOK) return 0;
2699 if (fTrackStatus != 0 && !CheckTrack(track)) return 0;
2700 //select only primary traks(for data & reco MC tracks)
2701 if(fonlyprimarydatareco && track->GetType()!=AliAODTrack::kPrimary) return 0;
2702 if(track->Charge()==0) return 0;
2703 fHistQA[12]->Fill(track->GetTPCNcls());
2706 dz = track->ZAtDCA();
2707 fHistQA[6]->Fill(dxy);
2708 fHistQA[7]->Fill(dz);
2709 Float_t chi2ndf = track->Chi2perNDF();
2710 fHistQA[13]->Fill(chi2ndf);
2711 Float_t nCrossedRowsTPC = track->GetTPCClusterInfo(2,1);
2712 fHistQA[14]->Fill(nCrossedRowsTPC);
2713 //Float_t ratioCrossedRowsOverFindableClustersTPC = 1.0;
2714 if (track->GetTPCNclsF()>0) {
2715 Float_t ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC/track->GetTPCNclsF();
2716 fHistQA[15]->Fill(ratioCrossedRowsOverFindableClustersTPC);
2719 Float_t pt=track->Pt();
2720 if(pt< fminPt || pt> fmaxPt) return 0;
2721 if(TMath::Abs(track->Eta())> fmaxeta) return 0;
2722 if(track->Phi()<0. || track->Phi()>2*TMath::Pi()) return 0;
2723 //if (!HasTPCPID(track)) return 0;//trigger & associated particles must have TPC PID,Is it required
2725 if (fdcacut && fDCAXYCut)
2732 AliAODTrack* clone =(AliAODTrack*) track->Clone();
2733 Bool_t success = clone->PropagateToDCA(vertex, magfield, fdcacutvalue, pos, covar);
2738 // Printf("%f", ((AliAODTrack*)part)->DCA());
2739 // Printf("%f", pos[0]);
2740 if (TMath::Abs(pos[0]) > fDCAXYCut->Eval(track->Pt()))
2744 if (fSharedClusterCut >= 0)
2746 Double_t frac = Double_t(((AliAODTrack*)track)->GetTPCnclsS()) / Double_t(((AliAODTrack*)track)->GetTPCncls());
2747 if (frac > fSharedClusterCut)
2750 fHistQA[8]->Fill(pt);
2751 fHistQA[9]->Fill(track->Eta());
2752 fHistQA[10]->Fill(track->Phi());
2755 //________________________________________________________________________________
2756 void AliTwoParticlePIDCorr::CalculateNSigmas(AliAODTrack *track, Bool_t FIllQAHistos)
2758 //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 )
2759 Float_t pt=track->Pt();
2761 //it is assumed that every track that passed the filterbit have proper TPC response(!!)
2762 Float_t nsigmaTPCkPion =fPID->NumberOfSigmasTPC(track, AliPID::kPion);
2763 Float_t nsigmaTPCkKaon =fPID->NumberOfSigmasTPC(track, AliPID::kKaon);
2764 Float_t nsigmaTPCkProton =fPID->NumberOfSigmasTPC(track, AliPID::kProton);
2766 Float_t nsigmaTOFkProton=999.,nsigmaTOFkKaon=999.,nsigmaTOFkPion=999.;
2767 Float_t nsigmaTPCTOFkProton=999.,nsigmaTPCTOFkKaon=999.,nsigmaTPCTOFkPion=999.;
2769 if(HasTOFPID(track) && pt>fPtTOFPIDmin)
2772 nsigmaTOFkPion =fPID->NumberOfSigmasTOF(track, AliPID::kPion);
2773 nsigmaTOFkKaon =fPID->NumberOfSigmasTOF(track, AliPID::kKaon);
2774 nsigmaTOFkProton =fPID->NumberOfSigmasTOF(track, AliPID::kProton);
2776 nsigmaTPCTOFkPion = TMath::Sqrt(nsigmaTPCkPion*nsigmaTPCkPion+nsigmaTOFkPion*nsigmaTOFkPion);
2777 nsigmaTPCTOFkKaon = TMath::Sqrt(nsigmaTPCkKaon*nsigmaTPCkKaon+nsigmaTOFkKaon*nsigmaTOFkKaon);
2778 nsigmaTPCTOFkProton = TMath::Sqrt(nsigmaTPCkProton*nsigmaTPCkProton+nsigmaTOFkProton*nsigmaTOFkProton);
2784 // if TOF is missing and below fPtTOFPID only the TPC information is used
2785 nsigmaTPCTOFkProton = TMath::Abs(nsigmaTPCkProton);
2786 nsigmaTPCTOFkKaon = TMath::Abs(nsigmaTPCkKaon);
2787 nsigmaTPCTOFkPion = TMath::Abs(nsigmaTPCkPion);
2791 //set data member fnsigmas
2792 fnsigmas[SpPion][NSigmaTPC]=nsigmaTPCkPion;
2793 fnsigmas[SpKaon][NSigmaTPC]=nsigmaTPCkKaon;
2794 fnsigmas[SpProton][NSigmaTPC]=nsigmaTPCkProton;
2796 //for all tracks below fPtTOFPIDmin and also for tracks above fPtTOFPIDmin without proper TOF response these TOF nsigma values will be 999.
2797 fnsigmas[SpPion][NSigmaTOF]=nsigmaTOFkPion;
2798 fnsigmas[SpKaon][NSigmaTOF]=nsigmaTOFkKaon;
2799 fnsigmas[SpProton][NSigmaTOF]=nsigmaTOFkProton;
2801 //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)
2802 fnsigmas[SpPion][NSigmaTPCTOF]=nsigmaTPCTOFkPion;
2803 fnsigmas[SpKaon][NSigmaTPCTOF]=nsigmaTPCTOFkKaon;
2804 fnsigmas[SpProton][NSigmaTPCTOF]=nsigmaTPCTOFkProton;
2807 //Fill NSigma SeparationPlot
2808 for(Int_t ipart=0;ipart<NSpecies;ipart++){
2809 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
2810 if((ipid!=NSigmaTPC) && (!HasTOFPID(track)) && track->Pt()<fPtTOFPIDmin)continue;//not filling TOF and combined if no TOF PID
2811 TH2F *h=GetHistogram2D(Form("NSigma_%d_%d",ipart,ipid));
2812 h->Fill(track->Pt(),fnsigmas[ipart][ipid]);
2818 //----------------------------------------------------------------------------
2819 Int_t AliTwoParticlePIDCorr::FindMinNSigma(AliAODTrack *track,Bool_t FillQAHistos)
2821 //this function is always called after calling the function CalculateNSigmas(AliAODTrack *track)
2822 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
2823 //get the identity of the particle with the minimum Nsigma
2824 Float_t nsigmaPion=999., nsigmaKaon=999., nsigmaProton=999.;
2827 nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTPC]);
2828 nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTPC]) ;
2829 nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTPC]) ;
2832 nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTOF]);
2833 nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTOF]) ;
2834 nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTOF]) ;
2836 case NSigmaTPCTOF://In case of no TOF matching the combined nsigma is the TPC one
2837 nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTPCTOF]);
2838 nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTPCTOF]) ;
2839 nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTPCTOF]) ;
2843 if(track->Pt()<=fPtTOFPIDmax) {
2844 // guess the particle based on the smaller nsigma (within fNSigmaPID)
2845 if( ( nsigmaKaon==nsigmaPion ) && ( nsigmaKaon==nsigmaProton )) return SpUndefined;//it is the default value for the three
2846 if( ( nsigmaKaon < nsigmaPion ) && ( nsigmaKaon < nsigmaProton ) && (nsigmaKaon < fNSigmaPID)){
2848 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
2849 if((ipid!=NSigmaTPC) && (!HasTOFPID(track)) && (track->Pt()<fPtTOFPIDmin))continue;//not filling TOF and combined if no TOF PID
2850 TH2F *h=GetHistogram2D(Form("NSigmaRec_%d_%d",SpKaon,ipid));
2851 h->Fill(track->Pt(),fnsigmas[SpKaon][ipid]);
2856 if( ( nsigmaPion < nsigmaKaon ) && ( nsigmaPion < nsigmaProton ) && (nsigmaPion < fNSigmaPID)) {
2858 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
2859 if((ipid!=NSigmaTPC) && (!HasTOFPID(track)) && (track->Pt()<fPtTOFPIDmin))continue;//not filling TOF and combined if no TOF PID
2860 TH2F *h=GetHistogram2D(Form("NSigmaRec_%d_%d",SpPion,ipid));
2861 h->Fill(track->Pt(),fnsigmas[SpPion][ipid]);
2866 if( ( nsigmaProton < nsigmaKaon ) && ( nsigmaProton < nsigmaPion ) && (nsigmaProton < fNSigmaPID)) {
2868 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
2869 if((ipid!=NSigmaTPC) && (!HasTOFPID(track)) && (track->Pt()<fPtTOFPIDmin))continue;//not filling TOF and combined if no TOF PID
2870 TH2F *h=GetHistogram2D(Form("NSigmaRec_%d_%d",SpProton,ipid));
2871 h->Fill(track->Pt(),fnsigmas[SpProton][ipid]);
2877 // else, return undefined
2880 else {//asymmetric nsigma cut around pion's mean position for tracks having Pt>4.0 Gev
2881 if(fminprotonsigmacut<fnsigmas[SpPion][NSigmaTPC] && fnsigmas[SpPion][NSigmaTPC]<fmaxprotonsigmacut) return SpProton;
2882 if(fminpionsigmacut<fnsigmas[SpPion][NSigmaTPC] && fnsigmas[SpPion][NSigmaTPC]<fmaxpionsigmacut) return SpPion;
2883 // else, return undefined(here we don't detect kaons)
2889 //------------------------------------------------------------------------------------------
2890 Bool_t* AliTwoParticlePIDCorr::GetDoubleCounting(AliAODTrack * trk,Bool_t FIllQAHistos){
2891 //this function is always called after calling the function CalculateNSigmas(AliAODTrack *track)
2893 //if a particle has double counting set fHasDoubleCounting[ipart]=kTRUE
2895 for(Int_t ipart=0;ipart<NSpecies;ipart++)fHasDoubleCounting[ipart]=kFALSE;//array with kTRUE for second (or third) identity of the track
2897 Int_t MinNSigma=FindMinNSigma(trk,kFALSE);//not filling the NSigmaRec histos
2900 if(MinNSigma==SpUndefined)return fHasDoubleCounting;//in case of undefined no Double counting
2902 Float_t nsigmaPion=999., nsigmaKaon=999., nsigmaProton=999.;
2905 nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTPC]);
2906 nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTPC]) ;
2907 nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTPC]) ;
2910 nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTOF]);
2911 nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTOF]) ;
2912 nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTOF]) ;
2914 case NSigmaTPCTOF://In case of no TOF matching the combined nsigma is the TPC one
2915 nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTPCTOF]);
2916 nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTPCTOF]) ;
2917 nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTPCTOF]) ;
2921 //there is chance of overlapping only for particles having pt below 4.0 GEv
2923 if(nsigmaPion<fNSigmaPID && MinNSigma!=SpPion)fHasDoubleCounting[SpPion]=kTRUE;
2924 if(nsigmaKaon<fNSigmaPID && MinNSigma!=SpKaon)fHasDoubleCounting[SpKaon]=kTRUE;
2925 if(nsigmaProton<fNSigmaPID && MinNSigma!=SpProton)fHasDoubleCounting[SpProton]=kTRUE;
2930 //fill NSigma distr for double counting
2931 for(Int_t ipart=0;ipart<NSpecies;ipart++){
2932 if(fHasDoubleCounting[ipart]){
2933 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
2934 if((ipid!=NSigmaTPC) && (!HasTOFPID(trk)) && (trk->Pt()<fPtTOFPIDmin))continue;//not filling TOF and combined if no TOF PID
2935 TH2F *h=GetHistogram2D(Form("NSigmaDC_%d_%d",ipart,ipid));
2936 h->Fill(trk->Pt(),fnsigmas[ipart][ipid]);
2943 return fHasDoubleCounting;
2946 //////////////////////////////////////////////////////////////////////////////////////////////////
2947 Int_t AliTwoParticlePIDCorr::GetParticle(AliAODTrack * trk, Bool_t FIllQAHistos){
2948 //return the specie according to the minimum nsigma value
2949 //no double counting, this has to be evaluated using CheckDoubleCounting()
2951 Int_t ID=SpUndefined;
2953 CalculateNSigmas(trk,FIllQAHistos);//fill the data member fnsigmas with the nsigmas value [ipart][iPID]
2955 ID=FindMinNSigma(trk,FIllQAHistos);
2957 if(fUseExclusiveNSigma){ //if one particle has double counting and exclusive nsigma is requested ID = kSpUndefined
2959 HasDC=GetDoubleCounting(trk,FIllQAHistos);
2960 for(Int_t ipart=0;ipart<NSpecies;ipart++){
2961 if(HasDC[ipart]==kTRUE) ID = SpUndefined;
2965 //Fill PID signal plot
2966 if(ID != SpUndefined){
2967 for(Int_t idet=0;idet<fNDetectors;idet++){
2968 TH2F *h=GetHistogram2D(Form("PID_%d_%d",idet,ID));
2969 if(idet==fITS)h->Fill(trk->P(),trk->GetITSsignal()*trk->Charge());
2970 if(idet==fTPC)h->Fill(trk->P(),trk->GetTPCsignal()*trk->Charge());
2971 if(idet==fTOF && HasTOFPID(trk))h->Fill(trk->P(),GetBeta(trk)*trk->Charge());
2974 //Fill PID signal plot without cuts
2975 for(Int_t idet=0;idet<fNDetectors;idet++){
2976 TH2F *h=GetHistogram2D(Form("PIDAll_%d",idet));
2977 if(idet==fITS)h->Fill(trk->P(),trk->GetITSsignal()*trk->Charge());
2978 if(idet==fTPC)h->Fill(trk->P(),trk->GetTPCsignal()*trk->Charge());
2979 if(idet==fTOF && HasTOFPID(trk))h->Fill(trk->P(),GetBeta(trk)*trk->Charge());
2985 //-------------------------------------------------------------------------------------
2987 AliTwoParticlePIDCorr::HasTPCPID(AliAODTrack *track) const
2990 AliPIDResponse::EDetPidStatus statustpc = fPID->CheckPIDStatus(AliPIDResponse::kTPC,track);
2991 if(statustpc!=AliPIDResponse::kDetPidOk) return kFALSE;
2992 //ULong_t status=track->GetStatus();
2993 //if (!( (status & AliAODTrack::kTPCpid ) == AliAODTrack::kTPCpid )) return kFALSE;//remove light nuclei
2994 //if (track->GetTPCsignal() <= 0.) return kFALSE;
2995 // 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.
2999 //___________________________________________________________
3002 AliTwoParticlePIDCorr::HasTOFPID(AliAODTrack *track) const
3004 // check TOF matched track
3005 //ULong_t status=track->GetStatus();
3006 //if (!( (status & AliAODTrack::kITSin ) == AliAODTrack::kITSin )) return kFALSE;
3007 AliPIDResponse::EDetPidStatus statustof = fPID->CheckPIDStatus(AliPIDResponse::kTOF,track);
3008 if(statustof!= AliPIDResponse::kDetPidOk) return kFALSE;
3009 if(track->Pt()<=fPtTOFPIDmin) return kFALSE;
3010 //if(!((status & AliAODTrack::kTOFpid ) == AliAODTrack::kTOFpid )) return kFALSE;
3011 //Float_t probMis = fPIDresponse->GetTOFMismatchProbability(track);
3012 // if (probMis > 0.01) return kFALSE;
3013 if(fRemoveTracksT0Fill)
3015 Int_t startTimeMask = fPID->GetTOFResponse().GetStartTimeMask(track->P());
3016 if (startTimeMask < 0)return kFALSE;
3021 //________________________________________________________________________
3022 Double_t AliTwoParticlePIDCorr :: GetBeta(AliAODTrack *track)
3024 //it is called only when TOF PID is available
3025 //TOF beta calculation
3026 Double_t tofTime=track->GetTOFsignal();
3028 Double_t c=TMath::C()*1.E-9;// m/ns
3029 Float_t startTime = fPID->GetTOFResponse().GetStartTime(((AliVTrack*)track)->P());//in ps
3030 Double_t length= fPID->GetTOFResponse().GetExpectedSignal(track,AliPID::kElectron)*1E-3*c;
3031 tofTime -= startTime; // subtract startTime to the signal
3032 Double_t tof= tofTime*1E-3; // ns, average T0 fill subtracted, no info from T0detector
3038 Double_t p = track->P();
3039 Double_t time=track->GetTOFsignal()-fPID->GetTOFResponse().GetStartTime(p);
3041 track->GetIntegratedTimes(timei);
3042 return timei[0]/time;
3045 //------------------------------------------------------------------------------------------------------
3047 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)
3049 // calculate inv mass squared
3050 // same can be achieved, but with more computing time with
3051 /*TLorentzVector photon, p1, p2;
3052 p1.SetPtEtaPhiM(triggerParticle->Pt(), triggerEta, triggerParticle->Phi(), 0.510e-3);
3053 p2.SetPtEtaPhiM(particle->Pt(), eta[j], particle->Phi(), 0.510e-3);
3057 Float_t tantheta1 = 1e10;
3059 if (eta1 < -1e-10 || eta1 > 1e-10)
3060 tantheta1 = 2 * TMath::Exp(-eta1) / ( 1 - TMath::Exp(-2*eta1));
3062 Float_t tantheta2 = 1e10;
3063 if (eta2 < -1e-10 || eta2 > 1e-10)
3064 tantheta2 = 2 * TMath::Exp(-eta2) / ( 1 - TMath::Exp(-2*eta2));
3066 Float_t e1squ = m0_1 * m0_1 + pt1 * pt1 * (1.0 + 1.0 / tantheta1 / tantheta1);
3067 Float_t e2squ = m0_2 * m0_2 + pt2 * pt2 * (1.0 + 1.0 / tantheta2 / tantheta2);
3069 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 ) ) );
3073 //---------------------------------------------------------------------------------
3075 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)
3077 // calculate inv mass squared approximately
3079 Float_t tantheta1 = 1e10;
3081 if (eta1 < -1e-10 || eta1 > 1e-10)
3083 Float_t expTmp = 1.0-eta1+eta1*eta1/2-eta1*eta1*eta1/6+eta1*eta1*eta1*eta1/24;
3084 tantheta1 = 2.0 * expTmp / ( 1.0 - expTmp*expTmp);
3087 Float_t tantheta2 = 1e10;
3088 if (eta2 < -1e-10 || eta2 > 1e-10)
3090 Float_t expTmp = 1.0-eta2+eta2*eta2/2-eta2*eta2*eta2/6+eta2*eta2*eta2*eta2/24;
3091 tantheta2 = 2.0 * expTmp / ( 1.0 - expTmp*expTmp);
3094 Float_t e1squ = m0_1 * m0_1 + pt1 * pt1 * (1.0 + 1.0 / tantheta1 / tantheta1);
3095 Float_t e2squ = m0_2 * m0_2 + pt2 * pt2 * (1.0 + 1.0 / tantheta2 / tantheta2);
3098 Float_t deltaPhi = TMath::Abs(phi1 - phi2);
3099 while (deltaPhi > TMath::TwoPi())
3100 deltaPhi -= TMath::TwoPi();
3101 if (deltaPhi > TMath::Pi())
3102 deltaPhi = TMath::TwoPi() - deltaPhi;
3104 Float_t cosDeltaPhi = 0;
3105 if (deltaPhi < TMath::Pi()/3)
3106 cosDeltaPhi = 1.0 - deltaPhi*deltaPhi/2 + deltaPhi*deltaPhi*deltaPhi*deltaPhi/24;
3107 else if (deltaPhi < 2*TMath::Pi()/3)
3108 cosDeltaPhi = -(deltaPhi - TMath::Pi()/2) + 1.0/6 * TMath::Power((deltaPhi - TMath::Pi()/2), 3);
3110 cosDeltaPhi = -1.0 + 1.0/2.0*(deltaPhi - TMath::Pi())*(deltaPhi - TMath::Pi()) - 1.0/24.0 * TMath::Power(deltaPhi - TMath::Pi(), 4);
3112 Float_t mass2 = m0_1 * m0_1 + m0_2 * m0_2 + 2 * ( TMath::Sqrt(e1squ * e2squ) - ( pt1 * pt2 * ( cosDeltaPhi + 1.0 / tantheta1 / tantheta2 ) ) );
3114 // Printf(Form("%f %f %f %f %f %f %f %f %f", pt1, eta1, phi1, pt2, eta2, phi2, m0_1, m0_2, mass2));
3118 //--------------------------------------------------------------------------------
3119 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)
3122 // calculates dphistar
3125 Float_t dphistar = phi1 - phi2 - charge1 * bSign * TMath::ASin(0.075 * radius / pt1) + charge2 * bSign * TMath::ASin(0.075 * radius / pt2);
3127 static const Double_t kPi = TMath::Pi();
3130 // if (dphistar > 2 * kPi)
3131 // dphistar -= 2 * kPi;
3132 // if (dphistar < -2 * kPi)
3133 // dphistar += 2 * kPi;
3136 dphistar = kPi * 2 - dphistar;
3137 if (dphistar < -kPi)
3138 dphistar = -kPi * 2 - dphistar;
3139 if (dphistar > kPi) // might look funny but is needed
3140 dphistar = kPi * 2 - dphistar;
3144 //_________________________________________________________________________
3145 void AliTwoParticlePIDCorr ::DefineEventPool()
3147 Int_t MaxNofEvents=1000;
3148 const Int_t NofVrtxBins=10+(1+10)*2;
3149 Double_t ZvrtxBins[NofVrtxBins+1]={ -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10,
3150 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110,
3151 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210
3153 if (fSampleType=="pp"){
3154 const Int_t NofCentBins=4;
3155 Double_t CentralityBins[NofCentBins+1]={0.,20., 40.,60.,200.1};//Is This binning is fine for pp, or we don't require them....
3156 fPoolMgr = new AliEventPoolManager(MaxNofEvents,fMaxNofMixingTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins);
3158 if (fSampleType=="pPb" || fSampleType=="PbPb")
3160 const Int_t NofCentBins=15;
3161 Double_t CentralityBins[NofCentBins+1]={0., 1., 2., 3., 4., 5., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100.1 };
3162 fPoolMgr = new AliEventPoolManager(MaxNofEvents,fMaxNofMixingTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins);
3164 fPoolMgr->SetTargetValues(fMaxNofMixingTracks, 0.1, 5);
3166 //if(!fPoolMgr) return kFALSE;
3170 //------------------------------------------------------------------------
3171 Double_t* AliTwoParticlePIDCorr::GetBinning(const char* configuration, const char* tag, Int_t& nBins)
3173 // This method is a copy from AliUEHist::GetBinning
3174 // takes the binning from <configuration> identified by <tag>
3175 // configuration syntax example:
3176 // 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
3179 // returns bin edges which have to be deleted by the caller
3181 TString config(configuration);
3182 TObjArray* lines = config.Tokenize("\n");
3183 for (Int_t i=0; i<lines->GetEntriesFast(); i++)
3185 TString line(lines->At(i)->GetName());
3186 if (line.BeginsWith(TString(tag) + ":"))
3188 line.Remove(0, strlen(tag) + 1);
3189 line.ReplaceAll(" ", "");
3190 TObjArray* binning = line.Tokenize(",");
3191 Double_t* bins = new Double_t[binning->GetEntriesFast()];
3192 for (Int_t j=0; j<binning->GetEntriesFast(); j++)
3193 bins[j] = TString(binning->At(j)->GetName()).Atof();
3195 nBins = binning->GetEntriesFast() - 1;
3204 AliFatal(Form("Tag %s not found in %s", tag, configuration));
3208 //____________________________________________________________________
3210 Bool_t AliTwoParticlePIDCorr::CheckTrack(AliAODTrack * part)
3212 // check if the track status flags are set
3214 UInt_t status=((AliAODTrack*)part)->GetStatus();
3215 if ((status & fTrackStatus) == fTrackStatus)
3219 //________________________________________________________________________
3220 void AliTwoParticlePIDCorr::Terminate(Option_t *)
3222 // Draw result to screen, or perform fitting, normalizations
3223 // Called once at the end of the query
3224 fOutput = dynamic_cast<TList*> (GetOutputData(1));
3225 if(!fOutput) { Printf("ERROR: could not retrieve TList fOutput"); return; }
3229 //------------------------------------------------------------------