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
87 fCentralityMethod("V0A"),
89 fnTracksVertex(1), // QA tracks pointing to principal vertex (= 3 default)
94 fSharedClusterCut(-1),
97 ffilltrigassoUNID(kFALSE),
98 ffilltrigUNIDassoID(kFALSE),
99 ffilltrigIDassoUNID(kTRUE),
100 ffilltrigIDassoID(kFALSE),
101 ffilltrigIDassoIDMCTRUTH(kFALSE),
102 fMaxNofMixingTracks(50000),
103 fPtOrderMCTruth(kTRUE),
104 fPtOrderDataReco(kTRUE),
105 fWeightPerEvent(kFALSE),
106 fTriggerSpeciesSelection(kFALSE),
107 fAssociatedSpeciesSelection(kFALSE),
108 fTriggerSpecies(SpPion),
109 fAssociatedSpecies(SpPion),
112 fSelectHighestPtTrig(kFALSE),
113 fcontainPIDtrig(kTRUE),
114 fcontainPIDasso(kFALSE),
115 frejectPileUp(kFALSE),
120 fminprotonsigmacut(-6.0),
121 fmaxprotonsigmacut(-3.0),
122 fminpionsigmacut(0.0),
123 fmaxpionsigmacut(4.0),
124 fselectprimaryTruth(kTRUE),
125 fonlyprimarydatareco(kFALSE),
128 ffillhistQAReco(kFALSE),
129 ffillhistQATruth(kFALSE),
130 kTrackVariablesPair(0),
159 fhistJetTrigestimate(0),
160 fCentralityCorrelation(0x0),
161 fControlConvResoncances(0),
176 fCorrelatonTruthPrimary(0),
177 fCorrelatonTruthPrimarymix(0),
183 fTHnCorrIDUNIDmix(0),
185 fTHnTrigcountMCTruthPrim(0),
188 fAnalysisType("AOD"),
190 ftwoTrackEfficiencyCutDataReco(kTRUE),
191 twoTrackEfficiencyCutValue(0.02),
196 fRequestTOFPID(kTRUE),
197 fPIDType(NSigmaTPCTOF),
198 fFIllPIDQAHistos(kTRUE),
200 fHighPtKaonNSigmaPID(-1),
201 fHighPtKaonSigma(3.5),
202 fUseExclusiveNSigma(kFALSE),
203 fRemoveTracksT0Fill(kFALSE),
205 fTriggerSelectCharge(0),
206 fAssociatedSelectCharge(0),
207 fTriggerRestrictEta(-1),
208 fEtaOrdering(kFALSE),
209 fCutConversions(kFALSE),
210 fCutResonances(kFALSE),
211 fRejectResonanceDaughters(-1),
213 fInjectedSignals(kFALSE),
214 fRemoveWeakDecays(kFALSE),
215 fRemoveDuplicates(kFALSE),
216 fapplyTrigefficiency(kFALSE),
217 fapplyAssoefficiency(kFALSE),
218 ffillefficiency(kFALSE),
219 fmesoneffrequired(kFALSE),
220 fkaonprotoneffrequired(kFALSE),
225 for ( Int_t i = 0; i < 16; i++) {
229 for ( Int_t i = 0; i < 6; i++ ){
230 fTrackHistEfficiency[i] = NULL;
231 effcorection[i]=NULL;
236 for(Int_t ipart=0;ipart<NSpecies;ipart++)
237 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++)
238 fnsigmas[ipart][ipid]=999.;
240 for(Int_t ipart=0;ipart<NSpecies;ipart++) {fHasDoubleCounting[ipart]=kFALSE;}
243 //________________________________________________________________________
244 AliTwoParticlePIDCorr::AliTwoParticlePIDCorr(const char *name) // All data members should be initialised here
245 :AliAnalysisTaskSE(name),
248 fCentralityMethod("V0A"),
250 fnTracksVertex(1), // QA tracks pointing to principal vertex (= 3 default)
255 fSharedClusterCut(-1),
258 ffilltrigassoUNID(kFALSE),
259 ffilltrigUNIDassoID(kFALSE),
260 ffilltrigIDassoUNID(kTRUE),
261 ffilltrigIDassoID(kFALSE),
262 ffilltrigIDassoIDMCTRUTH(kFALSE),
263 fMaxNofMixingTracks(50000),
264 fPtOrderMCTruth(kTRUE),
265 fPtOrderDataReco(kTRUE),
266 fWeightPerEvent(kFALSE),
267 fTriggerSpeciesSelection(kFALSE),
268 fAssociatedSpeciesSelection(kFALSE),
269 fTriggerSpecies(SpPion),
270 fAssociatedSpecies(SpPion),
273 fSelectHighestPtTrig(kFALSE),
274 fcontainPIDtrig(kTRUE),
275 fcontainPIDasso(kFALSE),
276 frejectPileUp(kFALSE),
281 fminprotonsigmacut(-6.0),
282 fmaxprotonsigmacut(-3.0),
283 fminpionsigmacut(0.0),
284 fmaxpionsigmacut(4.0),
285 fselectprimaryTruth(kTRUE),
286 fonlyprimarydatareco(kFALSE),
289 ffillhistQAReco(kFALSE),
290 ffillhistQATruth(kFALSE),
291 kTrackVariablesPair(0),
320 fhistJetTrigestimate(0),
321 fCentralityCorrelation(0x0),
322 fControlConvResoncances(0),
337 fCorrelatonTruthPrimary(0),
338 fCorrelatonTruthPrimarymix(0),
344 fTHnCorrIDUNIDmix(0),
346 fTHnTrigcountMCTruthPrim(0),
349 fAnalysisType("AOD"),
351 ftwoTrackEfficiencyCutDataReco(kTRUE),
352 twoTrackEfficiencyCutValue(0.02),
357 fRequestTOFPID(kTRUE),
358 fPIDType(NSigmaTPCTOF),
359 fFIllPIDQAHistos(kTRUE),
361 fHighPtKaonNSigmaPID(-1),
362 fHighPtKaonSigma(3.5),
363 fUseExclusiveNSigma(kFALSE),
364 fRemoveTracksT0Fill(kFALSE),
366 fTriggerSelectCharge(0),
367 fAssociatedSelectCharge(0),
368 fTriggerRestrictEta(-1),
369 fEtaOrdering(kFALSE),
370 fCutConversions(kFALSE),
371 fCutResonances(kFALSE),
372 fRejectResonanceDaughters(-1),
374 fInjectedSignals(kFALSE),
375 fRemoveWeakDecays(kFALSE),
376 fRemoveDuplicates(kFALSE),
377 fapplyTrigefficiency(kFALSE),
378 fapplyAssoefficiency(kFALSE),
379 ffillefficiency(kFALSE),
380 fmesoneffrequired(kFALSE),
381 fkaonprotoneffrequired(kFALSE),
386 for ( Int_t i = 0; i < 16; i++) {
390 for ( Int_t i = 0; i < 6; i++ ){
391 fTrackHistEfficiency[i] = NULL;
392 effcorection[i]=NULL;
396 for(Int_t ipart=0;ipart<NSpecies;ipart++)
397 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++)
398 fnsigmas[ipart][ipid]=999.;
400 for(Int_t ipart=0;ipart<NSpecies;ipart++) {fHasDoubleCounting[ipart]=kFALSE;}
402 // The last in the above list should not have a comma after it
405 // Define input and output slots here (never in the dummy constructor)
406 // Input slot #0 works with a TChain - it is connected to the default input container
407 // Output slot #1 writes into a TH1 container
409 DefineOutput(1, TList::Class()); // for output list
410 DefineOutput(2, TList::Class());
414 //________________________________________________________________________
415 AliTwoParticlePIDCorr::~AliTwoParticlePIDCorr()
417 // Destructor. Clean-up the output list, but not the histograms that are put inside
418 // (the list is owner and will clean-up these histograms). Protect in PROOF case.
419 if (fOutput && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
424 if (fOutputList && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
429 if (fPID) delete fPID;
432 //________________________________________________________________________
434 //////////////////////////////////////////////////////////////////////////////////////////////////
436 TH2F* AliTwoParticlePIDCorr::GetHistogram2D(const char * name){
437 // returns histo named name
438 return (TH2F*) fOutputList->FindObject(name);
441 //////////////////////////////////////////////////////////////////////////////////////////////////
443 Float_t AliTwoParticlePIDCorr::PhiRange(Float_t DPhi)
447 // Puts the argument in the range [-pi/2,3 pi/2].
450 if (DPhi < -TMath::Pi()/2) DPhi += 2*TMath::Pi();
451 if (DPhi > 3*TMath::Pi()/2) DPhi -= 2*TMath::Pi();
456 //________________________________________________________________________
457 void AliTwoParticlePIDCorr::UserCreateOutputObjects()
460 // Called once (on the worker node)
461 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
462 AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
463 fPID = inputHandler->GetPIDResponse();
465 //AliAnalysisUtils *fUtils = new AliAnalysisUtils();
467 //get the efficiency correction map
469 // global switch disabling the reference
470 // (to avoid "Replacing existing TH1" if several wagons are created in train)
471 Bool_t oldStatus = TH1::AddDirectoryStatus();
472 TH1::AddDirectory(kFALSE);
474 fOutput = new TList();
475 fOutput->SetOwner(); // IMPORTANT!
477 fOutputList = new TList;
478 fOutputList->SetOwner();
479 fOutputList->SetName("PIDQAList");
482 Int_t centmultbins=10;
483 Double_t centmultmin=0.0;
484 Double_t centmultmax=100.0;
485 if(fSampleType=="pPb" || fSampleType=="PbPb")
491 if(fSampleType=="pp")
498 fhistcentrality=new TH1F("fhistcentrality","fhistcentrality",centmultbins*4,centmultmin,centmultmax);
499 fOutput->Add(fhistcentrality);
501 fEventCounter = new TH1F("fEventCounter","EventCounter", 12, 0.5,12.5);
502 fEventCounter->GetXaxis()->SetBinLabel(1,"Event Accesed");
503 fEventCounter->GetXaxis()->SetBinLabel(3,"After PileUP Cut");
504 fEventCounter->GetXaxis()->SetBinLabel(5,"Have A Vertex");
505 fEventCounter->GetXaxis()->SetBinLabel(7,"After vertex Cut");
506 fEventCounter->GetXaxis()->SetBinLabel(9,"Within 0-100% centrality");
507 fEventCounter->GetXaxis()->SetBinLabel(11,"Event Analyzed");
508 //fEventCounter->GetXaxis()->SetBinLabel(8,"Event Analysis finished");
509 fOutput->Add(fEventCounter);
511 fEtaSpectrasso=new TH2F("fEtaSpectraasso","fEtaSpectraasso",180,-0.9,0.9,100,0.,20. );
512 fOutput->Add(fEtaSpectrasso);
514 fphiSpectraasso=new TH2F("fphiSpectraasso","fphiSpectraasso",72,0,2*TMath::Pi(),100,0.,20.);
515 fOutput->Add(fphiSpectraasso);
517 if(fSampleType=="pPb" || fSampleType=="PbPb"){ fCentralityCorrelation = new TH2D("fCentralityCorrelation", ";centrality;multiplicity", 101, 0, 101, 20000, 0,40000);
518 fOutput->Add(fCentralityCorrelation);
521 if(fCutConversions || fCutResonances)
523 fControlConvResoncances = new TH2F("fControlConvResoncances", ";id;delta mass", 3, -0.5, 2.5, 100, -0.1, 0.1);
524 fOutput->Add(fControlConvResoncances);
527 fHistoTPCdEdx = new TH2F("hHistoTPCdEdx", ";p_{T} (GeV/c);dE/dx (au.)",200,0.0,10.0,500, 0., 500.);
528 fOutputList->Add(fHistoTPCdEdx);
529 fHistoTOFbeta = new TH2F(Form("hHistoTOFbeta"), ";p_{T} (GeV/c);v/c",100, 0., fmaxPt, 500, 0.1, 1.1);
530 fOutputList->Add(fHistoTOFbeta);
532 fTPCTOFPion3d=new TH3F ("fTPCTOFpion3d", "fTPCTOFpion3d",100,0., 10., 120,-60.,60.,120,-60.,60);
533 fOutputList->Add(fTPCTOFPion3d);
535 fTPCTOFKaon3d=new TH3F ("fTPCTOFKaon3d", "fTPCTOFKaon3d",100,0., 10., 120,-60.,60.,120,-60.,60);
536 fOutputList->Add(fTPCTOFKaon3d);
538 fTPCTOFProton3d=new TH3F ("fTPCTOFProton3d", "fTPCTOFProton3d",100,0., 10., 120,-60.,60.,120,-60.,60);
539 fOutputList->Add(fTPCTOFProton3d);
543 fPionPt = new TH1F("fHistQAPionPt","p_{T} distribution",200,0.,10.);
544 fOutputList->Add(fPionPt);
545 fPionEta= new TH1F("fHistQAPionEta","#eta distribution",360,-1.8,1.8);
546 fOutputList->Add(fPionEta);
547 fPionPhi = new TH1F("fHistQAPionPhi","#phi distribution",340,0,6.8);
548 fOutputList->Add(fPionPhi);
550 fKaonPt = new TH1F("fHistQAKaonPt","p_{T} distribution",200,0.,10.);
551 fOutputList->Add(fKaonPt);
552 fKaonEta= new TH1F("fHistQAKaonEta","#eta distribution",360,-1.8,1.8);
553 fOutputList->Add(fKaonEta);
554 fKaonPhi = new TH1F("fHistQAKaonPhi","#phi distribution",340,0,6.8);
555 fOutputList->Add(fKaonPhi);
557 fProtonPt = new TH1F("fHistQAProtonPt","p_{T} distribution",200,0.,10.);
558 fOutputList->Add(fProtonPt);
559 fProtonEta= new TH1F("fHistQAProtonEta","#eta distribution",360,-1.8,1.8);
560 fOutputList->Add(fProtonEta);
561 fProtonPhi= new TH1F("fHistQAProtonPhi","#phi distribution",340,0,6.8);
562 fOutputList->Add(fProtonPhi);
565 fHistQA[0] = new TH1F("fHistQAvx", "Histo Vx All ", 50, -5., 5.);
566 fHistQA[1] = new TH1F("fHistQAvy", "Histo Vy All", 50, -5., 5.);
567 fHistQA[2] = new TH1F("fHistQAvz", "Histo Vz All", 50, -25., 25.);
568 fHistQA[3] = new TH1F("fHistQAvxA", "Histo Vx After Cut ", 50, -5., 5.);
569 fHistQA[4] = new TH1F("fHistQAvyA", "Histo Vy After Cut", 50, -5., 5.);
570 fHistQA[5] = new TH1F("fHistQAvzA", "Histo Vz After Cut", 50, -25., 25.);
571 fHistQA[6] = new TH1F("fHistQADcaXyC", "Histo DCAxy after cut", 50, -5., 5.);
572 fHistQA[7] = new TH1F("fHistQADcaZC", "Histo DCAz after cut", 50, -5., 5.);
573 fHistQA[8] = new TH1F("fHistQAPt","p_{T} distribution",200,0.,10.);
574 fHistQA[9] = new TH1F("fHistQAEta","#eta distribution",360,-1.8,1.8);
575 fHistQA[10] = new TH1F("fHistQAPhi","#phi distribution",340,0,6.8);
576 fHistQA[11] = new TH1F("fHistQANCls","Number of TPC cluster",200,0,200);
577 fHistQA[13] = new TH1F("fHistQAChi2","Chi2 per NDF",100,0,10);
578 fHistQA[12] = new TH1F("fHistQANCls1","Number of TPC cluster1",200,0,200);
579 fHistQA[14] = new TH1F("nCrossedRowsTPC","Number of TPC ccrossed rows",200,0,200);
580 fHistQA[15] = new TH1F("ratioCrossedRowsOverFindableClustersTPC","Number of TPC ccrossed rows find clusters",200,0,2);
582 for(Int_t i = 0; i < 16; i++)
584 fOutput->Add(fHistQA[i]);
587 kTrackVariablesPair=6 ;
589 if(fcontainPIDtrig && !fcontainPIDasso) kTrackVariablesPair=7;
591 if(!fcontainPIDtrig && fcontainPIDasso) kTrackVariablesPair=7;
593 if(fcontainPIDtrig && fcontainPIDasso) kTrackVariablesPair=8;
596 // two particle histograms
597 Int_t anaSteps = 1; // analysis steps
598 const char* title = "d^{2}N_{ch}/d#varphid#eta";
600 Int_t iBinPair[kTrackVariablesPair]; // binning for track variables
601 Double_t* dBinsPair[kTrackVariablesPair]; // bins for track variables
602 TString* axisTitlePair; // axis titles for track variables
603 axisTitlePair=new TString[kTrackVariablesPair];
605 TString defaultBinningStr;
606 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"
607 "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"
608 "p_t_leading_course: 0.5, 1.0, 2.0, 3.0, 4.0, 6.0, 8.0,10.0\n"
609 "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"
610 "vertex: -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10\n"
611 "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
612 "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"
613 "multiplicity: 0, 1, 2, 3, 4, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100.1\n";
616 defaultBinningStr += "PIDTrig: -0.5,0.5,1.5,2.5,3.5\n"; // course
619 defaultBinningStr += "PIDAsso: -0.5,0.5,1.5,2.5,3.5\n"; // course
621 // =========================================================
622 // Customization (adopted from AliUEHistograms)
623 // =========================================================
625 TObjArray* lines = defaultBinningStr.Tokenize("\n");
626 for (Int_t i=0; i<lines->GetEntriesFast(); i++)
628 TString line(lines->At(i)->GetName());
629 TString tag = line(0, line.Index(":")+1);
630 if (!fCustomBinning.BeginsWith(tag) && !fCustomBinning.Contains(TString("\n") + tag))
631 fBinningString += line + "\n";
633 AliInfo(Form("Using custom binning for %s", tag.Data()));
636 fBinningString += fCustomBinning;
638 AliInfo(Form("Used AliTHn Binning:\n%s",fBinningString.Data()));
640 // =========================================================
642 // =========================================================
644 dBinsPair[0] = GetBinning(fBinningString, "multiplicity", iBinPair[0]);
645 axisTitlePair[0] = " multiplicity";
647 dBinsPair[1] = GetBinning(fBinningString, "vertex", iBinPair[1]);
648 axisTitlePair[1] = "v_{Z} (cm)";
650 dBinsPair[2] = GetBinning(fBinningString, "p_t_leading_course", iBinPair[2]);
651 axisTitlePair[2] = "p_{T,trig.} (GeV/c)";
653 dBinsPair[3] = GetBinning(fBinningString, "p_t_assoc", iBinPair[3]);
654 axisTitlePair[3] = "p_{T,assoc.} (GeV/c)";
656 dBinsPair[4] = GetBinning(fBinningString, "delta_eta", iBinPair[4]);
657 axisTitlePair[4] = "#Delta#eta";
659 dBinsPair[5] = GetBinning(fBinningString, "delta_phi", iBinPair[5]);
660 axisTitlePair[5] = "#Delta#varphi (rad)";
662 if(fcontainPIDtrig && !fcontainPIDasso){
663 dBinsPair[6] = GetBinning(fBinningString, "PIDTrig", iBinPair[6]);
664 axisTitlePair[6] = "PIDTrig";
667 if(!fcontainPIDtrig && fcontainPIDasso){
668 dBinsPair[6] = GetBinning(fBinningString, "PIDAsso", iBinPair[6]);
669 axisTitlePair[6] = "PIDAsso";
672 if(fcontainPIDtrig && fcontainPIDasso){
674 dBinsPair[6] = GetBinning(fBinningString, "PIDTrig", iBinPair[6]);
675 axisTitlePair[6] = "PIDTrig";
677 dBinsPair[7] = GetBinning(fBinningString, "PIDAsso", iBinPair[7]);
678 axisTitlePair[7] = "PIDAsso";
682 Double_t* EtaBin = GetBinning(fBinningString, "eta", nEtaBin);
684 Int_t nPteffbin = -1;
685 Double_t* Pteff = GetBinning(fBinningString, "p_t_eff", nPteffbin);
688 fminPtTrig=dBinsPair[2][0];
689 fmaxPtTrig=dBinsPair[2][iBinPair[2]];
690 fminPtAsso=dBinsPair[3][0];
691 fmaxPtAsso=dBinsPair[3][iBinPair[3]];
693 //fminPtComboeff=fminPtTrig;***then this value will be fixed ,even Setter can't change it's value
694 //fmaxPtComboeff=fmaxPtTrig;
695 //THnSparses for calculation of efficiency
697 if((fAnalysisType =="MCAOD") && ffillefficiency) {
700 effbin[0]=iBinPair[0];
701 effbin[1]=iBinPair[1];
705 for(Int_t jj=0;jj<6;jj++)//PID type binning
707 if(jj==5) effsteps=3;//for unidentified particles
708 Histrename="fTrackHistEfficiency";Histrename+=jj;
709 fTrackHistEfficiency[jj] = new AliTHn(Histrename.Data(), "Tracking efficiency", effsteps, 4, effbin);
710 fTrackHistEfficiency[jj]->SetBinLimits(0, dBinsPair[0]);
711 fTrackHistEfficiency[jj]->SetVarTitle(0, "Centrality");
712 fTrackHistEfficiency[jj]->SetBinLimits(1, dBinsPair[1]);
713 fTrackHistEfficiency[jj]->SetVarTitle(1, "zvtx");
714 fTrackHistEfficiency[jj]->SetBinLimits(2, Pteff);
715 fTrackHistEfficiency[jj]->SetVarTitle(2, "p_{T} (GeV/c)");
716 fTrackHistEfficiency[jj]->SetBinLimits(3, EtaBin);
717 fTrackHistEfficiency[jj]->SetVarTitle(3, "#eta");
718 fOutput->Add(fTrackHistEfficiency[jj]);
722 //AliThns for Correlation plots(data & MC)
724 if(ffilltrigassoUNID)
726 fTHnCorrUNID = new AliTHn("fTHnCorrUNID", title, anaSteps, kTrackVariablesPair, iBinPair);
727 for (Int_t j=0; j<kTrackVariablesPair; j++) {
728 fTHnCorrUNID->SetBinLimits(j, dBinsPair[j]);
729 fTHnCorrUNID->SetVarTitle(j, axisTitlePair[j]);
731 fOutput->Add(fTHnCorrUNID);
733 fTHnCorrUNIDmix = new AliTHn("fTHnCorrUNIDmix", title, anaSteps, kTrackVariablesPair, iBinPair);
734 for (Int_t j=0; j<kTrackVariablesPair; j++) {
735 fTHnCorrUNIDmix->SetBinLimits(j, dBinsPair[j]);
736 fTHnCorrUNIDmix->SetVarTitle(j, axisTitlePair[j]);
738 fOutput->Add(fTHnCorrUNIDmix);
741 if(ffilltrigIDassoID)
743 fTHnCorrID = new AliTHn("fTHnCorrID", title, anaSteps, kTrackVariablesPair, iBinPair);
744 for (Int_t j=0; j<kTrackVariablesPair; j++) {
745 fTHnCorrID->SetBinLimits(j, dBinsPair[j]);
746 fTHnCorrID->SetVarTitle(j, axisTitlePair[j]);
748 fOutput->Add(fTHnCorrID);
750 fTHnCorrIDmix = new AliTHn("fTHnCorrIDmix", title, anaSteps, kTrackVariablesPair, iBinPair);
751 for (Int_t j=0; j<kTrackVariablesPair; j++) {
752 fTHnCorrIDmix->SetBinLimits(j, dBinsPair[j]);
753 fTHnCorrIDmix->SetVarTitle(j, axisTitlePair[j]);
755 fOutput->Add(fTHnCorrIDmix);
758 if(ffilltrigUNIDassoID || ffilltrigIDassoUNID)//***********a bit tricky, be careful
760 fTHnCorrIDUNID = new AliTHn("fTHnCorrIDUNID", title, anaSteps, kTrackVariablesPair, iBinPair);
761 for (Int_t j=0; j<kTrackVariablesPair; j++) {
762 fTHnCorrIDUNID->SetBinLimits(j, dBinsPair[j]);
763 fTHnCorrIDUNID->SetVarTitle(j, axisTitlePair[j]);
765 fOutput->Add(fTHnCorrIDUNID);
768 fTHnCorrIDUNIDmix = new AliTHn("fTHnCorrIDUNIDmix", title, anaSteps, kTrackVariablesPair, iBinPair);
769 for (Int_t j=0; j<kTrackVariablesPair; j++) {
770 fTHnCorrIDUNIDmix->SetBinLimits(j, dBinsPair[j]);
771 fTHnCorrIDUNIDmix->SetVarTitle(j, axisTitlePair[j]);
773 fOutput->Add(fTHnCorrIDUNIDmix);
778 //ThnSparse for Correlation plots(truth MC)
779 if((fAnalysisType == "MCAOD") && ffilltrigIDassoIDMCTRUTH) {//remember that in this case uidentified means other than pions, kaons, protons
781 fCorrelatonTruthPrimary = new AliTHn("fCorrelatonTruthPrimary", title, anaSteps, kTrackVariablesPair, iBinPair);
782 for (Int_t j=0; j<kTrackVariablesPair; j++) {
783 fCorrelatonTruthPrimary->SetBinLimits(j, dBinsPair[j]);
784 fCorrelatonTruthPrimary->SetVarTitle(j, axisTitlePair[j]);
786 fOutput->Add(fCorrelatonTruthPrimary);
789 fCorrelatonTruthPrimarymix = new AliTHn("fCorrelatonTruthPrimarymix", title, anaSteps, kTrackVariablesPair, iBinPair);
790 for (Int_t j=0; j<kTrackVariablesPair; j++) {
791 fCorrelatonTruthPrimarymix->SetBinLimits(j, dBinsPair[j]);
792 fCorrelatonTruthPrimarymix->SetVarTitle(j, axisTitlePair[j]);
794 fOutput->Add(fCorrelatonTruthPrimarymix);
797 //binning for trigger no. counting
801 if(fcontainPIDtrig) dims=4;
802 fBinst= new Int_t[dims];
803 for(Int_t i=0; i<3;i++)
805 fBinst[i]=iBinPair[i];
808 fBinst[3]=iBinPair[6];
811 //ThSparse for trigger counting(data & reco MC)
812 if(ffilltrigassoUNID || ffilltrigUNIDassoID || ffilltrigIDassoUNID || ffilltrigIDassoID)
814 fTHnTrigcount = new AliTHn("fTHnTrigcount", "fTHnTrigcount", 2, dims, fBinst); //2 steps;;;;0->same event;;;;;1->mixed event
815 for(Int_t i=0; i<3;i++){
816 fTHnTrigcount->SetBinLimits(i, dBinsPair[i]);
817 fTHnTrigcount->SetVarTitle(i, axisTitlePair[i]);
821 fTHnTrigcount->SetBinLimits(3, dBinsPair[6]);
822 fTHnTrigcount->SetVarTitle(3, axisTitlePair[6]);
824 fOutput->Add(fTHnTrigcount);
827 if((fAnalysisType =="MCAOD") && ffilltrigIDassoIDMCTRUTH) {
828 //AliTHns for trigger counting(truth MC)
829 fTHnTrigcountMCTruthPrim = new AliTHn("fTHnTrigcountMCTruthPrim", "fTHnTrigcountMCTruthPrim", 2, dims, fBinst); //2 steps;;;;0->same event;;;;;1->mixed event
830 for(Int_t i=0; i<3;i++){
831 fTHnTrigcountMCTruthPrim->SetBinLimits(i, dBinsPair[i]);
832 fTHnTrigcountMCTruthPrim->SetVarTitle(i, axisTitlePair[i]);
836 fTHnTrigcountMCTruthPrim->SetBinLimits(3, dBinsPair[6]);
837 fTHnTrigcountMCTruthPrim->SetVarTitle(3, axisTitlePair[6]);
839 fOutput->Add(fTHnTrigcountMCTruthPrim);
842 if(fAnalysisType=="MCAOD"){
845 MCtruthpt=new TH1F ("MCtruthpt","ptdistributiontruthprim",100,0.,10.);
846 fOutputList->Add(MCtruthpt);
848 MCtrutheta=new TH1F ("MCtrutheta","etadistributiontruthprim",360,-1.8,1.8);
849 fOutputList->Add(MCtrutheta);
851 MCtruthphi=new TH1F ("MCtruthphi","phidisttruthprim",340,0,6.8);
852 fOutputList->Add(MCtruthphi);
854 MCtruthpionpt=new TH1F ("MCtruthpionpt","MCtruthpionpt",100,0.,10.);
855 fOutputList->Add(MCtruthpionpt);
857 MCtruthpioneta=new TH1F ("MCtruthpioneta","MCtruthpioneta",360,-1.8,1.8);
858 fOutputList->Add(MCtruthpioneta);
860 MCtruthpionphi=new TH1F ("MCtruthpionphi","MCtruthpionphi",340,0,6.8);
861 fOutputList->Add(MCtruthpionphi);
863 MCtruthkaonpt=new TH1F ("MCtruthkaonpt","MCtruthkaonpt",100,0.,10.);
864 fOutputList->Add(MCtruthkaonpt);
866 MCtruthkaoneta=new TH1F ("MCtruthkaoneta","MCtruthkaoneta",360,-1.8,1.8);
867 fOutputList->Add(MCtruthkaoneta);
869 MCtruthkaonphi=new TH1F ("MCtruthkaonphi","MCtruthkaonphi",340,0,6.8);
870 fOutputList->Add(MCtruthkaonphi);
872 MCtruthprotonpt=new TH1F ("MCtruthprotonpt","MCtruthprotonpt",100,0.,10.);
873 fOutputList->Add(MCtruthprotonpt);
875 MCtruthprotoneta=new TH1F ("MCtruthprotoneta","MCtruthprotoneta",360,-1.8,1.8);
876 fOutputList->Add(MCtruthprotoneta);
878 MCtruthprotonphi=new TH1F ("MCtruthprotonphi","MCtruthprotonphi",340,0,6.8);
879 fOutputList->Add(MCtruthprotonphi);
881 fPioncont=new TH2F("fPioncont", "fPioncont",10,-0.5,9.5,100,0.,10.);
882 fOutputList->Add(fPioncont);
884 fKaoncont=new TH2F("fKaoncont","fKaoncont",10,-0.5,9.5,100,0.,10.);
885 fOutputList->Add(fKaoncont);
887 fProtoncont=new TH2F("fProtoncont","fProtoncont",10,-0.5,9.5,100,0.,10.);
888 fOutputList->Add(fProtoncont);
891 fEventno=new TH2F("fEventno","fEventno",iBinPair[0], dBinsPair[0],iBinPair[1],dBinsPair[1]);
892 fEventno->GetXaxis()->SetTitle("Centrality");
893 fEventno->GetYaxis()->SetTitle("Z_Vtx");
894 fOutput->Add(fEventno);
895 fEventnobaryon=new TH2F("fEventnobaryon","fEventnobaryon",iBinPair[0], dBinsPair[0],iBinPair[1],dBinsPair[1]);
896 fEventnobaryon->GetXaxis()->SetTitle("Centrality");
897 fEventnobaryon->GetYaxis()->SetTitle("Z_Vtx");
898 fOutput->Add(fEventnobaryon);
899 fEventnomeson=new TH2F("fEventnomeson","fEventnomeson",iBinPair[0], dBinsPair[0],iBinPair[1],dBinsPair[1]);
900 fEventnomeson->GetXaxis()->SetTitle("Centrality");
901 fEventnomeson->GetYaxis()->SetTitle("Z_Vtx");
902 fOutput->Add(fEventnomeson);
904 fhistJetTrigestimate=new TH2F("fhistJetTrigestimate","fhistJetTrigestimate",iBinPair[0],dBinsPair[0],6,-0.5,5.5);
905 fOutput->Add(fhistJetTrigestimate);
911 if(fapplyTrigefficiency || fapplyAssoefficiency)
913 const Int_t nDimt = 4;// cent zvtx pt eta
914 Int_t fBinsCht[nDimt] = {iBinPair[0], iBinPair[1], nPteffbin ,nEtaBin};//*************change it
915 Double_t fMinCht[nDimt] = { dBinsPair[0][0],dBinsPair[1][0], Pteff[0], EtaBin[0] };
916 Double_t fMaxCht[nDimt] = {dBinsPair[0][iBinPair[0]], dBinsPair[1][iBinPair[1]], Pteff[nPteffbin], EtaBin[nEtaBin]};
919 for(Int_t jj=0;jj<6;jj++)// PID type binning
921 Histrexname="effcorection";Histrexname+=jj;
922 effcorection[jj] = new THnSparseF(Histrexname.Data(),"cent:zvtx::Pt:eta", nDimt, fBinsCht, fMinCht, fMaxCht);
923 effcorection[jj]->Sumw2();
924 effcorection[jj]->GetAxis(0)->Set(iBinPair[0], dBinsPair[0]);
925 effcorection[jj]->GetAxis(0)->SetTitle("Centrality");
926 effcorection[jj]->GetAxis(1)->Set( iBinPair[1],dBinsPair[1]);
927 effcorection[jj]->GetAxis(1)->SetTitle("zvtx");
928 effcorection[jj]->GetAxis(2)->Set(nPteffbin, Pteff);
929 effcorection[jj]->GetAxis(2)->SetTitle("p_{T} (GeV/c)");
930 effcorection[jj]->GetAxis(3)->Set( nEtaBin,EtaBin);
931 effcorection[jj]->GetAxis(3)->SetTitle("#eta");
932 fOutput->Add(effcorection[jj]);
934 // TFile *fsifile = new TFile(fefffilename,"READ");
936 if (TString(fefffilename).BeginsWith("alien:"))
937 TGrid::Connect("alien:");
938 TFile *fileT=TFile::Open(fefffilename);
940 for(Int_t jj=0;jj<6;jj++)//type binning
942 Nameg="effmap";Nameg+=jj;
943 //effcorection[jj] = (THnSparseF*)fsifile->Get(Nameg.Data());
944 effcorection[jj] = (THnSparseF*)fileT->Get(Nameg.Data());
946 //effcorection[jj]->SetDirectory(0);//****************************not present in case oh THnF
953 //*****************************************************PIDQA histos*****************************************************//
957 for(Int_t ipart=0;ipart<NSpecies;ipart++){
958 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
961 if(ipid==NSigmaTPCTOF){miny=0;maxy=50;}
962 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);
963 fHistoNSigma->GetXaxis()->SetTitle("P_{T} (GeV / c)");
964 fHistoNSigma->GetYaxis()->SetTitle(Form("n#sigma %s %s",kParticleSpeciesName[ipart],kPIDTypeName[ipid]));
965 fOutputList->Add(fHistoNSigma);
970 for(Int_t ipart=0;ipart<NSpecies;ipart++){
971 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
974 if(ipid==NSigmaTPCTOF){miny=0;maxy=20;}
975 TH2F *fHistoNSigma=new TH2F(Form("NSigmaRec_%d_%d",ipart,ipid),
976 Form("n#sigma for reconstructed %s %s",kParticleSpeciesName[ipart],kPIDTypeName[ipid]),200,0,10,500,miny,maxy);
977 fHistoNSigma->GetXaxis()->SetTitle("P_{T} (GeV / c)");
978 fHistoNSigma->GetYaxis()->SetTitle(Form("n#sigma %s %s",kParticleSpeciesName[ipart],kPIDTypeName[ipid]));
979 fOutputList->Add(fHistoNSigma);
984 if(fUseExclusiveNSigma) {
985 for(Int_t ipart=0;ipart<NSpecies;ipart++){
986 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
989 if(ipid==NSigmaTPCTOF){miny=0;maxy=20;}
990 TH2F *fHistoNSigma=new TH2F(Form("NSigmaDC_%d_%d",ipart,ipid),
991 Form("n#sigma for double counting %s %s",kParticleSpeciesName[ipart],kPIDTypeName[ipid]),200,0,10,500,miny,maxy);
992 fHistoNSigma->GetXaxis()->SetTitle("P_{T} (GeV / c)");
993 fHistoNSigma->GetYaxis()->SetTitle(Form("n#sigma %s %s",kParticleSpeciesName[ipart],kPIDTypeName[ipid]));
994 fOutputList->Add(fHistoNSigma);
999 if (fAnalysisType == "MCAOD"){
1000 for(Int_t ipart=0;ipart<NSpecies;ipart++){
1001 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
1004 if(ipid==NSigmaTPCTOF){miny=0;maxy=50;}
1005 TH2F *fHistoNSigma=new TH2F(Form("NSigmaMC_%d_%d",ipart,ipid),
1006 Form("n#sigma for MC %s %s",kParticleSpeciesName[ipart],kPIDTypeName[ipid]),200,0,10,500,miny,maxy);
1007 fHistoNSigma->GetXaxis()->SetTitle("P_{T} (GeV / c)");
1008 fHistoNSigma->GetYaxis()->SetTitle(Form("n#sigma %s %s",kParticleSpeciesName[ipart],kPIDTypeName[ipid]));
1009 fOutputList->Add(fHistoNSigma);
1014 for(Int_t idet=0;idet<fNDetectors;idet++){
1015 for(Int_t ipart=0;ipart<NSpecies;ipart++){
1017 if(idet==fTOF)maxy=1.1;
1018 TH2F *fHistoPID=new TH2F(Form("PID_%d_%d",idet,ipart),Form("%s signal - %s",kDetectorName[idet],kParticleSpeciesName[ipart]),200,0,10,500,-maxy,maxy);
1019 fHistoPID->GetXaxis()->SetTitle("P (GeV / c)");
1020 fHistoPID->GetYaxis()->SetTitle(Form("%s signal",kDetectorName[idet]));
1021 fOutputList->Add(fHistoPID);
1024 //PID signal plot, before PID cut
1025 for(Int_t idet=0;idet<fNDetectors;idet++){
1027 if(idet==fTOF)maxy=1.1;
1028 TH2F *fHistoPID=new TH2F(Form("PIDAll_%d",idet),Form("%s signal",kDetectorName[idet]),200,0,10,500,-maxy,maxy);
1029 fHistoPID->GetXaxis()->SetTitle("P (GeV / c)");
1030 fHistoPID->GetYaxis()->SetTitle(Form("%s signal",kDetectorName[idet]));
1031 fOutputList->Add(fHistoPID);
1034 PostData(1, fOutput); // Post data for ALL output slots >0 here, to get at least an empty histogram
1035 PostData(2, fOutputList);
1037 AliInfo("Finished setting up the Output");
1039 TH1::AddDirectory(oldStatus);
1044 //-------------------------------------------------------------------------------
1045 void AliTwoParticlePIDCorr::UserExec( Option_t * ){
1048 if(fAnalysisType == "AOD") {
1052 }//AOD--analysis-----
1054 else if(fAnalysisType == "MCAOD") {
1063 //-------------------------------------------------------------------------
1064 void AliTwoParticlePIDCorr::doMCAODevent()
1066 AliVEvent *event = InputEvent();
1067 if (!event) { Printf("ERROR: Could not retrieve event"); return; }
1068 AliAODEvent* aod = dynamic_cast<AliAODEvent*>(event);
1070 AliError("Cannot get the AOD event");
1074 // count all events(physics triggered)
1075 fEventCounter->Fill(1);
1077 // get centrality object and check quality(valid for p-Pb and Pb-Pb)
1078 Double_t cent_v0=0.0;
1080 if(fSampleType=="pPb" || fSampleType=="PbPb")
1082 AliCentrality *centrality=0;
1084 centrality = aod->GetHeader()->GetCentralityP();
1085 // if (centrality->GetQuality() != 0) return ;
1089 cent_v0 = centrality->GetCentralityPercentile(fCentralityMethod);
1097 //check the PIDResponse handler
1100 // get mag. field required for twotrack efficiency cut
1102 bSign = (aod->GetMagneticField() > 0) ? 1 : -1;
1104 //check for TClonesArray(truth track MC information)
1105 fArrayMC = dynamic_cast<TClonesArray*>(aod->FindListObject(AliAODMCParticle::StdBranchName()));
1107 AliFatal("Error: MC particles branch not found!\n");
1111 //check for AliAODMCHeader(truth event MC information)
1112 AliAODMCHeader *header=NULL;
1113 header=(AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
1115 printf("MC header branch not found!\n");
1119 //Only consider MC events within the vtx-z region used also as cut on the reconstructed vertex
1120 Float_t zVtxmc =header->GetVtxZ();
1121 if(TMath::Abs(zVtxmc)>fzvtxcut) return;
1123 // For productions with injected signals, figure out above which label to skip particles/tracks
1124 Int_t skipParticlesAbove = 0;
1126 if (fInjectedSignals)
1128 AliGenEventHeader* eventHeader = 0;
1133 AliFatal("fInjectedSignals set but no MC header found");
1135 headers = header->GetNCocktailHeaders();
1136 eventHeader = header->GetCocktailHeader(0);
1140 // We avoid AliFatal here, because the AOD productions sometimes have events where the MC header is missing
1141 // (due to unreadable Kinematics) and we don't want to loose the whole job because of a few events
1142 AliError("First event header not found. Skipping this event.");
1143 //fHistos->FillEvent(centrality, AliUEHist::kCFStepAnaTopology);
1146 skipParticlesAbove = eventHeader->NProduced();
1147 AliInfo(Form("Injected signals in this event (%d headers). Keeping events of %s. Will skip particles/tracks above %d.", headers, eventHeader->ClassName(), skipParticlesAbove));
1150 //vertex selection(is it fine for PP?)
1151 if ( fVertextype==1){
1152 trkVtx = aod->GetPrimaryVertex();
1153 if (!trkVtx || trkVtx->GetNContributors()<=0) return;
1154 TString vtxTtl = trkVtx->GetTitle();
1155 if (!vtxTtl.Contains("VertexerTracks")) return;
1156 zvtx = trkVtx->GetZ();
1157 const AliAODVertex* spdVtx = aod->GetPrimaryVertexSPD();
1158 if (!spdVtx || spdVtx->GetNContributors()<=0) return;
1159 TString vtxTyp = spdVtx->GetTitle();
1160 Double_t cov[6]={0};
1161 spdVtx->GetCovarianceMatrix(cov);
1162 Double_t zRes = TMath::Sqrt(cov[5]);
1163 if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) return;
1164 if (TMath::Abs(spdVtx->GetZ() - trkVtx->GetZ())>0.5) return;
1166 else if(fVertextype==2) {//for pp and pb-pb case
1167 Int_t nVertex = aod->GetNumberOfVertices();
1169 trkVtx = aod->GetPrimaryVertex();
1170 Int_t nTracksPrim = trkVtx->GetNContributors();
1171 zvtx = trkVtx->GetZ();
1172 //if (fDebug > 1)AliInfo(Form(" Vertex in = %f with %d particles by %s data ...",zVertex,nTracksPrim,vertex->GetName()));
1173 // Reject TPC only vertex
1174 TString name(trkVtx->GetName());
1175 if (name.CompareTo("PrimaryVertex") && name.CompareTo("SPDVertex"))return;
1177 // Select a quality vertex by number of tracks?
1178 if( nTracksPrim < fnTracksVertex ) {
1179 //if (fDebug > 1) AliInfo(" Primary-vertex Selection: event REJECTED ...");
1182 // TODO remove vertexer Z events with dispersion > 0.02: Doesn't work for AOD at present
1183 //if (strcmp(vertex->GetTitle(), "AliVertexerZ") == 0 && vertex->GetDispersion() > 0.02)
1185 // if (fDebug > 1) AliInfo(" Primary-vertex Selection: event ACCEPTED...");
1190 else if(fVertextype==0){//default case
1191 trkVtx = aod->GetPrimaryVertex();
1192 if (!trkVtx || trkVtx->GetNContributors()<=0) return;//proper number of contributors
1193 zvtx = trkVtx->GetZ();
1195 trkVtx->GetCovarianceMatrix(fCov);
1196 if(fCov[5] == 0) return;//proper vertex resolution
1199 AliInfo("Wrong Vertextype set for Primary-vertex Selection: event REJECTED ...");
1200 return;//as there is no proper sample type
1204 fHistQA[0]->Fill((trkVtx->GetX()));fHistQA[1]->Fill((trkVtx->GetY()));fHistQA[2]->Fill((trkVtx->GetZ())); //for trkVtx only before vertex cut |zvtx|<10 cm
1206 //count events having a proper vertex
1207 fEventCounter->Fill(3);
1209 if (TMath::Abs(zvtx) > fzvtxcut) return;
1211 fHistQA[3]->Fill((trkVtx->GetX()));fHistQA[4]->Fill((trkVtx->GetY()));fHistQA[5]->Fill((trkVtx->GetZ()));//after vertex cut for trkVtx only
1213 //now we have events passed physics trigger, centrality,eventzvtx cut
1215 //count events after vertex cut
1216 fEventCounter->Fill(5);
1218 if(!aod) return; //for safety
1220 if (fSampleType=="pPb" || fSampleType=="PbPb") if (cent_v0 < 0) return;//for pp case it is the multiplicity
1222 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)
1224 Double_t cent_v0_truth=0.0;
1226 //TObjArray* tracksMCtruth=0;
1227 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
1228 tracksMCtruth->SetOwner(kTRUE); //***********************************IMPORTANT!
1232 //There is a small difference between zvtx and zVtxmc??????
1233 //cout<<"***********************************************zVtxmc="<<zVtxmc<<endl;
1234 //cout<<"***********************************************zvtx="<<zvtx<<endl;
1236 //now process the truth particles(for both efficiency & correlation function)
1237 Int_t nMCTrack = fArrayMC->GetEntriesFast();
1239 for (Int_t iMC = 0; iMC < nMCTrack; iMC++)
1240 { //MC truth track loop starts
1242 AliAODMCParticle *partMC = (AliAODMCParticle*) fArrayMC->At(iMC);
1245 AliError(Form("ERROR: Could not retrieve AODMCtrack %d",iMC));
1249 //consider only charged particles
1250 if(partMC->Charge() == 0) continue;
1252 //consider only primary particles; neglect all secondary particles including from weak decays
1253 if(fselectprimaryTruth && !partMC->IsPhysicalPrimary()) continue;
1256 //remove injected signals(primaries above <maxLabel>)
1257 if (fInjectedSignals && partMC->GetLabel() >= skipParticlesAbove) continue;
1260 Bool_t isduplicate=kFALSE;
1261 if (fRemoveDuplicates)
1263 for (Int_t j=iMC+1; j<nMCTrack; ++j)
1264 {//2nd trutuh loop starts
1265 AliAODMCParticle *partMC2 = (AliAODMCParticle*) fArrayMC->At(j);
1267 AliError(Form("ERROR: Could not retrieve AODMCtrack %d",j));
1270 if (partMC->GetLabel() == partMC2->GetLabel())
1275 }//2nd truth loop ends
1277 if(fRemoveDuplicates && isduplicate) continue;//remove duplicates
1279 //give only kinematic cuts at the truth level
1280 if (partMC->Eta() < fmineta || partMC->Eta() > fmaxeta) continue;
1281 if (partMC->Pt() < fminPt || partMC->Pt() > fmaxPt) continue;
1283 if(!partMC) continue;//for safety
1285 //To determine multiplicity in case of PP
1287 //cout<<"**************************************"<<TMath::Abs(partMC->GetLabel())<<endl;
1288 //only physical primary(all/unidentified)
1289 if(ffillhistQATruth)
1291 MCtruthpt->Fill(partMC->Pt());
1292 MCtrutheta->Fill(partMC->Eta());
1293 MCtruthphi->Fill(partMC->Phi());
1296 Int_t pdgtruth=((AliAODMCParticle*)partMC)->GetPdgCode();
1297 Int_t particletypeTruth=-999;
1298 if (TMath::Abs(pdgtruth)==211)
1300 particletypeTruth=SpPion;
1301 if(ffillhistQATruth)
1303 MCtruthpionpt->Fill(partMC->Pt());
1304 MCtruthpioneta->Fill(partMC->Eta());
1305 MCtruthpionphi->Fill(partMC->Phi());
1308 if (TMath::Abs(pdgtruth)==321)
1310 particletypeTruth=SpKaon;
1311 if(ffillhistQATruth)
1313 MCtruthkaonpt->Fill(partMC->Pt());
1314 MCtruthkaoneta->Fill(partMC->Eta());
1315 MCtruthkaonphi->Fill(partMC->Phi());
1318 if(TMath::Abs(pdgtruth)==2212)
1320 particletypeTruth=SpProton;
1321 if(ffillhistQATruth)
1323 MCtruthprotonpt->Fill(partMC->Pt());
1324 MCtruthprotoneta->Fill(partMC->Eta());
1325 MCtruthprotonphi->Fill(partMC->Phi());
1328 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)
1330 // -- Fill THnSparse for efficiency and contamination calculation
1331 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
1333 Double_t primmctruth[4] = {cent_v0, zVtxmc,partMC->Pt(), partMC->Eta()};
1336 fTrackHistEfficiency[5]->Fill(primmctruth,0);//for all primary truth particles(4)
1337 if (TMath::Abs(pdgtruth)==211 || TMath::Abs(pdgtruth)==321) fTrackHistEfficiency[3]->Fill(primmctruth,0);//for primary truth mesons(3)
1338 if (TMath::Abs(pdgtruth)==2212 || TMath::Abs(pdgtruth)==321) fTrackHistEfficiency[4]->Fill(primmctruth,0);//for primary truth kaons+protons(4)
1339 if (TMath::Abs(pdgtruth)==211) fTrackHistEfficiency[0]->Fill(primmctruth,0);//for pions
1340 if (TMath::Abs(pdgtruth)==321) fTrackHistEfficiency[1]->Fill(primmctruth,0);//for kaons
1341 if(TMath::Abs(pdgtruth)==2212) fTrackHistEfficiency[2]->Fill(primmctruth,0);//for protons
1344 Float_t effmatrixtruth=1.0;//In Truth MC, no case of efficiency correction so it should be always 1.0
1345 if((partMC->Pt()>=fminPtAsso && partMC->Pt()<=fmaxPtAsso) || (partMC->Pt()>=fminPtTrig && partMC->Pt()<=fmaxPtTrig))//to reduce memory consumption in pool
1347 LRCParticlePID* copy6 = new LRCParticlePID(particletypeTruth,partMC->Charge(),partMC->Pt(),partMC->Eta(), partMC->Phi(),effmatrixtruth);
1348 //copy6->SetUniqueID(eventno * 100000 + TMath::Abs(partMC->GetLabel()));
1349 copy6->SetUniqueID(eventno * 100000 + (Int_t)nooftrackstruth);
1350 tracksMCtruth->Add(copy6);//************** TObjArray used for truth correlation function calculation
1352 }//MC truth track loop ends
1354 //*********************still in event loop
1355 Float_t weghtval=1.0;
1357 if (fSampleType=="pp") cent_v0_truth=nooftrackstruth;
1358 else cent_v0_truth=cent_v0;//the notation cent_v0 is reserved for reco/data case
1360 //now cent_v0_truth should be used for all correlation function calculation
1362 if(nooftrackstruth>0.0 && ffilltrigIDassoIDMCTRUTH)
1364 //Fill Correlations for MC truth particles(same event)
1365 if(tracksMCtruth && tracksMCtruth->GetEntriesFast()>0)//hadron triggered correlation
1366 Fillcorrelation(tracksMCtruth,0,cent_v0_truth,zVtxmc,weghtval,kFALSE,bSign,fPtOrderMCTruth,kFALSE,kFALSE,"trigIDassoIDMCTRUTH");//mixcase=kFALSE for same event case
1369 AliEventPool* pool2 = fPoolMgr->GetEventPool(cent_v0_truth, zVtxmc+200);
1370 if (pool2 && pool2->IsReady())
1371 {//start mixing only when pool->IsReady
1372 if(tracksMCtruth && tracksMCtruth->GetEntriesFast()>0)
1373 {//proceed only when no. of trigger particles >0 in current event
1374 Float_t nmix=(Float_t)pool2->GetCurrentNEvents();
1375 for (Int_t jMix=0; jMix<pool2->GetCurrentNEvents(); jMix++)
1376 { //pool event loop start
1377 TObjArray* bgTracks6 = pool2->GetEvent(jMix);
1378 if(!bgTracks6) continue;
1379 Fillcorrelation(tracksMCtruth,bgTracks6,cent_v0_truth,zVtxmc,nmix,(jMix == 0),bSign,fPtOrderMCTruth,kFALSE,kTRUE,"trigIDassoIDMCTRUTH");//mixcase=kTRUE for mixing case
1381 }// pool event loop ends mixing case
1382 }//if(trackstrig && trackstrig->GetEntriesFast()>0) condition ends mixing case
1383 } //if pool->IsReady() condition ends mixing case
1385 //still in main event loop
1388 if(pool2) pool2->UpdatePool(CloneAndReduceTrackList(tracksMCtruth));//ownership of tracksasso is with pool now, don't delete it
1392 //still in main event loop
1394 if(tracksMCtruth) delete tracksMCtruth;
1396 //now deal with reco tracks
1397 //TObjArray* tracksUNID=0;
1398 TObjArray* tracksUNID = new TObjArray;
1399 tracksUNID->SetOwner(kTRUE);
1401 //TObjArray* tracksID=0;
1402 TObjArray* tracksID = new TObjArray;
1403 tracksID->SetOwner(kTRUE);
1406 Float_t bSign1=aod->GetHeader()->GetMagneticField() ;//used for reconstructed track dca cut
1408 Double_t trackscount=0.0;
1410 // loop over reconstructed tracks
1411 for (Int_t itrk = 0; itrk < aod->GetNumberOfTracks(); itrk++)
1412 { // reconstructed track loop starts
1413 AliAODTrack* track = dynamic_cast<AliAODTrack*>(aod->GetTrack(itrk));
1414 if (!track) continue;
1415 //get the corresponding MC track at the truth level (doing reco matching)
1416 AliAODMCParticle* recomatched = static_cast<AliAODMCParticle*>(fArrayMC->At(TMath::Abs(track->GetLabel())));
1417 if(!recomatched) continue;//if a reco track doesn't have corresponding truth track at generated level is a fake track(label==0), ignore it
1419 //remove injected signals
1420 if(fInjectedSignals)
1422 AliAODMCParticle* mother = recomatched;
1424 while (!mother->IsPhysicalPrimary())
1425 {// find the primary mother;the first stable mother is searched and checked if it is <= <maxLabel>
1426 if (mother->GetMother() < 0)
1432 mother =(AliAODMCParticle*) fArrayMC->At(((AliAODMCParticle*)mother)->GetMother());
1438 Printf("WARNING: No mother found for particle %d:", recomatched->GetLabel());
1441 if (mother->GetLabel() >= skipParticlesAbove) continue;//remove injected signals(primaries above <maxLabel>)
1442 }//remove injected signals
1444 if (fRemoveWeakDecays && ((AliAODMCParticle*) recomatched)->IsSecondaryFromWeakDecay()) continue;//remove weak decays
1446 Bool_t isduplicate2=kFALSE;
1447 if (fRemoveDuplicates)
1449 for (Int_t j =itrk+1; j < aod->GetNumberOfTracks(); j++)
1451 AliAODTrack* track2 = dynamic_cast<AliAODTrack*>(aod->GetTrack(j));
1452 if (!track2) continue;
1453 AliAODMCParticle* recomatched2 = static_cast<AliAODMCParticle*>(fArrayMC->At(TMath::Abs(track2->GetLabel())));
1454 if(!recomatched2) continue;
1456 if (track->GetLabel() == track2->GetLabel())
1463 if(fRemoveDuplicates && isduplicate2) continue;//remove duplicates
1465 fHistQA[11]->Fill(track->GetTPCNcls());
1466 Int_t tracktype=ClassifyTrack(track,trkVtx,bSign1);//dcacut=kFALSE,onlyprimary=kFALSE
1468 if(tracktype==0) continue;
1469 if(tracktype==1)//tracks "not" passed AliAODTrack::kPrimary at reconstructed level & have proper TPC PID response(?)
1471 if(!track) continue;//for safety
1472 //accepted all(primaries+secondary) reconstructed tracks(pt 0.2 to 10.0,,eta -0.8 to 0.8)
1475 //check for eta , phi holes
1476 fEtaSpectrasso->Fill(track->Eta(),track->Pt());
1477 fphiSpectraasso->Fill(track->Phi(),track->Pt());
1479 Int_t particletypeMC=-9999;
1481 //tag all particles as unidentified
1482 particletypeMC=unidentified;
1484 Float_t effmatrix=1.;
1486 // -- Fill THnSparse for efficiency calculation
1487 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
1488 //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)
1490 //Clone & Reduce track list(TObjArray) for unidentified particles
1491 if((track->Pt()>=fminPtAsso && track->Pt()<=fmaxPtAsso) || (track->Pt()>=fminPtTrig && track->Pt()<=fmaxPtTrig))//to reduce memory consumption in pool
1493 if (fapplyTrigefficiency || fapplyAssoefficiency)//get the trackingefficiency x contamination factor for unidentified particles
1494 effmatrix=GetTrackbyTrackeffvalue(track,cent_v0,zvtx,particletypeMC);
1495 LRCParticlePID* copy = new LRCParticlePID(particletypeMC,track->Charge(),track->Pt(),track->Eta(), track->Phi(),effmatrix);
1496 copy->SetUniqueID(eventno * 100000 +(Int_t)trackscount);
1497 tracksUNID->Add(copy);//track information Storage for UNID correlation function(tracks that pass the filterbit & kinematic cuts only)
1500 //get the pdg code of the corresponding truth particle
1501 Int_t pdgCode = ((AliAODMCParticle*)recomatched)->GetPdgCode();
1503 Double_t allrecomatchedpid[4] = {cent_v0, zVtxmc,recomatched->Pt(), recomatched->Eta()};
1504 if(ffillefficiency) {
1505 fTrackHistEfficiency[5]->Fill(allrecomatchedpid,2);//for allreco matched
1506 if(TMath::Abs(pdgCode)==211 || TMath::Abs(pdgCode)==321) fTrackHistEfficiency[3]->Fill(allrecomatchedpid,2);//for mesons
1507 if(TMath::Abs(pdgCode)==321 || TMath::Abs(pdgCode)==2212) fTrackHistEfficiency[4]->Fill(allrecomatchedpid,2);//for kaons+protons
1508 if(TMath::Abs(pdgCode)==211) fTrackHistEfficiency[0]->Fill(allrecomatchedpid,2);//for pions
1509 if(TMath::Abs(pdgCode)==321) fTrackHistEfficiency[1]->Fill(allrecomatchedpid,2);//for kaons
1510 if(TMath::Abs(pdgCode)==2212) fTrackHistEfficiency[2]->Fill(allrecomatchedpid,2);//for protons
1512 if (((AliAODMCParticle*)recomatched)->IsPhysicalPrimary()) {
1513 fTrackHistEfficiency[5]->Fill(allrecomatchedpid,1);//for primreco matched
1514 if(TMath::Abs(pdgCode)==211 || TMath::Abs(pdgCode)==321) fTrackHistEfficiency[3]->Fill(allrecomatchedpid,1);//for mesons
1515 if(TMath::Abs(pdgCode)==321 || TMath::Abs(pdgCode)==2212) fTrackHistEfficiency[4]->Fill(allrecomatchedpid,1);//for kaons+protons
1516 if( TMath::Abs(pdgCode)==211) fTrackHistEfficiency[0]->Fill(allrecomatchedpid,1);//for pions
1517 if( TMath::Abs(pdgCode)==321) fTrackHistEfficiency[1]->Fill(allrecomatchedpid,1);//for kaons
1518 if( TMath::Abs(pdgCode)==2212) fTrackHistEfficiency[2]->Fill(allrecomatchedpid,1);//for protons
1523 //now start the particle identification process:)
1524 switch(TMath::Abs(pdgCode)){
1526 if(fFIllPIDQAHistos){
1527 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
1528 if((ipid!=NSigmaTPC) && (!HasTOFPID(track)) && track->Pt()<fPtTOFPIDmin)continue;//not filling TOF and combined if no TOF PID
1529 TH2F *h=GetHistogram2D(Form("NSigmaMC_%d_%d",SpProton,ipid));
1530 h->Fill(track->Pt(),fnsigmas[SpProton][ipid]);
1535 if(fFIllPIDQAHistos){
1536 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
1537 if((ipid!=NSigmaTPC) && (!HasTOFPID(track)) && track->Pt()<fPtTOFPIDmin)continue;//not filling TOF and combined if no TOF PID
1538 TH2F *h=GetHistogram2D(Form("NSigmaMC_%d_%d",SpKaon,ipid));
1539 h->Fill(track->Pt(),fnsigmas[SpKaon][ipid]);
1544 if(fFIllPIDQAHistos){
1545 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
1546 if((ipid!=NSigmaTPC) && (!HasTOFPID(track)) && track->Pt()<fPtTOFPIDmin)continue;//not filling TOF and combined if no TOF PID
1547 TH2F *h=GetHistogram2D(Form("NSigmaMC_%d_%d",SpPion,ipid));
1548 h->Fill(track->Pt(),fnsigmas[SpPion][ipid]);
1555 Float_t dEdx = track->GetTPCsignal();
1556 fHistoTPCdEdx->Fill(track->Pt(), dEdx);
1558 if(HasTOFPID(track))
1560 Double_t beta = GetBeta(track);
1561 fHistoTOFbeta->Fill(track->Pt(), beta);
1564 //do track identification(nsigma method)
1565 particletypeMC=GetParticle(track,fFIllPIDQAHistos);//******************************problem is here
1567 //2-d TPCTOF map(for each Pt interval)
1568 if(HasTOFPID(track)){
1569 fTPCTOFPion3d->Fill(track->Pt(),fnsigmas[SpPion][NSigmaTOF],fnsigmas[SpPion][NSigmaTPC]);
1570 fTPCTOFKaon3d->Fill(track->Pt(),fnsigmas[SpKaon][NSigmaTOF],fnsigmas[SpKaon][NSigmaTPC]);
1571 fTPCTOFProton3d->Fill(track->Pt(),fnsigmas[SpProton][NSigmaTOF],fnsigmas[SpProton][NSigmaTPC]);
1573 if(particletypeMC==SpUndefined) continue;
1575 //Pt, Eta , Phi distribution of the reconstructed identified particles
1578 if (particletypeMC==SpPion)
1580 fPionPt->Fill(track->Pt());
1581 fPionEta->Fill(track->Eta());
1582 fPionPhi->Fill(track->Phi());
1584 if (particletypeMC==SpKaon)
1586 fKaonPt->Fill(track->Pt());
1587 fKaonEta->Fill(track->Eta());
1588 fKaonPhi->Fill(track->Phi());
1590 if (particletypeMC==SpProton)
1592 fProtonPt->Fill(track->Pt());
1593 fProtonEta->Fill(track->Eta());
1594 fProtonPhi->Fill(track->Phi());
1598 //for misidentification fraction calculation(do it with tuneonPID)
1599 if(particletypeMC==SpPion )
1601 if(TMath::Abs(pdgCode)==211) fPioncont->Fill(1.,track->Pt());
1602 if(TMath::Abs(pdgCode)==321) fPioncont->Fill(3.,track->Pt());
1603 if(TMath::Abs(pdgCode)==2212) fPioncont->Fill(5.,track->Pt());
1604 if(TMath::Abs(pdgCode)!=211 && TMath::Abs(pdgCode)!=321 && TMath::Abs(pdgCode)!=2212) fPioncont->Fill(7.,track->Pt());
1606 if(particletypeMC==SpKaon )
1608 if(TMath::Abs(pdgCode)==211) fKaoncont->Fill(1.,track->Pt());
1609 if(TMath::Abs(pdgCode)==321) fKaoncont->Fill(3.,track->Pt());
1610 if(TMath::Abs(pdgCode)==2212) fKaoncont->Fill(5.,track->Pt());
1611 if(TMath::Abs(pdgCode)!=211 && TMath::Abs(pdgCode)!=321 && TMath::Abs(pdgCode)!=2212) fKaoncont->Fill(7.,track->Pt());
1613 if(particletypeMC==SpProton )
1615 if(TMath::Abs(pdgCode)==211) fProtoncont->Fill(1.,track->Pt());
1616 if(TMath::Abs(pdgCode)==321) fProtoncont->Fill(3.,track->Pt());
1617 if(TMath::Abs(pdgCode)==2212) fProtoncont->Fill(5.,track->Pt());
1618 if(TMath::Abs(pdgCode)!=211 && TMath::Abs(pdgCode)!=321 && TMath::Abs(pdgCode)!=2212) fProtoncont->Fill(7.,track->Pt());
1621 //fill tracking efficiency
1624 if(particletypeMC==SpPion || particletypeMC==SpKaon)
1626 if(TMath::Abs(pdgCode)==211 || TMath::Abs(pdgCode)==321) {
1627 fTrackHistEfficiency[3]->Fill(allrecomatchedpid,4);//for mesons
1628 if (((AliAODMCParticle*)recomatched)->IsPhysicalPrimary()) fTrackHistEfficiency[3]->Fill(allrecomatchedpid,3);//for mesons
1631 if(particletypeMC==SpKaon || particletypeMC==SpProton)
1633 if(TMath::Abs(pdgCode)==321 || TMath::Abs(pdgCode)==2212) {
1634 fTrackHistEfficiency[4]->Fill(allrecomatchedpid,4);//for kaons+protons
1635 if (((AliAODMCParticle*)recomatched)->IsPhysicalPrimary()) fTrackHistEfficiency[4]->Fill(allrecomatchedpid,3);
1638 if(particletypeMC==SpPion && TMath::Abs(pdgCode)==211) {
1639 fTrackHistEfficiency[0]->Fill(allrecomatchedpid,4);//for pions
1640 if (((AliAODMCParticle*)recomatched)->IsPhysicalPrimary()) fTrackHistEfficiency[0]->Fill(allrecomatchedpid,3);
1642 if(particletypeMC==SpKaon && TMath::Abs(pdgCode)==321) {
1643 fTrackHistEfficiency[1]->Fill(allrecomatchedpid,4);//for kaons
1644 if (((AliAODMCParticle*)recomatched)->IsPhysicalPrimary()) fTrackHistEfficiency[1]->Fill(allrecomatchedpid,3);
1646 if(particletypeMC==SpProton && TMath::Abs(pdgCode)==2212){
1647 fTrackHistEfficiency[2]->Fill(allrecomatchedpid,4);//for protons
1648 if (((AliAODMCParticle*)recomatched)->IsPhysicalPrimary()) fTrackHistEfficiency[2]->Fill(allrecomatchedpid,3);
1652 if((track->Pt()>=fminPtAsso && track->Pt()<=fmaxPtAsso) || (track->Pt()>=fminPtTrig && track->Pt()<=fmaxPtTrig))//to reduce memory consumption in pool
1654 if (fapplyTrigefficiency || fapplyAssoefficiency)
1655 effmatrix=GetTrackbyTrackeffvalue(track,cent_v0,zvtx,particletypeMC);//get the tracking eff x TOF matching eff x PID eff x contamination factor for identified particles
1656 LRCParticlePID* copy1 = new LRCParticlePID(particletypeMC,track->Charge(),track->Pt(),track->Eta(), track->Phi(),effmatrix);
1657 copy1->SetUniqueID(eventno * 100000 + (Int_t)trackscount);
1658 tracksID->Add(copy1);
1660 }// if(tracktype==1) condition structure ands
1662 }//reco track loop ends
1664 //*************************************************************still in event loop
1666 //same event delta-eta-deltaphi plot
1667 if(fSampleType=="pp") cent_v0=trackscount;//multiplicity
1671 //fill the centrality/multiplicity distribution of the selected events
1672 fhistcentrality->Fill(cent_v0);//*********************************WARNING::binning of cent_v0 is different for pp and pPb/PbPb case
1674 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??????
1676 //count selected events having centrality betn 0-100%
1677 fEventCounter->Fill(9);
1679 //***************************************event no. counting
1680 Bool_t isbaryontrig=kFALSE;
1681 Bool_t ismesontrig=kFALSE;
1682 if(tracksUNID && tracksUNID->GetEntriesFast()>0) fEventno->Fill(cent_v0,zvtx);
1684 if(tracksID && tracksID->GetEntriesFast()>0)
1686 for(Int_t i=0;i<tracksID->GetEntriesFast();i++)
1687 { //trigger loop starts
1688 LRCParticlePID *trig=(LRCParticlePID*)(tracksID->UncheckedAt(i));
1690 if(trig->Pt()<fminPtTrig || trig->Pt()>fmaxPtTrig) continue;
1691 Int_t particlepidtrig=trig->getparticle(); //either 1 or 2
1692 if(particlepidtrig==SpProton) isbaryontrig=kTRUE;
1693 if(particlepidtrig==SpPion) ismesontrig=kTRUE;
1695 if (isbaryontrig) fEventnobaryon->Fill(cent_v0,zvtx);
1696 if (ismesontrig) fEventnomeson->Fill(cent_v0,zvtx);
1699 //same event delte-eta, delta-phi plot
1700 if(tracksUNID && tracksUNID->GetEntriesFast()>0)//hadron triggered correlation
1701 {//same event calculation starts
1702 if(ffilltrigassoUNID) Fillcorrelation(tracksUNID,0,cent_v0,zvtx,weghtval,kFALSE,bSign,fPtOrderDataReco,ftwoTrackEfficiencyCutDataReco,kFALSE,"trigassoUNID");//mixcase=kFALSE (hadron-hadron correlation)
1703 if(tracksID && tracksID->GetEntriesFast()>0 && ffilltrigUNIDassoID) Fillcorrelation(tracksUNID,tracksID,cent_v0,zvtx,weghtval,kFALSE,bSign,fPtOrderDataReco,ftwoTrackEfficiencyCutDataReco,kFALSE,"trigUNIDassoID");//mixcase=kFALSE (hadron-ID correlation)
1706 if(tracksID && tracksID->GetEntriesFast()>0)//ID triggered correlation
1707 {//same event calculation starts
1708 if(tracksUNID && tracksUNID->GetEntriesFast()>0 && ffilltrigIDassoUNID) Fillcorrelation(tracksID,tracksUNID,cent_v0,zvtx,weghtval,kFALSE,bSign,fPtOrderDataReco,ftwoTrackEfficiencyCutDataReco,kFALSE,"trigIDassoUNID");//mixcase=kFALSE (ID-hadron correlation)
1709 if(ffilltrigIDassoID) Fillcorrelation(tracksID,0,cent_v0,zvtx,weghtval,kFALSE,bSign,fPtOrderDataReco,ftwoTrackEfficiencyCutDataReco,kFALSE,"trigIDassoID");//mixcase=kFALSE (ID-ID correlation)
1712 //still in main event loop
1714 if(ffilltrigassoUNID || ffilltrigIDassoUNID){//mixing with unidentified particles
1715 AliEventPool* pool = fPoolMgr->GetEventPool(cent_v0, zvtx);//In the pool there is tracksUNID(i.e associateds are unidentified)
1716 if (pool && pool->IsReady())
1717 {//start mixing only when pool->IsReady
1718 Float_t nmix1=(Float_t)pool->GetCurrentNEvents();
1719 for (Int_t jMix=0; jMix<pool->GetCurrentNEvents(); jMix++)
1720 { //pool event loop start
1721 TObjArray* bgTracks = pool->GetEvent(jMix);
1722 if(!bgTracks) continue;
1723 if(ffilltrigassoUNID && tracksUNID && tracksUNID->GetEntriesFast()>0)//*******************************hadron trggered mixing
1724 Fillcorrelation(tracksUNID,bgTracks,cent_v0,zvtx,nmix1,(jMix == 0),bSign,fPtOrderDataReco,ftwoTrackEfficiencyCutDataReco,kTRUE,"trigassoUNID");//mixcase=kTRUE
1725 if(ffilltrigIDassoUNID && tracksID && tracksID->GetEntriesFast()>0)//***********************************ID trggered mixing
1726 Fillcorrelation(tracksID,bgTracks,cent_v0,zvtx,nmix1,(jMix == 0),bSign,fPtOrderDataReco,ftwoTrackEfficiencyCutDataReco,kTRUE,"trigIDassoUNID");//mixcase=kTRUE
1727 }// pool event loop ends mixing case
1729 } //if pool->IsReady() condition ends mixing case
1732 pool->UpdatePool(CloneAndReduceTrackList(tracksUNID));
1734 }//mixing with unidentified particles
1736 if(ffilltrigUNIDassoID || ffilltrigIDassoID){//mixing with identified particles
1737 AliEventPool* pool1 = fPoolMgr->GetEventPool(cent_v0, zvtx+100);//In the pool1 there is tracksID(i.e associateds are identified)
1738 if (pool1 && pool1->IsReady())
1739 {//start mixing only when pool->IsReady
1740 Float_t nmix2=(Float_t)pool1->GetCurrentNEvents();
1741 for (Int_t jMix=0; jMix<pool1->GetCurrentNEvents(); jMix++)
1742 { //pool event loop start
1743 TObjArray* bgTracks2 = pool1->GetEvent(jMix);
1744 if(!bgTracks2) continue;
1745 if(ffilltrigUNIDassoID && tracksUNID && tracksUNID->GetEntriesFast()>0)
1746 Fillcorrelation(tracksUNID,bgTracks2,cent_v0,zvtx,nmix2,(jMix == 0),bSign,fPtOrderDataReco,ftwoTrackEfficiencyCutDataReco,kTRUE,"trigUNIDassoID");//mixcase=kTRUE
1747 if(ffilltrigIDassoID && tracksID && tracksID->GetEntriesFast()>0)
1748 Fillcorrelation(tracksID,bgTracks2,cent_v0,zvtx,nmix2,(jMix == 0),bSign,fPtOrderDataReco,ftwoTrackEfficiencyCutDataReco,kTRUE,"trigIDassoID");//mixcase=kTRUE
1750 }// pool event loop ends mixing case
1751 } //if pool1->IsReady() condition ends mixing case
1755 pool1->UpdatePool(CloneAndReduceTrackList(tracksID));//ownership of tracksasso is with pool now, don't delete it(tracksUNID is with pool)
1757 }//mixing with identified particles
1759 //no. of events analyzed
1760 fEventCounter->Fill(11);
1763 if(tracksUNID) delete tracksUNID;
1765 if(tracksID) delete tracksID;
1768 PostData(1, fOutput);
1771 //________________________________________________________________________
1772 void AliTwoParticlePIDCorr::doAODevent()
1776 AliVEvent *event = InputEvent();
1777 if (!event) { Printf("ERROR: Could not retrieve event"); return; }
1778 AliAODEvent* aod = dynamic_cast<AliAODEvent*>(event);
1780 AliError("Cannot get the AOD event");
1785 fEventCounter->Fill(1);
1787 // get centrality object and check quality
1790 if(fSampleType=="pPb" || fSampleType=="PbPb")
1792 AliCentrality *centrality=0;
1794 centrality = aod->GetHeader()->GetCentralityP();
1795 // if (centrality->GetQuality() != 0) return ;
1799 cent_v0 = centrality->GetCentralityPercentile(fCentralityMethod);
1807 Float_t bSign = (aod->GetMagneticField() > 0) ? 1 : -1;//for two track efficiency cut in correlation function calculation
1808 Float_t bSign1=aod->GetHeader()->GetMagneticField() ;//for dca cut in ClassifyTrack(), i.e in track loop
1810 // Pileup selection ************************************************
1811 if(frejectPileUp) //applicable only for TPC only tracks,not for hybrid tracks?.
1813 if (fAnalysisUtils && fAnalysisUtils->IsPileUpEvent(aod)) return;
1816 //count events after PileUP cut
1817 fEventCounter->Fill(3);
1819 if (!fPID) return;//this should be available with each event even if we don't do PID selection
1821 //vertex selection(is it fine for PP?)
1822 if ( fVertextype==1){//for pPb basically if(!fAnalysisUtils->IsVertexSelected2013pA(aod)) return;
1823 trkVtx = aod->GetPrimaryVertex();
1824 if (!trkVtx || trkVtx->GetNContributors()<=0) return;
1825 TString vtxTtl = trkVtx->GetTitle();
1826 if (!vtxTtl.Contains("VertexerTracks")) return;
1827 zvtx = trkVtx->GetZ();
1828 const AliAODVertex* spdVtx = aod->GetPrimaryVertexSPD();
1829 if (!spdVtx || spdVtx->GetNContributors()<=0) return;
1830 TString vtxTyp = spdVtx->GetTitle();
1831 Double_t cov[6]={0};
1832 spdVtx->GetCovarianceMatrix(cov);
1833 Double_t zRes = TMath::Sqrt(cov[5]);
1834 if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) return;
1835 if (TMath::Abs(spdVtx->GetZ() - trkVtx->GetZ())>0.5) return;
1837 else if(fVertextype==2) {//for pp and pb-pb case , taken from Jan's code
1838 Int_t nVertex = aod->GetNumberOfVertices();
1840 trkVtx = aod->GetPrimaryVertex();
1841 Int_t nTracksPrim = trkVtx->GetNContributors();
1842 zvtx = trkVtx->GetZ();
1843 //if (fDebug > 1)AliInfo(Form(" Vertex in = %f with %d particles by %s data ...",zVertex,nTracksPrim,vertex->GetName()));
1844 // Reject TPC only vertex
1845 TString name(trkVtx->GetName());
1846 if (name.CompareTo("PrimaryVertex") && name.CompareTo("SPDVertex"))return;
1848 // Select a quality vertex by number of tracks?
1849 if( nTracksPrim < fnTracksVertex ) {
1850 //if (fDebug > 1) AliInfo(" Primary-vertex Selection: event REJECTED ...");
1853 // TODO remove vertexer Z events with dispersion > 0.02: Doesn't work for AOD at present
1854 //if (strcmp(vertex->GetTitle(), "AliVertexerZ") == 0 && vertex->GetDispersion() > 0.02)
1856 // if (fDebug > 1) AliInfo(" Primary-vertex Selection: event ACCEPTED...");
1861 else if(fVertextype==0){//default case
1862 trkVtx = aod->GetPrimaryVertex();
1863 if (!trkVtx || trkVtx->GetNContributors()<=0) return;//proper number of contributors
1864 zvtx = trkVtx->GetZ();
1866 trkVtx->GetCovarianceMatrix(fCov);
1867 if(fCov[5] == 0) return;//proper vertex resolution
1870 AliInfo("Wrong Vertextype set for Primary-vertex Selection: event REJECTED ...");
1871 return;//as there is no proper sample type
1874 fHistQA[0]->Fill((trkVtx->GetX()));fHistQA[1]->Fill((trkVtx->GetY()));fHistQA[2]->Fill((trkVtx->GetZ())); //for trkVtx only before vertex cut |zvtx|<10 cm
1876 //count events having a proper vertex
1877 fEventCounter->Fill(5);
1879 if (TMath::Abs(zvtx) > fzvtxcut) return;
1881 //count events after vertex cut
1882 fEventCounter->Fill(7);
1885 //if(!fAnalysisUtils->IsVertexSelected2013pA(aod)) return;
1887 fHistQA[3]->Fill((trkVtx->GetX()));fHistQA[4]->Fill((trkVtx->GetY()));fHistQA[5]->Fill((trkVtx->GetZ()));//after vertex cut,for trkVtx only
1890 if(!aod) return; //for safety
1892 if(fSampleType=="pPb" || fSampleType=="PbPb") if (cent_v0 < 0) return;//for pp case it is the multiplicity
1894 TObjArray* tracksUNID= new TObjArray;//track info before doing PID
1895 tracksUNID->SetOwner(kTRUE); // IMPORTANT!
1897 TObjArray* tracksID= new TObjArray;//only pions, kaons,protonsi.e. after doing the PID selection
1898 tracksID->SetOwner(kTRUE); // IMPORTANT!
1900 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)
1904 Bool_t fTrigPtmin1=kFALSE;
1905 Bool_t fTrigPtmin2=kFALSE;
1906 Bool_t fTrigPtJet=kFALSE;
1908 for (Int_t itrk = 0; itrk < aod->GetNumberOfTracks(); itrk++)
1909 { //track loop starts for TObjArray(containing track and event information) filling; used for correlation function calculation
1910 AliAODTrack* track = dynamic_cast<AliAODTrack*>(aod->GetTrack(itrk));
1911 if (!track) continue;
1912 fHistQA[11]->Fill(track->GetTPCNcls());
1913 Int_t particletype=-9999;//required for PID filling
1914 Int_t tracktype=ClassifyTrack(track,trkVtx,bSign1);//dcacut=kFALSE,onlyprimary=kFALSE
1915 if(tracktype!=1) continue;
1917 if(!track) continue;//for safety
1919 //check for eta , phi holes
1920 fEtaSpectrasso->Fill(track->Eta(),track->Pt());
1921 fphiSpectraasso->Fill(track->Phi(),track->Pt());
1925 //if no applyefficiency , set the eff factor=1.0
1926 Float_t effmatrix=1.0;
1928 //tag all particles as unidentified that passed filterbit & kinematic cuts
1929 particletype=unidentified;
1932 if(track->Pt()>=fminPtTrig) fTrigPtmin1=kTRUE;
1933 if(track->Pt()>=(fminPtTrig+0.5)) fTrigPtmin2=kTRUE;
1934 if(track->Pt()>=fmaxPtTrig) fTrigPtJet=kTRUE;
1937 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
1940 //to reduce memory consumption in pool
1941 if((track->Pt()>=fminPtAsso && track->Pt()<=fmaxPtAsso) || (track->Pt()>=fminPtTrig && track->Pt()<=fmaxPtTrig))
1943 //Clone & Reduce track list(TObjArray) for unidentified particles
1944 if (fapplyTrigefficiency || fapplyAssoefficiency)//get the trackingefficiency x contamination factor for unidentified particles
1945 effmatrix=GetTrackbyTrackeffvalue(track,cent_v0,zvtx,particletype);
1946 LRCParticlePID* copy = new LRCParticlePID(particletype,track->Charge(),track->Pt(),track->Eta(), track->Phi(),effmatrix);
1947 copy->SetUniqueID(eventno * 100000 + (Int_t)trackscount);
1948 tracksUNID->Add(copy);//track information Storage for UNID correlation function(tracks that pass the filterbit & kinematic cuts only)
1951 //now start the particle identificaion process:)
1953 //track passing filterbit 768 have proper TPC response,or need to be checked explicitly before doing PID????
1955 Float_t dEdx = track->GetTPCsignal();
1956 fHistoTPCdEdx->Fill(track->Pt(), dEdx);
1958 //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)
1959 if(HasTOFPID(track))
1961 Double_t beta = GetBeta(track);
1962 fHistoTOFbeta->Fill(track->Pt(), beta);
1966 //track identification(using nsigma method)
1967 particletype=GetParticle(track,fFIllPIDQAHistos);//*******************************change may be required(It should return only pion,kaon, proton and Spundefined; NOT unidentifed***************be careful)
1970 //2-d TPCTOF map(for each Pt interval)
1971 if(HasTOFPID(track)){
1972 fTPCTOFPion3d->Fill(track->Pt(),fnsigmas[SpPion][NSigmaTOF],fnsigmas[SpPion][NSigmaTPC]);
1973 fTPCTOFKaon3d->Fill(track->Pt(),fnsigmas[SpKaon][NSigmaTOF],fnsigmas[SpKaon][NSigmaTPC]);
1974 fTPCTOFProton3d->Fill(track->Pt(),fnsigmas[SpProton][NSigmaTOF],fnsigmas[SpProton][NSigmaTPC]);
1977 //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!!!!!
1978 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)!!!!!!!!!!!
1980 //Pt, Eta , Phi distribution of the reconstructed identified particles
1983 if (particletype==SpPion)
1985 fPionPt->Fill(track->Pt());
1986 fPionEta->Fill(track->Eta());
1987 fPionPhi->Fill(track->Phi());
1989 if (particletype==SpKaon)
1991 fKaonPt->Fill(track->Pt());
1992 fKaonEta->Fill(track->Eta());
1993 fKaonPhi->Fill(track->Phi());
1995 if (particletype==SpProton)
1997 fProtonPt->Fill(track->Pt());
1998 fProtonEta->Fill(track->Eta());
1999 fProtonPhi->Fill(track->Phi());
2003 if((track->Pt()>=fminPtAsso && track->Pt()<=fmaxPtAsso) || (track->Pt()>=fminPtTrig && track->Pt()<=fmaxPtTrig))
2005 if (fapplyTrigefficiency || fapplyAssoefficiency)
2006 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
2007 LRCParticlePID* copy1 = new LRCParticlePID(particletype,track->Charge(),track->Pt(),track->Eta(), track->Phi(),effmatrix);
2008 copy1->SetUniqueID(eventno * 100000 + (Int_t)trackscount);
2009 tracksID->Add(copy1);
2011 } //track loop ends but still in event loop
2013 if(trackscount<1.0){
2014 if(tracksUNID) delete tracksUNID;
2015 if(tracksID) delete tracksID;
2019 if (fTrigPtmin1) fhistJetTrigestimate->Fill(cent_v0,0.0);
2020 if (fTrigPtmin2) fhistJetTrigestimate->Fill(cent_v0,2.0);
2021 if (fTrigPtJet) fhistJetTrigestimate->Fill(cent_v0,4.0);
2023 Float_t weightval=1.0;
2026 // cout<<fminPtAsso<<"***"<<fmaxPtAsso<<"*********************"<<fminPtTrig<<"***"<<fmaxPtTrig<<"*****************"<<kTrackVariablesPair<<endl;
2027 if(fSampleType=="pp") cent_v0=trackscount;//multiplicity
2029 //fill the centrality/multiplicity distribution of the selected events
2030 fhistcentrality->Fill(cent_v0);//*********************************WARNING::binning of cent_v0 is different for pp and pPb/PbPb case
2032 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??????
2034 //count selected events having centrality betn 0-100%
2035 fEventCounter->Fill(9);
2037 //***************************************event no. counting
2038 Bool_t isbaryontrig=kFALSE;
2039 Bool_t ismesontrig=kFALSE;
2040 if(tracksUNID && tracksUNID->GetEntriesFast()>0) fEventno->Fill(cent_v0,zvtx);
2042 if(tracksID && tracksID->GetEntriesFast()>0)
2044 for(Int_t i=0;i<tracksID->GetEntriesFast();i++)
2045 { //trigger loop starts
2046 LRCParticlePID *trig=(LRCParticlePID*)(tracksID->UncheckedAt(i));
2048 if(trig->Pt()<fminPtTrig || trig->Pt()>fmaxPtTrig) continue;
2049 Int_t particlepidtrig=trig->getparticle(); //either 1 or 2
2050 if(particlepidtrig==SpProton) isbaryontrig=kTRUE;
2051 if(particlepidtrig==SpPion) ismesontrig=kTRUE;
2053 if (isbaryontrig) fEventnobaryon->Fill(cent_v0,zvtx);
2054 if (ismesontrig) fEventnomeson->Fill(cent_v0,zvtx);
2058 //same event delta-eta-deltaphi plot
2060 if(tracksUNID && tracksUNID->GetEntriesFast()>0)//hadron triggered correlation
2061 {//same event calculation starts
2062 if(ffilltrigassoUNID) Fillcorrelation(tracksUNID,0,cent_v0,zvtx,weightval,kFALSE,bSign,fPtOrderDataReco,ftwoTrackEfficiencyCutDataReco,kFALSE,"trigassoUNID");//mixcase=kFALSE (hadron-hadron correlation)
2063 if(tracksID && tracksID->GetEntriesFast()>0 && ffilltrigUNIDassoID) Fillcorrelation(tracksUNID,tracksID,cent_v0,zvtx,weightval,kFALSE,bSign,fPtOrderDataReco,ftwoTrackEfficiencyCutDataReco,kFALSE,"trigUNIDassoID");//mixcase=kFALSE (hadron-ID correlation)
2066 if(tracksID && tracksID->GetEntriesFast()>0)//ID triggered correlation
2067 {//same event calculation starts
2068 if(tracksUNID && tracksUNID->GetEntriesFast()>0 && ffilltrigIDassoUNID) Fillcorrelation(tracksID,tracksUNID,cent_v0,zvtx,weightval,kFALSE,bSign,fPtOrderDataReco,ftwoTrackEfficiencyCutDataReco,kFALSE,"trigIDassoUNID");//mixcase=kFALSE (ID-hadron correlation)
2069 if(ffilltrigIDassoID) Fillcorrelation(tracksID,0,cent_v0,zvtx,weightval,kFALSE,bSign,fPtOrderDataReco,ftwoTrackEfficiencyCutDataReco,kFALSE,"trigIDassoID");//mixcase=kFALSE (ID-ID correlation)
2072 //still in main event loop
2076 if(ffilltrigassoUNID || ffilltrigIDassoUNID){//mixing with unidentified particles
2077 AliEventPool* pool = fPoolMgr->GetEventPool(cent_v0, zvtx);//In the pool there is tracksUNID(i.e associateds are unidentified)
2078 if (pool && pool->IsReady())
2079 {//start mixing only when pool->IsReady
2080 Float_t nmix1=(Float_t)pool->GetCurrentNEvents();
2081 for (Int_t jMix=0; jMix<pool->GetCurrentNEvents(); jMix++)
2082 { //pool event loop start
2083 TObjArray* bgTracks = pool->GetEvent(jMix);
2084 if(!bgTracks) continue;
2085 if(ffilltrigassoUNID && tracksUNID && tracksUNID->GetEntriesFast()>0)//*******************************hadron trggered mixing
2086 Fillcorrelation(tracksUNID,bgTracks,cent_v0,zvtx,nmix1,(jMix == 0),bSign,fPtOrderDataReco,ftwoTrackEfficiencyCutDataReco,kTRUE,"trigassoUNID");//mixcase=kTRUE
2087 if(ffilltrigIDassoUNID && tracksID && tracksID->GetEntriesFast()>0)//***********************************ID trggered mixing
2088 Fillcorrelation(tracksID,bgTracks,cent_v0,zvtx,nmix1,(jMix == 0),bSign,fPtOrderDataReco,ftwoTrackEfficiencyCutDataReco,kTRUE,"trigIDassoUNID");//mixcase=kTRUE
2089 }// pool event loop ends mixing case
2090 } //if pool->IsReady() condition ends mixing case
2093 pool->UpdatePool(CloneAndReduceTrackList(tracksUNID));
2095 }//mixing with unidentified particles
2098 if(ffilltrigUNIDassoID || ffilltrigIDassoID){//mixing with identified particles
2099 AliEventPool* pool1 = fPoolMgr->GetEventPool(cent_v0, zvtx+100);//In the pool1 there is tracksID(i.e associateds are identified)
2100 if (pool1 && pool1->IsReady())
2101 {//start mixing only when pool->IsReady
2102 Float_t nmix2=(Float_t)pool1->GetCurrentNEvents();
2103 for (Int_t jMix=0; jMix<pool1->GetCurrentNEvents(); jMix++)
2104 { //pool event loop start
2105 TObjArray* bgTracks2 = pool1->GetEvent(jMix);
2106 if(!bgTracks2) continue;
2107 if(ffilltrigUNIDassoID && tracksUNID && tracksUNID->GetEntriesFast()>0)
2108 Fillcorrelation(tracksUNID,bgTracks2,cent_v0,zvtx,nmix2,(jMix == 0),bSign,fPtOrderDataReco,ftwoTrackEfficiencyCutDataReco,kTRUE,"trigUNIDassoID");//mixcase=kTRUE
2109 if(ffilltrigIDassoID && tracksID && tracksID->GetEntriesFast()>0)
2110 Fillcorrelation(tracksID,bgTracks2,cent_v0,zvtx,nmix2,(jMix == 0),bSign,fPtOrderDataReco,ftwoTrackEfficiencyCutDataReco,kTRUE,"trigIDassoID");//mixcase=kTRUE
2112 }// pool event loop ends mixing case
2113 } //if pool1->IsReady() condition ends mixing case
2117 pool1->UpdatePool(CloneAndReduceTrackList(tracksID));//ownership of tracksasso is with pool now, don't delete it(tracksUNID is with pool)
2119 }//mixing with identified particles
2122 //no. of events analyzed
2123 fEventCounter->Fill(11);
2125 //still in main event loop
2128 if(tracksUNID) delete tracksUNID;
2130 if(tracksID) delete tracksID;
2133 PostData(1, fOutput);
2135 } // *************************event loop ends******************************************//_______________________________________________________________________
2136 TObjArray* AliTwoParticlePIDCorr::CloneAndReduceTrackList(TObjArray* tracks)
2138 // clones a track list by using AliDPhiBasicParticle which uses much less memory (used for event mixing)
2140 TObjArray* tracksClone = new TObjArray;
2141 tracksClone->SetOwner(kTRUE);
2143 for (Int_t i=0; i<tracks->GetEntriesFast(); i++)
2145 LRCParticlePID* particle = (LRCParticlePID*) tracks->UncheckedAt(i);
2146 LRCParticlePID* copy100 = new LRCParticlePID(particle->getparticle(),particle->Charge(), particle->Pt(),particle->Eta(), particle->Phi(), particle->geteffcorrectionval());
2147 copy100->SetUniqueID(particle->GetUniqueID());
2148 tracksClone->Add(copy100);
2154 //--------------------------------------------------------------------------------
2155 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)
2158 //before calling this function check that either trackstrig & tracksasso are available
2160 // Eta() is extremely time consuming, therefore cache it for the inner loop here:
2161 TObjArray* input = (tracksasso) ? tracksasso : trackstrig;
2162 TArrayF eta(input->GetEntriesFast());
2163 for (Int_t i=0; i<input->GetEntriesFast(); i++)
2164 eta[i] = ((LRCParticlePID*) input->UncheckedAt(i))->Eta();
2167 Int_t jmax=trackstrig->GetEntriesFast();
2169 jmax=tracksasso->GetEntriesFast();
2171 // identify K, Lambda candidates and flag those particles
2172 // a TObject bit is used for this
2173 const UInt_t kResonanceDaughterFlag = 1 << 14;
2174 if (fRejectResonanceDaughters > 0)
2176 Double_t resonanceMass = -1;
2177 Double_t massDaughter1 = -1;
2178 Double_t massDaughter2 = -1;
2179 const Double_t interval = 0.02;
2180 switch (fRejectResonanceDaughters)
2182 case 1: resonanceMass = 0.9; massDaughter1 = 0.1396; massDaughter2 = 0.9383; break; // method test
2183 case 2: resonanceMass = 0.4976; massDaughter1 = 0.1396; massDaughter2 = massDaughter1; break; // k0
2184 case 3: resonanceMass = 1.115; massDaughter1 = 0.1396; massDaughter2 = 0.9383; break; // lambda
2185 default: AliFatal(Form("Invalid setting %d", fRejectResonanceDaughters));
2188 for (Int_t i=0; i<trackstrig->GetEntriesFast(); i++)
2189 trackstrig->UncheckedAt(i)->ResetBit(kResonanceDaughterFlag);
2190 for (Int_t i=0; tracksasso->GetEntriesFast(); i++)
2191 tracksasso->UncheckedAt(i)->ResetBit(kResonanceDaughterFlag);
2193 for (Int_t i=0; i<trackstrig->GetEntriesFast(); i++)
2195 LRCParticlePID *trig=(LRCParticlePID*)(trackstrig->UncheckedAt(i));
2196 for (Int_t j=0; tracksasso->GetEntriesFast(); j++)
2198 LRCParticlePID *asso=(LRCParticlePID*)(tracksasso->UncheckedAt(j));
2200 // check if both particles point to the same element (does not occur for mixed events, but if subsets are mixed within the same event)
2201 if (trig->IsEqual(asso)) continue;
2203 if (trig->Charge() * asso->Charge() > 0) continue;
2205 Float_t mass = GetInvMassSquaredCheap(trig->Pt(), trig->Eta(), trig->Phi(), asso->Pt(), asso->Eta(), asso->Phi(), massDaughter1, massDaughter2);
2207 if (TMath::Abs(mass - resonanceMass*resonanceMass) < interval*5)
2209 mass = GetInvMassSquared(trig->Pt(), trig->Eta(), trig->Phi(), asso->Pt(), asso->Eta(), asso->Phi(), massDaughter1, massDaughter2);
2211 if (mass > (resonanceMass-interval)*(resonanceMass-interval) && mass < (resonanceMass+interval)*(resonanceMass+interval))
2213 trig->SetBit(kResonanceDaughterFlag);
2214 asso->SetBit(kResonanceDaughterFlag);
2216 // Printf("Flagged %d %d %f", i, j, TMath::Sqrt(mass));
2223 //Select the highest Pt trigger particle in an event (within a given Pt trigger range)
2225 Float_t TriggerPtMin=fminPtTrig;
2226 Float_t TriggerPtMax=fmaxPtTrig;
2227 Int_t HighestPtTriggerIndx=-99999;
2228 TH1* triggerWeighting = 0;
2230 if(fSelectHighestPtTrig || fWeightPerEvent)//**************add this data member to the constructor
2232 if (fWeightPerEvent)
2235 if(ffilltrigassoUNID || ffilltrigUNIDassoID || ffilltrigIDassoUNID || ffilltrigIDassoID) axis = fTHnTrigcount->GetGrid(0)->GetGrid()->GetAxis(2);
2236 if((fAnalysisType =="MCAOD") && ffilltrigIDassoIDMCTRUTH) axis = fTHnTrigcountMCTruthPrim->GetGrid(0)->GetGrid()->GetAxis(2);
2237 triggerWeighting = new TH1F("triggerWeighting", "", axis->GetNbins(), axis->GetXbins()->GetArray());
2239 for(Int_t i=0;i<trackstrig->GetEntriesFast();i++)
2240 { //trigger loop starts(highest Pt trigger selection)
2241 LRCParticlePID *trig=(LRCParticlePID*)(trackstrig->UncheckedAt(i));
2243 Float_t trigpt=trig->Pt();
2244 //to avoid overflow qnd underflow
2245 if(trigpt<fminPtTrig || trigpt>fmaxPtTrig) continue;
2246 Int_t particlepidtrig=trig->getparticle();
2247 if(fTriggerSpeciesSelection){ if (particlepidtrig!=fTriggerSpecies) continue;}
2249 Float_t trigeta=trig->Eta();
2251 // some optimization
2252 if (fTriggerRestrictEta > 0 && TMath::Abs(trigeta) > fTriggerRestrictEta)
2255 if (fOnlyOneEtaSide != 0)
2257 if (fOnlyOneEtaSide * trigeta < 0)
2260 if (fTriggerSelectCharge != 0)
2261 if (trig->Charge() * fTriggerSelectCharge < 0)
2264 if (fRejectResonanceDaughters > 0)
2265 if (trig->TestBit(kResonanceDaughterFlag)) continue;
2267 if(fSelectHighestPtTrig){
2268 if(trigpt>TriggerPtMin && trigpt<=TriggerPtMax)
2270 HighestPtTriggerIndx=(Int_t)trig->GetUniqueID();
2271 TriggerPtMin=trigpt;
2275 if (fWeightPerEvent) triggerWeighting->Fill(trigpt);
2277 }//trigger loop ends(highest Pt trigger selection)
2279 }//******************(fSelectHighestPtTrig || fWeightPerEvent) condition ends
2282 //two particle correlation filling
2283 for(Int_t i=0;i<trackstrig->GetEntriesFast();i++)
2284 { //trigger loop starts
2285 LRCParticlePID *trig=(LRCParticlePID*)(trackstrig->UncheckedAt(i));
2287 Float_t trigpt=trig->Pt();
2288 //to avoid overflow qnd underflow
2289 if(trigpt<fminPtTrig || trigpt>fmaxPtTrig) continue;
2290 Int_t particlepidtrig=trig->getparticle();
2291 if(fTriggerSpeciesSelection){ if (particlepidtrig!=fTriggerSpecies) continue;}
2293 Float_t trigeta=trig->Eta();
2295 // some optimization
2296 if (fTriggerRestrictEta > 0 && TMath::Abs(trigeta) > fTriggerRestrictEta)
2299 if (fOnlyOneEtaSide != 0)
2301 if (fOnlyOneEtaSide * trigeta < 0)
2304 if (fTriggerSelectCharge != 0)
2305 if (trig->Charge() * fTriggerSelectCharge < 0)
2308 if (fRejectResonanceDaughters > 0)
2309 if (trig->TestBit(kResonanceDaughterFlag)) continue;
2311 if(fSelectHighestPtTrig && HighestPtTriggerIndx!=-99999) {
2312 if(trig->GetUniqueID()!=(UInt_t)HighestPtTriggerIndx) continue;
2315 Float_t trigphi=trig->Phi();
2316 Float_t trackefftrig=1.0;
2317 if(fapplyTrigefficiency) trackefftrig=trig->geteffcorrectionval();
2318 //cout<<"*******************trackefftrig="<<trackefftrig<<endl;
2321 if(fcontainPIDtrig) dim=4;
2322 trigval= new Double_t[dim];
2325 trigval[2] = trigpt;
2326 if(fcontainPIDtrig) trigval[3] = particlepidtrig;
2328 if (fWeightPerEvent)
2330 // leads effectively to a filling of one entry per filled trigger particle pT bin
2331 Int_t weightBin = triggerWeighting->GetXaxis()->FindBin(trigval[2]);
2332 // Printf("Using weight %f", triggerWeighting->GetBinContent(weightBin));
2333 trackefftrig *= triggerWeighting->GetBinContent(weightBin);
2337 //trigger particle counting for both same and mixed event case;;;;;step=0->same event case;;;;;step=1->mixed event case;;;;;;
2338 if(ffilltrigassoUNID==kTRUE && ffilltrigUNIDassoID==kTRUE){
2339 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==kTRUE && ffilltrigUNIDassoID==kFALSE){
2345 if(fillup=="trigassoUNID" )
2347 if(mixcase==kFALSE) fTHnTrigcount->Fill(trigval,0,1.0/trackefftrig);
2348 if(mixcase==kTRUE && firstTime) fTHnTrigcount->Fill(trigval,1,1.0/trackefftrig);
2351 if(ffilltrigassoUNID==kFALSE && ffilltrigUNIDassoID==kTRUE){
2352 if(fillup=="trigUNIDassoID")
2354 if(mixcase==kFALSE) fTHnTrigcount->Fill(trigval,0,1.0/trackefftrig);
2355 if(mixcase==kTRUE && firstTime) fTHnTrigcount->Fill(trigval,1,1.0/trackefftrig);
2358 //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
2359 if(ffilltrigIDassoUNID==kTRUE && ffilltrigIDassoID==kTRUE){
2360 if(fillup=="trigIDassoID")
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==kTRUE && ffilltrigIDassoID==kFALSE){
2367 if(fillup=="trigIDassoUNID" )
2369 if(mixcase==kFALSE) fTHnTrigcount->Fill(trigval,0,1.0/trackefftrig);
2370 if(mixcase==kTRUE && firstTime) fTHnTrigcount->Fill(trigval,1,1.0/trackefftrig);
2373 if(ffilltrigIDassoUNID==kFALSE && ffilltrigIDassoID==kTRUE){
2374 if(fillup=="trigIDassoID")
2376 if(mixcase==kFALSE) fTHnTrigcount->Fill(trigval,0,1.0/trackefftrig);
2377 if(mixcase==kTRUE && firstTime) fTHnTrigcount->Fill(trigval,1,1.0/trackefftrig);
2381 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!!!!
2382 if(mixcase==kFALSE) fTHnTrigcountMCTruthPrim->Fill(trigval,0,1.0/trackefftrig);
2383 if(mixcase==kTRUE && firstTime) fTHnTrigcountMCTruthPrim->Fill(trigval,1,1.0/trackefftrig);
2386 //asso loop starts within trigger loop
2387 for(Int_t j=0;j<jmax;j++)
2389 LRCParticlePID *asso=0;
2391 asso=(LRCParticlePID*)(trackstrig->UncheckedAt(j));
2393 asso=(LRCParticlePID*)(tracksasso->UncheckedAt(j));
2397 //to avoid overflow qnd underflow
2398 if(asso->Pt()<fminPtAsso || asso->Pt()>fmaxPtAsso) continue;//***********************Important
2400 //if(fmaxPtAsso==fminPtTrig) {if(asso->Pt()==fminPtTrig) continue;}//******************Think about it!
2402 if(!tracksasso && j==i) continue;
2404 // 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)
2405 // if (tracksasso && trig->IsEqual(asso)) continue;
2407 if (tracksasso && (trig->GetUniqueID()==asso->GetUniqueID())) continue;
2410 if (asso->Pt() >= trig->Pt()) continue;
2412 Int_t particlepidasso=asso->getparticle();
2413 if(fAssociatedSpeciesSelection){ if (particlepidasso!=fAssociatedSpecies) continue;}
2416 if (fAssociatedSelectCharge != 0)
2417 if (asso->Charge() * fAssociatedSelectCharge < 0) continue;
2419 if (fSelectCharge > 0)
2422 if (fSelectCharge == 1 && asso->Charge() * trig->Charge() > 0)
2426 if (fSelectCharge == 2 && asso->Charge() * trig->Charge() < 0)
2432 if (trigeta < 0 && asso->Eta() < trigeta)
2434 if (trigeta > 0 && asso->Eta() > trigeta)
2438 if (fRejectResonanceDaughters > 0)
2439 if (asso->TestBit(kResonanceDaughterFlag))
2441 // Printf("Skipped j=%d", j);
2446 if (fCutConversions && asso->Charge() * trig->Charge() < 0)
2448 Float_t mass = GetInvMassSquaredCheap(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j], asso->Phi(), 0.510e-3, 0.510e-3);
2452 mass = GetInvMassSquared(trig->Pt(), trigeta, trig->Phi(), asso->Pt(), eta[j], asso->Phi(), 0.510e-3, 0.510e-3);
2454 fControlConvResoncances->Fill(0.0, mass);
2456 if (mass < 0.04*0.04)
2462 if (fCutResonances && asso->Charge() * trig->Charge() < 0)
2464 Float_t mass = GetInvMassSquaredCheap(trig->Pt(), trigeta, trig->Phi(), asso->Pt(), eta[j], asso->Phi(), 0.1396, 0.1396);
2466 const Float_t kK0smass = 0.4976;
2468 if (TMath::Abs(mass - kK0smass*kK0smass) < 0.1)
2470 mass = GetInvMassSquared(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j], asso->Phi(), 0.1396, 0.1396);
2472 fControlConvResoncances->Fill(1, mass - kK0smass*kK0smass);
2474 if (mass > (kK0smass-0.02)*(kK0smass-0.02) && mass < (kK0smass+0.02)*(kK0smass+0.02))
2480 if (fCutResonances && asso->Charge() * trig->Charge() < 0)
2482 Float_t mass1 = GetInvMassSquaredCheap(trig->Pt(), trigeta, trig->Phi(), asso->Pt(), eta[j], asso->Phi(), 0.1396, 0.9383);
2483 Float_t mass2 = GetInvMassSquaredCheap(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j] , asso->Phi(), 0.9383, 0.1396);
2485 const Float_t kLambdaMass = 1.115;
2487 if (TMath::Abs(mass1 - kLambdaMass*kLambdaMass) < 0.1)
2489 mass1 = GetInvMassSquared(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j], asso->Phi(), 0.1396, 0.9383);
2491 fControlConvResoncances->Fill(2, mass1 - kLambdaMass*kLambdaMass);
2493 if (mass1 > (kLambdaMass-0.02)*(kLambdaMass-0.02) && mass1 < (kLambdaMass+0.02)*(kLambdaMass+0.02))
2496 if (TMath::Abs(mass2 - kLambdaMass*kLambdaMass) < 0.1)
2498 mass2 = GetInvMassSquared(trig->Pt(), trigeta, trig->Phi(), asso->Pt(),eta[j] , asso->Phi(), 0.9383, 0.1396);
2500 fControlConvResoncances->Fill(2, mass2 - kLambdaMass*kLambdaMass);
2502 if (mass2 > (kLambdaMass-0.02)*(kLambdaMass-0.02) && mass2 < (kLambdaMass+0.02)*(kLambdaMass+0.02))
2507 if (twoTrackEfficiencyCut)
2509 // the variables & cuthave been developed by the HBT group
2510 // see e.g. https://indico.cern.ch/materialDisplay.py?contribId=36&sessionId=6&materialId=slides&confId=142700
2511 Float_t phi1 = trig->Phi();
2512 Float_t pt1 = trig->Pt();
2513 Float_t charge1 = trig->Charge();
2514 Float_t phi2 = asso->Phi();
2515 Float_t pt2 = asso->Pt();
2516 Float_t charge2 = asso->Charge();
2518 Float_t deta= trigeta - eta[j];
2521 if (TMath::Abs(deta) < twoTrackEfficiencyCutValue * 2.5 * 3)
2524 // check first boundaries to see if is worth to loop and find the minimum
2525 Float_t dphistar1 = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, 0.8, bSign);
2526 Float_t dphistar2 = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, 2.5, bSign);
2528 const Float_t kLimit = twoTrackEfficiencyCutValue * 3;
2530 Float_t dphistarminabs = 1e5;
2531 Float_t dphistarmin = 1e5;
2533 if (TMath::Abs(dphistar1) < kLimit || TMath::Abs(dphistar2) < kLimit || dphistar1 * dphistar2 < 0)
2535 for (Double_t rad=0.8; rad<2.51; rad+=0.01)
2537 Float_t dphistar = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, rad, bSign);
2539 Float_t dphistarabs = TMath::Abs(dphistar);
2541 if (dphistarabs < dphistarminabs)
2543 dphistarmin = dphistar;
2544 dphistarminabs = dphistarabs;
2548 if (dphistarminabs < twoTrackEfficiencyCutValue && TMath::Abs(deta) < twoTrackEfficiencyCutValue)
2550 // 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);
2553 //fTwoTrackDistancePt[1]->Fill(deta, dphistarmin, TMath::Abs(pt1 - pt2));
2559 Float_t weightperevent=weight;
2560 Float_t trackeffasso=1.0;
2561 if(fapplyAssoefficiency) trackeffasso=asso->geteffcorrectionval();
2562 //cout<<"*******************trackeffasso="<<trackeffasso<<endl;
2563 Float_t deleta=trigeta-eta[j];
2564 Float_t delphi=PhiRange(trigphi-asso->Phi());
2566 //here get the two particle efficiency correction factor
2567 Float_t effweight=trackefftrig*trackeffasso*weightperevent;
2568 // if(mixcase==kFALSE) cout<<"*******************effweight="<<effweight<<endl;
2570 vars= new Double_t[kTrackVariablesPair];
2577 if(fcontainPIDtrig && !fcontainPIDasso) vars[6]=particlepidtrig;
2578 if(!fcontainPIDtrig && fcontainPIDasso) vars[6]=particlepidasso;
2579 if(fcontainPIDtrig && fcontainPIDasso){
2580 vars[6]=particlepidtrig;
2581 vars[7]=particlepidasso;
2584 if (fWeightPerEvent)
2586 Int_t weightBin = triggerWeighting->GetXaxis()->FindBin(vars[2]);
2587 // Printf("Using weight %f", triggerWeighting->GetBinContent(weightBin));
2588 effweight *= triggerWeighting->GetBinContent(weightBin);
2592 //Fill Correlation ThnSparses
2593 if(fillup=="trigassoUNID")
2595 if(mixcase==kFALSE) fTHnCorrUNID->Fill(vars,0,1.0/effweight);
2596 if(mixcase==kTRUE) fTHnCorrUNIDmix->Fill(vars,0,1.0/effweight);
2598 if(fillup=="trigIDassoID")
2600 if(mixcase==kFALSE) fTHnCorrID->Fill(vars,0,1.0/effweight);
2601 if(mixcase==kTRUE) fTHnCorrIDmix->Fill(vars,0,1.0/effweight);
2603 if(fillup=="trigIDassoIDMCTRUTH")//******************************************for TRUTH MC particles
2604 {//in this case effweight should be 1 always
2605 if(mixcase==kFALSE) fCorrelatonTruthPrimary->Fill(vars,0,1.0/effweight);
2606 if(mixcase==kTRUE) fCorrelatonTruthPrimarymix->Fill(vars,0,1.0/effweight);
2608 if(fillup=="trigIDassoUNID" || fillup=="trigUNIDassoID")//****************************be careful
2610 if(mixcase==kFALSE) fTHnCorrIDUNID->Fill(vars,0,1.0/effweight);
2611 if(mixcase==kTRUE) fTHnCorrIDUNIDmix->Fill(vars,0,1.0/effweight);
2617 }//trigger loop ends
2619 if (triggerWeighting)
2621 delete triggerWeighting;
2622 triggerWeighting = 0;
2626 //--------------------------------------------------------------------------------
2627 Float_t AliTwoParticlePIDCorr::GetTrackbyTrackeffvalue(AliAODTrack* track,Double_t cent,Float_t evzvtx, Int_t parpid)
2629 //This function is called only when applyefficiency=kTRUE; also ensure that "track" is present before calling that function
2631 Float_t effvalue=1.;
2633 if(parpid==unidentified)
2635 effVars[0] = effcorection[5]->GetAxis(0)->FindBin(cent);
2636 effVars[1] = effcorection[5]->GetAxis(1)->FindBin(evzvtx);
2637 effVars[2] = effcorection[5]->GetAxis(2)->FindBin(track->Pt());
2638 effVars[3] = effcorection[5]->GetAxis(3)->FindBin(track->Eta());
2639 effvalue=effcorection[5]->GetBinContent(effVars);
2641 if(parpid==SpPion || parpid==SpKaon)
2643 if(fmesoneffrequired && !fkaonprotoneffrequired && track->Pt()>=fminPtComboeff && track->Pt()<=fmaxPtComboeff)
2645 effVars[0] = effcorection[3]->GetAxis(0)->FindBin(cent);
2646 effVars[1] = effcorection[3]->GetAxis(1)->FindBin(evzvtx);
2647 effVars[2] = effcorection[3]->GetAxis(2)->FindBin(track->Pt());
2648 effVars[3] = effcorection[3]->GetAxis(3)->FindBin(track->Eta());
2649 effvalue=effcorection[3]->GetBinContent(effVars);
2654 effVars[0] = effcorection[0]->GetAxis(0)->FindBin(cent);
2655 effVars[1] = effcorection[0]->GetAxis(1)->FindBin(evzvtx);
2656 effVars[2] = effcorection[0]->GetAxis(2)->FindBin(track->Pt());
2657 effVars[3] = effcorection[0]->GetAxis(3)->FindBin(track->Eta());
2658 effvalue=effcorection[0]->GetBinContent(effVars);
2663 effVars[0] = effcorection[1]->GetAxis(0)->FindBin(cent);
2664 effVars[1] = effcorection[1]->GetAxis(1)->FindBin(evzvtx);
2665 effVars[2] = effcorection[1]->GetAxis(2)->FindBin(track->Pt());
2666 effVars[3] = effcorection[1]->GetAxis(3)->FindBin(track->Eta());
2667 effvalue=effcorection[1]->GetBinContent(effVars);
2672 if(parpid==SpProton)
2674 effVars[0] = effcorection[2]->GetAxis(0)->FindBin(cent);
2675 effVars[1] = effcorection[2]->GetAxis(1)->FindBin(evzvtx);
2676 effVars[2] = effcorection[2]->GetAxis(2)->FindBin(track->Pt());
2677 effVars[3] = effcorection[2]->GetAxis(3)->FindBin(track->Eta());
2678 effvalue=effcorection[2]->GetBinContent(effVars);
2681 if(fkaonprotoneffrequired && !fmesoneffrequired && track->Pt()>=fminPtComboeff && track->Pt()<=fmaxPtComboeff)
2683 if(parpid==SpProton || parpid==SpKaon)
2685 effVars[0] = effcorection[4]->GetAxis(0)->FindBin(cent);
2686 effVars[1] = effcorection[4]->GetAxis(1)->FindBin(evzvtx);
2687 effVars[2] = effcorection[4]->GetAxis(2)->FindBin(track->Pt());
2688 effVars[3] = effcorection[4]->GetAxis(3)->FindBin(track->Eta());
2689 effvalue=effcorection[4]->GetBinContent(effVars);
2692 // Printf("%d %d %d %d %f", effVars[0], effVars[1], effVars[2], effVars[3], fEfficiencyCorrectionAssociated->GetBinContent(effVars));
2693 if(effvalue==0.) effvalue=1.;
2698 //-----------------------------------------------------------------------
2700 Int_t AliTwoParticlePIDCorr::ClassifyTrack(AliAODTrack* track,AliAODVertex* vertex,Float_t magfield)
2703 if(!track) return 0;
2704 Bool_t trackOK = track->TestFilterBit(fFilterBit);
2705 if(!trackOK) return 0;
2706 if (fTrackStatus != 0 && !CheckTrack(track)) return 0;
2707 //select only primary traks(for data & reco MC tracks)
2708 if(fonlyprimarydatareco && track->GetType()!=AliAODTrack::kPrimary) return 0;
2709 if(track->Charge()==0) return 0;
2710 fHistQA[12]->Fill(track->GetTPCNcls());
2713 dz = track->ZAtDCA();
2714 fHistQA[6]->Fill(dxy);
2715 fHistQA[7]->Fill(dz);
2716 Float_t chi2ndf = track->Chi2perNDF();
2717 fHistQA[13]->Fill(chi2ndf);
2718 Float_t nCrossedRowsTPC = track->GetTPCClusterInfo(2,1);
2719 fHistQA[14]->Fill(nCrossedRowsTPC);
2720 //Float_t ratioCrossedRowsOverFindableClustersTPC = 1.0;
2721 if (track->GetTPCNclsF()>0) {
2722 Float_t ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC/track->GetTPCNclsF();
2723 fHistQA[15]->Fill(ratioCrossedRowsOverFindableClustersTPC);
2726 Float_t pt=track->Pt();
2727 if(pt< fminPt || pt> fmaxPt) return 0;
2728 if(TMath::Abs(track->Eta())> fmaxeta) return 0;
2729 if(track->Phi()<0. || track->Phi()>2*TMath::Pi()) return 0;
2730 //if (!HasTPCPID(track)) return 0;//trigger & associated particles must have TPC PID,Is it required
2732 if (fdcacut && fDCAXYCut)
2739 AliAODTrack* clone =(AliAODTrack*) track->Clone();
2740 Bool_t success = clone->PropagateToDCA(vertex, magfield, fdcacutvalue, pos, covar);
2745 // Printf("%f", ((AliAODTrack*)part)->DCA());
2746 // Printf("%f", pos[0]);
2747 if (TMath::Abs(pos[0]) > fDCAXYCut->Eval(track->Pt()))
2751 if (fSharedClusterCut >= 0)
2753 Double_t frac = Double_t(((AliAODTrack*)track)->GetTPCnclsS()) / Double_t(((AliAODTrack*)track)->GetTPCncls());
2754 if (frac > fSharedClusterCut)
2757 fHistQA[8]->Fill(pt);
2758 fHistQA[9]->Fill(track->Eta());
2759 fHistQA[10]->Fill(track->Phi());
2762 //________________________________________________________________________________
2763 void AliTwoParticlePIDCorr::CalculateNSigmas(AliAODTrack *track, Bool_t FIllQAHistos)
2765 //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 )
2766 Float_t pt=track->Pt();
2768 //it is assumed that every track that passed the filterbit have proper TPC response(!!)
2769 Float_t nsigmaTPCkPion =fPID->NumberOfSigmasTPC(track, AliPID::kPion);
2770 Float_t nsigmaTPCkKaon =fPID->NumberOfSigmasTPC(track, AliPID::kKaon);
2771 Float_t nsigmaTPCkProton =fPID->NumberOfSigmasTPC(track, AliPID::kProton);
2773 Float_t nsigmaTOFkProton=999.,nsigmaTOFkKaon=999.,nsigmaTOFkPion=999.;
2774 Float_t nsigmaTPCTOFkProton=999.,nsigmaTPCTOFkKaon=999.,nsigmaTPCTOFkPion=999.;
2776 if(HasTOFPID(track) && pt>fPtTOFPIDmin)
2779 nsigmaTOFkPion =fPID->NumberOfSigmasTOF(track, AliPID::kPion);
2780 nsigmaTOFkKaon =fPID->NumberOfSigmasTOF(track, AliPID::kKaon);
2781 nsigmaTOFkProton =fPID->NumberOfSigmasTOF(track, AliPID::kProton);
2783 nsigmaTPCTOFkPion = TMath::Sqrt(nsigmaTPCkPion*nsigmaTPCkPion+nsigmaTOFkPion*nsigmaTOFkPion);
2784 nsigmaTPCTOFkKaon = TMath::Sqrt(nsigmaTPCkKaon*nsigmaTPCkKaon+nsigmaTOFkKaon*nsigmaTOFkKaon);
2785 nsigmaTPCTOFkProton = TMath::Sqrt(nsigmaTPCkProton*nsigmaTPCkProton+nsigmaTOFkProton*nsigmaTOFkProton);
2791 // if TOF is missing and below fPtTOFPID only the TPC information is used
2792 nsigmaTPCTOFkProton = TMath::Abs(nsigmaTPCkProton);
2793 nsigmaTPCTOFkKaon = TMath::Abs(nsigmaTPCkKaon);
2794 nsigmaTPCTOFkPion = TMath::Abs(nsigmaTPCkPion);
2798 //set data member fnsigmas
2799 fnsigmas[SpPion][NSigmaTPC]=nsigmaTPCkPion;
2800 fnsigmas[SpKaon][NSigmaTPC]=nsigmaTPCkKaon;
2801 fnsigmas[SpProton][NSigmaTPC]=nsigmaTPCkProton;
2803 //for all tracks below fPtTOFPIDmin and also for tracks above fPtTOFPIDmin without proper TOF response these TOF nsigma values will be 999.
2804 fnsigmas[SpPion][NSigmaTOF]=nsigmaTOFkPion;
2805 fnsigmas[SpKaon][NSigmaTOF]=nsigmaTOFkKaon;
2806 fnsigmas[SpProton][NSigmaTOF]=nsigmaTOFkProton;
2808 //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)
2809 fnsigmas[SpPion][NSigmaTPCTOF]=nsigmaTPCTOFkPion;
2810 fnsigmas[SpKaon][NSigmaTPCTOF]=nsigmaTPCTOFkKaon;
2811 fnsigmas[SpProton][NSigmaTPCTOF]=nsigmaTPCTOFkProton;
2814 //Fill NSigma SeparationPlot
2815 for(Int_t ipart=0;ipart<NSpecies;ipart++){
2816 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
2817 if((ipid!=NSigmaTPC) && (!HasTOFPID(track)) && track->Pt()<fPtTOFPIDmin)continue;//not filling TOF and combined if no TOF PID
2818 TH2F *h=GetHistogram2D(Form("NSigma_%d_%d",ipart,ipid));
2819 h->Fill(track->Pt(),fnsigmas[ipart][ipid]);
2825 //----------------------------------------------------------------------------
2826 Int_t AliTwoParticlePIDCorr::FindMinNSigma(AliAODTrack *track,Bool_t FillQAHistos)
2828 //this function is always called after calling the function CalculateNSigmas(AliAODTrack *track)
2829 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
2830 //get the identity of the particle with the minimum Nsigma
2831 Float_t nsigmaPion=999., nsigmaKaon=999., nsigmaProton=999.;
2834 nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTPC]);
2835 nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTPC]) ;
2836 nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTPC]) ;
2839 nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTOF]);
2840 nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTOF]) ;
2841 nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTOF]) ;
2843 case NSigmaTPCTOF://In case of no TOF matching the combined nsigma is the TPC one
2844 nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTPCTOF]);
2845 nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTPCTOF]) ;
2846 nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTPCTOF]) ;
2850 if(track->Pt()<=fPtTOFPIDmax) { //the range upto which combined TPC-TOF cut can be used(here 4.0 Gev/C)
2851 // guess the particle based on the smaller nsigma (within fNSigmaPID)
2852 if( ( nsigmaKaon==nsigmaPion ) && ( nsigmaKaon==nsigmaProton )) return SpUndefined;//it is the default value for the three
2854 if( ( nsigmaKaon < nsigmaPion ) && ( nsigmaKaon < nsigmaProton ) && (nsigmaKaon < fNSigmaPID)){
2855 if((fHighPtKaonNSigmaPID>0) && (track->Pt()>fHighPtKaonSigma) && (nsigmaKaon > fHighPtKaonNSigmaPID)) return SpUndefined;
2857 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
2858 if((ipid!=NSigmaTPC) && (!HasTOFPID(track)) && (track->Pt()<fPtTOFPIDmin))continue;//not filling TOF and combined if no TOF PID
2859 TH2F *h=GetHistogram2D(Form("NSigmaRec_%d_%d",SpKaon,ipid));
2860 h->Fill(track->Pt(),fnsigmas[SpKaon][ipid]);
2865 if( ( nsigmaPion < nsigmaKaon ) && ( nsigmaPion < nsigmaProton ) && (nsigmaPion < fNSigmaPID)) {
2867 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
2868 if((ipid!=NSigmaTPC) && (!HasTOFPID(track)) && (track->Pt()<fPtTOFPIDmin))continue;//not filling TOF and combined if no TOF PID
2869 TH2F *h=GetHistogram2D(Form("NSigmaRec_%d_%d",SpPion,ipid));
2870 h->Fill(track->Pt(),fnsigmas[SpPion][ipid]);
2875 if( ( nsigmaProton < nsigmaKaon ) && ( nsigmaProton < nsigmaPion ) && (nsigmaProton < fNSigmaPID)) {
2877 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
2878 if((ipid!=NSigmaTPC) && (!HasTOFPID(track)) && (track->Pt()<fPtTOFPIDmin))continue;//not filling TOF and combined if no TOF PID
2879 TH2F *h=GetHistogram2D(Form("NSigmaRec_%d_%d",SpProton,ipid));
2880 h->Fill(track->Pt(),fnsigmas[SpProton][ipid]);
2886 // else, return undefined
2889 else {//asymmetric nsigma cut around pion's mean position for tracks having Pt>4.0 Gev
2890 if(fminprotonsigmacut<fnsigmas[SpPion][NSigmaTPC] && fnsigmas[SpPion][NSigmaTPC]<fmaxprotonsigmacut) return SpProton;
2891 if(fminpionsigmacut<fnsigmas[SpPion][NSigmaTPC] && fnsigmas[SpPion][NSigmaTPC]<fmaxpionsigmacut) return SpPion;
2892 // else, return undefined(here we don't detect kaons)
2898 //------------------------------------------------------------------------------------------
2899 Bool_t* AliTwoParticlePIDCorr::GetDoubleCounting(AliAODTrack * trk,Bool_t FIllQAHistos){
2900 //this function is always called after calling the function CalculateNSigmas(AliAODTrack *track)
2902 //if a particle has double counting set fHasDoubleCounting[ipart]=kTRUE
2904 for(Int_t ipart=0;ipart<NSpecies;ipart++)fHasDoubleCounting[ipart]=kFALSE;//array with kTRUE for second (or third) identity of the track
2906 Int_t MinNSigma=FindMinNSigma(trk,kFALSE);//not filling the NSigmaRec histos
2909 if(MinNSigma==SpUndefined)return fHasDoubleCounting;//in case of undefined no Double counting
2911 Float_t nsigmaPion=999., nsigmaKaon=999., nsigmaProton=999.;
2914 nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTPC]);
2915 nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTPC]) ;
2916 nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTPC]) ;
2919 nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTOF]);
2920 nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTOF]) ;
2921 nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTOF]) ;
2923 case NSigmaTPCTOF://In case of no TOF matching the combined nsigma is the TPC one
2924 nsigmaProton = TMath::Abs(fnsigmas[SpProton][NSigmaTPCTOF]);
2925 nsigmaKaon = TMath::Abs(fnsigmas[SpKaon][NSigmaTPCTOF]) ;
2926 nsigmaPion = TMath::Abs(fnsigmas[SpPion][NSigmaTPCTOF]) ;
2930 //there is chance of overlapping only for particles having pt below 4.0 GEv
2932 if(nsigmaPion<fNSigmaPID && MinNSigma!=SpPion)fHasDoubleCounting[SpPion]=kTRUE;
2933 if(nsigmaKaon<fNSigmaPID && MinNSigma!=SpKaon)fHasDoubleCounting[SpKaon]=kTRUE;
2934 if(nsigmaProton<fNSigmaPID && MinNSigma!=SpProton)fHasDoubleCounting[SpProton]=kTRUE;
2939 //fill NSigma distr for double counting
2940 for(Int_t ipart=0;ipart<NSpecies;ipart++){
2941 if(fHasDoubleCounting[ipart]){
2942 for(Int_t ipid=0;ipid<=NSigmaPIDType;ipid++){
2943 if((ipid!=NSigmaTPC) && (!HasTOFPID(trk)) && (trk->Pt()<fPtTOFPIDmin))continue;//not filling TOF and combined if no TOF PID
2944 TH2F *h=GetHistogram2D(Form("NSigmaDC_%d_%d",ipart,ipid));
2945 h->Fill(trk->Pt(),fnsigmas[ipart][ipid]);
2952 return fHasDoubleCounting;
2955 //////////////////////////////////////////////////////////////////////////////////////////////////
2956 Int_t AliTwoParticlePIDCorr::GetParticle(AliAODTrack * trk, Bool_t FIllQAHistos){
2957 //return the specie according to the minimum nsigma value
2958 //no double counting, this has to be evaluated using CheckDoubleCounting()
2960 Int_t ID=SpUndefined;
2962 CalculateNSigmas(trk,FIllQAHistos);//fill the data member fnsigmas with the nsigmas value [ipart][iPID]
2964 ID=FindMinNSigma(trk,FIllQAHistos);
2966 if(fUseExclusiveNSigma){ //if one particle has double counting and exclusive nsigma is requested ID = kSpUndefined
2968 HasDC=GetDoubleCounting(trk,FIllQAHistos);
2969 for(Int_t ipart=0;ipart<NSpecies;ipart++){
2970 if(HasDC[ipart]==kTRUE) ID = SpUndefined;
2974 //Fill PID signal plot
2975 if(ID != SpUndefined){
2976 for(Int_t idet=0;idet<fNDetectors;idet++){
2977 TH2F *h=GetHistogram2D(Form("PID_%d_%d",idet,ID));
2978 if(idet==fITS)h->Fill(trk->P(),trk->GetITSsignal()*trk->Charge());
2979 if(idet==fTPC)h->Fill(trk->P(),trk->GetTPCsignal()*trk->Charge());
2980 if(idet==fTOF && HasTOFPID(trk))h->Fill(trk->P(),GetBeta(trk)*trk->Charge());
2983 //Fill PID signal plot without cuts
2984 for(Int_t idet=0;idet<fNDetectors;idet++){
2985 TH2F *h=GetHistogram2D(Form("PIDAll_%d",idet));
2986 if(idet==fITS)h->Fill(trk->P(),trk->GetITSsignal()*trk->Charge());
2987 if(idet==fTPC)h->Fill(trk->P(),trk->GetTPCsignal()*trk->Charge());
2988 if(idet==fTOF && HasTOFPID(trk))h->Fill(trk->P(),GetBeta(trk)*trk->Charge());
2994 //-------------------------------------------------------------------------------------
2996 AliTwoParticlePIDCorr::HasTPCPID(AliAODTrack *track) const
2999 AliPIDResponse::EDetPidStatus statustpc = fPID->CheckPIDStatus(AliPIDResponse::kTPC,track);
3000 if(statustpc!=AliPIDResponse::kDetPidOk) return kFALSE;
3001 //ULong_t status=track->GetStatus();
3002 //if (!( (status & AliAODTrack::kTPCpid ) == AliAODTrack::kTPCpid )) return kFALSE;//remove light nuclei
3003 //if (track->GetTPCsignal() <= 0.) return kFALSE;
3004 // 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.
3008 //___________________________________________________________
3011 AliTwoParticlePIDCorr::HasTOFPID(AliAODTrack *track) const
3013 // check TOF matched track
3014 //ULong_t status=track->GetStatus();
3015 //if (!( (status & AliAODTrack::kITSin ) == AliAODTrack::kITSin )) return kFALSE;
3016 AliPIDResponse::EDetPidStatus statustof = fPID->CheckPIDStatus(AliPIDResponse::kTOF,track);
3017 if(statustof!= AliPIDResponse::kDetPidOk) return kFALSE;
3018 if(track->Pt()<=fPtTOFPIDmin) return kFALSE;
3019 //if(!((status & AliAODTrack::kTOFpid ) == AliAODTrack::kTOFpid )) return kFALSE;
3020 //Float_t probMis = fPIDresponse->GetTOFMismatchProbability(track);
3021 // if (probMis > 0.01) return kFALSE;
3022 if(fRemoveTracksT0Fill)
3024 Int_t startTimeMask = fPID->GetTOFResponse().GetStartTimeMask(track->P());
3025 if (startTimeMask < 0)return kFALSE;
3030 //________________________________________________________________________
3031 Double_t AliTwoParticlePIDCorr :: GetBeta(AliAODTrack *track)
3033 //it is called only when TOF PID is available
3034 //TOF beta calculation
3035 Double_t tofTime=track->GetTOFsignal();
3037 Double_t c=TMath::C()*1.E-9;// m/ns
3038 Float_t startTime = fPID->GetTOFResponse().GetStartTime(((AliVTrack*)track)->P());//in ps
3039 Double_t length= fPID->GetTOFResponse().GetExpectedSignal(track,AliPID::kElectron)*1E-3*c;
3040 tofTime -= startTime; // subtract startTime to the signal
3041 Double_t tof= tofTime*1E-3; // ns, average T0 fill subtracted, no info from T0detector
3047 Double_t p = track->P();
3048 Double_t time=track->GetTOFsignal()-fPID->GetTOFResponse().GetStartTime(p);
3050 track->GetIntegratedTimes(timei);
3051 return timei[0]/time;
3054 //------------------------------------------------------------------------------------------------------
3056 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)
3058 // calculate inv mass squared
3059 // same can be achieved, but with more computing time with
3060 /*TLorentzVector photon, p1, p2;
3061 p1.SetPtEtaPhiM(triggerParticle->Pt(), triggerEta, triggerParticle->Phi(), 0.510e-3);
3062 p2.SetPtEtaPhiM(particle->Pt(), eta[j], particle->Phi(), 0.510e-3);
3066 Float_t tantheta1 = 1e10;
3068 if (eta1 < -1e-10 || eta1 > 1e-10)
3069 tantheta1 = 2 * TMath::Exp(-eta1) / ( 1 - TMath::Exp(-2*eta1));
3071 Float_t tantheta2 = 1e10;
3072 if (eta2 < -1e-10 || eta2 > 1e-10)
3073 tantheta2 = 2 * TMath::Exp(-eta2) / ( 1 - TMath::Exp(-2*eta2));
3075 Float_t e1squ = m0_1 * m0_1 + pt1 * pt1 * (1.0 + 1.0 / tantheta1 / tantheta1);
3076 Float_t e2squ = m0_2 * m0_2 + pt2 * pt2 * (1.0 + 1.0 / tantheta2 / tantheta2);
3078 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 ) ) );
3082 //---------------------------------------------------------------------------------
3084 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)
3086 // calculate inv mass squared approximately
3088 Float_t tantheta1 = 1e10;
3090 if (eta1 < -1e-10 || eta1 > 1e-10)
3092 Float_t expTmp = 1.0-eta1+eta1*eta1/2-eta1*eta1*eta1/6+eta1*eta1*eta1*eta1/24;
3093 tantheta1 = 2.0 * expTmp / ( 1.0 - expTmp*expTmp);
3096 Float_t tantheta2 = 1e10;
3097 if (eta2 < -1e-10 || eta2 > 1e-10)
3099 Float_t expTmp = 1.0-eta2+eta2*eta2/2-eta2*eta2*eta2/6+eta2*eta2*eta2*eta2/24;
3100 tantheta2 = 2.0 * expTmp / ( 1.0 - expTmp*expTmp);
3103 Float_t e1squ = m0_1 * m0_1 + pt1 * pt1 * (1.0 + 1.0 / tantheta1 / tantheta1);
3104 Float_t e2squ = m0_2 * m0_2 + pt2 * pt2 * (1.0 + 1.0 / tantheta2 / tantheta2);
3107 Float_t deltaPhi = TMath::Abs(phi1 - phi2);
3108 while (deltaPhi > TMath::TwoPi())
3109 deltaPhi -= TMath::TwoPi();
3110 if (deltaPhi > TMath::Pi())
3111 deltaPhi = TMath::TwoPi() - deltaPhi;
3113 Float_t cosDeltaPhi = 0;
3114 if (deltaPhi < TMath::Pi()/3)
3115 cosDeltaPhi = 1.0 - deltaPhi*deltaPhi/2 + deltaPhi*deltaPhi*deltaPhi*deltaPhi/24;
3116 else if (deltaPhi < 2*TMath::Pi()/3)
3117 cosDeltaPhi = -(deltaPhi - TMath::Pi()/2) + 1.0/6 * TMath::Power((deltaPhi - TMath::Pi()/2), 3);
3119 cosDeltaPhi = -1.0 + 1.0/2.0*(deltaPhi - TMath::Pi())*(deltaPhi - TMath::Pi()) - 1.0/24.0 * TMath::Power(deltaPhi - TMath::Pi(), 4);
3121 Float_t mass2 = m0_1 * m0_1 + m0_2 * m0_2 + 2 * ( TMath::Sqrt(e1squ * e2squ) - ( pt1 * pt2 * ( cosDeltaPhi + 1.0 / tantheta1 / tantheta2 ) ) );
3123 // Printf(Form("%f %f %f %f %f %f %f %f %f", pt1, eta1, phi1, pt2, eta2, phi2, m0_1, m0_2, mass2));
3127 //--------------------------------------------------------------------------------
3128 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)
3131 // calculates dphistar
3134 Float_t dphistar = phi1 - phi2 - charge1 * bSign * TMath::ASin(0.075 * radius / pt1) + charge2 * bSign * TMath::ASin(0.075 * radius / pt2);
3136 static const Double_t kPi = TMath::Pi();
3139 // if (dphistar > 2 * kPi)
3140 // dphistar -= 2 * kPi;
3141 // if (dphistar < -2 * kPi)
3142 // dphistar += 2 * kPi;
3145 dphistar = kPi * 2 - dphistar;
3146 if (dphistar < -kPi)
3147 dphistar = -kPi * 2 - dphistar;
3148 if (dphistar > kPi) // might look funny but is needed
3149 dphistar = kPi * 2 - dphistar;
3153 //_________________________________________________________________________
3154 void AliTwoParticlePIDCorr ::DefineEventPool()
3156 Int_t MaxNofEvents=1000;
3157 const Int_t NofVrtxBins=10+(1+10)*2;
3158 Double_t ZvrtxBins[NofVrtxBins+1]={ -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10,
3159 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110,
3160 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210
3162 if (fSampleType=="pp"){
3163 const Int_t NofCentBins=4;
3164 Double_t CentralityBins[NofCentBins+1]={0.,20., 40.,60.,200.1};//Is This binning is fine for pp, or we don't require them....
3165 fPoolMgr = new AliEventPoolManager(MaxNofEvents,fMaxNofMixingTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins);
3167 if (fSampleType=="pPb" || fSampleType=="PbPb")
3169 const Int_t NofCentBins=15;
3170 Double_t CentralityBins[NofCentBins+1]={0., 1., 2., 3., 4., 5., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100.1 };
3171 fPoolMgr = new AliEventPoolManager(MaxNofEvents,fMaxNofMixingTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins);
3173 fPoolMgr->SetTargetValues(fMaxNofMixingTracks, 0.1, 5);
3175 //if(!fPoolMgr) return kFALSE;
3179 //------------------------------------------------------------------------
3180 Double_t* AliTwoParticlePIDCorr::GetBinning(const char* configuration, const char* tag, Int_t& nBins)
3182 // This method is a copy from AliUEHist::GetBinning
3183 // takes the binning from <configuration> identified by <tag>
3184 // configuration syntax example:
3185 // 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
3188 // returns bin edges which have to be deleted by the caller
3190 TString config(configuration);
3191 TObjArray* lines = config.Tokenize("\n");
3192 for (Int_t i=0; i<lines->GetEntriesFast(); i++)
3194 TString line(lines->At(i)->GetName());
3195 if (line.BeginsWith(TString(tag) + ":"))
3197 line.Remove(0, strlen(tag) + 1);
3198 line.ReplaceAll(" ", "");
3199 TObjArray* binning = line.Tokenize(",");
3200 Double_t* bins = new Double_t[binning->GetEntriesFast()];
3201 for (Int_t j=0; j<binning->GetEntriesFast(); j++)
3202 bins[j] = TString(binning->At(j)->GetName()).Atof();
3204 nBins = binning->GetEntriesFast() - 1;
3213 AliFatal(Form("Tag %s not found in %s", tag, configuration));
3217 //____________________________________________________________________
3219 Bool_t AliTwoParticlePIDCorr::CheckTrack(AliAODTrack * part)
3221 // check if the track status flags are set
3223 UInt_t status=((AliAODTrack*)part)->GetStatus();
3224 if ((status & fTrackStatus) == fTrackStatus)
3228 //________________________________________________________________________
3229 void AliTwoParticlePIDCorr::Terminate(Option_t *)
3231 // Draw result to screen, or perform fitting, normalizations
3232 // Called once at the end of the query
3233 fOutput = dynamic_cast<TList*> (GetOutputData(1));
3234 if(!fOutput) { Printf("ERROR: could not retrieve TList fOutput"); return; }
3238 //------------------------------------------------------------------