From 20ca0114f143e130e33bef1ff383dfda0ff65c65 Mon Sep 17 00:00:00 2001 From: Preet Pati Date: Mon, 23 Nov 2026 11:17:33 +0100 Subject: [PATCH 1/3] Addition of MCPID and PIDQA to flowPbPbpiKp --- PWGCF/Flow/Tasks/flowPbpbPikp.cxx | 1755 ++++++++++++++++++----------- 1 file changed, 1124 insertions(+), 631 deletions(-) diff --git a/PWGCF/Flow/Tasks/flowPbpbPikp.cxx b/PWGCF/Flow/Tasks/flowPbpbPikp.cxx index 312e01a7f61..3eab96b93ad 100644 --- a/PWGCF/Flow/Tasks/flowPbpbPikp.cxx +++ b/PWGCF/Flow/Tasks/flowPbpbPikp.cxx @@ -20,6 +20,7 @@ #include "Common/CCDB/EventSelectionParams.h" #include "Common/CCDB/TriggerAliases.h" +#include "Common/Core/RecoDecay.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" @@ -47,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -69,7 +71,7 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -using namespace std; +using namespace constants::math; #define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; @@ -81,157 +83,295 @@ GFWCorrConfigs configs; using namespace o2::analysis::genericframework; +template +auto readMatrix(Array2D const& mat, P& array) +{ + for (auto i = 0; i < static_cast(mat.rows); ++i) { + for (auto j = 0; j < static_cast(mat.cols); ++j) { + array[i][j] = mat(i, j); + } + } + + return; +} + +static constexpr std::array, 20> LongArrayFloat = {{{{1.1, 2.1, 3.1}}, {{1.2, 2.2, 3.2}}, {{1.3, 2.3, 3.3}}, {{-1.1, -2.1, -3.1}}, {{-1.2, -2.2, -3.2}}, {{-1.3, -2.3, -3.3}}, {{1.1, 1.1, 1.1}}, {{1.2, 1.2, 1.2}}, {{1.3, 1.3, 1.3}}, {{-1.1, -1.1, -1.1}}, {{-1.2, -1.2, -1.2}}, {{-1.3, -1.3, -1.3}}, {{1.1, 1.1, 1.1}}, {{1.2, 1.2, 1.2}}, {{1.3, 1.3, 1.3}}, {{-1.1, -1.1, -1.1}}, {{-1.2, -1.2, -1.2}}, {{-1.3, -1.3, -1.3}}, {{1.1, 1.1, 1.1}}, {{1.2, 1.2, 1.2}}}}; +static constexpr std::array, 20> LongArrayInt = {{{{1, 2, 3}}, {{1, 2, 3}}, {{1, 2, 3}}, {{0, 0, 0}}, {{0, 0, 0}}, {{0, 0, 0}}, {{1, 1, 1}}, {{1, 1, 1}}, {{1, 1, 1}}, {{0, 0, 0}}, {{0, 0, 0}}, {{0, 0, 0}}, {{1, 1, 1}}, {{1, 1, 1}}, {{1, 1, 1}}, {{0, 0, 0}}, {{0, 0, 0}}, {{0, 0, 0}}, {{1, 1, 1}}, {{1, 1, 1}}}}; + struct FlowPbpbPikp { o2::aod::ITSResponse itsResponse; Service ccdb; - Configurable noLaterThan{"noLaterThan", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; - Configurable ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - - O2_DEFINE_CONFIGURABLE(cfgCutVertex, float, 10.0f, "Accepted z-vertex range") - O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMin, float, 0.2f, "Minimal pT for poi tracks") - O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMax, float, 10.0f, "Maximal pT for poi tracks") - O2_DEFINE_CONFIGURABLE(cfgCutPtMin, float, 0.2f, "Minimal pT for ref tracks") - O2_DEFINE_CONFIGURABLE(cfgCutPtMax, float, 3.0f, "Maximal pT for ref tracks") - O2_DEFINE_CONFIGURABLE(cfgCutEta, float, 0.8f, "Eta range for tracks") - O2_DEFINE_CONFIGURABLE(cfgTpcCluster, int, 70, "Number of TPC clusters") - O2_DEFINE_CONFIGURABLE(cfgTpcCrossRows, int, 70, "Number of TPC clusters") - O2_DEFINE_CONFIGURABLE(cfgCutChi2prTPCcls, float, 2.5, "Chi2 per TPC clusters") - O2_DEFINE_CONFIGURABLE(cfgNbootstrap, int, 10, "Number of subsamples") - O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeights, bool, true, "Fill and output NUA weights") - O2_DEFINE_CONFIGURABLE(cfgOutputRunByRun, bool, true, "Fill and output NUA weights run by run") - O2_DEFINE_CONFIGURABLE(cfgEfficiency, std::string, "", "CCDB path to efficiency object") - O2_DEFINE_CONFIGURABLE(cfgAcceptance, std::string, "", "CCDB path to acceptance object") - O2_DEFINE_CONFIGURABLE(cfgTpcCut, float, 2.0f, "TPC N-sigma cut for pions, kaons, protons") - O2_DEFINE_CONFIGURABLE(cfgTofPtCut, float, 0.5f, "Minimum pt to use TOF N-sigma") - O2_DEFINE_CONFIGURABLE(cfgCutDCAxy, float, 2.0f, "DCAxy range for tracks") - O2_DEFINE_CONFIGURABLE(cfgCutDCAz, float, 2.0f, "DCAz range for tracks") - - O2_DEFINE_CONFIGURABLE(cfgCutOccupancyMin, int, 0, "Minimum occupancy cut") - O2_DEFINE_CONFIGURABLE(cfgCutOccupancyMax, int, 2000, "Maximum occupancy cut") - O2_DEFINE_CONFIGURABLE(cfgUseGlobalTrack, bool, true, "use Global track") - O2_DEFINE_CONFIGURABLE(cfgITScluster, int, 5, "Number of ITS cluster") - O2_DEFINE_CONFIGURABLE(cfgTrackDensityCorrUse, bool, false, "Use track density efficiency correction") - - O2_DEFINE_CONFIGURABLE(cfgUseWeightPhiEtaVtxz, bool, false, "Use Phi, Eta, VertexZ dependent NUA weights") - O2_DEFINE_CONFIGURABLE(cfgUseWeightPhiPtCent, bool, false, "Use Phi, Pt, Centrality dependent NUA weights") - O2_DEFINE_CONFIGURABLE(cfgUseWeightPhiEtaPt, bool, true, "Use Phi, Eta, Pt dependent NUA weights") - O2_DEFINE_CONFIGURABLE(cfgUseStrictPID, bool, true, "Use strict PID cuts for TPC") - O2_DEFINE_CONFIGURABLE(cfgV0AT0Acut, int, 5, "V0AT0A cut") - O2_DEFINE_CONFIGURABLE(cfgUseAsymmetricPID, bool, false, "Use asymmetric PID cuts") - O2_DEFINE_CONFIGURABLE(cfgUseItsPID, bool, true, "Use ITS PID for particle identification") - O2_DEFINE_CONFIGURABLE(cfgUseNch, bool, true, "Use Nch for multiplicity selection instead of centrality") - - Configurable> cfgTrackDensityP0{"cfgTrackDensityP0", std::vector{0.7217476707, 0.7384792571, 0.7542625668, 0.7640680200, 0.7701951667, 0.7755299053, 0.7805901710, 0.7849446786, 0.7957356586, 0.8113039262, 0.8211968966, 0.8280558878, 0.8329342135}, "parameter 0 for track density efficiency correction"}; - Configurable> cfgTrackDensityP1{"cfgTrackDensityP1", std::vector{-2.169488e-05, -2.191913e-05, -2.295484e-05, -2.556538e-05, -2.754463e-05, -2.816832e-05, -2.846502e-05, -2.843857e-05, -2.705974e-05, -2.477018e-05, -2.321730e-05, -2.203315e-05, -2.109474e-05}, "parameter 1 for track density efficiency correction"}; - Configurable> cfgTofNsigmaCut{"cfgTofNsigmaCut", std::vector{1.5, 1.5, 1.5, -1.5, -1.5, -1.5}, "TOF n-sigma cut for pions_posNsigma, kaons_posNsigma, protons_posNsigma, pions_negNsigma, kaons_negNsigma, protons_negNsigma"}; - Configurable> cfgItsNsigmaCut{"cfgItsNsigmaCut", std::vector{3, 3, 3, -3, -3, -3}, "ITS n-sigma cut for pions_posNsigma, kaons_posNsigma, protons_posNsigma, pions_negNsigma, kaons_negNsigma, protons_negNsigma"}; - Configurable> cfgTpcNsigmaCut{"cfgTpcNsigmaCut", std::vector{10, 10, 10, -10, -10, -10}, "TOF n-sigma cut for pions_posNsigma, kaons_posNsigma, protons_posNsigma, pions_negNsigma, kaons_negNsigma, protons_negNsigma"}; - Configurable> cfgUseEventCuts{"cfgUseEventCuts", std::vector{1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0}, "Switch for various event cuts [Filtered Events, Sel8, kNoTimeFrameBorder, kNoITSROFrameBorder, kNoSameBunchPileup, kIsGoodZvtxFT0vsPV, kNoCollInTimeRangeStandard, kIsGoodITSLayersAll, kNoCollInRofStandard, kNoHighMultCollInPrevRof, Occupancy, Multiplicity correlation, T0AV0A 3 sigma cut, kIsVertexITSTPC, kTVXinTRD]"}; - - Configurable cfgRegions{"cfgRegions", {{"refN08", "refP08", "full", "poiN", "olN", "poiP", "olP", "poi", "ol", "poiNpi", "olNpi", "poiPpi", "olPpi", "poifullpi", "olfullpi", "poiNka", "olNka", "poiPka", "olPka", "poifullka", "olfullka", "poiNpr", "olNpr", "poiPpr", "olPpr", "poifullpr", "olfullpr"}, {-0.8, 0.4, -0.8, -0.8, -0.8, 0.4, 0.4, -0.8, -0.8, -0.8, -0.8, 0.4, 0.4, -0.8, -0.8, -0.8, -0.8, 0.4, 0.4, -0.8, -0.8, -0.8, -0.8, 0.4, 0.4, -0.8, -0.8}, {-0.4, 0.8, 0.8, -0.4, -0.4, 0.8, 0.8, 0.8, 0.8, -0.4, -0.4, 0.8, 0.8, 0.8, 0.8, -0.4, -0.4, 0.8, 0.8, 0.8, 0.8, -0.4, -0.4, 0.8, 0.8, 0.8, 0.8}, {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 128, 256, 128, 256, 128, 256, 2, 16, 2, 16, 2, 16, 4, 32, 4, 32, 4, 32, 8, 64, 8, 64, 8, 64}}, "Configurations for GFW regions"}; - Configurable cfgCorrConfig{"cfgCorrConfig", {{"full {2 -2}", "full {2 -2}", "full {2 -2}", "full {2 -2}", "refN08 {2} refP08 {-2}", "refN08 {2} refP08 {-2}", "refN08 {2} refP08 {-2}", "refN08 {2} refP08 {-2}", "refP08 {-2} refN08 {2}", "refP08 {-2} refN08 {2}", "refP08 {-2} refN08 {2}", "refP08 {-2} refN08 {2}", "full {2 2 -2 -2}", "full {2 2 -2 -2}", "full {2 2 -2 -2}", "full {2 2 -2 -2}", "poi full | ol {2 -2}", "poifullpi full | olfullpi {2 -2}", "poifullka full | olfullka {2 -2}", "poifullpr full | olfullpr {2 -2}", "poiN refN08 | olN {2} refP08 {-2}", "poiNpi refN08 | olNpi {2} refP08 {-2}", "poiNka refN08 | olNka {2} refP08 {-2}", "poiNpr refN08 | olNpr {2} refP08 {-2}", "poiP refP08 | olP {2} refN08 {-2}", "poiPpi refP08 | olPpi {2} refN08 {-2}", "poiPka refP08 | olPka {2} refN08 {-2}", "poiPpr refP08 | olPpr {2} refN08 {-2}", "poi full | ol {2 2 -2 -2}", "poifullpi full | olfullpi {2 2 -2 -2}", "poifullka full | olfullka {2 2 -2 -2}", "poifullpr full | olfullpr {2 2 -2 -2}", "refN08 {2 2} refP08 {-2 -2}", "refP08 {-2 -2} refN08 {2 2}", "poiNka refN08 | olNka {2 2} refP08 {-2 -2}", "poiPka refP08 | olPka {2 2} refN08 {-2 -2}"}, {"ChFull22", "PiFull22", "KaFull22", "PrFull22", "Ch08FGap22", "Pi08FGap22", "Ka08FGap22", "Pr08FGap22", "Ch08BGap22", "Pi08BGap22", "Ka08BGap22", "Pr08BGap22", "ChFull24", "PiFull24", "KaFull24", "PrFull24", "ChFull22", "PiFull22", "KaFull22", "PrFull22", "Ch08FGap22", "Pi08FGap22", "Ka08FGap22", "Pr08FGap22", "Ch08BGap22", "Pi08BGap22", "Ka08BGap22", "Pr08BGap22", "ChFull24", "PiFull24", "KaFull24", "PrFull24", "Ka08FGap24", "Ka08BGap24", "Ka08FGap24", "Ka08BGap24"}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, "Configurations for each correlation to calculate"}; + struct : ConfigurableGroup { + std::string prefix = "GeneralConfigs"; + O2_DEFINE_CONFIGURABLE(cfgQABasic, bool, true, "Enable QA histograms for event and track selection") + O2_DEFINE_CONFIGURABLE(cfgRefPtMin, float, 0.2f, "Minimal pT for ref tracks") + O2_DEFINE_CONFIGURABLE(cfgRefPtMax, float, 3.0f, "Maximal pT for ref tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMin, float, 0.2f, "Minimal pT for poi tracks") + O2_DEFINE_CONFIGURABLE(cfgCutPtPOIMax, float, 10.0f, "Maximal pT for poi tracks") + O2_DEFINE_CONFIGURABLE(cfgNbootstrap, int, 10, "Number of subsamples") + O2_DEFINE_CONFIGURABLE(cfgStrictTrackCounter, bool, false, "Strict track counter for multiplicity correlation cut, counts only tracks that pass all cuts and are used in the correlation") + } GeneralConfigs; + + struct : ConfigurableGroup { + std::string prefix = "Weights"; + O2_DEFINE_CONFIGURABLE(cfgEfficiency, std::string, "", "CCDB path to efficiency object") + O2_DEFINE_CONFIGURABLE(cfgAcceptance, std::string, "", "CCDB path to acceptance object") + O2_DEFINE_CONFIGURABLE(cfgOutputNUAWeights, bool, true, "Fill and output NUA weights") + O2_DEFINE_CONFIGURABLE(cfgOutputRunByRun, bool, true, "Fill and output NUA weights run by run") + O2_DEFINE_CONFIGURABLE(cfgUseWeightPhiEtaVtxz, bool, false, "Use Phi, Eta, VertexZ dependent NUA weights") + O2_DEFINE_CONFIGURABLE(cfgUseWeightPhiPtCent, bool, false, "Use Phi, Pt, Centrality dependent NUA weights") + O2_DEFINE_CONFIGURABLE(cfgUseWeightPhiEtaPt, bool, true, "Use Phi, Eta, Pt dependent NUA weights") + } Weights; + + struct : ConfigurableGroup { + std::string prefix = "EvSels"; + O2_DEFINE_CONFIGURABLE(cfgGlobalCutVertex, float, 10.0f, "Accepted z-vertex range") + O2_DEFINE_CONFIGURABLE(cfgCutOccupancyMax, int, 2000, "Maximum occupancy cut") + O2_DEFINE_CONFIGURABLE(cfgCutOccupancyMin, int, 0, "Minimum occupancy cut") + O2_DEFINE_CONFIGURABLE(cfgUseNch, bool, true, "Use Nch for analysis instead of centrality") + O2_DEFINE_CONFIGURABLE(cfgCentEstimator, int, 0, "0:FT0C; 1:FT0CVariant1; 2:FT0M; 3:FV0A") + O2_DEFINE_CONFIGURABLE(cfgCentTableUnavailable, bool, false, "if a dataset does not provide centrality information") + Configurable> cfgUseEventCuts{"cfgUseEventCuts", {LongArrayInt.front().data(), 14, 1, {"Filtered Events", "Sel8", "kNoTimeFrameBorder", "kNoITSROFrameBorder", "kNoSameBunchPileup", "kIsGoodZvtxFT0vsPV", "kNoCollInTimeRangeStandard", "kIsGoodITSLayersAll", "kIsGoodITSLayer0123", "kNoCollInRofStandard", "kNoHighMultCollInPrevRof", "Occupancy", "Multcorrelation", "T0AV0ACut"}, {"EvCuts"}}, "Labeled array (int) for various cuts on resonances"}; + } EvSels; + + struct : ConfigurableGroup { + std::string prefix = "TrkSels"; + O2_DEFINE_CONFIGURABLE(cfgGlobalPtMin, float, 0.2f, "minimum accepted track pT") + O2_DEFINE_CONFIGURABLE(cfgGlobalPtMax, float, 10.0f, "maximum accepted track pT") + O2_DEFINE_CONFIGURABLE(cfgGlobalEta, float, 0.8f, "Eta cut") + O2_DEFINE_CONFIGURABLE(cfgGlobalChi2prTPCcls, float, 2.5f, "Maximum chi2 per TPC clusters") + O2_DEFINE_CONFIGURABLE(cfgGlobalDCAz, float, 2.0f, "Maximum DCA to vertex z") + Configurable> cfgTrackCutsDCAxy{"cfgTrackCutsDCAxy", std::vector{"[0]*(0.0026+0.005/(x^1.01))", "[0]*(0.0026+0.005/(x^1.01))"}, "Functional form of pt-dependent DCAxy cut"}; + Configurable> cfgTrackCutsDCAz{"cfgTrackCutsDCAz", std::vector{"", ""}, "Functional form of pt-dependent DCAz cut"}; + Configurable> cfgTrackCuts{"cfgTrackCuts", {LongArrayFloat.front().data(), 10, 2, {"PtMin", "PtMax", "EtaCut", "Chi2PrTpcCls", "TpcCluster", "TpcCrossedRows", "ItsCluster", "DCAz", "DCAzNsigma", "DCAxyNsigma"}, {"General", "SelNch"}}, "Labeled array for track selections"}; + } TrkSels; + + struct : ConfigurableGroup { + std::string prefix = "PIDConfigs"; + O2_DEFINE_CONFIGURABLE(cfgQANsigma, bool, false, "Get QA histograms for PID Nsigma") + O2_DEFINE_CONFIGURABLE(cfgQAdEdx, bool, false, "Get QA histograms for PID (TpcdEdx, ExpTpc, ExpSigma) vs TOF Nsigma") + O2_DEFINE_CONFIGURABLE(cfgQABetadEdx, bool, false, "Get QA histograms for TpcdEdx vs TofBeta") + O2_DEFINE_CONFIGURABLE(cfgPIDTofPtCut, float, 0.4f, "Minimum pt to use TOF N-sigma") + O2_DEFINE_CONFIGURABLE(cfgPIDUseIts, bool, false, "Use ITS PID for particle identification") + O2_DEFINE_CONFIGURABLE(cfgPIDUseRejection, bool, true, "True: use exclusion exclusion criteria for PID determination, false: don't use exclusion") + O2_DEFINE_CONFIGURABLE(cfgPIDNclsPIDCut, int, 70, "Number of clusters used for PID selection") + O2_DEFINE_CONFIGURABLE(cfgPIDUseNclsPID, bool, false, "Switch for using cfgPIDNclsPIDCut") + Configurable> cfgPIDnSigmas{"cfgPIDnSigmas", {LongArrayFloat.front().data(), 6, 3, {"UpCut_pi", "UpCut_ka", "UpCut_pr", "LowCut_pi", "LowCut_ka", "LowCut_pr"}, {"TPC", "TOF", "ITS"}}, "Labeled array for n-sigma values for TPC, TOF, ITS for pions, kaons, protons (positive and negative)"}; + } PIDConfigs; + + struct : ConfigurableGroup { + std::string prefix = "FuncParas"; + O2_DEFINE_CONFIGURABLE(cfgMultCentHighCutFunction, std::string, "[0] + [1]*x + [2]*x*x + [3]*x*x*x + [4]*x*x*x*x + 10.*([5] + [6]*x + [7]*x*x + [8]*x*x*x + [9]*x*x*x*x)", "Functional for multiplicity correlation cut"); + O2_DEFINE_CONFIGURABLE(cfgMultCentLowCutFunction, std::string, "[0] + [1]*x + [2]*x*x + [3]*x*x*x + [4]*x*x*x*x - 3.*([5] + [6]*x + [7]*x*x + [8]*x*x*x + [9]*x*x*x*x)", "Functional for multiplicity correlation cut"); + O2_DEFINE_CONFIGURABLE(cfgMultT0CCutEnabled, bool, false, "Enable Global multiplicity vs T0C centrality cut") + Configurable> cfgMultT0CCutPars{"cfgMultT0CCutPars", std::vector{143.04, -4.58368, 0.0766055, -0.000727796, 2.86153e-06, 23.3108, -0.36304, 0.00437706, -4.717e-05, 1.98332e-07}, "Global multiplicity vs T0C centrality cut parameter values"}; + O2_DEFINE_CONFIGURABLE(cfgMultPVT0CCutEnabled, bool, false, "Enable PV multiplicity vs T0C centrality cut") + Configurable> cfgMultPVT0CCutPars{"cfgMultPVT0CCutPars", std::vector{195.357, -6.15194, 0.101313, -0.000955828, 3.74793e-06, 30.0326, -0.43322, 0.00476265, -5.11206e-05, 2.13613e-07}, "PV multiplicity vs T0C centrality cut parameter values"}; + O2_DEFINE_CONFIGURABLE(cfgMultMultPVHighCutFunction, std::string, "[0]+[1]*x + 5.*([2]+[3]*x)", "Functional for multiplicity correlation cut"); + O2_DEFINE_CONFIGURABLE(cfgMultMultPVLowCutFunction, std::string, "[0]+[1]*x - 5.*([2]+[3]*x)", "Functional for multiplicity correlation cut"); + O2_DEFINE_CONFIGURABLE(cfgMultGlobalPVCutEnabled, bool, false, "Enable global multiplicity vs PV multiplicity cut") + Configurable> cfgMultGlobalPVCutPars{"cfgMultGlobalPVCutPars", std::vector{-0.140809, 0.734344, 2.77495, 0.0165935}, "PV multiplicity vs T0C centrality cut parameter values"}; + O2_DEFINE_CONFIGURABLE(cfgMultMultV0AHighCutFunction, std::string, "[0] + [1]*x + [2]*x*x + [3]*x*x*x + [4]*x*x*x*x + 4.*([5] + [6]*x + [7]*x*x + [8]*x*x*x + [9]*x*x*x*x)", "Functional for multiplicity correlation cut"); + O2_DEFINE_CONFIGURABLE(cfgMultMultV0ALowCutFunction, std::string, "[0] + [1]*x + [2]*x*x + [3]*x*x*x + [4]*x*x*x*x - 3.*([5] + [6]*x + [7]*x*x + [8]*x*x*x + [9]*x*x*x*x)", "Functional for multiplicity correlation cut"); + O2_DEFINE_CONFIGURABLE(cfgMultMultV0ACutEnabled, bool, false, "Enable global multiplicity vs V0A multiplicity cut") + Configurable> cfgMultMultV0ACutPars{"cfgMultMultV0ACutPars", std::vector{534.893, 184.344, 0.423539, -0.00331436, 5.34622e-06, 871.239, 53.3735, -0.203528, 0.000122758, 5.41027e-07}, "Global multiplicity vs V0A multiplicity cut parameter values"}; + std::vector multT0CCutPars; + std::vector multPVT0CCutPars; + std::vector multGlobalPVCutPars; + std::vector multMultV0ACutPars; + std::unique_ptr fMultPVT0CCutLow = nullptr; + std::unique_ptr fMultPVT0CCutHigh = nullptr; + std::unique_ptr fMultT0CCutLow = nullptr; + std::unique_ptr fMultT0CCutHigh = nullptr; + std::unique_ptr fMultGlobalPVCutLow = nullptr; + std::unique_ptr fMultGlobalPVCutHigh = nullptr; + std::unique_ptr fMultMultV0ACutLow = nullptr; + std::unique_ptr fMultMultV0ACutHigh = nullptr; + std::unique_ptr fT0AV0AMean = nullptr; + std::unique_ptr fT0AV0ASigma = nullptr; + std::unique_ptr fPtDepDCAxy = nullptr; + std::unique_ptr fPtDepDCAxyForNch = nullptr; + std::unique_ptr fPtDepDCAz = nullptr; + std::unique_ptr fPtDepDCAzForNch = nullptr; + O2_DEFINE_CONFIGURABLE(cfgV0AT0Acut, int, 5, "V0AT0A cut") + } FuncParas; + + struct : ConfigurableGroup { + std::string prefix = "TrkDensCorr"; + O2_DEFINE_CONFIGURABLE(cfgTrackDensityCorrUse, bool, false, "Use track density efficiency correction") + Configurable> cfgTrackDensityP0{"cfgTrackDensityP0", std::vector{0.7217476707, 0.7384792571, 0.7542625668, 0.7640680200, 0.7701951667, 0.7755299053, 0.7805901710, 0.7849446786, 0.7957356586, 0.8113039262, 0.8211968966, 0.8280558878, 0.8329342135}, "parameter 0 for track density efficiency correction"}; + Configurable> cfgTrackDensityP1{"cfgTrackDensityP1", std::vector{-2.169488e-05, -2.191913e-05, -2.295484e-05, -2.556538e-05, -2.754463e-05, -2.816832e-05, -2.846502e-05, -2.843857e-05, -2.705974e-05, -2.477018e-05, -2.321730e-05, -2.203315e-05, -2.109474e-05}, "parameter 1 for track density efficiency correction"}; + } TrkDensCorr; + + Configurable cfgRegions{"cfgRegions", {{"refN08", "refP08", "full"}, {-0.8, 0.4, -0.8}, {-0.4, 0.8, 0.8}, {0, 0, 0}, {1, 1, 1}}, "Configurations for GFW regions (Name, minEta, maxEta, pT-diff, BitMask)"}; + Configurable cfgCorrConfig{"cfgCorrConfig", {{"full {2 -2}", "full {2 -2}", "full {2 -2}"}, {"ChFull22", "PiFull22", "KaFull22"}, {0, 0, 0}, {0, 0, 0}}, "Configurations for each correlation to calculate"}; + + // Axes for general QA ConfigurableAxis axisVertex{"axisVertex", {20, -10, 10}, "vertex axis for histograms"}; ConfigurableAxis axisPhi{"axisPhi", {60, 0.0, constants::math::TwoPI}, "phi axis for histograms"}; ConfigurableAxis axisEta{"axisEta", {16, -0.8, 0.8}, "eta axis for histograms"}; - ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1.00, 1.20, 1.40, 1.60, 1.80, 2.00, 2.20, 2.40, 2.60, 2.80, 3.00, 3.50, 4.00, 5.00, 6.00, 8.00, 10.00}, "pt axis for histograms"}; - ConfigurableAxis axisMultiplicity{"axisMultiplicity", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90}, "centrality axis for histograms"}; + ConfigurableAxis axisPtForQA{"axisPtForQA", {98, 0.2, 10.0}, "pt axis for QA histograms"}; + ConfigurableAxis axisMultForQA{"axisMultForQA", {100, 0, 1000}, "multiplicity axis for QA histograms"}; + ConfigurableAxis axisAllParticles{"axisAllParticles", {4, -0.5, 3.5}, "particle axis for general QA (ch, pi, ka, pr)"}; + + // Axes for correlations + ConfigurableAxis axisMultForCorr{"axisMultForCorr", {VARIABLE_WIDTH, 0, 5, 10, 20, 50, 100, 150, 200, 300, 500}, "multiplicity axis for correlation histograms"}; + ConfigurableAxis axisCentForCorr{"axisCentForCorr", {VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90}, "centrality axis for correlation histograms"}; + ConfigurableAxis axisPtForCorr{"axisPtForCorr", {VARIABLE_WIDTH, 0.2, 0.5, 1, 1.5, 2, 3, 4, 6, 10}, "pt trigger axis for correlation histograms"}; + + // Axes for PID QA ConfigurableAxis axisNsigmaTPC{"axisNsigmaTPC", {80, -5, 5}, "nsigmaTPC axis"}; ConfigurableAxis axisNsigmaTOF{"axisNsigmaTOF", {80, -5, 5}, "nsigmaTOF axis"}; ConfigurableAxis axisNsigmaITS{"axisNsigmaITS", {80, -5, 5}, "nsigmaITS axis"}; - ConfigurableAxis axisParticles{"axisParticles", {3, 0, 3}, "axis for different hadrons"}; - ConfigurableAxis axisTPCsignal{"axisTPCsignal", {10000, 0, 1000}, "axis for TPC signal"}; - ConfigurableAxis axisTOFbeta{"axisTOFbeta", {200, 0, 2}, "axis for TOF beta"}; - ConfigurableAxis axisNch{"axisNch", {200, 2000, 4000}, "N_{ch}"}; + ConfigurableAxis axisTpcSignal{"axisTpcSignal", {250, 0, 250}, "dEdx axis for TPC"}; + ConfigurableAxis axisTofBeta{"axisTofBeta", {200, 0, 2}, "axis for TOF beta"}; + ConfigurableAxis axisSigma{"axisSigma", {200, 0, 20}, "sigma axis for TPC"}; + ConfigurableAxis axisPIDParticles{"axisPIDParticles", {3, 0.5, 3.5}, "particle axis for PID QA (pi, ka, pr)"}; - std::vector tofNsigmaCut; - std::vector itsNsigmaCut; - std::vector tpcNsigmaCut; - std::vector eventCuts; + Filter collisionFilter = (nabs(aod::collision::posZ) < EvSels.cfgGlobalCutVertex); + Filter trackFilter = (nabs(aod::track::eta) < TrkSels.cfgGlobalEta) && (aod::track::pt > TrkSels.cfgGlobalPtMin) && (aod::track::pt < TrkSels.cfgGlobalPtMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t)true)) && (aod::track::tpcChi2NCl < TrkSels.cfgGlobalChi2prTPCcls) && (nabs(aod::track::dcaZ) < TrkSels.cfgGlobalDCAz); - Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; - Filter trackFilter = (nabs(aod::track::dcaXY) < cfgCutDCAxy) && (nabs(aod::track::dcaZ) < cfgCutDCAz) && (nabs(aod::track::eta) < cfgCutEta) && (aod::track::pt > cfgCutPtPOIMin) && (aod::track::pt < cfgCutPtPOIMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == static_cast(true))) && (aod::track::tpcChi2NCl < cfgCutChi2prTPCcls); - - using AodCollisions = soa::Filtered>; + using AodCollisions = soa::Filtered>; using AodTracksWithoutBayes = soa::Filtered>; + using AodTracksMcLabels = soa::Filtered>; - OutputObj fFC{FlowContainer("FlowContainer")}; + // OutputObj fFC{FlowContainer("FlowContainer")}; + OutputObj fFC{"FlowContainer"}; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - GFW* fGFW = new GFW(); - std::vector corrconfigs; - TAxis* fPtAxis; - TRandom3* fRndm = new TRandom3(0); - std::map>> th3sList; + + // Generic framework intializations + std::unique_ptr fGFW{std::make_unique()}; + std::vector corrConfigs; + TAxis* fPtAxis = nullptr; + + // Initializer for random number + TRandom3* fRandom = new TRandom3(0); + + // Enum definitions enum OutputSpecies { - hRef = 0, - hCharge, - hPion, - hKaon, - hProton, - kCount_OutputSpecies + UseCharged = 0, + UsePions, + UseKaons, + UseProtons, + UseRef, + NumCountTypes + }; + + enum PiKpArrayIndex { + IndexPionUp = 0, + IndexKaonUp, + IndexProtonUp, + IndexPionLow, + IndexKaonLow, + IndexProtonLow }; enum EventCutTypes { - kFilteredEvents = 0, - kAfterSel8, - kUseNoTimeFrameBorder, - kUseNoITSROFrameBorder, - kUseNoSameBunchPileup, - kUseGoodZvtxFT0vsPV, - kUseNoCollInTimeRangeStandard, - kUseGoodITSLayersAll, - kUseNoCollInRofStandard, - kUseNoHighMultCollInPrevRof, - kUseOccupancy, - kUseMultCorrCut, - kUseT0AV0ACut, - kUseVertexITSTPC, - kUseTVXinTRD + FilteredEvents = 0, + AfterSel8, + UseNoTimeFrameBorder, + UseNoITSROFrameBorder, + UseNoSameBunchPileup, + UseGoodZvtxFT0vsPV, + UseNoCollInTimeRangeStandard, + UseGoodITSLayersAll, + UseGoodITSLayer0123, + UseNoCollInRofStandard, + UseNoHighMultCollInPrevRof, + UseOccupancy, + UseMultCorrCut, + UseT0AV0ACut, + NumEventCuts + }; + + enum TrackCuts { + TrkCutPtMin = 0, + TrkCutPtMax, + TrkCutEta, + TrkCutChi2PrTpcCls, + TrkCutTpcCluster, + TrkCutTpcCrossedRows, + TrkCutItsCluster, + TrkCutDCAz, + TrkCutDCAzNsigma, + TrkCutDCAxyNsigma }; - enum TrackCutTypes { - kFilteredTracks = 0, - kUseGlobalTracks, - kUsePvContributor, - kItsClustersCut, - kHasTpcSignal, - kTpcClustersCut, - kTpcCrossedRowsCut, - kNumPions, - kNumKaons, - kNumProtons + enum FillTrackCuts { + FillFilteredTrks = 1, + FillCutPt, + FillCutEta, + FillCutChi2PrTpcCls, + FillCutTpcCluster, + FillCutTpcCrossedRows, + FillCutItsCluster, + FillCutDCAz, + FillCutDCAxy }; + enum TrackCutGroup { + UseGenTrkCuts = 0, + UseNchSelCuts, + NumTrackCutTypes + }; + enum CentEstimators { + UseCentFT0C = 0, + UseCentFT0CVariant1, + UseCentFT0M, + UseCentFV0A, + NumCentEstimators + }; + enum DetectorType { + UseTPC = 0, + UseTOF, + UseITS + }; + enum EventCutType { + EvCut1 = 0, + NumEvCutTypes = 1 + }; + enum Stage { + Before = 0, + After + }; + + // Vectors for labelled arrays + std::array, 10> trackCuts{}; + std::array, 14> eventCuts{}; + std::array, 6> nSigmaVals{}; + + // For run by run analysis int lastRunNumer = -1; std::vector runNumbers; std::vector mAcceptance; bool correctionsLoaded = false; + TH1D* mEfficiency = nullptr; + // Local track density correction - Copy from flowTask.cxx std::vector funcEff; - TH1D* hFindPtBin; - TF1* funcV2; - TF1* funcV3; - TF1* funcV4; - - // Additional Event selection cuts - Copy from flowGenericFramework.cxx - TF1* fMultPVCutLow = nullptr; - TF1* fMultPVCutHigh = nullptr; - TF1* fMultCutLow = nullptr; - TF1* fMultCutHigh = nullptr; - TF1* fMultMultPVCut = nullptr; - TF1* fT0AV0AMean = nullptr; - TF1* fT0AV0ASigma = nullptr; + TH1D* hFindPtBin = nullptr; + TF1* funcV2 = nullptr; + TF1* funcV3 = nullptr; + TF1* funcV4 = nullptr; void init(InitContext const&) { - eventCuts = cfgUseEventCuts; + readMatrix(TrkSels.cfgTrackCuts->getData(), trackCuts); + readMatrix(EvSels.cfgUseEventCuts->getData(), eventCuts); + readMatrix(PIDConfigs.cfgPIDnSigmas->getData(), nSigmaVals); - ccdb->setURL(ccdbUrl.value); + if (EvSels.cfgCentTableUnavailable && !EvSels.cfgUseNch) { + LOGF(fatal, "Centrality table is unavailable, cannot select collisions by centrality"); + } + + ccdb->setURL("http://alice-ccdb.cern.ch"); ccdb->setCaching(true); - ccdb->setCreatedNotAfter(noLaterThan.value); + auto now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + ccdb->setCreatedNotAfter(now); LOGF(info, "flowGenericFramework::init()"); regions.SetNames(cfgRegions->GetNames()); @@ -246,158 +386,238 @@ struct FlowPbpbPikp { regions.Print(); configs.Print(); - const AxisSpec axisCentForQA{100, 0, 100, "centrality (%)"}; - - histos.add("hVtxZ", "", {HistType::kTH1D, {axisVertex}}); - histos.add("hMult", "", {HistType::kTH1D, {{3000, 0.5, 3000.5}}}); - histos.add("hCent", "", {HistType::kTH1D, {{90, 0, 90}}}); - histos.add("hPhi", "", {HistType::kTH1D, {axisPhi}}); - histos.add("hPhiWeighted", "", {HistType::kTH1D, {axisPhi}}); - histos.add("hEta", "", {HistType::kTH1D, {axisEta}}); - histos.add("hPt", "", {HistType::kTH1D, {axisPt}}); - histos.add("c22_full_ch", "", {HistType::kTProfile, {axisMultiplicity}}); - histos.add("c22_full_ch_Nch", "", {HistType::kTProfile, {axisNch}}); - - histos.add("TpcdEdx", "", {HistType::kTH2D, {axisPt, axisTPCsignal}}); - histos.add("TofBeta", "", {HistType::kTH2D, {axisPt, axisTOFbeta}}); - - histos.add("globalTracks_centT0C", "after cut;Centrality T0C;mulplicity global tracks", {HistType::kTH2D, {axisCentForQA, axisNch}}); - - histos.add("TofTpcNsigma_before", "", {HistType::kTHnSparseD, {{axisParticles, axisNsigmaTPC, axisNsigmaTOF, axisPt}}}); - if (!cfgUseItsPID) - histos.add("TofTpcNsigma_after", "", {HistType::kTHnSparseD, {{axisParticles, axisNsigmaTPC, axisNsigmaTOF, axisPt}}}); - - histos.add("TofItsNsigma_before", "", {HistType::kTHnSparseD, {{axisParticles, axisNsigmaITS, axisNsigmaTOF, axisPt}}}); - if (cfgUseItsPID) - histos.add("TofItsNsigma_after", "", {HistType::kTHnSparseD, {{axisParticles, axisNsigmaITS, axisNsigmaTOF, axisPt}}}); - - histos.add("partCount", "", {HistType::kTHnSparseD, {{axisParticles, axisMultiplicity, axisPt}}}); - - histos.add("hEventCount", "Number of Events;; Count", {HistType::kTH1D, {{15, -0.5, 14.5}}}); - histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kFilteredEvents + 1, "Filtered event"); - histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kAfterSel8 + 1, "After sel8"); - histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseNoTimeFrameBorder + 1, "kNoTimeFrameBorder"); - histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseNoITSROFrameBorder + 1, "kNoITSROFrameBorder"); - histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseNoSameBunchPileup + 1, "kNoSameBunchPileup"); - histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseGoodZvtxFT0vsPV + 1, "kIsGoodZvtxFT0vsPV"); - histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseNoCollInRofStandard + 1, "kNoCollInTimeRangeStandard"); - histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseGoodITSLayersAll + 1, "kIsGoodITSLayersAll"); - histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseNoCollInRofStandard + 1, "kNoCollInRofStandard"); - histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseNoHighMultCollInPrevRof + 1, "kNoHighMultCollInPrevRof"); - histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseOccupancy + 1, "Occupancy Cut"); - histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseMultCorrCut + 1, "Multiplicity correlation Cut"); - histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseT0AV0ACut + 1, "T0AV0A cut"); - histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseVertexITSTPC + 1, "kIsVertexITSTPC"); - histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(kUseTVXinTRD + 1, "kTVXinTRD"); - - histos.add("hTrackCount", "Number of Tracks;; Count", {HistType::kTH1D, {{10, -0.5, 9.5}}}); - histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kFilteredTracks + 1, "Filtered track"); - histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kUseGlobalTracks + 1, "Global tracks"); - histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kUsePvContributor + 1, "PV contributor"); - histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kItsClustersCut + 1, "ITS clusters"); - histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kHasTpcSignal + 1, "TPC signal"); - histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kTpcClustersCut + 1, "TPC clusters"); - histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kTpcCrossedRowsCut + 1, "TPC crossed rows"); - histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kNumPions + 1, "Pions"); - histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kNumKaons + 1, "Kaons"); - histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(kNumProtons + 1, "Protons"); - - if (cfgOutputNUAWeights && !cfgOutputRunByRun) { - histos.add("NUA/hPhiEtaVtxz_ref", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); - histos.add("NUA/hPhiEtaVtxz_ch", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); - histos.add("NUA/hPhiEtaVtxz_pi", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); - histos.add("NUA/hPhiEtaVtxz_ka", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); - histos.add("NUA/hPhiEtaVtxz_pr", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); - - histos.add("NUA/hPhiPtCent_ref", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPt, axisMultiplicity}}); - histos.add("NUA/hPhiPtCent_ch", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPt, axisMultiplicity}}); - histos.add("NUA/hPhiPtCent_pi", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPt, axisMultiplicity}}); - histos.add("NUA/hPhiPtCent_ka", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPt, axisMultiplicity}}); - histos.add("NUA/hPhiPtCent_pr", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPt, axisMultiplicity}}); - - histos.add("NUA/hPhiEtaPt_ref", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPt}}); - histos.add("NUA/hPhiEtaPt_ch", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPt}}); - histos.add("NUA/hPhiEtaPt_pi", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPt}}); - histos.add("NUA/hPhiEtaPt_ka", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPt}}); - histos.add("NUA/hPhiEtaPt_pr", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPt}}); - } - - if (!cfgAcceptance.value.empty()) { - if (cfgUseWeightPhiEtaVtxz) { - histos.add("PhiCorrected/hPhiEtaVtxz_pi_corrd", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); - histos.add("PhiCorrected/hPhiEtaVtxz_ka_corrd", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); - histos.add("PhiCorrected/hPhiEtaVtxz_pr_corrd", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + // Axis definitions + std::string hCentTitle = "Centrality distribution, Estimator " + std::to_string(EvSels.cfgCentEstimator); + const AxisSpec axisCentForQA{100, 0, 100, "Centrality (%)"}; + AxisSpec axisEventClass = {(EvSels.cfgUseNch) ? axisMultForCorr : axisCentForCorr}; + + histos.add("hEventCount", "Number of Events;; Count", {HistType::kTH1D, {{14, -0.5, 13.5}}}); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(FilteredEvents + 1, "Filtered events"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(AfterSel8 + 1, "After sel8"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(UseNoTimeFrameBorder + 1, "kNoTimeFrameBorder"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(UseNoITSROFrameBorder + 1, "kNoITSROFrameBorder"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(UseNoSameBunchPileup + 1, "kNoSameBunchPileup"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(UseGoodZvtxFT0vsPV + 1, "kIsGoodZvtxFT0vsPV"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(UseNoCollInTimeRangeStandard + 1, "kNoCollInTimeRangeStandard"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(UseGoodITSLayersAll + 1, "kIsGoodITSLayersAll"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(UseGoodITSLayer0123 + 1, "kIsGoodITSLayer0123"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(UseNoCollInRofStandard + 1, "kNoCollInRofStandard"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(UseNoHighMultCollInPrevRof + 1, "kNoHighMultCollInPrevRof"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(UseOccupancy + 1, "Occupancy Cut"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(UseMultCorrCut + 1, "MultCorrelation Cut"); + histos.get(HIST("hEventCount"))->GetXaxis()->SetBinLabel(UseT0AV0ACut + 1, "T0AV0A cut"); + + histos.add("hTrackCount", "Number of Tracks;; Count", {HistType::kTH1D, {{9, -0.5, 8.5}}}); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(FillFilteredTrks, "Filtered track"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(FillCutPt, "p_{T} Cut"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(FillCutEta, "#eta Cut"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(FillCutChi2PrTpcCls, "#chi^2/nTpcCls Cut"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(FillCutTpcCluster, "TPC Clusters"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(FillCutTpcCrossedRows, "TPC Crossed Rows"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(FillCutItsCluster, "ITS Clusters"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(FillCutDCAz, "DCAz Cut"); + histos.get(HIST("hTrackCount"))->GetXaxis()->SetBinLabel(FillCutDCAxy, "DCAxy Cut"); + + if (doprocessGFW) { + if (Weights.cfgOutputNUAWeights && !Weights.cfgOutputRunByRun) { + histos.add("NUA/hPhiEtaVtxz_ref", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + histos.add("NUA/hPhiEtaVtxz_ch", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + histos.add("NUA/hPhiEtaVtxz_pi", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + histos.add("NUA/hPhiEtaVtxz_ka", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + histos.add("NUA/hPhiEtaVtxz_pr", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + + histos.add("NUA/hPhiPtCent_ref", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPtForCorr, axisCentForCorr}}); + histos.add("NUA/hPhiPtCent_ch", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPtForCorr, axisCentForCorr}}); + histos.add("NUA/hPhiPtCent_pi", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPtForCorr, axisCentForCorr}}); + histos.add("NUA/hPhiPtCent_ka", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPtForCorr, axisCentForCorr}}); + histos.add("NUA/hPhiPtCent_pr", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPtForCorr, axisCentForCorr}}); + + histos.add("NUA/hPhiEtaPt_ref", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPtForCorr}}); + histos.add("NUA/hPhiEtaPt_ch", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPtForCorr}}); + histos.add("NUA/hPhiEtaPt_pi", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPtForCorr}}); + histos.add("NUA/hPhiEtaPt_ka", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPtForCorr}}); + histos.add("NUA/hPhiEtaPt_pr", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPtForCorr}}); + } // end of output weight histograms condition + if (!Weights.cfgAcceptance.value.empty()) { + if (Weights.cfgUseWeightPhiEtaVtxz) { + histos.add("PhiCorrected/hPhiEtaVtxz_pi_corrd", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + histos.add("PhiCorrected/hPhiEtaVtxz_ka_corrd", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + histos.add("PhiCorrected/hPhiEtaVtxz_pr_corrd", ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + } + if (Weights.cfgUseWeightPhiPtCent) { + histos.add("PhiCorrected/hPhiPtCent_pi_corrd", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPtForCorr, axisCentForCorr}}); + histos.add("PhiCorrected/hPhiPtCent_ka_corrd", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPtForCorr, axisCentForCorr}}); + histos.add("PhiCorrected/hPhiPtCent_pr_corrd", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPtForCorr, axisCentForCorr}}); + } + if (Weights.cfgUseWeightPhiEtaPt) { + histos.add("PhiCorrected/hPhiEtaPt_pi_corrd", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPtForCorr}}); + histos.add("PhiCorrected/hPhiEtaPt_ka_corrd", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPtForCorr}}); + histos.add("PhiCorrected/hPhiEtaPt_pr_corrd", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPtForCorr}}); + } + } // end of acceptance corrected phi histograms condition + + if (GeneralConfigs.cfgQABasic) { + histos.add("hPhi", "#phi", {HistType::kTH2D, {axisPhi, axisAllParticles}}); + histos.add("hPhiWeighted", "#phi Corrected", {HistType::kTH2D, {axisPhi, axisAllParticles}}); + histos.add("hEta", "#eta", {HistType::kTH2D, {axisEta, axisAllParticles}}); + histos.add("hEtaCorrected", "#eta Corrected", {HistType::kTH2D, {axisEta, axisAllParticles}}); + histos.add("hPt", "p_{T}", {HistType::kTHnSparseF, {axisPtForQA, axisAllParticles, axisEventClass}}); + histos.add("hPtCorrected", "p_{T} Corrected", {HistType::kTHnSparseF, {axisPtForQA, axisAllParticles, axisEventClass}}); + } + + histos.add("hNch", "", {HistType::kTH1D, {axisMultForQA}}); + histos.add("hNchCorrected", "", {HistType::kTH1D, {axisMultForQA}}); + histos.add("hCent", hCentTitle.c_str(), {HistType::kTH1D, {axisCentForQA}}); + histos.add("hVtxZ", "", {HistType::kTH1D, {axisVertex}}); + + o2::framework::AxisSpec axis = axisPtForCorr; + int nPtBins = axis.binEdges.size() - 1; + double* ptBins = &(axis.binEdges)[0]; + fPtAxis = new TAxis(nPtBins, ptBins); + + // Iniitializing object for GFW + auto* oba = new TObjArray(); + + // Defining the regions + for (auto i(0); i < regions.GetSize(); i++) { + fGFW->AddRegion(regions.GetNames().at(i), regions.GetEtaMin().at(i), regions.GetEtaMax().at(i), (regions.GetpTDifs().at(i)) ? nPtBins + 1 : 1, regions.GetBitmasks().at(i)); } - if (cfgUseWeightPhiPtCent) { - histos.add("PhiCorrected/hPhiPtCent_pi_corrd", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPt, axisMultiplicity}}); - histos.add("PhiCorrected/hPhiPtCent_ka_corrd", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPt, axisMultiplicity}}); - histos.add("PhiCorrected/hPhiPtCent_pr_corrd", ";#varphi;p_{T};Cent", {HistType::kTH3D, {axisPhi, axisPt, axisMultiplicity}}); + + // Defining the correlators + std::string suffix = "_ptDiff"; + for (auto i = 0; i < configs.GetSize(); i++) { + corrConfigs.push_back(fGFW->GetCorrelatorConfig(configs.GetCorrs().at(i), configs.GetHeads().at(i), configs.GetpTDifs().at(i))); + if (configs.GetpTDifs().at(i) != 0) { + for (auto j = 1; j <= nPtBins; j++) { + std::string index = Form("_pt_%i", j); + oba->Add(new TNamed(configs.GetHeads().at(i) + index, configs.GetHeads().at(i) + suffix)); + std::string corrName = configs.GetHeads().at(i) + index; + LOGF(info, Form("Correlator to be calculated: %s", corrName.c_str())); + } + } else { + oba->Add(new TNamed(configs.GetHeads().at(i), configs.GetHeads().at(i))); + LOGF(info, Form("Correlator to be calculated: %s", configs.GetHeads().at(i).c_str())); + } } - if (cfgUseWeightPhiEtaPt) { - histos.add("PhiCorrected/hPhiEtaPt_pi_corrd", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPt}}); - histos.add("PhiCorrected/hPhiEtaPt_ka_corrd", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPt}}); - histos.add("PhiCorrected/hPhiEtaPt_pr_corrd", ";#varphi;#eta;p_{T}", {HistType::kTH3D, {axisPhi, axisEta, axisPt}}); + if (corrConfigs.empty()) { + LOGF(error, "Configuration contains vectors of different size - check the GFWCorrConfig configurable"); } - } + fGFW->CreateRegions(); - o2::framework::AxisSpec axis = axisPt; - int nPtBins = axis.binEdges.size() - 1; - double* ptBins = &(axis.binEdges)[0]; - fPtAxis = new TAxis(nPtBins, ptBins); + fFC.setObject(new FlowContainer("FlowContainer")); + fFC->SetXAxis(fPtAxis); + fFC->Initialize(oba, axisEventClass, GeneralConfigs.cfgNbootstrap); - // Defining the regions - for (auto i(0); i < regions.GetSize(); ++i) { - fGFW->AddRegion(regions.GetNames()[i], regions.GetEtaMin()[i], regions.GetEtaMax()[i], (regions.GetpTDifs()[i]) ? nPtBins + 1 : 1, regions.GetBitmasks()[i]); - } + delete oba; + } // end of doprocessGFW - // Defining the correlators - for (auto i = 0; i < configs.GetSize(); ++i) { - corrconfigs.push_back(fGFW->GetCorrelatorConfig(configs.GetCorrs()[i], configs.GetHeads()[i], configs.GetpTDifs()[i])); + if (doprocessGFW || doprocessPIDQA || doprocessMCPID) { + if (PIDConfigs.cfgQANsigma) { + if (!PIDConfigs.cfgPIDUseIts) { // TPC-TOF PID QA hists + histos.add("TofTpcNsigma_beforeCut", "", {HistType::kTHnSparseD, {{axisNsigmaTPC, axisNsigmaTOF, axisEventClass, axisPtForCorr, axisPIDParticles}}}); + histos.add("TofTpcNsigma_afterCut", "", {HistType::kTHnSparseD, {{axisNsigmaTPC, axisNsigmaTOF, axisEventClass, axisPtForCorr, axisPIDParticles}}}); + } + if (PIDConfigs.cfgPIDUseIts) { // ITS-TOF PID QA hists + histos.add("TofItsNsigma_beforeCut", "", {HistType::kTHnSparseD, {{axisNsigmaITS, axisNsigmaTOF, axisEventClass, axisPtForCorr, axisPIDParticles}}}); + histos.add("TofItsNsigma_afterCut", "", {HistType::kTHnSparseD, {{axisNsigmaITS, axisNsigmaTOF, axisEventClass, axisPtForCorr, axisPIDParticles}}}); + } + } // end of PID nsigma QA hists } - if (corrconfigs.empty()) - LOGF(error, "Configuration contains vectors of different size - check the GFWCorrConfig configurable"); - fGFW->CreateRegions(); - // Defining the flow container - TObjArray* oba = new TObjArray(); - addConfigObjectsToObjArray(oba, corrconfigs); + if (doprocessPIDQA) { + if (PIDConfigs.cfgQAdEdx) { + histos.add("TpcdEdx_beforeCut", "", {HistType::kTHnSparseD, {{axisTpcSignal, axisNsigmaTOF, axisEventClass, axisPtForCorr, axisPIDParticles}}}); + histos.add("ExpTpcdEdx_beforeCut", "", {HistType::kTHnSparseD, {{axisTpcSignal, axisNsigmaTOF, axisEventClass, axisPtForCorr, axisPIDParticles}}}); + histos.add("ExpSigma_beforeCut", "", {HistType::kTHnSparseD, {{axisSigma, axisNsigmaTOF, axisEventClass, axisPtForCorr, axisPIDParticles}}}); + + histos.add("TpcdEdx_afterCut", "", {HistType::kTHnSparseD, {{axisTpcSignal, axisNsigmaTOF, axisEventClass, axisPtForCorr, axisPIDParticles}}}); + histos.add("ExpTpcdEdx_afterCut", "", {HistType::kTHnSparseD, {{axisTpcSignal, axisNsigmaTOF, axisEventClass, axisPtForCorr, axisPIDParticles}}}); + histos.add("ExpSigma_afterCut", "", {HistType::kTHnSparseD, {{axisSigma, axisNsigmaTOF, axisEventClass, axisPtForCorr, axisPIDParticles}}}); + } // end of PID dEdx QA hists + + if (PIDConfigs.cfgQABetadEdx) { + histos.add("TpcdEdx_TofBeta_beforeCut", "", {HistType::kTHnSparseD, {{axisTpcSignal, axisTofBeta, axisEventClass, axisPtForCorr, axisPIDParticles}}}); + histos.add("ExpTpcdEdx_TofBeta_beforeCut", "", {HistType::kTHnSparseD, {{axisTpcSignal, axisTofBeta, axisEventClass, axisPtForCorr, axisPIDParticles}}}); + histos.add("ExpSigma_TofBeta_beforeCut", "", {HistType::kTHnSparseD, {{axisSigma, axisTofBeta, axisEventClass, axisPtForCorr, axisPIDParticles}}}); + + histos.add("TpcdEdx_TofBeta_afterCut", "", {HistType::kTHnSparseD, {{axisTpcSignal, axisTofBeta, axisEventClass, axisPtForCorr, axisPIDParticles}}}); + histos.add("ExpTpcdEdx_TofBeta_afterCut", "", {HistType::kTHnSparseD, {{axisTpcSignal, axisTofBeta, axisEventClass, axisPtForCorr, axisPIDParticles}}}); + histos.add("ExpSigma_TofBeta_afterCut", "", {HistType::kTHnSparseD, {{axisSigma, axisTofBeta, axisEventClass, axisPtForCorr, axisPIDParticles}}}); + } + } - fFC->SetName("FlowContainer"); - fFC->SetXAxis(fPtAxis); + if (doprocessMCPID) { + histos.add("hNTruePositives", "hNTruePositives", {HistType::kTHnSparseD, {axisEventClass, axisPtForCorr, axisPIDParticles}}); // Fraction of particles that are correctly identified as the given PID particle + histos.add("hNAllPositives", "hNAllPositives", {HistType::kTHnSparseD, {axisEventClass, axisPtForCorr, axisPIDParticles}}); // Fraction of particles identified as the given PID particle + histos.add("hNAllTrues", "hNAllTrues", {HistType::kTHnSparseD, {axisEventClass, axisPtForCorr, axisPIDParticles}}); // All true PID particles from MC - if (!cfgUseNch) { - fFC->Initialize(oba, axisMultiplicity, cfgNbootstrap); - } else { - fFC->Initialize(oba, axisNch, cfgNbootstrap); + histos.add("TpcdEdx_AllTrues_physprim", "", {HistType::kTHnSparseD, {{axisTpcSignal, axisTofBeta, axisPtForCorr, axisPIDParticles}}}); + histos.add("TpcdEdx_AllPositives_physprim", "", {HistType::kTHnSparseD, {{axisTpcSignal, axisTofBeta, axisPtForCorr, axisPIDParticles}}}); } - delete oba; + // Multiplicity correlation cuts + if (eventCuts[UseMultCorrCut][EvCut1] != 0) { + FuncParas.multT0CCutPars = FuncParas.cfgMultT0CCutPars; + FuncParas.multPVT0CCutPars = FuncParas.cfgMultPVT0CCutPars; + FuncParas.multGlobalPVCutPars = FuncParas.cfgMultGlobalPVCutPars; + FuncParas.multMultV0ACutPars = FuncParas.cfgMultMultV0ACutPars; + + FuncParas.fMultPVT0CCutLow = std::make_unique("fMultPVT0CCutLow", FuncParas.cfgMultCentLowCutFunction->c_str(), 0, 100); + FuncParas.fMultPVT0CCutLow->SetParameters(FuncParas.multPVT0CCutPars.data()); + FuncParas.fMultPVT0CCutHigh = std::make_unique("fMultPVT0CCutHigh", FuncParas.cfgMultCentHighCutFunction->c_str(), 0, 100); + FuncParas.fMultPVT0CCutHigh->SetParameters(FuncParas.multPVT0CCutPars.data()); + + FuncParas.fMultT0CCutLow = std::make_unique("fMultT0CCutLow", FuncParas.cfgMultCentLowCutFunction->c_str(), 0, 100); + FuncParas.fMultT0CCutLow->SetParameters(FuncParas.multT0CCutPars.data()); + FuncParas.fMultT0CCutHigh = std::make_unique("fMultT0CCutHigh", FuncParas.cfgMultCentHighCutFunction->c_str(), 0, 100); + FuncParas.fMultT0CCutHigh->SetParameters(FuncParas.multT0CCutPars.data()); + + FuncParas.fMultGlobalPVCutLow = std::make_unique("fMultGlobalPVCutLow", FuncParas.cfgMultMultPVLowCutFunction->c_str(), 0, 4000); + FuncParas.fMultGlobalPVCutLow->SetParameters(FuncParas.multGlobalPVCutPars.data()); + FuncParas.fMultGlobalPVCutHigh = std::make_unique("fMultGlobalPVCutHigh", FuncParas.cfgMultMultPVHighCutFunction->c_str(), 0, 4000); + FuncParas.fMultGlobalPVCutHigh->SetParameters(FuncParas.multGlobalPVCutPars.data()); + + FuncParas.fMultMultV0ACutLow = std::make_unique("fMultMultV0ACutLow", FuncParas.cfgMultMultV0ALowCutFunction->c_str(), 0, 4000); + FuncParas.fMultMultV0ACutLow->SetParameters(FuncParas.multMultV0ACutPars.data()); + FuncParas.fMultMultV0ACutHigh = std::make_unique("fMultMultV0ACutHigh", FuncParas.cfgMultMultV0AHighCutFunction->c_str(), 0, 4000); + FuncParas.fMultMultV0ACutHigh->SetParameters(FuncParas.multMultV0ACutPars.data()); + } + if (eventCuts[UseT0AV0ACut][EvCut1] != 0) { + FuncParas.fT0AV0AMean = std::make_unique("fT0AV0AMean", "[0]+[1]*x", 0, 200000); + FuncParas.fT0AV0AMean->SetParameters(-1601.0581, 9.417652e-01); + FuncParas.fT0AV0ASigma = std::make_unique("fT0AV0ASigma", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 200000); + FuncParas.fT0AV0ASigma->SetParameters(463.4144, 6.796509e-02, -9.097136e-07, 7.971088e-12, -2.600581e-17); + } - if (eventCuts[kUseMultCorrCut]) { - fMultPVCutLow = new TF1("fMultPVCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x - 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); - fMultPVCutLow->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); - fMultPVCutHigh = new TF1("fMultPVCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x + 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100); - fMultPVCutHigh->SetParameters(3257.29, -121.848, 1.98492, -0.0172128, 6.47528e-05, 154.756, -1.86072, -0.0274713, 0.000633499, -3.37757e-06); + if (!TrkSels.cfgTrackCutsDCAxy.value[UseGenTrkCuts].empty()) { + FuncParas.fPtDepDCAxy = std::make_unique("ptDepDCAxy", TrkSels.cfgTrackCutsDCAxy.value[UseGenTrkCuts].c_str(), 0.001, 1000); + FuncParas.fPtDepDCAxy->SetParameter(0, trackCuts[TrkCutDCAxyNsigma][UseGenTrkCuts]); + LOGF(info, "DCAxy pt-dependence function: %0.1f * %s", trackCuts[TrkCutDCAxyNsigma][UseGenTrkCuts], TrkSels.cfgTrackCutsDCAxy.value[UseGenTrkCuts].c_str()); + } + if (!TrkSels.cfgTrackCutsDCAxy.value[UseNchSelCuts].empty()) { + FuncParas.fPtDepDCAxyForNch = std::make_unique("ptDepDCAxyForNch", TrkSels.cfgTrackCutsDCAxy.value[UseNchSelCuts].c_str(), 0.001, 1000); + FuncParas.fPtDepDCAxyForNch->SetParameter(0, trackCuts[TrkCutDCAxyNsigma][UseNchSelCuts]); + LOGF(info, "DCAxy pt-dependence function for Nch: %0.1f * %s", trackCuts[TrkCutDCAxyNsigma][UseNchSelCuts], TrkSels.cfgTrackCutsDCAxy.value[UseNchSelCuts].c_str()); + } - fMultCutLow = new TF1("fMultCutLow", "[0]+[1]*x+[2]*x*x+[3]*x*x*x - 2.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); - fMultCutLow->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); - fMultCutHigh = new TF1("fMultCutHigh", "[0]+[1]*x+[2]*x*x+[3]*x*x*x + 3.*([4]+[5]*x+[6]*x*x+[7]*x*x*x+[8]*x*x*x*x)", 0, 100); - fMultCutHigh->SetParameters(1654.46, -47.2379, 0.449833, -0.0014125, 150.773, -3.67334, 0.0530503, -0.000614061, 3.15956e-06); + if (!TrkSels.cfgTrackCutsDCAz.value[UseGenTrkCuts].empty()) { + FuncParas.fPtDepDCAz = std::make_unique("ptDepDCAz", TrkSels.cfgTrackCutsDCAz.value[UseGenTrkCuts].c_str(), 0.001, 1000); + FuncParas.fPtDepDCAz->SetParameter(0, trackCuts[TrkCutDCAzNsigma][UseGenTrkCuts]); + LOGF(info, "DCAz pt-dependence function: %0.1f * %s", trackCuts[TrkCutDCAzNsigma][UseGenTrkCuts], TrkSels.cfgTrackCutsDCAz.value[UseGenTrkCuts].c_str()); } - if (eventCuts[kUseT0AV0ACut]) { - fT0AV0AMean = new TF1("fT0AV0AMean", "[0]+[1]*x", 0, 200000); - fT0AV0AMean->SetParameters(-1601.0581, 9.417652e-01); - fT0AV0ASigma = new TF1("fT0AV0ASigma", "[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x", 0, 200000); - fT0AV0ASigma->SetParameters(463.4144, 6.796509e-02, -9.097136e-07, 7.971088e-12, -2.600581e-17); + if (!TrkSels.cfgTrackCutsDCAz.value[UseNchSelCuts].empty()) { + FuncParas.fPtDepDCAzForNch = std::make_unique("ptDepDCAzForNch", TrkSels.cfgTrackCutsDCAz.value[UseNchSelCuts].c_str(), 0.001, 1000); + FuncParas.fPtDepDCAzForNch->SetParameter(0, trackCuts[TrkCutDCAzNsigma][UseNchSelCuts]); + LOGF(info, "DCAz pt-dependence function for Nch: %0.1f * %s", trackCuts[TrkCutDCAzNsigma][UseNchSelCuts], TrkSels.cfgTrackCutsDCAz.value[UseNchSelCuts].c_str()); } - if (cfgTrackDensityCorrUse) { + if (TrkDensCorr.cfgTrackDensityCorrUse) { std::vector pTEffBins = {0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.4, 1.8, 2.2, 2.6, 3.0}; hFindPtBin = new TH1D("hFindPtBin", "hFindPtBin", pTEffBins.size() - 1, &pTEffBins[0]); funcEff.resize(pTEffBins.size() - 1); // LHC24g3 Eff - std::vector f1p0 = cfgTrackDensityP0; - std::vector f1p1 = cfgTrackDensityP1; + std::vector f1p0 = TrkDensCorr.cfgTrackDensityP0; + std::vector f1p1 = TrkDensCorr.cfgTrackDensityP1; for (uint ifunc = 0; ifunc < pTEffBins.size() - 1; ifunc++) { funcEff[ifunc] = new TF1(Form("funcEff%i", ifunc), "[0]+[1]*x", 0, 3000); funcEff[ifunc]->SetParameters(f1p0[ifunc], f1p1[ifunc]); @@ -410,171 +630,142 @@ struct FlowPbpbPikp { funcV4->SetParameters(0.008845, 0.000259668, -3.24435e-06, 4.54837e-08, -6.01825e-10); } - tofNsigmaCut = cfgTofNsigmaCut; - itsNsigmaCut = cfgItsNsigmaCut; - tpcNsigmaCut = cfgTpcNsigmaCut; } // End of init() - enum Particles { - PIONS, - KAONS, - PROTONS - }; - - void addConfigObjectsToObjArray(TObjArray* oba, const std::vector& configs) + template + float getCentrality(TCollision const& collision) { - for (auto it = configs.begin(); it != configs.end(); ++it) { - if (it->pTDif) { - std::string suffix = "_ptDiff"; - for (auto i = 0; i < fPtAxis->GetNbins(); ++i) { - std::string index = Form("_pt_%i", i + 1); - oba->Add(new TNamed(it->Head.c_str() + index, it->Head.c_str() + suffix)); - } - } else { - oba->Add(new TNamed(it->Head.c_str(), it->Head.c_str())); - } + float cent = 0.0; + switch (EvSels.cfgCentEstimator) { + case UseCentFT0C: + cent = collision.centFT0C(); + break; + case UseCentFT0CVariant1: + cent = collision.centFT0CVariant1(); + break; + case UseCentFT0M: + cent = collision.centFT0M(); + break; + case UseCentFV0A: + cent = collision.centFV0A(); + break; + default: + cent = collision.centFT0C(); } + return cent; } template - bool selectionTrack(const TTrack& track) + bool trackSelected(TTrack const& track) { - histos.fill(HIST("hTrackCount"), kFilteredTracks); // Filtered tracks - if (cfgUseGlobalTrack && !(track.isGlobalTrack())) { - return 0; + histos.fill(HIST("hTrackCount"), FillFilteredTrks - 1); // Filtered tracks + + if ((track.pt() <= trackCuts[TrkCutPtMin][UseGenTrkCuts]) || (track.pt() >= trackCuts[TrkCutPtMax][UseGenTrkCuts])) { + return false; } - if (cfgUseGlobalTrack) - histos.fill(HIST("hTrackCount"), kUseGlobalTracks); // After global track selection + histos.fill(HIST("hTrackCount"), FillCutPt - 1); // After pT cut - if (!(track.isPVContributor())) { - return 0; + if (std::abs(track.eta()) > trackCuts[TrkCutEta][UseGenTrkCuts]) { + return false; } - histos.fill(HIST("hTrackCount"), kUsePvContributor); // After PV contributor selection + histos.fill(HIST("hTrackCount"), FillCutEta - 1); // After eta cut - if (!(track.itsNCls() > cfgITScluster)) { - return 0; + if (track.tpcChi2NCl() > trackCuts[TrkCutChi2PrTpcCls][UseGenTrkCuts]) { + return false; } - histos.fill(HIST("hTrackCount"), kItsClustersCut); // After ITS cluster selection + histos.fill(HIST("hTrackCount"), FillCutChi2PrTpcCls - 1); // After chi2 per TPC NCls cut - if (!(track.hasTPC())) { - return 0; + if (track.tpcNClsFound() < trackCuts[TrkCutTpcCluster][UseGenTrkCuts]) { + return false; } - histos.fill(HIST("hTrackCount"), kHasTpcSignal); // If track has TPC signal + histos.fill(HIST("hTrackCount"), FillCutTpcCluster - 1); // After TPC Clusters cut - if (!(track.tpcNClsFound() > cfgTpcCluster)) { - return 0; + if (track.tpcNClsCrossedRows() < trackCuts[TrkCutTpcCrossedRows][UseGenTrkCuts]) { + return false; } - histos.fill(HIST("hTrackCount"), kTpcClustersCut); // After TPC cluster selection + histos.fill(HIST("hTrackCount"), FillCutTpcCrossedRows - 1); // After TPC Crossed Rows cut - if (!(track.tpcNClsCrossedRows() > cfgTpcCrossRows)) { - return 0; + if (track.itsNCls() < trackCuts[TrkCutItsCluster][UseGenTrkCuts]) { + return false; } - histos.fill(HIST("hTrackCount"), kTpcCrossedRowsCut); // After TPC crossed rows selection - return 1; - } + histos.fill(HIST("hTrackCount"), FillCutItsCluster - 1); // After ITS Clusters cut - template - void fillQA(const TCollision& collision, const TTrack& track, int pidIndex, double wacc) - { - histos.fill(HIST("partCount"), pidIndex - 1, collision.centFT0C(), track.pt()); - switch (pidIndex) { - case 1: - if (!cfgUseItsPID) - histos.fill(HIST("TofTpcNsigma_after"), pidIndex - 1, track.tpcNSigmaPi(), track.tofNSigmaPi(), track.pt()); - if (cfgUseItsPID) - histos.fill(HIST("TofItsNsigma_after"), pidIndex - 1, itsResponse.nSigmaITS(track), track.tofNSigmaPi(), track.pt()); - histos.fill(HIST("hTrackCount"), kNumPions); // Pion count - if (!cfgAcceptance.value.empty() && cfgUseWeightPhiEtaVtxz) - histos.fill(HIST("PhiCorrected/hPhiEtaVtxz_pi_corrd"), track.phi(), track.eta(), collision.posZ(), wacc); // pion weights - if (!cfgAcceptance.value.empty() && cfgUseWeightPhiPtCent) - histos.fill(HIST("PhiCorrected/hPhiPtCent_pi_corrd"), track.phi(), track.pt(), collision.centFT0C(), wacc); - if (!cfgAcceptance.value.empty() && cfgUseWeightPhiEtaPt) - histos.fill(HIST("PhiCorrected/hPhiEtaPt_pi_corrd"), track.phi(), track.eta(), track.pt(), wacc); - break; - case 2: - if (!cfgUseItsPID) - histos.fill(HIST("TofTpcNsigma_after"), pidIndex - 1, track.tpcNSigmaKa(), track.tofNSigmaKa(), track.pt()); - if (cfgUseItsPID) - histos.fill(HIST("TofItsNsigma_after"), pidIndex - 1, itsResponse.nSigmaITS(track), track.tofNSigmaKa(), track.pt()); - histos.fill(HIST("hTrackCount"), kNumKaons); // Kaon count - if (!cfgAcceptance.value.empty() && cfgUseWeightPhiEtaVtxz) - histos.fill(HIST("PhiCorrected/hPhiEtaVtxz_ka_corrd"), track.phi(), track.eta(), collision.posZ(), wacc); // kaon weights - if (!cfgAcceptance.value.empty() && cfgUseWeightPhiPtCent) - histos.fill(HIST("PhiCorrected/hPhiPtCent_ka_corrd"), track.phi(), track.pt(), collision.centFT0C(), wacc); - if (!cfgAcceptance.value.empty() && cfgUseWeightPhiEtaPt) - histos.fill(HIST("PhiCorrected/hPhiEtaPt_ka_corrd"), track.phi(), track.eta(), track.pt(), wacc); - break; - case 3: - if (!cfgUseItsPID) - histos.fill(HIST("TofTpcNsigma_after"), pidIndex - 1, track.tpcNSigmaPr(), track.tofNSigmaPr(), track.pt()); - if (cfgUseItsPID) - histos.fill(HIST("TofItsNsigma_after"), pidIndex - 1, itsResponse.nSigmaITS(track), track.tofNSigmaPr(), track.pt()); - histos.fill(HIST("hTrackCount"), kNumProtons); // Proton count - if (!cfgAcceptance.value.empty() && cfgUseWeightPhiEtaVtxz) - histos.fill(HIST("PhiCorrected/hPhiEtaVtxz_pr_corrd"), track.phi(), track.eta(), collision.posZ(), wacc); // proton weights - if (!cfgAcceptance.value.empty() && cfgUseWeightPhiPtCent) - histos.fill(HIST("PhiCorrected/hPhiPtCent_pr_corrd"), track.phi(), track.pt(), collision.centFT0C(), wacc); - if (!cfgAcceptance.value.empty() && cfgUseWeightPhiEtaPt) - histos.fill(HIST("PhiCorrected/hPhiEtaPt_pr_corrd"), track.phi(), track.eta(), track.pt(), wacc); - break; - } // end of switch - } // end of fillQA + if (!TrkSels.cfgTrackCutsDCAz.value[UseGenTrkCuts].empty()) { + if (std::fabs(track.dcaZ()) > FuncParas.fPtDepDCAz->Eval(track.pt())) { + return false; + } + } else { + if (std::fabs(track.dcaZ()) > trackCuts[TrkCutDCAz][UseGenTrkCuts]) { + return false; + } + } + histos.fill(HIST("hTrackCount"), FillCutDCAz - 1); // After DCAz cut + + if (!TrkSels.cfgTrackCutsDCAxy.value[UseGenTrkCuts].empty() && std::fabs(track.dcaXY()) > FuncParas.fPtDepDCAxy->Eval(track.pt())) { + return false; + } + histos.fill(HIST("hTrackCount"), FillCutDCAxy - 1); // After DCAxy cut + + return true; + } template - int getNsigmaPIDTpcTof(const TTrack& track) + bool trackSelectedForNch(TTrack const& track) { - // Computing Nsigma arrays for pion, kaon, and protons - std::array nSigmaTPC = {track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr()}; - std::array nSigmaCombined = {std::hypot(track.tpcNSigmaPi(), track.tofNSigmaPi()), std::hypot(track.tpcNSigmaKa(), track.tofNSigmaKa()), std::hypot(track.tpcNSigmaPr(), track.tofNSigmaPr())}; - int pid = -1; - float nsigma = cfgTpcCut; - - // Choose which nSigma to use - std::array nSigmaToUse = (track.pt() > cfgTofPtCut && track.hasTOF()) ? nSigmaCombined : nSigmaTPC; - if (track.pt() > cfgTofPtCut && !track.hasTOF()) - return 0; - - const int numSpecies = 3; - int pidCount = 0; - // Select particle with the lowest nsigma - for (int i = 0; i < numSpecies; ++i) { - if (std::abs(nSigmaToUse[i]) < nsigma) { - if (pidCount > 0 && cfgUseStrictPID) - return 0; // more than one particle with low nsigma - - pidCount++; - pid = i; - if (!cfgUseStrictPID) - nsigma = std::abs(nSigmaToUse[i]); + if (!TrkSels.cfgTrackCutsDCAxy.value[UseNchSelCuts].empty() && (std::fabs(track.dcaXY()) > FuncParas.fPtDepDCAxyForNch->Eval(track.pt()))) { + return false; + } + if (!TrkSels.cfgTrackCutsDCAz.value[UseNchSelCuts].empty()) { + if (std::fabs(track.dcaZ()) > FuncParas.fPtDepDCAzForNch->Eval(track.pt())) { + return false; + } + } else { + if (std::fabs(track.dcaZ()) > trackCuts[TrkCutDCAz][UseNchSelCuts]) { + return false; } } - return pid + 1; // shift the pid by 1, 1 = pion, 2 = kaon, 3 = proton + return ((track.pt() > trackCuts[TrkCutPtMin][UseNchSelCuts]) && (track.pt() < trackCuts[TrkCutPtMax][UseNchSelCuts]) && (std::abs(track.eta()) < trackCuts[TrkCutEta][UseNchSelCuts]) && (track.tpcChi2NCl() < trackCuts[TrkCutChi2PrTpcCls][UseNchSelCuts]) && (track.tpcNClsFound() >= trackCuts[TrkCutTpcCluster][UseNchSelCuts]) && (track.tpcNClsCrossedRows() >= trackCuts[TrkCutTpcCrossedRows][UseNchSelCuts]) && (track.itsNCls() >= trackCuts[TrkCutItsCluster][UseNchSelCuts])); } template - int getNsigmaPIDAssymmetric(const TTrack& track) + int getNsigmaPID(const TTrack& track) { + if (PIDConfigs.cfgPIDUseNclsPID && track.tpcNClsPID() < PIDConfigs.cfgPIDNclsPIDCut) { + return -1; + } + // Computing Nsigma arrays for pion, kaon, and protons std::array nSigmaTPC = {track.tpcNSigmaPi(), track.tpcNSigmaKa(), track.tpcNSigmaPr()}; std::array nSigmaTOF = {track.tofNSigmaPi(), track.tofNSigmaKa(), track.tofNSigmaPr()}; std::array nSigmaITS = {itsResponse.nSigmaITS(track), itsResponse.nSigmaITS(track), itsResponse.nSigmaITS(track)}; - int pid = -1; - - std::array nSigmaToUse = cfgUseItsPID ? nSigmaITS : nSigmaTPC; // Choose which nSigma to use: TPC or ITS - std::vector detectorNsigmaCut = cfgUseItsPID ? itsNsigmaCut : tpcNsigmaCut; // Choose which nSigma to use: TPC or ITS - - bool isPion, isKaon, isProton; - bool isDetectedPion = nSigmaToUse[0] < detectorNsigmaCut[0] && nSigmaToUse[0] > detectorNsigmaCut[0 + 3]; - bool isDetectedKaon = nSigmaToUse[1] < detectorNsigmaCut[1] && nSigmaToUse[1] > detectorNsigmaCut[1 + 3]; - bool isDetectedProton = nSigmaToUse[2] < detectorNsigmaCut[2] && nSigmaToUse[2] > detectorNsigmaCut[2 + 3]; - - bool isTofPion = nSigmaTOF[0] < tofNsigmaCut[0] && nSigmaTOF[0] > tofNsigmaCut[0 + 3]; - bool isTofKaon = nSigmaTOF[1] < tofNsigmaCut[1] && nSigmaTOF[1] > tofNsigmaCut[1 + 3]; - bool isTofProton = nSigmaTOF[2] < tofNsigmaCut[2] && nSigmaTOF[2] > tofNsigmaCut[2 + 3]; - - if (track.pt() > cfgTofPtCut && !track.hasTOF()) { - return 0; - } else if (track.pt() > cfgTofPtCut && track.hasTOF()) { + int pid = -1; // -1 = not identified, 1 = pion, 2 = kaon, 3 = proton + + std::array nSigmaToUse = PIDConfigs.cfgPIDUseIts ? nSigmaITS : nSigmaTPC; // Choose which nSigma to use: TPC or ITS + int useIndexDetector = UseTPC; + useIndexDetector = PIDConfigs.cfgPIDUseIts ? UseITS : UseTPC; // Choose which nSigma to use: TPC or ITS + + bool isPion = false; + bool isKaon = false; + bool isProton = false; + bool isDetectedPion = false; + bool isDetectedKaon = false; + bool isDetectedProton = false; + bool isTofPion = false; + bool isTofKaon = false; + bool isTofProton = false; + + isDetectedPion = nSigmaToUse[IndexPionUp] < nSigmaVals[IndexPionUp][useIndexDetector] && nSigmaToUse[IndexPionUp] > nSigmaVals[IndexPionLow][useIndexDetector]; + isDetectedKaon = nSigmaToUse[IndexKaonUp] < nSigmaVals[IndexKaonUp][useIndexDetector] && nSigmaToUse[IndexKaonUp] > nSigmaVals[IndexKaonLow][useIndexDetector]; + isDetectedProton = nSigmaToUse[IndexProtonUp] < nSigmaVals[IndexProtonUp][useIndexDetector] && nSigmaToUse[IndexProtonUp] > nSigmaVals[IndexProtonLow][useIndexDetector]; + + isTofPion = nSigmaTOF[IndexPionUp] < nSigmaVals[IndexPionUp][UseTOF] && nSigmaTOF[IndexPionUp] > nSigmaVals[IndexPionLow][UseTOF]; + isTofKaon = nSigmaTOF[IndexKaonUp] < nSigmaVals[IndexKaonUp][UseTOF] && nSigmaTOF[IndexKaonUp] > nSigmaVals[IndexKaonLow][UseTOF]; + isTofProton = nSigmaTOF[IndexProtonUp] < nSigmaVals[IndexProtonUp][UseTOF] && nSigmaTOF[IndexProtonUp] > nSigmaVals[IndexProtonLow][UseTOF]; + + if (track.pt() > PIDConfigs.cfgPIDTofPtCut && !track.hasTOF()) { + return -1; + } + if (track.pt() > PIDConfigs.cfgPIDTofPtCut && track.hasTOF()) { isPion = isTofPion && isDetectedPion; isKaon = isTofKaon && isDetectedKaon; isProton = isTofProton && isDetectedProton; @@ -584,139 +775,259 @@ struct FlowPbpbPikp { isProton = isDetectedProton; } - if ((isPion && isKaon) || (isPion && isProton) || (isKaon && isProton)) { - return 0; // more than one particle satisfy the criteria + if (PIDConfigs.cfgPIDUseRejection && ((isPion && isKaon) || (isPion && isProton) || (isKaon && isProton))) { + return -1; // more than one particle satisfy the criteria } if (isPion) { - pid = PIONS; + pid = UsePions; } else if (isKaon) { - pid = KAONS; + pid = UseKaons; } else if (isProton) { - pid = PROTONS; + pid = UseProtons; } else { - return 0; // no particle satisfies the criteria + return -1; // no particle satisfies the criteria } - return pid + 1; // shift the pid by 1, 1 = pion, 2 = kaon, 3 = proton + return pid; // -1 = not identified, 1 = pion, 2 = kaon, 3 = proton } - template - requires is_const_str::value - void fillProfile(const GFW::CorrConfig& corrconf, const TName& tarName, const double& cent) + void loadCorrections(uint64_t timestamp) { - double dnx, val; - if (!corrconf.pTDif) { - dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); - if (dnx == 0) - return; - val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; - if (std::fabs(val) < 1) - histos.fill(tarName, cent, val, dnx); + if (correctionsLoaded) { return; } - for (int i = 1; i <= fPtAxis->GetNbins(); i++) { - dnx = fGFW->Calculate(corrconf, i - 1, kTRUE).real(); - if (dnx == 0) - continue; - val = fGFW->Calculate(corrconf, i - 1, kFALSE).real() / dnx; - if (std::fabs(val) < 1) - histos.fill(tarName, fPtAxis->GetBinCenter(i), val, dnx); + // Loading efficiency histograms + if (!Weights.cfgEfficiency.value.empty()) { + mEfficiency = ccdb->getForTimeStamp(Weights.cfgEfficiency, timestamp); + if (mEfficiency == nullptr) { + LOGF(fatal, "Could not load efficiency histogram for trigger particles from %s", Weights.cfgEfficiency.value.c_str()); + } + LOGF(info, "Loaded efficiency histogram from %s (%p)", Weights.cfgEfficiency.value.c_str(), static_cast(mEfficiency)); } - return; + // Loading acceptance histograms + if (!Weights.cfgAcceptance.value.empty()) { + mAcceptance.clear(); + mAcceptance.resize(NumCountTypes); + + // Charged particles + mAcceptance[UseCharged] = ccdb->getForTimeStamp(Weights.cfgAcceptance.value + "_ch", timestamp); + if (mAcceptance[UseCharged]) { + LOGF(info, "Loaded acceptance weights from %s_ch (%p)", Weights.cfgAcceptance.value.c_str(), (void*)mAcceptance[UseCharged]); + } else { + LOGF(fatal, "Could not load acceptance weights from %s_ch (%p)", Weights.cfgAcceptance.value.c_str(), (void*)mAcceptance[UseCharged]); + } + // Pions + mAcceptance[UsePions] = ccdb->getForTimeStamp(Weights.cfgAcceptance.value + "_pi", timestamp); + if (mAcceptance[UsePions]) { + LOGF(info, "Loaded acceptance weights from %s_pi (%p)", Weights.cfgAcceptance.value.c_str(), (void*)mAcceptance[UsePions]); + } else { + LOGF(fatal, "Could not load acceptance weights from %s_pi (%p)", Weights.cfgAcceptance.value.c_str(), (void*)mAcceptance[UsePions]); + } + // Kaons + mAcceptance[UseKaons] = ccdb->getForTimeStamp(Weights.cfgAcceptance.value + "_ka", timestamp); + if (mAcceptance[UseKaons]) { + LOGF(info, "Loaded acceptance weights from %s_ka (%p)", Weights.cfgAcceptance.value.c_str(), (void*)mAcceptance[UseKaons]); + } else { + LOGF(fatal, "Could not load acceptance weights from %s_ka (%p)", Weights.cfgAcceptance.value.c_str(), (void*)mAcceptance[UseKaons]); + } + // Protons + mAcceptance[UseProtons] = ccdb->getForTimeStamp(Weights.cfgAcceptance.value + "_pr", timestamp); + if (mAcceptance[UseProtons]) { + LOGF(info, "Loaded acceptance weights from %s_pr (%p)", Weights.cfgAcceptance.value.c_str(), (void*)mAcceptance[UseProtons]); + } else { + LOGF(fatal, "Could not load acceptance weights from %s_pr (%p)", Weights.cfgAcceptance.value.c_str(), (void*)mAcceptance[UseProtons]); + } + // Reference charged particles + mAcceptance[UseRef] = ccdb->getForTimeStamp(Weights.cfgAcceptance.value + "_ref", timestamp); + if (mAcceptance[UseRef]) { + LOGF(info, "Loaded acceptance weights from %s_ref (%p)", Weights.cfgAcceptance.value.c_str(), (void*)mAcceptance[UseRef]); + } else { + LOGF(fatal, "Could not load acceptance weights from %s_ref (%p)", Weights.cfgAcceptance.value.c_str(), (void*)mAcceptance[UseRef]); + } + } + correctionsLoaded = true; } - void fillFC(const GFW::CorrConfig& corrconf, const double& cent, const double& rndm) + bool getEfficiencyCorrection(float& weight_nue, float pt) { - double dnx, val; - if (!corrconf.pTDif) { - dnx = fGFW->Calculate(corrconf, 0, kTRUE).real(); - if (dnx == 0) { - return; + float effNch = 1.; + if (mEfficiency) { + int ptBin = mEfficiency->FindBin(pt); + effNch = mEfficiency->GetBinContent(ptBin); + } else { + effNch = 1.0; + } + if (effNch == 0) { + return false; + } + weight_nue = 1. / effNch; + return true; + } + + template + void nchCounter(const TTracks& tracks, double& multiplicity) // function to count the number of tracks in the event and fill the histogram + { + double nTracksCorrected = 0; + float weight = 1.0f; + for (auto const& track : tracks) { + if (!trackSelectedForNch(track)) { + continue; } - val = fGFW->Calculate(corrconf, 0, kFALSE).real() / dnx; - if (std::fabs(val) < 1) { - fFC->FillProfile(corrconf.Head.c_str(), cent, val, dnx, rndm); + + if (!getEfficiencyCorrection(weight, track.pt())) { + continue; } - return; + nTracksCorrected += weight; } - for (int i = 1; i <= fPtAxis->GetNbins(); i++) { - dnx = fGFW->Calculate(corrconf, i - 1, kTRUE).real(); - if (dnx == 0) - continue; - val = fGFW->Calculate(corrconf, i - 1, kFALSE).real() / dnx; - if (std::fabs(val) < 1) - fFC->FillProfile(Form("%s_pt_%i", corrconf.Head.c_str(), i), cent, val, dnx, rndm); + multiplicity = nTracksCorrected; + } + + template + void fillTrackQA(TTrack const& track, int pid, double eventClass, Stage stage, float weff, float wacc) // function to fill the QA after Nsigma selection + { + if (stage == Before && pid == UseCharged) { + histos.fill(HIST("hPhi"), RecoDecay::constrainAngle(track.phi(), 0.0), UseCharged); + histos.fill(HIST("hPhiWeighted"), RecoDecay::constrainAngle(track.phi(), 0.0), UseCharged, wacc); + histos.fill(HIST("hEta"), track.eta(), UseCharged); + histos.fill(HIST("hEtaCorrected"), track.eta(), UseCharged, weff); + histos.fill(HIST("hPt"), track.pt(), UseCharged, eventClass); + histos.fill(HIST("hPtCorrected"), track.pt(), UseCharged, eventClass, weff); + + } else if (stage == After && pid > UseCharged) { + histos.fill(HIST("hPhi"), RecoDecay::constrainAngle(track.phi(), 0.0), pid); + histos.fill(HIST("hPhiWeighted"), RecoDecay::constrainAngle(track.phi(), 0.0), pid, wacc); + histos.fill(HIST("hEta"), track.eta(), pid); + histos.fill(HIST("hEtaCorrected"), track.eta(), pid, weff); + histos.fill(HIST("hPt"), track.pt(), pid, eventClass); + histos.fill(HIST("hPtCorrected"), track.pt(), pid, eventClass, weff); } - return; } - void createRunByRunHistos(int runNumber) + template + void fillPIDQA(TTrack const& track, int pid, double eventClass, Stage stage) { - if (cfgOutputNUAWeights) { - std::vector> tH3s(kCount_OutputSpecies); - tH3s[hRef] = histos.add(Form("NUA/%d/hPhiEtaVtxz_ref", runNumber), ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); - tH3s[hCharge] = histos.add(Form("NUA/%d/hPhiEtaVtxz_ch", runNumber), ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); - tH3s[hPion] = histos.add(Form("NUA/%d/hPhiEtaVtxz_pi", runNumber), ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); - tH3s[hKaon] = histos.add(Form("NUA/%d/hPhiEtaVtxz_ka", runNumber), ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); - tH3s[hProton] = histos.add(Form("NUA/%d/hPhiEtaVtxz_pr", runNumber), ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); - th3sList.insert(std::make_pair(runNumber, tH3s)); + const bool useITS = PIDConfigs.cfgPIDUseIts; + double detectorNSigma = 0.0; + double tpcExpSigma = 0.0; + double tofNSigma = 0.0; + double tpcNSigma = 0.0; + switch (pid) { + case UsePions: // For Pions + tofNSigma = track.tofNSigmaPi(); + tpcExpSigma = track.tpcExpSigmaPi(); + tpcNSigma = track.tpcNSigmaPi(); + detectorNSigma = useITS ? itsResponse.nSigmaITS(track) : tpcNSigma; + break; + case UseKaons: // For Kaons + tofNSigma = track.tofNSigmaKa(); + tpcExpSigma = track.tpcExpSigmaKa(); + tpcNSigma = track.tpcNSigmaKa(); + detectorNSigma = useITS ? itsResponse.nSigmaITS(track) : tpcNSigma; + break; + case UseProtons: // For Protons + tofNSigma = track.tofNSigmaPr(); + tpcExpSigma = track.tpcExpSigmaPr(); + tpcNSigma = track.tpcNSigmaPr(); + detectorNSigma = useITS ? itsResponse.nSigmaITS(track) : tpcNSigma; + break; + default: + return; } + + if (PIDConfigs.cfgQANsigma) { + if (stage == Before) { // This is filled before deciding the particle type, so this segment is filled four times + if (!useITS) { + histos.fill(HIST("TofTpcNsigma_beforeCut"), detectorNSigma, tofNSigma, eventClass, track.pt(), pid); + } else { + histos.fill(HIST("TofItsNsigma_beforeCut"), detectorNSigma, tofNSigma, eventClass, track.pt(), pid); + } + } else if (stage == After) { // This is filled after deciding the particle type, so this segment is filled once + if (!useITS) { + histos.fill(HIST("TofTpcNsigma_afterCut"), detectorNSigma, tofNSigma, eventClass, track.pt(), pid); + } else { + histos.fill(HIST("TofItsNsigma_afterCut"), detectorNSigma, tofNSigma, eventClass, track.pt(), pid); + } + } + } // If switched on cfgQANsigma + + if (PIDConfigs.cfgQAdEdx) { + double tpcExpSignal = track.tpcSignal() - (tpcNSigma * tpcExpSigma); + + if (stage == Before) { + histos.fill(HIST("TpcdEdx_beforeCut"), track.tpcSignal(), tofNSigma, eventClass, track.pt(), pid); + histos.fill(HIST("ExpTpcdEdx_beforeCut"), tpcExpSignal, tofNSigma, eventClass, track.pt(), pid); + histos.fill(HIST("ExpSigma_beforeCut"), tpcExpSigma, tofNSigma, eventClass, track.pt(), pid); + } else if (stage == After) { + histos.fill(HIST("TpcdEdx_afterCut"), track.tpcSignal(), tofNSigma, eventClass, track.pt(), pid); + histos.fill(HIST("ExpTpcdEdx_afterCut"), tpcExpSignal, tofNSigma, eventClass, track.pt(), pid); + histos.fill(HIST("ExpSigma_afterCut"), tpcExpSigma, tofNSigma, eventClass, track.pt(), pid); + } + } // If switched on cfgQAdEdx + + if (PIDConfigs.cfgQABetadEdx) { + double tpcExpSignal = track.tpcSignal() - (tpcNSigma * tpcExpSigma); + + if (stage == Before) { + histos.fill(HIST("TpcdEdx_TofBeta_beforeCut"), track.tpcSignal(), track.beta(), eventClass, track.pt(), pid); + histos.fill(HIST("ExpTpcdEdx_TofBeta_beforeCut"), tpcExpSignal, track.beta(), eventClass, track.pt(), pid); + histos.fill(HIST("ExpSigma_TofBeta_beforeCut"), tpcExpSigma, track.beta(), eventClass, track.pt(), pid); + } else if (stage == After) { + histos.fill(HIST("TpcdEdx_TofBeta_afterCut"), track.tpcSignal(), track.beta(), eventClass, track.pt(), pid); + histos.fill(HIST("ExpTpcdEdx_TofBeta_afterCut"), tpcExpSignal, track.beta(), eventClass, track.pt(), pid); + histos.fill(HIST("ExpSigma_TofBeta_afterCut"), tpcExpSigma, track.beta(), eventClass, track.pt(), pid); + } + } // If switched on cfgQABetadEdx } - void loadCorrections(aod::BCsWithTimestamps::iterator const& bc) + void fillFC(const GFW::CorrConfig& corrconf, const double& eventClass, const double& rndm) { - if (correctionsLoaded) - return; - if (!cfgAcceptance.value.empty()) { - uint64_t timestamp = bc.timestamp(); - mAcceptance.clear(); - mAcceptance.resize(kCount_OutputSpecies); - mAcceptance[hRef] = ccdb->getForTimeStamp(cfgAcceptance.value + "_ref", timestamp); - if (mAcceptance[hRef]) - LOGF(info, "Loaded acceptance weights from %s_ref (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[hRef]); - else - LOGF(fatal, "Could not load acceptance weights from %s_ref (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[hRef]); - - mAcceptance[hCharge] = ccdb->getForTimeStamp(cfgAcceptance.value + "_ch", timestamp); - if (mAcceptance[hCharge]) - LOGF(info, "Loaded acceptance weights from %s_ch (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[hCharge]); - else - LOGF(fatal, "Could not load acceptance weights from %s_ch (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[hCharge]); - - mAcceptance[hPion] = ccdb->getForTimeStamp(cfgAcceptance.value + "_pi", timestamp); - if (mAcceptance[hPion]) - LOGF(info, "Loaded acceptance weights from %s_pi (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[hPion]); - else - LOGF(fatal, "Could not load acceptance weights from %s_pi (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[hPion]); - - mAcceptance[hKaon] = ccdb->getForTimeStamp(cfgAcceptance.value + "_ka", timestamp); - if (mAcceptance[hKaon]) - LOGF(info, "Loaded acceptance weights from %s_ka (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[hKaon]); - else - LOGF(fatal, "Could not load acceptance weights from %s_ka (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[hKaon]); - - mAcceptance[hProton] = ccdb->getForTimeStamp(cfgAcceptance.value + "_pr", timestamp); - if (mAcceptance[hProton]) - LOGF(info, "Loaded acceptance weights from %s_pr (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[hProton]); - else - LOGF(fatal, "Could not load acceptance weights from %s_pr (%p)", cfgAcceptance.value.c_str(), (void*)mAcceptance[hProton]); + auto fillSingleContainer = [&](const GFW::CorrConfig& cc, const double& ec, const int& ib, const double& rd, const std::string& cn) { + auto dnx = fGFW->Calculate(cc, ib, kTRUE).real(); + if (dnx == 0) { + return; + } + auto val = fGFW->Calculate(cc, ib, kFALSE).real() / dnx; + if (std::abs(val) < 1) { + fFC->FillProfile(cn.c_str(), ec, val, dnx, rd); + } + }; + + // For pT-integrated + if (!corrconf.pTDif) { + fillSingleContainer(corrconf, eventClass, 0, rndm, corrconf.Head); + } else { // For pT-differential + for (int i = 1; i <= fPtAxis->GetNbins(); i++) { + std::string name = corrconf.Head + "_pt_" + std::to_string(i); + fillSingleContainer(corrconf, eventClass, i, rndm, name); + } } - correctionsLoaded = true; + return; } - template - double getAcceptance(const TTrack& track, const TCollision& collision, int index) - { // 0 = ref, 1 = ch, 2 = pi, 3 = ka, 4 = pr - if (index < 0 || index >= kCount_OutputSpecies) { + void createRunByRunHistos(int runNumber) + { + if (Weights.cfgOutputNUAWeights) { + std::vector> tH3s(NumCountTypes); + tH3s[UseCharged] = histos.add(Form("NUA/%d/hPhiEtaVtxz_ch", runNumber), ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + tH3s[UsePions] = histos.add(Form("NUA/%d/hPhiEtaVtxz_pi", runNumber), ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + tH3s[UseKaons] = histos.add(Form("NUA/%d/hPhiEtaVtxz_ka", runNumber), ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + tH3s[UseProtons] = histos.add(Form("NUA/%d/hPhiEtaVtxz_pr", runNumber), ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + tH3s[UseRef] = histos.add(Form("NUA/%d/hPhiEtaVtxz_ref", runNumber), ";#varphi;#eta;v_{z}", {HistType::kTH3D, {axisPhi, axisEta, axisVertex}}); + th3sList.insert(std::make_pair(runNumber, tH3s)); + } + } + + template + double getAcceptance(const TTrack& track, float cent, float vtxz, int index) + { // ch = 0, pi = 1, ka = 2, pr = 3, ref = 4 + if (index < 0 || index >= NumCountTypes) { return 1; } double wacc = 1; - double cent = collision.centFT0C(); - double vtxz = collision.posZ(); - if ((cfgUseWeightPhiEtaVtxz && cfgUseWeightPhiPtCent) || (cfgUseWeightPhiEtaPt && cfgUseWeightPhiPtCent) || (cfgUseWeightPhiEtaVtxz && cfgUseWeightPhiEtaPt)) { + if ((Weights.cfgUseWeightPhiEtaVtxz && Weights.cfgUseWeightPhiPtCent) || (Weights.cfgUseWeightPhiEtaPt && Weights.cfgUseWeightPhiPtCent) || (Weights.cfgUseWeightPhiEtaVtxz && Weights.cfgUseWeightPhiEtaPt)) { LOGF(fatal, "Only one of the three weight options can be used at a time"); } @@ -725,55 +1036,62 @@ struct FlowPbpbPikp { LOGF(fatal, "Acceptance weights not loaded for index %d", index); return 1; } - if (cfgUseWeightPhiEtaVtxz) + if (Weights.cfgUseWeightPhiEtaVtxz) { wacc = mAcceptance[index]->getNUA(track.phi(), track.eta(), vtxz); - if (cfgUseWeightPhiPtCent) + } + if (Weights.cfgUseWeightPhiPtCent) { wacc = mAcceptance[index]->getNUA(track.phi(), track.pt(), cent); - if (cfgUseWeightPhiEtaPt) + } + if (Weights.cfgUseWeightPhiEtaPt) { wacc = mAcceptance[index]->getNUA(track.phi(), track.eta(), track.pt()); + } } return wacc; } - template - void fillWeights(const TTrack& track, const TCollision& collision, const int& pid_index, const int& run) + template + void fillWeights(const TTrack& track, float cent, float vtxz, const int& pid_index, const int& run) { - double cent = collision.centFT0C(); - double vtxz = collision.posZ(); double pt = track.pt(); - bool withinPtPOI = (cfgCutPtPOIMin < pt) && (pt < cfgCutPtPOIMax); // within POI pT range - bool withinPtRef = (cfgCutPtMin < pt) && (pt < cfgCutPtMax); // within RF pT range - - if (cfgOutputRunByRun) { - if (withinPtRef && !pid_index) - th3sList[run][hRef]->Fill(track.phi(), track.eta(), vtxz); // pt-subset of charged particles for ref flow - if (withinPtPOI) - th3sList[run][hCharge + pid_index]->Fill(track.phi(), track.eta(), vtxz); // charged and id'ed particle weights - } else { - if (withinPtRef && !pid_index) { + bool withinPtPOI = (GeneralConfigs.cfgCutPtPOIMin < pt) && (pt < GeneralConfigs.cfgCutPtPOIMax); // within POI pT range + bool withinPtRef = (GeneralConfigs.cfgRefPtMin < pt) && (pt < GeneralConfigs.cfgRefPtMax); // within RF pT range + + if (Weights.cfgOutputRunByRun) { + if (withinPtRef && (pid_index < UseCharged)) { + th3sList[run][UseRef]->Fill(track.phi(), track.eta(), vtxz); // pt-subset of charged particles for ref flow + } + if (withinPtPOI) { + th3sList[run][UseCharged]->Fill(track.phi(), track.eta(), vtxz); // charged particle weights + if (pid_index > UseCharged) { + th3sList[run][pid_index]->Fill(track.phi(), track.eta(), vtxz); // id'ed particle weights + } + } + } else { // Fill NUA histograms for the entire run + // Fill NUA histograms for reference particles only when they are not identified as PID particle + // This will only be used for pT-dependent flow calculation for PID particles + if (withinPtRef && (pid_index < UseCharged)) { histos.fill(HIST("NUA/hPhiEtaVtxz_ref"), track.phi(), track.eta(), vtxz); // pt-subset of charged particles for ref flow histos.fill(HIST("NUA/hPhiPtCent_ref"), track.phi(), track.pt(), cent); histos.fill(HIST("NUA/hPhiEtaPt_ref"), track.phi(), track.eta(), track.pt()); } if (withinPtPOI) { + histos.fill(HIST("NUA/hPhiEtaVtxz_ch"), track.phi(), track.eta(), vtxz); // charged particle weights + histos.fill(HIST("NUA/hPhiPtCent_ch"), track.phi(), track.pt(), cent); + histos.fill(HIST("NUA/hPhiEtaPt_ch"), track.phi(), track.eta(), track.pt()); + switch (pid_index) { - case 0: - histos.fill(HIST("NUA/hPhiEtaVtxz_ch"), track.phi(), track.eta(), vtxz); // charged particle weights - histos.fill(HIST("NUA/hPhiPtCent_ch"), track.phi(), track.pt(), cent); - histos.fill(HIST("NUA/hPhiEtaPt_ch"), track.phi(), track.eta(), track.pt()); - break; - case 1: + case UsePions: histos.fill(HIST("NUA/hPhiEtaVtxz_pi"), track.phi(), track.eta(), vtxz); // pion weights histos.fill(HIST("NUA/hPhiPtCent_pi"), track.phi(), track.pt(), cent); histos.fill(HIST("NUA/hPhiEtaPt_pi"), track.phi(), track.eta(), track.pt()); break; - case 2: + case UseKaons: histos.fill(HIST("NUA/hPhiEtaVtxz_ka"), track.phi(), track.eta(), vtxz); // kaon weights histos.fill(HIST("NUA/hPhiPtCent_ka"), track.phi(), track.pt(), cent); histos.fill(HIST("NUA/hPhiEtaPt_ka"), track.phi(), track.eta(), track.pt()); break; - case 3: + case UseProtons: histos.fill(HIST("NUA/hPhiEtaVtxz_pr"), track.phi(), track.eta(), vtxz); // proton weights histos.fill(HIST("NUA/hPhiPtCent_pr"), track.phi(), track.pt(), cent); histos.fill(HIST("NUA/hPhiEtaPt_pr"), track.phi(), track.eta(), track.pt()); @@ -784,120 +1102,168 @@ struct FlowPbpbPikp { } template - bool selectionEvent(const TCollision& collision, const int mult, const float cent) + bool selectionEvent(TCollision const& collision, const int mult, const double cent, const bool fillCounter) { - histos.fill(HIST("hEventCount"), kFilteredEvents); + if (fillCounter) { + histos.fill(HIST("hEventCount"), FilteredEvents); + } if (!collision.sel8()) { - return 0; + return false; + } + if (fillCounter) { + histos.fill(HIST("hEventCount"), AfterSel8); } - histos.fill(HIST("hEventCount"), kAfterSel8); - if (eventCuts[kUseNoTimeFrameBorder] && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { - return 0; + if (eventCuts[UseNoTimeFrameBorder][EvCut1] && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { + return false; + } + if (fillCounter && eventCuts[UseNoTimeFrameBorder][EvCut1]) { + histos.fill(HIST("hEventCount"), UseNoTimeFrameBorder); } - if (eventCuts[kUseNoTimeFrameBorder]) - histos.fill(HIST("hEventCount"), kUseNoTimeFrameBorder); - if (eventCuts[kUseNoITSROFrameBorder] && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { - return 0; + if (eventCuts[UseNoITSROFrameBorder][EvCut1] && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + return false; + } + if (fillCounter && eventCuts[UseNoITSROFrameBorder][EvCut1]) { + histos.fill(HIST("hEventCount"), UseNoITSROFrameBorder); } - if (eventCuts[kUseNoITSROFrameBorder]) - histos.fill(HIST("hEventCount"), kUseNoITSROFrameBorder); - if (eventCuts[kUseNoSameBunchPileup] && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { - return 0; + if (eventCuts[UseNoSameBunchPileup][EvCut1] && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) { + // rejects collisions which are associated with the same "found-by-T0" bunch crossing + // https://indico.cern.ch/event/1396220/#1-event-selection-with-its-rof + return false; + } + if (fillCounter && eventCuts[UseNoSameBunchPileup][EvCut1]) { + histos.fill(HIST("hEventCount"), UseNoSameBunchPileup); } - if (eventCuts[kUseNoSameBunchPileup]) - histos.fill(HIST("hEventCount"), kUseNoSameBunchPileup); - if (eventCuts[kUseGoodZvtxFT0vsPV] && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { - return 0; + if (eventCuts[UseGoodZvtxFT0vsPV][EvCut1] && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { + // removes collisions with large differences between z of PV by tracks and z of PV from FT0 A-C time difference + // use this cut at low multiplicities with caution + return false; + } + if (fillCounter && eventCuts[UseGoodZvtxFT0vsPV][EvCut1]) { + histos.fill(HIST("hEventCount"), UseGoodZvtxFT0vsPV); } - if (eventCuts[kUseGoodZvtxFT0vsPV]) - histos.fill(HIST("hEventCount"), kUseGoodZvtxFT0vsPV); - if (eventCuts[kUseNoCollInTimeRangeStandard] && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { - return 0; + if (eventCuts[UseNoCollInTimeRangeStandard][EvCut1] && !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { + // no collisions in specified time range + return false; } - if (eventCuts[kUseNoCollInTimeRangeStandard]) - histos.fill(HIST("hEventCount"), kUseNoCollInTimeRangeStandard); - if (eventCuts[kUseGoodITSLayersAll] && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { - return 0; + if (fillCounter && eventCuts[UseNoCollInTimeRangeStandard][EvCut1]) { + histos.fill(HIST("hEventCount"), UseNoCollInTimeRangeStandard); } - if (eventCuts[kUseGoodITSLayersAll]) - histos.fill(HIST("hEventCount"), kUseGoodITSLayersAll); - if (eventCuts[kUseNoCollInRofStandard] && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { - return 0; + if (eventCuts[UseGoodITSLayersAll][EvCut1] && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll)) { + // from Jan 9 2025 AOT meeting + // cut time intervals with dead ITS staves + return false; } - if (eventCuts[kUseNoCollInRofStandard]) - histos.fill(HIST("hEventCount"), kUseNoCollInRofStandard); - if (eventCuts[kUseNoHighMultCollInPrevRof] && !collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { - return 0; + if (fillCounter && eventCuts[UseGoodITSLayersAll][EvCut1]) { + histos.fill(HIST("hEventCount"), UseGoodITSLayersAll); + } + + if (eventCuts[UseGoodITSLayer0123][EvCut1] && !collision.selection_bit(o2::aod::evsel::kIsGoodITSLayer0123)) { + return false; + } + if (fillCounter && eventCuts[UseGoodITSLayer0123][EvCut1]) { + histos.fill(HIST("hEventCount"), UseGoodITSLayer0123); + } + + if (eventCuts[UseNoCollInRofStandard][EvCut1] && !collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { + // no other collisions in this Readout Frame with per-collision multiplicity above threshold + return false; + } + + if (fillCounter && eventCuts[UseNoCollInRofStandard][EvCut1]) { + histos.fill(HIST("hEventCount"), UseNoCollInRofStandard); + } + + if (eventCuts[UseNoHighMultCollInPrevRof][EvCut1] && !collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof)) { + // veto an event if FT0C amplitude in previous ITS ROF is above threshold + return false; + } + if (fillCounter && eventCuts[UseNoHighMultCollInPrevRof][EvCut1]) { + histos.fill(HIST("hEventCount"), UseNoHighMultCollInPrevRof); } - if (eventCuts[kUseNoHighMultCollInPrevRof]) - histos.fill(HIST("hEventCount"), kUseNoHighMultCollInPrevRof); auto multNTracksPV = collision.multNTracksPV(); auto occupancy = collision.trackOccupancyInTimeRange(); - if (eventCuts[kUseOccupancy] && (occupancy < cfgCutOccupancyMin || occupancy > cfgCutOccupancyMax)) { - return 0; + if (eventCuts[UseOccupancy][EvCut1] && (occupancy < EvSels.cfgCutOccupancyMin || occupancy > EvSels.cfgCutOccupancyMax)) { + return false; } - if (eventCuts[kUseOccupancy]) - histos.fill(HIST("hEventCount"), kUseOccupancy); - - if (eventCuts[kUseMultCorrCut]) { - if (multNTracksPV < fMultPVCutLow->Eval(cent)) - return 0; - if (multNTracksPV > fMultPVCutHigh->Eval(cent)) - return 0; - if (mult < fMultCutLow->Eval(cent)) - return 0; - if (mult > fMultCutHigh->Eval(cent)) - return 0; + if (fillCounter && eventCuts[UseOccupancy][EvCut1]) { + histos.fill(HIST("hEventCount"), UseOccupancy); } - if (eventCuts[kUseMultCorrCut]) - histos.fill(HIST("hEventCount"), kUseMultCorrCut); - // V0A T0A 5 sigma cut - if (eventCuts[kUseT0AV0ACut] && (std::fabs(collision.multFV0A() - fT0AV0AMean->Eval(collision.multFT0A())) > cfgV0AT0Acut * fT0AV0ASigma->Eval(collision.multFT0A()))) - return 0; - if (eventCuts[kUseT0AV0ACut]) - histos.fill(HIST("hEventCount"), kUseT0AV0ACut); + if (eventCuts[UseMultCorrCut][EvCut1]) { + if (FuncParas.cfgMultPVT0CCutEnabled) { + if (multNTracksPV < FuncParas.fMultPVT0CCutLow->Eval(cent)) { + return false; + } + if (multNTracksPV > FuncParas.fMultPVT0CCutHigh->Eval(cent)) { + return false; + } + } + if (FuncParas.cfgMultT0CCutEnabled) { + if (mult < FuncParas.fMultT0CCutLow->Eval(cent)) { + return false; + } + if (mult > FuncParas.fMultT0CCutHigh->Eval(cent)) { + return false; + } + } + if (FuncParas.cfgMultGlobalPVCutEnabled) { + if (mult < FuncParas.fMultGlobalPVCutLow->Eval(multNTracksPV)) { + return false; + } + if (mult > FuncParas.fMultGlobalPVCutHigh->Eval(multNTracksPV)) { + return false; + } + } + if (FuncParas.cfgMultMultV0ACutEnabled) { + if (collision.multFV0A() < FuncParas.fMultMultV0ACutLow->Eval(mult)) { + return false; + } + if (collision.multFV0A() > FuncParas.fMultMultV0ACutHigh->Eval(mult)) { + return false; + } + } + } - if (eventCuts[kUseVertexITSTPC] && !collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC)) - return 0; - if (eventCuts[kUseVertexITSTPC]) - histos.fill(HIST("hEventCount"), kUseVertexITSTPC); + if (fillCounter && eventCuts[UseMultCorrCut][EvCut1]) { + histos.fill(HIST("hEventCount"), UseMultCorrCut); + } - if (eventCuts[kUseTVXinTRD] && collision.alias_bit(kTVXinTRD)) { - return 0; + // V0A T0A 5 sigma cut + if (eventCuts[UseT0AV0ACut][EvCut1] && (std::fabs(collision.multFV0A() - FuncParas.fT0AV0AMean->Eval(collision.multFT0A())) > FuncParas.cfgV0AT0Acut * FuncParas.fT0AV0ASigma->Eval(collision.multFT0A()))) { + return false; + } + if (fillCounter && eventCuts[UseT0AV0ACut][EvCut1]) { + histos.fill(HIST("hEventCount"), UseT0AV0ACut); } - if (eventCuts[kUseTVXinTRD]) - histos.fill(HIST("hEventCount"), kUseTVXinTRD); - return 1; + return true; } - void process(AodCollisions::iterator const& collision, aod::BCsWithTimestamps const&, AodTracksWithoutBayes const& tracks) + void processGFW(AodCollisions::iterator const& collision, aod::BCsWithTimestamps const&, AodTracksWithoutBayes const& tracks) { - int nTot = tracks.size(); - if (nTot < 1) + if (tracks.size() < 1) { return; + } - float lRandom = fRndm->Rndm(); - float vtxz = collision.posZ(); - const auto cent = collision.centFT0C(); + auto bc = collision.bc_as(); + float cent = EvSels.cfgCentTableUnavailable ? -1.f : getCentrality(collision); - if (!selectionEvent(collision, nTot, cent)) + if (!selectionEvent(collision, tracks.size(), cent, true)) { return; + } - auto bc = collision.bc_as(); int runNumber = bc.runNumber(); - if (cfgOutputRunByRun && runNumber != lastRunNumer) { + if (Weights.cfgOutputRunByRun && runNumber != lastRunNumer) { lastRunNumer = runNumber; if (std::find(runNumbers.begin(), runNumbers.end(), runNumber) == runNumbers.end()) { // if run number is not in the preconfigured list, create new output histograms for this run @@ -906,15 +1272,20 @@ struct FlowPbpbPikp { } } - histos.fill(HIST("hVtxZ"), vtxz); - histos.fill(HIST("hMult"), nTot); - histos.fill(HIST("hCent"), cent); - histos.fill(HIST("globalTracks_centT0C"), cent, nTot); fGFW->Clear(); - float weff = 1; - int pidIndex; - loadCorrections(bc); // load corrections for the each event + loadCorrections(bc.timestamp()); // load corrections for each event + if (!EvSels.cfgCentTableUnavailable) { + histos.fill(HIST("hCent"), cent); + } + histos.fill(HIST("hNch"), tracks.size()); + histos.fill(HIST("hVtxZ"), collision.posZ()); + + auto multiplicity = static_cast(tracks.size()); + if (GeneralConfigs.cfgStrictTrackCounter) { + nchCounter(tracks, multiplicity); + } + histos.fill(HIST("hNchCorrected"), multiplicity); // Track loop for calculating the Qn angles double psi2Est = 0, psi3Est = 0, psi4Est = 0; @@ -922,12 +1293,12 @@ struct FlowPbpbPikp { double v2 = 0, v3 = 0, v4 = 0; // be cautious, this only works for Pb-Pb // esimate the Qn angles and vn for this event - if (cfgTrackDensityCorrUse) { + if (TrkDensCorr.cfgTrackDensityCorrUse) { double q2x = 0, q2y = 0; double q3x = 0, q3y = 0; double q4x = 0, q4y = 0; for (const auto& track : tracks) { - bool withinPtRef = (cfgCutPtMin < track.pt()) && (track.pt() < cfgCutPtMax); // within RF pT range + bool withinPtRef = (GeneralConfigs.cfgRefPtMin < track.pt()) && (track.pt() < GeneralConfigs.cfgRefPtMax); // within RF pT range if (withinPtRef) { q2x += std::cos(2 * track.phi()); q2y += std::sin(2 * track.phi()); @@ -946,46 +1317,70 @@ struct FlowPbpbPikp { v4 = funcV4->Eval(cent); } + double fSampleIndex = fRandom->Rndm(); + auto eventClass = (EvSels.cfgUseNch) ? multiplicity : cent; + // Actual track loop for (auto const& track : tracks) { - if (!selectionTrack(track)) + if (!trackSelected(track)) { continue; + } - double pt = track.pt(); - histos.fill(HIST("hPhi"), track.phi()); - histos.fill(HIST("hEta"), track.eta()); - histos.fill(HIST("hPt"), pt); + // Defining the pT regions for POI and REF + bool withinPtPOI = (GeneralConfigs.cfgCutPtPOIMin < track.pt()) && (track.pt() < GeneralConfigs.cfgCutPtPOIMax); // within POI pT range + bool withinPtRef = (GeneralConfigs.cfgRefPtMin < track.pt()) && (track.pt() < GeneralConfigs.cfgRefPtMax); // within RF pT range - histos.fill(HIST("TpcdEdx"), pt, track.tpcSignal()); - histos.fill(HIST("TofBeta"), pt, track.beta()); + if (!withinPtPOI && !withinPtRef) { + continue; + } - histos.fill(HIST("TofTpcNsigma_before"), PIONS, track.tpcNSigmaPi(), track.tofNSigmaPi(), pt); - histos.fill(HIST("TofTpcNsigma_before"), KAONS, track.tpcNSigmaKa(), track.tofNSigmaKa(), pt); - histos.fill(HIST("TofTpcNsigma_before"), PROTONS, track.tpcNSigmaPr(), track.tofNSigmaPr(), pt); + // Initializing weff for each track + float weff = 1.0; + float weffPIDPOI = 1.0; + if (!Weights.cfgEfficiency.value.empty()) { + getEfficiencyCorrection(weff, track.pt()); + } - histos.fill(HIST("TofItsNsigma_before"), PIONS, itsResponse.nSigmaITS(track), track.tofNSigmaPi(), pt); - histos.fill(HIST("TofItsNsigma_before"), KAONS, itsResponse.nSigmaITS(track), track.tofNSigmaKa(), pt); - histos.fill(HIST("TofItsNsigma_before"), PROTONS, itsResponse.nSigmaITS(track), track.tofNSigmaPr(), pt); + // Get acceptance weights for reference and charged particles + double waccRef = (!mAcceptance.empty()) ? getAcceptance(track, cent, collision.posZ(), UseRef) : 1.0; + double waccChargedPOI = (!mAcceptance.empty()) ? getAcceptance(track, cent, collision.posZ(), UseCharged) : 1.0; - bool withinPtPOI = (cfgCutPtPOIMin < pt) && (pt < cfgCutPtPOIMax); // within POI pT range - bool withinPtRef = (cfgCutPtMin < pt) && (pt < cfgCutPtMax); // within RF pT range + // Filling QA histograms + if (GeneralConfigs.cfgQABasic) { + fillTrackQA(track, UseCharged, eventClass, Before, weff, waccChargedPOI); // Fills track properties for all charged particles + } - pidIndex = cfgUseAsymmetricPID ? getNsigmaPIDAssymmetric(track) : getNsigmaPIDTpcTof(track); + if (PIDConfigs.cfgQANsigma) { + fillPIDQA(track, UsePions, eventClass, Before); // Fills Nsigma histograms for pions before PID selection + fillPIDQA(track, UseKaons, eventClass, Before); // Fills Nsigma histograms for kaons before PID selection + fillPIDQA(track, UseProtons, eventClass, Before); // Fills Nsigma histograms for protons before PID selection + } - weff = 1; // Initializing weff for each track - // NUA weights - if (cfgOutputNUAWeights) - fillWeights(track, collision, pidIndex, runNumber); + // Select track as PID particle + int pidIndex = getNsigmaPID(track); - if (!withinPtPOI && !withinPtRef) - return; - double waccRef = getAcceptance(track, collision, 0); - double waccPOI = withinPtPOI ? getAcceptance(track, collision, pidIndex + 1) : getAcceptance(track, collision, 0); - if (withinPtRef && withinPtPOI && pidIndex) - waccRef = waccPOI; // if particle is both (then it's overlap), override ref with POI + double waccPIDPOI = (!mAcceptance.empty()) ? getAcceptance(track, cent, collision.posZ(), pidIndex) : 1.0; + if (withinPtRef && withinPtPOI && (pidIndex > UseCharged)) { + waccRef = waccPIDPOI; // if particle is both (then it's overlap), override ref with POI + } + + // Filling QA histograms for PID particles after PID selection + if (pidIndex > UseCharged) { + if (GeneralConfigs.cfgQABasic) { + fillTrackQA(track, pidIndex, eventClass, After, weffPIDPOI, waccPIDPOI); // Fills track properties and Nsigma histograms + } + if (PIDConfigs.cfgQANsigma) { + fillPIDQA(track, pidIndex, eventClass, After); + } + } + + // Fill histograms for NUA weights + if (Weights.cfgOutputNUAWeights) { + fillWeights(track, cent, collision.posZ(), pidIndex, runNumber); + } // Track density correction - if (cfgTrackDensityCorrUse && withinPtRef) { + if (TrkDensCorr.cfgTrackDensityCorrUse && withinPtRef) { double fphi = v2 * std::cos(2 * (track.phi() - psi2Est)) + v3 * std::cos(3 * (track.phi() - psi3Est)) + v4 * std::cos(4 * (track.phi() - psi4Est)); fphi = (1 + 2 * fphi); int pTBinForEff = hFindPtBin->FindBin(track.pt()); @@ -998,41 +1393,139 @@ struct FlowPbpbPikp { } } // end of track density correction loop + auto ptBin = fPtAxis->FindBin(track.pt()) - 1; + + // Filling GFW if (withinPtRef) { - histos.fill(HIST("hPhiWeighted"), track.phi(), waccRef); - fGFW->Fill(track.eta(), fPtAxis->FindBin(pt) - 1, track.phi(), waccRef * weff, 1); + fGFW->Fill(track.eta(), ptBin, track.phi(), waccRef * weff, 1); } if (withinPtPOI) { - fGFW->Fill(track.eta(), fPtAxis->FindBin(pt) - 1, track.phi(), waccPOI * weff, 128); + fGFW->Fill(track.eta(), ptBin, track.phi(), waccChargedPOI * weff, 128); } if (withinPtPOI && withinPtRef) { - fGFW->Fill(track.eta(), fPtAxis->FindBin(pt) - 1, track.phi(), waccPOI * weff, 256); + fGFW->Fill(track.eta(), ptBin, track.phi(), waccChargedPOI * weff, 256); } - if (pidIndex) { - fillQA(collision, track, pidIndex, waccPOI); - if (withinPtPOI) - fGFW->Fill(track.eta(), fPtAxis->FindBin(pt) - 1, track.phi(), waccPOI * weff, 1 << (pidIndex)); - if (withinPtPOI && withinPtRef) - fGFW->Fill(track.eta(), fPtAxis->FindBin(pt) - 1, track.phi(), waccPOI * weff, 1 << (pidIndex + 3)); + if (pidIndex > UseCharged) { + if (withinPtPOI) { + fGFW->Fill(track.eta(), ptBin, track.phi(), waccPIDPOI * weff, 1 << (pidIndex)); + } + if (withinPtPOI && withinPtRef) { + fGFW->Fill(track.eta(), ptBin, track.phi(), waccPIDPOI * weff, 1 << (pidIndex + 3)); + } } } // track loop ends - // Filling cumulants with ROOT TProfile - fillProfile(corrconfigs.at(0), HIST("c22_full_ch"), cent); - fillProfile(corrconfigs.at(0), HIST("c22_full_ch_Nch"), nTot); + // Filling FlowContainer + for (auto corrconfig : corrConfigs) { + fillFC(corrconfig, eventClass, fSampleIndex); + } + } // end of process + PROCESS_SWITCH(FlowPbpbPikp, processGFW, "Process for GFW flow analysis", true); + + void processPIDQA(AodCollisions::iterator const& collision, aod::BCsWithTimestamps const&, AodTracksWithoutBayes const& tracks) + { + if (tracks.size() < 1) { + return; + } + + auto bc = collision.bc_as(); + float cent = EvSels.cfgCentTableUnavailable ? -1.f : getCentrality(collision); - if (!cfgUseNch) { - for (uint l_ind = 0; l_ind < corrconfigs.size(); l_ind++) { - fillFC(corrconfigs.at(l_ind), cent, lRandom); + if (!selectionEvent(collision, tracks.size(), cent, true)) { + return; + } + + loadCorrections(bc.timestamp()); // load corrections for each event + + auto multiplicity = static_cast(tracks.size()); + if (GeneralConfigs.cfgStrictTrackCounter) { + nchCounter(tracks, multiplicity); + } + + auto eventClass = (EvSels.cfgUseNch) ? multiplicity : cent; + + for (auto const& track : tracks) { + if (!trackSelected(track)) { + continue; } - } else { - for (uint l_ind = 0; l_ind < corrconfigs.size(); l_ind++) { - fillFC(corrconfigs.at(l_ind), nTot, lRandom); + + fillPIDQA(track, UsePions, eventClass, Before); // Fills Nsigma histograms for pions before PID selection + fillPIDQA(track, UseKaons, eventClass, Before); // Fills Nsigma histograms for kaons before PID selection + fillPIDQA(track, UseProtons, eventClass, Before); // Fills Nsigma histograms for protons before PID selection + + // Select track as PID particle + int pidIndex = getNsigmaPID(track); + + if (pidIndex > UseCharged) { + fillPIDQA(track, pidIndex, eventClass, After); } + + } // track loop ends + } // end of processPIDQA + + PROCESS_SWITCH(FlowPbpbPikp, processPIDQA, "Process for PID related QA production", true); + + void processMCPID(AodCollisions::iterator const& collision, aod::BCsWithTimestamps const&, AodTracksMcLabels const& tracksmc, aod::McParticles const&) + { + auto bc = collision.bc_as(); + float cent = EvSels.cfgCentTableUnavailable ? -1.f : getCentrality(collision); + + if (!selectionEvent(collision, tracksmc.size(), cent, true)) { + return; } - } // end of process + loadCorrections(bc.timestamp()); // load corrections for each event + + auto multiplicity = static_cast(tracksmc.size()); + if (GeneralConfigs.cfgStrictTrackCounter) { + nchCounter(tracksmc, multiplicity); + } + + auto eventClass = (EvSels.cfgUseNch) ? multiplicity : cent; + + // loop over all tracks + for (auto const& track : tracksmc) { + + if (!trackSelected(track)) { + continue; + } + + int pdgIndex = -1; + if (std::abs(track.mcParticle().pdgCode()) == PDG_t::kPiPlus) { + pdgIndex = UsePions; + } else if (std::abs(track.mcParticle().pdgCode()) == PDG_t::kKPlus) { + pdgIndex = UseKaons; + } else if (std::abs(track.mcParticle().pdgCode()) == PDG_t::kProton) { + pdgIndex = UseProtons; + } else { + pdgIndex = -1; + } + + // Fill Counts for MC true particles + if (pdgIndex > UseCharged) { + histos.fill(HIST("hNAllTrues"), eventClass, track.pt(), pdgIndex); + } + + int pidIndex = getNsigmaPID(track); + // Fill Counts for selection through Nsigma cuts + if (pidIndex > UseCharged) { + histos.fill(HIST("hNAllPositives"), eventClass, track.pt(), pidIndex); + + // Fill Counts for selected particles if it matches their PDG particle + if (pidIndex == pdgIndex) { + histos.fill(HIST("hNTruePositives"), eventClass, track.pt(), pidIndex); + } + } + + if (track.mcParticle().isPhysicalPrimary()) { + histos.fill(HIST("TpcdEdx_AllPositives_physprim"), track.tpcSignal(), track.beta(), track.pt(), pidIndex); + histos.fill(HIST("TpcdEdx_AllTrues_physprim"), track.tpcSignal(), track.beta(), track.pt(), pdgIndex); + } + + } // end of tracks MC loop + } + PROCESS_SWITCH(FlowPbpbPikp, processMCPID, "Process for MC PID QA production", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) From 1f76a3208863bd4753b983fa49031aa601423488 Mon Sep 17 00:00:00 2001 From: Preet Pati Date: Mon, 23 Nov 2026 11:40:45 +0100 Subject: [PATCH 2/3] Modified C-style (*void) to static_cast to pass MegaLinter check --- PWGCF/Flow/Tasks/flowPbpbPikp.cxx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/PWGCF/Flow/Tasks/flowPbpbPikp.cxx b/PWGCF/Flow/Tasks/flowPbpbPikp.cxx index 3eab96b93ad..aafb5d9760d 100644 --- a/PWGCF/Flow/Tasks/flowPbpbPikp.cxx +++ b/PWGCF/Flow/Tasks/flowPbpbPikp.cxx @@ -813,37 +813,37 @@ struct FlowPbpbPikp { // Charged particles mAcceptance[UseCharged] = ccdb->getForTimeStamp(Weights.cfgAcceptance.value + "_ch", timestamp); if (mAcceptance[UseCharged]) { - LOGF(info, "Loaded acceptance weights from %s_ch (%p)", Weights.cfgAcceptance.value.c_str(), (void*)mAcceptance[UseCharged]); + LOGF(info, "Loaded acceptance weights from %s_ch (%p)", Weights.cfgAcceptance.value.c_str(), static_cast(mAcceptance[UseCharged])); } else { - LOGF(fatal, "Could not load acceptance weights from %s_ch (%p)", Weights.cfgAcceptance.value.c_str(), (void*)mAcceptance[UseCharged]); + LOGF(fatal, "Could not load acceptance weights from %s_ch (%p)", Weights.cfgAcceptance.value.c_str(), static_cast(mAcceptance[UseCharged])); } // Pions mAcceptance[UsePions] = ccdb->getForTimeStamp(Weights.cfgAcceptance.value + "_pi", timestamp); if (mAcceptance[UsePions]) { - LOGF(info, "Loaded acceptance weights from %s_pi (%p)", Weights.cfgAcceptance.value.c_str(), (void*)mAcceptance[UsePions]); + LOGF(info, "Loaded acceptance weights from %s_pi (%p)", Weights.cfgAcceptance.value.c_str(), static_cast(mAcceptance[UsePions])); } else { - LOGF(fatal, "Could not load acceptance weights from %s_pi (%p)", Weights.cfgAcceptance.value.c_str(), (void*)mAcceptance[UsePions]); + LOGF(fatal, "Could not load acceptance weights from %s_pi (%p)", Weights.cfgAcceptance.value.c_str(), static_cast(mAcceptance[UsePions])); } // Kaons mAcceptance[UseKaons] = ccdb->getForTimeStamp(Weights.cfgAcceptance.value + "_ka", timestamp); if (mAcceptance[UseKaons]) { - LOGF(info, "Loaded acceptance weights from %s_ka (%p)", Weights.cfgAcceptance.value.c_str(), (void*)mAcceptance[UseKaons]); + LOGF(info, "Loaded acceptance weights from %s_ka (%p)", Weights.cfgAcceptance.value.c_str(), static_cast(mAcceptance[UseKaons])); } else { - LOGF(fatal, "Could not load acceptance weights from %s_ka (%p)", Weights.cfgAcceptance.value.c_str(), (void*)mAcceptance[UseKaons]); + LOGF(fatal, "Could not load acceptance weights from %s_ka (%p)", Weights.cfgAcceptance.value.c_str(), static_cast(mAcceptance[UseKaons])); } // Protons mAcceptance[UseProtons] = ccdb->getForTimeStamp(Weights.cfgAcceptance.value + "_pr", timestamp); if (mAcceptance[UseProtons]) { - LOGF(info, "Loaded acceptance weights from %s_pr (%p)", Weights.cfgAcceptance.value.c_str(), (void*)mAcceptance[UseProtons]); + LOGF(info, "Loaded acceptance weights from %s_pr (%p)", Weights.cfgAcceptance.value.c_str(), static_cast(mAcceptance[UseProtons])); } else { - LOGF(fatal, "Could not load acceptance weights from %s_pr (%p)", Weights.cfgAcceptance.value.c_str(), (void*)mAcceptance[UseProtons]); + LOGF(fatal, "Could not load acceptance weights from %s_pr (%p)", Weights.cfgAcceptance.value.c_str(), static_cast(mAcceptance[UseProtons])); } // Reference charged particles mAcceptance[UseRef] = ccdb->getForTimeStamp(Weights.cfgAcceptance.value + "_ref", timestamp); if (mAcceptance[UseRef]) { - LOGF(info, "Loaded acceptance weights from %s_ref (%p)", Weights.cfgAcceptance.value.c_str(), (void*)mAcceptance[UseRef]); + LOGF(info, "Loaded acceptance weights from %s_ref (%p)", Weights.cfgAcceptance.value.c_str(), static_cast(mAcceptance[UseRef])); } else { - LOGF(fatal, "Could not load acceptance weights from %s_ref (%p)", Weights.cfgAcceptance.value.c_str(), (void*)mAcceptance[UseRef]); + LOGF(fatal, "Could not load acceptance weights from %s_ref (%p)", Weights.cfgAcceptance.value.c_str(), static_cast(mAcceptance[UseRef])); } } correctionsLoaded = true; From fd599998a7e827487a749ef5f4949c8a30d20865 Mon Sep 17 00:00:00 2001 From: Preet Pati Date: Mon, 23 Nov 2026 14:17:28 +0100 Subject: [PATCH 3/3] Fixing the code-check errors --- PWGCF/Flow/Tasks/flowPbpbPikp.cxx | 70 +++++++++++++++---------------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/PWGCF/Flow/Tasks/flowPbpbPikp.cxx b/PWGCF/Flow/Tasks/flowPbpbPikp.cxx index aafb5d9760d..25c0a4c9c31 100644 --- a/PWGCF/Flow/Tasks/flowPbpbPikp.cxx +++ b/PWGCF/Flow/Tasks/flowPbpbPikp.cxx @@ -19,7 +19,6 @@ #include "PWGCF/GenericFramework/Core/GFWWeights.h" #include "Common/CCDB/EventSelectionParams.h" -#include "Common/CCDB/TriggerAliases.h" #include "Common/Core/RecoDecay.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" @@ -34,12 +33,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include #include @@ -73,13 +72,7 @@ using namespace o2::framework; using namespace o2::framework::expressions; using namespace constants::math; -#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, DEFAULT, HELP}; - -namespace o2::analysis::genericframework -{ -GFWRegions regions; -GFWCorrConfigs configs; -} // namespace o2::analysis::genericframework +#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable NAME{#NAME, (DEFAULT), (HELP)}; // NOLINT(bugprone-macro-parentheses) using namespace o2::analysis::genericframework; @@ -100,7 +93,7 @@ static constexpr std::array, 20> LongArrayInt = {{{{1, 2, 3}} struct FlowPbpbPikp { o2::aod::ITSResponse itsResponse; - Service ccdb; + Service ccdb{}; struct : ConfigurableGroup { std::string prefix = "GeneralConfigs"; @@ -229,8 +222,13 @@ struct FlowPbpbPikp { ConfigurableAxis axisSigma{"axisSigma", {200, 0, 20}, "sigma axis for TPC"}; ConfigurableAxis axisPIDParticles{"axisPIDParticles", {3, 0.5, 3.5}, "particle axis for PID QA (pi, ka, pr)"}; + struct GFWMemberCache { + GFWRegions regions; + GFWCorrConfigs configs; + } GfwMemberCache; + Filter collisionFilter = (nabs(aod::collision::posZ) < EvSels.cfgGlobalCutVertex); - Filter trackFilter = (nabs(aod::track::eta) < TrkSels.cfgGlobalEta) && (aod::track::pt > TrkSels.cfgGlobalPtMin) && (aod::track::pt < TrkSels.cfgGlobalPtMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t)true)) && (aod::track::tpcChi2NCl < TrkSels.cfgGlobalChi2prTPCcls) && (nabs(aod::track::dcaZ) < TrkSels.cfgGlobalDCAz); + Filter trackFilter = (nabs(aod::track::eta) < TrkSels.cfgGlobalEta) && (aod::track::pt > TrkSels.cfgGlobalPtMin) && (aod::track::pt < TrkSels.cfgGlobalPtMax) && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == static_cast(1))) && (aod::track::tpcChi2NCl < TrkSels.cfgGlobalChi2prTPCcls) && (nabs(aod::track::dcaZ) < TrkSels.cfgGlobalDCAz); using AodCollisions = soa::Filtered>; using AodTracksWithoutBayes = soa::Filtered>; @@ -374,17 +372,17 @@ struct FlowPbpbPikp { ccdb->setCreatedNotAfter(now); LOGF(info, "flowGenericFramework::init()"); - regions.SetNames(cfgRegions->GetNames()); - regions.SetEtaMin(cfgRegions->GetEtaMin()); - regions.SetEtaMax(cfgRegions->GetEtaMax()); - regions.SetpTDifs(cfgRegions->GetpTDifs()); - regions.SetBitmasks(cfgRegions->GetBitmasks()); - configs.SetCorrs(cfgCorrConfig->GetCorrs()); - configs.SetHeads(cfgCorrConfig->GetHeads()); - configs.SetpTDifs(cfgCorrConfig->GetpTDifs()); - configs.SetpTCorrMasks(cfgCorrConfig->GetpTCorrMasks()); - regions.Print(); - configs.Print(); + GfwMemberCache.regions.SetNames(cfgRegions->GetNames()); + GfwMemberCache.regions.SetEtaMin(cfgRegions->GetEtaMin()); + GfwMemberCache.regions.SetEtaMax(cfgRegions->GetEtaMax()); + GfwMemberCache.regions.SetpTDifs(cfgRegions->GetpTDifs()); + GfwMemberCache.regions.SetBitmasks(cfgRegions->GetBitmasks()); + GfwMemberCache.configs.SetCorrs(cfgCorrConfig->GetCorrs()); + GfwMemberCache.configs.SetHeads(cfgCorrConfig->GetHeads()); + GfwMemberCache.configs.SetpTDifs(cfgCorrConfig->GetpTDifs()); + GfwMemberCache.configs.SetpTCorrMasks(cfgCorrConfig->GetpTCorrMasks()); + GfwMemberCache.regions.Print(); + GfwMemberCache.configs.Print(); // Axis definitions std::string hCentTitle = "Centrality distribution, Estimator " + std::to_string(EvSels.cfgCentEstimator); @@ -472,31 +470,31 @@ struct FlowPbpbPikp { o2::framework::AxisSpec axis = axisPtForCorr; int nPtBins = axis.binEdges.size() - 1; - double* ptBins = &(axis.binEdges)[0]; + double* ptBins = axis.binEdges.data(); fPtAxis = new TAxis(nPtBins, ptBins); // Iniitializing object for GFW auto* oba = new TObjArray(); // Defining the regions - for (auto i(0); i < regions.GetSize(); i++) { - fGFW->AddRegion(regions.GetNames().at(i), regions.GetEtaMin().at(i), regions.GetEtaMax().at(i), (regions.GetpTDifs().at(i)) ? nPtBins + 1 : 1, regions.GetBitmasks().at(i)); + for (auto i(0); i < GfwMemberCache.regions.GetSize(); i++) { + fGFW->AddRegion(GfwMemberCache.regions.GetNames().at(i), GfwMemberCache.regions.GetEtaMin().at(i), GfwMemberCache.regions.GetEtaMax().at(i), (GfwMemberCache.regions.GetpTDifs().at(i) != 0) ? nPtBins + 1 : 1, GfwMemberCache.regions.GetBitmasks().at(i)); } // Defining the correlators std::string suffix = "_ptDiff"; - for (auto i = 0; i < configs.GetSize(); i++) { - corrConfigs.push_back(fGFW->GetCorrelatorConfig(configs.GetCorrs().at(i), configs.GetHeads().at(i), configs.GetpTDifs().at(i))); - if (configs.GetpTDifs().at(i) != 0) { + for (auto i = 0; i < GfwMemberCache.configs.GetSize(); i++) { + corrConfigs.push_back(fGFW->GetCorrelatorConfig(GfwMemberCache.configs.GetCorrs().at(i), GfwMemberCache.configs.GetHeads().at(i), GfwMemberCache.configs.GetpTDifs().at(i))); + if (GfwMemberCache.configs.GetpTDifs().at(i) != 0) { for (auto j = 1; j <= nPtBins; j++) { std::string index = Form("_pt_%i", j); - oba->Add(new TNamed(configs.GetHeads().at(i) + index, configs.GetHeads().at(i) + suffix)); - std::string corrName = configs.GetHeads().at(i) + index; + oba->Add(new TNamed(GfwMemberCache.configs.GetHeads().at(i) + index, GfwMemberCache.configs.GetHeads().at(i) + suffix)); + std::string corrName = GfwMemberCache.configs.GetHeads().at(i) + index; LOGF(info, Form("Correlator to be calculated: %s", corrName.c_str())); } } else { - oba->Add(new TNamed(configs.GetHeads().at(i), configs.GetHeads().at(i))); - LOGF(info, Form("Correlator to be calculated: %s", configs.GetHeads().at(i).c_str())); + oba->Add(new TNamed(GfwMemberCache.configs.GetHeads().at(i), GfwMemberCache.configs.GetHeads().at(i))); + LOGF(info, Form("Correlator to be calculated: %s", GfwMemberCache.configs.GetHeads().at(i).c_str())); } } if (corrConfigs.empty()) { @@ -613,7 +611,7 @@ struct FlowPbpbPikp { if (TrkDensCorr.cfgTrackDensityCorrUse) { std::vector pTEffBins = {0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.4, 1.8, 2.2, 2.6, 3.0}; - hFindPtBin = new TH1D("hFindPtBin", "hFindPtBin", pTEffBins.size() - 1, &pTEffBins[0]); + hFindPtBin = new TH1D("hFindPtBin", "hFindPtBin", pTEffBins.size() - 1, pTEffBins.data()); funcEff.resize(pTEffBins.size() - 1); // LHC24g3 Eff std::vector f1p0 = TrkDensCorr.cfgTrackDensityP0; @@ -1002,8 +1000,6 @@ struct FlowPbpbPikp { fillSingleContainer(corrconf, eventClass, i, rndm, name); } } - - return; } void createRunByRunHistos(int runNumber) @@ -1096,6 +1092,8 @@ struct FlowPbpbPikp { histos.fill(HIST("NUA/hPhiPtCent_pr"), track.phi(), track.pt(), cent); histos.fill(HIST("NUA/hPhiEtaPt_pr"), track.phi(), track.eta(), track.pt()); break; + default: + break; } } } @@ -1417,7 +1415,7 @@ struct FlowPbpbPikp { } // track loop ends // Filling FlowContainer - for (auto corrconfig : corrConfigs) { + for (auto const& corrconfig : corrConfigs) { fillFC(corrconfig, eventClass, fSampleIndex); } } // end of process