AliPhysics  a3be53f (a3be53f)
AliAnalysisTaskFlowModes.cxx
Go to the documentation of this file.
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15 
16 // AliAnalysisTaskFlowModes - ALICE Flow framework
17 //
18 // ALICE analysis task for universal study of flow.
19 // Note: So far implemented only for AOD analysis!
20 // Author: Vojtech Pacik
21 // Modified by: Naghmeh Mohammadi to include non-linear terms, Nikhef, 2017
22 // Generic framework by: You Zhou
23 
24 #include <vector>
25 
26 #include <TDatabasePDG.h>
27 #include <TPDGCode.h>
28 
29 #include "TFile.h"
30 #include "TChain.h"
31 #include "TH1D.h"
32 #include "TH2D.h"
33 #include "TH3D.h"
34 #include "TProfile.h"
35 #include "TProfile2D.h"
36 #include "TProfile3D.h"
37 #include "TList.h"
38 #include "TComplex.h"
39 #include "TRandom3.h"
40 
41 #include "AliAnalysisTask.h"
42 #include "AliAnalysisManager.h"
43 #include "AliAODInputHandler.h"
44 #include "AliAnalysisUtils.h"
45 #include "AliMultSelection.h"
46 #include "AliPIDResponse.h"
47 #include "AliPIDCombined.h"
49 #include "AliLog.h"
50 #include "AliAODEvent.h"
51 #include "AliESDEvent.h"
52 #include "AliAODTrack.h"
53 #include "AliAODv0.h"
54 #include "AliVTrack.h"
55 #include "AliESDpid.h"
56 #include "AliFlowBayesianPID.h"
57 
58 
60 
61 ClassImp(AliAnalysisTaskFlowModes); // classimp: necessary for root
62 
64 Int_t AliAnalysisTaskFlowModes::fMixedHarmonics[] = {422,633,523,6222};// 422: v4{psi2}, 523: v5{psi2, psi3}, 633: v6{psi3} and 6222: v6{psi2}
65 
67 
68 
69 
71  fEventAOD(0x0),
72  fPIDResponse(0x0),
73  fPIDCombined(0x0),
76  fInit(kFALSE),
77  fIndexSampling(0),
78  fIndexCentrality(-1),
79  fEventCounter(0),
81  fRunNumber(-1),
82  fExtraPileUp(kFALSE),
83  fPDGMassPion(TDatabasePDG::Instance()->GetParticle(211)->Mass()),
84  fPDGMassKaon(TDatabasePDG::Instance()->GetParticle(321)->Mass()),
85  fPDGMassProton(TDatabasePDG::Instance()->GetParticle(2212)->Mass()),
86 
87  // FlowPart containers
88  fVectorCharged(0x0),
89  fVectorPion(0x0),
90  fVectorKaon(0x0),
91  fVectorProton(0x0),
92 
93  // analysis selection
94  fRunMode(kFull),
95  fAnalType(kAOD),
96  fSampling(kFALSE),
97  fFillQA(kTRUE),
98  fProcessCharged(kFALSE),
99  fProcessPID(kFALSE),
100  fBayesianResponse(NULL),
101 
102  // flow related
105  fFlowPOIsPtMin(0),
106  fFlowPOIsPtMax(10.),
107  fFlowCentMin(0),
108  fFlowCentMax(150),
109  fFlowCentNumBins(150),
111  fDoOnlyMixedCorrelations(kFALSE),
112  fFlowFillWeights(kFALSE),
113  fFlowUseNUAWeights(kFALSE),
114  fFlowUseNUEWeights(kFALSE),
117  fPositivelyChargedRef(kFALSE),
118  fNegativelyChargedRef(kFALSE),
119  fPositivelyChargedPOI(kFALSE),
120  fNegativelyChargedPOI(kFALSE),
121 
122 
123 
124  // events selection
125  fPVtxCutZ(0.),
126  fColSystem(kPbPb),
127  fMultEstimator(),
128  fTrigger(0),
129  fFullCentralityRange(kTRUE),
130  // charged tracks selection
132  fCutChargedPtMax(0),
133  fCutChargedPtMin(0),
139 
140  // PID tracks selection
141  fESDpid(),
142  fCutPIDUseAntiProtonOnly(kFALSE),
143  fPIDnsigma(kTRUE),
145  fPIDbayesian(kFALSE),
151  fCurrCentr(0.0),
153 
154  // output lists
155  fQAEvents(0x0),
156  fQACharged(0x0),
157  fQAPID(0x0),
158  fFlowWeights(0x0),
159  fFlowRefs(0x0),
160  fFlowCharged(0x0),
161  fFlowPID(0x0),
162 
163  // flow histograms & profiles
169 
175 
181 
187 
193 
199 
200  // event histograms
201  fhEventSampling(0x0),
202  fhEventCentrality(0x0),
204  fhEventCounter(0x0),
205 
206  // charged histogram
207  fh2RefsMult(0x0),
208  fh2RefsPt(0x0),
209  fh2RefsEta(0x0),
210  fh2RefsPhi(0x0),
211  fhChargedCounter(0x0),
212 
213  // PID histogram
214  fh2PIDPionMult(0x0),
215  fh2PIDPionPt(0x0),
216  fh2PIDPionPhi(0x0),
217  fh2PIDPionEta(0x0),
218  fhPIDPionCharge(0x0),
219  fh2PIDKaonMult(0x0),
220  fh2PIDKaonPt(0x0),
221  fh2PIDKaonPhi(0x0),
222  fh2PIDKaonEta(0x0),
223  fhPIDKaonCharge(0x0),
224  fh2PIDProtonMult(0x0),
225  fh2PIDProtonPt(0x0),
226  fh2PIDProtonPhi(0x0),
227  fh2PIDProtonEta(0x0),
228  fhPIDProtonCharge(0x0),
229  fh2PIDPionTPCdEdx(0x0),
230  fh2PIDPionTOFbeta(0x0),
231  fh2PIDKaonTPCdEdx(0x0),
232  fh2PIDKaonTOFbeta(0x0),
233  fh2PIDProtonTPCdEdx(0x0),
234  fh2PIDProtonTOFbeta(0x0),
253  fhNUEWeightRefsPlus(0x0),
257  fhNUEWeightPionPlus(0x0),
259  fhNUEWeightKaonPlus(0x0),
263 {
264  SetPriors(); //init arrays
265  // New PID procedure (Bayesian Combined PID)
266  // allocating here is necessary because we don't
267  // stream this member
270  // default constructor, don't allocate memory here!
271  // this is used by root for IO purposes, it needs to remain empty
272 }
273 //_____________________________________________________________________________
275  fEventAOD(0x0),
276  fPIDResponse(0x0),
277  fPIDCombined(0x0),
278  fFlowNUAWeightsFile(0x0),
279  fFlowNUEWeightsFile(0x0),
280  fInit(kFALSE),
281  fIndexSampling(0),
282  fIndexCentrality(-1),
283  fEventCounter(0),
284  fNumEventsAnalyse(50),
285  fRunNumber(-1),
286  fExtraPileUp(kFALSE),
287  fPDGMassPion(TDatabasePDG::Instance()->GetParticle(211)->Mass()),
288  fPDGMassKaon(TDatabasePDG::Instance()->GetParticle(321)->Mass()),
289  fPDGMassProton(TDatabasePDG::Instance()->GetParticle(2212)->Mass()),
290 
291  // FlowPart containers
292  fVectorCharged(0x0),
293  fVectorPion(0x0),
294  fVectorKaon(0x0),
295  fVectorProton(0x0),
296 
297  // analysis selection
298  fRunMode(kFull),
299  fAnalType(kAOD),
300  fSampling(kFALSE),
301  fFillQA(kTRUE),
302  fProcessCharged(kFALSE),
303  fProcessPID(kFALSE),
304  fBayesianResponse(NULL),
305 
306  // flow related
309  fFlowPOIsPtMin(0),
310  fFlowPOIsPtMax(20.),
311  fFlowCentMin(0),
312  fFlowCentMax(150),
313  fFlowCentNumBins(150),
315  fDoOnlyMixedCorrelations(kFALSE),
316  fFlowFillWeights(kFALSE),
317  fFlowUseNUAWeights(kFALSE),
318  fFlowUseNUEWeights(kFALSE),
321  fPositivelyChargedRef(kFALSE),
322  fNegativelyChargedRef(kFALSE),
323  fPositivelyChargedPOI(kFALSE),
324  fNegativelyChargedPOI(kFALSE),
325 
326  // events selection
327  fPVtxCutZ(0.),
328  fColSystem(kPbPb),
329  fMultEstimator(),
330  fTrigger(0),
331  fFullCentralityRange(kTRUE),
332  // charged tracks selection
334  fCutChargedPtMax(0),
335  fCutChargedPtMin(0),
341  // PID tracks selection
342  fESDpid(),
343  fCutPIDUseAntiProtonOnly(kFALSE),
344  fPIDnsigma(kTRUE),
346  fPIDbayesian(kFALSE),
352  fCurrCentr(0.0),
354 
355 
356  // output lists
357  fQAEvents(0x0),
358  fQACharged(0x0),
359  fQAPID(0x0),
360  fFlowWeights(0x0),
361  fFlowRefs(0x0),
362  fFlowCharged(0x0),
363  fFlowPID(0x0),
364 
365  // flow histograms & profiles
371 
377 
383 
389 
395 
401 
402  // event histograms
403  fhEventSampling(0x0),
404  fhEventCentrality(0x0),
406  fhEventCounter(0x0),
407 
408  // charged histogram
409  fh2RefsMult(0x0),
410  fh2RefsPt(0x0),
411  fh2RefsEta(0x0),
412  fh2RefsPhi(0x0),
413  fhChargedCounter(0x0),
414 
415  // PID histogram
416  fh2PIDPionMult(0x0),
417  fh2PIDPionPt(0x0),
418  fh2PIDPionPhi(0x0),
419  fh2PIDPionEta(0x0),
420  fhPIDPionCharge(0x0),
421  fh2PIDKaonMult(0x0),
422  fh2PIDKaonPt(0x0),
423  fh2PIDKaonPhi(0x0),
424  fh2PIDKaonEta(0x0),
425  fhPIDKaonCharge(0x0),
426  fh2PIDProtonMult(0x0),
427  fh2PIDProtonPt(0x0),
428  fh2PIDProtonPhi(0x0),
429  fh2PIDProtonEta(0x0),
430  fhPIDProtonCharge(0x0),
431  fh2PIDPionTPCdEdx(0x0),
432  fh2PIDPionTOFbeta(0x0),
433  fh2PIDKaonTPCdEdx(0x0),
434  fh2PIDKaonTOFbeta(0x0),
435  fh2PIDProtonTPCdEdx(0x0),
436  fh2PIDProtonTOFbeta(0x0),
455  fhNUEWeightRefsPlus(0x0),
459  fhNUEWeightPionPlus(0x0),
461  fhNUEWeightKaonPlus(0x0),
465 {
466 
467  SetPriors(); //init arrays
468  // New PID procedure (Bayesian Combined PID)
471 
472  // Flow vectors
473  for(Short_t iHarm(0); iHarm < fFlowNumHarmonicsMax; iHarm++)
474  {
475  for(Short_t iPower(0); iPower < fFlowNumWeightPowersMax; iPower++)
476  {
477  fFlowVecQpos[iHarm][iPower] = TComplex(0,0,kFALSE);
478  fFlowVecQneg[iHarm][iPower] = TComplex(0,0,kFALSE);
479 
480  for(Short_t iPt(0); iPt < fFlowPOIsPtNumBins; iPt++)
481  {
482  fFlowVecPpos[iHarm][iPower][iPt] = TComplex(0,0,kFALSE);
483  fFlowVecPneg[iHarm][iPower][iPt] = TComplex(0,0,kFALSE);
484  fFlowVecS[iHarm][iPower][iPt] = TComplex(0,0,kFALSE);
485  }//endfor(Short_t iPt(0); iPt < fFlowPOIsPtNumBins; iPt++)
486  }//endfor(Short_t iPower(0); iPower < fFlowNumWeightPowersMax; iPower++)
487  }//endfor(Short_t iHarm(0); iHarm < fFlowNumHarmonicsMax; iHarm++)
488 
489  // Flow profiles & histograms
491  for(Short_t iMixedHarm(0); iMixedHarm < fNumMixedHarmonics; iMixedHarm++)
492  {
493  for(Short_t iGap(0); iGap < fNumEtaGap; iGap++)
494  {
495  for(Short_t iSample(0); iSample < fNumSamples; iSample++)
496  {
497  fpMixedRefsCor4[iSample][iGap][iMixedHarm] = 0x0;
498  if(iMixedHarm==3)fpMixedRefsCor6[iSample][iGap] = 0x0;
499 
500  fpMixedChargedCor3Pos[iSample][iGap][iMixedHarm] = 0x0;
501  fpMixedChargedCor3Neg[iSample][iGap][iMixedHarm] = 0x0;
502 
503  fpMixedPionCor3Pos[iSample][iGap][iMixedHarm] = 0x0;
504  fpMixedPionCor3Neg[iSample][iGap][iMixedHarm] = 0x0;
505  fpMixedKaonCor3Pos[iSample][iGap][iMixedHarm] = 0x0;
506  fpMixedKaonCor3Neg[iSample][iGap][iMixedHarm] = 0x0;
507  fpMixedProtonCor3Pos[iSample][iGap][iMixedHarm] = 0x0;
508  fpMixedProtonCor3Neg[iSample][iGap][iMixedHarm] = 0x0;
509 
510  if(iMixedHarm==3){
511  fpMixedChargedCor4Pos[iSample][iGap] = 0x0;
512  fpMixedChargedCor4Neg[iSample][iGap] = 0x0;
513 
514  fpMixedPionCor4Pos[iSample][iGap] = 0x0;
515  fpMixedPionCor4Neg[iSample][iGap] = 0x0;
516  fpMixedKaonCor4Pos[iSample][iGap] = 0x0;
517  fpMixedKaonCor4Neg[iSample][iGap] = 0x0;
518  fpMixedProtonCor4Pos[iSample][iGap] = 0x0;
519  fpMixedProtonCor4Neg[iSample][iGap] = 0x0;
520  }
521  }
522 
523  }//endfor(Short_t iGap(0); iGap < fNumEtaGap; iGap++)
524  }//endfor(Short_t iMixedHarm(0); iMixedHarm < fNumMixedHarmonics; iMixedHarm++)
525  }//endif(fDoOnlyMixedCorrelations)
526 
528  for(Short_t iHarm(0); iHarm < fNumHarmonics; iHarm++){
529  //fpRefsCor4[iHarm] = 0x0;
530  //fp2ChargedCor4[iHarm] = 0x0;
531  //fp2PionCor4[iHarm] = 0x0;
532  //fp2KaonCor4[iHarm] = 0x0;
533  //fp2ProtonCor4[iHarm] = 0x0;
534  for(Short_t iGap(0); iGap < fNumEtaGap; iGap++){
535  // mean Qx,Qy
536  fpMeanQxRefsPos[iGap][iHarm] = 0x0;
537  fpMeanQxRefsNeg[iGap][iHarm] = 0x0;
538  fpMeanQyRefsPos[iGap][iHarm] = 0x0;
539  fpMeanQyRefsNeg[iGap][iHarm] = 0x0;
540  for(Short_t iSample(0); iSample < fNumSamples; iSample++)
541  {
542 
543  fpRefsCor2[iSample][iGap][iHarm] = 0x0;
544  fp2ChargedCor2Pos[iSample][iGap][iHarm] = 0x0;
545  fp2ChargedCor2Neg[iSample][iGap][iHarm] = 0x0;
546  fp2PionCor2Pos[iSample][iGap][iHarm] = 0x0;
547  fp2PionCor2Neg[iSample][iGap][iHarm] = 0x0;
548  fp2KaonCor2Pos[iSample][iGap][iHarm] = 0x0;
549  fp2KaonCor2Neg[iSample][iGap][iHarm] = 0x0;
550  fp2ProtonCor2Pos[iSample][iGap][iHarm] = 0x0;
551  fp2ProtonCor2Neg[iSample][iGap][iHarm] = 0x0;
552  }
553  }//endfor(Short_t iGap(0); iGap < fNumEtaGap; iGap++)
554  }//endfor(Short_t iHarm(0); iHarm < fNumHarmonics; iHarm++)
555  }//endif(!fDoOnlyMixedCorrelations)
556 
557  // QA histograms
558  for(Short_t iQA(0); iQA < fiNumIndexQA; iQA++)
559  {
560  // Event histograms
561  fhQAEventsPVz[iQA] = 0x0;
562  fhQAEventsNumContrPV[iQA] = 0x0;
563  fhQAEventsNumSPDContrPV[iQA] = 0x0;
564  fhQAEventsDistPVSPD[iQA] = 0x0;
565  fhQAEventsSPDresol[iQA] = 0x0;
566  fhQAEventsPileUp[iQA] = 0x0;
567  fhQAEventsCentralityOutliers[iQA] = 0x0;
568  fhEventsMultTOFFilterbit32[iQA] = 0x0;
569  // charged
570  fhQAChargedMult[iQA] = 0x0;
571  fhQAChargedPt[iQA] = 0x0;
572  fhQAChargedEta[iQA] = 0x0;
573  fhQAChargedPhi[iQA] = 0x0;
574  fhQAChargedCharge[iQA] = 0x0;
575  fhQAChargedFilterBit[iQA] = 0x0;
576  fhQAChargedNumTPCcls[iQA] = 0x0;
577  fhQAChargedDCAxy[iQA] = 0x0;
578  fhQAChargedDCAz[iQA] = 0x0;
579 
580  // PID
581  fhQAPIDTPCstatus[iQA] = 0x0;
582  fhQAPIDTOFstatus[iQA] = 0x0;
583  fhQAPIDTPCdEdx[iQA] = 0x0;
584  fhQAPIDTOFbeta[iQA] = 0x0;
585 
586  fh3PIDPionTPCTOFnSigmaPion[iQA] = 0x0;
587  fh3PIDPionTPCTOFnSigmaKaon[iQA] = 0x0;
588  fh3PIDPionTPCTOFnSigmaProton[iQA] = 0x0;
589 
590  fh3PIDKaonTPCTOFnSigmaPion[iQA] = 0x0;
591  fh3PIDKaonTPCTOFnSigmaKaon[iQA] = 0x0;
592  fh3PIDKaonTPCTOFnSigmaProton[iQA] = 0x0;
593 
594  fh3PIDProtonTPCTOFnSigmaPion[iQA] = 0x0;
595  fh3PIDProtonTPCTOFnSigmaKaon[iQA] = 0x0;
597 
598 
599  }//endfor(Short_t iQA(0); iQA < fiNumIndexQA; iQA++)
600 
601  // defining input/output
602  DefineInput(0, TChain::Class());
603  DefineOutput(1, TList::Class());
604  DefineOutput(2, TList::Class());
605  DefineOutput(3, TList::Class());
606  DefineOutput(4, TList::Class());
607  DefineOutput(5, TList::Class());
608  DefineOutput(6, TList::Class());
609  DefineOutput(7, TList::Class());
610 }
611 //_____________________________________________________________________________
613 {
614  // destructor
615  // if(fPIDCombined)
616  // {
617  // delete fPIDCombined;
618  // }
619 
620  // deleting FlowPart vectors (containers)
621  if(fVectorCharged) delete fVectorCharged;
622  if(fVectorPion) delete fVectorPion;
623  if(fVectorKaon) delete fVectorKaon;
624  if(fVectorProton) delete fVectorProton;
625 
626  // deleting output lists
627  if(fFlowWeights) delete fFlowWeights;
628  if(fFlowRefs) delete fFlowRefs;
629  if(fFlowCharged) delete fFlowCharged;
630  if(fFlowPID) delete fFlowPID;
631 
632  if(fQAEvents) delete fQAEvents;
633  if(fQACharged) delete fQACharged;
634  if(fQAPID) delete fQAPID;
635  //deleting histograms
646 }
647 //_____________________________________________________________________________
649 {
650  // create output objects
651  // this function is called ONCE at the start of your analysis (RUNTIME)
652  // *************************************************************
653 
654  // list all parameters used in this analysis
655  ListParameters();
656 
657  // task initialization
658  fInit = InitializeTask();
659  if(!fInit) return;
660 
661  // creating output lists
662  fFlowRefs = new TList();
663  fFlowRefs->SetOwner(kTRUE);
664  fFlowRefs->SetName("fFlowRefs");
665  fFlowCharged = new TList();
666  fFlowCharged->SetOwner(kTRUE);
667  fFlowCharged->SetName("fFlowCharged");
668  fFlowPID = new TList();
669  fFlowPID->SetOwner(kTRUE);
670  fFlowPID->SetName("fFlowPID");
671  fFlowWeights = new TList();
672  fFlowWeights->SetOwner(kTRUE);
673  fFlowWeights->SetName("fFlowWeights");
674 
675  fQAEvents = new TList();
676  fQAEvents->SetOwner(kTRUE);
677  fQACharged = new TList();
678  fQACharged->SetOwner(kTRUE);
679  fQAPID = new TList();
680  fQAPID->SetOwner(kTRUE);
681 
682  // creating particle vectors
683  fVectorCharged = new std::vector<FlowPart>;
684  fVectorPion = new std::vector<FlowPart>;
685  fVectorKaon = new std::vector<FlowPart>;
686  fVectorProton = new std::vector<FlowPart>;
687 
688  fVectorCharged->reserve(300);
689  if(fProcessPID) { fVectorPion->reserve(200); fVectorKaon->reserve(100); fVectorProton->reserve(100); }
690 
691  // creating histograms
692  // event histogram
693 
694  fhEventSampling = new TH2D("fhEventSampling","Event sampling; centrality/multiplicity; sample index", fFlowCentNumBins,0,fFlowCentNumBins, fNumSamples,0,fNumSamples);
696  fhEventCentrality = new TH1D("fhEventCentrality",Form("Event centrality (%s); centrality/multiplicity",fMultEstimator.Data()), fFlowCentNumBins,0,fFlowCentNumBins);
698  fh2EventCentralityNumSelCharged = new TH2D("fh2EventCentralityNumSelCharged",Form("Event centrality (%s) vs. N^{sel}_{ch}; N^{sel}_{ch}; centrality/multiplicity",fMultEstimator.Data()), 3000,0,3000, fFlowCentNumBins,0,fFlowCentNumBins);
700 
701  const Short_t iEventCounterBins = 11;//10 it was
702  TString sEventCounterLabel[iEventCounterBins] = {"Input","Physics selection OK","Centr. Est. Consis. OK","PV OK","SPD Vtx OK","Pileup MV OK","Out-of-bunch Pileup OK","Vtx Consis. OK","PV #it{z} OK","ESD TPC Mult. Diff. OK","Selected"};
703  fhEventCounter = new TH1D("fhEventCounter","Event Counter",iEventCounterBins,0,iEventCounterBins);
704  for(Short_t i(0); i < iEventCounterBins; i++) fhEventCounter->GetXaxis()->SetBinLabel(i+1, sEventCounterLabel[i].Data() );
706 
707  // flow histograms & profiles
708  // weights
710  {
711  fh3BeforeNUAWeightsRefs = new TH3D("fh3BeforeNUAWeightsRefs","Weights: Refs; #varphi; #eta; Prim. vtx_{z} (cm)", 100,0,TMath::TwoPi(), 151,-1.5,1.5, 20, -10,10);
712  fh3BeforeNUAWeightsRefs->Sumw2();
714  fh3BeforeNUAWeightsCharged = new TH3D("fh3BeforeNUAWeightsCharged","Weights: Charged; #varphi; #eta; Prim. vtx_{z} (cm)", 100,0,TMath::TwoPi(), 151,-1.5,1.5,20, -10,10);
717  fh3BeforeNUAWeightsPion = new TH3D("fh3BeforeNUAWeightsPion","Weights: #pi; #varphi; #eta; Prim. vtx_{z} (cm)", 100,0,TMath::TwoPi(), 151,-1.5,1.5,20, -10,10);
718  fh3BeforeNUAWeightsPion->Sumw2();
720  fh3BeforeNUAWeightsKaon = new TH3D("fh3BeforeNUAWeightsKaon","Weights: K; #varphi; #eta; Prim. vtx_{z} (cm)", 100,0,TMath::TwoPi(), 151,-1.5,1.5,20, -10,10);
721  fh3BeforeNUAWeightsKaon->Sumw2();
723  fh3BeforeNUAWeightsProton = new TH3D("fh3BeforeNUAWeightsProton","Weights: p; #varphi; #eta; Prim. vtx_{z} (cm)", 100,0,TMath::TwoPi(), 151,-1.5,1.5,20, -10,10);
724  fh3BeforeNUAWeightsProton->Sumw2();
726 
727  fhBeforeNUEWeightsRefs = new TH1D("fhBeforeNUEWeightsRefs","Weights: Refs; #it{p}_{T} (GeV/#it{c})",fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
728  fhBeforeNUEWeightsRefs->Sumw2();
730  fhBeforeNUEWeightsCharged = new TH1D("fhBeforeNUEWeightsCharged","Weights: Charged; #it{p}_{T} (GeV/#it{c})",fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
731  fhBeforeNUEWeightsCharged->Sumw2();
733  fhBeforeNUEWeightsPion = new TH1D("fhBeforeNUEWeightsPion","Weights: #pi; #it{p}_{T} (GeV/#it{c})",fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
734  fhBeforeNUEWeightsPion->Sumw2();
736  fhBeforeNUEWeightsKaon = new TH1D("fhBeforeNUEWeightsKaon","Weights: K; #it{p}_{T} (GeV/#it{c})",fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
737  fhBeforeNUEWeightsKaon->Sumw2();
739  fhBeforeNUEWeightsProton = new TH1D("fhBeforeNUEWeightsProton","Weights: p; #it{p}_{T} (GeV/#it{c})",fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
740  fhBeforeNUEWeightsProton->Sumw2();
742  }//if(fFlowFillWeights || fRunMode == kFillWeights)
743 
745  {
746  fh3AfterNUAWeightsRefs = new TH3D("fh3AfterNUAWeightsRefs","Weights: Refs; #varphi; #eta; Prim. vtx_{z} (cm)", 100,0,TMath::TwoPi(), 151,-1.5,1.5, 20, -10,10);
747  fh3AfterNUAWeightsRefs->Sumw2();
749  fh3AfterNUAWeightsCharged = new TH3D("fh3AfterNUAWeightsCharged","Weights: Charged; #varphi; #eta; Prim. vtx_{z} (cm)", 100,0,TMath::TwoPi(), 151,-1.5,1.5,20, -10,10);
750  fh3AfterNUAWeightsCharged->Sumw2();
752  fh3AfterNUAWeightsPion = new TH3D("fh3AfterNUAWeightsPion","Weights: #pi; #varphi; #eta; Prim. vtx_{z} (cm)", 100,0,TMath::TwoPi(), 151,-1.5,1.5,20, -10,10);
753  fh3AfterNUAWeightsPion->Sumw2();
755  fh3AfterNUAWeightsKaon = new TH3D("fh3AfterNUAWeightsKaon","Weights: K; #varphi; #eta; Prim. vtx_{z} (cm)", 100,0,TMath::TwoPi(), 151,-1.5,1.5,20, -10,10);
756  fh3AfterNUAWeightsKaon->Sumw2();
758  fh3AfterNUAWeightsProton = new TH3D("fh3AfterNUAWeightsProton","Weights: p; #varphi; #eta; Prim. vtx_{z} (cm)", 100,0,TMath::TwoPi(), 151,-1.5,1.5,20, -10,10);
759  fh3AfterNUAWeightsProton->Sumw2();
761  }//if(fFlowUseNUAWeights)
762  if(fFlowUseNUEWeights){
763  fhAfterNUEWeightsRefs = new TH1D("fhAfterNUEWeightsRefs","Weights: Refs; #it{p}_{T} (GeV/#it{c})",fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
764  fhAfterNUEWeightsRefs->Sumw2();
766  fhAfterNUEWeightsCharged = new TH1D("fhAfterNUEWeightsCharged","Weights: Charged; #it{p}_{T} (GeV/#it{c})",fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
767  fhAfterNUEWeightsCharged->Sumw2();
769  fhAfterNUEWeightsPion = new TH1D("fhAfterNUEWeightsPion","Weights: #pi; #it{p}_{T} (GeV/#it{c})",fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
770  fhAfterNUEWeightsPion->Sumw2();
772  fhAfterNUEWeightsKaon = new TH1D("fhAfterNUEWeightsKaon","Weights: K; #it{p}_{T} (GeV/#it{c})",fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
773  fhAfterNUEWeightsKaon->Sumw2();
775  fhAfterNUEWeightsProton = new TH1D("fhAfterNUEWeightsProton","Weights: p; #it{p}_{T} (GeV/#it{c})",fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
776  fhAfterNUEWeightsProton->Sumw2();
778  }//if(fFlowUseNUEWeights)
779 
780 
781  //mixed correlations
782  //
784  for(Short_t iMixedHarm(0); iMixedHarm < fNumMixedHarmonics; iMixedHarm++)
785  {
786  for(Short_t iGap(0); iGap < fNumEtaGap; iGap++)//For now only for nonoverlapping subevents...
787  {
788  for(Short_t iSample(0); iSample < fNumSamples; iSample++)
789  {
790  //reference flow for mixed harmonics 422,633,523
791  if(iMixedHarm!=3){
792  fpMixedRefsCor4[iSample][iGap][iMixedHarm] = new TProfile(Form("fpRefs_<4>_MixedHarm%d_gap%02.2g_sample%d",fMixedHarmonics[iMixedHarm],10*fEtaGap[iGap],iSample),Form("Ref: <<4>> | Gap %g | v%d | sample %d ; centrality/multiplicity;",fEtaGap[iGap],fMixedHarmonics[iMixedHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax);
793  fpMixedRefsCor4[iSample][iGap][iMixedHarm]->Sumw2(kTRUE);
794  fFlowRefs->Add(fpMixedRefsCor4[iSample][iGap][iMixedHarm]);
795  }
796  if(iMixedHarm==3){
797  //reference flow for mixed harmonics 6222
798  fpMixedRefsCor6[iSample][iGap] = new TProfile(Form("fpRefs_<6>_MixedHarm%d_gap%02.2g_sample%d",fMixedHarmonics[iMixedHarm],10*fEtaGap[iGap],iSample),Form("Ref: <<6>> | Gap %g | v%d | sample %d ; centrality/multiplicity;",fEtaGap[iGap],fMixedHarmonics[iMixedHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax);
799  fpMixedRefsCor6[iSample][iGap]->Sumw2(kTRUE);
800  fFlowRefs->Add(fpMixedRefsCor6[iSample][iGap]);
801  }
802 
803  if(fProcessCharged){
804  if(iMixedHarm!=3){
805  fpMixedChargedCor3Pos[iSample][iGap][iMixedHarm] = new TProfile2D(Form("fp2Charged_<3>_MixedHarm%d_gap%02.2g_Pos_sample%d",fMixedHarmonics[iMixedHarm],10*fEtaGap[iGap],iSample),Form("Charged: <<3'>> | Gap %g | v%d | POIs pos | sample %d ; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fMixedHarmonics[iMixedHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
806  fpMixedChargedCor3Pos[iSample][iGap][iMixedHarm]->Sumw2(kTRUE);
807  fFlowCharged->Add(fpMixedChargedCor3Pos[iSample][iGap][iMixedHarm]);
808 
809  fpMixedChargedCor3Neg[iSample][iGap][iMixedHarm] = new TProfile2D(Form("fp2Charged_<3>_MixedHarm%d_gap%02.2g_Neg_sample%d",fMixedHarmonics[iMixedHarm],10*fEtaGap[iGap],iSample),Form("Charged: <<3'>> | Gap %g | v%d | POIs neg | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fMixedHarmonics[iMixedHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
810  fpMixedChargedCor3Neg[iSample][iGap][iMixedHarm]->Sumw2(kTRUE);
811  fFlowCharged->Add(fpMixedChargedCor3Neg[iSample][iGap][iMixedHarm]);
812  }
813  if(iMixedHarm==3){
814  fpMixedChargedCor4Pos[iSample][iGap] = new TProfile2D(Form("fp2Charged_<4>_MixedHarm%d_gap%02.2g_Pos_sample%d",fMixedHarmonics[iMixedHarm],10*fEtaGap[iGap],iSample),Form("Charged: <<4'>> | Gap %g | v%d | POIs pos | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fMixedHarmonics[iMixedHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
815  fpMixedChargedCor4Pos[iSample][iGap]->Sumw2(kTRUE);
816  fFlowCharged->Add(fpMixedChargedCor4Pos[iSample][iGap]);
817 
818  fpMixedChargedCor4Neg[iSample][iGap] = new TProfile2D(Form("fp2Charged_<4>_MixedHarm%d_gap%02.2g_Neg_sample%d",fMixedHarmonics[iMixedHarm],10*fEtaGap[iGap],iSample),Form("Charged: <<4'>> | Gap %g | v%d | POIs neg | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fMixedHarmonics[iMixedHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
819  fpMixedChargedCor4Neg[iSample][iGap]->Sumw2(kTRUE);
820  fFlowCharged->Add(fpMixedChargedCor4Neg[iSample][iGap]);
821  }
822  }//if(fProcessCharged)
823  if(fProcessPID){
824  if(iMixedHarm!=3){
825  fpMixedPionCor3Pos[iSample][iGap][iMixedHarm] = new TProfile2D(Form("fp2Pion_<3>_MixedHarm%d_gap%02.2g_Pos_sample%d",fMixedHarmonics[iMixedHarm],10*fEtaGap[iGap],iSample),Form("Pion: <<3'>> | Gap %g | v%d | POIs pos | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fMixedHarmonics[iMixedHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
826  fpMixedPionCor3Pos[iSample][iGap][iMixedHarm]->Sumw2(kTRUE);
827  fFlowPID->Add(fpMixedPionCor3Pos[iSample][iGap][iMixedHarm]);
828 
829  fpMixedPionCor3Neg[iSample][iGap][iMixedHarm] = new TProfile2D(Form("fp2Pion_<3>_MixedHarm%d_gap%02.2g_Neg_sample%d",fMixedHarmonics[iMixedHarm],10*fEtaGap[iGap],iSample),Form("Pion: <<3'>> | Gap %g | v%d | POIs neg | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fMixedHarmonics[iMixedHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
830  fpMixedPionCor3Neg[iSample][iGap][iMixedHarm]->Sumw2(kTRUE);
831  fFlowPID->Add(fpMixedPionCor3Neg[iSample][iGap][iMixedHarm]);
832 
833  fpMixedKaonCor3Pos[iSample][iGap][iMixedHarm] = new TProfile2D(Form("fp2Kaon_<3>_MixedHarm%d_gap%02.2g_Pos_sample%d",fMixedHarmonics[iMixedHarm],10*fEtaGap[iGap],iSample),Form("Pion: <<3'>> | Gap %g | v%d | POIs pos | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fMixedHarmonics[iMixedHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
834  fpMixedKaonCor3Pos[iSample][iGap][iMixedHarm]->Sumw2(kTRUE);
835  fFlowPID->Add(fpMixedKaonCor3Pos[iSample][iGap][iMixedHarm]);
836 
837  fpMixedKaonCor3Neg[iSample][iGap][iMixedHarm] = new TProfile2D(Form("fp2Kaon_<3>_MixedHarm%d_gap%02.2g_Neg_sample%d",fMixedHarmonics[iMixedHarm],10*fEtaGap[iGap],iSample),Form("Kaon: <<3'>> | Gap %g | v%d | POIs neg | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fMixedHarmonics[iMixedHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
838  fpMixedKaonCor3Neg[iSample][iGap][iMixedHarm]->Sumw2(kTRUE);
839  fFlowPID->Add(fpMixedKaonCor3Neg[iSample][iGap][iMixedHarm]);
840 
841  fpMixedProtonCor3Pos[iSample][iGap][iMixedHarm] = new TProfile2D(Form("fp2Proton_<3>_MixedHarm%d_gap%02.2g_Pos_sample%d",fMixedHarmonics[iMixedHarm],10*fEtaGap[iGap],iSample),Form("Proton: <<3'>> | Gap %g | v%d | POIs pos | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fMixedHarmonics[iMixedHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
842  fpMixedProtonCor3Pos[iSample][iGap][iMixedHarm]->Sumw2(kTRUE);
843  fFlowPID->Add(fpMixedProtonCor3Pos[iSample][iGap][iMixedHarm]);
844 
845  fpMixedProtonCor3Neg[iSample][iGap][iMixedHarm] = new TProfile2D(Form("fp2Proton_<3>_MixedHarm%d_gap%02.2g_Neg_sample%d",fMixedHarmonics[iMixedHarm],10*fEtaGap[iGap],iSample),Form("Proton: <<3'>> | Gap %g | v%d | POIs neg | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fMixedHarmonics[iMixedHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
846  fpMixedProtonCor3Neg[iSample][iGap][iMixedHarm]->Sumw2(kTRUE);
847  fFlowPID->Add(fpMixedProtonCor3Neg[iSample][iGap][iMixedHarm]);
848  }
849  if(iMixedHarm==3){
850  fpMixedPionCor4Pos[iSample][iGap] = new TProfile2D(Form("fp2Pion_<4>_MixedHarm%d_gap%02.2g_Pos_sample%d",fMixedHarmonics[iMixedHarm],10*fEtaGap[iGap],iSample),Form("Pion: <<4'>> | Gap %g | v%d | POIs pos | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fMixedHarmonics[iMixedHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
851  fpMixedPionCor4Pos[iSample][iGap]->Sumw2(kTRUE);
852  fFlowPID->Add(fpMixedPionCor4Pos[iSample][iGap]);
853 
854  fpMixedPionCor4Neg[iSample][iGap] = new TProfile2D(Form("fp2Pion_<4>_MixedHarm%d_gap%02.2g_Neg_sample%d",fMixedHarmonics[iMixedHarm],10*fEtaGap[iGap],iSample),Form("Pion: <<4'>> | Gap %g | v%d | POIs neg | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fMixedHarmonics[iMixedHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
855  fpMixedPionCor4Neg[iSample][iGap]->Sumw2(kTRUE);
856  fFlowPID->Add(fpMixedPionCor4Neg[iSample][iGap]);
857 
858  fpMixedKaonCor4Pos[iSample][iGap] = new TProfile2D(Form("fp2Kaon_<4>_MixedHarm%d_gap%02.2g_Pos_sample%d",fMixedHarmonics[iMixedHarm],10*fEtaGap[iGap],iSample),Form("Kaon: <<4'>> | Gap %g | v%d | POIs pos | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fMixedHarmonics[iMixedHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
859  fpMixedKaonCor4Pos[iSample][iGap]->Sumw2(kTRUE);
860  fFlowPID->Add(fpMixedKaonCor4Pos[iSample][iGap]);
861 
862  fpMixedKaonCor4Neg[iSample][iGap] = new TProfile2D(Form("fp2Kaon_<4>_MixedHarm%d_gap%02.2g_Neg_sample%d",fMixedHarmonics[iMixedHarm],10*fEtaGap[iGap],iSample),Form("Kaon: <<4'>> | Gap %g | v%d | POIs neg | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fMixedHarmonics[iMixedHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
863  fpMixedKaonCor4Neg[iSample][iGap]->Sumw2(kTRUE);
864  fFlowPID->Add(fpMixedKaonCor4Neg[iSample][iGap]);
865 
866  fpMixedProtonCor4Pos[iSample][iGap] = new TProfile2D(Form("fp2Proton_<4>_MixedHarm%d_gap%02.2g_Pos_sample%d",fMixedHarmonics[iMixedHarm],10*fEtaGap[iGap],iSample),Form("Proton: <<4'>> | Gap %g | v%d | POIs pos | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fMixedHarmonics[iMixedHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
867  fpMixedProtonCor4Pos[iSample][iGap]->Sumw2(kTRUE);
868  fFlowPID->Add(fpMixedProtonCor4Pos[iSample][iGap]);
869 
870  fpMixedProtonCor4Neg[iSample][iGap] = new TProfile2D(Form("fp2Proton_<4>_MixedHarm%d_gap%02.2g_Neg_sample%d",fMixedHarmonics[iMixedHarm],10*fEtaGap[iGap],iSample),Form("Proton: <<4'>> | Gap %g | v%d | POIs neg | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fMixedHarmonics[iMixedHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
871  fpMixedProtonCor4Neg[iSample][iGap]->Sumw2(kTRUE);
872  fFlowPID->Add(fpMixedProtonCor4Neg[iSample][iGap]);
873  }
874  }//if(fProcessPID)
875  }//for(Short_t iSample(0); iSample < fNumSamples; iSample++)
876  }//for(Short_t iGap(0); iGap < fNumEtaGap; iGap++)
877  }//for(Short_t iMixedHarm(0); iMixedHarm < fNumMixedHarmonics; iMixedHarm++)
878  }//if(fDoOnlyMixedCorrelations)
879 
881  // correlations
882  for(Short_t iHarm(0); iHarm < fNumHarmonics; iHarm++)
883  {
884  for(Short_t iGap(0); iGap < fNumEtaGap; iGap++)
885  {
886  for(Short_t iSample(0); iSample < fNumSamples; iSample++)
887  {
888  fpRefsCor2[iSample][iGap][iHarm] = new TProfile(Form("fpRefs_<2>_harm%d_gap%02.2g_sample%d",fHarmonics[iHarm],10*fEtaGap[iGap],iSample),Form("Ref: <<2>> | Gap %g | n=%d | sample %d; centrality/multiplicity;",fEtaGap[iGap],fHarmonics[iHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax);
889  fpRefsCor2[iSample][iGap][iHarm]->Sumw2(kTRUE);
890  fFlowRefs->Add(fpRefsCor2[iSample][iGap][iHarm]);
891 
892  if(fProcessCharged)
893  {
894  fp2ChargedCor2Pos[iSample][iGap][iHarm] = new TProfile2D(Form("fp2Charged_<2>_harm%d_gap%02.2g_Pos_sample%d",fHarmonics[iHarm],10*fEtaGap[iGap],iSample),Form("Charged: <<2'>> | Gap %g | n=%d | POIs pos | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fHarmonics[iHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
895  fp2ChargedCor2Pos[iSample][iGap][iHarm]->Sumw2(kTRUE);
896  fFlowCharged->Add(fp2ChargedCor2Pos[iSample][iGap][iHarm]);
897 
898 
899  fp2ChargedCor2Neg[iSample][iGap][iHarm] = new TProfile2D(Form("fp2Charged_<2>_harm%d_gap%02.2g_Neg_sample%d",fHarmonics[iHarm],10*fEtaGap[iGap],iSample),Form("Charged: <<2'>> | Gap %g | n=%d | POIs neg | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fHarmonics[iHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
900  fp2ChargedCor2Neg[iSample][iGap][iHarm]->Sumw2(kTRUE);
901  fFlowCharged->Add(fp2ChargedCor2Neg[iSample][iGap][iHarm]);
902 
903  }//if(fProcessCharged)
904 
905  if(fProcessPID)
906  {
907  fp2PionCor2Pos[iSample][iGap][iHarm] = new TProfile2D(Form("fp2Pion_<2>_harm%d_gap%02.2g_Pos_sample%d",fHarmonics[iHarm],10*fEtaGap[iGap],iSample),Form("PID #pi: <<2'>> | Gap %g | n=%d | POIs pos | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fHarmonics[iHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
908  fp2PionCor2Pos[iSample][iGap][iHarm]->Sumw2(kTRUE);
909  fFlowPID->Add(fp2PionCor2Pos[iSample][iGap][iHarm]);
910 
911  fp2KaonCor2Pos[iSample][iGap][iHarm] = new TProfile2D(Form("fp2Kaon_<2>_harm%d_gap%02.2g_Pos_sample%d",fHarmonics[iHarm],10*fEtaGap[iGap],iSample),Form("PID K: <<2'>> | Gap %g | n=%d | POIs pos | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fHarmonics[iHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
912  fp2KaonCor2Pos[iSample][iGap][iHarm]->Sumw2(kTRUE);
913  fFlowPID->Add(fp2KaonCor2Pos[iSample][iGap][iHarm]);
914 
915  fp2ProtonCor2Pos[iSample][iGap][iHarm] = new TProfile2D(Form("fp2Proton_<2>_harm%d_gap%02.2g_Pos_sample%d",fHarmonics[iHarm],10*fEtaGap[iGap],iSample),Form("PID p: <<2'>> | Gap %g | n=%d | POIs pos | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fHarmonics[iHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
916  fp2ProtonCor2Pos[iSample][iGap][iHarm]->Sumw2(kTRUE);
917  fFlowPID->Add(fp2ProtonCor2Pos[iSample][iGap][iHarm]);
918 
919  fp2PionCor2Neg[iSample][iGap][iHarm] = new TProfile2D(Form("fp2Pion_<2>_harm%d_gap%02.2g_Neg_sample%d",fHarmonics[iHarm],10*fEtaGap[iGap],iSample),Form("PID #pi: <<2'>> | Gap %g | n=%d | POIs neg | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fHarmonics[iHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
920  fp2PionCor2Neg[iSample][iGap][iHarm]->Sumw2(kTRUE);
921  fFlowPID->Add(fp2PionCor2Neg[iSample][iGap][iHarm]);
922 
923  fp2KaonCor2Neg[iSample][iGap][iHarm] = new TProfile2D(Form("fp2Kaon_<2>_harm%d_gap%02.2g_Neg_sample%d",fHarmonics[iHarm],10*fEtaGap[iGap],iSample),Form("PID K: <<2'>> | Gap %g | n=%d | POIs neg | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fHarmonics[iHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
924  fp2KaonCor2Neg[iSample][iGap][iHarm]->Sumw2(kTRUE);
925  fFlowPID->Add(fp2KaonCor2Neg[iSample][iGap][iHarm]);
926 
927  fp2ProtonCor2Neg[iSample][iGap][iHarm] = new TProfile2D(Form("fp2Proton_<2>_harm%d_gap%02.2g_Neg_sample%d",fHarmonics[iHarm],10*fEtaGap[iGap],iSample),Form("PID p: <<2'>> | Gap %g | n=%d | POIs neg | sample %d; centrality/multiplicity; #it{p}_{T} (GeV/c)",fEtaGap[iGap],fHarmonics[iHarm],iSample), fFlowCentNumBins,fFlowCentMin,fFlowCentMax, fFlowPOIsPtNumBins,fFlowPOIsPtMin,fFlowPOIsPtMax);
928  fp2ProtonCor2Neg[iSample][iGap][iHarm]->Sumw2(kTRUE);
929  fFlowPID->Add(fp2ProtonCor2Neg[iSample][iGap][iHarm]);
930  }//endif(fProcessPID)
931  }//for(Short_t iSample(0); iSample < fNumSamples; iSample++)
932  }//for(Short_t iGap(0); iGap < fNumEtaGap; iGap++)
933  }//for(Short_t iHarm(0); iHarm < fNumHarmonics; iHarm++)
934  }//endif(!fDoOnlyMixedCorrelations)
935 
936  // charged (tracks) histograms
937  fh2RefsMult = new TH2D("fh2RefsMult","RFPs: Centrality: Multiplicity; centrality; multiplicity",fFlowCentNumBins,0,fFlowCentNumBins,1000,0,1000);
938  fQACharged->Add(fh2RefsMult);
939  fh2RefsPt = new TH2D("fh2RefsPt","RFPs: #it{p}_{T}; centrality; #it{p}_{T} (GeV/#it{c})",fFlowCentNumBins,0,fFlowCentNumBins,300,0,30);
940  fQACharged->Add(fh2RefsPt);
941  fh2RefsEta = new TH2D("fh2RefsEta","RFPs: #eta; centrality; #eta",fFlowCentNumBins,0,fFlowCentNumBins, 151,-1.5,1.5);
942  fQACharged->Add(fh2RefsEta);
943  fh2RefsPhi = new TH2D("fh2RefsPhi","RFPs: #varphi; centrality; #varphi",fFlowCentNumBins,0,fFlowCentNumBins,100,0,TMath::TwoPi());
944  fQACharged->Add(fh2RefsPhi);
945 
946  if(fProcessCharged)
947  {
948  TString sChargedCounterLabel[] = {"Input","FB","#TPC-Cls","TPC-Chi2","DCA-z","DCA-xy","Eta","Selected"};
949  const Short_t iNBinsChargedCounter = sizeof(sChargedCounterLabel)/sizeof(sChargedCounterLabel[0]);
950  fhChargedCounter = new TH1D("fhChargedCounter","Charged tracks: Counter",iNBinsChargedCounter,0,iNBinsChargedCounter);
951  for(Short_t i(0); i < iNBinsChargedCounter; i++) fhChargedCounter->GetXaxis()->SetBinLabel(i+1, sChargedCounterLabel[i].Data() );
953  } // endif {fProcessCharged}
954 
955  // PID tracks histograms
956  if(fProcessPID)
957  {
958  fh2PIDPionMult = new TH2D("fh2PIDPionMult","PID: #pi: Multiplicity; centrality; multiplicity", fFlowCentNumBins,0,fFlowCentNumBins,200,0,200);
959  fQAPID->Add(fh2PIDPionMult);
960  fh2PIDKaonMult = new TH2D("fh2PIDKaonMult","PID: K: Multiplicity; centrality; multiplicity", fFlowCentNumBins,0,fFlowCentNumBins,100,0,100);
961  fQAPID->Add(fh2PIDKaonMult);
962  fh2PIDProtonMult = new TH2D("fh2PIDProtonMult","PID: p: Multiplicity; centrality; multiplicity", fFlowCentNumBins,0,fFlowCentNumBins,100,0,100);
963  fQAPID->Add(fh2PIDProtonMult);
964 
965  if(fFillQA)
966  {
967  fh2PIDPionPt = new TH2D("fh2PIDPionPt","PID: #pi: centrality vs. #it{p}_{T}; centrality; #it{p}_{T}", fFlowCentNumBins,0,fFlowCentNumBins,150,0.,30.);
968  fQAPID->Add(fh2PIDPionPt);
969  fh2PIDPionPhi = new TH2D("fh2PIDPionPhi","PID: #pi: centrality vs. #varphi; centrality; #varphi", fFlowCentNumBins,0,fFlowCentNumBins,100,0,TMath::TwoPi());
970  fQAPID->Add(fh2PIDPionPhi);
971  fh2PIDPionEta = new TH2D("fh2PIDPionEta","PID: #pi: centrality vs. #eta; centrality; #eta", fFlowCentNumBins,0,fFlowCentNumBins,151,-1.5,1.5);
972  fQAPID->Add(fh2PIDPionEta);
973  fhPIDPionCharge = new TH1D("fhPIDPionCharge","PID: #pi: charge; charge", 3,-1.5,1.5);
974  fQAPID->Add(fhPIDPionCharge);
975  fh2PIDKaonPt = new TH2D("fh2PIDKaonPt","PID: K: centrality vs. #it{p}_{T}; centrality; #it{p}_{T}", fFlowCentNumBins,0,fFlowCentNumBins,150,0.,30.);
976  fQAPID->Add(fh2PIDKaonPt);
977  fh2PIDKaonPhi = new TH2D("fh2PIDKaonPhi","PID: K: centrality vs. #varphi; centrality; #varphi", fFlowCentNumBins,0,fFlowCentNumBins,100,0,TMath::TwoPi());
978  fQAPID->Add(fh2PIDKaonPhi);
979  fh2PIDKaonEta = new TH2D("fh2PIDKaonEta","PID: K: centrality vs. #eta; centrality; #eta", fFlowCentNumBins,0,fFlowCentNumBins,151,-1.5,1.5);
980  fQAPID->Add(fh2PIDKaonEta);
981  fhPIDKaonCharge = new TH1D("fhPIDKaonCharge","PID: K: charge; charge", 3,-1.5,1.5);
982  fQAPID->Add(fhPIDKaonCharge);
983  fh2PIDProtonPt = new TH2D("fh2PIDProtonPt","PID: p: centrality vs. #it{p}_{T}; centrality; #it{p}_{T}", fFlowCentNumBins,0,fFlowCentNumBins,150,0.,30.);
984  fQAPID->Add(fh2PIDProtonPt);
985  fh2PIDProtonPhi = new TH2D("fh2PIDProtonPhi","PID: p: centrality vs. #varphi; centrality; #varphi", fFlowCentNumBins,0,fFlowCentNumBins,100,0,TMath::TwoPi());
986  fQAPID->Add(fh2PIDProtonPhi);
987  fh2PIDProtonEta = new TH2D("fh2PIDProtonEta","PID: p: centrality vs. #eta; centrality; #eta", fFlowCentNumBins,0,fFlowCentNumBins,151,-1.5,1.5);
988  fQAPID->Add(fh2PIDProtonEta);
989  fhPIDProtonCharge = new TH1D("fhPIDProtonCharge","PID: p: charge; charge", 3,-1.5,1.5);
991  fh2PIDPionTPCdEdx = new TH2D("fh2PIDPionTPCdEdx","PID: #pi: TPC dE/dx; #it{p} (GeV/#it{c}); TPC dE/dx", 200,0,20, 131,-10,1000);
993  fh2PIDPionTOFbeta = new TH2D("fh2PIDPionTOFbeta","PID: #pi: TOF #beta; #it{p} (GeV/#it{c});TOF #beta", 200,0,20, 101,-0.1,1.5);
995  fh2PIDKaonTPCdEdx = new TH2D("fh2PIDKaonTPCdEdx","PID: K: TPC dE/dx; #it{p} (GeV/#it{c}); TPC dE/dx", 200,0,20, 131,-10,1000);
997  fh2PIDKaonTOFbeta = new TH2D("fh2PIDKaonTOFbeta","PID: K: TOF #beta; #it{p} (GeV/#it{c});TOF #beta", 200,0,20, 101,-0.1,1.5);
999  fh2PIDProtonTPCdEdx = new TH2D("fh2PIDProtonTPCdEdx","PID: p: TPC dE/dx; #it{p} (GeV/#it{c}); TPC dE/dx", 200,0,20, 131,-10,1000);
1001  fh2PIDProtonTOFbeta = new TH2D("fh2PIDProtonTOFbeta","PID: p: TOF #beta; #it{p} (GeV/#it{c});TOF #beta", 200,0,20, 101,-0.1,1.5);
1003  fh2PIDPionTPCnSigmaPion = new TH2D("fh2PIDPionTPCnSigmaPion","PID: #pi: TPC n#sigma (#pi hyp.); #it{p}_{T} (GeV/#it{c}); TPC n#sigma", 200,0,20, 42,-11,10);
1005  fh2PIDPionTOFnSigmaPion = new TH2D("fh2PIDPionTOFnSigmaPion","PID: #pi: TOF n#sigma (#pi hyp.); #it{p}_{T} (GeV/#it{c}); TOF n#sigma", 200,0,20, 42,-11,10);
1007  fh2PIDPionTPCnSigmaKaon = new TH2D("fh2PIDPionTPCnSigmaKaon","PID: #pi: TPC n#sigma (K hyp.); #it{p}_{T} (GeV/#it{c}); TPC n#sigma", 200,0,20, 42,-11,10);
1009  fh2PIDPionTOFnSigmaKaon = new TH2D("fh2PIDPionTOFnSigmaKaon","PID: #pi: TOF n#sigma (K hyp.); #it{p}_{T} (GeV/#it{c}); TOF n#sigma", 200,0,20, 42,-11,10);
1011  fh2PIDPionTPCnSigmaProton = new TH2D("fh2PIDPionTPCnSigmaProton","PID: #pi: TPC n#sigma (p hyp.); #it{p}_{T} (GeV/#it{c}); TPC n#sigma", 200,0,20, 42,-11,10);
1013  fh2PIDPionTOFnSigmaProton = new TH2D("fh2PIDPionTOFnSigmaProton","PID: #pi: TOF n#sigma (p hyp.); #it{p}_{T} (GeV/#it{c}); TOF n#sigma", 200,0,20, 42,-11,10);
1015  fh2PIDKaonTPCnSigmaPion = new TH2D("fh2PIDKaonTPCnSigmaPion","PID: K: TPC n#sigma (#pi hyp.); #it{p}_{T} (GeV/#it{c}); TPC n#sigma", 200,0,20, 42,-11,10);
1017  fh2PIDKaonTOFnSigmaPion = new TH2D("fh2PIDKaonTOFnSigmaPion","PID: K: TOF n#sigma (#pi hyp.); #it{p}_{T} (GeV/#it{c}); TOF n#sigma", 200,0,20, 42,-11,10);
1019  fh2PIDKaonTPCnSigmaKaon = new TH2D("fh2PIDKaonTPCnSigmaKaon","PID: K: TPC n#sigma (K hyp.); #it{p}_{T} (GeV/#it{c}); TPC n#sigma", 200,0,20, 42,-11,10);
1021  fh2PIDKaonTOFnSigmaKaon = new TH2D("fh2PIDKaonTOFnSigmaKaon","PID: K: TOF n#sigma (K hyp.); #it{p}_{T} (GeV/#it{c}); TOF n#sigma", 200,0,20, 42,-11,10);
1023  fh2PIDKaonTPCnSigmaProton = new TH2D("fh2PIDKaonTPCnSigmaProton","PID: K: TPC n#sigma (p hyp.); #it{p}_{T} (GeV/#it{c}); TPC n#sigma", 200,0,20, 42,-11,10);
1025  fh2PIDKaonTOFnSigmaProton = new TH2D("fh2PIDKaonTOFnSigmaProton","PID: K: TOF n#sigma (p hyp.); #it{p}_{T} (GeV/#it{c}); TOF n#sigma", 200,0,20, 42,-11,10);
1027  fh2PIDProtonTPCnSigmaPion = new TH2D("fh2PIDProtonTPCnSigmaPion","PID: p: TPC n#sigma (#pi hyp.); #it{p}_{T} (GeV/#it{c}); TPC n#sigma", 200,0,20, 42,-11,10);
1029  fh2PIDProtonTOFnSigmaPion = new TH2D("fh2PIDProtonTOFnSigmaPion","PID: p: TOF n#sigma (#pi hyp.); #it{p}_{T} (GeV/#it{c}); TOF n#sigma", 200,0,20, 42,-11,10);
1031  fh2PIDProtonTPCnSigmaKaon = new TH2D("fh2PIDProtonTPCnSigmaKaon","PID: p: TPC n#sigma (K hyp.); #it{p}_{T} (GeV/#it{c}); TPC n#sigma", 200,0,20, 42,-11,10);
1033  fh2PIDProtonTOFnSigmaKaon = new TH2D("fh2PIDProtonTOFnSigmaKaon","PID: p: TOF n#sigma (K hyp.); #it{p}_{T} (GeV/#it{c}); TOF n#sigma", 200,0,20, 42,-11,10);
1035  fh2PIDProtonTPCnSigmaProton = new TH2D("fh2PIDProtonTPCnSigmaProton","PID: p: TPC n#sigma (p hyp.); #it{p}_{T} (GeV/#it{c}); TPC n#sigma", 200,0,20, 42,-11,10);
1037  fh2PIDProtonTOFnSigmaProton = new TH2D("fh2PIDProtonTOFnSigmaProton","PID: p: TOF n#sigma (p hyp.); #it{p}_{T} (GeV/#it{c}); TOF n#sigma", 200,0,20, 42,-11,10);
1039  }
1040 
1041  } //endif {fProcessPID}
1042 
1043  const Short_t iNBinsPIDstatus = 4;
1044  TString sPIDstatus[iNBinsPIDstatus] = {"kDetNoSignal","kDetPidOk","kDetMismatch","kDetNoParams"};
1045  const Short_t iNFilterMapBinBins = 32;
1046 
1047  // QA histograms
1048  if(fFillQA)
1049  {
1050  TString sQAindex[fiNumIndexQA] = {"Before", "After"};
1051  for(Short_t iQA(0); iQA < fiNumIndexQA; iQA++)
1052  {
1053  // EVENTs QA histograms
1054  fhQAEventsPVz[iQA] = new TH1D(Form("fhQAEventsPVz_%s",sQAindex[iQA].Data()), "QA Events: PV-#it{z}", 101,-50,50);
1055  fQAEvents->Add(fhQAEventsPVz[iQA]);
1056  fhQAEventsNumContrPV[iQA] = new TH1D(Form("fhQAEventsNumContrPV_%s",sQAindex[iQA].Data()), "QA Events: Number of contributors to AOD PV", 20,0,20);
1057  fQAEvents->Add(fhQAEventsNumContrPV[iQA]);
1058  fhQAEventsNumSPDContrPV[iQA] = new TH1D(Form("fhQAEventsNumSPDContrPV_%s",sQAindex[iQA].Data()), "QA Events: SPD contributors to PV", 20,0,20);
1060  fhQAEventsDistPVSPD[iQA] = new TH1D(Form("fhQAEventsDistPVSPD_%s",sQAindex[iQA].Data()), "QA Events: PV SPD vertex", 50,0,5);
1061  fQAEvents->Add(fhQAEventsDistPVSPD[iQA]);
1062  fhQAEventsSPDresol[iQA] = new TH1D(Form("fhQAEventsSPDresol_%s",sQAindex[iQA].Data()), "QA Events: SPD resolution", 150,0,15);
1063  fQAEvents->Add(fhQAEventsSPDresol[iQA]);
1064 
1065  fhQAEventsCentralityOutliers[iQA] = new TH2D(Form("fhQAEventsCentralityOutliers_%s",sQAindex[iQA].Data()),"QA Events: Centrality distribution; centrality percentile (V0M);centrality percentile (CL1)",100,0,100,100,0,100);
1067 
1068  fhQAEventsPileUp[iQA] = new TH2D(Form("fhQAEventsPileUp_%s",sQAindex[iQA].Data()),"QA Events: TPC vs. ESD multiplicity; TPC multiplicity; ESD multiplicity",500,0,6000,500,0,6000);
1069  fQAEvents->Add(fhQAEventsPileUp[iQA]);
1070  fhEventsMultTOFFilterbit32[iQA] = new TH2D(Form("fhEventsMultTOFFilterbit32_%s",sQAindex[iQA].Data()),"filterbit32 vs. TOF multiplicity; multiplicity(fb32);multiplicity(fb32+TOF)", 4000,0,4000,2000,0,2000);
1072  // Charged tracks QA
1073  if(fProcessCharged)
1074  {
1075  fhQAChargedMult[iQA] = new TH1D(Form("fhQAChargedMult_%s",sQAindex[iQA].Data()),"QA Charged: Number of Charged in selected events; #it{N}^{Charged}", 1500,0,1500);
1076  fQACharged->Add(fhQAChargedMult[iQA]);
1077  fhQAChargedCharge[iQA] = new TH1D(Form("fhQAChargedCharge_%s",sQAindex[iQA].Data()),"QA Charged: Track charge; charge;", 3,-1.5,1.5);
1078  fQACharged->Add(fhQAChargedCharge[iQA]);
1079  fhQAChargedPt[iQA] = new TH1D(Form("fhQAChargedPt_%s",sQAindex[iQA].Data()),"QA Charged: Track #it{p}_{T}; #it{p}_{T} (GeV/#it{c})", 300,0.,30.);
1080  fQACharged->Add(fhQAChargedPt[iQA]);
1081  fhQAChargedEta[iQA] = new TH1D(Form("fhQAChargedEta_%s",sQAindex[iQA].Data()),"QA Charged: Track #it{#eta}; #it{#eta}", 151,-1.5,1.5);
1082  fQACharged->Add(fhQAChargedEta[iQA]);
1083  fhQAChargedPhi[iQA] = new TH1D(Form("fhQAChargedPhi_%s",sQAindex[iQA].Data()),"QA Charged: Track #it{#varphi}; #it{#varphi}", 100,0.,TMath::TwoPi());
1084  fQACharged->Add(fhQAChargedPhi[iQA]);
1085  fhQAChargedFilterBit[iQA] = new TH1D(Form("fhQAChargedFilterBit_%s",sQAindex[iQA].Data()), "QA Charged: Filter bit",iNFilterMapBinBins,0,iNFilterMapBinBins);
1086  for(Int_t j = 0x0; j < iNFilterMapBinBins; j++) fhQAChargedFilterBit[iQA]->GetXaxis()->SetBinLabel(j+1, Form("%g",TMath::Power(2,j)));
1087  fQACharged->Add(fhQAChargedFilterBit[iQA]);
1088  fhQAChargedNumTPCcls[iQA] = new TH1D(Form("fhQAChargedNumTPCcls_%s",sQAindex[iQA].Data()),"QA Charged: Track number of TPC clusters; #it{N}^{TPC clusters}", 160,0,160);
1089  fQACharged->Add(fhQAChargedNumTPCcls[iQA]);
1090  fhQAChargedDCAxy[iQA] = new TH1D(Form("fhQAChargedDCAxy_%s",sQAindex[iQA].Data()),"QA Charged: Track DCA-xy; DCA_{#it{xy}} (cm)", 100,0.,10);
1091  fQACharged->Add(fhQAChargedDCAxy[iQA]);
1092  fhQAChargedDCAz[iQA] = new TH1D(Form("fhQAChargedDCAz_%s",sQAindex[iQA].Data()),"QA Charged: Track DCA-z; DCA_{#it{z}} (cm)", 200,-10.,10.);
1093  fQACharged->Add(fhQAChargedDCAz[iQA]);
1094  } // endif {fProcessCharged}
1095 
1096  // PID tracks QA
1097  if(fProcessPID)
1098  {
1099  fhQAPIDTPCstatus[iQA] = new TH1D(Form("fhQAPIDTPCstatus_%s",sQAindex[iQA].Data()),"QA PID: PID status: TPC;", iNBinsPIDstatus,0,iNBinsPIDstatus);
1100  fQAPID->Add(fhQAPIDTPCstatus[iQA]);
1101  fhQAPIDTPCdEdx[iQA] = new TH2D(Form("fhQAPIDTPCdEdx_%s",sQAindex[iQA].Data()),"QA PID: TPC PID information; #it{p} (GeV/#it{c}); TPC dEdx (au)", 100,0,10, 131,-10,1000);
1102  fQAPID->Add(fhQAPIDTPCdEdx[iQA]);
1103  fhQAPIDTOFstatus[iQA] = new TH1D(Form("fhQAPIDTOFstatus_%s",sQAindex[iQA].Data()),"QA PID: PID status: TOF;", iNBinsPIDstatus,0,iNBinsPIDstatus);
1104  fQAPID->Add(fhQAPIDTOFstatus[iQA]);
1105  fhQAPIDTOFbeta[iQA] = new TH2D(Form("fhQAPIDTOFbeta_%s",sQAindex[iQA].Data()),"QA PID: TOF #beta information; #it{p} (GeV/#it{c}); TOF #beta", 100,0,10, 101,-0.1,1.5);
1106  fQAPID->Add(fhQAPIDTOFbeta[iQA]);
1107 
1108  fh3PIDPionTPCTOFnSigmaPion[iQA] = new TH3D(Form("fh3PIDPionTPCTOFnSigmaPion_%s",sQAindex[iQA].Data()),"QA PID: #pi: TPC-TOF n#sigma (#pi hyp.); n#sigma^{TPC}; n#sigma^{TOF}; #it{p}_{T}", 22,-11,10, 22,-11,10, 100,0,10);
1110  fh3PIDPionTPCTOFnSigmaKaon[iQA] = new TH3D(Form("fh3PIDPionTPCTOFnSigmaKaon_%s",sQAindex[iQA].Data()),"QA PID: #pi: TPC-TOF n#sigma (K hyp.); n#sigma^{TPC}; n#sigma^{TOF}; #it{p}_{T}", 22,-11,10, 22,-11,10, 100,0,10);
1112  fh3PIDPionTPCTOFnSigmaProton[iQA] = new TH3D(Form("fh3PIDPionTPCTOFnSigmaProton_%s",sQAindex[iQA].Data()),"QA PID: #pi: TPC-TOF n#sigma (p hyp.); n#sigma^{TPC}; n#sigma^{TOF}; #it{p}_{T}", 22,-11,10, 22,-11,10, 100,0,10);
1114 
1115  fh3PIDKaonTPCTOFnSigmaPion[iQA] = new TH3D(Form("fh3PIDKaonTPCTOFnSigmaPion_%s",sQAindex[iQA].Data()),"QA PID: K: TPC-TOF n#sigma (#pi hyp.); n#sigma^{TPC}; n#sigma^{TOF}; #it{p}_{T}", 22,-11,10, 22,-11,10, 100,0,10);
1117  fh3PIDKaonTPCTOFnSigmaKaon[iQA] = new TH3D(Form("fh3PIDKaonTPCTOFnSigmaKaon_%s",sQAindex[iQA].Data()),"QA PID: K: TPC-TOF n#sigma (K hyp.); n#sigma^{TPC}; n#sigma^{TOF}; #it{p}_{T}", 22,-11,10, 22,-11,10, 100,0,10);
1119  fh3PIDKaonTPCTOFnSigmaProton[iQA] = new TH3D(Form("fh3PIDKaonTPCTOFnSigmaProton_%s",sQAindex[iQA].Data()),"QA PID: K: TPC-TOF n#sigma (p hyp.); n#sigma^{TPC}; n#sigma^{TOF}; #it{p}_{T}", 22,-11,10, 22,-11,10, 100,0,10);
1121 
1122  fh3PIDProtonTPCTOFnSigmaPion[iQA] = new TH3D(Form("fh3PIDProtonTPCTOFnSigmaPion_%s",sQAindex[iQA].Data()),"QA PID: p: TPC-TOF n#sigma (#pi hyp.); n#sigma^{TPC}; n#sigma^{TOF}; #it{p}_{T}", 22,-11,10, 22,-11,10, 100,0,10);
1124  fh3PIDProtonTPCTOFnSigmaKaon[iQA] = new TH3D(Form("fh3PIDProtonTPCTOFnSigmaKaon_%s",sQAindex[iQA].Data()),"QA PID: p: TPC-TOF n#sigma (K hyp.); n#sigma^{TPC}; n#sigma^{TOF}; #it{p}_{T}", 22,-11,10, 22,-11,10, 100,0,10);
1126  fh3PIDProtonTPCTOFnSigmaProton[iQA] = new TH3D(Form("fh3PIDProtonTPCTOFnSigmaProton_%s",sQAindex[iQA].Data()),"QA PID: p: TPC-TOF n#sigma (p hyp.); n#sigma^{TPC}; n#sigma^{TOF}; #it{p}_{T}", 22,-11,10, 22,-11,10, 100,0,10);
1128 
1129 
1130 
1131  for(Int_t j = 0x0; j < iNBinsPIDstatus; j++)
1132  {
1133  fhQAPIDTOFstatus[iQA]->GetXaxis()->SetBinLabel(j+1, sPIDstatus[j].Data() );
1134  fhQAPIDTPCstatus[iQA]->GetXaxis()->SetBinLabel(j+1, sPIDstatus[j].Data() );
1135  }
1136  } // endif {fProcessPID}
1137  }
1138  }
1139 
1140  // posting data (mandatory)
1141  PostData(1, fFlowRefs);
1142  PostData(2, fFlowCharged);
1143  PostData(3, fFlowPID);
1144  PostData(4, fQAEvents);
1145  PostData(5, fQACharged);
1146  PostData(6, fQAPID);
1147  PostData(7, fFlowWeights);
1148 
1149  return;
1150 }//AliAnalysisTaskFlowModes::UserCreateOutputObjects()
1151 //_____________________________________________________________________________
1153 {
1154  // lists all task parameters
1155  // *************************************************************
1156  printf("\n======= List of parameters ========================================\n");
1157  printf(" -------- Analysis task ---------------------------------------\n");
1158  printf(" fRunMode: (RunMode) %d\n", fRunMode);
1159  printf(" fAnalType: (AnalType) %d\n", fAnalType);
1160  printf(" fFillQA: (Bool_t) %s\n", fFillQA ? "kTRUE" : "kFALSE");
1161  printf(" fProcessCharged: (Bool_t) %s\n", fProcessCharged ? "kTRUE" : "kFALSE");
1162  printf(" fProcessPID: (Bool_t) %s\n", fProcessPID ? "kTRUE" : "kFALSE");
1163  printf(" -------- Flow related ----------------------------------------\n");
1164  printf(" fCutFlowDoFourCorrelations: (Bool_t) %s\n", fCutFlowDoFourCorrelations ? "kTRUE" : "kFALSE");
1165  printf(" fCutFlowRFPsPtMin: (Float_t) %g (GeV/c)\n", fCutFlowRFPsPtMin);
1166  printf(" fCutFlowRFPsPtMax: (Float_t) %g (GeV/c)\n", fCutFlowRFPsPtMax);
1167  printf(" fFlowPOIsPtMin: (Float_t) %g (GeV/c)\n", fFlowPOIsPtMin);
1168  printf(" fFlowPOIsPtMax: (Float_t) %g (GeV/c)\n", fFlowPOIsPtMax);
1169  printf(" fFlowCentNumBins: (Int_t) %d (GeV/c)\n", fFlowCentNumBins);
1170  printf(" fFlowCentMin: (Int_t) %d (GeV/c)\n", fFlowCentMin);
1171  printf(" fFlowCentMax: (Int_t) %d (GeV/c)\n", fFlowCentMax);
1172  printf(" fFlowUseNUAWeights: (Bool_t) %s\n", fFlowUseNUAWeights ? "kTRUE" : "kFALSE");
1173  printf(" fFlowUseNUEWeights: (Bool_t) %s\n", fFlowUseNUEWeights ? "kTRUE" : "kFALSE");
1174  printf(" fPositivelyChargedRef: (Bool_t) %s\n", fPositivelyChargedRef ? "kTRUE" : "kFALSE");
1175  printf(" fNegativelyChargedRef: (Bool_t) %s\n", fNegativelyChargedRef ? "kTRUE" : "kFALSE");
1176  printf(" fPositivelyChargedPOI: (Bool_t) %s\n", fPositivelyChargedPOI ? "kTRUE" : "kFALSE");
1177  printf(" fNegativelyChargedPOI: (Bool_t) %s\n", fNegativelyChargedPOI ? "kTRUE" : "kFALSE");
1178  printf(" fFlowNUAWeightsPath: (TString) '%s' \n", fFlowNUAWeightsPath.Data());
1179  printf(" fFlowNUEWeightsPath: (TString) '%s' \n", fFlowNUEWeightsPath.Data());
1180  printf(" -------- Events ----------------------------------------------\n");
1181  printf(" fTrigger: (Short_t) %d\n", fTrigger);
1182  printf(" fMultEstimator: (TString) '%s'\n", fMultEstimator.Data());
1183  printf(" fPVtxCutZ: (Double_t) %g (cm)\n", fPVtxCutZ);
1184  printf(" fFullCentralityRange: (Bool_t) runs over %s centrality range \n", fFullCentralityRange ? "0-100%" : "50-100%");
1185  printf(" -------- Charge tracks ---------------------------------------\n");
1186  printf(" fCutChargedTrackFilterBit: (UInt) %d\n", fCutChargedTrackFilterBit);
1187  printf(" fCutChargedNumTPCclsMin: (UShort_t) %d\n", fCutChargedNumTPCclsMin);
1188  printf(" fCutChargedEtaMax: (Float_t) %g\n", fCutChargedEtaMax);
1189  printf(" fCutChargedPtMin: (Float_t) %g (GeV/c)\n", fCutChargedPtMin);
1190  printf(" fCutChargedPtMax: (Float_t) %g (GeV/c)\n", fCutChargedPtMax);
1191  printf(" fCutChargedDCAzMax: (Float_t) %g (cm)\n", fCutChargedDCAzMax);
1192  printf(" fCutChargedDCAxyMax: (Float_t) %g (cm)\n", fCutChargedDCAxyMax);
1193  printf(" -------- PID (pi,K,p) tracks ---------------------------------\n");
1194  printf(" fCutPIDUseAntiProtonOnly: (Bool_t) %s\n", fCutPIDUseAntiProtonOnly ? "kTRUE" : "kFALSE");
1195  printf(" fCutPIDnSigmaCombinedNoTOFrejection: (Bool_t) %s\n", fCutPIDnSigmaCombinedNoTOFrejection ? "kTRUE" : "kFALSE");
1196  printf(" fCutPIDnSigmaPionMax: (Double_t) %g\n", fCutPIDnSigmaPionMax);
1197  printf(" fCutPIDnSigmaKaonMax: (Double_t) %g\n", fCutPIDnSigmaKaonMax);
1198  printf(" fCutPIDnSigmaProtonMax: (Double_t) %g\n", fCutPIDnSigmaProtonMax);
1199  printf("=====================================================================\n\n");
1200 
1201  return;
1202 }
1203 //_____________________________________________________________________________
1205 {
1206  // called once on beginning of task (within UserCreateOutputObjects method)
1207  // check if task parameters are specified and valid
1208  // returns kTRUE if succesfull
1209  // *************************************************************
1210 
1211  printf("====== InitializeTask AliAnalysisTaskFlowModes =========================\n");
1212 
1213  if(fAnalType != kESD && fAnalType != kAOD)
1214  {
1215  ::Error("InitializeTask","Analysis type not specified! Terminating!");
1216  return kFALSE;
1217  }
1218 
1219  if(fAnalType == kESD)
1220  {
1221  ::Error("InitializeTask","Analysis type: ESD not implemented! Terminating!");
1222  return kFALSE;
1223  }
1224 
1225  if(fColSystem != kPP && fColSystem != kPbPb)
1226  {
1227  ::Error("InitializeTask","Collisional system not specified! Terminating!");
1228  return kFALSE;
1229  }
1230 
1231  // checking PID response
1232  AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager();
1233  AliInputEventHandler* inputHandler = (AliInputEventHandler*)mgr->GetInputEventHandler();
1234  fPIDResponse = inputHandler->GetPIDResponse();
1235  if(!fPIDResponse)
1236  {
1237  ::Error("InitializeTask","AliPIDResponse object not found! Terminating!");
1238  return kFALSE;
1239  }
1240 
1241  fPIDCombined = new AliPIDCombined();
1242  if(!fPIDCombined)
1243  {
1244  ::Error("InitializeTask","AliPIDCombined object not found! Terminating!");
1245  return kFALSE;
1246  }
1247  fPIDCombined->SetDefaultTPCPriors();
1248  fPIDCombined->SetSelectedSpecies(5); // all particle species
1249  fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC+AliPIDResponse::kDetTOF); // setting TPC + TOF mask
1250 
1251  // checking cut setting
1252  ::Info("InitializeTask","Checking task parameters setting conflicts (ranges, etc)");
1254  {
1255  ::Error("InitializeTask","Cut: RFPs Pt range wrong!");
1256  return kFALSE;
1257  }
1258 
1259  // upper-case for multiplicity estimator
1260  fMultEstimator.ToUpper();
1261 
1262  // checking for weights source file
1263  if(fFlowUseNUAWeights && !fFlowNUAWeightsPath.EqualTo(""))
1264  {
1265  fFlowNUAWeightsFile = TFile::Open(Form("alien:///%s",fFlowNUAWeightsPath.Data()));
1266  if(!fFlowNUAWeightsFile)
1267  {
1268  ::Error("InitializeTask","NUA flow weights file not found");
1269  return kFALSE;
1270  }
1271  }
1272  if(fFlowUseNUEWeights && !fFlowNUEWeightsPath.EqualTo(""))
1273  {
1274  fFlowNUEWeightsFile = TFile::Open(Form("alien:///%s",fFlowNUEWeightsPath.Data()));
1275  if(!fFlowNUEWeightsFile)
1276  {
1277  ::Error("InitializeTask","NUE flow weights file not found");
1278  return kFALSE;
1279  }
1280  }
1281 
1282  ::Info("InitializeTask","Initialization succesfull!");
1283  printf("======================================================================\n\n");
1284  return kTRUE;
1285 }
1286 //_____________________________________________________________________________
1288 {
1289  // main method called for each event (event loop)
1290  // *************************************************************
1291 
1292  if(!fInit) return; // check if initialization succesfull
1293 
1294  // local event counter check: if running in test mode, it runs until the 50 events are succesfully processed
1295  if(fRunMode == kTest && fEventCounter >= fNumEventsAnalyse) return;
1296 
1297  // event selection
1298  fEventAOD = dynamic_cast<AliAODEvent*>(InputEvent());
1299  if(!EventSelection()) return;
1300 
1301  // processing of selected event
1302  if(!ProcessEvent()) return;
1303 
1304  // posting data (mandatory)
1305  PostData(1, fFlowRefs);
1306  PostData(2, fFlowCharged);
1307  PostData(3, fFlowPID);
1308  PostData(4, fQAEvents);
1309  PostData(5, fQACharged);
1310  PostData(6, fQAPID);
1311  PostData(7, fFlowWeights);
1312 
1313  return;
1314 }
1315 //_____________________________________________________________________________
1317 {
1318  // main (envelope) method for event selection
1319  // Specific event selection methods are called from here
1320  // returns kTRUE if event pass all selection criteria
1321  // *************************************************************
1322 
1323  Bool_t eventSelected = kFALSE;
1324 
1325  if(!fEventAOD) return kFALSE;
1326 
1327  // Fill event QA BEFORE cuts
1328  if(fFillQA) FillEventsQA(0);
1329 
1330  // event selection for small systems pp in Run2
1331  if(fColSystem == kPP) eventSelected = IsEventSelected_pp();
1332 
1333  // event selection for PbPb in Run2
1334  if(fColSystem == kPbPb) eventSelected = IsEventSelected_PbPb();
1335 
1336  // eventSelected = IsEventSelected_PbPb();
1337 
1338  return eventSelected;
1339 }
1340 //_____________________________________________________________________________
1342 {
1343  // Event selection for PbPb collisions recorded in Run 2 year 2015
1344  // PbPb (LHC15o)
1345  // return kTRUE if event passes all criteria, kFALSE otherwise
1346  // *************************************************************
1347  fhEventCounter->Fill("Input",1);
1348 
1349  // Physics selection (trigger)
1350  AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager();
1351  AliInputEventHandler* inputHandler = (AliInputEventHandler*) mgr->GetInputEventHandler();
1352  UInt_t fSelectMask = inputHandler->IsEventSelected();
1353 
1354  Bool_t isTriggerSelected = kFALSE;
1355  switch(fTrigger) // check for high multiplicity trigger
1356  {
1357  case 0:
1358  isTriggerSelected = fSelectMask& AliVEvent::kINT7;
1359  break;
1360 
1361  case 1:
1362  isTriggerSelected = fSelectMask& AliVEvent::kHighMultV0;
1363  break;
1364 
1365  case 2:
1366  isTriggerSelected = fSelectMask& AliVEvent::kHighMultSPD;
1367  break;
1368 
1369  default: isTriggerSelected = kFALSE;
1370  }
1371  if(!isTriggerSelected){ return kFALSE;}
1372 
1373  // events passing physics selection
1374  fhEventCounter->Fill("Physics selection OK",1);
1375 
1376  // get centrality from AliMultSelection
1377 
1378  AliMultSelection* fMultSelection = 0x0;
1379  fMultSelection = (AliMultSelection*) fEventAOD->FindListObject("MultSelection");
1380  Double_t centrV0M = fMultSelection->GetMultiplicityPercentile("V0M");
1381  Double_t centrCL1 = fMultSelection->GetMultiplicityPercentile("CL1");
1382 
1383  // cut on consistency between centrality estimators: VOM vs CL1
1384 
1385  double fEstimatorsCorrelationCoef[2];
1386  double fEstimatorsSigmaPars[4];
1387  double fDeltaEstimatorNsigma[2];
1388 
1389  fEstimatorsCorrelationCoef[0] = 0.0157497;
1390  fEstimatorsCorrelationCoef[1] = 0.973488;
1391  fEstimatorsSigmaPars[0] = 0.673612;
1392  fEstimatorsSigmaPars[1] = 0.0290718;
1393  fEstimatorsSigmaPars[2] = -0.000546728;
1394  fEstimatorsSigmaPars[3] = 5.82749e-06;
1395  fDeltaEstimatorNsigma[0] = 5.;
1396  fDeltaEstimatorNsigma[1] = 5.5;
1397 
1398  const double center = centrCL1 * fEstimatorsCorrelationCoef[1] + fEstimatorsCorrelationCoef[0];
1399  const double sigma = fEstimatorsSigmaPars[0] + fEstimatorsSigmaPars[1] * centrCL1 + fEstimatorsSigmaPars[2] * centrCL1 * centrCL1 + fEstimatorsSigmaPars[3] * centrCL1 * centrCL1 * centrCL1;
1400  if (centrV0M < center - fDeltaEstimatorNsigma[0] * sigma && centrV0M > center + fDeltaEstimatorNsigma[1] * sigma) {return kFALSE;}
1401  //if(fabs(centrV0M-centrCL1)>7.5) return kFALSE;
1402  fhEventCounter->Fill("Centr. Est. Consis. OK",1);
1403 
1404 
1405  // primary vertex selection
1406  const AliAODVertex* vtx = dynamic_cast<const AliAODVertex*>(fEventAOD->GetPrimaryVertex());
1407  if(!vtx || vtx->GetNContributors() < 1){ return kFALSE;}
1408  fhEventCounter->Fill("PV OK",1);
1409 
1410  // SPD vertex selection
1411  const AliAODVertex* vtxSPD = dynamic_cast<const AliAODVertex*>(fEventAOD->GetPrimaryVertexSPD());
1412 
1413 
1414  if (((AliAODHeader*)fEventAOD->GetHeader())->GetRefMultiplicityComb08() < 0) return kFALSE;
1415 
1416  if (fEventAOD->IsIncompleteDAQ()) return kFALSE;
1417 
1418  if (vtx->GetNContributors() < 2 || vtxSPD->GetNContributors()<1) return kFALSE;
1419  double cov[6]={0}; double covSPD[6]={0};
1420  vtx->GetCovarianceMatrix(cov);
1421  vtxSPD->GetCovarianceMatrix(covSPD);
1422 
1423  //Special selections for SPD vertex
1424  double zRes = TMath::Sqrt(covSPD[5]);
1425  double fMaxResol=0.25;
1426  if ( vtxSPD->IsFromVertexerZ() && (zRes>fMaxResol)) return kFALSE;
1427  fhEventCounter->Fill("SPD Vtx OK",1);
1428 
1429 
1430  // check for multi-vertexer pile-up
1431  /*
1432  const int kMinPileUpContrib = 5;
1433  const double kMaxPileUpChi2 = 5.0;
1434  const double kMinWDist = 15;
1435  const AliAODVertex* vtxPileUp = 0;
1436  int nPileUp = 0;
1437 
1438  nPileUp=fEventAOD->GetNumberOfPileupVerticesTracks();
1439 
1440  if (nPileUp) {
1441  if (vtx == vtxSPD) return kTRUE; // there are pile-up vertices but no primary
1442  Int_t bcPrim = vtPrm->GetBC();
1443  for (int iPileUp=0;iPileUp<nPileUp;iPileUp++) {
1444  vtxPileUp = (const AliAODVertex*)fEventAOD->GetPileupVertexTracks(iPileUp);
1445  if (vtxPileUp->GetNContributors() < kMinPileUpContrib) continue;
1446  if (vtxPileUp->GetChi2perNDF() > kMaxPileUpChi2) continue;
1447  int bcPlp = vtxPileUp->GetBC(); ///newly added
1448  if (bcPlp!=AliVTrack::kTOFBCNA && TMath::Abs(bcPlp-bcPrim)>2) return kTRUE; // pile-up from other Bunch crossing (BC)
1449  double wDst = GetWDist(vtx,vtxPileUp);
1450  if (wDst<kMinWDist) continue;
1451  return kTRUE; // pile-up: well separated vertices
1452  }
1453  }
1454 */
1455 // fhEventCounter->Fill("Pileup MV OK",1);
1457  AliAnalysisUtils utils;
1458  utils.SetMinPlpContribMV(5);
1459  utils.SetMaxPlpChi2MV(5);
1460  utils.SetMinWDistMV(15);
1461  utils.SetCheckPlpFromDifferentBCMV(kTRUE);
1462 
1463  Bool_t isPileupFromMV = utils.IsPileUpMV(fEventAOD);
1464 
1465  if(isPileupFromMV) return kFALSE;
1466  fhEventCounter->Fill("Pileup MV OK",1);
1467 
1468  //Bool_t fRejectOutOfBunchPileUp = kFALSE;
1469  //if(fRejectOutOfBunchPileUp) // out-of-bunch rejection (provided by Christian)
1470  //{
1471  //out-of-bunch
1472  // if (utils.IsOutOfBunchPileUp(fEventAOD)){ return kFALSE; }
1473  //}
1474  fhEventCounter->Fill("Out-of-bunch Pileup OK",1);
1476  // check vertex consistency
1477  double dz = vtx->GetZ() - vtxSPD->GetZ();
1478  double errTot = TMath::Sqrt(cov[5]+covSPD[5]);
1479  double err = TMath::Sqrt(cov[5]);
1480  double nsigTot = dz/errTot;
1481  double nsig = dz/err;
1482  if (TMath::Abs(dz)>0.2 || TMath::Abs(nsigTot)>10 || TMath::Abs(nsig)>20) return kFALSE;
1483  fhEventCounter->Fill("Vtx Consis. OK",1);
1484 
1485 
1486  const Double_t aodVtxZ = vtx->GetZ();
1487  if( TMath::Abs(aodVtxZ) > fPVtxCutZ ){return kFALSE;}
1488  fhEventCounter->Fill("PV #it{z} OK",1);
1489 
1490  // cut on # ESD tracks vs # TPC only tracks
1491  const Int_t nTracks = fEventAOD->GetNumberOfTracks();
1492  Int_t multEsd = ((AliAODHeader*)fEventAOD->GetHeader())->GetNumberOfESDTracks();
1493  Int_t multTrk = 0;
1494  //Int_t multTrkBefC = 0;
1495  Int_t multTrkTOF = 0;
1496  Int_t multTPC = 0;
1497  for (Int_t it = 0; it < nTracks; it++) {
1498  AliAODTrack* AODTrk = (AliAODTrack*)fEventAOD->GetTrack(it);
1499  if (!AODTrk){ delete AODTrk; continue; }
1500  if (AODTrk->TestFilterBit(128)) {multTPC++;}
1501  if (AODTrk->TestFilterBit(32)){
1502  multTrk++;
1503  if ( TMath::Abs(AODTrk->GetTOFsignalDz()) <= 10 && AODTrk->GetTOFsignal() >= 12000 && AODTrk->GetTOFsignal() <= 25000) multTrkTOF++;
1504  }
1505  } // end of for (Int_t it = 0; it < nTracks; it++)
1506  Double_t multTPCn = multTPC;
1507  Double_t multEsdn = multEsd;
1508  Double_t fESDvsTPConlyLinearCut[2];
1509 
1510  fESDvsTPConlyLinearCut[0] = 700.;
1511  fESDvsTPConlyLinearCut[1] = 3.38;
1512 
1513  if(multEsdn > fESDvsTPConlyLinearCut[0] + fESDvsTPConlyLinearCut[1] * multTPCn) return kFALSE;
1514  fhEventCounter->Fill("ESD TPC Mult. Diff. OK",1);
1515 
1516  Int_t fTOFvsFB32nSigmaCut[2];
1517  fTOFvsFB32nSigmaCut[0] = 4.;
1518  fTOFvsFB32nSigmaCut[1] = 4.;
1519 
1520  Double_t multTrkn = multTrk;
1521  Double_t multTrkTOFn = multTrkTOF;
1522 
1523  Double_t fTOFvsFB32correlationPars[4];
1524  Double_t fTOFvsFB32sigmaPars[6];
1525 
1526  fTOFvsFB32correlationPars[0] = -1.0178;
1527  fTOFvsFB32correlationPars[1] = 0.333132;
1528  fTOFvsFB32correlationPars[2] = 9.10282e-05;
1529  fTOFvsFB32correlationPars[3] = -1.61861e-08;
1530 
1531  fTOFvsFB32sigmaPars[0] = 1.47848;
1532  fTOFvsFB32sigmaPars[1] = 0.0385923;
1533  fTOFvsFB32sigmaPars[2] = -5.06153e-05;
1534  fTOFvsFB32sigmaPars[3] = 4.37641e-08;
1535  fTOFvsFB32sigmaPars[4] = -1.69082e-11;
1536  fTOFvsFB32sigmaPars[5] = 2.35085e-15;
1537 
1538  //Double_t mu32tof = PolN(multTrkn,fTOFvsFB32correlationPars,3);
1539  //Double_t sigma32tof = PolN(multTrkn,fTOFvsFB32sigmaPars, 5);
1540 
1541  Double_t mu32tof = fTOFvsFB32correlationPars[0] + fTOFvsFB32correlationPars[1]* multTrkn + fTOFvsFB32correlationPars[2]* pow(multTrkn,2) + fTOFvsFB32correlationPars[3]* pow(multTrkn,3);
1542  Double_t sigma32tof = fTOFvsFB32sigmaPars[0] + fTOFvsFB32sigmaPars[1]* multTrkn + fTOFvsFB32sigmaPars[2]* pow(multTrkn,2) + fTOFvsFB32sigmaPars[3]* pow(multTrkn,3) + fTOFvsFB32sigmaPars[4]* pow(multTrkn,4) + fTOFvsFB32sigmaPars[5]* pow(multTrkn,5);
1543 
1544 
1545  if ((multTrkTOFn > mu32tof + fTOFvsFB32nSigmaCut[0] * sigma32tof || multTrkTOFn < mu32tof - fTOFvsFB32nSigmaCut[1] * sigma32tof)) return kFALSE;
1546  //if(fExtraPileUp && multTrkTOFn< (-32+ 0.32*multTrkn+0.000037*multTrkn*multTrkn)) return kFALSE;
1547  //if(fExtraPileUp && multTrkTOFn> (13+0.46*multTrkn+0.000018*multTrkn*multTrkn)) return kFALSE;
1548  fhEventCounter->Fill("TOF fb32 Mult. correlation OK",1);
1549 
1550  fhEventCounter->Fill("Selected",1);
1551 
1552  // Fill event QA AFTER cuts
1553  if(fFillQA) FillEventsQA(1);
1554 
1555  return kTRUE;
1556 
1557 }
1558 //_____________________________________________________________________________
1560 {
1561  // Event selection for small system collision recorder in Run 2 year 2016
1562  // pp (LHC16kl), pPb (LHC16rqts)
1563  // return kTRUE if event passes all criteria, kFALSE otherwise
1564  // *************************************************************
1565 
1566  fhEventCounter->Fill("Input",1);
1567 
1568  // Physics selection (trigger)
1569  AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager();
1570  AliInputEventHandler* inputHandler = (AliInputEventHandler*) mgr->GetInputEventHandler();
1571  UInt_t fSelectMask = inputHandler->IsEventSelected();
1572 
1573  Bool_t isTriggerSelected = kFALSE;
1574  switch(fTrigger) // check for high multiplicity trigger
1575  {
1576  case 0:
1577  isTriggerSelected = fSelectMask& AliVEvent::kINT7;
1578  break;
1579 
1580  case 1:
1581  isTriggerSelected = fSelectMask& AliVEvent::kHighMultV0;
1582  break;
1583 
1584  case 2:
1585  isTriggerSelected = fSelectMask& AliVEvent::kHighMultSPD;
1586  break;
1587 
1588  default: isTriggerSelected = kFALSE;
1589  }
1590 
1591  if(!isTriggerSelected)
1592  return kFALSE;
1593 
1594  // events passing physics selection
1595  fhEventCounter->Fill("Physics selection OK",1);
1596 
1597  // primary vertex selection
1598  const AliAODVertex* vtx = dynamic_cast<const AliAODVertex*>(fEventAOD->GetPrimaryVertex());
1599  if(!vtx || vtx->GetNContributors() < 1)
1600  return kFALSE;
1601  fhEventCounter->Fill("PV OK",1);
1602 
1603  // SPD vertex selection
1604  const AliAODVertex* vtxSPD = dynamic_cast<const AliAODVertex*>(fEventAOD->GetPrimaryVertexSPD());
1605 
1606  Double_t dMaxResol = 0.25; // suggested from DPG
1607  Double_t cov[6] = {0};
1608  vtxSPD->GetCovarianceMatrix(cov);
1609  Double_t zRes = TMath::Sqrt(cov[5]);
1610  if ( vtxSPD->IsFromVertexerZ() && (zRes > dMaxResol)) return kFALSE;
1611  fhEventCounter->Fill("SPD Vtx OK",1);
1612 
1613  // PileUp rejection included in Physics selection
1614  // but with values for high mult pp (> 5 contrib) => for low ones: do manually (> 3 contrib)
1615 
1616  /*
1617  if(fTrigger == 0 && fAOD->IsPileupFromSPD(3,0.8) )
1618  {
1619  return kFALSE;
1620  }
1621  */
1622 
1623  //fhEventCounter->Fill("Pileup SPD OK",1);
1624 
1625  // pileup rejection from multivertexer
1626 
1627  AliAnalysisUtils utils;
1628  utils.SetMinPlpContribMV(5);
1629  utils.SetMaxPlpChi2MV(5);
1630  utils.SetMinWDistMV(15);
1631  utils.SetCheckPlpFromDifferentBCMV(kFALSE);
1632  Bool_t isPileupFromMV = utils.IsPileUpMV(fEventAOD);
1633  utils.SetCheckPlpFromDifferentBCMV(kTRUE);
1634 
1635  if(isPileupFromMV) return kFALSE;
1636  fhEventCounter->Fill("Pileup MV OK",1);
1637 
1638  //Bool_t fRejectOutOfBunchPileUp = kTRUE; //you have to add this to the task and set from header
1639  //if(fRejectOutOfBunchPileUp) // out-of-bunch rejection (provided by Christian)
1640  //{
1641  //out-of-bunch
1642  // if (utils.IsOutOfBunchPileUp(fEventAOD)){ return kFALSE; }
1643  //}
1644  fhEventCounter->Fill("Out-of-bunch Pileup OK",1);
1645 
1646  // if (utils.IsSPDClusterVsTrackletBG(fEventAOD))
1647  // {
1648  // return kFALSE;
1649  // }
1650  //
1651  // fhEventCounter->Fill("SPDClTrBG OK",1);
1652  //
1653  // // SPD pileup
1654  // if (utils.IsPileUpSPD(fEventAOD))
1655  // {
1656  // return kFALSE;
1657  // }
1658  //
1659  // fhEventCounter->Fill("SPDPU OK",1);
1660  // }
1661 
1662  //fhEventCounter->Fill("Utils OK",1);
1663 
1664  // cutting on PV z-distance
1665  const Double_t aodVtxZ = vtx->GetZ();
1666  if( TMath::Abs(aodVtxZ) > fPVtxCutZ )
1667  {
1668  return kFALSE;
1669  }
1670  fhEventCounter->Fill("PV #it{z} OK",1);
1671 
1672  fhEventCounter->Fill("Selected",1);
1673  return kTRUE;
1674 }
1675 //_____________________________________________________________________________
1677 {
1678  // Filling various QA plots related with event selection
1679  // *************************************************************
1680 
1681  const AliAODVertex* aodVtx = fEventAOD->GetPrimaryVertex();
1682  const Double_t dVtxZ = aodVtx->GetZ();
1683  const Int_t iNumContr = aodVtx->GetNContributors();
1684  const AliAODVertex* spdVtx = fEventAOD->GetPrimaryVertexSPD();
1685  const Int_t iNumContrSPD = spdVtx->GetNContributors();
1686  const Double_t spdVtxZ = spdVtx->GetZ();
1687 
1688  fhQAEventsPVz[iQAindex]->Fill(dVtxZ);
1689  fhQAEventsNumContrPV[iQAindex]->Fill(iNumContr);
1690  fhQAEventsNumSPDContrPV[iQAindex]->Fill(iNumContrSPD);
1691  fhQAEventsDistPVSPD[iQAindex]->Fill(TMath::Abs(dVtxZ - spdVtxZ));
1692 
1693  // SPD vertexer resolution
1694  Double_t cov[6] = {0};
1695  spdVtx->GetCovarianceMatrix(cov);
1696  Double_t zRes = TMath::Sqrt(cov[5]);
1697  fhQAEventsSPDresol[iQAindex]->Fill(zRes);
1698 
1699  AliMultSelection* fMultSelection = 0x0;
1700  fMultSelection = (AliMultSelection*) fEventAOD->FindListObject("MultSelection");
1701  Double_t centrV0M = fMultSelection->GetMultiplicityPercentile("V0M");
1702  Double_t centrCL1 = fMultSelection->GetMultiplicityPercentile("CL1");
1703 
1704  fhQAEventsCentralityOutliers[iQAindex]->Fill(centrV0M,centrCL1);
1705 
1706  const Int_t nTracks = fEventAOD->GetNumberOfTracks();
1707  Int_t multEsd = ((AliAODHeader*)fEventAOD->GetHeader())->GetNumberOfESDTracks();
1708  Int_t multTPC = 0;
1709  Int_t multTrk = 0;
1710  Int_t multTrkTOF = 0;
1711  for (Int_t it = 0; it < nTracks; it++) {
1712  AliAODTrack* AODTrk = (AliAODTrack*)fEventAOD->GetTrack(it);
1713  if (!AODTrk){ delete AODTrk; continue; }
1714  if (AODTrk->TestFilterBit(128)) {multTPC++;}
1715  if (AODTrk->TestFilterBit(32)){
1716  multTrk++;
1717  if ( TMath::Abs(AODTrk->GetTOFsignalDz()) <= 10 && AODTrk->GetTOFsignal() >= 12000 && AODTrk->GetTOFsignal() <= 25000) multTrkTOF++;
1718  }
1719 
1720  }// end of for (Int_t it = 0; it < nTracks; it++)
1721  if(iQAindex==1){
1722  Double_t multTPCn = multTPC;
1723  Double_t multEsdn = multEsd;
1724 
1725  //Double_t multESDTPCDif = multEsdn - multTPCn*3.38;
1726  //if (multESDTPCDif > 700.) return;//15000
1727 
1728  Double_t fESDvsTPConlyLinearCut[2];
1729 
1730  fESDvsTPConlyLinearCut[0] = 700.;
1731  fESDvsTPConlyLinearCut[1] = 3.38;
1732 
1733  if(multEsdn > fESDvsTPConlyLinearCut[0] + fESDvsTPConlyLinearCut[1] * multTPCn) return;
1734  }
1735  fhQAEventsPileUp[iQAindex]->Fill(multTPC,multEsd);
1736 
1737 
1738  if(iQAindex==1){
1739  Double_t multTrkn = multTrk;
1740  Double_t multTrkTOFn = multTrkTOF;
1741 
1742  Int_t fTOFvsFB32nSigmaCut[2];
1743  fTOFvsFB32nSigmaCut[0] = 4.;
1744  fTOFvsFB32nSigmaCut[1] = 4.;
1745 
1746  Double_t fTOFvsFB32correlationPars[4];
1747  Double_t fTOFvsFB32sigmaPars[6];
1748 
1749  fTOFvsFB32correlationPars[0] = -1.0178;
1750  fTOFvsFB32correlationPars[1] = 0.333132;
1751  fTOFvsFB32correlationPars[2] = 9.10282e-05;
1752  fTOFvsFB32correlationPars[3] = -1.61861e-08;
1753 
1754  fTOFvsFB32sigmaPars[0] = 1.47848;
1755  fTOFvsFB32sigmaPars[1] = 0.0385923;
1756  fTOFvsFB32sigmaPars[2] = -5.06153e-05;
1757  fTOFvsFB32sigmaPars[3] = 4.37641e-08;
1758  fTOFvsFB32sigmaPars[4] = -1.69082e-11;
1759  fTOFvsFB32sigmaPars[5] = 2.35085e-15;
1760 
1761  //Double_t mu32tof = PolN(multTrkn,fTOFvsFB32correlationPars,3);
1762  //Double_t sigma32tof = PolN(multTrkn,fTOFvsFB32sigmaPars, 5);
1763 
1764  Double_t mu32tof = fTOFvsFB32correlationPars[0] + fTOFvsFB32correlationPars[1]* multTrkn + fTOFvsFB32correlationPars[2]* pow(multTrkn,2) + fTOFvsFB32correlationPars[3]* pow(multTrkn,3);
1765  Double_t sigma32tof = fTOFvsFB32sigmaPars[0] + fTOFvsFB32sigmaPars[1]* multTrkn + fTOFvsFB32sigmaPars[2]* pow(multTrkn,2) + fTOFvsFB32sigmaPars[3]* pow(multTrkn,3) + fTOFvsFB32sigmaPars[4]* pow(multTrkn,4) + fTOFvsFB32sigmaPars[5]* pow(multTrkn,5);
1766 
1767  if ((multTrkTOFn > mu32tof + fTOFvsFB32nSigmaCut[0] * sigma32tof || multTrkTOFn < mu32tof - fTOFvsFB32nSigmaCut[1] * sigma32tof)) return;
1768 
1769  //if(fExtraPileUp && multTrkTOFn< (-32+ 0.32*multTrkn+0.000037*multTrkn*multTrkn)) return;
1770  //if(fExtraPileUp && multTrkTOFn> (13+0.46*multTrkn+0.000018*multTrkn*multTrkn)) return;
1771  }
1772  fhEventsMultTOFFilterbit32[iQAindex]->Fill(multTrk,multTrkTOF);
1773 
1774  return;
1775 }
1776 //_____________________________________________________________________________
1778 {
1779 
1780  // main (envelope) method for filtering all particles of interests (POIs) in selected events
1781  // All POIs passing selection criteria are saved to relevant TClonesArray for further processing
1782  // return kTRUE if succesfull (no errors in process)
1783  // *************************************************************
1784  if(!fProcessCharged && !fProcessPID) // if neither is ON, filtering is skipped
1785  return kFALSE; //return;
1786  fVectorCharged->clear();
1787  FilterCharged();
1788 
1789  // estimate centrality & assign indexes (centrality/percentile, ...)
1790  if(fColSystem == kPbPb){
1791 
1793  if(fIndexCentrality < 0) return kFALSE; // return; not succesfull estimation
1794  Double_t Mult = fVectorCharged->size();
1795  if(fExtraPileUp && fIndexCentrality< (-1.5*TMath::Power(Mult,0.46)-0.6*TMath::Log(Mult)*TMath::Log(Mult)+81)) return kFALSE;
1796  if(fExtraPileUp && fIndexCentrality>(-2.3*TMath::Power(Mult,0.39)-0.9*TMath::Log(Mult)*TMath::Log(Mult)+110)) return kFALSE;
1797 
1798  }
1799  if(fColSystem == kPP){fIndexCentrality = 1;}
1800 
1802 
1804 
1806 
1808 
1809  if(fProcessPID)
1810  {
1811 
1812  fVectorPion->clear();
1813  fVectorKaon->clear();
1814  fVectorProton->clear();
1815  FilterPID();
1816  }
1817 
1818  return kTRUE; //return;
1819 }
1820 //_____________________________________________________________________________
1822 {
1823  // Filtering input charged tracks
1824  // If track passes all requirements as defined in IsChargedSelected(),
1825  // the relevant properties (pT, eta, phi) are stored in FlowPart struct
1826  // and pushed to relevant vector container.
1827  // return kFALSE if any complications occurs
1828  // *************************************************************
1829  const Short_t iNumTracks = fEventAOD->GetNumberOfTracks();
1830  if(iNumTracks < 1) return;
1831 
1832  AliAODTrack* track = 0x0;
1833  Int_t iNumRefs = 0;
1834  Double_t NUAweight = 0;
1835  Double_t NUEweight = 0;
1836 
1837  for(Short_t iTrack(0); iTrack < iNumTracks; iTrack++)
1838  {
1839  track = static_cast<AliAODTrack*>(fEventAOD->GetTrack(iTrack));
1840  if(!track) continue;
1841 
1842  if(fFillQA) FillQACharged(0,track); // QA before selection
1843 
1844  if(fNegativelyChargedRef==kTRUE && track->Charge()>0) continue;
1845  if(fPositivelyChargedRef==kTRUE && track->Charge()<0) continue;
1846 
1847  if(IsChargedSelected(track))
1848  {
1849  fVectorCharged->emplace_back( FlowPart(track->Pt(),track->Phi(),track->Eta(), track->Charge(), kCharged) );
1850 
1852  fh3BeforeNUAWeightsCharged->Fill(track->Phi(),track->Eta(),fEventAOD->GetPrimaryVertex()->GetZ());
1853  fhBeforeNUEWeightsCharged->Fill(track->Pt());
1854  }
1855  if(fFlowUseNUAWeights)
1856  {
1857  if(track->Charge()>0){ NUAweight = fh3NUAWeightChargedPlus->GetBinContent( fh3NUAWeightChargedPlus->FindBin(track->Phi(),track->Eta(),fEventAOD->GetPrimaryVertex()->GetZ()) );}
1858  if(track->Charge()<0){ NUAweight = fh3NUAWeightChargedMinus->GetBinContent( fh3NUAWeightChargedMinus->FindBin(track->Phi(),track->Eta(),fEventAOD->GetPrimaryVertex()->GetZ()) );}
1859 
1860  fh3AfterNUAWeightsCharged->Fill(track->Phi(),track->Eta(),fEventAOD->GetPrimaryVertex()->GetZ(),NUAweight);
1861  }
1862  if(fFlowUseNUEWeights){
1863  if(track->Charge()>0){NUEweight = fhNUEWeightChargedPlus->GetBinContent( fhNUEWeightChargedPlus->FindBin(track->Pt()));}
1864  if(track->Charge()<0){NUEweight = fhNUEWeightChargedMinus->GetBinContent( fhNUEWeightChargedMinus->FindBin(track->Pt()));}
1865 
1866  fhAfterNUEWeightsCharged->Fill(track->Pt(),NUEweight);
1867  }
1868 
1869  if(fFillQA) FillQACharged(1,track); // QA after selection
1870 
1871  // Filling refs QA plots
1872  if(fCutFlowRFPsPtMin > 0. && track->Pt() >= fCutFlowRFPsPtMin && fCutFlowRFPsPtMax > 0. && track->Pt() <= fCutFlowRFPsPtMax)
1873  {
1874  iNumRefs++;
1876  fh3BeforeNUAWeightsRefs->Fill(track->Phi(),track->Eta(),fEventAOD->GetPrimaryVertex()->GetZ());
1877  fhBeforeNUEWeightsRefs->Fill(track->Pt());
1878  }
1879  if(fFlowUseNUAWeights)
1880  {
1881  if(track->Charge()>0){ NUAweight = fh3NUAWeightRefsPlus->GetBinContent( fh3NUAWeightRefsPlus->FindBin(track->Phi(),track->Eta(),fEventAOD->GetPrimaryVertex()->GetZ()) );}
1882  if(track->Charge()<0){ NUAweight = fh3NUAWeightRefsMinus->GetBinContent( fh3NUAWeightRefsMinus->FindBin(track->Phi(),track->Eta(),fEventAOD->GetPrimaryVertex()->GetZ()) );}
1883 
1884  fh3AfterNUAWeightsRefs->Fill(track->Phi(),track->Eta(),fEventAOD->GetPrimaryVertex()->GetZ(),NUAweight);
1885  }
1886  if(fFlowUseNUEWeights)
1887  {
1888  if(track->Charge()>0) {NUEweight = fhNUEWeightRefsPlus->GetBinContent( fhNUEWeightRefsPlus->FindBin(track->Pt()) );}
1889  if(track->Charge()<0) {NUEweight = fhNUEWeightRefsMinus->GetBinContent( fhNUEWeightRefsMinus->FindBin(track->Pt()) );}
1890 
1891  //if(track->Charge()>0 && fIndexCentrality<10){NUEweight = fhNUEWeightRefsPlus[fIndexCentrality/5]->GetBinContent( fhNUEWeightRefsPlus[fIndexCentrality/5]->FindBin(track->Pt()) );}
1892  //if(track->Charge()>0 && fIndexCentrality>=10 && fIndexCentrality<60){NUEweight = fhNUEWeightRefsPlus[1+fIndexCentrality/10]->GetBinContent( fhNUEWeightRefsPlus[1+fIndexCentrality/10]->FindBin(track->Pt()) );}
1893  //if(track->Charge()<0 && fIndexCentrality<10){NUEweight = fhNUEWeightRefsMinus[fIndexCentrality/5]->GetBinContent( fhNUEWeightRefsMinus[fIndexCentrality/5]->FindBin(track->Pt()) );}
1894  //if(track->Charge()<0 && fIndexCentrality>=10 && fIndexCentrality<60){NUEweight = fhNUEWeightRefsMinus[1+fIndexCentrality/10]->GetBinContent( fhNUEWeightRefsMinus[1+fIndexCentrality/10]->FindBin(track->Pt()) );}
1895 
1896  fhAfterNUEWeightsRefs->Fill(track->Pt(),NUEweight);
1897  }
1898  FillQARefs(1,track);
1899  }
1900  }
1901  }
1902 
1903  // fill QA charged multiplicity
1904  fh2RefsMult->Fill(fIndexCentrality,iNumRefs);
1905  if(fFillQA)
1906  {
1907  fhQAChargedMult[0]->Fill(fEventAOD->GetNumberOfTracks());
1908  fhQAChargedMult[1]->Fill(fVectorCharged->size());
1909  }
1910 
1911  return;
1912 }
1913 //_____________________________________________________________________________
1915 {
1916  // Selection of charged track
1917  // returns kTRUE if track pass all requirements, kFALSE otherwise
1918  // *************************************************************
1919  if(!track) return kFALSE;
1920  fhChargedCounter->Fill("Input",1);
1921 
1922  // filter bit
1923  if( !track->TestFilterBit(fCutChargedTrackFilterBit) ) return kFALSE;
1924  fhChargedCounter->Fill("FB",1);
1925 
1926  // number of TPC clusters (additional check for not ITS-standalone tracks)
1927  if( track->GetTPCNcls() < fCutChargedNumTPCclsMin && fCutChargedTrackFilterBit != 2) return kFALSE;
1928  fhChargedCounter->Fill("#TPC-Cls",1);
1929 
1930  // track chi2 per space points
1931  Double_t chi2TPC =0.;
1932  chi2TPC = track->Chi2perNDF();
1933  if (fMaxChi2perTPCcls > 0. && chi2TPC > fMaxChi2perTPCcls) return kFALSE;
1934  fhChargedCounter->Fill("TPC-Chi2",1);
1935 
1936  // track DCA coordinates
1937  // note AliAODTrack::XYZAtDCA() works only for constrained tracks
1938  Double_t dTrackXYZ[3] = {0};
1939  Double_t dVertexXYZ[3] = {0.};
1940  Double_t dDCAXYZ[3] = {0.};
1941  if( fCutChargedDCAzMax > 0. || fCutChargedDCAxyMax > 0.)
1942  {
1943  const AliAODVertex* vertex = fEventAOD->GetPrimaryVertex();
1944  if(!vertex) return kFALSE; // event does not have a PV
1945 
1946  track->GetXYZ(dTrackXYZ);
1947  vertex->GetXYZ(dVertexXYZ);
1948 
1949  for(Short_t i(0); i < 3; i++)
1950  dDCAXYZ[i] = dTrackXYZ[i] - dVertexXYZ[i];
1951  }
1952 
1953  if(fCutChargedDCAzMax > 0. && TMath::Abs(dDCAXYZ[2]) > fCutChargedDCAzMax) return kFALSE;
1954  fhChargedCounter->Fill("DCA-z",1);
1955 
1956  if(fCutChargedDCAxyMax > 0. && TMath::Sqrt(dDCAXYZ[0]*dDCAXYZ[0] + dDCAXYZ[1]*dDCAXYZ[1]) > fCutChargedDCAxyMax) return kFALSE;
1957  fhChargedCounter->Fill("DCA-xy",1);
1958 
1959  // pseudorapidity (eta)
1960  if(fCutChargedEtaMax > 0. && TMath::Abs(track->Eta()) > fCutChargedEtaMax) return kFALSE;
1961  fhChargedCounter->Fill("Eta",1);
1962 
1963  // track passing all criteria
1964  fhChargedCounter->Fill("Selected",1);
1965  return kTRUE;
1966 }
1967 //_____________________________________________________________________________
1968 void AliAnalysisTaskFlowModes::FillQARefs(const Short_t iQAindex, const AliAODTrack* track)
1969 {
1970  // Filling various QA plots related to RFPs subset of charged track selection
1971  // *************************************************************
1972 
1973  if(!track) return;
1974  if(iQAindex == 0) return; // NOTE implemented only for selected RFPs
1975 
1976  fh2RefsPt->Fill(fIndexCentrality,track->Pt());
1977  fh2RefsEta->Fill(fIndexCentrality,track->Eta());
1978  fh2RefsPhi->Fill(fIndexCentrality,track->Phi());
1979 
1980  return;
1981 }
1982 //_____________________________________________________________________________
1983 void AliAnalysisTaskFlowModes::FillQACharged(const Short_t iQAindex, const AliAODTrack* track)
1984 {
1985  // Filling various QA plots related to charged track selection
1986  // *************************************************************
1987  if(!track) return;
1988 
1989  // filter bit testing
1990  for(Short_t i(0); i < 32; i++)
1991  {
1992  if(track->TestFilterBit(TMath::Power(2.,i)))
1993  fhQAChargedFilterBit[iQAindex]->Fill(i);
1994  }
1995 
1996  // track charge
1997  fhQAChargedCharge[iQAindex]->Fill(track->Charge());
1998 
1999  // number of TPC clusters
2000  fhQAChargedNumTPCcls[iQAindex]->Fill(track->GetTPCNcls());
2001 
2002  // track DCA
2003  Double_t dDCAXYZ[3] = {-999., -999., -999.};
2004  const AliAODVertex* vertex = fEventAOD->GetPrimaryVertex();
2005  if(vertex)
2006  {
2007  Double_t dTrackXYZ[3] = {-999., -999., -999.};
2008  Double_t dVertexXYZ[3] = {-999., -999., -999.};
2009 
2010  track->GetXYZ(dTrackXYZ);
2011  vertex->GetXYZ(dVertexXYZ);
2012 
2013  for(Short_t i(0); i < 3; i++)
2014  dDCAXYZ[i] = dTrackXYZ[i] - dVertexXYZ[i];
2015  }
2016  fhQAChargedDCAxy[iQAindex]->Fill(TMath::Sqrt(dDCAXYZ[0]*dDCAXYZ[0] + dDCAXYZ[1]*dDCAXYZ[1]));
2017  fhQAChargedDCAz[iQAindex]->Fill(dDCAXYZ[2]);
2018 
2019  // kinematics
2020  fhQAChargedPt[iQAindex]->Fill(track->Pt());
2021  fhQAChargedPhi[iQAindex]->Fill(track->Phi());
2022  fhQAChargedEta[iQAindex]->Fill(track->Eta());
2023 
2024  return;
2025 }
2026 //_____________________________________________________________________________
2028 {
2029  // If track passes all requirements as defined in IsPIDSelected() (and species dependent),
2030  // the relevant properties (pT, eta, phi) are stored in FlowPart struct
2031  // and pushed to relevant vector container.
2032  // return kFALSE if any complications occurs
2033  // *************************************************************
2034 
2035  const Short_t iNumTracks = fEventAOD->GetNumberOfTracks();
2036  if(iNumTracks < 1) return;
2037 
2038  PartSpecies species = kUnknown;
2039  AliAODTrack* track = 0x0;
2040  Double_t NUAweight = 0;
2041  Double_t NUEweight = 0;
2042 
2043  for(Short_t iTrack(0); iTrack < iNumTracks; iTrack++)
2044  {
2045  track = static_cast<AliAODTrack*>(fEventAOD->GetTrack(iTrack));
2046  if(!track) continue;
2047 
2048  // PID tracks are subset of selected charged tracks (same quality requirements)
2049  if(!IsChargedSelected(track)) continue;
2050 
2051  if(fFillQA) FillPIDQA(0,track,kUnknown); // filling QA for tracks before selection (but after charged criteria applied)
2052 
2053  if(fNegativelyChargedPOI==kTRUE && track->Charge()>0) continue;
2054  if(fPositivelyChargedPOI==kTRUE && track->Charge()<0) continue;
2055 
2056  // PID track selection (return most favourable species)
2057  PartSpecies species = IsPIDSelected(track);
2058  // check if only protons should be used
2059  if(fCutPIDUseAntiProtonOnly && species == kProton && track->Charge() == 1) species = kUnknown;
2060 
2061  // selection of PID tracks
2062  switch (species)
2063  {
2064  case kPion:
2065  fVectorPion->emplace_back( FlowPart(track->Pt(),track->Phi(),track->Eta(), track->Charge(), kPion, fPDGMassPion, track->Px(), track->Py(), track->Pz()) );
2067  fh3BeforeNUAWeightsPion->Fill(track->Phi(), track->Eta(),fEventAOD->GetPrimaryVertex()->GetZ());
2068  fhBeforeNUEWeightsPion->Fill(track->Pt());
2069  }
2070  if(fFlowUseNUAWeights)
2071  {
2072  if(track->Charge() > 0){ NUAweight = fh3NUAWeightPionPlus->GetBinContent( fh3NUAWeightPionPlus->FindBin(track->Phi(),track->Eta(),fEventAOD->GetPrimaryVertex()->GetZ()) );}
2073  if(track->Charge() < 0){ NUAweight = fh3NUAWeightPionMinus->GetBinContent( fh3NUAWeightPionMinus->FindBin(track->Phi(),track->Eta(),fEventAOD->GetPrimaryVertex()->GetZ()) );}
2074 
2075  fh3AfterNUAWeightsPion->Fill(track->Phi(),track->Eta(),fEventAOD->GetPrimaryVertex()->GetZ(),NUAweight);
2076  }
2077  if(fFlowUseNUEWeights)
2078  {
2079  if(track->Charge()>0){NUEweight = fhNUEWeightPionPlus->GetBinContent( fhNUEWeightPionPlus->FindBin(track->Pt()));}
2080  if(track->Charge() < 0){ NUEweight = fhNUEWeightPionMinus->GetBinContent( fhNUEWeightPionMinus->FindBin(track->Pt()) );}
2081 
2082  fhAfterNUEWeightsPion->Fill(track->Pt(),NUEweight);
2083  }
2084  break;
2085  case kKaon:
2086  fVectorKaon->emplace_back( FlowPart(track->Pt(),track->Phi(),track->Eta(), track->Charge(), kKaon, fPDGMassKaon, track->Px(), track->Py(), track->Pz()) );
2088  fh3BeforeNUAWeightsKaon->Fill(track->Phi(), track->Eta(),fEventAOD->GetPrimaryVertex()->GetZ());
2089  fhBeforeNUEWeightsKaon->Fill(track->Pt());
2090  }
2091  if(fFlowUseNUAWeights)
2092  {
2093  if(track->Charge() > 0){NUAweight = fh3NUAWeightKaonPlus->GetBinContent( fh3NUAWeightKaonPlus->FindBin(track->Phi(),track->Eta(),fEventAOD->GetPrimaryVertex()->GetZ()) );}
2094  if(track->Charge() < 0){NUAweight = fh3NUAWeightKaonMinus->GetBinContent( fh3NUAWeightKaonMinus->FindBin(track->Phi(),track->Eta(),fEventAOD->GetPrimaryVertex()->GetZ()) );}
2095 
2096  fh3AfterNUAWeightsKaon->Fill(track->Phi(),track->Eta(),fEventAOD->GetPrimaryVertex()->GetZ(),NUAweight);
2097  }
2098  if(fFlowUseNUEWeights)
2099  {
2100  if(track->Charge() > 0){ NUEweight = fhNUEWeightKaonPlus->GetBinContent( fhNUEWeightKaonPlus->FindBin(track->Pt()) );}
2101  if(track->Charge() < 0){ NUEweight = fhNUEWeightKaonMinus->GetBinContent( fhNUEWeightKaonMinus->FindBin(track->Pt()) );}
2102 
2103  fhAfterNUEWeightsKaon->Fill(track->Pt(),NUEweight);
2104  }
2105  break;
2106  case kProton:
2107  fVectorProton->emplace_back( FlowPart(track->Pt(),track->Phi(),track->Eta(), track->Charge(), kProton, fPDGMassProton, track->Px(), track->Py(), track->Pz()) );
2109  fh3BeforeNUAWeightsProton->Fill(track->Phi(), track->Eta(),fEventAOD->GetPrimaryVertex()->GetZ());
2110  fhBeforeNUEWeightsProton->Fill(track->Pt());
2111  }
2112  if(fFlowUseNUAWeights)
2113  {
2114  if(track->Charge() > 0){NUAweight = fh3NUAWeightProtonPlus->GetBinContent( fh3NUAWeightProtonPlus->FindBin(track->Phi(),track->Eta(),fEventAOD->GetPrimaryVertex()->GetZ()) );}
2115  if(track->Charge() < 0){NUAweight = fh3NUAWeightProtonMinus->GetBinContent( fh3NUAWeightProtonMinus->FindBin(track->Phi(),track->Eta(),fEventAOD->GetPrimaryVertex()->GetZ()) );}
2116 
2117  fh3AfterNUAWeightsProton->Fill(track->Phi(),track->Eta(),fEventAOD->GetPrimaryVertex()->GetZ(),NUAweight);
2118  }
2119  if(fFlowUseNUEWeights)
2120  {
2121  if(track->Charge() > 0){ NUEweight = fhNUEWeightProtonPlus->GetBinContent( fhNUEWeightProtonPlus->FindBin(track->Pt()) );}
2122  if(track->Charge() < 0 ){ NUEweight = fhNUEWeightProtonMinus->GetBinContent( fhNUEWeightProtonMinus->FindBin(track->Pt()));}
2123 
2124  fhAfterNUEWeightsProton->Fill(track->Pt(),NUEweight);
2125  }
2126  break;
2127  default:
2128  break;
2129  }
2130 
2131  //if(fFillQA) FillPIDQA(1,track,species); // filling QA for tracks AFTER selection
2132  }
2133 
2137 
2138  return;
2139 }
2140 //_____________________________________________________________________________
2142 {
2143  // Selection of PID tracks (pi,K,p) - track identification
2144  // nSigma cutting is used
2145  // returns AliAnalysisTaskFlowModes::PartSpecies enum : kPion, kKaon, kProton if any of this passed kUnknown otherwise
2146  // *************************************************************
2147 
2148  // checking detector states
2149  AliPIDResponse::EDetPidStatus pidStatusTPC = fPIDResponse->CheckPIDStatus(AliPIDResponse::kTPC, track);
2150  AliPIDResponse::EDetPidStatus pidStatusTOF = fPIDResponse->CheckPIDStatus(AliPIDResponse::kTOF, track);
2151 
2152  Bool_t bIsTPCok = (pidStatusTPC == AliPIDResponse::kDetPidOk);
2153  Bool_t bIsTOFok = ((pidStatusTOF == AliPIDResponse::kDetPidOk) && (track->GetStatus()& AliVTrack::kTOFout) && (track->GetStatus()& AliVTrack::kTIME) && (track->GetTOFsignal() > 12000) && (track->GetTOFsignal() < 100000)); // checking TOF
2154  //if(!bIsTPCok) return kUnknown;
2155 
2156  const Double_t dPt = track->Pt();
2157  const Double_t dP = track->P();
2158 
2159  // use nSigma cuts (based on combination of TPC / TOF nSigma cuts)
2160 
2161  Double_t dNumSigmaTPC[5] = {-99,-99,-99,-99,-99}; // TPC nSigma array: 0: electron / 1: muon / 2: pion / 3: kaon / 4: proton
2162  Double_t dNumSigmaTOF[5] = {-99,-99,-99,-99,-99}; // TOF nSigma array: 0: electron / 1: muon / 2: pion / 3: kaon / 4: proton
2163 
2164  Float_t *probabilities;
2165  Float_t mismProb;
2166  Float_t ProbBayes[5] = {0,0,0,0,0}; //0=el, 1=mu, 2=pi, 3=ka, 4=pr, 5=deuteron, 6=triton, 7=He3
2167 
2168  Double_t probTPC[AliPID::kSPECIES]={0.};
2169  Double_t probTOF[AliPID::kSPECIES]={0.};
2170  Double_t probTPCTOF[AliPID::kSPECIES]={0.};
2171 
2172 
2173  // filling nSigma arrays
2174  if(bIsTPCok) // should be anyway
2175  {
2176  dNumSigmaTPC[0] = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(track, AliPID::kElectron));
2177  dNumSigmaTPC[1] = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(track, AliPID::kMuon));
2178  dNumSigmaTPC[2] = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(track, AliPID::kPion));
2179  dNumSigmaTPC[3] = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(track, AliPID::kKaon));
2180  dNumSigmaTPC[4] = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(track, AliPID::kProton));
2181  }
2182 
2183  if(bIsTOFok) // should be anyway
2184  {
2185  dNumSigmaTOF[0] = TMath::Abs(fPIDResponse->NumberOfSigmasTOF(track, AliPID::kElectron));
2186  dNumSigmaTOF[1] = TMath::Abs(fPIDResponse->NumberOfSigmasTOF(track, AliPID::kMuon));
2187  dNumSigmaTOF[2] = TMath::Abs(fPIDResponse->NumberOfSigmasTOF(track, AliPID::kPion));
2188  dNumSigmaTOF[3] = TMath::Abs(fPIDResponse->NumberOfSigmasTOF(track, AliPID::kKaon));
2189  dNumSigmaTOF[4] = TMath::Abs(fPIDResponse->NumberOfSigmasTOF(track, AliPID::kProton));
2190  }
2191 
2192 
2193  if(fPIDbayesian){
2194  if(!TPCTOFagree(track)){return kUnknown;}
2195 
2196  fBayesianResponse->SetDetResponse(fEventAOD, fCurrCentr,AliESDpid::kTOF_T0); // centrality = PbPb centrality class (0-100%) or -1 for pp collisions
2197  if(fEventAOD->GetTOFHeader()){
2198  fESDpid.SetTOFResponse(fEventAOD,AliESDpid::kTOF_T0);
2199  }
2201  }
2202 
2203  Int_t ParticleFlag[]={0,0,0,0};//Unknown (electron), pion, kaon, proton
2204  fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC);
2205  UInt_t detUsed = fPIDCombined->ComputeProbabilities(track, fPIDResponse, probTPC);
2206  if (detUsed == (UInt_t)fPIDCombined->GetDetectorMask() ) { // TPC is available
2207 
2208  // TPC nSigma cuts
2209  if(dP>0.2 && dP <= 0.5)
2210  {
2211  if(fPIDnsigma){
2212  Double_t dMinSigmasTPC = TMath::MinElement(5,dNumSigmaTPC);
2213  // electron rejection
2214  if(dMinSigmasTPC == dNumSigmaTPC[0] && TMath::Abs(dNumSigmaTPC[0]) <= fCutPIDnSigmaTPCRejectElectron) ParticleFlag[0] = 1; //return kUnknown;
2215  if(dMinSigmasTPC == dNumSigmaTPC[2] && TMath::Abs(dNumSigmaTPC[2]) <= fCutPIDnSigmaPionMax) ParticleFlag[1] = 1;//return kPion;
2216  if(dMinSigmasTPC == dNumSigmaTPC[3] && TMath::Abs(dNumSigmaTPC[3]) <= fCutPIDnSigmaKaonMax) ParticleFlag[2] = 1;//return kKaon;
2217  if(dMinSigmasTPC == dNumSigmaTPC[4] && TMath::Abs(dNumSigmaTPC[4]) <= fCutPIDnSigmaProtonMax) ParticleFlag[3] = 1;//return kProton;
2218  }
2219  if(fPIDbayesian){
2220  ProbBayes[0] = probTPC[0];
2221  ProbBayes[1] = probTPC[1];
2222  ProbBayes[2] = probTPC[2];
2223  ProbBayes[3] = probTPC[3];
2224  ProbBayes[4] = probTPC[4];
2225 
2226  Double_t dMaxBayesianProb = TMath::MaxElement(5,ProbBayes);
2227  if(dMaxBayesianProb > fParticleProbability){
2228  if(dMaxBayesianProb == ProbBayes[0] && TMath::Abs(dNumSigmaTPC[0]) <= fCutPIDnSigmaTPCRejectElectron)ParticleFlag[0] = 1;// return kUnknown;
2229  if(dMaxBayesianProb == ProbBayes[2] && TMath::Abs(dNumSigmaTPC[2]) <= fCutPIDnSigmaPionMax)ParticleFlag[1] = 1;//return kPion;
2230  if(dMaxBayesianProb == ProbBayes[3] && TMath::Abs(dNumSigmaTPC[3]) <= fCutPIDnSigmaKaonMax)ParticleFlag[2] = 1;//return kKaon;
2231  if(dMaxBayesianProb == ProbBayes[4] && TMath::Abs(dNumSigmaTPC[4]) <= fCutPIDnSigmaProtonMax)ParticleFlag[3] = 1;//return kProton;
2232  }
2233  /*
2234  fBayesianResponse->ComputeProb(track,track->GetAODEvent()); // fCurrCentr is needed for mismatch fraction
2235  probabilities = fBayesianResponse->GetProb(); // Bayesian Probability (from 0 to 4) (Combined TPC || TOF) including a tuning of priors and TOF mism$
2236  ProbBayes[0] = probabilities[0];
2237  ProbBayes[1] = probabilities[1];
2238  ProbBayes[2] = probabilities[2];
2239  ProbBayes[3] = probabilities[3];
2240  ProbBayes[4] = probabilities[4];
2241 
2242  mismProb = fBayesianResponse->GetTOFMismProb(); // mismatch Bayesian probabilities
2243 
2244  Double_t dMaxBayesianProb = TMath::MaxElement(5,ProbBayes);
2245  if(dMaxBayesianProb > fParticleProbability && mismProb < 0.5){
2246  // electron rejection
2247  if(dMaxBayesianProb == ProbBayes[0] && TMath::Abs(dNumSigmaTPC[0]) <= fCutPIDnSigmaTPCRejectElectron)ParticleFlag[0] = 1;// return kUnknown;
2248  if(dMaxBayesianProb == ProbBayes[2] && TMath::Abs(dNumSigmaTPC[2]) <= fCutPIDnSigmaPionMax)ParticleFlag[1] = 1;//return kPion;
2249  if(dMaxBayesianProb == ProbBayes[3] && TMath::Abs(dNumSigmaTPC[3]) <= fCutPIDnSigmaKaonMax)ParticleFlag[2] = 1;//return kKaon;
2250  if(dMaxBayesianProb == ProbBayes[4] && TMath::Abs(dNumSigmaTPC[4]) <= fCutPIDnSigmaProtonMax)ParticleFlag[3] = 1;//return kProton;
2251  }*/
2252  }
2253  }
2254  fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTOF|AliPIDResponse::kDetTPC);
2255  detUsed = fPIDCombined->ComputeProbabilities(track, fPIDResponse, probTPCTOF);
2256 
2257  if (detUsed == (UInt_t)fPIDCombined->GetDetectorMask()){
2258  AliAODPid* pidObj = track->GetDetPid();
2259  if ((detUsed >= AliPIDResponse::kDetTOF) && (pidObj && pidObj->GetTOFsignal() < 99999)){
2260 
2261  // combined TPC + TOF nSigma cuts
2262  if(dP > 0.5) // && < 4 GeV TODO once TPC dEdx parametrisation is available
2263  {
2264  Double_t dNumSigmaCombined[5] = {-99,-99,-99,-99,-99};
2265 
2266  // discard candidates if no TOF is available if cut is on
2267  if(fCutPIDnSigmaCombinedNoTOFrejection && !bIsTOFok) ParticleFlag[0] = 1;// return kUnknown;
2268 
2269  // calculating combined nSigmas
2270  for(Short_t i(0); i < 5; i++)
2271  {
2272  if(bIsTOFok) { dNumSigmaCombined[i] = TMath::Sqrt(dNumSigmaTPC[i]*dNumSigmaTPC[i] + dNumSigmaTOF[i]*dNumSigmaTOF[i]); }
2273  else { dNumSigmaCombined[i] = dNumSigmaTPC[i]; }
2274  }
2275 
2276  if(fPIDnsigma){
2277  Double_t dMinSigmasCombined = TMath::MinElement(5,dNumSigmaCombined);
2278 
2279  // electron rejection
2280  if(dMinSigmasCombined == dNumSigmaCombined[0] && TMath::Abs(dNumSigmaCombined[0]) <= fCutPIDnSigmaPionMax) ParticleFlag[0] = 1;// return kUnknown;
2281 
2282  switch (fPIDnsigmaCombination) {
2283  case 1:
2284  //combination 1
2285  if(dMinSigmasCombined == dNumSigmaCombined[2] && TMath::Abs(dNumSigmaCombined[2]) <= 3.) ParticleFlag[1] = 1;//return kPion;
2286  if(dMinSigmasCombined == dNumSigmaCombined[3] && TMath::Abs(dNumSigmaCombined[3]) <= 2.5) ParticleFlag[2] = 1; //return kKaon;
2287  if(dMinSigmasCombined == dNumSigmaCombined[4] && TMath::Abs(dNumSigmaCombined[4]) <= 3.) ParticleFlag[3] = 1;//return kProton;
2288  break;
2289  case 2:
2290  //combination 2
2291  if(dP < 2.5 && dMinSigmasCombined == dNumSigmaCombined[2] && TMath::Abs(dNumSigmaCombined[2]) <= 3.) ParticleFlag[1] = 1; //return kPion;
2292  if(dP > 2.5 && dMinSigmasCombined == dNumSigmaCombined[2] && TMath::Abs(dNumSigmaCombined[2]) <= 2.) ParticleFlag[1] = 1; //return kPion;
2293 
2294  if(dP < 2. && dMinSigmasCombined == dNumSigmaCombined[3] && TMath::Abs(dNumSigmaCombined[3]) <= 2.5) ParticleFlag[2] = 1; //return kKaon;
2295  if(dP > 2. && dP < 3. && dMinSigmasCombined == dNumSigmaCombined[3] && TMath::Abs(dNumSigmaCombined[3]) <= 2.) ParticleFlag[2] = 1; //return kKaon;
2296  if(dP > 3. && dMinSigmasCombined == dNumSigmaCombined[3] && TMath::Abs(dNumSigmaCombined[3]) <= 1.5) ParticleFlag[2] = 1; //return kKaon;
2297 
2298  if(dP < 3. && dMinSigmasCombined == dNumSigmaCombined[4] && TMath::Abs(dNumSigmaCombined[4]) <= 3.) ParticleFlag[3] = 1; //return kProton;
2299  if(dP > 3. && dP < 5. && dMinSigmasCombined == dNumSigmaCombined[4] && TMath::Abs(dNumSigmaCombined[4]) <= 2.) ParticleFlag[3] = 1; //return kProton;
2300  if(dP > 5. && dMinSigmasCombined == dNumSigmaCombined[4] && TMath::Abs(dNumSigmaCombined[4]) <= 1.5) ParticleFlag[3] = 1; //return kProton;
2301 
2302  break;
2303  case 3:
2304  //combination 3
2305  if(dP < 2.5 && dMinSigmasCombined == dNumSigmaCombined[2] && TMath::Abs(dNumSigmaCombined[2]) <= 3.) ParticleFlag[1] = 1; //return kPion;
2306  if(dP > 2.5 && dP < 4. && dMinSigmasCombined == dNumSigmaCombined[2] && TMath::Abs(dNumSigmaCombined[2]) <= 1.5) ParticleFlag[1] = 1; //return kPion;
2307  if(dP > 4. && dMinSigmasCombined == dNumSigmaCombined[2] && TMath::Abs(dNumSigmaCombined[2]) <= 1.) ParticleFlag[1] = 1; //return kPion;
2308 
2309  if(dP < 2. && dMinSigmasCombined == dNumSigmaCombined[3] && TMath::Abs(dNumSigmaCombined[3]) <= 2.5) ParticleFlag[2] = 1; //return kKaon;
2310  if(dP > 2. && dP < 3. && dMinSigmasCombined == dNumSigmaCombined[3] && TMath::Abs(dNumSigmaCombined[3]) <= 1.5)ParticleFlag[2] = 1; //return kKaon;
2311  if(dP > 3. && dMinSigmasCombined == dNumSigmaCombined[3] && TMath::Abs(dNumSigmaCombined[3]) <= 1.) ParticleFlag[2] = 1; //return kKaon;
2312 
2313  if(dP < 3. && dMinSigmasCombined == dNumSigmaCombined[4] && TMath::Abs(dNumSigmaCombined[4]) <= 3.) ParticleFlag[3] = 1; //return kProton;
2314  if(dP > 3. && dP < 5. && dMinSigmasCombined == dNumSigmaCombined[4] && TMath::Abs(dNumSigmaCombined[4]) <= 2.) ParticleFlag[3] = 1; //return kProton;
2315  if(dP > 5. && dMinSigmasCombined == dNumSigmaCombined[4] && TMath::Abs(dNumSigmaCombined[4]) <= 1.) ParticleFlag[3] = 1; //return kProton;
2316  break;
2317  default:
2318  break;
2319  }
2320  }
2321  if(fPIDbayesian){
2322  ProbBayes[0] = probTPCTOF[0];
2323  ProbBayes[1] = probTPCTOF[1];
2324  ProbBayes[2] = probTPCTOF[2];
2325  ProbBayes[3] = probTPCTOF[3];
2326  ProbBayes[4] = probTPCTOF[4];
2327  Double_t dMaxBayesianProb = TMath::MaxElement(5,ProbBayes);
2328  if(dMaxBayesianProb > fParticleProbability){
2329  if(dMaxBayesianProb == ProbBayes[0] && TMath::Abs(dNumSigmaCombined[0]) <= fCutPIDnSigmaPionMax) ParticleFlag[0] = 1; //return kUnknown;
2330  if(dMaxBayesianProb == ProbBayes[2] && TMath::Abs(dNumSigmaCombined[2]) <= fCutPIDnSigmaPionMax) ParticleFlag[1] = 1; //return kPion;
2331  if(dMaxBayesianProb == ProbBayes[3] && TMath::Abs(dNumSigmaCombined[3]) <= fCutPIDnSigmaKaonMax) ParticleFlag[2] = 1; //return kKaon;
2332  if(dMaxBayesianProb == ProbBayes[4] && TMath::Abs(dNumSigmaCombined[4]) <= fCutPIDnSigmaProtonMax) ParticleFlag[3] = 1; //return kProton;
2333  }else{ParticleFlag[0] = 1;}
2334  /*
2335  fBayesianResponse->ComputeProb(track,track->GetAODEvent()); // fCurrCentr is needed for mismatch fraction
2336  probabilities = fBayesianResponse->GetProb(); // Bayesian Probability (from 0 to 4) (Combined TPC || TOF) including a tuning of priors and TOF mism$
2337  ProbBayes[0] = probabilities[0];
2338  ProbBayes[1] = probabilities[1];
2339  ProbBayes[2] = probabilities[2];
2340  ProbBayes[3] = probabilities[3];
2341  ProbBayes[4] = probabilities[4];
2342 
2343  mismProb = fBayesianResponse->GetTOFMismProb(); // mismatch Bayesian probabilities
2344 
2345  Double_t dMaxBayesianProb = TMath::MaxElement(5,ProbBayes);
2346  if(dMaxBayesianProb > fParticleProbability && mismProb < 0.5){
2347  // electron rejection
2348  if(dMaxBayesianProb == ProbBayes[0] && TMath::Abs(dNumSigmaCombined[0]) <= fCutPIDnSigmaPionMax) ParticleFlag[0] = 1; //return kUnknown;
2349  if(dMaxBayesianProb == ProbBayes[2] && TMath::Abs(dNumSigmaCombined[2]) <= fCutPIDnSigmaPionMax) ParticleFlag[1] = 1; //return kPion;
2350  if(dMaxBayesianProb == ProbBayes[3] && TMath::Abs(dNumSigmaCombined[3]) <= fCutPIDnSigmaKaonMax) ParticleFlag[2] = 1; //return kKaon;
2351  if(dMaxBayesianProb == ProbBayes[4] && TMath::Abs(dNumSigmaCombined[4]) <= fCutPIDnSigmaProtonMax) ParticleFlag[3] = 1; //return kProton;
2352  }*/
2353  }
2354  }//if(dP > 0.5)
2355  }//if ((detUsed >= AliPIDResponse::kDetTOF) && (pidObj && pidObj->GetTOFsignal() < 99999))
2356  }//TPC or TOF if (detUsed)
2357  }//TPC if (detUsed)
2358 
2359  PartSpecies species;
2360  if(!ParticleFlag[0] && ParticleFlag[1] && !ParticleFlag[2] && !ParticleFlag[3]){
2361  species = kPion;
2362  }else if(!ParticleFlag[0] && !ParticleFlag[1] && ParticleFlag[2] && !ParticleFlag[3]){
2363  species = kKaon;
2364  }else if(!ParticleFlag[0] && !ParticleFlag[1] && !ParticleFlag[2] && ParticleFlag[3]){
2365  species = kProton;
2366  }else{species = kUnknown;}
2367 
2368  if(fFillQA) FillPIDQA(1,track,species); // filling QA for tracks AFTER selection
2369 
2370  return species;
2371 }
2372 //_____________________________________________________________________________
2373 void AliAnalysisTaskFlowModes::FillPIDQA(const Short_t iQAindex, const AliAODTrack* track, const PartSpecies species)
2374 {
2375  // Filling various QA plots related to PID (pi,K,p) track selection
2376  // *************************************************************
2377  if(!track) return;
2378  if(!fPIDResponse || !fPIDCombined)
2379  {
2380  ::Error("FillPIDQA","AliPIDResponse or AliPIDCombined object not found!");
2381  return;
2382  }
2383 
2384  // TPC & TOF statuses & measures
2385  AliPIDResponse::EDetPidStatus pidStatusTPC = fPIDResponse->CheckPIDStatus(AliPIDResponse::kTPC, track);
2386  AliPIDResponse::EDetPidStatus pidStatusTOF = fPIDResponse->CheckPIDStatus(AliPIDResponse::kTOF, track);
2387 
2388  fhQAPIDTOFstatus[iQAindex]->Fill((Int_t) pidStatusTOF );
2389  fhQAPIDTPCstatus[iQAindex]->Fill((Int_t) pidStatusTPC );
2390 
2391  Bool_t bIsTPCok = (pidStatusTPC == AliPIDResponse::kDetPidOk);
2392  //Bool_t bIsTOFok = ((pidStatusTOF == AliPIDResponse::kDetPidOk) && (track->GetStatus()& AliVTrack::kTOFout) && (track->GetStatus()& AliVTrack::kTIME));
2393 
2394  Bool_t bIsTOFok = ((pidStatusTOF == AliPIDResponse::kDetPidOk) && (track->GetStatus()& AliVTrack::kTOFout) && (track->GetStatus()& AliVTrack::kTIME) && (track->GetTOFsignal() > 12000) && (track->GetTOFsignal() < 100000)); // checking TOF
2395 
2396  Double_t dNumSigmaTPC[5] = {-11}; // array: 0: electron / 1: muon / 2: pion / 3: kaon / 4: proton
2397  Double_t dNumSigmaTOF[5] = {-11}; // array: 0: electron / 1: muon / 2: pion / 3: kaon / 4: proton
2398 
2399  Double_t dTPCdEdx = -5; // TPC dEdx for selected particle
2400  Double_t dTOFbeta = -0.05; //TOF beta for selected particle
2401 
2402  Double_t dP = track->P();
2403  Double_t dPt = track->Pt();
2404 
2405  // detector status dependent
2406  if(bIsTPCok)
2407  {
2408  dNumSigmaTPC[0] = fPIDResponse->NumberOfSigmasTPC(track, AliPID::kElectron);
2409  dNumSigmaTPC[1] = fPIDResponse->NumberOfSigmasTPC(track, AliPID::kMuon);
2410  dNumSigmaTPC[2] = fPIDResponse->NumberOfSigmasTPC(track, AliPID::kPion);
2411  dNumSigmaTPC[3] = fPIDResponse->NumberOfSigmasTPC(track, AliPID::kKaon);
2412  dNumSigmaTPC[4] = fPIDResponse->NumberOfSigmasTPC(track, AliPID::kProton);
2413 
2414  dTPCdEdx = track->GetTPCsignal();
2415  fhQAPIDTPCdEdx[iQAindex]->Fill(track->P(), dTPCdEdx);
2416  }
2417  else // TPC status not OK
2418  {
2419  dNumSigmaTPC[0] = -11.;
2420  dNumSigmaTPC[1] = -11.;
2421  dNumSigmaTPC[2] = -11.;
2422  dNumSigmaTPC[3] = -11.;
2423  dNumSigmaTPC[4] = -11.;
2424 
2425  fhQAPIDTPCdEdx[iQAindex]->Fill(track->P(), -5.);
2426  }
2427 
2428  if(bIsTOFok)
2429  {
2430  dNumSigmaTOF[0] = fPIDResponse->NumberOfSigmasTOF(track, AliPID::kElectron);
2431  dNumSigmaTOF[1] = fPIDResponse->NumberOfSigmasTOF(track, AliPID::kMuon);
2432  dNumSigmaTOF[2] = fPIDResponse->NumberOfSigmasTOF(track, AliPID::kPion);
2433  dNumSigmaTOF[3] = fPIDResponse->NumberOfSigmasTOF(track, AliPID::kKaon);
2434  dNumSigmaTOF[4] = fPIDResponse->NumberOfSigmasTOF(track, AliPID::kProton);
2435 
2436  Double_t dTOF[5];
2437  track->GetIntegratedTimes(dTOF);
2438  dTOFbeta = dTOF[0] / track->GetTOFsignal();
2439  fhQAPIDTOFbeta[iQAindex]->Fill(dP,dTOFbeta);
2440  }
2441  else // TOF status not OK
2442  {
2443  dNumSigmaTOF[0] = -11.;
2444  dNumSigmaTOF[1] = -11.;
2445  dNumSigmaTOF[2] = -11.;
2446  dNumSigmaTOF[3] = -11.;
2447  dNumSigmaTOF[4] = -11.;
2448 
2449  fhQAPIDTOFbeta[iQAindex]->Fill(track->P(),-0.05);
2450  }
2451 
2452 
2453  // species dependent QA
2454  switch (species)
2455  {
2456  case kPion:
2457  fh2PIDPionPt->Fill(fIndexCentrality,track->Pt());
2458  fh2PIDPionPhi->Fill(fIndexCentrality,track->Phi());
2459  fh2PIDPionEta->Fill(fIndexCentrality,track->Eta());
2460  fhPIDPionCharge->Fill(track->Charge());
2461  fh2PIDPionTPCdEdx->Fill(dPt,dTPCdEdx);
2462  fh2PIDPionTOFbeta->Fill(dPt,dTOFbeta);
2463  fh2PIDPionTPCnSigmaPion->Fill(dPt,dNumSigmaTPC[2]);
2464  fh2PIDPionTOFnSigmaPion->Fill(dPt,dNumSigmaTOF[2]);
2465  fh2PIDPionTPCnSigmaKaon->Fill(dPt,dNumSigmaTPC[3]);
2466  fh2PIDPionTOFnSigmaKaon->Fill(dPt,dNumSigmaTOF[3]);
2467  fh2PIDPionTPCnSigmaProton->Fill(dPt,dNumSigmaTPC[4]);
2468  fh2PIDPionTOFnSigmaProton->Fill(dPt,dNumSigmaTOF[4]);
2469 
2470  fh3PIDPionTPCTOFnSigmaPion[iQAindex]->Fill(dNumSigmaTPC[2],dNumSigmaTOF[2],dPt);
2471  fh3PIDPionTPCTOFnSigmaKaon[iQAindex]->Fill(dNumSigmaTPC[3],dNumSigmaTOF[3],dPt);
2472  fh3PIDPionTPCTOFnSigmaProton[iQAindex]->Fill(dNumSigmaTPC[4],dNumSigmaTOF[4],dPt);
2473 
2474  break;
2475 
2476  case kKaon:
2477  fh2PIDKaonPt->Fill(fIndexCentrality,track->Pt());
2478  fh2PIDKaonPhi->Fill(fIndexCentrality,track->Phi());
2479  fh2PIDKaonEta->Fill(fIndexCentrality,track->Eta());
2480  fhPIDKaonCharge->Fill(track->Charge());
2481  fh2PIDKaonTPCdEdx->Fill(dP,dTPCdEdx);
2482  fh2PIDKaonTOFbeta->Fill(dP,dTOFbeta);
2483  fh2PIDKaonTPCnSigmaPion->Fill(dPt,dNumSigmaTPC[2]);
2484  fh2PIDKaonTOFnSigmaPion->Fill(dPt,dNumSigmaTOF[2]);
2485  fh2PIDKaonTPCnSigmaKaon->Fill(dPt,dNumSigmaTPC[3]);
2486  fh2PIDKaonTOFnSigmaKaon->Fill(dPt,dNumSigmaTOF[3]);
2487  fh2PIDKaonTPCnSigmaProton->Fill(dPt,dNumSigmaTPC[4]);
2488  fh2PIDKaonTOFnSigmaProton->Fill(dPt,dNumSigmaTOF[4]);
2489 
2490  fh3PIDKaonTPCTOFnSigmaPion[iQAindex]->Fill(dNumSigmaTPC[2],dNumSigmaTOF[2],dPt);
2491  fh3PIDKaonTPCTOFnSigmaKaon[iQAindex]->Fill(dNumSigmaTPC[3],dNumSigmaTOF[3],dPt);
2492  fh3PIDKaonTPCTOFnSigmaProton[iQAindex]->Fill(dNumSigmaTPC[4],dNumSigmaTOF[4],dPt);
2493 
2494  break;
2495 
2496  case kProton:
2497  fh2PIDProtonPt->Fill(fIndexCentrality,track->Pt());
2498  fh2PIDProtonPhi->Fill(fIndexCentrality,track->Phi());
2499  fh2PIDProtonEta->Fill(fIndexCentrality,track->Eta());
2500  fhPIDProtonCharge->Fill(track->Charge());
2501  fh2PIDProtonTPCdEdx->Fill(dP,dTPCdEdx);
2502  fh2PIDProtonTOFbeta->Fill(dP,dTOFbeta);
2503  fh2PIDProtonTPCnSigmaPion->Fill(dPt,dNumSigmaTPC[2]);
2504  fh2PIDProtonTOFnSigmaPion->Fill(dPt,dNumSigmaTOF[2]);
2505  fh2PIDProtonTPCnSigmaKaon->Fill(dPt,dNumSigmaTPC[3]);
2506  fh2PIDProtonTOFnSigmaKaon->Fill(dPt,dNumSigmaTOF[3]);
2507  fh2PIDProtonTPCnSigmaProton->Fill(dPt,dNumSigmaTPC[4]);
2508  fh2PIDProtonTOFnSigmaProton->Fill(dPt,dNumSigmaTOF[4]);
2509 
2510  fh3PIDProtonTPCTOFnSigmaPion[iQAindex]->Fill(dNumSigmaTPC[2],dNumSigmaTOF[2],dPt);
2511  fh3PIDProtonTPCTOFnSigmaKaon[iQAindex]->Fill(dNumSigmaTPC[3],dNumSigmaTOF[3],dPt);
2512  fh3PIDProtonTPCTOFnSigmaProton[iQAindex]->Fill(dNumSigmaTPC[4],dNumSigmaTOF[4],dPt);
2513 
2514  break;
2515 
2516  default:
2517  break;
2518  }
2519 
2520 
2521  //
2522 
2523 
2524  return;
2525 }
2526 //_____________________________________________________________________________
2528 {
2529 
2530  // main method for processing of (selected) event:
2531  // - Filtering of tracks / particles for flow calculations
2532  // - Phi,eta,pt weights for generic framework are calculated if specified
2533  // - Flow calculations
2534  // returns kTRUE if succesfull
2535  // *************************************************************
2536 
2537  // printf("======= EVENT ================\n");
2538 
2539 
2540  // checking the run number for applying weights & loading TList with weights
2541  if(fRunNumber < 0 || fRunNumber != fEventAOD->GetRunNumber() )
2542  {
2543  fRunNumber = fEventAOD->GetRunNumber();
2544 
2546  {
2547  TDirectory* dirFlowNUAWeights = (TDirectory*) fFlowNUAWeightsFile->Get(Form("000%d",fRunNumber));
2548  if(!dirFlowNUAWeights) {::Error("ProcessEvent","TList from flow weights not found."); return kFALSE; }
2549  fh3NUAWeightRefsPlus = (TH3D*) dirFlowNUAWeights->Get("ChargedPlus"); if(!fh3NUAWeightRefsPlus) { ::Error("ProcessEvent","Positive Refs NUA weights not found"); return kFALSE; }
2550  fh3NUAWeightRefsMinus = (TH3D*) dirFlowNUAWeights->Get("ChargedMinus"); if(!fh3NUAWeightRefsMinus) { ::Error("ProcessEvent","Negative Refs NUA weights not found"); return kFALSE; }
2551 
2552  fh3NUAWeightChargedPlus = (TH3D*) dirFlowNUAWeights->Get("ChargedPlus"); if(!fh3NUAWeightChargedPlus) { ::Error("ProcessEvent","Positive Charged NUA weights not found"); return kFALSE; }
2553  fh3NUAWeightChargedMinus = (TH3D*) dirFlowNUAWeights->Get("ChargedMinus"); if(!fh3NUAWeightChargedMinus) { ::Error("ProcessEvent","Nagative Charged NUA weights not found"); return kFALSE; }
2554 
2555  fh3NUAWeightPionPlus = (TH3D*) dirFlowNUAWeights->Get("PionPlus"); if(!fh3NUAWeightPionPlus) { ::Error("ProcessEvent","Positive Pion NUA weights not found"); return kFALSE; }
2556  fh3NUAWeightPionMinus = (TH3D*) dirFlowNUAWeights->Get("PionMinus"); if(!fh3NUAWeightPionMinus) { ::Error("ProcessEvent","Negative Pion NUA weights not found"); return kFALSE; }
2557 
2558 
2559  fh3NUAWeightKaonPlus = (TH3D*) dirFlowNUAWeights->Get("KaonPlus"); if(!fh3NUAWeightKaonPlus) { ::Error("ProcessEvent","Positive Kaon NUA weights not found"); return kFALSE; }
2560  fh3NUAWeightKaonMinus = (TH3D*) dirFlowNUAWeights->Get("KaonMinus"); if(!fh3NUAWeightKaonMinus) { ::Error("ProcessEvent","Negative Kaon NUA weights not found"); return kFALSE; }
2561 
2562 
2563  fh3NUAWeightProtonPlus = (TH3D*) dirFlowNUAWeights->Get("ProtonPlus"); if(!fh3NUAWeightProtonPlus) { ::Error("ProcessEvent","Positive Proton NUA weights not found"); return kFALSE; }
2564  fh3NUAWeightProtonMinus = (TH3D*) dirFlowNUAWeights->Get("ProtonMinus"); if(!fh3NUAWeightProtonMinus) { ::Error("ProcessEvent","Negative Proton NUA weights not found"); return kFALSE; }
2565 
2566 
2567  }
2568  }
2569 
2570  if(fColSystem == kPbPb){
2572  if(fIndexCentrality < 0) { return kFALSE;}
2573  }
2575  {
2576  //TDirectory* dirFlowNUEWeights = 0x0;
2577  const char* gCentrality[] = {"0-5","5-10","10-20","20-30","30-40","40-50","50-60"};
2578  TString indexCentrality;// = 0x0;
2579  if(fIndexCentrality>=0. && fIndexCentrality<=5.){indexCentrality = "0-5";}//gCentrality[0];}
2580  if(fIndexCentrality>5. && fIndexCentrality<=10.){indexCentrality = "5-10";}//gCentrality[1];}
2581  if(fIndexCentrality>10. && fIndexCentrality<=20.){indexCentrality = "10-20";}//gCentrality[2];}
2582  if(fIndexCentrality>20. && fIndexCentrality<=30.){indexCentrality = "20-30";}//gCentrality[3];}
2583  if(fIndexCentrality>30. && fIndexCentrality<=40.){indexCentrality = "30-40";}//gCentrality[4];}
2584  if(fIndexCentrality>40. && fIndexCentrality<=50.){indexCentrality = "40-50";}//gCentrality[5];}
2585  if(fIndexCentrality>50. && fIndexCentrality<=60.){indexCentrality = "50-60";}//gCentrality[6];}
2586  if(fIndexCentrality<0. || fIndexCentrality>60.){return kFALSE;}
2587 
2588  TDirectory* dirFlowNUEWeights = (TDirectory*) fFlowNUEWeightsFile->Get(indexCentrality);
2589  if(!dirFlowNUEWeights) { ::Error("ProcessEvent","TDirectoy from NUE weights not found."); return kFALSE; }
2590  fhNUEWeightRefsPlus = dynamic_cast<TH1F*>( dirFlowNUEWeights->Get("ChargedPlus"));
2591  if(!fhNUEWeightRefsPlus) { ::Error("ProcessEvent","Positive Refs NUE weights not found"); return kFALSE; }
2592  fhNUEWeightRefsMinus = dynamic_cast<TH1F*>(dirFlowNUEWeights->Get("ChargedMinus"));
2593  if(!fhNUEWeightRefsMinus) { ::Error("ProcessEvent","Negative Refs NUE weights not found"); return kFALSE; }
2594  fhNUEWeightChargedPlus = dynamic_cast<TH1F*>(dirFlowNUEWeights->Get("ChargedPlus"));
2595  if(!fhNUEWeightChargedPlus) { ::Error("ProcessEvent","Positive Charged NUE weights not found"); return kFALSE; }
2596  fhNUEWeightChargedMinus = dynamic_cast<TH1F*>(dirFlowNUEWeights->Get("ChargedMinus"));
2597  if(!fhNUEWeightChargedMinus) { ::Error("ProcessEvent","Negative Charged NUE weights not found"); return kFALSE; }
2598  fhNUEWeightPionPlus = dynamic_cast<TH1F*>(dirFlowNUEWeights->Get("PionPlus"));
2599  if(!fhNUEWeightPionPlus) { ::Error("ProcessEvent","Positive Pion NUE weights not found"); return kFALSE; }
2600  fhNUEWeightPionMinus = dynamic_cast<TH1F*>(dirFlowNUEWeights->Get("PionMinus"));
2601  if(!fhNUEWeightPionMinus) { ::Error("ProcessEvent","Negative Pion NUE weights not found"); return kFALSE; }
2602  fhNUEWeightKaonPlus = dynamic_cast<TH1F*>(dirFlowNUEWeights->Get("KaonPlus"));
2603  if(!fhNUEWeightKaonPlus) { ::Error("ProcessEvent","Positive Kaon NUE weights not found"); return kFALSE; }
2604  fhNUEWeightKaonMinus = dynamic_cast<TH1F*>(dirFlowNUEWeights->Get("KaonMinus"));
2605  if(!fhNUEWeightKaonMinus) { ::Error("ProcessEvent","Negative Kaon NUE weights not found"); return kFALSE; }
2606  fhNUEWeightProtonPlus = dynamic_cast<TH1F*>(dirFlowNUEWeights->Get("ProtonPlus"));
2607  if(!fhNUEWeightProtonPlus) { ::Error("ProcessEvent","Positive Proton NUE weights not found"); return kFALSE; }
2608  fhNUEWeightProtonMinus = dynamic_cast<TH1F*>(dirFlowNUEWeights->Get("ProtonMinus"));
2609  if(!fhNUEWeightProtonMinus) { ::Error("ProcessEvent","Negative Proton NUE weights not found"); return kFALSE; }
2610  }
2611 
2612  // filtering particles
2613  if(!Filtering()) return kFALSE;
2614  // at this point, centrality index (percentile) should be properly estimated, if not, skip event
2615 
2616  // if running in kFillWeights mode, skip the remaining part
2617  if(fRunMode == kFillWeights) { fEventCounter++; return kTRUE; }
2618 
2619  // checking if there is at least one charged track selected;
2620  // if not, event is skipped: unable to compute Reference flow (and thus any differential flow)
2621  if(fVectorCharged->size() < 1)
2622  return kFALSE;
2623  // at this point, all particles fullfiling relevant POIs (and REFs) criteria are filled in TClonesArrays
2624 
2625  // >>>> flow starts here <<<<
2626  // >>>> Flow a la General Framework <<<<
2627  for(Short_t iGap(0); iGap < fNumEtaGap; iGap++)
2628  {
2629 
2630  // Reference (pT integrated) flow
2631  DoFlowRefs(iGap);
2632 
2633  // pT differential
2634  if(fProcessCharged)
2635  {
2636  // charged track flow
2637  DoFlowCharged(iGap);
2638  }
2639  if(fProcessPID)
2640  {
2641  const Int_t iSizePion = fVectorPion->size();
2642  const Int_t iSizeKaon = fVectorKaon->size();
2643  const Int_t iSizeProton = fVectorProton->size();
2644 
2645  // pi,K,p flow
2646  if(iSizePion > 0) DoFlowPID(iGap,kPion);
2647  if(iSizeKaon > 0) DoFlowPID(iGap,kKaon);
2648  if(iSizeProton > 0) DoFlowPID(iGap,kProton);
2649  }
2650  } // endfor {iGap} eta gaps
2651 
2652  fEventCounter++; // counter of processed events
2653  //printf("event %d\n",fEventCounter);
2654 
2655  return kTRUE;
2656 }
2657 //_____________________________________________________________________________
2659 {
2660 
2661  // Estimate <2>, <4> and <6> for reference flow for all harmonics based on relevant flow vectors
2662  // *************************************************************
2663 
2664  //Float_t dEtaGap = fEtaGap[iEtaGapIndex];
2665  Short_t iHarmonics = 0;
2666  Double_t Cn2 = 0;
2667  Double_t Dn4GapP = 0;
2668  Double_t Dn6GapP = 0;
2669  TComplex vector = TComplex(0,0,kFALSE);
2670  Double_t dValue = 999;
2671 
2672  FillRefsVectors(iEtaGapIndex); // filling RFPs (Q) flow vectors
2674  // estimating <2>
2675  Cn2 = TwoGap(0,0).Re();
2676  if(Cn2 != 0)
2677  {
2678  for(Short_t iHarm(0); iHarm < fNumHarmonics; iHarm++)
2679  {
2680  iHarmonics = fHarmonics[iHarm];
2681  vector = TwoGap(iHarmonics,-iHarmonics);
2682  dValue = vector.Re()/Cn2;
2683  // printf("Gap (RFPs): %g Harm %d | Dn2: %g | fFlowVecQpos[0][0]: %g | fFlowVecQneg[0][0]: %g | fIndexCentrality %d\n\n", dEtaGap,iHarmonics,Cn2,fFlowVecQpos[0][0].Re(),fFlowVecQneg[0][0].Re(),fIndexCentrality);
2684  if( TMath::Abs(dValue < 1) )
2685  fpRefsCor2[fIndexSampling][iEtaGapIndex][iHarm]->Fill(fIndexCentrality, dValue, Cn2);
2686 
2687  }
2688  }
2689  }
2690  //for mixed harmonics
2692  //estimating <4>
2693  Dn4GapP = FourGapPos(0,0,0,0).Re();
2694  if(Dn4GapP != 0)
2695  {
2696  // (2,2 | 2,2)_gap , referece flow for v4/psi2
2697  TComplex Four_2222_GapP = FourGapPos(2, 2, -2, -2);
2698  double c4_2222_GapP = Four_2222_GapP.Re()/Dn4GapP;
2699  fpMixedRefsCor4[fIndexSampling][iEtaGapIndex][0]->Fill(fIndexCentrality, c4_2222_GapP, Dn4GapP);
2700  // (3,3 | 3,3)_gap, referece flow for v6/psi3
2701  TComplex Four_3333_GapP = FourGapPos(3, 3, -3, -3);
2702  double c4_3333_GapP = Four_3333_GapP.Re()/Dn4GapP;
2703  fpMixedRefsCor4[fIndexSampling][iEtaGapIndex][1]->Fill(fIndexCentrality, c4_3333_GapP, Dn4GapP);
2704  // (3,2 | 3,2)_gap, reference flow for v5/psi23
2705  TComplex Four_3232_GapP = FourGapPos(3, 2, -3, -2);
2706  double c4_3232_GapP = Four_3232_GapP.Re()/Dn4GapP;
2707  fpMixedRefsCor4[fIndexSampling][iEtaGapIndex][2]->Fill(fIndexCentrality, c4_3232_GapP, Dn4GapP);
2708  }
2709  //estimating <6>
2710  Dn6GapP = SixGapPos(0,0,0,0,0,0).Re();
2711  if(Dn6GapP != 0)
2712  {
2713  // (2,2,2 | 2,2,2)_gap, reference flow for v6/psi2
2714  TComplex Six_222222_GapP = SixGapPos(2, 2, 2, -2, -2, -2);
2715  double c6_222222_GapP = Six_222222_GapP.Re()/Dn6GapP;
2716  fpMixedRefsCor6[fIndexSampling][iEtaGapIndex]->Fill(fIndexCentrality, c6_222222_GapP, Dn6GapP);
2717  }
2718  }
2719  return;
2720 }
2721 //_____________________________________________________________________________
2723 {
2724  // Estimate <2'>, <3'> and <4'> for pT diff flow of charged tracks for all harmonics based on relevant flow vectors
2725  // *************************************************************
2726 
2727  FillPOIsVectors(iEtaGapIndex,kCharged); // filling POIs (P,S) flow vectors
2728 
2729  const Double_t dPtBinWidth = (fFlowPOIsPtMax - fFlowPOIsPtMin) / fFlowPOIsPtNumBins;
2730 
2731  //Float_t dEtaGap = fEtaGap[iEtaGapIndex];
2732  Short_t iHarmonics = 0;
2733  Double_t Dn2 = 0;
2734  Double_t DDn3GapP=0;
2735  Double_t DDn4GapP=0;
2736  TComplex vector = TComplex(0,0,kFALSE);
2737  Double_t dValue = 999;
2738 
2739 
2740  for(Short_t iPt(0); iPt < fFlowPOIsPtNumBins; iPt++)
2741  {
2743  // estimating <2'>
2744  // POIs in positive eta
2745  Dn2 = TwoDiffGapPos(0,0,iPt).Re();
2746  if(Dn2 != 0)
2747  {
2748  for(Short_t iHarm(0); iHarm < fNumHarmonics; iHarm++)
2749  {
2750  iHarmonics = fHarmonics[iHarm];
2751  vector = TwoDiffGapPos(iHarmonics,-iHarmonics,iPt);
2752  dValue = vector.Re()/Dn2;
2753  if( TMath::Abs(dValue < 1) )
2754  fp2ChargedCor2Pos[fIndexSampling][iEtaGapIndex][iHarm]->Fill(fIndexCentrality, iPt*dPtBinWidth, dValue, Dn2);
2755  }
2756  }
2757 
2758  // POIs in negative eta
2759  Dn2 = TwoDiffGapNeg(0,0,iPt).Re();
2760  if(Dn2 != 0)
2761  {
2762  for(Short_t iHarm(0); iHarm < fNumHarmonics; iHarm++)
2763  {
2764  iHarmonics = fHarmonics[iHarm];
2765  vector = TwoDiffGapNeg(iHarmonics,-iHarmonics,iPt);
2766  dValue = vector.Re()/Dn2;
2767  if( TMath::Abs(dValue < 1) )
2768  fp2ChargedCor2Neg[fIndexSampling][iEtaGapIndex][iHarm]->Fill(fIndexCentrality, iPt*dPtBinWidth, dValue, Dn2);
2769  }
2770  }
2771  }
2773  // estimating <3'>
2774  // POIs in positive eta
2775  DDn3GapP = ThreeDiffGapPos(0,0,0,iPt).Re();
2776  if(DDn3GapP!=0)
2777  {
2778  for(Short_t iMixedHarm(0); iMixedHarm < fNumMixedHarmonics-1; iMixedHarm++)
2779  {
2780  if(iMixedHarm==0){ vector = ThreeDiffGapPos(4,-2,-2,iPt);}
2781  if(iMixedHarm==1){ vector = ThreeDiffGapPos(6,-3,-3,iPt);}
2782  if(iMixedHarm==2){ vector = ThreeDiffGapPos(5,-3,-2,iPt);}
2783  dValue = vector.Re()/DDn3GapP;
2784  if( TMath::Abs(dValue < 1) ){
2785  fpMixedChargedCor3Pos[fIndexSampling][iEtaGapIndex][iMixedHarm]->Fill(fIndexCentrality,iPt*dPtBinWidth, dValue, DDn3GapP);
2786  }
2787  }
2788  }
2789  // POIs in negative eta
2790  DDn3GapP = ThreeDiffGapNeg(0,0,0,iPt).Re();
2791  if(DDn3GapP!=0)
2792  {
2793  for(Short_t iMixedHarm(0); iMixedHarm < fNumMixedHarmonics-1; iMixedHarm++)
2794  {
2795  if(iMixedHarm==0){ vector = ThreeDiffGapNeg(4,-2,-2,iPt);}
2796  if(iMixedHarm==1){ vector = ThreeDiffGapNeg(6,-3,-3,iPt);}
2797  if(iMixedHarm==2){ vector = ThreeDiffGapNeg(5,-2,-3,iPt);}
2798  dValue = vector.Re()/DDn3GapP;
2799  if( TMath::Abs(dValue < 1) ){
2800  fpMixedChargedCor3Neg[fIndexSampling][iEtaGapIndex][iMixedHarm]->Fill(fIndexCentrality,iPt*dPtBinWidth, dValue, DDn3GapP);
2801  }
2802  }
2803  }
2804  // estimating <4'>
2805  // POIs in positive eta
2806  DDn4GapP = Four13DiffGapPos(0,0,0,0,iPt).Re();
2807  if(DDn4GapP!=0)
2808  {
2809  vector = Four13DiffGapPos(6,-2,-2,-2,iPt);
2810  dValue = vector.Re()/DDn4GapP;
2811  if( TMath::Abs(dValue < 1) ){
2812  fpMixedChargedCor4Pos[fIndexSampling][iEtaGapIndex]->Fill(fIndexCentrality,iPt*dPtBinWidth, dValue, DDn4GapP);
2813  }
2814  }
2815  // POIs in negative eta
2816  DDn4GapP = Four13DiffGapNeg(0,0,0,0,iPt).Re();
2817  if(DDn4GapP!=0)
2818  {
2819  vector = Four13DiffGapNeg(6,-2,-2,-2,iPt);
2820  dValue = vector.Re()/DDn4GapP;
2821  if( TMath::Abs(dValue < 1) ){
2822  fpMixedChargedCor4Neg[fIndexSampling][iEtaGapIndex]->Fill(fIndexCentrality,iPt*dPtBinWidth, dValue, DDn4GapP);
2823  }
2824  }
2825  }
2826  } // endfor {iPt}
2827  return;
2828 }
2829 //_____________________________________________________________________________
2830 void AliAnalysisTaskFlowModes::DoFlowPID(const Short_t iEtaGapIndex, const PartSpecies species)
2831 {
2832  // Estimate <2'>, <3'> and <4'> for pT diff flow of pi/K/p tracks for all harmonics based on relevant flow vectors
2833  // *************************************************************
2834 
2835  TProfile2D** profile2Pos = 0x0;
2836  TProfile2D** profile2Neg = 0x0;
2837  //TProfile2D** profile4 = 0x0;
2838  TProfile2D** profile3Pos = 0x0;
2839  TProfile2D** profile3Neg = 0x0;
2840  TProfile2D* profile4Pos = 0x0;
2841  TProfile2D* profile4Neg = 0x0;
2842 
2843 
2845 
2846  switch (species)
2847  {
2848  case kPion:
2849  profile2Pos = fp2PionCor2Pos[fIndexSampling][iEtaGapIndex];
2850  profile2Neg = fp2PionCor2Neg[fIndexSampling][iEtaGapIndex];
2851  //profile4 = fp2PionCor4;
2852  break;
2853 
2854  case kKaon:
2855  profile2Pos = fp2KaonCor2Pos[fIndexSampling][iEtaGapIndex];
2856  profile2Neg = fp2KaonCor2Neg[fIndexSampling][iEtaGapIndex];
2857  //profile4 = fp2KaonCor4;
2858  break;
2859 
2860  case kProton:
2861  profile2Pos = fp2ProtonCor2Pos[fIndexSampling][iEtaGapIndex];
2862  profile2Neg = fp2ProtonCor2Neg[fIndexSampling][iEtaGapIndex];
2863  //profile4 = fp2ProtonCor4;
2864  break;
2865 
2866  default:
2867  ::Error("DoFlowPID","Unexpected species! Terminating!");
2868  return;
2869  }
2870  }
2871 
2873 
2874  switch (species)
2875  {
2876  case kPion:
2877  profile3Pos = fpMixedPionCor3Pos[fIndexSampling][iEtaGapIndex];
2878  profile3Neg = fpMixedPionCor3Neg[fIndexSampling][iEtaGapIndex];
2879 
2880  profile4Pos = fpMixedPionCor4Pos[fIndexSampling][iEtaGapIndex];
2881  profile4Neg = fpMixedPionCor4Neg[fIndexSampling][iEtaGapIndex];
2882  break;
2883 
2884  case kKaon:
2885  profile3Pos = fpMixedKaonCor3Pos[fIndexSampling][iEtaGapIndex];
2886  profile3Neg = fpMixedKaonCor3Neg[fIndexSampling][iEtaGapIndex];
2887 
2888  profile4Pos = fpMixedKaonCor4Pos[fIndexSampling][iEtaGapIndex];
2889  profile4Neg = fpMixedKaonCor4Neg[fIndexSampling][iEtaGapIndex];
2890  break;
2891 
2892  case kProton:
2893  profile3Pos = fpMixedProtonCor3Pos[fIndexSampling][iEtaGapIndex];
2894  profile3Neg = fpMixedProtonCor3Neg[fIndexSampling][iEtaGapIndex];
2895 
2896  profile4Pos = fpMixedProtonCor4Pos[fIndexSampling][iEtaGapIndex];
2897  profile4Neg = fpMixedProtonCor4Neg[fIndexSampling][iEtaGapIndex];
2898  break;
2899 
2900  default:
2901  ::Error("DoFlowPID with mixed harmonics","Unexpected species! Terminating!");
2902  return;
2903  }
2904  }
2905 
2906  FillPOIsVectors(iEtaGapIndex,species); // Filling POIs vectors
2907 
2908  const Double_t dPtBinWidth = (fFlowPOIsPtMax - fFlowPOIsPtMin) / fFlowPOIsPtNumBins;
2909 
2910  //Float_t dEtaGap = fEtaGap[iEtaGapIndex];
2911  Short_t iHarmonics = 0;
2912  Double_t Dn2 = 0;
2913  TComplex vector = TComplex(0,0,kFALSE);
2914  Double_t dValue = 999;
2915  Double_t DDn3GapP=0;
2916  Double_t DDn4GapP=0;
2917 
2918 
2919  // filling POIs (P,S) flow vectors
2920 
2921  for(Short_t iPt(0); iPt < fFlowPOIsPtNumBins; iPt++)
2922  {
2924  // estimating <2'>
2925  // POIs in positive eta
2926  Dn2 = TwoDiffGapPos(0,0,iPt).Re();
2927  if(Dn2 != 0)
2928  {
2929  for(Short_t iHarm(0); iHarm < fNumHarmonics; iHarm++)
2930  {
2931  iHarmonics = fHarmonics[iHarm];
2932  vector = TwoDiffGapPos(iHarmonics,-iHarmonics,iPt);
2933  dValue = vector.Re()/Dn2;
2934  if( TMath::Abs(dValue < 1) )
2935  profile2Pos[iHarm]->Fill(fIndexCentrality, iPt*dPtBinWidth, dValue, Dn2);
2936  }
2937  }
2938  // POIs in negative eta
2939  Dn2 = TwoDiffGapNeg(0,0,iPt).Re();
2940  if(Dn2 != 0)
2941  {
2942  for(Short_t iHarm(0); iHarm < fNumHarmonics; iHarm++)
2943  {
2944  iHarmonics = fHarmonics[iHarm];
2945  vector = TwoDiffGapNeg(iHarmonics,-iHarmonics,iPt);
2946  dValue = vector.Re()/Dn2;
2947  if( TMath::Abs(dValue < 1) )
2948  profile2Neg[iHarm]->Fill(fIndexCentrality, iPt*dPtBinWidth, dValue, Dn2);
2949  }
2950  }
2951  }
2953  // estimating <3'>
2954  // POIs in positive eta
2955  DDn3GapP = ThreeDiffGapPos(0,0,0,iPt).Re();
2956  if(DDn3GapP!=0)
2957  {
2958  for(Short_t iMixedHarm(0); iMixedHarm < fNumMixedHarmonics-1; iMixedHarm++)
2959  {
2960  if(iMixedHarm==0){ vector = ThreeDiffGapPos(4,-2,-2,iPt);}
2961  if(iMixedHarm==1){ vector = ThreeDiffGapPos(6,-3,-3,iPt);}
2962  if(iMixedHarm==2){ vector = ThreeDiffGapPos(5,-3,-2,iPt);}
2963  dValue = vector.Re()/DDn3GapP;
2964  if( TMath::Abs(dValue < 1) ){
2965  profile3Pos[iMixedHarm]->Fill(fIndexCentrality,iPt*dPtBinWidth, dValue, DDn3GapP);
2966  }
2967  }
2968  }
2969  // POIs in negative eta
2970  DDn3GapP = ThreeDiffGapNeg(0,0,0,iPt).Re();
2971  if(DDn3GapP!=0)
2972  {
2973  for(Short_t iMixedHarm(0); iMixedHarm < fNumMixedHarmonics-1; iMixedHarm++)
2974  {
2975  if(iMixedHarm==0){ vector = ThreeDiffGapNeg(4,-2,-2,iPt);}
2976  if(iMixedHarm==1){ vector = ThreeDiffGapNeg(6,-3,-3,iPt);}
2977  if(iMixedHarm==2){ vector = ThreeDiffGapNeg(5,-2,-3,iPt);}
2978  dValue = vector.Re()/DDn3GapP;
2979  if( TMath::Abs(dValue < 1) ){
2980  profile3Neg[iMixedHarm]->Fill(fIndexCentrality,iPt*dPtBinWidth, dValue, DDn3GapP);
2981  }
2982  }
2983  }
2984 
2985  //estimating <4'>
2986  //POIs in positive eta
2987  DDn4GapP = Four13DiffGapPos(0,0,0,0,iPt).Re();
2988  if(DDn4GapP!=0)
2989  {
2990  vector = Four13DiffGapPos(6,-2,-2,-2,iPt);
2991  dValue = vector.Re()/DDn4GapP;
2992  if( TMath::Abs(dValue < 1) ){
2993  profile4Pos->Fill(fIndexCentrality,iPt*dPtBinWidth, dValue, DDn4GapP);
2994  }
2995  }
2996  //POIs in negative eta
2997  DDn4GapP = Four13DiffGapNeg(0,0,0,0,iPt).Re();
2998  if(DDn4GapP!=0)
2999  {
3000  vector = Four13DiffGapNeg(6,-2,-2,-2,iPt);
3001  dValue = vector.Re()/DDn4GapP;
3002  if( TMath::Abs(dValue < 1) ){
3003  profile4Neg->Fill(fIndexCentrality,iPt*dPtBinWidth, dValue, DDn4GapP);
3004  }
3005  }
3006  }
3007  } // endfor {iPt}
3008  return;
3009 }
3010 //_____________________________________________________________________________
3012 {
3013  // Filling Q flow vector with RFPs
3014  // return kTRUE if succesfull (i.e. no error occurs), kFALSE otherwise
3015  // *************************************************************
3016  const Float_t dEtaGap = fEtaGap[iEtaGapIndex];
3017  TH3D* h3NUAWeights = 0x0;
3018  TH1F* hNUEWeights = 0x0;
3019  Double_t dNUAWeight = 1.;
3020  Double_t dNUEWeight = 1.;
3021 
3022  // clearing output (global) flow vectors
3025 
3026  Double_t dQcosPos, dQcosNeg, dQsinPos, dQsinNeg;
3027 
3028  // Double_t dQcosPos[fFlowNumHarmonicsMax][fFlowNumWeightPowersMax] = {0};
3029  // Double_t dQcosNeg[fFlowNumHarmonicsMax][fFlowNumWeightPowersMax] = {0};
3030  // Double_t dQsinPos[fFlowNumHarmonicsMax][fFlowNumWeightPowersMax] = {0};
3031  // Double_t dQsinNeg[fFlowNumHarmonicsMax][fFlowNumWeightPowersMax] = {0};
3032 
3033  for (auto part = fVectorCharged->begin(); part != fVectorCharged->end(); part++)
3034  {
3035  // checking species of used particles (just for double checking purpose)
3036  if( part->species != kCharged)
3037  {
3038  ::Warning("FillRefsVectors","Unexpected part. species (%d) in selected sample (expected %d)",part->species,kCharged);
3039  continue;
3040  }
3041  if(fFlowUseNUAWeights)
3042  {
3043  if(part->charge >0) h3NUAWeights = fh3NUAWeightRefsPlus;
3044  if(part->charge <0) h3NUAWeights = fh3NUAWeightRefsMinus;
3045 
3046  if(!h3NUAWeights) { ::Error("FillRefsVectors","Histogram with NUA weights not found."); continue; }
3047  }
3048 
3049  if(fFlowUseNUEWeights)
3050  {
3051  if(part->charge >0) hNUEWeights = fhNUEWeightRefsPlus;
3052  if(part->charge <0) hNUEWeights = fhNUEWeightRefsMinus;
3053 
3054  if(!hNUEWeights) { ::Error("FillRefsVectors","Histogram with NUE weights not found."); return; }
3055  }
3056  // RFPs pT check
3057  if(fCutFlowRFPsPtMin > 0. && part->pt < fCutFlowRFPsPtMin)
3058  continue;
3059 
3060  if(fCutFlowRFPsPtMax > 0. && part->pt > fCutFlowRFPsPtMax)
3061  continue;
3062 
3063  // 0-ing variables
3064  dQcosPos = 0;
3065  dQcosNeg = 0;
3066  dQsinPos = 0;
3067  dQsinNeg = 0;
3068 
3069  // loading weights if needed
3070  if(fFlowUseNUAWeights && h3NUAWeights)
3071  {
3072  dNUAWeight = h3NUAWeights->GetBinContent(h3NUAWeights->FindBin(part->phi,part->eta,fEventAOD->GetPrimaryVertex()->GetZ()));
3073  if(dNUAWeight <= 0) dNUAWeight = 1.;
3074  //if(iEtaGapIndex == 0)
3075  fh3AfterNUAWeightsRefs->Fill(part->phi,part->eta,fEventAOD->GetPrimaryVertex()->GetZ(), dNUAWeight);
3076  }
3077  if(fFlowUseNUEWeights && hNUEWeights)
3078  {
3079  dNUEWeight = hNUEWeights->GetBinContent(hNUEWeights->FindBin(part->pt));
3080  if(dNUEWeight <= 0) dNUEWeight = 1.;
3081  //if(iEtaGapIndex == 0)
3082  fhAfterNUEWeightsRefs->Fill(part->pt, dNUEWeight);
3083  }
3084 
3085  // RPF candidate passing all criteria: start filling flow vectors
3086 
3087  if(part->eta > dEtaGap / 2)
3088  {
3089  // RFP in positive eta acceptance
3090  for(Short_t iHarm(0); iHarm < fFlowNumHarmonicsMax; iHarm++){
3091  for(Short_t iPower(0); iPower < fFlowNumWeightPowersMax; iPower++)
3092  {
3093  dQcosPos = TMath::Power(dNUAWeight*dNUEWeight,iPower) * TMath::Cos(iHarm * part->phi);
3094  dQsinPos = TMath::Power(dNUAWeight*dNUEWeight,iPower) * TMath::Sin(iHarm * part->phi);
3095  fFlowVecQpos[iHarm][iPower] += TComplex(dQcosPos,dQsinPos,kFALSE);
3096  }
3097  }
3098  }
3099  if(part->eta < -dEtaGap / 2 )
3100  {
3101  // RFP in negative eta acceptance
3102  for(Short_t iHarm(0); iHarm < fFlowNumHarmonicsMax; iHarm++){
3103  for(Short_t iPower(0); iPower < fFlowNumWeightPowersMax; iPower++)
3104  {
3105  dQcosNeg = TMath::Power(dNUAWeight*dNUEWeight,iPower) * TMath::Cos(iHarm * part->phi);
3106  dQsinNeg = TMath::Power(dNUAWeight*dNUEWeight,iPower) * TMath::Sin(iHarm * part->phi);
3107  fFlowVecQneg[iHarm][iPower] += TComplex(dQcosNeg,dQsinNeg,kFALSE);
3108  }
3109  }
3110  }
3111  } // endfor {tracks} particle loop
3112 
3113  // // filling local flow vectors to global flow vector arrays
3114  // for(Short_t iHarm(0); iHarm < fFlowNumHarmonicsMax; iHarm++)
3115  // for(Short_t iPower(0); iPower < fFlowNumWeightPowersMax; iPower++)
3116  // {
3117  // fFlowVecQpos[iHarm][iPower] = TComplex(dQcosPos[iHarm][iPower],dQsinPos[iHarm][iPower],kFALSE);
3118  // if(dEtaGap > -1)
3119  // fFlowVecQneg[iHarm][iPower] = TComplex(dQcosNeg[iHarm][iPower],dQsinNeg[iHarm][iPower],kFALSE);
3120  // }
3121 
3122  // printf("RFPs EtaGap %g : number %g (pos) %g (neg) \n", dEtaGap,fFlowVecQpos[0][0].Re(),fFlowVecQneg[0][0].Re());
3123  return;
3124 }
3125 //_____________________________________________________________________________
3126 void AliAnalysisTaskFlowModes::FillPOIsVectors(const Short_t iEtaGapIndex, const PartSpecies species, const Short_t iMassIndex)
3127 {
3128  // Filling p,q and s flow vectors with POIs (given by species) for differential flow calculation
3129  // *************************************************************
3130 
3131  if(species == kUnknown) return;
3132 
3133  Double_t dNUAWeight = 1.; // for generic framework != 1
3134  Double_t dNUEWeight = 1.; // for generic framework != 1
3135 
3136  // clearing output (global) flow vectors
3140 
3141  std::vector<FlowPart>* vector = 0x0;
3142  //TH3D* hist = 0x0;
3143  //Double_t dMassLow = 0, dMassHigh = 0;
3144  TH3D* h3NUAWeights = 0x0;
3145  TH1F* hNUEWeights = 0x0;
3146 
3147  // swich based on species
3148  switch (species)
3149  {
3150  case kCharged:
3151  vector = fVectorCharged;
3152  break;
3153 
3154  case kPion:
3155  vector = fVectorPion;
3156  break;
3157 
3158  case kKaon:
3159  vector = fVectorKaon;
3160  break;
3161 
3162  case kProton:
3163  vector = fVectorProton;
3164  break;
3165 
3166  default:
3167  ::Error("FillPOIsVectors","Selected species unknown.");
3168  return;
3169  }//switch(species)
3170 
3171  const Double_t dEtaGap = fEtaGap[iEtaGapIndex];
3172  //const Double_t dMass = (dMassLow+dMassHigh)/2;
3173 
3174  Short_t iPtBin = 0;
3175  Double_t dCos = 0, dSin = 0;
3176 
3177  for (auto part = vector->begin(); part != vector->end(); part++)
3178  {
3179 
3180  // swich based on species
3181  switch (species)
3182  {
3183  case kCharged:
3184  if(fFlowUseNUAWeights) {
3185  if(part->charge >0) h3NUAWeights = fh3NUAWeightChargedPlus;
3186  if(part->charge <0) h3NUAWeights = fh3NUAWeightChargedMinus;
3187  }
3188  if(fFlowUseNUEWeights) {
3189  if(part->charge >0) hNUEWeights = fhNUEWeightChargedPlus;
3190  if(part->charge <0) hNUEWeights = fhNUEWeightChargedMinus;
3191  }
3192  break;
3193 
3194  case kPion:
3195  if(fFlowUseNUAWeights) {
3196  if(part->charge >0) h3NUAWeights = fh3NUAWeightPionPlus;
3197  if(part->charge <0) h3NUAWeights = fh3NUAWeightPionMinus;
3198  }
3199  if(fFlowUseNUEWeights) {
3200  if(part->charge >0) hNUEWeights = fhNUEWeightPionPlus;
3201  if(part->charge <0) hNUEWeights = fhNUEWeightPionMinus;
3202  }
3203  break;
3204 
3205  case kKaon:
3206  if(fFlowUseNUAWeights) {
3207  if(part->charge >0) h3NUAWeights = fh3NUAWeightKaonPlus;
3208  if(part->charge <0) h3NUAWeights = fh3NUAWeightKaonMinus;
3209  }
3210  if(fFlowUseNUEWeights) {
3211  if(part->charge >0) hNUEWeights = fhNUEWeightKaonPlus;
3212  if(part->charge <0) hNUEWeights = fhNUEWeightKaonMinus;
3213  }
3214  break;
3215 
3216  case kProton:
3217  if(fFlowUseNUAWeights) {
3218  if(part->charge >0) h3NUAWeights = fh3NUAWeightProtonPlus;
3219  if(part->charge <0) h3NUAWeights = fh3NUAWeightProtonMinus;
3220  }
3221  if(fFlowUseNUEWeights) {
3222  if(part->charge >0) hNUEWeights = fhNUEWeightProtonPlus;
3223  if(part->charge <0) hNUEWeights = fhNUEWeightProtonMinus;
3224  }
3225  break;
3226 
3227  default:
3228  ::Error("FillPOIsVectors","Selected species unknown.");
3229  return;
3230  }//switch(species)
3231 
3232  if(fFlowUseNUAWeights && !h3NUAWeights) { ::Error("FillPOIsVectors","Histogram with NUA weights not found."); continue; }
3233  if(fFlowUseNUEWeights && !hNUEWeights) { ::Error("FillPOIsVectors","Histogram with NUE weights not found."); return; }
3234 
3235  // checking species of used particles (just for double checking purpose)
3236  if( part->species != species)
3237  {
3238  ::Warning("FillPOIsVectors","Unexpected part. species (%d) in selected sample (expected %d)",part->species,species);
3239  continue;
3240  }//endif{part->species != species}
3241 
3242  // assign iPtBin based on particle momenta
3243  iPtBin = GetPOIsPtBinIndex(part->pt);
3244 
3245  // 0-ing variables
3246  dCos = 0;
3247  dSin = 0;
3248 
3249  // POIs candidate passing all criteria: start filling flow vectors
3250 
3251  // loading weights if needed
3252  if(fFlowUseNUAWeights && h3NUAWeights)
3253  {
3254  dNUAWeight = h3NUAWeights->GetBinContent(h3NUAWeights->FindBin(part->phi,part->eta,fEventAOD->GetPrimaryVertex()->GetZ()));
3255  if(dNUAWeight <= 0){ dNUAWeight = 1.;}
3256  //if(iEtaGapIndex == 0){
3257  switch (species)
3258  {
3259  case kCharged:
3260  fh3AfterNUAWeightsCharged->Fill(part->phi,part->eta,fEventAOD->GetPrimaryVertex()->GetZ(), dNUAWeight);
3261  break;
3262  case kPion:
3263  fh3AfterNUAWeightsPion->Fill(part->phi,part->eta,fEventAOD->GetPrimaryVertex()->GetZ(), dNUAWeight);
3264  break;
3265  case kKaon:
3266  fh3AfterNUAWeightsKaon->Fill(part->phi,part->eta,fEventAOD->GetPrimaryVertex()->GetZ(), dNUAWeight);
3267  break;
3268  case kProton:
3269  fh3AfterNUAWeightsProton->Fill(part->phi,part->eta,fEventAOD->GetPrimaryVertex()->GetZ(), dNUAWeight);
3270  break;
3271  default:
3272  ::Error("Fill fh3AfterNUAWeights","Selected species unknown.");
3273  return;
3274  }
3275  //}
3276  }//endif{fFlowUseNUAWeights && h3NUAWeights}
3277 
3278  if(fFlowUseNUEWeights && hNUEWeights)
3279  {
3280  dNUEWeight = hNUEWeights->GetBinContent(hNUEWeights->FindBin(part->pt));
3281  if(dNUEWeight <= 0) dNUEWeight = 1.;
3282  //if(iEtaGapIndex == 0){
3283  switch (species)
3284  {
3285  case kCharged:
3286  fhAfterNUEWeightsCharged->Fill(part->pt, dNUEWeight);
3287  break;
3288  case kPion:
3289  fhAfterNUEWeightsPion->Fill(part->pt, dNUEWeight);
3290  break;
3291  case kKaon:
3292  fhAfterNUEWeightsKaon->Fill(part->pt, dNUEWeight);
3293  break;
3294  case kProton:
3295  fhAfterNUEWeightsProton->Fill(part->pt, dNUEWeight);
3296  break;
3297  default:
3298  ::Error("Fill fhAfterNUEWeights","Selected species unknown.");
3299  return;
3300  }
3301  //}
3302  }//endif{fFlowUseNUEWeights && hNUEWeights}
3303 
3304  if(part->eta > dEtaGap / 2 )
3305  {
3306  // particle in positive eta acceptance
3307  for(Short_t iHarm(0); iHarm < fFlowNumHarmonicsMax; iHarm++){
3308  for(Short_t iPower(0); iPower < fFlowNumWeightPowersMax; iPower++)
3309  {
3310  dCos = TMath::Power(dNUAWeight*dNUEWeight,iPower) * TMath::Cos(iHarm * part->phi);
3311  dSin = TMath::Power(dNUAWeight*dNUEWeight,iPower) * TMath::Sin(iHarm * part->phi);
3312  fFlowVecPpos[iHarm][iPower][iPtBin] += TComplex(dCos,dSin,kFALSE);
3313  }//endfor{Short_t iPower(0); iPower < fFlowNumWeightPowersMax; iPower++}
3314  }//endfor{Short_t iHarm(0); iHarm < fFlowNumHarmonicsMax; iHarm++}
3315  }//endif{part->eta > dEtaGap / 2 }
3316  if(part->eta < -dEtaGap / 2 ){
3317  // particle in negative eta acceptance
3318  for(Short_t iHarm(0); iHarm < fFlowNumHarmonicsMax; iHarm++){
3319  for(Short_t iPower(0); iPower < fFlowNumWeightPowersMax; iPower++)
3320  {
3321  dCos = TMath::Power(dNUAWeight*dNUEWeight,iPower) * TMath::Cos(iHarm * part->phi);
3322  dSin = TMath::Power(dNUAWeight*dNUEWeight,iPower) * TMath::Sin(iHarm * part->phi);
3323  fFlowVecPneg[iHarm][iPower][iPtBin] += TComplex(dCos,dSin,kFALSE);
3324  }//endfor{Short_t iPower(0); iPower < fFlowNumWeightPowersMax; iPower++}
3325  }//endfor{Short_t iHarm(0); iHarm < fFlowNumHarmonicsMax; iHarm++}
3326  }//endif{part->eta < -dEtaGap / 2 }
3327  } // endfor {tracks}
3328  return;
3329 }
3330 //_____________________________________________________________________________
3332 {
3333  // Return POIs pT bin index based on pT value
3334  // *************************************************************
3335  const Double_t dPtBinWidth = (fFlowPOIsPtMax - fFlowPOIsPtMin) / fFlowPOIsPtNumBins;
3336  // printf("Pt %g | index %d\n",pt,(Short_t) (pt / dPtBinWidth) );
3337  return (Short_t) (pt / dPtBinWidth);
3338 }
3339 //_____________________________________________________________________________
3341 {
3342  // Reset RFPs (Q) array values to TComplex(0,0,kFALSE) for given array
3343  // *************************************************************
3344  for(Short_t iHarm(0); iHarm < fFlowNumHarmonicsMax; iHarm++)
3345  for(Short_t iPower(0); iPower < fFlowNumWeightPowersMax; iPower++)
3346  array[iHarm][iPower] = TComplex(0,0,kFALSE);
3347  return;
3348 }
3349 //_____________________________________________________________________________
3351 {
3352  for(Short_t iHarm(0); iHarm < fFlowNumHarmonicsMax; iHarm++)
3353  for(Short_t iPower(0); iPower < fFlowNumWeightPowersMax; iPower++)
3354  for(Short_t iPt(0); iPt < fFlowPOIsPtNumBins; iPt++)
3355  array[iHarm][iPower][iPt] = TComplex(0,0,kFALSE);
3356  return;
3357 }
3358 //_____________________________________________________________________________
3360 {
3361  // List all values of given flow vector TComplex array
3362  // *************************************************************
3363  printf(" ### Listing (TComplex) flow vector array ###########################\n");
3364  for(Short_t iHarm(0); iHarm < fFlowNumHarmonicsMax; iHarm++)
3365  {
3366  printf("Harm %d (power):",iHarm);
3367  for(Short_t iPower(0); iPower < fFlowNumWeightPowersMax; iPower++)
3368  {
3369  printf("|(%d) %g+%g(i)",iPower, array[iHarm][iPower].Re(), array[iHarm][iPower].Im());
3370  }
3371  printf("\n");
3372  }
3373  return;
3374 }
3375 //_____________________________________________________________________________
3377 {
3378  // Assessing sampling index based on generated random number
3379  // returns centrality index
3380  // *************************************************************
3381 
3382  Short_t index = 0x0;
3383 
3384  if(fSampling && fNumSamples > 1)
3385  {
3386  TRandom3 rr(0);
3387  Double_t ranNum = rr.Rndm(); // getting random number in (0,1)
3388  Double_t generated = ranNum * fNumSamples; // getting random number in range (0, fNumSamples)
3389  // finding right index for sampling based on generated number and total number of samples
3390  for(Short_t i(0); i < fNumSamples; i++)
3391  {
3392  if(generated < (i+1) )
3393  {
3394  index = i;
3395  break;
3396  }
3397  }
3398  }
3399 
3400  return index;
3401 }
3402 
3403 //_____________________________________________________________________________
3405 {
3406  // Estimating centrality percentile based on selected estimator.
3407  // (Default) If no multiplicity estimator is specified (fMultEstimator == '' || Charged), percentile is estimated as number of selected / filtered charged tracks.
3408  // If a valid multiplicity estimator is specified, centrality percentile is estimated via AliMultSelection
3409  // otherwise -1 is returned (and event is skipped)
3410  // *************************************************************
3411  fMultEstimator.ToUpper();
3412  if(
3413  fMultEstimator.EqualTo("V0A") || fMultEstimator.EqualTo("V0C") || fMultEstimator.EqualTo("V0M") ||
3414  fMultEstimator.EqualTo("CL0") || fMultEstimator.EqualTo("CL1") || fMultEstimator.EqualTo("ZNA") ||
3415  fMultEstimator.EqualTo("ZNC") || fMultEstimator.EqualTo("TRK") ){
3416 
3417  // some of supported AliMultSelection estimators (listed above)
3418  Float_t dPercentile = 300;
3419 
3420  // checking AliMultSelection
3421  AliMultSelection* multSelection = 0x0;
3422  multSelection = (AliMultSelection*) fEventAOD->FindListObject("MultSelection");
3423  if(!multSelection) { AliError("AliMultSelection object not found! Returning -1"); return -1;}
3424 
3425  dPercentile = multSelection->GetMultiplicityPercentile(fMultEstimator.Data());
3427  if(dPercentile > 100 || dPercentile < 0) { AliWarning("Centrality percentile estimated not within 0-100 range. Returning -1"); return -1;}
3428  else { return dPercentile;}
3429  }
3430  if(!fFullCentralityRange){
3431  if(dPercentile > 100 || dPercentile <50) { AliWarning("Centrality percentile estimated not within 50-100 range. Returning -1"); return -1;}
3432  else { return dPercentile;}
3433  }
3434  }
3435  else if(fMultEstimator.EqualTo("") || fMultEstimator.EqualTo("CHARGED"))
3436  {
3437  // assigning centrality based on number of selected charged tracks
3438  return fVectorCharged->size();
3439  }
3440  else
3441  {
3442  AliWarning(Form("Multiplicity estimator '%s' not supported. Returning -1\n",fMultEstimator.Data()));
3443  return -1;
3444  }
3445 
3446 
3447  return -1;
3448 }
3449 //____________________________
3450 Double_t AliAnalysisTaskFlowModes::GetWDist(const AliAODVertex* v0, const AliAODVertex* v1) {
3451 // calculate sqrt of weighted distance to other vertex
3452  if (!v0 || !v1) {
3453  printf("One of vertices is not valid\n");
3454  return kFALSE;
3455  }
3456  static TMatrixDSym vVb(3);
3457  double dist = -1;
3458  double dx = v0->GetX()-v1->GetX();
3459  double dy = v0->GetY()-v1->GetY();
3460  double dz = v0->GetZ()-v1->GetZ();
3461  double cov0[6],cov1[6];
3462  v0->GetCovarianceMatrix(cov0);
3463  v1->GetCovarianceMatrix(cov1);
3464  vVb(0,0) = cov0[0]+cov1[0];
3465  vVb(1,1) = cov0[2]+cov1[2];
3466  vVb(2,2) = cov0[5]+cov1[5];
3467  vVb(1,0) = vVb(0,1) = cov0[1]+cov1[1];
3468  vVb(0,2) = vVb(1,2) = vVb(2,0) = vVb(2,1) = 0.;
3469  vVb.InvertFast();
3470  if (!vVb.IsValid()) {printf("Singular Matrix\n"); return dist;}
3471  dist = vVb(0,0)*dx*dx + vVb(1,1)*dy*dy + vVb(2,2)*dz*dz+2*vVb(0,1)*dx*dy + 2*vVb(0,2)*dx*dz + 2*vVb(1,2)*dy*dz;
3472  return dist>0 ? TMath::Sqrt(dist) : -1;
3473 }
3474 //_________________________________________________
3476 {
3477  // called on end of task, after all events are processed
3478  // *************************************************************
3479 
3480  return;
3481 }
3482 //_____________________________________________________________________________
3483 // Set of methods returning given complex flow vector based on flow harmonics (n) and weight power indexes (p)
3484 // a la General Framework implementation.
3485 // Q: flow vector of RFPs (with/out eta gap)
3486 // P: flow vector of POIs (with/out eta gap) (in usual notation p)
3487 // S: flow vector of overlaping RFPs and POIs (in usual notation q)
3488 
3489 TComplex AliAnalysisTaskFlowModes::Q(const Short_t n, const Short_t p)
3490 {
3491  if (n < 0) return TComplex::Conjugate(fFlowVecQpos[-n][p]);
3492  else return fFlowVecQpos[n][p];
3493 }
3494 //____________________________________________________________________
3496 {
3497  if (n < 0) return TComplex::Conjugate(fFlowVecQpos[-n][p]);
3498  else return fFlowVecQpos[n][p];
3499 }
3500 //____________________________________________________________________
3502 {
3503  if(n < 0) return TComplex::Conjugate(fFlowVecQneg[-n][p]);
3504  else return fFlowVecQneg[n][p];
3505 }
3506 //____________________________________________________________________
3507 TComplex AliAnalysisTaskFlowModes::P(const Short_t n, const Short_t p, const Short_t pt)
3508 {
3509  if(n < 0) return TComplex::Conjugate(fFlowVecPpos[-n][p][pt]);
3510  else return fFlowVecPpos[n][p][pt];
3511 }
3512 //____________________________________________________________________
3513 TComplex AliAnalysisTaskFlowModes::PGapPos(const Short_t n, const Short_t p, const Short_t pt)
3514 {
3515  if(n < 0) return TComplex::Conjugate(fFlowVecPpos[-n][p][pt]);
3516  else return fFlowVecPpos[n][p][pt];
3517 }
3518 //____________________________________________________________________
3519 TComplex AliAnalysisTaskFlowModes::PGapNeg(const Short_t n, const Short_t p, const Short_t pt)
3520 {
3521  if(n < 0) return TComplex::Conjugate(fFlowVecPneg[-n][p][pt]);
3522  else return fFlowVecPneg[n][p][pt];
3523 }
3524 //____________________________________________________________________
3525 TComplex AliAnalysisTaskFlowModes::S(const Short_t n, const Short_t p, const Short_t pt)
3526 {
3527  if(n < 0) return TComplex::Conjugate(fFlowVecS[-n][p][pt]);
3528  else return fFlowVecS[n][p][pt];
3529 }
3530 //____________________________________________________________________
3531 
3532 // Set of flow calculation methods for cumulants of different orders with/out eta gap
3533 
3534 TComplex AliAnalysisTaskFlowModes::Two(const Short_t n1, const Short_t n2)
3535 {
3536  TComplex formula = Q(n1,1)*Q(n2,1) - Q(n1+n2,2);
3537  return formula;
3538 }
3539 //____________________________________________________________________
3541 {
3542  TComplex formula = QGapPos(n1,1)*QGapNeg(n2,1);
3543  return formula;
3544 }
3545 //____________________________________________________________________
3546 TComplex AliAnalysisTaskFlowModes::TwoDiff(const Short_t n1, const Short_t n2, const Short_t pt)
3547 {
3548  TComplex formula = P(n1,1,pt)*Q(n2,1) - S(n1+n2,1,pt);
3549  return formula;
3550 }
3551 //____________________________________________________________________
3552 TComplex AliAnalysisTaskFlowModes::TwoDiffGapPos(const Short_t n1, const Short_t n2, const Short_t pt)
3553 {
3554  TComplex formula = PGapPos(n1,1,pt)*QGapNeg(n2,1);
3555  return formula;
3556 }
3557 //____________________________________________________________________
3558 TComplex AliAnalysisTaskFlowModes::TwoDiffGapNeg(const Short_t n1, const Short_t n2, const Short_t pt)
3559 {
3560  TComplex formula = PGapNeg(n1,1,pt)*QGapPos(n2,1);
3561  return formula;
3562 }
3563 //____________________________________________________________________
3564 TComplex AliAnalysisTaskFlowModes::ThreeDiffGapPos(const Short_t n1, const Short_t n2, const Short_t n3,const Short_t pt)
3565 {
3566  TComplex formula = PGapPos(n1,1,pt)*QGapNeg(n2,1)*QGapNeg(n3,1)- PGapPos(n1,1,pt)*QGapNeg(n2+n3,2);
3567  return formula;
3568 }
3569 //____________________________________________________________________
3570 TComplex AliAnalysisTaskFlowModes::ThreeDiffGapNeg(const Short_t n1, const Short_t n2, const Short_t n3,const Short_t pt)
3571 {
3572  TComplex formula = PGapNeg(n1,1,pt)*QGapPos(n2,1)*QGapPos(n3,1)- PGapNeg(n1,1,pt)*QGapPos(n2+n3,2);
3573  return formula;
3574 }
3575 //____________________________________________________________________
3576 TComplex AliAnalysisTaskFlowModes::Four(const Short_t n1, const Short_t n2, const Short_t n3, const Short_t n4)
3577 {
3578  TComplex formula = Q(n1,1)*Q(n2,1)*Q(n3,1)*Q(n4,1)-Q(n1+n2,2)*Q(n3,1)*Q(n4,1)-Q(n2,1)*Q(n1+n3,2)*Q(n4,1)
3579  - Q(n1,1)*Q(n2+n3,2)*Q(n4,1)+2.*Q(n1+n2+n3,3)*Q(n4,1)-Q(n2,1)*Q(n3,1)*Q(n1+n4,2)
3580  + Q(n2+n3,2)*Q(n1+n4,2)-Q(n1,1)*Q(n3,1)*Q(n2+n4,2)+Q(n1+n3,2)*Q(n2+n4,2)
3581  + 2.*Q(n3,1)*Q(n1+n2+n4,3)-Q(n1,1)*Q(n2,1)*Q(n3+n4,2)+Q(n1+n2,2)*Q(n3+n4,2)
3582  + 2.*Q(n2,1)*Q(n1+n3+n4,3)+2.*Q(n1,1)*Q(n2+n3+n4,3)-6.*Q(n1+n2+n3+n4,4);
3583  return formula;
3584 }
3585 // //____________________________________________________________________
3586 TComplex AliAnalysisTaskFlowModes::FourDiff(const Short_t n1, const Short_t n2, const Short_t n3, const Short_t n4, const Short_t pt)
3587 {
3588  TComplex formula = P(n1,1,pt)*Q(n2,1)*Q(n3,1)*Q(n4,1)-S(n1+n2,2,pt)*Q(n3,1)*Q(n4,1)-Q(n2,1)*S(n1+n3,2,pt)*Q(n4,1)
3589  - P(n1,1,pt)*Q(n2+n3,2)*Q(n4,1)+2.*S(n1+n2+n3,3,pt)*Q(n4,1)-Q(n2,1)*Q(n3,1)*S(n1+n4,2,pt)
3590  + Q(n2+n3,2)*S(n1+n4,2,pt)-P(n1,1,pt)*Q(n3,1)*Q(n2+n4,2)+S(n1+n3,2,pt)*Q(n2+n4,2)
3591  + 2.*Q(n3,1)*S(n1+n2+n4,3,pt)-P(n1,1,pt)*Q(n2,1)*Q(n3+n4,2)+S(n1+n2,2,pt)*Q(n3+n4,2)
3592  + 2.*Q(n2,1)*S(n1+n3+n4,3,pt)+2.*P(n1,1,pt)*Q(n2+n3+n4,3)-6.*S(n1+n2+n3+n4,4,pt);
3593  return formula;
3594 }
3595 //____________________________________________________________________
3596 TComplex AliAnalysisTaskFlowModes::FourGapPos(const Short_t n1, const Short_t n2, const Short_t n3, const Short_t n4) // n1+n2 = n3+n4; n1, n2 from P & n3, n4 from M
3597 {
3598  TComplex formula = QGapPos(n1,1)*QGapPos(n2,1)*QGapNeg(n3,1)*QGapNeg(n4,1)-QGapPos(n1+n2,2)*QGapNeg(n3,1)*QGapNeg(n4,1)-QGapPos(n1,1)*QGapPos(n2,1)*QGapNeg(n3+n4,2)+QGapPos(n1+n2,2)*QGapNeg(n3+n4,2);
3599  //TComplex *out = (TComplex*) &formula;
3600  return formula;
3601 }
3602 //____________________________________________________________________
3603 TComplex AliAnalysisTaskFlowModes::FourGapNeg(const Short_t n1, const Short_t n2, const Short_t n3, const Short_t n4) // n1+n2 = n3+n4; n1, n2 from M & n3, n4 from P
3604 {
3605  TComplex formula = QGapNeg(n1,1)*QGapNeg(n2,1)*QGapPos(n3,1)*QGapPos(n4,1)-QGapNeg(n1+n2,2)*QGapPos(n3,1)*QGapPos(n4,1)-QGapNeg(n1,1)*QGapNeg(n2,1)*QGapPos(n3+n4,2)+QGapNeg(n1+n2,2)*QGapPos(n3+n4,2);
3606  //TComplex *out = (TComplex*) &formula;
3607  return formula;
3608 }
3609 //____________________________________________________________________
3610 TComplex AliAnalysisTaskFlowModes::Four13DiffGapPos(const Short_t n1, const Short_t n2, const Short_t n3, const Short_t n4,const Short_t pt) // n1 = n2 + n3 + n4
3611 {
3612  TComplex formula = PGapPos(n1,1,pt)*QGapNeg(n2,1)*QGapNeg(n3,1)*QGapNeg(n4,1)- PGapPos(n1,1,pt)*QGapNeg(n2+n3,2)*QGapNeg(n4,1) - PGapPos(n1,1,pt)*QGapNeg(n2+n4,2)*QGapNeg(n3,1) - PGapPos(n1,1,pt)*QGapNeg(n3+n4,2)*QGapNeg(n2,1) + 2.*PGapPos(n1,1,pt)*QGapNeg(n2+n3+n4,3);
3613  return formula;
3614 }
3615 //____________________________________________________________________
3616 TComplex AliAnalysisTaskFlowModes::Four13DiffGapNeg(const Short_t n1, const Short_t n2, const Short_t n3, const Short_t n4,const Short_t pt) // n1 = n2 + n3 + n4
3617 {
3618  TComplex formula = PGapNeg(n1,1,pt)*QGapPos(n2,1)*QGapPos(n3,1)*QGapPos(n4,1)- PGapNeg(n1,1,pt)*QGapPos(n2+n3,2)*QGapPos(n4,1) - PGapNeg(n1,1,pt)*QGapPos(n2+n4,2)*QGapPos(n3,1) - PGapNeg(n1,1,pt)*QGapPos(n3+n4,2)*QGapPos(n2,1) + 2.*PGapNeg(n1,1,pt)*QGapPos(n2+n3+n4,3);
3619  return formula;
3620 }
3621 //____________________________________________________________________
3622 TComplex AliAnalysisTaskFlowModes::SixGapPos(const Short_t n1, const Short_t n2, const Short_t n3, const Short_t n4, const Short_t n5, const Short_t n6) // n1 + n2 + n3 = n4 + n5 + n6
3623 {
3624  TComplex formula = QGapPos(n1,1)*QGapPos(n2,1)*QGapPos(n3,1)*QGapNeg(n4,1)*QGapNeg(n5,1)*QGapNeg(n6,1) - QGapPos(n1,1)*QGapPos(n2,1)*QGapPos(n3,1)*QGapNeg(n4+n5,2)*QGapNeg(n6,1) - QGapPos(n1,1)*QGapPos(n2,1)*QGapPos(n3,1)*QGapNeg(n4+n6,2)*QGapNeg(n5,1) - QGapPos(n1,1)*QGapPos(n2,1)*QGapPos(n3,1)*QGapNeg(n5+n6,2)*QGapNeg(n4,1) + 2.*QGapPos(n1,1)*QGapPos(n2,1)*QGapPos(n3,1)*QGapNeg(n4+n5+n6,3)- QGapPos(n1+n2,2)*QGapPos(n3,1)*QGapNeg(n4,1)*QGapNeg(n5,1)*QGapNeg(n6,1) + QGapPos(n1+n2,2)*QGapPos(n3,1)*QGapNeg(n4+n5,2)*QGapNeg(n6,1) + QGapPos(n1+n2,2)*QGapPos(n3,1)*QGapNeg(n4+n6,2)*QGapNeg(n5,1) + QGapPos(n1+n2,2)*QGapPos(n3,1)*QGapNeg(n5+n6,2)*QGapNeg(n4,1) - 2.*QGapPos(n1+n2,2)*QGapPos(n3,1)*QGapNeg(n4+n5+n6,3) - QGapPos(n1+n3,2)*QGapPos(n2,1)*QGapNeg(n4,1)*QGapNeg(n5,1)*QGapNeg(n6,1) + QGapPos(n1+n3,2)*QGapPos(n2,1)*QGapNeg(n4+n5,2)*QGapNeg(n6,1) + QGapPos(n1+n3,2)*QGapPos(n2,1)*QGapNeg(n4+n6,2)*QGapNeg(n5,1) + QGapPos(n1+n3,2)*QGapPos(n2,1)*QGapNeg(n5+n6,2)*QGapNeg(n4,1) - 2.*QGapPos(n1+n3,2)*QGapPos(n2,1)*QGapNeg(n4+n5+n6,3) - QGapPos(n2+n3,2)*QGapPos(n1,1)*QGapNeg(n4,1)*QGapNeg(n5,1)*QGapNeg(n6,1) + QGapPos(n2+n3,2)*QGapPos(n1,1)*QGapNeg(n4+n5,2)*QGapNeg(n6,1) + QGapPos(n2+n3,2)*QGapPos(n1,1)*QGapNeg(n4+n6,2)*QGapNeg(n5,1) + QGapPos(n2+n3,2)*QGapPos(n1,1)*QGapNeg(n5+n6,2)*QGapNeg(n4,1) - 2.*QGapPos(n2+n3,2)*QGapPos(n1,1)*QGapNeg(n4+n5+n6,3)+ 2.*QGapPos(n1+n2+n3,3)*QGapNeg(n4,1)*QGapNeg(n5,1)*QGapNeg(n6,1) - 2.*QGapPos(n1+n2+n3,3)*QGapNeg(n4+n5,2)*QGapNeg(n6,1) - 2.*QGapPos(n1+n2+n3,3)*QGapNeg(n4+n6,2)*QGapNeg(n5,1) - 2.*QGapPos(n1+n2+n3,3)*QGapNeg(n5+n6,2)*QGapNeg(n4,1) + 4.*QGapPos(n1+n2+n3,3)*QGapNeg(n4+n5+n6,3);
3625  return formula;
3626 }
3627 //____________________________________________________________________
3628 TComplex AliAnalysisTaskFlowModes::SixGapNeg(const Short_t n1, const Short_t n2, const Short_t n3, const Short_t n4, const Short_t n5, const Short_t n6) // n1 + n2 + n3 = n4 + n5 + n6
3629 {
3630 
3631  TComplex formula = QGapNeg(n1,1)*QGapNeg(n2,1)*QGapNeg(n3,1)*QGapPos(n4,1)*QGapPos(n5,1)*QGapPos(n6,1) - QGapNeg(n1,1)*QGapNeg(n2,1)*QGapNeg(n3,1)*QGapPos(n4+n5,2)*QGapPos(n6,1) - QGapNeg(n1,1)*QGapNeg(n2,1)*QGapNeg(n3,1)*QGapPos(n4+n6,2)*QGapPos(n5,1) - QGapNeg(n1,1)*QGapNeg(n2,1)*QGapNeg(n3,1)*QGapPos(n5+n6,2)*QGapPos(n4,1) + 2.*QGapNeg(n1,1)*QGapNeg(n2,1)*QGapNeg(n3,1)*QGapPos(n4+n5+n6,3)- QGapNeg(n1+n2,2)*QGapNeg(n3,1)*QGapPos(n4,1)*QGapPos(n5,1)*QGapPos(n6,1) + QGapNeg(n1+n2,2)*QGapNeg(n3,1)*QGapPos(n4+n5,2)*QGapPos(n6,1) + QGapNeg(n1+n2,2)*QGapNeg(n3,1)*QGapPos(n4+n6,2)*QGapPos(n5,1) + QGapNeg(n1+n2,2)*QGapNeg(n3,1)*QGapPos(n5+n6,2)*QGapPos(n4,1) - 2.*QGapNeg(n1+n2,2)*QGapNeg(n3,1)*QGapPos(n4+n5+n6,3) - QGapNeg(n1+n3,2)*QGapNeg(n2,1)*QGapPos(n4,1)*QGapPos(n5,1)*QGapPos(n6,1) + QGapNeg(n1+n3,2)*QGapNeg(n2,1)*QGapPos(n4+n5,2)*QGapPos(n6,1) + QGapNeg(n1+n3,2)*QGapNeg(n2,1)*QGapPos(n4+n6,2)*QGapPos(n5,1) + QGapNeg(n1+n3,2)*QGapNeg(n2,1)*QGapPos(n5+n6,2)*QGapPos(n4,1) - 2.*QGapNeg(n1+n3,2)*QGapNeg(n2,1)*QGapPos(n4+n5+n6,3) - QGapNeg(n2+n3,2)*QGapNeg(n1,1)*QGapPos(n4,1)*QGapPos(n5,1)*QGapPos(n6,1) + QGapNeg(n2+n3,2)*QGapNeg(n1,1)*QGapPos(n4+n5,2)*QGapPos(n6,1) + QGapNeg(n2+n3,2)*QGapNeg(n1,1)*QGapPos(n4+n6,2)*QGapPos(n5,1) + QGapNeg(n2+n3,2)*QGapNeg(n1,1)*QGapPos(n5+n6,2)*QGapPos(n4,1) - 2.*QGapNeg(n2+n3,2)*QGapNeg(n1,1)*QGapPos(n4+n5+n6,3)+ 2.*QGapNeg(n1+n2+n3,3)*QGapPos(n4,1)*QGapPos(n5,1)*QGapPos(n6,1) -2.*QGapNeg(n1+n2+n3,3)*QGapPos(n4+n5,2)*QGapPos(n6,1) - 2.*QGapNeg(n1+n2+n3,3)*QGapPos(n4+n6,2)*QGapPos(n5,1) - 2.*QGapNeg(n1+n2+n3,3)*QGapPos(n5+n6,2)*QGapPos(n4,1) + 4.*QGapNeg(n1+n2+n3,3)*QGapPos(n4+n5+n6,3);
3632  return formula;
3633 }
3634 
3635 //-----------------------------------------------------------------------
3637  //set priors for the bayesian pid selection
3638  fCurrCentr = centrCur;
3639 
3640  fBinLimitPID[0] = 0.300000;
3641  fBinLimitPID[1] = 0.400000;
3642  fBinLimitPID[2] = 0.500000;
3643  fBinLimitPID[3] = 0.600000;
3644  fBinLimitPID[4] = 0.700000;
3645  fBinLimitPID[5] = 0.800000;
3646  fBinLimitPID[6] = 0.900000;
3647  fBinLimitPID[7] = 1.000000;
3648  fBinLimitPID[8] = 1.200000;
3649  fBinLimitPID[9] = 1.400000;
3650  fBinLimitPID[10] = 1.600000;
3651  fBinLimitPID[11] = 1.800000;
3652  fBinLimitPID[12] = 2.000000;
3653  fBinLimitPID[13] = 2.200000;
3654  fBinLimitPID[14] = 2.400000;
3655  fBinLimitPID[15] = 2.600000;
3656  fBinLimitPID[16] = 2.800000;
3657  fBinLimitPID[17] = 3.000000;
3658 
3659  for(Int_t i=18;i<fgkPIDptBin;i++){
3660  fBinLimitPID[i] = 3.0 + 0.2 * (i-17);
3661  }
3662 
3663  // 0-10%
3664  if(centrCur < 10){
3665  fC[0][0] = 0.005;
3666  fC[0][1] = 0.005;
3667  fC[0][2] = 1.0000;
3668  fC[0][3] = 0.0010;
3669  fC[0][4] = 0.0010;
3670 
3671  fC[1][0] = 0.005;
3672  fC[1][1] = 0.005;
3673  fC[1][2] = 1.0000;
3674  fC[1][3] = 0.0168;
3675  fC[1][4] = 0.0122;
3676 
3677  fC[2][0] = 0.005;
3678  fC[2][1] = 0.005;
3679  fC[2][2] = 1.0000;
3680  fC[2][3] = 0.0272;
3681  fC[2][4] = 0.0070;
3682 
3683  fC[3][0] = 0.005;
3684  fC[3][1] = 0.005;
3685  fC[3][2] = 1.0000;
3686  fC[3][3] = 0.0562;
3687  fC[3][4] = 0.0258;
3688 
3689  fC[4][0] = 0.005;
3690  fC[4][1] = 0.005;
3691  fC[4][2] = 1.0000;
3692  fC[4][3] = 0.0861;
3693  fC[4][4] = 0.0496;
3694 
3695  fC[5][0] = 0.005;
3696  fC[5][1] = 0.005;
3697  fC[5][2] = 1.0000;
3698  fC[5][3] = 0.1168;
3699  fC[5][4] = 0.0740;
3700 
3701  fC[6][0] = 0.005;
3702  fC[6][1] = 0.005;
3703  fC[6][2] = 1.0000;
3704  fC[6][3] = 0.1476;
3705  fC[6][4] = 0.0998;
3706 
3707  fC[7][0] = 0.005;
3708  fC[7][1] = 0.005;
3709  fC[7][2] = 1.0000;
3710  fC[7][3] = 0.1810;
3711  fC[7][4] = 0.1296;
3712 
3713  fC[8][0] = 0.005;
3714  fC[8][1] = 0.005;
3715  fC[8][2] = 1.0000;
3716  fC[8][3] = 0.2240;
3717  fC[8][4] = 0.1827;
3718 
3719  fC[9][0] = 0.005;
3720  fC[9][1] = 0.005;
3721  fC[9][2] = 1.0000;
3722  fC[9][3] = 0.2812;
3723  fC[9][4] = 0.2699;
3724 
3725  fC[10][0] = 0.005;
3726  fC[10][1] = 0.005;
3727  fC[10][2] = 1.0000;
3728  fC[10][3] = 0.3328;
3729  fC[10][4] = 0.3714;
3730 
3731  fC[11][0] = 0.005;
3732  fC[11][1] = 0.005;
3733  fC[11][2] = 1.0000;
3734  fC[11][3] = 0.3780;
3735  fC[11][4] = 0.4810;
3736 
3737  fC[12][0] = 0.005;
3738  fC[12][1] = 0.005;
3739  fC[12][2] = 1.0000;
3740  fC[12][3] = 0.4125;
3741  fC[12][4] = 0.5771;
3742 
3743  fC[13][0] = 0.005;
3744  fC[13][1] = 0.005;
3745  fC[13][2] = 1.0000;
3746  fC[13][3] = 0.4486;
3747  fC[13][4] = 0.6799;
3748 
3749  fC[14][0] = 0.005;
3750  fC[14][1] = 0.005;
3751  fC[14][2] = 1.0000;
3752  fC[14][3] = 0.4840;
3753  fC[14][4] = 0.7668;
3754 
3755  fC[15][0] = 0.005;
3756  fC[15][1] = 0.005;
3757  fC[15][2] = 1.0000;
3758  fC[15][3] = 0.4971;
3759  fC[15][4] = 0.8288;
3760 
3761  fC[16][0] = 0.005;
3762  fC[16][1] = 0.005;
3763  fC[16][2] = 1.0000;
3764  fC[16][3] = 0.4956;
3765  fC[16][4] = 0.8653;
3766 
3767  fC[17][0] = 0.005;
3768  fC[17][1] = 0.005;
3769  fC[17][2] = 1.0000;
3770  fC[17][3] = 0.5173;
3771  fC[17][4] = 0.9059;
3772 
3773  for(Int_t i=18;i<fgkPIDptBin;i++){
3774  fC[i][0] = fC[17][0];
3775  fC[i][1] = fC[17][1];
3776  fC[i][2] = fC[17][2];
3777  fC[i][3] = fC[17][3];
3778  fC[i][4] = fC[17][4];
3779  }
3780  }
3781  // 10-20%
3782  else if(centrCur < 20){
3783  fC[0][0] = 0.005;
3784  fC[0][1] = 0.005;
3785  fC[0][2] = 1.0000;
3786  fC[0][3] = 0.0010;
3787  fC[0][4] = 0.0010;
3788 
3789  fC[1][0] = 0.005;
3790  fC[1][1] = 0.005;
3791  fC[1][2] = 1.0000;
3792  fC[1][3] = 0.0132;
3793  fC[1][4] = 0.0088;
3794 
3795  fC[2][0] = 0.005;
3796  fC[2][1] = 0.005;
3797  fC[2][2] = 1.0000;
3798  fC[2][3] = 0.0283;
3799  fC[2][4] = 0.0068;
3800 
3801  fC[3][0] = 0.005;
3802  fC[3][1] = 0.005;
3803  fC[3][2] = 1.0000;
3804  fC[3][3] = 0.0577;
3805  fC[3][4] = 0.0279;
3806 
3807  fC[4][0] = 0.005;
3808  fC[4][1] = 0.005;
3809  fC[4][2] = 1.0000;
3810  fC[4][3] = 0.0884;
3811  fC[4][4] = 0.0534;
3812 
3813  fC[5][0] = 0.005;
3814  fC[5][1] = 0.005;
3815  fC[5][2] = 1.0000;
3816  fC[5][3] = 0.1179;
3817  fC[5][4] = 0.0794;
3818 
3819  fC[6][0] = 0.005;
3820  fC[6][1] = 0.005;
3821  fC[6][2] = 1.0000;
3822  fC[6][3] = 0.1480;
3823  fC[6][4] = 0.1058;
3824 
3825  fC[7][0] = 0.005;
3826  fC[7][1] = 0.005;
3827  fC[7][2] = 1.0000;
3828  fC[7][3] = 0.1807;
3829  fC[7][4] = 0.1366;
3830 
3831  fC[8][0] = 0.005;
3832  fC[8][1] = 0.005;
3833  fC[8][2] = 1.0000;
3834  fC[8][3] = 0.2219;
3835  fC[8][4] = 0.1891;
3836 
3837  fC[9][0] = 0.005;
3838  fC[9][1] = 0.005;
3839  fC[9][2] = 1.0000;
3840  fC[9][3] = 0.2804;
3841  fC[9][4] = 0.2730;
3842 
3843  fC[10][0] = 0.005;
3844  fC[10][1] = 0.005;
3845  fC[10][2] = 1.0000;
3846  fC[10][3] = 0.3283;
3847  fC[10][4] = 0.3660;
3848 
3849  fC[11][0] = 0.005;
3850  fC[11][1] = 0.005;
3851  fC[11][2] = 1.0000;
3852  fC[11][3] = 0.3710;
3853  fC[11][4] = 0.4647;
3854 
3855  fC[12][0] = 0.005;
3856  fC[12][1] = 0.005;
3857  fC[12][2] = 1.0000;
3858  fC[12][3] = 0.4093;
3859  fC[12][4] = 0.5566;
3860 
3861  fC[13][0] = 0.005;
3862  fC[13][1] = 0.005;
3863  fC[13][2] = 1.0000;
3864  fC[13][3] = 0.4302;
3865  fC[13][4] = 0.6410;
3866 
3867  fC[14][0] = 0.005;
3868  fC[14][1] = 0.005;
3869  fC[14][2] = 1.0000;
3870  fC[14][3] = 0.4649;
3871  fC[14][4] = 0.7055;
3872 
3873  fC[15][0] = 0.005;
3874  fC[15][1] = 0.005;
3875  fC[15][2] = 1.0000;
3876  fC[15][3] = 0.4523;
3877  fC[15][4] = 0.7440;
3878 
3879  fC[16][0] = 0.005;
3880  fC[16][1] = 0.005;
3881  fC[16][2] = 1.0000;
3882  fC[16][3] = 0.4591;
3883  fC[16][4] = 0.7799;
3884 
3885  fC[17][0] = 0.005;
3886  fC[17][1] = 0.005;
3887  fC[17][2] = 1.0000;
3888  fC[17][3] = 0.4804;
3889  fC[17][4] = 0.8218;
3890 
3891  for(Int_t i=18;i<fgkPIDptBin;i++){
3892  fC[i][0] = fC[17][0];
3893  fC[i][1] = fC[17][1];
3894  fC[i][2] = fC[17][2];
3895  fC[i][3] = fC[17][3];
3896  fC[i][4] = fC[17][4];
3897  }
3898  }
3899  // 20-30%
3900  else if(centrCur < 30){
3901  fC[0][0] = 0.005;
3902  fC[0][1] = 0.005;
3903  fC[0][2] = 1.0000;
3904  fC[0][3] = 0.0010;
3905  fC[0][4] = 0.0010;
3906 
3907  fC[1][0] = 0.005;
3908  fC[1][1] = 0.005;
3909  fC[1][2] = 1.0000;
3910  fC[1][3] = 0.0102;
3911  fC[1][4] = 0.0064;
3912 
3913  fC[2][0] = 0.005;
3914  fC[2][1] = 0.005;
3915  fC[2][2] = 1.0000;
3916  fC[2][3] = 0.0292;
3917  fC[2][4] = 0.0066;
3918 
3919  fC[3][0] = 0.005;
3920  fC[3][1] = 0.005;
3921  fC[3][2] = 1.0000;
3922  fC[3][3] = 0.0597;
3923  fC[3][4] = 0.0296;
3924 
3925  fC[4][0] = 0.005;
3926  fC[4][1] = 0.005;
3927  fC[4][2] = 1.0000;
3928  fC[4][3] = 0.0900;
3929  fC[4][4] = 0.0589;
3930 
3931  fC[5][0] = 0.005;
3932  fC[5][1] = 0.005;
3933  fC[5][2] = 1.0000;
3934  fC[5][3] = 0.1199;
3935  fC[5][4] = 0.0859;
3936 
3937  fC[6][0] = 0.005;
3938  fC[6][1] = 0.005;
3939  fC[6][2] = 1.0000;
3940  fC[6][3] = 0.1505;
3941  fC[6][4] = 0.1141;
3942 
3943  fC[7][0] = 0.005;
3944  fC[7][1] = 0.005;
3945  fC[7][2] = 1.0000;
3946  fC[7][3] = 0.1805;
3947  fC[7][4] = 0.1454;
3948 
3949  fC[8][0] = 0.005;
3950  fC[8][1] = 0.005;
3951  fC[8][2] = 1.0000;
3952  fC[8][3] = 0.2221;
3953  fC[8][4] = 0.2004;
3954 
3955  fC[9][0] = 0.005;
3956  fC[9][1] = 0.005;
3957  fC[9][2] = 1.0000;
3958  fC[9][3] = 0.2796;
3959  fC[9][4] = 0.2838;
3960 
3961  fC[10][0] = 0.005;
3962  fC[10][1] = 0.005;
3963  fC[10][2] = 1.0000;
3964  fC[10][3] = 0.3271;
3965  fC[10][4] = 0.3682;
3966 
3967  fC[11][0] = 0.005;
3968  fC[11][1] = 0.005;
3969  fC[11][2] = 1.0000;
3970  fC[11][3] = 0.3648;
3971  fC[11][4] = 0.4509;
3972 
3973  fC[12][0] = 0.005;
3974  fC[12][1] = 0.005;
3975  fC[12][2] = 1.0000;
3976  fC[12][3] = 0.3988;
3977  fC[12][4] = 0.5339;
3978 
3979  fC[13][0] = 0.005;
3980  fC[13][1] = 0.005;
3981  fC[13][2] = 1.0000;
3982  fC[13][3] = 0.4315;
3983  fC[13][4] = 0.5995;
3984 
3985  fC[14][0] = 0.005;
3986  fC[14][1] = 0.005;
3987  fC[14][2] = 1.0000;
3988  fC[14][3] = 0.4548;
3989  fC[14][4] = 0.6612;
3990 
3991  fC[15][0] = 0.005;
3992  fC[15][1] = 0.005;
3993  fC[15][2] = 1.0000;
3994  fC[15][3] = 0.4744;
3995  fC[15][4] = 0.7060;
3996 
3997  fC[16][0] = 0.005;
3998  fC[16][1] = 0.005;
3999  fC[16][2] = 1.0000;
4000  fC[16][3] = 0.4899;
4001  fC[16][4] = 0.7388;
4002 
4003  fC[17][0] = 0.005;
4004  fC[17][1] = 0.005;
4005  fC[17][2] = 1.0000;
4006  fC[17][3] = 0.4411;
4007  fC[17][4] = 0.7293;
4008 
4009  for(Int_t i=18;i<fgkPIDptBin;i++){
4010  fC[i][0] = fC[17][0];
4011  fC[i][1] = fC[17][1];
4012  fC[i][2] = fC[17][2];
4013  fC[i][3] = fC[17][3];
4014  fC[i][4] = fC[17][4];
4015  }
4016  }
4017  // 30-40%
4018  else if(centrCur < 40){
4019  fC[0][0] = 0.005;
4020  fC[0][1] = 0.005;
4021  fC[0][2] = 1.0000;
4022  fC[0][3] = 0.0010;
4023  fC[0][4] = 0.0010;
4024 
4025  fC[1][0] = 0.005;
4026  fC[1][1] = 0.005;
4027  fC[1][2] = 1.0000;
4028  fC[1][3] = 0.0102;
4029  fC[1][4] = 0.0048;
4030 
4031  fC[2][0] = 0.005;
4032  fC[2][1] = 0.005;
4033  fC[2][2] = 1.0000;
4034  fC[2][3] = 0.0306;
4035  fC[2][4] = 0.0079;
4036 
4037  fC[3][0] = 0.005;
4038  fC[3][1] = 0.005;
4039  fC[3][2] = 1.0000;
4040  fC[3][3] = 0.0617;
4041  fC[3][4] = 0.0338;
4042 
4043  fC[4][0] = 0.005;
4044  fC[4][1] = 0.005;
4045  fC[4][2] = 1.0000;
4046  fC[4][3] = 0.0920;
4047  fC[4][4] = 0.0652;
4048 
4049  fC[5][0] = 0.005;
4050  fC[5][1] = 0.005;
4051  fC[5][2] = 1.0000;
4052  fC[5][3] = 0.1211;
4053  fC[5][4] = 0.0955;
4054 
4055  fC[6][0] = 0.005;
4056  fC[6][1] = 0.005;
4057  fC[6][2] = 1.0000;
4058  fC[6][3] = 0.1496;
4059  fC[6][4] = 0.1242;
4060 
4061  fC[7][0] = 0.005;
4062  fC[7][1] = 0.005;
4063  fC[7][2] = 1.0000;
4064  fC[7][3] = 0.1807;
4065  fC[7][4] = 0.1576;
4066 
4067  fC[8][0] = 0.005;
4068  fC[8][1] = 0.005;
4069  fC[8][2] = 1.0000;
4070  fC[8][3] = 0.2195;
4071  fC[8][4] = 0.2097;
4072 
4073  fC[9][0] = 0.005;
4074  fC[9][1] = 0.005;
4075  fC[9][2] = 1.0000;
4076  fC[9][3] = 0.2732;
4077  fC[9][4] = 0.2884;
4078 
4079  fC[10][0] = 0.005;
4080  fC[10][1] = 0.005;
4081  fC[10][2] = 1.0000;
4082  fC[10][3] = 0.3204;
4083  fC[10][4] = 0.3679;
4084 
4085  fC[11][0] = 0.005;
4086  fC[11][1] = 0.005;
4087  fC[11][2] = 1.0000;
4088  fC[11][3] = 0.3564;
4089  fC[11][4] = 0.4449;
4090 
4091  fC[12][0] = 0.005;
4092  fC[12][1] = 0.005;
4093  fC[12][2] = 1.0000;
4094  fC[12][3] = 0.3791;
4095  fC[12][4] = 0.5052;
4096 
4097  fC[13][0] = 0.005;
4098  fC[13][1] = 0.005;
4099  fC[13][2] = 1.0000;
4100  fC[13][3] = 0.4062;
4101  fC[13][4] = 0.5647;
4102 
4103  fC[14][0] = 0.005;
4104  fC[14][1] = 0.005;
4105  fC[14][2] = 1.0000;
4106  fC[14][3] = 0.4234;
4107  fC[14][4] = 0.6203;
4108 
4109  fC[15][0] = 0.005;
4110  fC[15][1] = 0.005;
4111  fC[15][2] = 1.0000;
4112  fC[15][3] = 0.4441;
4113  fC[15][4] = 0.6381;
4114 
4115  fC[16][0] = 0.005;
4116  fC[16][1] = 0.005;
4117  fC[16][2] = 1.0000;
4118  fC[16][3] = 0.4629;
4119  fC[16][4] = 0.6496;
4120 
4121  fC[17][0] = 0.005;
4122  fC[17][1] = 0.005;
4123  fC[17][2] = 1.0000;
4124  fC[17][3] = 0.4293;
4125  fC[17][4] = 0.6491;
4126 
4127  for(Int_t i=18;i<fgkPIDptBin;i++){
4128  fC[i][0] = fC[17][0];
4129  fC[i][1] = fC[17][1];
4130  fC[i][2] = fC[17][2];
4131  fC[i][3] = fC[17][3];
4132  fC[i][4] = fC[17][4];
4133  }
4134  }
4135  // 40-50%
4136  else if(centrCur < 50){
4137  fC[0][0] = 0.005;
4138  fC[0][1] = 0.005;
4139  fC[0][2] = 1.0000;
4140  fC[0][3] = 0.0010;
4141  fC[0][4] = 0.0010;
4142 
4143  fC[1][0] = 0.005;
4144  fC[1][1] = 0.005;
4145  fC[1][2] = 1.0000;
4146  fC[1][3] = 0.0093;
4147  fC[1][4] = 0.0057;
4148 
4149  fC[2][0] = 0.005;
4150  fC[2][1] = 0.005;
4151  fC[2][2] = 1.0000;
4152  fC[2][3] = 0.0319;
4153  fC[2][4] = 0.0075;
4154 
4155  fC[3][0] = 0.005;
4156  fC[3][1] = 0.005;
4157  fC[3][2] = 1.0000;
4158  fC[3][3] = 0.0639;
4159  fC[3][4] = 0.0371;
4160 
4161  fC[4][0] = 0.005;
4162  fC[4][1] = 0.005;
4163  fC[4][2] = 1.0000;
4164  fC[4][3] = 0.0939;
4165  fC[4][4] = 0.0725;
4166 
4167  fC[5][0] = 0.005;
4168  fC[5][1] = 0.005;
4169  fC[5][2] = 1.0000;
4170  fC[5][3] = 0.1224;
4171  fC[5][4] = 0.1045;
4172 
4173  fC[6][0] = 0.005;
4174  fC[6][1] = 0.005;
4175  fC[6][2] = 1.0000;
4176  fC[6][3] = 0.1520;
4177  fC[6][4] = 0.1387;
4178 
4179  fC[7][0] = 0.005;
4180  fC[7][1] = 0.005;
4181  fC[7][2] = 1.0000;
4182  fC[7][3] = 0.1783;
4183  fC[7][4] = 0.1711;
4184 
4185  fC[8][0] = 0.005;
4186  fC[8][1] = 0.005;
4187  fC[8][2] = 1.0000;
4188  fC[8][3] = 0.2202;
4189  fC[8][4] = 0.2269;
4190 
4191  fC[9][0] = 0.005;
4192  fC[9][1] = 0.005;
4193  fC[9][2] = 1.0000;
4194  fC[9][3] = 0.2672;
4195  fC[9][4] = 0.2955;
4196 
4197  fC[10][0] = 0.005;
4198  fC[10][1] = 0.005;
4199  fC[10][2] = 1.0000;
4200  fC[10][3] = 0.3191;
4201  fC[10][4] = 0.3676;
4202 
4203  fC[11][0] = 0.005;
4204  fC[11][1] = 0.005;
4205  fC[11][2] = 1.0000;
4206  fC[11][3] = 0.3434;
4207  fC[11][4] = 0.4321;
4208 
4209  fC[12][0] = 0.005;
4210  fC[12][1] = 0.005;
4211  fC[12][2] = 1.0000;
4212  fC[12][3] = 0.3692;
4213  fC[12][4] = 0.4879;
4214 
4215  fC[13][0] = 0.005;
4216  fC[13][1] = 0.005;
4217  fC[13][2] = 1.0000;
4218  fC[13][3] = 0.3993;
4219  fC[13][4] = 0.5377;
4220 
4221  fC[14][0] = 0.005;
4222  fC[14][1] = 0.005;
4223  fC[14][2] = 1.0000;
4224  fC[14][3] = 0.3818;
4225  fC[14][4] = 0.5547;
4226 
4227  fC[15][0] = 0.005;
4228  fC[15][1] = 0.005;
4229  fC[15][2] = 1.0000;
4230  fC[15][3] = 0.4003;
4231  fC[15][4] = 0.5484;
4232 
4233  fC[16][0] = 0.005;
4234  fC[16][1] = 0.005;
4235  fC[16][2] = 1.0000;
4236  fC[16][3] = 0.4281;
4237  fC[16][4] = 0.5383;
4238 
4239  fC[17][0] = 0.005;
4240  fC[17][1] = 0.005;
4241  fC[17][2] = 1.0000;
4242  fC[17][3] = 0.3960;
4243  fC[17][4] = 0.5374;
4244 
4245  for(Int_t i=18;i<fgkPIDptBin;i++){
4246  fC[i][0] = fC[17][0];
4247  fC[i][1] = fC[17][1];
4248  fC[i][2] = fC[17][2];
4249  fC[i][3] = fC[17][3];
4250  fC[i][4] = fC[17][4];
4251  }
4252  }
4253  // 50-60%
4254  else if(centrCur < 60){
4255  fC[0][0] = 0.005;
4256  fC[0][1] = 0.005;
4257  fC[0][2] = 1.0000;
4258  fC[0][3] = 0.0010;
4259  fC[0][4] = 0.0010;
4260 
4261  fC[1][0] = 0.005;
4262  fC[1][1] = 0.005;
4263  fC[1][2] = 1.0000;
4264  fC[1][3] = 0.0076;
4265  fC[1][4] = 0.0032;
4266 
4267  fC[2][0] = 0.005;
4268  fC[2][1] = 0.005;
4269  fC[2][2] = 1.0000;
4270  fC[2][3] = 0.0329;
4271  fC[2][4] = 0.0085;
4272 
4273  fC[3][0] = 0.005;
4274  fC[3][1] = 0.005;
4275  fC[3][2] = 1.0000;
4276  fC[3][3] = 0.0653;
4277  fC[3][4] = 0.0423;
4278 
4279  fC[4][0] = 0.005;
4280  fC[4][1] = 0.005;
4281  fC[4][2] = 1.0000;
4282  fC[4][3] = 0.0923;
4283  fC[4][4] = 0.0813;
4284 
4285  fC[5][0] = 0.005;
4286  fC[5][1] = 0.005;
4287  fC[5][2] = 1.0000;
4288  fC[5][3] = 0.1219;
4289  fC[5][4] = 0.1161;
4290 
4291  fC[6][0] = 0.005;
4292  fC[6][1] = 0.005;
4293  fC[6][2] = 1.0000;
4294  fC[6][3] = 0.1519;
4295  fC[6][4] = 0.1520;
4296 
4297  fC[7][0] = 0.005;
4298  fC[7][1] = 0.005;
4299  fC[7][2] = 1.0000;
4300  fC[7][3] = 0.1763;
4301  fC[7][4] = 0.1858;
4302 
4303  fC[8][0] = 0.005;
4304  fC[8][1] = 0.005;
4305  fC[8][2] = 1.0000;
4306  fC[8][3] = 0.2178;
4307  fC[8][4] = 0.2385;
4308 
4309  fC[9][0] = 0.005;
4310  fC[9][1] = 0.005;
4311  fC[9][2] = 1.0000;
4312  fC[9][3] = 0.2618;
4313  fC[9][4] = 0.3070;
4314 
4315  fC[10][0] = 0.005;
4316  fC[10][1] = 0.005;
4317  fC[10][2] = 1.0000;
4318  fC[10][3] = 0.3067;
4319  fC[10][4] = 0.3625;
4320 
4321  fC[11][0] = 0.005;
4322  fC[11][1] = 0.005;
4323  fC[11][2] = 1.0000;
4324  fC[11][3] = 0.3336;
4325  fC[11][4] = 0.4188;
4326 
4327  fC[12][0] = 0.005;
4328  fC[12][1] = 0.005;
4329  fC[12][2] = 1.0000;
4330  fC[12][3] = 0.3706;
4331  fC[12][4] = 0.4511;
4332 
4333  fC[13][0] = 0.005;
4334  fC[13][1] = 0.005;
4335  fC[13][2] = 1.0000;
4336  fC[13][3] = 0.3765;
4337  fC[13][4] = 0.4729;
4338 
4339  fC[14][0] = 0.005;
4340  fC[14][1] = 0.005;
4341  fC[14][2] = 1.0000;
4342  fC[14][3] = 0.3942;
4343  fC[14][4] = 0.4855;
4344 
4345  fC[15][0] = 0.005;
4346  fC[15][1] = 0.005;
4347  fC[15][2] = 1.0000;
4348  fC[15][3] = 0.4051;
4349  fC[15][4] = 0.4762;
4350 
4351  fC[16][0] = 0.005;
4352  fC[16][1] = 0.005;
4353  fC[16][2] = 1.0000;
4354  fC[16][3] = 0.3843;
4355  fC[16][4] = 0.4763;
4356 
4357  fC[17][0] = 0.005;
4358  fC[17][1] = 0.005;
4359  fC[17][2] = 1.0000;
4360  fC[17][3] = 0.4237;
4361  fC[17][4] = 0.4773;
4362 
4363  for(Int_t i=18;i<fgkPIDptBin;i++){
4364  fC[i][0] = fC[17][0];
4365  fC[i][1] = fC[17][1];
4366  fC[i][2] = fC[17][2];
4367  fC[i][3] = fC[17][3];
4368  fC[i][4] = fC[17][4];
4369  }
4370  }
4371  // 60-70%
4372  else if(centrCur < 70){
4373  fC[0][0] = 0.005;
4374  fC[0][1] = 0.005;
4375  fC[0][2] = 1.0000;
4376  fC[0][3] = 0.0010;
4377  fC[0][4] = 0.0010;
4378 
4379  fC[1][0] = 0.005;
4380  fC[1][1] = 0.005;
4381  fC[1][2] = 1.0000;
4382  fC[1][3] = 0.0071;
4383  fC[1][4] = 0.0012;
4384 
4385  fC[2][0] = 0.005;
4386  fC[2][1] = 0.005;
4387  fC[2][2] = 1.0000;
4388  fC[2][3] = 0.0336;
4389  fC[2][4] = 0.0097;
4390 
4391  fC[3][0] = 0.005;
4392  fC[3][1] = 0.005;
4393  fC[3][2] = 1.0000;
4394  fC[3][3] = 0.0662;
4395  fC[3][4] = 0.0460;
4396 
4397  fC[4][0] = 0.005;
4398  fC[4][1] = 0.005;
4399  fC[4][2] = 1.0000;
4400  fC[4][3] = 0.0954;
4401  fC[4][4] = 0.0902;
4402 
4403  fC[5][0] = 0.005;
4404  fC[5][1] = 0.005;
4405  fC[5][2] = 1.0000;
4406  fC[5][3] = 0.1181;
4407  fC[5][4] = 0.1306;
4408 
4409  fC[6][0] = 0.005;
4410  fC[6][1] = 0.005;
4411  fC[6][2] = 1.0000;
4412  fC[6][3] = 0.1481;
4413  fC[6][4] = 0.1662;
4414 
4415  fC[7][0] = 0.005;
4416  fC[7][1] = 0.005;
4417  fC[7][2] = 1.0000;
4418  fC[7][3] = 0.1765;
4419  fC[7][4] = 0.1963;
4420 
4421  fC[8][0] = 0.005;
4422  fC[8][1] = 0.005;
4423  fC[8][2] = 1.0000;
4424  fC[8][3] = 0.2155;
4425  fC[8][4] = 0.2433;
4426 
4427  fC[9][0] = 0.005;
4428  fC[9][1] = 0.005;
4429  fC[9][2] = 1.0000;
4430  fC[9][3] = 0.2580;
4431  fC[9][4] = 0.3022;
4432 
4433  fC[10][0] = 0.005;
4434  fC[10][1] = 0.005;
4435  fC[10][2] = 1.0000;
4436  fC[10][3] = 0.2872;
4437  fC[10][4] = 0.3481;
4438 
4439  fC[11][0] = 0.005;
4440  fC[11][1] = 0.005;
4441  fC[11][2] = 1.0000;
4442  fC[11][3] = 0.3170;
4443  fC[11][4] = 0.3847;
4444 
4445  fC[12][0] = 0.005;
4446  fC[12][1] = 0.005;
4447  fC[12][2] = 1.0000;
4448  fC[12][3] = 0.3454;
4449  fC[12][4] = 0.4258;
4450 
4451  fC[13][0] = 0.005;
4452  fC[13][1] = 0.005;
4453  fC[13][2] = 1.0000;
4454  fC[13][3] = 0.3580;
4455  fC[13][4] = 0.4299;
4456 
4457  fC[14][0] = 0.005;
4458  fC[14][1] = 0.005;
4459  fC[14][2] = 1.0000;
4460  fC[14][3] = 0.3903;
4461  fC[14][4] = 0.4326;
4462 
4463  fC[15][0] = 0.005;
4464  fC[15][1] = 0.005;
4465  fC[15][2] = 1.0000;
4466  fC[15][3] = 0.3690;
4467  fC[15][4] = 0.4491;
4468 
4469  fC[16][0] = 0.005;
4470  fC[16][1] = 0.005;
4471  fC[16][2] = 1.0000;
4472  fC[16][3] = 0.4716;
4473  fC[16][4] = 0.4298;
4474 
4475  fC[17][0] = 0.005;
4476&#