From b6e5472733c40aa9120ac21dc82c2a71647a14a2 Mon Sep 17 00:00:00 2001 From: Somadutta Bhatta Date: Mon, 10 Nov 2025 20:01:56 +0100 Subject: [PATCH 01/10] Add new task for RadialFlow Decorrelation --- PWGCF/EbyEFluctuations/Tasks/CMakeLists.txt | 5 + .../EbyEFluctuations/Tasks/RadFlowDecorr.cxx | 2289 +++++++++++++++++ 2 files changed, 2294 insertions(+) create mode 100644 PWGCF/EbyEFluctuations/Tasks/RadFlowDecorr.cxx diff --git a/PWGCF/EbyEFluctuations/Tasks/CMakeLists.txt b/PWGCF/EbyEFluctuations/Tasks/CMakeLists.txt index 2afcf9e4afc..b3e37d174d9 100644 --- a/PWGCF/EbyEFluctuations/Tasks/CMakeLists.txt +++ b/PWGCF/EbyEFluctuations/Tasks/CMakeLists.txt @@ -78,3 +78,8 @@ o2physics_add_dpl_workflow(part-num-fluc SOURCES partNumFluc.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2Physics::PWGCFCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(radial-flow-decorr + SOURCES RadFlowDecorr.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore + COMPONENT_NAME Analysis) diff --git a/PWGCF/EbyEFluctuations/Tasks/RadFlowDecorr.cxx b/PWGCF/EbyEFluctuations/Tasks/RadFlowDecorr.cxx new file mode 100644 index 00000000000..6a772048b30 --- /dev/null +++ b/PWGCF/EbyEFluctuations/Tasks/RadFlowDecorr.cxx @@ -0,0 +1,2289 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +/// \file RadFlowDecorr.cxx +/// \brief Task for Radial Flow Decorrelation Measurement +/// \author Somadutta Bhatta +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "TDirectory.h" +#include "TFile.h" +#include "TMath.h" +#include "TH1F.h" +#include "TH2F.h" +#include "TH3F.h" +#include "TProfile.h" +#include "TProfile2D.h" +#include "TProfile3D.h" + +#include "Framework/AnalysisTask.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/Configurable.h" +#include "Framework/Logger.h" + +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" +#include "Common/Core/trackUtilities.h" +#include "Common/Core/RecoDecay.h" +#include "DataFormatsParameters/GRPObject.h" +#include "CCDB/BasicCCDBManager.h" +#include "ReconstructionDataFormats/DCA.h" +#include "ReconstructionDataFormats/Track.h" +#include "ReconstructionDataFormats/TrackTPCITS.h" +#include "MathUtils/Utils.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Common/DataModel/Centrality.h" +#include +#include "Framework/Logger.h" +#include "Framework/HistogramRegistry.h" +#include "CommonConstants/MathConstants.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using namespace constants::math; + +struct RadFlowDecorr { + + static constexpr int KIntM = 3; + static constexpr int KIntK = 3; + // static constexpr int KNEta = 33; + static constexpr int KNEta = 17; + static constexpr int KNpT = 3; + + // --- Linter Fixes: Magic Numbers --- + static constexpr float kFloatEpsilon = 1e-6f; +// static constexpr int kPiPlus = o2::constants::physics::Pdg::kPiPlus; +//   static constexpr int kKPlus = o2::constants::physics::Pdg::kKaPlus; +//   static constexpr int kProton = o2::constants::physics::Pdg::kProton; + static constexpr float kCentTestMin = 10.f; + static constexpr float kCentTestMaxLo = 60.f; + static constexpr float kCentTestMaxHi = 70.f; + static constexpr float kCentCovCut = 1.0f; + static constexpr float kBinOffset = 0.5f; + static constexpr float kHalf = 0.5f; + // Histogram axis definitions + static constexpr int kNbinsZvtx = 240; + static constexpr float kZvtxMin = -12.f; + static constexpr float kZvtxMax = 12.f; + static constexpr int kNbinsP = 100; + static constexpr float kPMin = 0.f; + static constexpr float kPMax = 10.f; + static constexpr int kNbinsPt = 200; + static constexpr float kPtMin = 0.f; + static constexpr float kPtMax = 10.f; + static constexpr int kNbinsEta = 120; + static constexpr float kEtaMin = -1.2f; + static constexpr float kEtaMax = 1.2f; + static constexpr int kNbinsPhi = 64; + static constexpr float kEtaAxisMin = -0.8f; + static constexpr float kEtaAxisMax = 0.8f; + static constexpr int kNbinsPhiFine = 30; + static constexpr int kNbinsPtRes = 50; + static constexpr float kPtResMax = 1.f; + static constexpr int kNbinsEtaRes = 100; + static constexpr float kEtaResMax = 0.5f; + static constexpr int kNbinsVz = 80; + static constexpr float kVzMin = -40.f; + static constexpr float kVzMax = 40.f; + static constexpr float kVzResMax = 20.f; + static constexpr int kNbinsEtaFine = 20; + static constexpr float kEtaFineMax = 1.f; + static constexpr int kNbinsDca = 400; + static constexpr float kDcaMax = 0.2f; + static constexpr int kNbinsPtCoarse = 50; + + enum PID { kInclusive = 0, kCombinedPID, kNumPID }; + const std::vector pidSuffix = {"", "_PID"}; + + const std::vector etaLw = { + -0.8, + -0.8,-0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1, 0.0, 0.1,0.2, 0.3, 0.4, 0.5, 0.6,0.7}; + const std::vector etaUp = { + 0.8, + -0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8}; + + const std::vector pTLw = {0.2, 0.2, 0.2}; + const std::vector pTUp = {3, 5.0, 10.0}; + //============================== + // Configurables + //============================== + Configurable cfgVtxZCut{"cfgVtxZCut", 10.f, "z-vertex range"}; + Configurable cfgPtMin{"cfgPtMin", 0.2f, "min pT"}; + Configurable cfgPtMax{"cfgPtMax", 10.0f, "max pT"}; + Configurable cfgEtaCut{"cfgEtaCut", 0.8f, "|η| cut"}; + Configurable cfgDCAXY{"cfgDCAXY", 2.4f, "DCAxy cut"}; + Configurable cfgDCAZ{"cfgDCAZ", 3.2f, "DCAz cut"}; + Configurable cfgTPCClsMin{"cfgTPCClsMin", 70.f, "min TPC clusters"}; + Configurable cfgChi2TPCMax{"cfgChi2TPCMax", 4.0f, "max TPC χ²"}; + Configurable cfgPIDnSigmaCut{"cfgPIDnSigmaCut", 3.f, "TPC PID |nσ| cut"}; + + Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; + Configurable cfgCutTpcChi2NCl{"cfgCutTpcChi2NCl", 2.5f, "Maximum TPCchi2NCl"}; + Configurable cfgCutItsChi2NCl{"cfgCutItsChi2NCl", 36.0f, "Maximum ITSchi2NCl"}; + Configurable cfgCutTrackDcaZ{"cfgCutTrackDcaZ", 2.0f, "Maximum DcaZ"}; + Configurable cfgCutTrackDcaXY{"cfgCutTrackDcaXY", 0.2f, "Maximum DcaZ"}; + + Configurable cfgITScluster{"cfgITScluster", 1, "Minimum Number of ITS cluster"}; + Configurable cfgTPCcluster{"cfgTPCcluster", 80, "Minimum Number of TPC cluster"}; + Configurable cfgTPCnCrossedRows{"cfgTPCnCrossedRows", 70, "Minimum Number of TPC crossed-rows"}; + Configurable cfgCutPtUpperTPC{"cfgCutPtUpperTPC", 0.6f, "Upper pT cut for PID using TPC only"}; + Configurable cfgnSigmaOtherParticles{"cfgnSigmaOtherParticles", 3.0f, "PID nSigma cut to remove other particles (default:3)"}; + Configurable cfgnSigmaCutTPC{"cfgnSigmaCutTPC", 2.0f, "PID nSigma cut for TPC"}; + Configurable cfgnSigmaCutTOF{"cfgnSigmaCutTOF", 2.0f, "PID nSigma cut for TOF"}; + Configurable cfgnSigmaCutCombTPCTOF{"cfgnSigmaCutCombTPCTOF", 2.0f, "PID nSigma combined cut for TPC and TOF"}; + Configurable cfgCutPtLower{"cfgCutPtLower", 0.2f, "Lower pT cut"}; + Configurable cfgCutPtLowerProt{"cfgCutPtLowerProt", 0.2f, "Lower pT cut"}; + Configurable cfgCutPtUpper{"cfgCutPtUpper", 10.0f, "Higher pT cut for inclusive hadron analysis"}; + Configurable cfgCutPtUpperPID{"cfgCutPtUpperPID", 6.0f, "Higher pT cut for identified particle analysis"}; + Configurable cfgCutEta{"cfgCutEta", 0.8f, "absolute Eta cut"}; + Configurable cfgCutEtaLeft{"cfgCutEtaLeft", 0.8f, "Left end of eta gap"}; + Configurable cfgCutEtaRight{"cfgCutEtaRight", 0.8f, "Right end of eta gap"}; + Configurable cfgNSubsample{"cfgNSubsample", 10, "Number of subsamples"}; + Configurable cfgCentralityChoice{"cfgCentralityChoice", 1, "Which centrality estimator? 1-->FT0C, 2-->FT0A, 3-->FT0M, 4-->FV0A"}; + Configurable cfgEvSelkNoSameBunchPileup{"cfgEvSelkNoSameBunchPileup", true, "Pileup removal"}; + Configurable cfgUseGoodITSLayerAllCut{"cfgUseGoodITSLayerAllCut", true, "Remove time interval with dead ITS zone"}; + Configurable cfgEvSelkNoITSROFrameBorder{"cfgEvSelkNoITSROFrameBorder", true, "ITSROFrame border event selection cut"}; + Configurable cfgEvSelkNoTimeFrameBorder{"cfgEvSelkNoTimeFrameBorder", true, "TimeFrame border event selection cut"}; + + + //============================== + // Services and registry + //============================== + Service ccdb; + Service pdg; + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + //============================== + // External objects (shared across processes) + //============================== + // ### MODIFICATION ### + // Store maps in arrays, one for each PID type (kInclusive, kCombinedPID) + std::array hEff{}; + std::array hFake{}; + std::array hWeightMap3D{}; // (cent, eta, phi) + // #################### + // mean pT / Et profiles loaded in init() + // --- pT Profiles --- + TProfile3D* pmeanTruNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanRecoNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanRecoMatchedNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanRecoEffcorrNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanRecoMatchedEffcorrNchEtabinPtbinStep2 = nullptr; + // --- Et Profiles --- + TProfile3D* pmeanEtTruNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanEtRecoNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanEtRecoMatchedNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanEtRecoEffcorrNchEtabinPtbinStep2 = nullptr; // This one was already here + TProfile3D* pmeanEtRecoMatchedEffcorrNchEtabinPtbinStep2 = nullptr; + // --- Data Profiles --- + TProfile3D* pmeanNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanEtNchEtabinPtbinStep2 = nullptr; + //============================== + // Basic helpers + //============================== + // Line 131 + template bool isEventSelected(const T& col) { + if (!col.sel8()) return false; + if (std::abs(col.posZ()) > cfgCutVertex) return false; + if (cfgEvSelkNoSameBunchPileup && !col.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) return false; + if (cfgEvSelkNoITSROFrameBorder && !col.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) return false; + if (cfgEvSelkNoTimeFrameBorder && !col.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) return false; + return true; + } + + + // Line 137 + template bool isTrackSelected(const T& trk) { + if (trk.sign() == 0) return false; + if (!trk.has_collision()) return false; + if (!trk.isPVContributor()) return false; + if (!(trk.itsNCls() > cfgITScluster)) return false; + if (!(trk.tpcNClsFound() >= cfgTPCcluster)) return false; + if (!(trk.tpcNClsCrossedRows() >= cfgTPCnCrossedRows)) return false; + + if (trk.pt() < cfgCutPtLower || trk.pt() > cfgCutPtUpper || std::abs(trk.eta()) > cfgCutEta) return false; + if (std::abs(trk.dcaXY()) > cfgCutTrackDcaXY || std::abs(trk.dcaZ()) > cfgCutTrackDcaZ) return false; + return true; + } + + template + bool isParticleSelected(const T& particle) + { + auto* pd = pdg->GetParticle(particle.pdgCode()); + if (!pd) return false; + // if (dpt::isStrangeBaryonPDG(particle.pdgCode())) return false; + if (std::abs(pd->Charge()) ==0) return false; + if (particle.pt() < cfgCutPtLower || particle.pt() > cfgCutPtUpper || std::abs(particle.eta()) > cfgCutEta) return false; + if (std::abs(particle.vz()) > cfgCutVertex) return false; + return true; + } + + // + // // Lines 153-155 + // template bool selectionPion (const T& trk) { return std::abs(trk.tpcNSigmaPi()) < cfgPIDnSigmaCut; } + // template bool selectionKaon (const T& trk) { return std::abs(trk.tpcNSigmaKa()) < cfgPIDnSigmaCut; } + // template bool selectionProton(const T& trk) { return std::abs(trk.tpcNSigmaPr()) < cfgPIDnSigmaCut; } + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + template + bool selectionProton(const T& candidate) + { + if (!candidate.hasTPC()) + return false; + int flag = 0; //! pid check main flag + + if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC) { + flag = 1; + } + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaPr()) < cfgnSigmaCutTOF) { + flag = 1; + } + } + if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { + float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); + float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); + float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); + + int flag2 = 0; + if (combNSigmaPr < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaPi < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaKa < cfgnSigmaOtherParticles) + flag2 += 1; + if (!(flag2 > 1) && !(combNSigmaPr > combNSigmaPi) && !(combNSigmaPr > combNSigmaKa)) { + if (combNSigmaPr < cfgnSigmaCutCombTPCTOF) { + flag = 1; + } + } + } + if (flag == 1) + return true; + else + return false; + } + + template + bool selectionPion(const T& candidate) + { + if (!candidate.hasTPC()) + return false; + int flag = 0; //! pid check main flag + + if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < cfgnSigmaCutTPC) { + flag = 1; + } + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaPi()) < cfgnSigmaCutTOF) { + flag = 1; + } + } + if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { + float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); + float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); + float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); + + int flag2 = 0; + if (combNSigmaPr < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaPi < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaKa < cfgnSigmaOtherParticles) + flag2 += 1; + if (!(flag2 > 1) && !(combNSigmaPi > combNSigmaPr) && !(combNSigmaPi > combNSigmaKa)) { + if (combNSigmaPi < cfgnSigmaCutCombTPCTOF) { + flag = 1; + } + } + } + if (flag == 1) + return true; + else + return false; + } + + template + bool selectionKaon(const T& candidate) + { + if (!candidate.hasTPC()) + return false; + int flag = 0; //! pid check main flag + + if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < cfgnSigmaCutTPC) { + flag = 1; + } + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaKa()) < cfgnSigmaCutTOF) { + flag = 1; + } + } + if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { + float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); + float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); + float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); + + int flag2 = 0; + if (combNSigmaPr < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaPi < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaKa < cfgnSigmaOtherParticles) + flag2 += 1; + if (!(flag2 > 1) && !(combNSigmaKa > combNSigmaPi) && !(combNSigmaKa > combNSigmaPr)) { + if (combNSigmaKa < cfgnSigmaCutCombTPCTOF) { + flag = 1; + } + } + } + if (flag == 1) + return true; + else + return false; + } + + + // Utility helpers + //============================== + float getCentrality(const auto& col) const { + if (cfgCentralityChoice.value == 1) return col.centFT0C(); + if (cfgCentralityChoice.value == 2) return col.centFT0A(); + if (cfgCentralityChoice.value == 3) return col.centFT0M(); + if (cfgCentralityChoice.value == 4) return col.centFV0A(); + return -1.0f; + } + // + float getEfficiency(float mult, float pt, float eta, PID pidType, int effidx) const { + TH3F* h; + if(effidx==0) h = hEff[pidType]; + if(effidx==1) h = hFake[pidType]; + + if (!h) return -1; + const int ibx = h->GetXaxis()->FindBin(mult); + const int iby = h->GetYaxis()->FindBin(pt); + const int ibz = h->GetZaxis()->FindBin(eta); + float val = h->GetBinContent(ibx, iby, ibz); + return val; + } + + /* + float getEfficiency(float mult, float pt, float eta, PID pidType, int effidx) const { + TH3F* h; + if(effidx==0) h = hEff[pidType]; // Efficiency map + if(effidx==1) h = hFake[pidType]; // Fake map + + if (!h) { + LOGF(error, "getEfficiency: Histogram is null for pidType %d, effidx %d", pidType, effidx); + return -1.0; + } + + const int ibx = h->GetXaxis()->FindBin(mult); + const int iby = h->GetYaxis()->FindBin(pt); + const int ibz = h->GetZaxis()->FindBin(eta); + float val = h->GetBinContent(ibx, iby, ibz); + + if (effidx == 1) { // This is a FAKE map + // For fakes, "it's ok if it is zero" + // But it's not ok if it's < 0 or >= 1. Set those to 0. + if (val < 0.f || val >= 1.0) { + return -1; + } + return val; // Return the valid fake value (which can be 0) +} + +// If we are here, this is an EFFICIENCY map (effidx == 0) +// For efficiency, "it's ok if it is 1" +// "but not vice versa" (i.e., val <= 0 is the problem) + +if (val > 0.f || val<1.1) { +// val > 0 is valid (including 1.0). +return val; +} + +// --- PROBLEM CASE: val <= 0. We must interpolate. --- +// We will scan along the pT axis (iby) to find neighbors + +// 1. Find bin "before" (lower pT) +int yBinBefore = iby - 1; +float valBefore = 0.f; +while (yBinBefore >= 1) { +valBefore = h->GetBinContent(ibx, yBinBefore, ibz); +if (valBefore > 0.f) break; // Found a valid bin +yBinBefore--; +} + +// 2. Find bin "after" (higher pT) +int yBinAfter = iby + 1; +float valAfter = 0.f; +int nBinsY = h->GetNbinsY(); +while (yBinAfter <= nBinsY) { +valAfter = h->GetBinContent(ibx, yBinAfter, ibz); +if (valAfter > 0.f) break; // Found a valid bin +yBinAfter++; +} + +// 3. Interpolate/Extrapolate +if (valBefore > 0.f && valAfter > 0.f) { +// We found valid bins on both sides. Do linear interpolation. +float m = (valAfter - valBefore) / (yBinAfter - yBinBefore); +float interpolatedVal = valBefore + m * (iby - yBinBefore); +return interpolatedVal; +} else if (valBefore > 0.f) { +// Only found a bin before. Extrapolate using that value. +return valBefore; +} else if (valAfter > 0.f) { +// Only found a bin after. Extrapolate using that value. +return valAfter; +} else { +return -1; +} +} +*/ +// Getter for (Cent, eta, phi) maps (Flattening) +float getFlatteningWeight(float cent, float eta, float phi, PID pidType) const { + TH3F* h = hWeightMap3D[pidType]; + if (!h) return -1; + const int ibx = h->GetXaxis()->FindBin(cent); + const int iby = h->GetYaxis()->FindBin(eta); + const int ibz = h->GetZaxis()->FindBin(phi); + float val = h->GetBinContent(ibx, iby, ibz); + return val; +} + + +template +std::pair calculateMeanAndC2FromSums(const double sumpmwk[KIntM][KIntK], const double sumwk[KIntK], float referenceMeanPt) const +{ + // --- Safety Checks --- + if (sumwk[1] == 0.) { + return {0.f, 0.f}; // No tracks, return 0 + } + + double tau1 = sumwk[2] / (sumwk[1] * sumwk[1]); + double denom2 = 1. - tau1; + + if (std::abs(denom2) < kFloatEpsilon) { // Protect against divide-by-zero (e.g., N=1) + // Return mean, but C2 is undefined + double pmk11_safe = sumpmwk[1][1] / sumwk[1]; + return {static_cast(pmk11_safe), 0.f}; + } + + // --- Calculations --- + double pmk11 = sumpmwk[1][1] / sumwk[1]; + + double pmk12 = 0.; + if (sumwk[2] != 0.) { + pmk12 = sumpmwk[1][2] / sumwk[2]; + } + + double pmk22 = 0.; + if (sumwk[2] != 0.) { + pmk22 = sumpmwk[2][2] / sumwk[2]; + } + + float calculatedMeanPt = pmk11; // Mean pT is / + + double p1kBar1 = pmk11 - referenceMeanPt; + double p2kBar2 = pmk22 - 2. * pmk12 * referenceMeanPt + referenceMeanPt * referenceMeanPt; + + double p1kBar1_sq = p1kBar1 * p1kBar1; + double numerator2 = p1kBar1_sq - (tau1 * p2kBar2); + + float C2 = numerator2 / denom2; + return {calculatedMeanPt, C2}; +} + +ConfigurableAxis cfgAxisCent{"cfgAxisCent",{0.0, 1.0, 3.0, 5.0, 10, 20, 30, 40, 50, 60, 70, 80, 100},"centrality axis (percentile)"}; // FT0*/FV0A style +const AxisSpec centAxis{cfgAxisCent, "Centrality (%)"}; +static constexpr int kNbinsNch = 5000; +static constexpr float kNchMin = 0.5f; +static constexpr float kNchMax = 5000.5f; +static constexpr int kNbinsNchCoarse = 500; +static constexpr float kNchCoarseMax = 5000.5f; +ConfigurableAxis nChAxis{"nChAxis", {kNbinsNch, kNchMin, kNchMax}, "PV-contributor track multiplicity axis"}; +ConfigurableAxis nChAxis2{"nChAxis2", {kNbinsNchCoarse, kNchMin, kNchCoarseMax}, "PV-contributor track multiplicity axis"}; + +// run switches +Configurable cfgRunGetEff{"cfgRunGetEff", false, "Run MC pass to build efficiency/fake maps"}; +Configurable cfgRunMCMean{"cfgRunMCMean", false, "Run MC mean(pT) & mean(Et)"}; +Configurable cfgRunMCFluc{"cfgRunMCFluc", false, "Run MC fluctuations (C2, subevent)"}; +Configurable cfgRunGetFlat{"cfgRunGetFlat", false, "Run Data Get Flattening Weights"}; +Configurable cfgRunDataMean{"cfgRunDataMean", false, "Run DATA mean(pT) & mean(Et)"}; +Configurable cfgRunDataFluc{"cfgRunDataFluc", false, "Run DATA fluctuations (C2, subevent)"}; +// --- DATA: collisions with centralities and selections --- +using GeneralCollisions = soa::Join< +aod::Collisions, +aod::EvSels, +aod::Mults, +aod::CentFT0As, aod::CentFT0Cs, aod::CentFT0Ms, aod::CentFV0As, +aod::CentNGlobals>; +Filter collisionFilter = nabs(aod::collision::posZ) < cfgVtxZCut; +using AodCollisionsSel = soa::Filtered; + + +using UnfilteredTracks = soa::Join< +aod::Tracks, +aod::TracksExtra, +aod::TrackSelection, +aod::TracksDCA, +aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, +aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr>; +Filter trackFilter = nabs(aod::track::eta) < cfgEtaCut && +aod::track::pt > cfgPtMin && +aod::track::pt < cfgPtMax && +nabs(aod::track::dcaXY) < cfgDCAXY && +nabs(aod::track::dcaZ) < cfgDCAZ; +using AodTracksSel = soa::Filtered; +// --- MC: reconstructed tracks with truth labels --- +using TCs = soa::Join; +using FilteredTCs = soa::Filtered; +// --- MC: collisions with labels --- +using MyRun3MCCollisions = soa::Join< +aod::Collisions, aod::EvSels, aod::Mults, aod::MultsExtra, +aod::CentFT0As, aod::CentFT0Cs, aod::CentFT0Ms, aod::CentFV0As, +aod::CentNGlobals, aod::McCollisionLabels>; +// --- MC: truth-matched tracks --- +using MyMCTracks = soa::Join< +aod::Tracks, aod::TrackSelection, aod::TracksExtra, aod::TracksDCA, +aod::McTrackLabels, +aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, +aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr>; +// --- Preslices (consistent policies) --- +PresliceUnsorted partPerMcCollision = aod::mcparticle::mcCollisionId; +PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; +PresliceUnsorted trackPerMcParticle = aod::mctracklabel::mcParticleId; +Preslice perCollision = aod::track::collisionId; +Preslice trackPerCollision = aod::track::collisionId; + +void declareCommonQA() +{ + histos.add("hZvtx_after_sel", ";z_{vtx} (cm)", kTH1F, {{kNbinsZvtx, kZvtxMin, kZvtxMax}}); + histos.add("hCentrality", ";centrality (%)", kTH1F, {{centAxis}}); + histos.add("Hist2D_globalTracks_PVTracks", ";N_{global};N_{PV}", kTH2F, {{nChAxis2}, {nChAxis2}}); + histos.add("Hist2D_cent_nch", ";N_{PV};cent (%)", kTH2F, {{nChAxis2}, {centAxis}}); + histos.add("hP", ";p (GeV/c)", kTH1F, {{kNbinsP, kPMin, kPMax}}); + histos.add("hPt", ";p_{T} (GeV/c)", kTH1F, {{kNbinsPt, kPtMin, kPtMax}}); + histos.add("hEta", ";#eta", kTH1F, {{kNbinsEta, kEtaMin, kEtaMax}}); + histos.add("hPhi", ";#phi", kTH1F, {{kNbinsPhi, 0., TwoPI}}); + + histos.add("hCentEtaPhi", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCent1EtaPhi", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCent7EtaPhi", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCentEtaPhiWtd", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCent1EtaPhiWtd", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCent7EtaPhiWtd", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + + histos.add("hCentEtaPhiWtd_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCent1EtaPhiWtd_PID", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCent7EtaPhiWtd_PID", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + + histos.add("hCentEtaPhiTrue", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCentEtaPhiReco", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCentEtaPhiRecoMatched", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + + histos.add("hCentEtaPhiTrue_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCentEtaPhiReco_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCentEtaPhiRecoMatched_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + +} +void declareMCCommonHists() +{ + + histos.add("ptResolution", ";p_{T}^{MC};p_{T}^{MC}-p_{T}^{reco}", kTH2F, {{kNbinsPtRes, 0., cfgPtMax}, {kNbinsPtRes, -kPtResMax, kPtResMax}}); + histos.add("ptTruthReco", ";p_{T}^{MC};p_{T}^{reco}", kTH2F, {{kNbinsPtRes, 0., cfgPtMax}, {kNbinsPtRes, 0., cfgPtMax}}); + histos.add("etaResolution", ";#eta^{MC};#eta^{MC}-#eta^{reco}", kTH2F, {{kNbinsEtaRes, -kEtaFineMax, kEtaFineMax}, {kNbinsPtRes, -kEtaResMax, kEtaResMax}}); + histos.add("etaTruthReco", ";#eta^{MC};#eta^{reco}", kTH2F, {{kNbinsPtRes, -kEtaFineMax, kEtaFineMax}, {kNbinsPtRes, -kEtaFineMax, kEtaFineMax}}); + + histos.add("TruthTrackVZ", ";Vz^{MC};Vz^{Reco}", kTH2F, {{kNbinsVz, kVzMin, kVzMax}, {kNbinsVz, kVzMin, kVzMax}}); + histos.add("vzResolution", ";Vz^{MC};Vz^{MC}-Vz^{Reco}", kTH2F, {{kNbinsVz, kVzMin, kVzMax}, {kNbinsVz, -kVzResMax, kVzResMax}}); + + histos.add("h3_AllPrimary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + histos.add("h3_RecoMatchedToPrimary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + histos.add("h3_RecoUnMatchedToPrimary_Secondary",";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + histos.add("h3_RecoUnMatchedToPrimary_Fake", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + histos.add("h3_AllReco", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + + histos.add("h3_AllPrimary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + histos.add("h3_RecoMatchedToPrimary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + histos.add("h3_RecoUnMatchedToPrimary_Secondary_PID",";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + histos.add("h3_RecoUnMatchedToPrimary_Fake_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + histos.add("h3_AllReco_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + + histos.add("h_AllPrimary", ";p_{T}", kTH1F, {{kNbinsP, 0., cfgPtMax}}); + histos.add("h_RecoMatchedToPrimary", ";p_{T}", kTH1F, {{kNbinsPt, 0., kPtMax}}); + histos.add("h_RecoUnMatchedToPrimary",";p_{T}", kTH1F, {{kNbinsPt, 0., kPtMax}}); + histos.add("h_AllReco", ";p_{T}", kTH1F, {{kNbinsPt, 0., kPtMax}}); + + histos.add("hReco_ParticleWeight", ";cent;p_{T};#eta", kTH3F, {{centAxis},{kNbinsPtRes,0.,cfgPtMax},{kNbinsPtRes,-kEtaFineMax,kEtaFineMax}}); + histos.add("hTruth_ParticleWeight", ";cent;p_{T};#eta", kTH3F, {{centAxis},{kNbinsPtRes,0.,cfgPtMax},{kNbinsPtRes,-kEtaFineMax,kEtaFineMax}}); + + histos.add("hDCAxy_Unmatched", ";DCA_{xy} (cm)", kTH1F, {{kNbinsDca, -kDcaMax, kDcaMax}}); + histos.add("hDCAz_Unmatched", ";DCA_{z} (cm)", kTH1F, {{kNbinsDca, -kDcaMax, kDcaMax}}); + histos.add("hDCAxy_NotPrimary", ";DCA_{xy} (cm)", kTH1F, {{kNbinsDca, -kDcaMax, kDcaMax}}); + histos.add("hDCAz_NotPrimary", ";DCA_{z} (cm)", kTH1F, {{kNbinsDca, -kDcaMax, kDcaMax}}); +} + +void declareMCMeanHists() +{ + // Eff/Fake and weights vs observables + histos.add("Eff_cent", ";cent;#epsilon", kTProfile, {centAxis}); + histos.add("Fake_cent", ";cent;f_{fake}", kTProfile, {centAxis}); + histos.add("wgt_cent", ";cent;w", kTProfile, {centAxis}); + histos.add("Eff_Ntrk", ";N_{PV};#epsilon", kTProfile, {nChAxis2}); + histos.add("Fake_Ntrk", ";N_{PV};f_{fake}", kTProfile, {nChAxis2}); + histos.add("wgt_Ntrk", ";N_{PV};w", kTProfile, {nChAxis2}); + histos.add("Eff_pT", ";p_{T};#epsilon", kTProfile, {{kNbinsPtRes, 0., cfgPtMax}}); + histos.add("Fake_pT", ";p_{T};f_{fake}", kTProfile, {{kNbinsPtRes, 0., cfgPtMax}}); + histos.add("wgt_pT", ";p_{T};w", kTProfile, {{kNbinsPtRes, 0., kPtMax}}); + histos.add("Eff_eta", ";#eta;#epsilon", kTProfile, {{kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + histos.add("Fake_eta", ";#eta;f_{fake}", kTProfile, {{kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + histos.add("wgt_eta", ";#eta;w", kTProfile, {{kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + // MC mean profiles (pT & Et) for various selections + histos.add("MCGen/Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanpT_Mult", ";N_{PV};#LT p_{T}#GT",kTProfile, {nChAxis}); + histos.add("pmeanTruNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); + histos.add("pmeanRecoNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); + histos.add("pmeanRecoMatchedNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); + histos.add("pmeanRecoEffcorrNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); + histos.add("pmeanRecoMatchedEffcorrNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); + // Et versions + histos.add("MCGen/Prof_MeanEt_Cent",";cent;#LT E_{T}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanEt_Mult",";N_{PV};#LT E_{T}#GT",kTProfile, {nChAxis}); + histos.add("pmeanEtTruNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); + histos.add("pmeanEtRecoNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); + histos.add("pmeanEtRecoMatchedNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); + histos.add("pmeanEtRecoEffcorrNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); + histos.add("pmeanEtRecoMatchedEffcorrNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); + // Clone sets for Reco/Matched/EffCorr variants + + + histos.addClone("MCGen/", "MCReco/"); + histos.addClone("MCGen/", "MCRecoMatched/"); + histos.addClone("MCGen/", "MCRecoEffCorr/"); + histos.addClone("MCGen/", "MCRecoMatchedEffCorr/"); +} +void declareMCFlucHists() +{ + static constexpr int kNbinsNchFluc = 1000; + // pT cumulants + histos.add("MCGen/Prof_C2_Cent", ";cent;C_{2}", kTProfile, {centAxis}); + histos.add("MCGen/Prof_C2_Mult", ";N_{PV};C_{2}", kTProfile, {nChAxis}); + histos.add("MCGen/Prof_C2Sub_Mult_etabin_ptbin", + ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, + {{kNbinsNchFluc, kNchMin, kNchCoarseMax},{KNEta+1,-kBinOffset,KNEta+kBinOffset},{KNpT+1,-kBinOffset,KNpT+kBinOffset}}); + histos.add("MCGen/Prof_ipt0_C2Sub2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_C2Sub2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_C2Sub2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt0_Cov_Cent_eta",";cent;#eta", kTProfile2D, {{centAxis},{(KNEta-1)/2,0,kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt0_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta-1)/2,0.,kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_Cov_Cent_eta",";cent;#eta", kTProfile2D, {{centAxis},{(KNEta-1)/2,0,kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta-1)/2,0.,kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_Cov_Cent_eta",";cent;#eta", kTProfile2D, {{centAxis},{(KNEta-1)/2,0,kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta-1)/2,0.,kEtaAxisMax}}); + histos.add("MCGen/Prof_C2Et_Cent", ";cent;C_{2}^{E_{T}}", kTProfile, {centAxis}); + histos.add("MCGen/Prof_C2Et_Mult", ";N_{PV};C_{2}^{E_{T}}", kTProfile, {nChAxis}); + histos.add("MCGen/Prof_C2EtSub_Mult_etabin_ptbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, + {{kNbinsNchFluc, kNchMin, kNchCoarseMax},{KNEta+1,-kBinOffset,KNEta+kBinOffset},{KNpT+1,-kBinOffset,KNpT+kBinOffset}}); + histos.add("MCGen/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt0_CovEt_Cent_eta",";cent;#eta", kTProfile2D, {{centAxis},{(KNEta-1)/2,0,kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt0_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta-1)/2,0.,kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_CovEt_Cent_eta",";cent;#eta", kTProfile2D, {{centAxis},{(KNEta-1)/2,0,kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta-1)/2,0.,kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_CovEt_Cent_eta",";cent;#eta", kTProfile2D, {{centAxis},{(KNEta-1)/2,0,kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta-1)/2,0.,kEtaAxisMax}}); + + histos.add("MCGen/Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanpT_Mult", ";N_{PV};#LT p_{T}#GT",kTProfile, {nChAxis}); + + histos.add("pmeanTruNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("pmeanRecoNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("pmeanRecoMatchedNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("pmeanRecoEffcorrNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("pmeanRecoMatchedEffcorrNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + + histos.add("MCGen/Prof_MeanEt_Cent",";cent;#LT E_{T}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanEt_Mult",";N_{PV};#LT E_{T}#GT",kTProfile, {nChAxis}); + histos.add("pmeanEtTruNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("pmeanEtRecoNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("pmeanEtRecoMatchedNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("pmeanEtRecoEffcorrNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("pmeanEtRecoMatchedEffcorrNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); +} +void declareDataMeanHists() +{ + histos.add("Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); + histos.add("Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); + histos.add("pmean_nch_etabin_ptbin",";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + // Et + histos.add("Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); + histos.add("pmeanEt_nch_etabin_ptbin",";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); +} + +void declareDataGetFlatHists() +{ + // histos.add("hCentEtaPhi", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), -0.8, 0.8}, {30, 0, TMath::TwoPi()}}); + histos.add("hCentEtaPhi_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); +} + +void declareDataFlucHists() +{ + histos.add("pmean_nch_etabin_ptbin",";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); + histos.add("pmeanEt_nch_etabin_ptbin",";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + + histos.add("Prof_C2_Cent", ";cent;C_{2}", kTProfile, {centAxis}); + histos.add("Prof_MeanpT_Cent",";cent;#LT p_{T}#GT", kTProfile, {centAxis}); + histos.add("Prof_MeanpT_Mult",";N_{PV};#LT p_{T}#GT", kTProfile, {nChAxis}); + histos.add("Prof_C2_Mult_etabin_ptbin",";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + + histos.add("Prof_ipt0_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta-1)/2, 0, kEtaAxisMax}}); + histos.add("Prof_ipt0_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta-1)/2, 0., kEtaAxisMax}}); + histos.add("Prof_ipt1_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta-1)/2, 0, kEtaAxisMax}}); + histos.add("Prof_ipt1_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta-1)/2, 0., kEtaAxisMax}}); + histos.add("Prof_ipt2_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta-1)/2, 0, kEtaAxisMax}}); + histos.add("Prof_ipt2_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta-1)/2, 0., kEtaAxisMax}}); + + histos.add("Prof_C2Et_Cent", ";cent;C_{2}^{E_{T}}", kTProfile, {centAxis}); + histos.add("Prof_MeanEt_Mult", ";N_{PV};#LT E_{T}#GT", kTProfile, {nChAxis}); + histos.add("Prof_C2Et_Mult_etabin_ptbin",";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + + histos.add("Prof_ipt0_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta-1)/2, 0, kEtaAxisMax}}); + histos.add("Prof_ipt0_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta-1)/2, 0., kEtaAxisMax}}); + histos.add("Prof_ipt1_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta-1)/2, 0, kEtaAxisMax}}); + histos.add("Prof_ipt1_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta-1)/2, 0., kEtaAxisMax}}); + histos.add("Prof_ipt2_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta-1)/2, 0, kEtaAxisMax}}); + histos.add("Prof_ipt2_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta-1)/2, 0., kEtaAxisMax}}); + + histos.add("Prof_ipt0_C2Sub2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); + histos.add("Prof_ipt1_C2Sub2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); + histos.add("Prof_ipt2_C2Sub2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); + histos.add("Prof_ipt0_C2SubEt2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); + histos.add("Prof_ipt1_C2SubEt2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); + histos.add("Prof_ipt2_C2SubEt2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); +} + +TH3F* buildWeightMapFromRaw(TH3F* hRaw, const char* mapName) +{ + if (!hRaw) { + LOGF(error, "Raw eta-phi map for '%s' is null; no flattening will be applied.", mapName); + return nullptr; + } + auto hWeightMap = (TH3F*)hRaw->Clone(mapName); + hWeightMap->SetTitle(Form("Flattening Weight Map %s (w_{#phi} = / N_{#phi})", mapName)); + hWeightMap->SetDirectory(nullptr); + hWeightMap->Reset(); + auto axC = hRaw->GetXaxis(); + auto axE = hRaw->GetYaxis(); + auto axP = hRaw->GetZaxis(); + for (int ic = 1; ic <= axC->GetNbins(); ++ic) { + for (int ie = 1; ie <= axE->GetNbins(); ++ie) { + // average over phi at fixed (cent,eta) + double sum = 0.0; + int nphi = axP->GetNbins(); + for (int ip = 1; ip <= nphi; ++ip) sum += hRaw->GetBinContent(ic, ie, ip); + const double avg = (nphi > 0 ? sum / nphi : 0.0); + for (int ip = 1; ip <= nphi; ++ip) { + const double raw = hRaw->GetBinContent(ic, ie, ip); + const double w = (avg > 0.0 && raw > 0.0) ? (avg / raw) : 1.0; + hWeightMap->SetBinContent(ic, ie, ip, w); + } + } + } + LOGF(info, "Flattening weight map '%s' built.", mapName); + return hWeightMap; +} + +void init(InitContext&) +{ + // CCDB + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + int64_t nowMs = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()).count(); + ccdb->setCreatedNotAfter(nowMs); + // Always-on common QA + declareCommonQA(); + // Conditionally declare sets + if (cfgRunMCMean || cfgRunMCFluc || cfgRunGetEff) { + declareMCCommonHists(); + } + if (cfgRunMCMean) { + declareMCMeanHists(); + } + if (cfgRunMCFluc) { + declareMCFlucHists(); + + histos.addClone("MCGen/", "MCReco/"); + histos.addClone("MCGen/", "MCRecoMatched/"); + histos.addClone("MCGen/", "MCRecoEffCorr/"); + histos.addClone("MCGen/", "MCRecoMatchedEffCorr/"); + } + if (cfgRunGetFlat) { + declareDataGetFlatHists(); + } + if (cfgRunDataMean) { + declareDataMeanHists(); + } + if (cfgRunDataFluc) { + declareDataFlucHists(); + } + + //======================== + // Load correction maps + //======================== + const bool needEffMaps = cfgRunMCMean || cfgRunMCFluc || cfgRunDataMean || cfgRunDataFluc; + if (needEffMaps && !cfgRunGetEff) { + + // --- 1. Load Efficiency and Fake maps (always from MC file) --- + if (auto* f = TFile::Open("Job1_EffMaps.root", "READ")) { + if (!f->IsZombie()) { + if (auto* dir = dynamic_cast(f->Get("rad-flow-decorr"))) { + // Helper lambda to load Eff/Fake maps for a given PID type + auto loadEffFakeForPID = [&](PID pidType) { + std::string suffix = pidSuffix[pidType]; + std::string hEff_NumName = "h3_RecoMatchedToPrimary" + suffix; + std::string hEff_DenName = "h3_AllPrimary" + suffix; + std::string hFake_NumSecName = "h3_RecoUnMatchedToPrimary_Secondary" + suffix; + std::string hFake_NumFakName = "h3_RecoUnMatchedToPrimary_Fake" + suffix; + std::string hFake_DenName = "h3_AllReco" + suffix; + + // --- Efficiency --- + if (auto* hNum = dynamic_cast(dir->Get(hEff_NumName.c_str()))) { + hEff[pidType] = (TH3F*)hNum->Clone(Form("hEff%s", suffix.c_str())); + hEff[pidType]->SetDirectory(nullptr); + if (auto* hDen = dynamic_cast(dir->Get(hEff_DenName.c_str()))) { + hDen->SetDirectory(nullptr); + hEff[pidType]->Divide(hDen); + delete hDen; + } else { + LOGF(error, "Missing denominator %s for efficiency.", hEff_DenName.c_str()); + } + } else { + LOGF(error, "Missing numerator %s for efficiency.", hEff_NumName.c_str()); + } + // --- Fakes --- + if (auto* hNumS = dynamic_cast(dir->Get(hFake_NumSecName.c_str()))) { + auto* hNumF = dynamic_cast(dir->Get(hFake_NumFakName.c_str())); + if (hNumS && hNumF) { + hFake[pidType] = (TH3F*)hNumS->Clone(Form("hFake%s", suffix.c_str())); + hFake[pidType]->Add(hNumF); + hFake[pidType]->SetDirectory(nullptr); + if (auto* hDenF = dynamic_cast(dir->Get(hFake_DenName.c_str()))) { + hDenF->SetDirectory(nullptr); + hFake[pidType]->Divide(hDenF); + delete hDenF; + } else { + LOGF(error, "Missing denominator %s for fakes.", hFake_DenName.c_str()); + } + } else { + LOGF(error, "Missing fake numerator(s) for %s in EffMaps file.", suffix.c_str()); + } + } + }; + // Load Eff/Fake maps for both Inclusive and CombinedPID + loadEffFakeForPID(kInclusive); + loadEffFakeForPID(kCombinedPID); + } else { + LOGF(error, "Directory 'rad-flow-decorr' not found in Job1_EffMaps.root"); + } + } else { + LOGF(error, "Job1_EffMaps.root is a zombie."); + } + f->Close(); + delete f; + } else { + LOGF(error, "Cannot open Job1_EffMaps.root for Eff/Fake maps"); + } + + // --- 2. Load Flattening maps (source depends on run mode) --- + const bool isDataRun = cfgRunDataMean || cfgRunDataFluc; + if (isDataRun) { + // Load from Data flattening file (produced by processGetFlat) + LOGF(info, "Data Run: Loading flattening maps from Job1_DataFlat.root"); + if (auto* fFlat = TFile::Open("Job1_DataFlat.root", "READ")) { + if (!fFlat->IsZombie()) { + if (auto* dirFlat = dynamic_cast(fFlat->Get("rad-flow-decorr"))) { + // Inclusive + if (auto* hRawIncl = dynamic_cast(dirFlat->Get("hCentEtaPhi"))) { + hWeightMap3D[kInclusive] = buildWeightMapFromRaw(hRawIncl, "hWeightMap3D"); + } else { + LOGF(error, "Data flattening source 'hCentEtaPhi' not found in Job1_DataFlat.root"); + } + // PID + if (auto* hRawPID = dynamic_cast(dirFlat->Get("hCentEtaPhi_PID"))) { + hWeightMap3D[kCombinedPID] = buildWeightMapFromRaw(hRawPID, "hWeightMap3D_PID"); + } else { + LOGF(error, "Data flattening source 'hCentEtaPhi_PID' not found in Job1_DataFlat.root"); + } + } else { + LOGF(error, "Directory 'rad-flow-decorr' not found in Job1_DataFlat.root"); + } + } else { + LOGF(error, "Job1_DataFlat.root is a zombie."); + } + fFlat->Close(); + delete fFlat; + } else { + LOGF(error, "Cannot open Job1_DataFlat.root"); + } + } else { + // Load from MC efficiency file (as before, but ONLY flattening) + LOGF(info, "MC Run: Loading flattening maps from Job1_EffMaps.root"); + if (auto* f = TFile::Open("Job1_EffMaps.root", "READ")) { + if (!f->IsZombie()) { + if (auto* dir = dynamic_cast(f->Get("rad-flow-decorr"))) { + auto loadFlatForPID = [&](PID pidType) { + std::string suffix = pidSuffix[pidType]; + // std::string hFlat_SrcName = "hCentEtaPhiRecoMatched" + suffix; + std::string hFlat_SrcName = "hCentEtaPhiReco" + suffix; // As in original code + if (auto* hRaw = dynamic_cast(dir->Get(hFlat_SrcName.c_str()))) { + hWeightMap3D[pidType] = buildWeightMapFromRaw(hRaw, Form("hWeightMap3D%s", suffix.c_str())); + } else { + LOGF(warning, "MC flattening source '%s' not found; proceeding without flattening for this PID.", hFlat_SrcName.c_str()); + } + }; + loadFlatForPID(kInclusive); + loadFlatForPID(kCombinedPID); + } else { + LOGF(error, "Directory 'rad-flow-decorr' not found in Job1_EffMaps.root (for MC flat)"); + } + } else { + LOGF(error, "Job1_EffMaps.root is a zombie (for MC flat)."); + } + f->Close(); + delete f; + } else { + LOGF(error, "Cannot open Job1_EffMaps.root (for MC flat)"); + } + } + } + + //======================== + // Load Step-2 mean profiles (pT and Et) + //======================== + auto loadTProfile3D = [&](const char* filename, const char* histname, TProfile3D*& target) { + if (auto* f = TFile::Open(filename, "READ")) { + if (!f->IsZombie()) { + if (auto* dir = dynamic_cast(f->Get("rad-flow-decorr"))) { + if (auto* tp = dynamic_cast(dir->Get(histname))) { + target = (TProfile3D*)tp->Clone(); + target->SetDirectory(nullptr); + } else { + LOGF(error, "Histogram %s missing in %s", histname, filename); + } + } else { + LOGF(error, "Directory 'rad-flow-decorr' missing in %s", filename); + } + } else { + LOGF(error, "%s is a zombie", filename); + } + f->Close(); + delete f; + } else { + LOGF(error, "Cannot open %s", filename); + } + }; + // === THIS BLOCK IS UPDATED === + if (cfgRunMCFluc) { + // pT profiles + loadTProfile3D("Job2_MCMean.root", "pmeanTruNchEtabinPtbin", pmeanTruNchEtabinPtbinStep2); + loadTProfile3D("Job2_MCMean.root", "pmeanRecoNchEtabinPtbin", pmeanRecoNchEtabinPtbinStep2); + loadTProfile3D("Job2_MCMean.root", "pmeanRecoMatchedNchEtabinPtbin", pmeanRecoMatchedNchEtabinPtbinStep2); + loadTProfile3D("Job2_MCMean.root", "pmeanRecoEffcorrNchEtabinPtbin", pmeanRecoEffcorrNchEtabinPtbinStep2); + loadTProfile3D("Job2_MCMean.root", "pmeanRecoMatchedEffcorrNchEtabinPtbin", pmeanRecoMatchedEffcorrNchEtabinPtbinStep2); + // Et profiles + loadTProfile3D("Job2_MCMean.root", "pmeanEtTruNchEtabinPtbin", pmeanEtTruNchEtabinPtbinStep2); + loadTProfile3D("Job2_MCMean.root", "pmeanEtRecoNchEtabinPtbin", pmeanEtRecoNchEtabinPtbinStep2); + loadTProfile3D("Job2_MCMean.root", "pmeanEtRecoMatchedNchEtabinPtbin", pmeanEtRecoMatchedNchEtabinPtbinStep2); + loadTProfile3D("Job2_MCMean.root", "pmeanEtRecoEffcorrNchEtabinPtbin", pmeanEtRecoEffcorrNchEtabinPtbinStep2); + loadTProfile3D("Job2_MCMean.root", "pmeanEtRecoMatchedEffcorrNchEtabinPtbin", pmeanEtRecoMatchedEffcorrNchEtabinPtbinStep2); + } + // ============================= + if (cfgRunDataFluc) { + loadTProfile3D("Job1_DataMean.root", "pmean_nch_etabin_ptbin", pmeanNchEtabinPtbinStep2); + loadTProfile3D("Job1_DataMean.root", "pmeanEt_nch_etabin_ptbin", pmeanEtNchEtabinPtbinStep2); + }} + + void processGetEffHists(aod::McCollisions const& mcColl, soa::SmallGroups const& collisions, TCs const& tracks, FilteredTCs const& /*filteredTracks*/, aod::McParticles const& mcParticles) + { + for (const auto& mcCollision : mcColl) { + auto colSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex()); + if (colSlice.size() != 1) continue; + + for (const auto& col : colSlice) { + if (!col.has_mcCollision()) continue; + if (!isEventSelected(col)) continue; + + auto trackSlice = tracks.sliceBy(trackPerCollision, col.globalIndex()); + if (trackSlice.size() < 1) continue; + + + auto partSlice = mcParticles.sliceBy(partPerMcCollision, mcCollision.globalIndex()); + if (partSlice.size() < 1) continue; + if (col.globalIndex() >= trackSlice.size()) { + LOGF(warning, "Skipping invalid globalIndex=%d for tracks (tracks.size=%d)",col.globalIndex(), tracks.size()); + continue; + } + + float cent = getCentrality(col); + if (cent < 0 || cent > 80) continue; + + for (const auto& particle : partSlice) { + if (!isParticleSelected(particle)) continue; + if (!particle.isPhysicalPrimary()) continue; + + const int absPdgId = std::abs(particle.pdgCode()); + const bool isPion = (absPdgId == kPiPlus); + const bool isKaon = (absPdgId == kKPlus); + const bool isProton = (absPdgId == kProton); + const bool isPid = (isPion || isKaon || isProton); + + histos.fill(HIST("hTruth_ParticleWeight"), cent, particle.pt(), particle.eta(), particle.weight()); + histos.fill(HIST("hCentEtaPhiTrue"), cent, particle.eta(), particle.phi()); + histos.fill(HIST("h3_AllPrimary"), col.multNTracksPV(), particle.pt(), particle.eta()); + + if (cent < kCentTestMin) histos.fill(HIST("hCent1EtaPhi"), particle.eta(), particle.phi()); + if (cent > kCentTestMaxLo && cent < kCentTestMaxHi) histos.fill(HIST("hCent7EtaPhi"), particle.eta(), particle.phi()); + + if (isPid) { + histos.fill(HIST("hCentEtaPhiTrue_PID"), cent, particle.eta(), particle.phi()); + histos.fill(HIST("h3_AllPrimary_PID"), col.multNTracksPV(), particle.pt(), particle.eta()); + } + + } + histos.fill(HIST("TruthTrackVZ"), mcCollision.posZ(), col.posZ()); + histos.fill(HIST("vzResolution"), mcCollision.posZ(), mcCollision.posZ() - col.posZ()); + + + // Reconstructed + for (const auto& track : trackSlice) { + if (!isTrackSelected(track)) continue; + + const bool isPion = selectionPion(track); + const bool isKaon = selectionKaon(track); + const bool isProton = selectionProton(track); + const bool isPid = (isPion || isKaon || isProton); + + histos.fill(HIST("h3_AllReco"), col.multNTracksPV(), track.pt(), track.eta()); + histos.fill(HIST("hCentEtaPhiReco"), cent, track.eta(), track.phi()); + + if (isPid) { + histos.fill(HIST("h3_AllReco_PID"), col.multNTracksPV(), track.pt(), track.eta()); + histos.fill(HIST("hCentEtaPhiReco_PID"), cent, track.eta(), track.phi()); + } + + if (track.has_mcParticle()) { + auto mcPart2 = track.mcParticle(); + if (mcPart2.isPhysicalPrimary()) { + const int absPdgId = std::abs(mcPart2.pdgCode()); + const bool isPionTrue = (absPdgId == kPiPlus); + const bool isKaonTrue = (absPdgId == kKPlus); + const bool isProtonTrue = (absPdgId == kProton); + const bool isPidTrue = (isPionTrue || isKaonTrue || isProtonTrue); + // Fill inclusive hists + histos.fill(HIST("hReco_ParticleWeight"), cent, mcPart2.pt(), mcPart2.eta(), mcPart2.weight()); + histos.fill(HIST("ptResolution"), mcPart2.pt(), mcPart2.pt() - track.pt()); + histos.fill(HIST("ptTruthReco"), mcPart2.pt(), track.pt()); + histos.fill(HIST("etaResolution"), mcPart2.eta(), mcPart2.eta() - track.eta()); + histos.fill(HIST("etaTruthReco"), mcPart2.eta(), track.eta()); + histos.fill(HIST("h3_RecoMatchedToPrimary"), col.multNTracksPV(), mcPart2.pt(), mcPart2.eta()); + histos.fill(HIST("hCentEtaPhiRecoMatched"), cent, mcPart2.eta(), mcPart2.phi()); + + if (isPid && isPidTrue) { + histos.fill(HIST("h3_RecoMatchedToPrimary_PID"), col.multNTracksPV(), mcPart2.pt(), mcPart2.eta()); + histos.fill(HIST("hCentEtaPhiRecoMatched_PID"), cent, mcPart2.eta(), mcPart2.phi()); + } + + } + else { + // Matched to secondary + histos.fill(HIST("h3_RecoUnMatchedToPrimary_Secondary"), col.multNTracksPV(), track.pt(), track.eta()); + histos.fill(HIST("hDCAxy_Unmatched"), track.dcaXY()); + histos.fill(HIST("hDCAz_Unmatched"), track.dcaZ()); + if (isPid) { + histos.fill(HIST("h3_RecoUnMatchedToPrimary_Secondary_PID"), col.multNTracksPV(), track.pt(), track.eta()); + } + } + } + else { + // Fake track + histos.fill(HIST("h3_RecoUnMatchedToPrimary_Fake"), col.multNTracksPV(), track.pt(), track.eta()); + histos.fill(HIST("hDCAxy_NotPrimary"), track.dcaXY()); + histos.fill(HIST("hDCAz_NotPrimary"), track.dcaZ()); + if (isPid) { + histos.fill(HIST("h3_RecoUnMatchedToPrimary_Fake_PID"), col.multNTracksPV(), track.pt(), track.eta()); + } + } + } // tracks + } // cols + } // mcColl + LOGF(info, "FINISHED RUNNING processGetEffHists"); + } + PROCESS_SWITCH(RadFlowDecorr, processGetEffHists, "process MC to calculate Eff and Fakes", cfgRunGetEff); + + + void processMCMean(aod::McCollisions const& mcColl, MyRun3MCCollisions const& collisions, TCs const& tracks, FilteredTCs const& /*filteredTracks*/, aod::McParticles const& mcParticles) + { + float sumWiTruth[KNEta][KNpT], sumWiptiTruth[KNEta][KNpT]; + float sumWiReco[KNEta][KNpT], sumWiptiReco[KNEta][KNpT]; + float sumWiRecoMatched[KNEta][KNpT], sumWiptiRecoMatched[KNEta][KNpT]; + float sumWiRecoEffCorr[KNEta][KNpT], sumWiptiRecoEffCorr[KNEta][KNpT]; + float sumWiRecoMatchedEffCorr[KNEta][KNpT], sumWiptiRecoMatchedEffCorr[KNEta][KNpT]; + float sumWiTruthEt[KNEta][KNpT], sumWiptiTruthEt[KNEta][KNpT]; + float sumWiRecoEt[KNEta][KNpT], sumWiptiRecoEt[KNEta][KNpT]; + float sumWiRecoMatchedEt[KNEta][KNpT], sumWiptiRecoMatchedEt[KNEta][KNpT]; + float sumWiRecoEffCorrEt[KNEta][KNpT], sumWiptiRecoEffCorrEt[KNEta][KNpT]; + float sumWiRecoMatchedEffCorrEt[KNEta][KNpT], sumWiptiRecoMatchedEffCorrEt[KNEta][KNpT]; + + + for (const auto& mcCollision : mcColl) { + auto colSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex()); + + if (colSlice.size() != 1) continue; + for (const auto& col : colSlice) { + if (!col.has_mcCollision()) continue; + if (!isEventSelected(col)) continue; + + auto trackSlice = tracks.sliceBy(trackPerCollision, col.globalIndex()); + if (trackSlice.size() < 1) continue; + + + auto partSlice = mcParticles.sliceBy(partPerMcCollision, mcCollision.globalIndex()); + if (partSlice.size() < 1) continue; + if (col.globalIndex() >= trackSlice.size()) { + LOGF(warning, "Skipping invalid globalIndex=%d for tracks (tracks.size=%d)",col.globalIndex(), tracks.size()); + continue; + } + + float cent = getCentrality(col); + if (cent < 0 || cent > 80) continue; + + + if (col.globalIndex() >= trackSlice.size()) { + LOGF(warning, "Skipping invalid globalIndex=%d for tracks (tracks.size=%d)",col.globalIndex(), tracks.size()); + continue; + } + + LOGF(info, "Event Check: cent = %.1f, nTracks = %d", cent, (int)trackSlice.size()); + memset(sumWiTruth, 0, sizeof(sumWiTruth)); + memset(sumWiptiTruth, 0, sizeof(sumWiptiTruth)); + memset(sumWiReco, 0, sizeof(sumWiReco)); + memset(sumWiptiReco, 0, sizeof(sumWiptiReco)); + memset(sumWiRecoMatched, 0, sizeof(sumWiRecoMatched)); + memset(sumWiptiRecoMatched, 0, sizeof(sumWiptiRecoMatched)); + memset(sumWiRecoEffCorr, 0, sizeof(sumWiRecoEffCorr)); + memset(sumWiptiRecoEffCorr, 0, sizeof(sumWiptiRecoEffCorr)); + memset(sumWiRecoMatchedEffCorr, 0, sizeof(sumWiRecoMatchedEffCorr)); + memset(sumWiptiRecoMatchedEffCorr, 0, sizeof(sumWiptiRecoMatchedEffCorr)); + memset(sumWiTruthEt, 0, sizeof(sumWiTruthEt)); + memset(sumWiptiTruthEt, 0, sizeof(sumWiptiTruthEt)); + memset(sumWiRecoEt, 0, sizeof(sumWiRecoEt)); + memset(sumWiptiRecoEt, 0, sizeof(sumWiptiRecoEt)); + memset(sumWiRecoMatchedEt, 0, sizeof(sumWiRecoMatchedEt)); + memset(sumWiptiRecoMatchedEt, 0, sizeof(sumWiptiRecoMatchedEt)); + memset(sumWiRecoEffCorrEt, 0, sizeof(sumWiRecoEffCorrEt)); + memset(sumWiptiRecoEffCorrEt, 0, sizeof(sumWiptiRecoEffCorrEt)); + memset(sumWiRecoMatchedEffCorrEt, 0, sizeof(sumWiRecoMatchedEffCorrEt)); + memset(sumWiptiRecoMatchedEffCorrEt, 0, sizeof(sumWiptiRecoMatchedEffCorrEt)); + + // Truth + for (const auto& particle : partSlice) { + if (!isParticleSelected(particle)) continue; + if (!particle.isPhysicalPrimary()) continue; + + const int absPdgId = std::abs(particle.pdgCode()); + const bool isPion = (absPdgId == kPiPlus); + const bool isKaon = (absPdgId == kKPlus); + const bool isProton = (absPdgId == kProton); + + float pt = particle.pt(); + float eta = particle.eta(); + float p = particle.p(); + const double wi = 1.0; + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + sumWiTruth[ieta][ipt] += 1.0; + sumWiptiTruth[ieta][ipt] += 1.0 * pt; + if (isPion || isKaon || isProton) { + float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus : o2::constants::physics::MassProton; + float E = std::sqrt(p * p + m * m); + float Et = E * (pt / p); // E_T = E * sin(theta) = E * (pT / p) + sumWiTruthEt[ieta][ipt] += 1.0; + sumWiptiTruthEt[ieta][ipt] += Et; + } + } + } + } + + for (const auto& track : trackSlice) { + if (!isTrackSelected(track)) continue; + + float pt = track.pt(); + float eta = track.eta(); + float p = track.p(); + float phi = track.phi(); + + + histos.fill(HIST("hCentEtaPhi"), cent, eta, phi); + if (cent < kCentTestMin) histos.fill(HIST("hCent1EtaPhi"), eta, phi); + if (cent > kCentTestMaxLo && cent < kCentTestMaxHi) histos.fill(HIST("hCent7EtaPhi"), eta, phi); + + float effIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 0); + float fakeIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 1); + float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); + float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; + + histos.fill(HIST("hCentEtaPhiWtd"), cent, eta, track.phi(), flatWeightIncl); + if (cent < kCentTestMin) histos.fill(HIST("hCent1EtaPhiWtd"), track.eta(), track.phi(), flatWeightIncl); + if (cent > kCentTestMaxLo && cent < kCentTestMaxHi) histos.fill(HIST("hCent7EtaPhiWtd"), track.eta(), track.phi(), flatWeightIncl); + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + sumWiReco[ieta][ipt] += 1.0; + sumWiptiReco[ieta][ipt] += pt; + } + } + + if (effIncl <= 0 || !isfinite(wIncl) || !isfinite(fakeIncl) || !isfinite(flatWeightIncl)) continue; + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + sumWiRecoEffCorr[ieta][ipt] += wIncl; + sumWiptiRecoEffCorr[ieta][ipt] += wIncl * pt; + } + } + + const bool isPion = selectionPion(track); + const bool isKaon = selectionKaon(track); + const bool isProton = selectionProton(track); + if (isPion || isKaon || isProton) { + float effPid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 0); + float fakePid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 1); + float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); + float wPid =  flatWeightPid * (1.0 - fakePid) / effPid; + + histos.fill(HIST("hCentEtaPhiWtd_PID"), cent, eta, track.phi(), flatWeightPid); + if (cent < kCentTestMin) histos.fill(HIST("hCent1EtaPhiWtd_PID"), track.eta(), track.phi(), flatWeightPid); + if (cent > kCentTestMaxLo && cent < kCentTestMaxHi) histos.fill(HIST("hCent7EtaPhiWtd_PID"), track.eta(), track.phi(), flatWeightPid); + + float m = isPion ? o2::constants::physics::MassPiPlus :isKaon ? o2::constants::physics::MassKPlus :o2::constants::physics::MassProton; + float E = std::sqrt(p * p + m * m); + float Et = E * (pt / p); // E_T = E * sin(theta) + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + sumWiRecoEt[ieta][ipt] += 1.0; + sumWiptiRecoEt[ieta][ipt] += Et; + } + } + + if (effPid <= kFloatEpsilon || !isfinite(wPid) || !isfinite(fakePid) || !isfinite(flatWeightPid)) continue; + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + sumWiRecoEffCorrEt[ieta][ipt] += wPid; + sumWiptiRecoEffCorrEt[ieta][ipt] += wPid * Et; + } + } + } + + if (isfinite(wIncl)){ + if(cent < kCentTestMin){ + histos.fill(HIST("wgt_pT"), pt, wIncl); + histos.fill(HIST("Eff_pT"), pt, effIncl); + histos.fill(HIST("Fake_pT"), pt, fakeIncl); + histos.fill(HIST("Eff_eta"), eta, effIncl); + histos.fill(HIST("Fake_eta"), eta, fakeIncl); + histos.fill(HIST("wgt_eta"), eta, wIncl); + } + histos.fill(HIST("Eff_cent"), cent, effIncl); + histos.fill(HIST("Eff_Ntrk"), col.multNTracksPV(), effIncl); + histos.fill(HIST("Fake_cent"), cent, fakeIncl); + histos.fill(HIST("Fake_Ntrk"), col.multNTracksPV(), fakeIncl); + histos.fill(HIST("wgt_cent"), cent, wIncl); + histos.fill(HIST("wgt_Ntrk"), col.multNTracksPV(), wIncl); + } + + } // end track loop + + if (isfinite(sumWiTruth[0][0])) { + float meanpT_truth = sumWiptiTruth[0][0] / sumWiTruth[0][0]; + if(!isfinite(meanpT_truth)) LOGF(info, "meanpT_truth = %.3f, num = %.3f, den =%.3f", meanpT_truth, sumWiptiTruth[0][0], sumWiTruth[0][0]); + if(!isfinite(meanpT_truth)) continue; + histos.fill(HIST("MCGen/Prof_cent_Nchrec"), cent, sumWiTruth[0][0]); + histos.fill(HIST("MCGen/Prof_MeanpT_Cent"), cent, meanpT_truth); + histos.fill(HIST("MCGen/Prof_MeanpT_Mult"), col.multNTracksPV(), meanpT_truth); + } + if (isfinite(sumWiReco[0][0])) { + float meanpT_reco = sumWiptiReco[0][0] / sumWiReco[0][0]; + if(!isfinite(meanpT_reco)) LOGF(info, "meanpT_reco = %.3f, num = %.3f, den =%.3f", meanpT_reco, sumWiptiReco[0][0], sumWiReco[0][0]); + if(!isfinite(meanpT_reco)) continue; + histos.fill(HIST("MCReco/Prof_cent_Nchrec"), cent, sumWiReco[0][0]); + histos.fill(HIST("MCReco/Prof_MeanpT_Cent"), cent, meanpT_reco); + histos.fill(HIST("MCReco/Prof_MeanpT_Mult"), col.multNTracksPV(), meanpT_reco); + } + if (isfinite(sumWiRecoEffCorr[0][0])) { + float meanpT_effcorr = sumWiptiRecoEffCorr[0][0] / sumWiRecoEffCorr[0][0]; + if(!isfinite(meanpT_effcorr)) LOGF(info, "meanpT_recoEffcorr = %.3f, num = %.3f, den =%.3f", meanpT_effcorr, sumWiptiRecoEffCorr[0][0], sumWiRecoEffCorr[0][0]); + if(!isfinite(meanpT_effcorr)) continue; + histos.fill(HIST("MCRecoEffCorr/Prof_cent_Nchrec"), cent, sumWiRecoEffCorr[0][0]); + histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Cent"), cent, meanpT_effcorr); + histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Mult"), col.multNTracksPV(), meanpT_effcorr); + } + + if (isfinite(sumWiTruthEt[0][0])) { + float meanEt = sumWiptiTruthEt[0][0] / sumWiTruthEt[0][0]; + if(!isfinite(meanEt)) LOGF(info, "meanEtTruthEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiTruthEt[0][0], sumWiTruthEt[0][0]); + if(!isfinite(meanEt)) continue; + histos.fill(HIST("MCGen/Prof_MeanEt_Cent"), cent, meanEt); + histos.fill(HIST("MCGen/Prof_MeanEt_Mult"), col.multNTracksPV(), meanEt); + } + // "MCReco" + if (isfinite(sumWiRecoEt[0][0])) { + float meanEt = sumWiptiRecoEt[0][0] / sumWiRecoEt[0][0]; + if(!isfinite(meanEt)) LOGF(info, "meanEtRecoEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiRecoEt[0][0], sumWiRecoEt[0][0]); + if(!isfinite(meanEt)) continue; + histos.fill(HIST("MCReco/Prof_MeanEt_Cent"), cent, meanEt); + histos.fill(HIST("MCReco/Prof_MeanEt_Mult"), col.multNTracksPV(), meanEt); + } + // "MCRecoEffCorr" + if (isfinite(sumWiRecoEffCorrEt[0][0])) { + float meanEt = sumWiptiRecoEffCorrEt[0][0] / sumWiRecoEffCorrEt[0][0]; + if(!isfinite(meanEt)) LOGF(info, "meanEtRecoEffcorrEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiRecoEffCorrEt[0][0], sumWiRecoEffCorrEt[0][0]); + if(!isfinite(meanEt)) continue; + histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Cent"), cent, meanEt); + histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Mult"), col.multNTracksPV(), meanEt); + } + + // --- Fill 3D pT Profiles --- + for (int ieta = 0; ieta < KNEta; ++ieta){ + for (int ipt = 0; ipt < KNpT; ++ipt){ + if (isfinite(sumWiTruth[ieta][ipt])) histos.fill(HIST("pmeanTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiTruth[ieta][ipt] / sumWiTruth[ieta][ipt]); + if (isfinite(sumWiReco[ieta][ipt])) histos.fill(HIST("pmeanRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt,sumWiptiReco[ieta][ipt] / sumWiReco[ieta][ipt]); + if (isfinite(sumWiRecoEffCorr[ieta][ipt])) histos.fill(HIST("pmeanRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt,sumWiptiRecoEffCorr[ieta][ipt] / sumWiRecoEffCorr[ieta][ipt]); + // --- Fill 3D Et Profiles --- + if (isfinite(sumWiTruthEt[ieta][ipt])) histos.fill(HIST("pmeanEtTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiTruthEt[ieta][ipt] / sumWiTruthEt[ieta][ipt]); + if (isfinite(sumWiRecoEt[ieta][ipt])) histos.fill(HIST("pmeanEtRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiRecoEt[ieta][ipt] / sumWiRecoEt[ieta][ipt]); + if (isfinite(sumWiRecoEffCorrEt[ieta][ipt])) histos.fill(HIST("pmeanEtRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiRecoEffCorrEt[ieta][ipt] / sumWiRecoEffCorrEt[ieta][ipt]); + } + } + } // end col loop + } + + LOGF(info, "FINISHED RUNNING processMCMean (pT + Et)"); + } + PROCESS_SWITCH(RadFlowDecorr, processMCMean, "process MC to calculate mean pt/Et and Eff Hists", cfgRunMCMean); + + void processMCFluc(aod::McCollisions const& mcColl, MyRun3MCCollisions const& collisions, TCs const& tracks, FilteredTCs const& /*filteredTracks*/, aod::McParticles const& mcParticles) + { + double sumPmwkTru[KNEta][KNpT][KIntM][KIntK]{}; + double sumWkTru[KNEta][KNpT][KIntK]{}; + double sumPmwkReco[KNEta][KNpT][KIntM][KIntK]{}; + double sumWkReco[KNEta][KNpT][KIntK]{}; + double sumPmwkRecoEffCor[KNEta][KNpT][KIntM][KIntK]{}; + double sumWkRecoEffCor[KNEta][KNpT][KIntK]{}; + double sumPmwkTruEt[KNEta][KNpT][KIntM][KIntK]{}; + double sumWkTruEt[KNEta][KNpT][KIntK]{}; + double sumPmwkRecoEt[KNEta][KNpT][KIntM][KIntK]{}; + double sumWkRecoEt[KNEta][KNpT][KIntK]{}; + double sumPmwkRecoEffCorEt[KNEta][KNpT][KIntM][KIntK]{}; + double sumWkRecoEffCorEt[KNEta][KNpT][KIntK]{}; + double meanTru[KNEta][KNpT]{}, c2Tru[KNEta][KNpT]{}; + double meanReco[KNEta][KNpT]{}, c2Reco[KNEta][KNpT]{}; + double meanRecoEffCor[KNEta][KNpT]{}, c2RecoEffCor[KNEta][KNpT]{}; + double meanTruEt[KNEta][KNpT]{}, c2TruEt[KNEta][KNpT]{}; + double meanRecoEt[KNEta][KNpT]{}, c2RecoEt[KNEta][KNpT]{}; + double meanRecoEffCorEt[KNEta][KNpT]{}, c2RecoEffCorEt[KNEta][KNpT]{}; + + for (const auto& mcCollision : mcColl) { + auto partSlice = mcParticles.sliceBy(partPerMcCollision, mcCollision.globalIndex()); + auto colSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex()); + if (colSlice.size() != 1) continue; + histos.fill(HIST("MCGen/hVtxZ"), mcCollision.posZ()); // This histogram was not declared, commenting out. + for (const auto& col : colSlice) { + + auto trackSlice = tracks.sliceBy(trackPerCollision, col.globalIndex()); + if (trackSlice.size() < 1) continue; + + memset(sumPmwkTru, 0, sizeof(sumPmwkTru)); + memset(sumWkTru, 0, sizeof(sumWkTru)); + memset(sumPmwkReco, 0, sizeof(sumPmwkReco)); + memset(sumWkReco, 0, sizeof(sumWkReco)); + memset(sumPmwkRecoEffCor, 0, sizeof(sumPmwkRecoEffCor)); + memset(sumWkRecoEffCor, 0, sizeof(sumWkRecoEffCor)); + + memset(sumPmwkTruEt, 0, sizeof(sumPmwkTruEt)); + memset(sumWkTruEt, 0, sizeof(sumWkTruEt)); + memset(sumPmwkRecoEt, 0, sizeof(sumPmwkRecoEt)); + memset(sumWkRecoEt, 0, sizeof(sumWkRecoEt)); + memset(sumPmwkRecoEffCorEt, 0, sizeof(sumPmwkRecoEffCorEt)); + memset(sumWkRecoEffCorEt, 0, sizeof(sumWkRecoEffCorEt)); + + memset(meanTru, 0, sizeof(meanTru)); memset(c2Tru, 0, sizeof(c2Tru)); + memset(meanReco, 0, sizeof(meanReco)); memset(c2Reco, 0, sizeof(c2Reco)); + memset(meanRecoEffCor, 0, sizeof(meanRecoEffCor)); memset(c2RecoEffCor, 0, sizeof(c2RecoEffCor)); + + memset(meanTruEt, 0, sizeof(meanTruEt)); memset(c2TruEt, 0, sizeof(c2TruEt)); + memset(meanRecoEt, 0, sizeof(meanRecoEt)); memset(c2RecoEt, 0, sizeof(c2RecoEt)); + memset(meanRecoEffCorEt, 0, sizeof(meanRecoEffCorEt)); memset(c2RecoEffCorEt, 0, sizeof(c2RecoEffCorEt)); + + if (!col.has_mcCollision() || !isEventSelected(col)) continue; + float cent = getCentrality(col); + if (cent < 0 || cent > 80) continue; + + // truth + for (const auto& particle : partSlice) { + if (!isParticleSelected(particle)) continue; + if (!particle.isPhysicalPrimary()) continue; + float pt = particle.pt(); + float eta = particle.eta(); + float p = particle.p(); + const double wi = 1.0; + + // pT (Inclusive) + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + for (int k = 0; k < KIntK; ++k) { + for (int m = 0; m < KIntM; ++m) { + sumPmwkTru[ieta][ipt][m][k] += std::pow(wi, k) * std::pow(pt, m); + } + sumWkTru[ieta][ipt][k] += std::pow(wi, k); + } + } + } + const int absPdgId = std::abs(particle.pdgCode()); + const bool isPion = (absPdgId == kPiPlus); + const bool isKaon = (absPdgId == kKPlus); + const bool isProton = (absPdgId == kProton); + if (isPion || isKaon || isProton){ + + float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus : o2::constants::physics::MassProton; + float E = std::sqrt(p * p + m * m); + float Et = E * (pt / p); + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + for (int k = 0; k < KIntK; ++k) { + for (int m = 0; m < KIntM; ++m) { + sumPmwkTruEt[ieta][ipt][m][k] += std::pow(wi, k) * std::pow(Et, m); + } + sumWkTruEt[ieta][ipt][k] += std::pow(wi, k); + } + } + } + } + + } // end truth loop + + for (const auto& track : trackSlice) { + if (!isTrackSelected(track)) continue; + float pt = track.pt(); + float eta = track.eta(); + float p = track.p(); + float phi = track.phi(); + + float effIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 0); + float fakeIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 1); + float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); + float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; + if (!std::isfinite(wIncl) || wIncl <= 0.f) continue; + if (effIncl <= 0 || !isfinite(effIncl) || !isfinite(fakeIncl) || !isfinite(flatWeightIncl))  continue; + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + for (int k = 0; k < KIntK; ++k) { + for (int m = 0; m < KIntM; ++m) { + sumPmwkReco[ieta][ipt][m][k] += std::pow(1.0f, k) * std::pow(pt, m); + sumPmwkRecoEffCor[ieta][ipt][m][k] += std::pow(wIncl, k) * std::pow(pt, m); + } + sumWkReco[ieta][ipt][k] += std::pow(1.0f, k); + sumWkRecoEffCor[ieta][ipt][k] += std::pow(wIncl, k); + } + } + } + + const bool isPion = selectionPion(track); + const bool isKaon = selectionKaon(track); + const bool isProton = selectionProton(track); + + if (isPion || isKaon || isProton){ + float m = isPion ? o2::constants::physics::MassPiPlus :isKaon ? o2::constants::physics::MassKPlus :o2::constants::physics::MassProton; + float E = std::sqrt(p * p + m * m); + float Et = E * (pt / p); // E_T = E * sin(theta) + float effPid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 0); + float fakePid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 1); + float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); + float wPid = flatWeightPid * (1.0 - fakePid) / effPid; + if(effPid >= 1.f || fakePid >= 1.f || !isfinite(effPid) || effPid <= kFloatEpsilon || !isfinite(fakePid) || !isfinite(flatWeightPid)) continue; + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + for (int k = 0; k < KIntK; ++k) { + for (int m = 0; m < KIntM; ++m) { + sumPmwkRecoEt[ieta][ipt][m][k] += std::pow(1.0f, k) * std::pow(Et, m); + sumPmwkRecoEffCorEt[ieta][ipt][m][k] += std::pow(wPid, k) * std::pow(Et, m); + } + sumWkRecoEt[ieta][ipt][k] += std::pow(1.0f, k); + sumWkRecoEffCorEt[ieta][ipt][k] += std::pow(wPid, k); + } + } + } + } + + + for (int ieta = 0; ieta < KNEta; ++ieta) { + for (int ipt = 0; ipt < KNpT; ++ipt) { + const int ibx = pmeanTruNchEtabinPtbinStep2->GetXaxis()->FindBin(col.multNTracksPV()); + const int iby = ieta + 1; + const int ibz = ipt + 1; + + float mmptTru = pmeanTruNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmptReco = pmeanRecoNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmptRecoEffCor = pmeanRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmetTru = pmeanEtTruNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmetReco = pmeanEtRecoNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmetRecoEffCor = pmeanEtRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + + if (isfinite(mmptTru)) std::tie(meanTru[ieta][ipt], c2Tru[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkTru[ieta][ipt], sumWkTru[ieta][ipt], mmptTru); + if (isfinite(mmptReco)) std::tie(meanReco[ieta][ipt], c2Reco[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkReco[ieta][ipt], sumWkReco[ieta][ipt], mmptReco); + if (isfinite(mmptRecoEffCor)) std::tie(meanRecoEffCor[ieta][ipt], c2RecoEffCor[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEffCor[ieta][ipt], sumWkRecoEffCor[ieta][ipt], mmptRecoEffCor); + + if (isfinite(mmetTru)) std::tie(meanTruEt[ieta][ipt], c2TruEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkTruEt[ieta][ipt], sumWkTruEt[ieta][ipt], mmetTru); + if (isfinite(mmetReco)) std::tie(meanRecoEt[ieta][ipt], c2RecoEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEt[ieta][ipt], sumWkRecoEt[ieta][ipt], mmetReco); + if (isfinite(mmetRecoEffCor)) std::tie(meanRecoEffCorEt[ieta][ipt], c2RecoEffCorEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEffCorEt[ieta][ipt], sumWkRecoEffCorEt[ieta][ipt], mmetRecoEffCor); + } + } + } + if (std::isfinite(c2Tru[0][0])) { + histos.fill(HIST("MCGen/Prof_C2_Cent"), cent, c2Tru[0][0]); + histos.fill(HIST("MCGen/Prof_C2_Mult"), col.multNTracksPV(), c2Tru[0][0]); + } + if (std::isfinite(c2TruEt[0][0])) { + histos.fill(HIST("MCGen/Prof_C2Et_Cent"), cent, c2TruEt[0][0]); + histos.fill(HIST("MCGen/Prof_C2Et_Mult"), col.multNTracksPV(), c2TruEt[0][0]); + } + // "MCReco" + if (std::isfinite(c2Reco[0][0])) { + histos.fill(HIST("MCReco/Prof_C2_Cent"), cent, c2Reco[0][0]); + histos.fill(HIST("MCReco/Prof_C2_Mult"), col.multNTracksPV(), c2Reco[0][0]); + } + if (std::isfinite(c2RecoEt[0][0])) { + histos.fill(HIST("MCReco/Prof_C2Et_Cent"), cent, c2RecoEt[0][0]); + histos.fill(HIST("MCReco/Prof_C2Et_Mult"), col.multNTracksPV(), c2RecoEt[0][0]); + } + + if (std::isfinite(c2RecoEffCor[0][0])) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2_Cent"), cent, c2RecoEffCor[0][0]); + histos.fill(HIST("MCRecoEffCorr/Prof_C2_Mult"), col.multNTracksPV(), c2RecoEffCor[0][0]); + } + if (std::isfinite(c2RecoEffCorEt[0][0])) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2Et_Cent"), cent, c2RecoEffCorEt[0][0]); + histos.fill(HIST("MCRecoEffCorr/Prof_C2Et_Mult"), col.multNTracksPV(), c2RecoEffCorEt[0][0]); + } + + if (std::isfinite(sumWkTru[0][0][1])) { + histos.fill(HIST("MCGen/Prof_cent_Nchrec"), cent, sumWkTru[0][0][1]); + histos.fill(HIST("MCGen/Prof_MeanpT_Cent"), cent, meanTru[0][0]); + histos.fill(HIST("MCGen/Prof_MeanpT_Mult"), col.multNTracksPV(), meanTru[0][0]); + } + if (std::isfinite(sumWkTruEt[0][0][1])) { + histos.fill(HIST("MCGen/Prof_MeanEt_Cent"), cent, meanTruEt[0][0]); + histos.fill(HIST("MCGen/Prof_MeanEt_Mult"), col.multNTracksPV(), meanTruEt[0][0]); + } + // "MCReco" + if (std::isfinite(sumWkReco[0][0][1])) { + histos.fill(HIST("MCReco/Prof_cent_Nchrec"), cent, sumWkReco[0][0][1]); + histos.fill(HIST("MCReco/Prof_MeanpT_Cent"), cent, meanReco[0][0]); + histos.fill(HIST("MCReco/Prof_MeanpT_Mult"), col.multNTracksPV(), meanReco[0][0]); + } + if (std::isfinite(sumWkRecoEt[0][0][1])) { + histos.fill(HIST("MCReco/Prof_MeanEt_Cent"), cent, meanRecoEt[0][0]); + histos.fill(HIST("MCReco/Prof_MeanEt_Mult"), col.multNTracksPV(), meanRecoEt[0][0]); + } + // "MCRecoEffCorr" + if (std::isfinite(sumWkRecoEffCor[0][0][1])) { + histos.fill(HIST("MCRecoEffCorr/Prof_cent_Nchrec"), cent, sumWkRecoEffCor[0][0][1]); + histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Cent"), cent, meanRecoEffCor[0][0]); + histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Mult"), col.multNTracksPV(), meanRecoEffCor[0][0]); + } + if (std::isfinite(sumWkRecoEffCorEt[0][0][1])) { + histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Cent"), cent, meanRecoEffCorEt[0][0]); + histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Mult"), col.multNTracksPV(), meanRecoEffCorEt[0][0]); + } + + for (int ieta = 0; ieta < KNEta; ++ieta){ + for (int ipt = 0; ipt < KNpT; ++ipt){ + if (std::isfinite(sumWkTru[ieta][ipt][1])) histos.fill(HIST("pmeanTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt,meanTru[ieta][ipt]); + if (std::isfinite(sumWkReco[ieta][ipt][1])) histos.fill(HIST("pmeanRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt,meanReco[ieta][ipt]); + if (std::isfinite(sumWkRecoEffCor[ieta][ipt][1])) histos.fill(HIST("pmeanRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt,meanRecoEffCor[ieta][ipt]); + if (std::isfinite(sumWkTruEt[ieta][ipt][1])) histos.fill(HIST("pmeanEtTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt,meanTruEt[ieta][ipt]); + if (std::isfinite(sumWkRecoEt[ieta][ipt][1])) histos.fill(HIST("pmeanEtRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt,meanRecoEt[ieta][ipt]); + if (std::isfinite(sumWkRecoEffCorEt[ieta][ipt][1])) histos.fill(HIST("pmeanEtRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt,meanRecoEffCorEt[ieta][ipt]); + } + } + + float p1kBarTru[KNEta][KNpT]{}, p1kBarReco[KNEta][KNpT]{},p1kBarRecoEffCor[KNEta][KNpT]{}; + float p1kBarTruEt[KNEta][KNpT]{}, p1kBarRecoEt[KNEta][KNpT]{}, p1kBarRecoEffCorEt[KNEta][KNpT]{}; + for (int ieta = 0; ieta < KNEta; ++ieta) { + for (int ipt = 0; ipt < KNpT; ++ipt) { + const int ibx = pmeanTruNchEtabinPtbinStep2->GetXaxis()->FindBin(col.multNTracksPV()); + const int iby = ieta + 1; + const int ibz = ipt + 1; + + float mmptTru = pmeanTruNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmptReco = pmeanRecoNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmptRecoEffCor = pmeanRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmetTru = pmeanEtTruNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmetReco = pmeanEtRecoNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmetRecoEffCor = pmeanEtRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + + // pT deviations + if (mmptTru != 0.0) p1kBarTru[ieta][ipt] = meanTru[ieta][ipt] - mmptTru; + if (mmptReco != 0.0) p1kBarReco[ieta][ipt] = meanReco[ieta][ipt] - mmptReco; + if (mmptRecoEffCor != 0.0) p1kBarRecoEffCor[ieta][ipt] = meanRecoEffCor[ieta][ipt] - mmptRecoEffCor; + // Et deviations + if (mmetTru != 0.0) p1kBarTruEt[ieta][ipt] = meanTruEt[ieta][ipt] - mmetTru; + if (mmetReco != 0.0) p1kBarRecoEt[ieta][ipt] = meanRecoEt[ieta][ipt] - mmetReco; + if (mmetRecoEffCor != 0.0)p1kBarRecoEffCorEt[ieta][ipt] = meanRecoEffCorEt[ieta][ipt] - mmetRecoEffCor; + } + } + + + // 1D Covariance (vs eta) + for (int ietaA = 1; ietaA <=(KNEta-1)/2; ++ietaA) { + int ietaC = KNEta - ietaA; + float valy = kHalf * (etaLw[ietaC] + etaUp[ietaC]); + { + const int ipt = 0; + float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCGen/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCGen/Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < kCentCovCut) histos.fill(HIST("MCGen/Prof_ipt0_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCGen/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCGen/Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < kCentCovCut) histos.fill(HIST("MCGen/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); + } + } + + // ipt = 1 + { + const int ipt = 1; + float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCGen/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCGen/Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < kCentCovCut) histos.fill(HIST("MCGen/Prof_ipt0_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCGen/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCGen/Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < kCentCovCut) histos.fill(HIST("MCGen/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); + } + } + // ipt = 2 + { + const int ipt = 2; + float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCGen/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCGen/Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < kCentCovCut) histos.fill(HIST("MCGen/Prof_ipt2_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCGen/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCGen/Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < kCentCovCut) histos.fill(HIST("MCGen/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); + } + } + } + + for (int ietaA = 1; ietaA < KNEta; ++ietaA) { + for (int ietaC = 1; ietaC < KNEta; ++ietaC) { + float valx = 0.5f * (etaLw[ietaA] + etaUp[ietaA]); + float valy = kHalf * (etaLw[ietaC] + etaUp[ietaC]); + // ipt = 0 + { + const int ipt = 0; + float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; + if(std::isfinite(c2Sub)) histos.fill(HIST("MCGen/Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; + if(std::isfinite(c2SubEt)) histos.fill(HIST("MCGen/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + } + // ipt = 1 + { + const int ipt = 1; + float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; + if(std::isfinite(c2Sub)) histos.fill(HIST("MCGen/Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; + if(std::isfinite(c2SubEt)) histos.fill(HIST("MCGen/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + } + // ipt = 2 + { + const int ipt = 2; + float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; + if(std::isfinite(c2Sub)) histos.fill(HIST("MCGen/Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; + if(std::isfinite(c2SubEt)) histos.fill(HIST("MCGen/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + } + } + } + + + // --- MCReco Covariance (1D vs eta) --- + for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { + int ietaC = KNEta - ietaA; + float valy = kHalf * (etaLw[ietaC] + etaUp[ietaC]); // 0.5 for averaging + + // ipt = 0 + { + const int ipt = 0; + float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCReco/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCReco/Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < kCentCovCut) histos.fill(HIST("MCReco/Prof_ipt0_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCReco/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCReco/Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < kCentCovCut) histos.fill(HIST("MCReco/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); + } + } + + // ipt = 1 + { + const int ipt = 1; + float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCReco/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCReco/Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < kCentCovCut) histos.fill(HIST("MCReco/Prof_ipt1_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCReco/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCReco/Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < kCentCovCut) histos.fill(HIST("MCReco/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); + } + } + + // ipt = 2 + { + const int ipt = 2; + float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCReco/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCReco/Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < kCentCovCut) histos.fill(HIST("MCReco/Prof_ipt2_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCReco/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCReco/Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < kCentCovCut) histos.fill(HIST("MCReco/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); + } + } + } + + // --- MCReco Covariance (2D etaA vs etaC) --- + for (int ietaA = 1; ietaA < KNEta; ++ietaA) { + for (int ietaC = 1; ietaC < KNEta; ++ietaC) { + float valx = 0.5f * (etaLw[ietaA] + etaUp[ietaA]); + float valy = kHalf * (etaLw[ietaC] + etaUp[ietaC]); + + // ipt = 0 + { + const int ipt = 0; + float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; + if (std::isfinite(c2Sub)) histos.fill(HIST("MCReco/Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) histos.fill(HIST("MCReco/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + } + + // ipt = 1 + { + const int ipt = 1; + float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; + if (std::isfinite(c2Sub)) histos.fill(HIST("MCReco/Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) histos.fill(HIST("MCReco/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + } + + // ipt = 2 + { + const int ipt = 2; + float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; + if (std::isfinite(c2Sub)) histos.fill(HIST("MCReco/Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) histos.fill(HIST("MCReco/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + } + } + } + + // --- MCRecoEffCorr Covariance (1D vs eta) --- + for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { + int ietaC = KNEta - ietaA; + float valy = kHalf * (etaLw[ietaC] + etaUp[ietaC]); + + // ipt = 0 + { + const int ipt = 0; + float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < kCentCovCut) histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < kCentCovCut) histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); + } + } + + // ipt = 1 + { + const int ipt = 1; + float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < kCentCovCut) histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < kCentCovCut) histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); + } + } + + // ipt = 2 + { + const int ipt = 2; + float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < kCentCovCut) histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < kCentCovCut) histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); + } + } + } + + // --- MCRecoEffCorr Covariance (2D etaA vs etaC) --- + for (int ietaA = 1; ietaA < KNEta; ++ietaA) { + for (int ietaC = 1; ietaC < KNEta; ++ietaC) { + float valx = 0.5f * (etaLw[ietaA] + etaUp[ietaA]); + float valy = kHalf * (etaLw[ietaC] + etaUp[ietaC]); + + // ipt = 0 + { + const int ipt = 0; + float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; + if (std::isfinite(c2Sub)) histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + } + + // ipt = 1 + { + const int ipt = 1; + float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; + if (std::isfinite(c2Sub)) histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + } + + // ipt = 2 + { + const int ipt = 2; + float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; + if (std::isfinite(c2Sub)) histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + } + } + } + + } + } + LOGF(info, "FINISHED RUNNING processMCFluc (pT + Et)"); + } + PROCESS_SWITCH(RadFlowDecorr, processMCFluc, "process MC to calculate pt/Et fluc", cfgRunMCFluc); + + void processGetFlat(AodCollisionsSel::iterator const& coll,aod::BCsWithTimestamps const&,AodTracksSel const& tracks) + { + if (!isEventSelected(coll)) return; + float cent = getCentrality(coll); + if (cent < 0 || cent > 80) return; + for (const auto& track : tracks) { + if (!isTrackSelected(track)) continue; + float p = track.p(); // ADDED + float eta = track.eta(); + float phi = track.phi(); + if (p < kFloatEpsilon) continue; + histos.fill(HIST("hCentEtaPhi"), cent, eta, phi); + const bool isPion = selectionPion(track); + const bool isKaon = selectionKaon(track); + const bool isProton = selectionProton(track); + if (isPion || isKaon || isProton) { + histos.fill(HIST("hCentEtaPhi_PID"), cent, eta, phi); + } + } + } + PROCESS_SWITCH(RadFlowDecorr, processGetFlat,"process real data to calculate mean pT and Et", cfgRunGetFlat); + + void processDataMean(AodCollisionsSel::iterator const& coll,aod::BCsWithTimestamps const&,AodTracksSel const& tracks) + { + float sumWi[KNEta][KNpT]{}, sumWipti[KNEta][KNpT]{}; + float sumWiEt[KNEta][KNpT]{}, sumWiEtVal[KNEta][KNpT]{}; + if (!isEventSelected(coll)) return; + float cent = getCentrality(coll); + if (cent < 0 || cent > 80) return; + histos.fill(HIST("hZvtx_after_sel"), coll.posZ()); + histos.fill(HIST("hCentrality"), cent); + + histos.fill(HIST("Hist2D_globalTracks_PVTracks"), coll.multNTracksPV(), tracks.size()); + histos.fill(HIST("Hist2D_cent_nch"), tracks.size(), cent); + + for (const auto& track : tracks) { + if (!isTrackSelected(track)) continue; + float pt = track.pt(); + float eta = track.eta(); + float p = track.p(); + float phi = track.phi(); + if (p < kFloatEpsilon) continue; + histos.fill(HIST("hP"), p); + histos.fill(HIST("hPt"), pt); + histos.fill(HIST("hEta"), eta); + histos.fill(HIST("hPhi"), track.phi()); + + float effIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 0); + float fakeIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 1); + float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); + float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; + if (!std::isfinite(wIncl) || wIncl <= kFloatEpsilon || effIncl <= kFloatEpsilon) continue; + + histos.fill(HIST("hCentEtaPhi"), cent, eta, track.phi()); + histos.fill(HIST("hCentEtaPhiWtd"), cent, eta, track.phi(), flatWeightIncl); + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + sumWi[ieta][ipt] += wIncl; + sumWipti[ieta][ipt] += wIncl * pt; + } + } + + const bool isPion = selectionPion(track); + const bool isKaon = selectionKaon(track); + const bool isProton = selectionProton(track); + if (isPion || isKaon || isProton) { + + float effPid = getEfficiency(coll.multNTracksPV(), pt, eta, kCombinedPID, 0); + float fakePid = getEfficiency(coll.multNTracksPV(), pt, eta, kCombinedPID, 1); + float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); + float wPid = flatWeightPid * (1.0 - fakePid) / effPid; + if (!std::isfinite(wPid) || wPid <= kFloatEpsilon || effPid <= kFloatEpsilon) continue; + + histos.fill(HIST("hCentEtaPhiWtd_PID"), cent, eta, track.phi(), flatWeightPid); + float m = isPion ? o2::constants::physics::MassPiPlus : + isKaon ? o2::constants::physics::MassKPlus : + o2::constants::physics::MassProton; + float E = std::sqrt(p * p + m * m); + float Et = E * (pt / p); // E_T = E * sin(theta) + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + sumWiEt[ieta][ipt] += wPid; + sumWiEtVal[ieta][ipt] += wPid * Et; + } + } + } + } + histos.fill(HIST("Prof_cent_Nchrec"), cent, sumWi[0][0]); + if (isfinite(sumWi[0][0])) histos.fill(HIST("Prof_MeanpT_Cent"), cent, sumWipti[0][0] / sumWi[0][0]); + if (isfinite(sumWiEt[0][0])) histos.fill(HIST("Prof_MeanEt_Cent"), cent, sumWiEtVal[0][0] / sumWiEt[0][0]); + + for (int ieta = 0; ieta < KNEta; ++ieta){ + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (isfinite(sumWi[ieta][ipt])) + histos.fill(HIST("pmean_nch_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, + sumWipti[ieta][ipt] / sumWi[ieta][ipt]); + if (isfinite(sumWiEt[ieta][ipt])) + histos.fill(HIST("pmeanEt_nch_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, + sumWiEtVal[ieta][ipt] / sumWiEt[ieta][ipt]); + } + } + } + PROCESS_SWITCH(RadFlowDecorr, processDataMean,"process real data to calculate mean pT and Et", cfgRunDataMean); + + + void processDataFluc(AodCollisionsSel::iterator const& coll,aod::BCsWithTimestamps const&,AodTracksSel const& tracks) + { + if (!isEventSelected(coll)) return; + float cent = getCentrality(coll); + if (cent < 0 || cent > 80) return; + if (!pmeanNchEtabinPtbinStep2 || !pmeanEtNchEtabinPtbinStep2) { + LOGF(warning, "Data fluc: Mean pT or Et map missing"); + return; + } + + if (!hEff[kInclusive] || !hFake[kInclusive] || !hWeightMap3D[kInclusive] ||!hEff[kCombinedPID] || !hFake[kCombinedPID] || !hWeightMap3D[kCombinedPID]) { + LOGF(warning, "Data fluc: Inclusive or PID correction maps are null"); + return; + } + double sumpmwk[KNEta][KNpT][KIntM][KIntK]{}; + double sumwk[KNEta][KNpT][KIntK]{}; + double sumpmwkEt[KNEta][KNpT][KIntM][KIntK]{}; + double sumwkEt[KNEta][KNpT][KIntK]{}; + double mean[KNEta][KNpT]{}, c2[KNEta][KNpT]{}; + double p1kBar[KNEta][KNpT]{}; + double meanEt[KNEta][KNpT]{}, c2Et[KNEta][KNpT]{}; + double p1kBarEt[KNEta][KNpT]{}; + + for (const auto& track : tracks) { + if (!isTrackSelected(track)) continue; + float pt = track.pt(); + float eta = track.eta(); + float p = track.p(); + float phi = track.phi(); + if (p < kFloatEpsilon) continue; + + float effIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 0); + float fakeIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 1); + float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); + + float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; + if (!std::isfinite(wIncl) || wIncl <= kFloatEpsilon || effIncl <= kFloatEpsilon) continue; + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + for (int k = 0; k < KIntK; ++k) { + for (int m = 0; m < KIntM; ++m) + sumpmwk[ieta][ipt][m][k] += std::pow(wIncl, k) * std::pow(pt, m); + sumwk[ieta][ipt][k] += std::pow(wIncl, k); + } + } + } + + const bool isPion = selectionPion(track); + const bool isKaon = selectionKaon(track); + const bool isProton = selectionProton(track); + if (isPion || isKaon || isProton) { + float effPid = getEfficiency(coll.multNTracksPV(), pt, eta, kCombinedPID, 0); + float fakePid = getEfficiency(coll.multNTracksPV(), pt, eta, kCombinedPID, 1); + float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); + + float wPid = flatWeightPid * (1.0 - fakePid) / effPid; + if (!std::isfinite(wPid) || wPid <= kFloatEpsilon || effPid <= kFloatEpsilon) continue; + + float m = isPion ? o2::constants::physics::MassPiPlus : + isKaon ? o2::constants::physics::MassKPlus : + o2::constants::physics::MassProton; + + float E = std::sqrt(p * p + m * m); + float Et = E * (pt / p); // E_T = E * sin(theta) + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + for (int k = 0; k < KIntK; ++k) { + for (int m = 0; m < KIntM; ++m) + sumpmwkEt[ieta][ipt][m][k] += std::pow(wPid, k) * std::pow(Et, m); + sumwkEt[ieta][ipt][k] += std::pow(wPid, k); + } + } + } + } + } + for (int ieta = 0; ieta < KNEta; ++ieta) + for (int ipt = 0; ipt < KNpT; ++ipt) { + const int ibx = pmeanNchEtabinPtbinStep2->GetXaxis()->FindBin(coll.multNTracksPV()); + const int iby = ieta + 1; + const int ibz = ipt + 1; + float mmpt = pmeanNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmet = pmeanEtNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + + mean[ieta][ipt] = sumpmwk[ieta][ipt][1][1]/sumwk[ieta][ipt][1]; + meanEt[ieta][ipt] = sumpmwkEt[ieta][ipt][1][1]/sumwkEt[ieta][ipt][1]; + + if (std::isfinite(mmpt)) { + std::tie(mean[ieta][ipt], c2[ieta][ipt]) = + calculateMeanAndC2FromSums(sumpmwk[ieta][ipt], sumwk[ieta][ipt], mmpt); + p1kBar[ieta][ipt] = mean[ieta][ipt] - mmpt; + } + if (std::isfinite(mmet)) { + std::tie(meanEt[ieta][ipt], c2Et[ieta][ipt]) = + calculateMeanAndC2FromSums(sumpmwkEt[ieta][ipt], sumwkEt[ieta][ipt], mmet); + p1kBarEt[ieta][ipt] = meanEt[ieta][ipt] - mmet; + } + } + + if (std::isfinite(c2[0][0])) histos.fill(HIST("Prof_C2_Cent"), cent, c2[0][0]); + if (std::isfinite(c2Et[0][0])) histos.fill(HIST("Prof_C2Et_Cent"), cent, c2Et[0][0]); + if (std::isfinite(sumwk[0][0][1])) { + histos.fill(HIST("Prof_MeanpT_Cent"), cent, mean[0][0]); + histos.fill(HIST("Prof_MeanpT_Mult"), coll.multNTracksPV(), mean[0][0]); + } + if (std::isfinite(sumwkEt[0][0][1])) { + histos.fill(HIST("Prof_MeanEt_Cent"), cent, meanEt[0][0]); + histos.fill(HIST("Prof_MeanEt_Mult"), coll.multNTracksPV(), meanEt[0][0]); + } + + for (int ieta = 0; ieta < KNEta; ++ieta) + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (std::isfinite(c2[ieta][ipt])) histos.fill(HIST("Prof_C2_Mult_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, c2[ieta][ipt]); + if (std::isfinite(c2Et[ieta][ipt])) histos.fill(HIST("Prof_C2Et_Mult_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, c2Et[ieta][ipt]); + } + + for (int ietaA = 1; ietaA <= (KNEta-1)/2; ++ietaA) { + int ietaC = KNEta - ietaA; + float valy = kHalf * (etaLw[ietaC] + etaUp[ietaC]); + + { + const int ipt = 0; + float c2Sub = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < kCentCovCut) histos.fill(HIST("Prof_ipt0_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < kCentCovCut) histos.fill(HIST("Prof_ipt0_CovEt_Eta"), valy, c2SubEt); + } + } + + { + const int ipt = 1; + float c2Sub = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < kCentCovCut) histos.fill(HIST("Prof_ipt1_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < kCentCovCut) histos.fill(HIST("Prof_ipt1_CovEt_Eta"), valy, c2SubEt); + } + } + + { + const int ipt = 2; + float c2Sub = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < kCentCovCut) histos.fill(HIST("Prof_ipt2_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < kCentCovCut) histos.fill(HIST("Prof_ipt2_CovEt_Eta"), valy, c2SubEt); + } + } + } + + for (int ietaA = 1; ietaA < KNEta; ++ietaA){ + for (int ietaC = 1; ietaC < KNEta; ++ietaC) { + float valx = 0.5f * (etaLw[ietaA] + etaUp[ietaA]); + float valy = kHalf * (etaLw[ietaC] + etaUp[ietaC]); + { + const int ipt = 0; + float covpt = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; + if (std::isfinite(covpt)) histos.fill(HIST("Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, covpt); + + float covet = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; + if (std::isfinite(covet)) histos.fill(HIST("Prof_ipt0_C2SubEt2D_Mult_etaA_etaC"), cent, valx, valy, covet); + } + + + { + const int ipt = 1; + float covpt = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; + if (std::isfinite(covpt)) histos.fill(HIST("Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, covpt); + + float covet = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; + if (std::isfinite(covet)) histos.fill(HIST("Prof_ipt1_C2SubEt2D_Mult_etaA_etaC"), cent, valx, valy, covet); + } + { + const int ipt = 2; + + float covpt = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; + if (std::isfinite(covpt)) histos.fill(HIST("Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, covpt); + + float covet = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; + if (std::isfinite(covet)) histos.fill(HIST("Prof_ipt2_C2SubEt2D_Mult_etaA_etaC"), cent, valx, valy, covet); + } + } + } + } + PROCESS_SWITCH(RadFlowDecorr, processDataFluc,"process real data to calculate fluc pT and Et", cfgRunDataFluc); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; + return workflow; +} From eef2e4e5e478384e6e5d963184806d57b616f3de Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Mon, 10 Nov 2025 19:10:10 +0000 Subject: [PATCH 02/10] Please consider the following formatting changes --- .../EbyEFluctuations/Tasks/RadFlowDecorr.cxx | 2012 +++++++++-------- 1 file changed, 1100 insertions(+), 912 deletions(-) diff --git a/PWGCF/EbyEFluctuations/Tasks/RadFlowDecorr.cxx b/PWGCF/EbyEFluctuations/Tasks/RadFlowDecorr.cxx index 6a772048b30..9bf63b4d27d 100644 --- a/PWGCF/EbyEFluctuations/Tasks/RadFlowDecorr.cxx +++ b/PWGCF/EbyEFluctuations/Tasks/RadFlowDecorr.cxx @@ -11,54 +11,51 @@ /// \file RadFlowDecorr.cxx /// \brief Task for Radial Flow Decorrelation Measurement /// \author Somadutta Bhatta -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "Common/Core/RecoDecay.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/Centrality.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/Multiplicity.h" +#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "CCDB/BasicCCDBManager.h" +#include "CommonConstants/MathConstants.h" +#include "DataFormatsParameters/GRPObject.h" +#include "Framework/ASoAHelpers.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/Configurable.h" +#include "Framework/HistogramRegistry.h" +#include "Framework/Logger.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "Framework/runDataProcessing.h" +#include "MathUtils/Utils.h" +#include "ReconstructionDataFormats/DCA.h" +#include "ReconstructionDataFormats/Track.h" +#include "ReconstructionDataFormats/TrackTPCITS.h" #include "TDirectory.h" #include "TFile.h" -#include "TMath.h" #include "TH1F.h" #include "TH2F.h" #include "TH3F.h" +#include "TMath.h" #include "TProfile.h" #include "TProfile2D.h" #include "TProfile3D.h" -#include "Framework/AnalysisTask.h" -#include "Framework/HistogramRegistry.h" -#include "Framework/runDataProcessing.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/Configurable.h" -#include "Framework/Logger.h" - -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/PIDResponse.h" -#include "Common/DataModel/TrackSelectionTables.h" -#include "Common/Core/trackUtilities.h" -#include "Common/Core/RecoDecay.h" -#include "DataFormatsParameters/GRPObject.h" -#include "CCDB/BasicCCDBManager.h" -#include "ReconstructionDataFormats/DCA.h" -#include "ReconstructionDataFormats/Track.h" -#include "ReconstructionDataFormats/TrackTPCITS.h" -#include "MathUtils/Utils.h" -#include "Framework/O2DatabasePDGPlugin.h" -#include "Common/DataModel/Centrality.h" +#include +#include #include -#include "Framework/Logger.h" -#include "Framework/HistogramRegistry.h" -#include "CommonConstants/MathConstants.h" +#include +#include +#include +#include +#include +#include +#include +#include using namespace o2; using namespace o2::framework; @@ -75,9 +72,9 @@ struct RadFlowDecorr { // --- Linter Fixes: Magic Numbers --- static constexpr float kFloatEpsilon = 1e-6f; -// static constexpr int kPiPlus = o2::constants::physics::Pdg::kPiPlus; -//   static constexpr int kKPlus = o2::constants::physics::Pdg::kKaPlus; -//   static constexpr int kProton = o2::constants::physics::Pdg::kProton; + // static constexpr int kPiPlus = o2::constants::physics::Pdg::kPiPlus; + //   static constexpr int kKPlus = o2::constants::physics::Pdg::kKaPlus; + //   static constexpr int kProton = o2::constants::physics::Pdg::kProton; static constexpr float kCentTestMin = 10.f; static constexpr float kCentTestMaxLo = 60.f; static constexpr float kCentTestMaxHi = 70.f; @@ -115,301 +112,330 @@ struct RadFlowDecorr { static constexpr float kDcaMax = 0.2f; static constexpr int kNbinsPtCoarse = 50; - enum PID { kInclusive = 0, kCombinedPID, kNumPID }; + enum PID { kInclusive = 0, + kCombinedPID, + kNumPID }; const std::vector pidSuffix = {"", "_PID"}; const std::vector etaLw = { -0.8, - -0.8,-0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1, 0.0, 0.1,0.2, 0.3, 0.4, 0.5, 0.6,0.7}; - const std::vector etaUp = { - 0.8, - -0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8}; - - const std::vector pTLw = {0.2, 0.2, 0.2}; - const std::vector pTUp = {3, 5.0, 10.0}; - //============================== - // Configurables - //============================== - Configurable cfgVtxZCut{"cfgVtxZCut", 10.f, "z-vertex range"}; - Configurable cfgPtMin{"cfgPtMin", 0.2f, "min pT"}; - Configurable cfgPtMax{"cfgPtMax", 10.0f, "max pT"}; - Configurable cfgEtaCut{"cfgEtaCut", 0.8f, "|η| cut"}; - Configurable cfgDCAXY{"cfgDCAXY", 2.4f, "DCAxy cut"}; - Configurable cfgDCAZ{"cfgDCAZ", 3.2f, "DCAz cut"}; - Configurable cfgTPCClsMin{"cfgTPCClsMin", 70.f, "min TPC clusters"}; - Configurable cfgChi2TPCMax{"cfgChi2TPCMax", 4.0f, "max TPC χ²"}; - Configurable cfgPIDnSigmaCut{"cfgPIDnSigmaCut", 3.f, "TPC PID |nσ| cut"}; - - Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; - Configurable cfgCutTpcChi2NCl{"cfgCutTpcChi2NCl", 2.5f, "Maximum TPCchi2NCl"}; - Configurable cfgCutItsChi2NCl{"cfgCutItsChi2NCl", 36.0f, "Maximum ITSchi2NCl"}; - Configurable cfgCutTrackDcaZ{"cfgCutTrackDcaZ", 2.0f, "Maximum DcaZ"}; - Configurable cfgCutTrackDcaXY{"cfgCutTrackDcaXY", 0.2f, "Maximum DcaZ"}; - - Configurable cfgITScluster{"cfgITScluster", 1, "Minimum Number of ITS cluster"}; - Configurable cfgTPCcluster{"cfgTPCcluster", 80, "Minimum Number of TPC cluster"}; - Configurable cfgTPCnCrossedRows{"cfgTPCnCrossedRows", 70, "Minimum Number of TPC crossed-rows"}; - Configurable cfgCutPtUpperTPC{"cfgCutPtUpperTPC", 0.6f, "Upper pT cut for PID using TPC only"}; - Configurable cfgnSigmaOtherParticles{"cfgnSigmaOtherParticles", 3.0f, "PID nSigma cut to remove other particles (default:3)"}; - Configurable cfgnSigmaCutTPC{"cfgnSigmaCutTPC", 2.0f, "PID nSigma cut for TPC"}; - Configurable cfgnSigmaCutTOF{"cfgnSigmaCutTOF", 2.0f, "PID nSigma cut for TOF"}; - Configurable cfgnSigmaCutCombTPCTOF{"cfgnSigmaCutCombTPCTOF", 2.0f, "PID nSigma combined cut for TPC and TOF"}; - Configurable cfgCutPtLower{"cfgCutPtLower", 0.2f, "Lower pT cut"}; - Configurable cfgCutPtLowerProt{"cfgCutPtLowerProt", 0.2f, "Lower pT cut"}; - Configurable cfgCutPtUpper{"cfgCutPtUpper", 10.0f, "Higher pT cut for inclusive hadron analysis"}; - Configurable cfgCutPtUpperPID{"cfgCutPtUpperPID", 6.0f, "Higher pT cut for identified particle analysis"}; - Configurable cfgCutEta{"cfgCutEta", 0.8f, "absolute Eta cut"}; - Configurable cfgCutEtaLeft{"cfgCutEtaLeft", 0.8f, "Left end of eta gap"}; - Configurable cfgCutEtaRight{"cfgCutEtaRight", 0.8f, "Right end of eta gap"}; - Configurable cfgNSubsample{"cfgNSubsample", 10, "Number of subsamples"}; - Configurable cfgCentralityChoice{"cfgCentralityChoice", 1, "Which centrality estimator? 1-->FT0C, 2-->FT0A, 3-->FT0M, 4-->FV0A"}; - Configurable cfgEvSelkNoSameBunchPileup{"cfgEvSelkNoSameBunchPileup", true, "Pileup removal"}; - Configurable cfgUseGoodITSLayerAllCut{"cfgUseGoodITSLayerAllCut", true, "Remove time interval with dead ITS zone"}; - Configurable cfgEvSelkNoITSROFrameBorder{"cfgEvSelkNoITSROFrameBorder", true, "ITSROFrame border event selection cut"}; - Configurable cfgEvSelkNoTimeFrameBorder{"cfgEvSelkNoTimeFrameBorder", true, "TimeFrame border event selection cut"}; - - - //============================== - // Services and registry - //============================== - Service ccdb; - Service pdg; - HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - //============================== - // External objects (shared across processes) - //============================== - // ### MODIFICATION ### - // Store maps in arrays, one for each PID type (kInclusive, kCombinedPID) - std::array hEff{}; - std::array hFake{}; - std::array hWeightMap3D{}; // (cent, eta, phi) - // #################### - // mean pT / Et profiles loaded in init() - // --- pT Profiles --- - TProfile3D* pmeanTruNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanRecoNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanRecoMatchedNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanRecoEffcorrNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanRecoMatchedEffcorrNchEtabinPtbinStep2 = nullptr; - // --- Et Profiles --- - TProfile3D* pmeanEtTruNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanEtRecoNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanEtRecoMatchedNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanEtRecoEffcorrNchEtabinPtbinStep2 = nullptr; // This one was already here - TProfile3D* pmeanEtRecoMatchedEffcorrNchEtabinPtbinStep2 = nullptr; - // --- Data Profiles --- - TProfile3D* pmeanNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanEtNchEtabinPtbinStep2 = nullptr; - //============================== - // Basic helpers - //============================== - // Line 131 - template bool isEventSelected(const T& col) { - if (!col.sel8()) return false; - if (std::abs(col.posZ()) > cfgCutVertex) return false; - if (cfgEvSelkNoSameBunchPileup && !col.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) return false; - if (cfgEvSelkNoITSROFrameBorder && !col.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) return false; - if (cfgEvSelkNoTimeFrameBorder && !col.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) return false; - return true; - } + -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7}; + const std::vector etaUp = { + 0.8, + -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8}; + + const std::vector pTLw = {0.2, 0.2, 0.2}; + const std::vector pTUp = {3, 5.0, 10.0}; + //============================== + //  Configurables + //============================== + Configurable cfgVtxZCut{"cfgVtxZCut", 10.f, "z-vertex range"}; + Configurable cfgPtMin{"cfgPtMin", 0.2f, "min pT"}; + Configurable cfgPtMax{"cfgPtMax", 10.0f, "max pT"}; + Configurable cfgEtaCut{"cfgEtaCut", 0.8f, "|η| cut"}; + Configurable cfgDCAXY{"cfgDCAXY", 2.4f, "DCAxy cut"}; + Configurable cfgDCAZ{"cfgDCAZ", 3.2f, "DCAz cut"}; + Configurable cfgTPCClsMin{"cfgTPCClsMin", 70.f, "min TPC clusters"}; + Configurable cfgChi2TPCMax{"cfgChi2TPCMax", 4.0f, "max TPC χ²"}; + Configurable cfgPIDnSigmaCut{"cfgPIDnSigmaCut", 3.f, "TPC PID |nσ| cut"}; + + Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; + Configurable cfgCutTpcChi2NCl{"cfgCutTpcChi2NCl", 2.5f, "Maximum TPCchi2NCl"}; + Configurable cfgCutItsChi2NCl{"cfgCutItsChi2NCl", 36.0f, "Maximum ITSchi2NCl"}; + Configurable cfgCutTrackDcaZ{"cfgCutTrackDcaZ", 2.0f, "Maximum DcaZ"}; + Configurable cfgCutTrackDcaXY{"cfgCutTrackDcaXY", 0.2f, "Maximum DcaZ"}; + + Configurable cfgITScluster{"cfgITScluster", 1, "Minimum Number of ITS cluster"}; + Configurable cfgTPCcluster{"cfgTPCcluster", 80, "Minimum Number of TPC cluster"}; + Configurable cfgTPCnCrossedRows{"cfgTPCnCrossedRows", 70, "Minimum Number of TPC crossed-rows"}; + Configurable cfgCutPtUpperTPC{"cfgCutPtUpperTPC", 0.6f, "Upper pT cut for PID using TPC only"}; + Configurable cfgnSigmaOtherParticles{"cfgnSigmaOtherParticles", 3.0f, "PID nSigma cut to remove other particles (default:3)"}; + Configurable cfgnSigmaCutTPC{"cfgnSigmaCutTPC", 2.0f, "PID nSigma cut for TPC"}; + Configurable cfgnSigmaCutTOF{"cfgnSigmaCutTOF", 2.0f, "PID nSigma cut for TOF"}; + Configurable cfgnSigmaCutCombTPCTOF{"cfgnSigmaCutCombTPCTOF", 2.0f, "PID nSigma combined cut for TPC and TOF"}; + Configurable cfgCutPtLower{"cfgCutPtLower", 0.2f, "Lower pT cut"}; + Configurable cfgCutPtLowerProt{"cfgCutPtLowerProt", 0.2f, "Lower pT cut"}; + Configurable cfgCutPtUpper{"cfgCutPtUpper", 10.0f, "Higher pT cut for inclusive hadron analysis"}; + Configurable cfgCutPtUpperPID{"cfgCutPtUpperPID", 6.0f, "Higher pT cut for identified particle analysis"}; + Configurable cfgCutEta{"cfgCutEta", 0.8f, "absolute Eta cut"}; + Configurable cfgCutEtaLeft{"cfgCutEtaLeft", 0.8f, "Left end of eta gap"}; + Configurable cfgCutEtaRight{"cfgCutEtaRight", 0.8f, "Right end of eta gap"}; + Configurable cfgNSubsample{"cfgNSubsample", 10, "Number of subsamples"}; + Configurable cfgCentralityChoice{"cfgCentralityChoice", 1, "Which centrality estimator? 1-->FT0C, 2-->FT0A, 3-->FT0M, 4-->FV0A"}; + Configurable cfgEvSelkNoSameBunchPileup{"cfgEvSelkNoSameBunchPileup", true, "Pileup removal"}; + Configurable cfgUseGoodITSLayerAllCut{"cfgUseGoodITSLayerAllCut", true, "Remove time interval with dead ITS zone"}; + Configurable cfgEvSelkNoITSROFrameBorder{"cfgEvSelkNoITSROFrameBorder", true, "ITSROFrame border event selection cut"}; + Configurable cfgEvSelkNoTimeFrameBorder{"cfgEvSelkNoTimeFrameBorder", true, "TimeFrame border event selection cut"}; + + //============================== + //  Services and registry + //============================== + Service ccdb; + Service pdg; + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + //============================== + //  External objects (shared across processes) + //============================== + // ### MODIFICATION ### + // Store maps in arrays, one for each PID type (kInclusive, kCombinedPID) + std::array hEff{}; + std::array hFake{}; + std::array hWeightMap3D{}; // (cent, eta, phi) + // #################### + // mean pT / Et profiles loaded in init() + // --- pT Profiles --- + TProfile3D* pmeanTruNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanRecoNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanRecoMatchedNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanRecoEffcorrNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanRecoMatchedEffcorrNchEtabinPtbinStep2 = nullptr; + // --- Et Profiles --- + TProfile3D* pmeanEtTruNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanEtRecoNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanEtRecoMatchedNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanEtRecoEffcorrNchEtabinPtbinStep2 = nullptr; // This one was already here + TProfile3D* pmeanEtRecoMatchedEffcorrNchEtabinPtbinStep2 = nullptr; + // --- Data Profiles --- + TProfile3D* pmeanNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanEtNchEtabinPtbinStep2 = nullptr; + //============================== + //  Basic helpers + //============================== + // Line 131 + template + bool isEventSelected(const T& col) + { + if (!col.sel8()) + return false; + if (std::abs(col.posZ()) > cfgCutVertex) + return false; + if (cfgEvSelkNoSameBunchPileup && !col.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) + return false; + if (cfgEvSelkNoITSROFrameBorder && !col.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) + return false; + if (cfgEvSelkNoTimeFrameBorder && !col.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) + return false; + return true; + } + // Line 137 + template + bool isTrackSelected(const T& trk) + { + if (trk.sign() == 0) + return false; + if (!trk.has_collision()) + return false; + if (!trk.isPVContributor()) + return false; + if (!(trk.itsNCls() > cfgITScluster)) + return false; + if (!(trk.tpcNClsFound() >= cfgTPCcluster)) + return false; + if (!(trk.tpcNClsCrossedRows() >= cfgTPCnCrossedRows)) + return false; + + if (trk.pt() < cfgCutPtLower || trk.pt() > cfgCutPtUpper || std::abs(trk.eta()) > cfgCutEta) + return false; + if (std::abs(trk.dcaXY()) > cfgCutTrackDcaXY || std::abs(trk.dcaZ()) > cfgCutTrackDcaZ) + return false; + return true; + } - // Line 137 - template bool isTrackSelected(const T& trk) { - if (trk.sign() == 0) return false; - if (!trk.has_collision()) return false; - if (!trk.isPVContributor()) return false; - if (!(trk.itsNCls() > cfgITScluster)) return false; - if (!(trk.tpcNClsFound() >= cfgTPCcluster)) return false; - if (!(trk.tpcNClsCrossedRows() >= cfgTPCnCrossedRows)) return false; + template + bool isParticleSelected(const T& particle) + { + auto* pd = pdg->GetParticle(particle.pdgCode()); + if (!pd) + return false; + // if (dpt::isStrangeBaryonPDG(particle.pdgCode())) return false; + if (std::abs(pd->Charge()) == 0) + return false; + if (particle.pt() < cfgCutPtLower || particle.pt() > cfgCutPtUpper || std::abs(particle.eta()) > cfgCutEta) + return false; + if (std::abs(particle.vz()) > cfgCutVertex) + return false; + return true; + } - if (trk.pt() < cfgCutPtLower || trk.pt() > cfgCutPtUpper || std::abs(trk.eta()) > cfgCutEta) return false; - if (std::abs(trk.dcaXY()) > cfgCutTrackDcaXY || std::abs(trk.dcaZ()) > cfgCutTrackDcaZ) return false; - return true; - } + // + // // Lines 153-155 + // template bool selectionPion (const T& trk) { return std::abs(trk.tpcNSigmaPi()) < cfgPIDnSigmaCut; } + // template bool selectionKaon (const T& trk) { return std::abs(trk.tpcNSigmaKa()) < cfgPIDnSigmaCut; } + // template bool selectionProton(const T& trk) { return std::abs(trk.tpcNSigmaPr()) < cfgPIDnSigmaCut; } + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + template + bool selectionProton(const T& candidate) + { + if (!candidate.hasTPC()) + return false; + int flag = 0; //! pid check main flag - template - bool isParticleSelected(const T& particle) - { - auto* pd = pdg->GetParticle(particle.pdgCode()); - if (!pd) return false; - // if (dpt::isStrangeBaryonPDG(particle.pdgCode())) return false; - if (std::abs(pd->Charge()) ==0) return false; - if (particle.pt() < cfgCutPtLower || particle.pt() > cfgCutPtUpper || std::abs(particle.eta()) > cfgCutEta) return false; - if (std::abs(particle.vz()) > cfgCutVertex) return false; - return true; + if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC) { + flag = 1; } - - // - // // Lines 153-155 - // template bool selectionPion (const T& trk) { return std::abs(trk.tpcNSigmaPi()) < cfgPIDnSigmaCut; } - // template bool selectionKaon (const T& trk) { return std::abs(trk.tpcNSigmaKa()) < cfgPIDnSigmaCut; } - // template bool selectionProton(const T& trk) { return std::abs(trk.tpcNSigmaPr()) < cfgPIDnSigmaCut; } - //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - template - bool selectionProton(const T& candidate) - { - if (!candidate.hasTPC()) - return false; - int flag = 0; //! pid check main flag - - if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { - if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC) { - flag = 1; - } - if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaPr()) < cfgnSigmaCutTOF) { - flag = 1; - } - } - if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { - float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); - float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); - float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); - - int flag2 = 0; - if (combNSigmaPr < cfgnSigmaOtherParticles) - flag2 += 1; - if (combNSigmaPi < cfgnSigmaOtherParticles) - flag2 += 1; - if (combNSigmaKa < cfgnSigmaOtherParticles) - flag2 += 1; - if (!(flag2 > 1) && !(combNSigmaPr > combNSigmaPi) && !(combNSigmaPr > combNSigmaKa)) { - if (combNSigmaPr < cfgnSigmaCutCombTPCTOF) { - flag = 1; - } - } - } - if (flag == 1) - return true; - else - return false; + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaPr()) < cfgnSigmaCutTOF) { + flag = 1; } - - template - bool selectionPion(const T& candidate) - { - if (!candidate.hasTPC()) - return false; - int flag = 0; //! pid check main flag - - if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { - if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < cfgnSigmaCutTPC) { - flag = 1; - } - if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaPi()) < cfgnSigmaCutTOF) { - flag = 1; - } - } - if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { - float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); - float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); - float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); - - int flag2 = 0; - if (combNSigmaPr < cfgnSigmaOtherParticles) - flag2 += 1; - if (combNSigmaPi < cfgnSigmaOtherParticles) - flag2 += 1; - if (combNSigmaKa < cfgnSigmaOtherParticles) - flag2 += 1; - if (!(flag2 > 1) && !(combNSigmaPi > combNSigmaPr) && !(combNSigmaPi > combNSigmaKa)) { - if (combNSigmaPi < cfgnSigmaCutCombTPCTOF) { - flag = 1; - } - } + } + if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { + float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); + float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); + float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); + + int flag2 = 0; + if (combNSigmaPr < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaPi < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaKa < cfgnSigmaOtherParticles) + flag2 += 1; + if (!(flag2 > 1) && !(combNSigmaPr > combNSigmaPi) && !(combNSigmaPr > combNSigmaKa)) { + if (combNSigmaPr < cfgnSigmaCutCombTPCTOF) { + flag = 1; } - if (flag == 1) - return true; - else - return false; } + } + if (flag == 1) + return true; + else + return false; + } - template - bool selectionKaon(const T& candidate) - { - if (!candidate.hasTPC()) - return false; - int flag = 0; //! pid check main flag + template + bool selectionPion(const T& candidate) + { + if (!candidate.hasTPC()) + return false; + int flag = 0; //! pid check main flag - if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { - if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < cfgnSigmaCutTPC) { - flag = 1; - } - if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaKa()) < cfgnSigmaCutTOF) { - flag = 1; - } - } - if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { - float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); - float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); - float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); - - int flag2 = 0; - if (combNSigmaPr < cfgnSigmaOtherParticles) - flag2 += 1; - if (combNSigmaPi < cfgnSigmaOtherParticles) - flag2 += 1; - if (combNSigmaKa < cfgnSigmaOtherParticles) - flag2 += 1; - if (!(flag2 > 1) && !(combNSigmaKa > combNSigmaPi) && !(combNSigmaKa > combNSigmaPr)) { - if (combNSigmaKa < cfgnSigmaCutCombTPCTOF) { - flag = 1; - } - } + if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < cfgnSigmaCutTPC) { + flag = 1; + } + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaPi()) < cfgnSigmaCutTOF) { + flag = 1; + } + } + if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { + float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); + float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); + float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); + + int flag2 = 0; + if (combNSigmaPr < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaPi < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaKa < cfgnSigmaOtherParticles) + flag2 += 1; + if (!(flag2 > 1) && !(combNSigmaPi > combNSigmaPr) && !(combNSigmaPi > combNSigmaKa)) { + if (combNSigmaPi < cfgnSigmaCutCombTPCTOF) { + flag = 1; } - if (flag == 1) - return true; - else - return false; } + } + if (flag == 1) + return true; + else + return false; + } + template + bool selectionKaon(const T& candidate) + { + if (!candidate.hasTPC()) + return false; + int flag = 0; //! pid check main flag - // Utility helpers - //============================== - float getCentrality(const auto& col) const { - if (cfgCentralityChoice.value == 1) return col.centFT0C(); - if (cfgCentralityChoice.value == 2) return col.centFT0A(); - if (cfgCentralityChoice.value == 3) return col.centFT0M(); - if (cfgCentralityChoice.value == 4) return col.centFV0A(); - return -1.0f; + if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < cfgnSigmaCutTPC) { + flag = 1; } - // - float getEfficiency(float mult, float pt, float eta, PID pidType, int effidx) const { - TH3F* h; - if(effidx==0) h = hEff[pidType]; - if(effidx==1) h = hFake[pidType]; - - if (!h) return -1; - const int ibx = h->GetXaxis()->FindBin(mult); - const int iby = h->GetYaxis()->FindBin(pt); - const int ibz = h->GetZaxis()->FindBin(eta); - float val = h->GetBinContent(ibx, iby, ibz); - return val; + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaKa()) < cfgnSigmaCutTOF) { + flag = 1; + } + } + if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { + float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); + float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); + float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); + + int flag2 = 0; + if (combNSigmaPr < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaPi < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaKa < cfgnSigmaOtherParticles) + flag2 += 1; + if (!(flag2 > 1) && !(combNSigmaKa > combNSigmaPi) && !(combNSigmaKa > combNSigmaPr)) { + if (combNSigmaKa < cfgnSigmaCutCombTPCTOF) { + flag = 1; + } } - - /* - float getEfficiency(float mult, float pt, float eta, PID pidType, int effidx) const { - TH3F* h; - if(effidx==0) h = hEff[pidType]; // Efficiency map - if(effidx==1) h = hFake[pidType]; // Fake map - - if (!h) { - LOGF(error, "getEfficiency: Histogram is null for pidType %d, effidx %d", pidType, effidx); - return -1.0; } + if (flag == 1) + return true; + else + return false; + } + //  Utility helpers + //============================== + float getCentrality(const auto& col) const + { + if (cfgCentralityChoice.value == 1) + return col.centFT0C(); + if (cfgCentralityChoice.value == 2) + return col.centFT0A(); + if (cfgCentralityChoice.value == 3) + return col.centFT0M(); + if (cfgCentralityChoice.value == 4) + return col.centFV0A(); + return -1.0f; + } + // + float getEfficiency(float mult, float pt, float eta, PID pidType, int effidx) const + { + TH3F* h; + if (effidx == 0) + h = hEff[pidType]; + if (effidx == 1) + h = hFake[pidType]; + + if (!h) + return -1; const int ibx = h->GetXaxis()->FindBin(mult); const int iby = h->GetYaxis()->FindBin(pt); const int ibz = h->GetZaxis()->FindBin(eta); float val = h->GetBinContent(ibx, iby, ibz); - - if (effidx == 1) { // This is a FAKE map - // For fakes, "it's ok if it is zero" - // But it's not ok if it's < 0 or >= 1. Set those to 0. - if (val < 0.f || val >= 1.0) { - return -1; + return val; } - return val; // Return the valid fake value (which can be 0) + + /* + float getEfficiency(float mult, float pt, float eta, PID pidType, int effidx) const { + TH3F* h; + if(effidx==0) h = hEff[pidType]; // Efficiency map + if(effidx==1) h = hFake[pidType]; // Fake map + + if (!h) { + LOGF(error, "getEfficiency: Histogram is null for pidType %d, effidx %d", pidType, effidx); + return -1.0; +} + +const int ibx = h->GetXaxis()->FindBin(mult); +const int iby = h->GetYaxis()->FindBin(pt); +const int ibz = h->GetZaxis()->FindBin(eta); +float val = h->GetBinContent(ibx, iby, ibz); + +if (effidx == 1) { // This is a FAKE map +// For fakes, "it's ok if it is zero" +// But it's not ok if it's < 0 or >= 1. Set those to 0. +if (val < 0.f || val >= 1.0) { +return -1; +} +return val; // Return the valid fake value (which can be 0) } // If we are here, this is an EFFICIENCY map (effidx == 0) @@ -460,372 +486,371 @@ return -1; } } */ -// Getter for (Cent, eta, phi) maps (Flattening) -float getFlatteningWeight(float cent, float eta, float phi, PID pidType) const { - TH3F* h = hWeightMap3D[pidType]; - if (!h) return -1; - const int ibx = h->GetXaxis()->FindBin(cent); - const int iby = h->GetYaxis()->FindBin(eta); - const int ibz = h->GetZaxis()->FindBin(phi); - float val = h->GetBinContent(ibx, iby, ibz); - return val; -} - - -template -std::pair calculateMeanAndC2FromSums(const double sumpmwk[KIntM][KIntK], const double sumwk[KIntK], float referenceMeanPt) const -{ - // --- Safety Checks --- - if (sumwk[1] == 0.) { - return {0.f, 0.f}; // No tracks, return 0 + // Getter for (Cent, eta, phi) maps (Flattening) + float getFlatteningWeight(float cent, float eta, float phi, PID pidType) const + { + TH3F* h = hWeightMap3D[pidType]; + if (!h) + return -1; + const int ibx = h->GetXaxis()->FindBin(cent); + const int iby = h->GetYaxis()->FindBin(eta); + const int ibz = h->GetZaxis()->FindBin(phi); + float val = h->GetBinContent(ibx, iby, ibz); + return val; } - double tau1 = sumwk[2] / (sumwk[1] * sumwk[1]); - double denom2 = 1. - tau1; - - if (std::abs(denom2) < kFloatEpsilon) { // Protect against divide-by-zero (e.g., N=1) - // Return mean, but C2 is undefined - double pmk11_safe = sumpmwk[1][1] / sumwk[1]; - return {static_cast(pmk11_safe), 0.f}; - } + template + std::pair calculateMeanAndC2FromSums(const double sumpmwk[KIntM][KIntK], const double sumwk[KIntK], float referenceMeanPt) const + { + // --- Safety Checks --- + if (sumwk[1] == 0.) { + return {0.f, 0.f}; // No tracks, return 0 + } - // --- Calculations --- - double pmk11 = sumpmwk[1][1] / sumwk[1]; + double tau1 = sumwk[2] / (sumwk[1] * sumwk[1]); + double denom2 = 1. - tau1; - double pmk12 = 0.; - if (sumwk[2] != 0.) { - pmk12 = sumpmwk[1][2] / sumwk[2]; - } + if (std::abs(denom2) < kFloatEpsilon) { // Protect against divide-by-zero (e.g., N=1) + // Return mean, but C2 is undefined + double pmk11_safe = sumpmwk[1][1] / sumwk[1]; + return {static_cast(pmk11_safe), 0.f}; + } - double pmk22 = 0.; - if (sumwk[2] != 0.) { - pmk22 = sumpmwk[2][2] / sumwk[2]; - } + // --- Calculations --- + double pmk11 = sumpmwk[1][1] / sumwk[1]; - float calculatedMeanPt = pmk11; // Mean pT is / + double pmk12 = 0.; + if (sumwk[2] != 0.) { + pmk12 = sumpmwk[1][2] / sumwk[2]; + } - double p1kBar1 = pmk11 - referenceMeanPt; - double p2kBar2 = pmk22 - 2. * pmk12 * referenceMeanPt + referenceMeanPt * referenceMeanPt; + double pmk22 = 0.; + if (sumwk[2] != 0.) { + pmk22 = sumpmwk[2][2] / sumwk[2]; + } - double p1kBar1_sq = p1kBar1 * p1kBar1; - double numerator2 = p1kBar1_sq - (tau1 * p2kBar2); + float calculatedMeanPt = pmk11; // Mean pT is / - float C2 = numerator2 / denom2; - return {calculatedMeanPt, C2}; -} + double p1kBar1 = pmk11 - referenceMeanPt; + double p2kBar2 = pmk22 - 2. * pmk12 * referenceMeanPt + referenceMeanPt * referenceMeanPt; -ConfigurableAxis cfgAxisCent{"cfgAxisCent",{0.0, 1.0, 3.0, 5.0, 10, 20, 30, 40, 50, 60, 70, 80, 100},"centrality axis (percentile)"}; // FT0*/FV0A style -const AxisSpec centAxis{cfgAxisCent, "Centrality (%)"}; -static constexpr int kNbinsNch = 5000; -static constexpr float kNchMin = 0.5f; -static constexpr float kNchMax = 5000.5f; -static constexpr int kNbinsNchCoarse = 500; -static constexpr float kNchCoarseMax = 5000.5f; -ConfigurableAxis nChAxis{"nChAxis", {kNbinsNch, kNchMin, kNchMax}, "PV-contributor track multiplicity axis"}; -ConfigurableAxis nChAxis2{"nChAxis2", {kNbinsNchCoarse, kNchMin, kNchCoarseMax}, "PV-contributor track multiplicity axis"}; - -// run switches -Configurable cfgRunGetEff{"cfgRunGetEff", false, "Run MC pass to build efficiency/fake maps"}; -Configurable cfgRunMCMean{"cfgRunMCMean", false, "Run MC mean(pT) & mean(Et)"}; -Configurable cfgRunMCFluc{"cfgRunMCFluc", false, "Run MC fluctuations (C2, subevent)"}; -Configurable cfgRunGetFlat{"cfgRunGetFlat", false, "Run Data Get Flattening Weights"}; -Configurable cfgRunDataMean{"cfgRunDataMean", false, "Run DATA mean(pT) & mean(Et)"}; -Configurable cfgRunDataFluc{"cfgRunDataFluc", false, "Run DATA fluctuations (C2, subevent)"}; -// --- DATA: collisions with centralities and selections --- -using GeneralCollisions = soa::Join< -aod::Collisions, -aod::EvSels, -aod::Mults, -aod::CentFT0As, aod::CentFT0Cs, aod::CentFT0Ms, aod::CentFV0As, -aod::CentNGlobals>; -Filter collisionFilter = nabs(aod::collision::posZ) < cfgVtxZCut; -using AodCollisionsSel = soa::Filtered; - - -using UnfilteredTracks = soa::Join< -aod::Tracks, -aod::TracksExtra, -aod::TrackSelection, -aod::TracksDCA, -aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, -aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr>; -Filter trackFilter = nabs(aod::track::eta) < cfgEtaCut && -aod::track::pt > cfgPtMin && -aod::track::pt < cfgPtMax && -nabs(aod::track::dcaXY) < cfgDCAXY && -nabs(aod::track::dcaZ) < cfgDCAZ; -using AodTracksSel = soa::Filtered; -// --- MC: reconstructed tracks with truth labels --- -using TCs = soa::Join; -using FilteredTCs = soa::Filtered; -// --- MC: collisions with labels --- -using MyRun3MCCollisions = soa::Join< -aod::Collisions, aod::EvSels, aod::Mults, aod::MultsExtra, -aod::CentFT0As, aod::CentFT0Cs, aod::CentFT0Ms, aod::CentFV0As, -aod::CentNGlobals, aod::McCollisionLabels>; -// --- MC: truth-matched tracks --- -using MyMCTracks = soa::Join< -aod::Tracks, aod::TrackSelection, aod::TracksExtra, aod::TracksDCA, -aod::McTrackLabels, -aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, -aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr>; -// --- Preslices (consistent policies) --- -PresliceUnsorted partPerMcCollision = aod::mcparticle::mcCollisionId; -PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; -PresliceUnsorted trackPerMcParticle = aod::mctracklabel::mcParticleId; -Preslice perCollision = aod::track::collisionId; -Preslice trackPerCollision = aod::track::collisionId; - -void declareCommonQA() -{ - histos.add("hZvtx_after_sel", ";z_{vtx} (cm)", kTH1F, {{kNbinsZvtx, kZvtxMin, kZvtxMax}}); - histos.add("hCentrality", ";centrality (%)", kTH1F, {{centAxis}}); - histos.add("Hist2D_globalTracks_PVTracks", ";N_{global};N_{PV}", kTH2F, {{nChAxis2}, {nChAxis2}}); - histos.add("Hist2D_cent_nch", ";N_{PV};cent (%)", kTH2F, {{nChAxis2}, {centAxis}}); - histos.add("hP", ";p (GeV/c)", kTH1F, {{kNbinsP, kPMin, kPMax}}); - histos.add("hPt", ";p_{T} (GeV/c)", kTH1F, {{kNbinsPt, kPtMin, kPtMax}}); - histos.add("hEta", ";#eta", kTH1F, {{kNbinsEta, kEtaMin, kEtaMax}}); - histos.add("hPhi", ";#phi", kTH1F, {{kNbinsPhi, 0., TwoPI}}); - - histos.add("hCentEtaPhi", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - histos.add("hCent1EtaPhi", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - histos.add("hCent7EtaPhi", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - histos.add("hCentEtaPhiWtd", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - histos.add("hCent1EtaPhiWtd", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - histos.add("hCent7EtaPhiWtd", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - - histos.add("hCentEtaPhiWtd_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - histos.add("hCent1EtaPhiWtd_PID", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - histos.add("hCent7EtaPhiWtd_PID", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - - histos.add("hCentEtaPhiTrue", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - histos.add("hCentEtaPhiReco", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - histos.add("hCentEtaPhiRecoMatched", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - - histos.add("hCentEtaPhiTrue_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - histos.add("hCentEtaPhiReco_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - histos.add("hCentEtaPhiRecoMatched_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + double p1kBar1_sq = p1kBar1 * p1kBar1; + double numerator2 = p1kBar1_sq - (tau1 * p2kBar2); -} -void declareMCCommonHists() -{ + float C2 = numerator2 / denom2; + return {calculatedMeanPt, C2}; + } - histos.add("ptResolution", ";p_{T}^{MC};p_{T}^{MC}-p_{T}^{reco}", kTH2F, {{kNbinsPtRes, 0., cfgPtMax}, {kNbinsPtRes, -kPtResMax, kPtResMax}}); - histos.add("ptTruthReco", ";p_{T}^{MC};p_{T}^{reco}", kTH2F, {{kNbinsPtRes, 0., cfgPtMax}, {kNbinsPtRes, 0., cfgPtMax}}); - histos.add("etaResolution", ";#eta^{MC};#eta^{MC}-#eta^{reco}", kTH2F, {{kNbinsEtaRes, -kEtaFineMax, kEtaFineMax}, {kNbinsPtRes, -kEtaResMax, kEtaResMax}}); - histos.add("etaTruthReco", ";#eta^{MC};#eta^{reco}", kTH2F, {{kNbinsPtRes, -kEtaFineMax, kEtaFineMax}, {kNbinsPtRes, -kEtaFineMax, kEtaFineMax}}); - - histos.add("TruthTrackVZ", ";Vz^{MC};Vz^{Reco}", kTH2F, {{kNbinsVz, kVzMin, kVzMax}, {kNbinsVz, kVzMin, kVzMax}}); - histos.add("vzResolution", ";Vz^{MC};Vz^{MC}-Vz^{Reco}", kTH2F, {{kNbinsVz, kVzMin, kVzMax}, {kNbinsVz, -kVzResMax, kVzResMax}}); - - histos.add("h3_AllPrimary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - histos.add("h3_RecoMatchedToPrimary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - histos.add("h3_RecoUnMatchedToPrimary_Secondary",";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - histos.add("h3_RecoUnMatchedToPrimary_Fake", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - histos.add("h3_AllReco", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - - histos.add("h3_AllPrimary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - histos.add("h3_RecoMatchedToPrimary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - histos.add("h3_RecoUnMatchedToPrimary_Secondary_PID",";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - histos.add("h3_RecoUnMatchedToPrimary_Fake_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - histos.add("h3_AllReco_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - - histos.add("h_AllPrimary", ";p_{T}", kTH1F, {{kNbinsP, 0., cfgPtMax}}); - histos.add("h_RecoMatchedToPrimary", ";p_{T}", kTH1F, {{kNbinsPt, 0., kPtMax}}); - histos.add("h_RecoUnMatchedToPrimary",";p_{T}", kTH1F, {{kNbinsPt, 0., kPtMax}}); - histos.add("h_AllReco", ";p_{T}", kTH1F, {{kNbinsPt, 0., kPtMax}}); - - histos.add("hReco_ParticleWeight", ";cent;p_{T};#eta", kTH3F, {{centAxis},{kNbinsPtRes,0.,cfgPtMax},{kNbinsPtRes,-kEtaFineMax,kEtaFineMax}}); - histos.add("hTruth_ParticleWeight", ";cent;p_{T};#eta", kTH3F, {{centAxis},{kNbinsPtRes,0.,cfgPtMax},{kNbinsPtRes,-kEtaFineMax,kEtaFineMax}}); - - histos.add("hDCAxy_Unmatched", ";DCA_{xy} (cm)", kTH1F, {{kNbinsDca, -kDcaMax, kDcaMax}}); - histos.add("hDCAz_Unmatched", ";DCA_{z} (cm)", kTH1F, {{kNbinsDca, -kDcaMax, kDcaMax}}); - histos.add("hDCAxy_NotPrimary", ";DCA_{xy} (cm)", kTH1F, {{kNbinsDca, -kDcaMax, kDcaMax}}); - histos.add("hDCAz_NotPrimary", ";DCA_{z} (cm)", kTH1F, {{kNbinsDca, -kDcaMax, kDcaMax}}); -} + ConfigurableAxis cfgAxisCent{"cfgAxisCent", {0.0, 1.0, 3.0, 5.0, 10, 20, 30, 40, 50, 60, 70, 80, 100}, "centrality axis (percentile)"}; // FT0*/FV0A style + const AxisSpec centAxis{cfgAxisCent, "Centrality (%)"}; + static constexpr int kNbinsNch = 5000; + static constexpr float kNchMin = 0.5f; + static constexpr float kNchMax = 5000.5f; + static constexpr int kNbinsNchCoarse = 500; + static constexpr float kNchCoarseMax = 5000.5f; + ConfigurableAxis nChAxis{"nChAxis", {kNbinsNch, kNchMin, kNchMax}, "PV-contributor track multiplicity axis"}; + ConfigurableAxis nChAxis2{"nChAxis2", {kNbinsNchCoarse, kNchMin, kNchCoarseMax}, "PV-contributor track multiplicity axis"}; + + // run switches + Configurable cfgRunGetEff{"cfgRunGetEff", false, "Run MC pass to build efficiency/fake maps"}; + Configurable cfgRunMCMean{"cfgRunMCMean", false, "Run MC mean(pT) & mean(Et)"}; + Configurable cfgRunMCFluc{"cfgRunMCFluc", false, "Run MC fluctuations (C2, subevent)"}; + Configurable cfgRunGetFlat{"cfgRunGetFlat", false, "Run Data Get Flattening Weights"}; + Configurable cfgRunDataMean{"cfgRunDataMean", false, "Run DATA mean(pT) & mean(Et)"}; + Configurable cfgRunDataFluc{"cfgRunDataFluc", false, "Run DATA fluctuations (C2, subevent)"}; + // --- DATA: collisions with centralities and selections --- + using GeneralCollisions = soa::Join< + aod::Collisions, + aod::EvSels, + aod::Mults, + aod::CentFT0As, aod::CentFT0Cs, aod::CentFT0Ms, aod::CentFV0As, + aod::CentNGlobals>; + Filter collisionFilter = nabs(aod::collision::posZ) < cfgVtxZCut; + using AodCollisionsSel = soa::Filtered; + + using UnfilteredTracks = soa::Join< + aod::Tracks, + aod::TracksExtra, + aod::TrackSelection, + aod::TracksDCA, + aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, + aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr>; + Filter trackFilter = nabs(aod::track::eta) < cfgEtaCut && + aod::track::pt > cfgPtMin&& + aod::track::pt < cfgPtMax&& + nabs(aod::track::dcaXY) < cfgDCAXY&& nabs(aod::track::dcaZ) < cfgDCAZ; + using AodTracksSel = soa::Filtered; + // --- MC: reconstructed tracks with truth labels --- + using TCs = soa::Join; + using FilteredTCs = soa::Filtered; + // --- MC: collisions with labels --- + using MyRun3MCCollisions = soa::Join< + aod::Collisions, aod::EvSels, aod::Mults, aod::MultsExtra, + aod::CentFT0As, aod::CentFT0Cs, aod::CentFT0Ms, aod::CentFV0As, + aod::CentNGlobals, aod::McCollisionLabels>; + // --- MC: truth-matched tracks --- + using MyMCTracks = soa::Join< + aod::Tracks, aod::TrackSelection, aod::TracksExtra, aod::TracksDCA, + aod::McTrackLabels, + aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, + aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr>; + // --- Preslices (consistent policies) --- + PresliceUnsorted partPerMcCollision = aod::mcparticle::mcCollisionId; + PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; + PresliceUnsorted trackPerMcParticle = aod::mctracklabel::mcParticleId; + Preslice perCollision = aod::track::collisionId; + Preslice trackPerCollision = aod::track::collisionId; + + void declareCommonQA() + { + histos.add("hZvtx_after_sel", ";z_{vtx} (cm)", kTH1F, {{kNbinsZvtx, kZvtxMin, kZvtxMax}}); + histos.add("hCentrality", ";centrality (%)", kTH1F, {{centAxis}}); + histos.add("Hist2D_globalTracks_PVTracks", ";N_{global};N_{PV}", kTH2F, {{nChAxis2}, {nChAxis2}}); + histos.add("Hist2D_cent_nch", ";N_{PV};cent (%)", kTH2F, {{nChAxis2}, {centAxis}}); + histos.add("hP", ";p (GeV/c)", kTH1F, {{kNbinsP, kPMin, kPMax}}); + histos.add("hPt", ";p_{T} (GeV/c)", kTH1F, {{kNbinsPt, kPtMin, kPtMax}}); + histos.add("hEta", ";#eta", kTH1F, {{kNbinsEta, kEtaMin, kEtaMax}}); + histos.add("hPhi", ";#phi", kTH1F, {{kNbinsPhi, 0., TwoPI}}); + + histos.add("hCentEtaPhi", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCent1EtaPhi", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCent7EtaPhi", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCentEtaPhiWtd", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCent1EtaPhiWtd", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCent7EtaPhiWtd", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + + histos.add("hCentEtaPhiWtd_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCent1EtaPhiWtd_PID", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCent7EtaPhiWtd_PID", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + + histos.add("hCentEtaPhiTrue", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCentEtaPhiReco", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCentEtaPhiRecoMatched", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + + histos.add("hCentEtaPhiTrue_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCentEtaPhiReco_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCentEtaPhiRecoMatched_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + } + void declareMCCommonHists() + { -void declareMCMeanHists() -{ - // Eff/Fake and weights vs observables - histos.add("Eff_cent", ";cent;#epsilon", kTProfile, {centAxis}); - histos.add("Fake_cent", ";cent;f_{fake}", kTProfile, {centAxis}); - histos.add("wgt_cent", ";cent;w", kTProfile, {centAxis}); - histos.add("Eff_Ntrk", ";N_{PV};#epsilon", kTProfile, {nChAxis2}); - histos.add("Fake_Ntrk", ";N_{PV};f_{fake}", kTProfile, {nChAxis2}); - histos.add("wgt_Ntrk", ";N_{PV};w", kTProfile, {nChAxis2}); - histos.add("Eff_pT", ";p_{T};#epsilon", kTProfile, {{kNbinsPtRes, 0., cfgPtMax}}); - histos.add("Fake_pT", ";p_{T};f_{fake}", kTProfile, {{kNbinsPtRes, 0., cfgPtMax}}); - histos.add("wgt_pT", ";p_{T};w", kTProfile, {{kNbinsPtRes, 0., kPtMax}}); - histos.add("Eff_eta", ";#eta;#epsilon", kTProfile, {{kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - histos.add("Fake_eta", ";#eta;f_{fake}", kTProfile, {{kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - histos.add("wgt_eta", ";#eta;w", kTProfile, {{kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - // MC mean profiles (pT & Et) for various selections - histos.add("MCGen/Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); - histos.add("MCGen/Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); - histos.add("MCGen/Prof_MeanpT_Mult", ";N_{PV};#LT p_{T}#GT",kTProfile, {nChAxis}); - histos.add("pmeanTruNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); - histos.add("pmeanRecoNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); - histos.add("pmeanRecoMatchedNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); - histos.add("pmeanRecoEffcorrNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); - histos.add("pmeanRecoMatchedEffcorrNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); - // Et versions - histos.add("MCGen/Prof_MeanEt_Cent",";cent;#LT E_{T}#GT", kTProfile, {centAxis}); - histos.add("MCGen/Prof_MeanEt_Mult",";N_{PV};#LT E_{T}#GT",kTProfile, {nChAxis}); - histos.add("pmeanEtTruNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); - histos.add("pmeanEtRecoNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); - histos.add("pmeanEtRecoMatchedNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); - histos.add("pmeanEtRecoEffcorrNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); - histos.add("pmeanEtRecoMatchedEffcorrNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); - // Clone sets for Reco/Matched/EffCorr variants - - - histos.addClone("MCGen/", "MCReco/"); - histos.addClone("MCGen/", "MCRecoMatched/"); - histos.addClone("MCGen/", "MCRecoEffCorr/"); - histos.addClone("MCGen/", "MCRecoMatchedEffCorr/"); -} -void declareMCFlucHists() -{ - static constexpr int kNbinsNchFluc = 1000; - // pT cumulants - histos.add("MCGen/Prof_C2_Cent", ";cent;C_{2}", kTProfile, {centAxis}); - histos.add("MCGen/Prof_C2_Mult", ";N_{PV};C_{2}", kTProfile, {nChAxis}); - histos.add("MCGen/Prof_C2Sub_Mult_etabin_ptbin", - ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, - {{kNbinsNchFluc, kNchMin, kNchCoarseMax},{KNEta+1,-kBinOffset,KNEta+kBinOffset},{KNpT+1,-kBinOffset,KNpT+kBinOffset}}); - histos.add("MCGen/Prof_ipt0_C2Sub2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_C2Sub2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_C2Sub2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt0_Cov_Cent_eta",";cent;#eta", kTProfile2D, {{centAxis},{(KNEta-1)/2,0,kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt0_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta-1)/2,0.,kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_Cov_Cent_eta",";cent;#eta", kTProfile2D, {{centAxis},{(KNEta-1)/2,0,kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta-1)/2,0.,kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_Cov_Cent_eta",";cent;#eta", kTProfile2D, {{centAxis},{(KNEta-1)/2,0,kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta-1)/2,0.,kEtaAxisMax}}); - histos.add("MCGen/Prof_C2Et_Cent", ";cent;C_{2}^{E_{T}}", kTProfile, {centAxis}); - histos.add("MCGen/Prof_C2Et_Mult", ";N_{PV};C_{2}^{E_{T}}", kTProfile, {nChAxis}); - histos.add("MCGen/Prof_C2EtSub_Mult_etabin_ptbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, - {{kNbinsNchFluc, kNchMin, kNchCoarseMax},{KNEta+1,-kBinOffset,KNEta+kBinOffset},{KNpT+1,-kBinOffset,KNpT+kBinOffset}}); - histos.add("MCGen/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt0_CovEt_Cent_eta",";cent;#eta", kTProfile2D, {{centAxis},{(KNEta-1)/2,0,kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt0_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta-1)/2,0.,kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_CovEt_Cent_eta",";cent;#eta", kTProfile2D, {{centAxis},{(KNEta-1)/2,0,kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta-1)/2,0.,kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_CovEt_Cent_eta",";cent;#eta", kTProfile2D, {{centAxis},{(KNEta-1)/2,0,kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta-1)/2,0.,kEtaAxisMax}}); - - histos.add("MCGen/Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); - histos.add("MCGen/Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); - histos.add("MCGen/Prof_MeanpT_Mult", ";N_{PV};#LT p_{T}#GT",kTProfile, {nChAxis}); - - histos.add("pmeanTruNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - histos.add("pmeanRecoNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - histos.add("pmeanRecoMatchedNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - histos.add("pmeanRecoEffcorrNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - histos.add("pmeanRecoMatchedEffcorrNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - - histos.add("MCGen/Prof_MeanEt_Cent",";cent;#LT E_{T}#GT", kTProfile, {centAxis}); - histos.add("MCGen/Prof_MeanEt_Mult",";N_{PV};#LT E_{T}#GT",kTProfile, {nChAxis}); - histos.add("pmeanEtTruNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - histos.add("pmeanEtRecoNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - histos.add("pmeanEtRecoMatchedNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - histos.add("pmeanEtRecoEffcorrNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - histos.add("pmeanEtRecoMatchedEffcorrNchEtabinPtbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); -} -void declareDataMeanHists() -{ - histos.add("Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); - histos.add("Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); - histos.add("pmean_nch_etabin_ptbin",";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - // Et - histos.add("Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); - histos.add("pmeanEt_nch_etabin_ptbin",";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); -} + histos.add("ptResolution", ";p_{T}^{MC};p_{T}^{MC}-p_{T}^{reco}", kTH2F, {{kNbinsPtRes, 0., cfgPtMax}, {kNbinsPtRes, -kPtResMax, kPtResMax}}); + histos.add("ptTruthReco", ";p_{T}^{MC};p_{T}^{reco}", kTH2F, {{kNbinsPtRes, 0., cfgPtMax}, {kNbinsPtRes, 0., cfgPtMax}}); + histos.add("etaResolution", ";#eta^{MC};#eta^{MC}-#eta^{reco}", kTH2F, {{kNbinsEtaRes, -kEtaFineMax, kEtaFineMax}, {kNbinsPtRes, -kEtaResMax, kEtaResMax}}); + histos.add("etaTruthReco", ";#eta^{MC};#eta^{reco}", kTH2F, {{kNbinsPtRes, -kEtaFineMax, kEtaFineMax}, {kNbinsPtRes, -kEtaFineMax, kEtaFineMax}}); + + histos.add("TruthTrackVZ", ";Vz^{MC};Vz^{Reco}", kTH2F, {{kNbinsVz, kVzMin, kVzMax}, {kNbinsVz, kVzMin, kVzMax}}); + histos.add("vzResolution", ";Vz^{MC};Vz^{MC}-Vz^{Reco}", kTH2F, {{kNbinsVz, kVzMin, kVzMax}, {kNbinsVz, -kVzResMax, kVzResMax}}); + + histos.add("h3_AllPrimary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + histos.add("h3_RecoMatchedToPrimary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + histos.add("h3_RecoUnMatchedToPrimary_Secondary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + histos.add("h3_RecoUnMatchedToPrimary_Fake", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + histos.add("h3_AllReco", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + + histos.add("h3_AllPrimary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + histos.add("h3_RecoMatchedToPrimary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + histos.add("h3_RecoUnMatchedToPrimary_Secondary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + histos.add("h3_RecoUnMatchedToPrimary_Fake_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + histos.add("h3_AllReco_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + + histos.add("h_AllPrimary", ";p_{T}", kTH1F, {{kNbinsP, 0., cfgPtMax}}); + histos.add("h_RecoMatchedToPrimary", ";p_{T}", kTH1F, {{kNbinsPt, 0., kPtMax}}); + histos.add("h_RecoUnMatchedToPrimary", ";p_{T}", kTH1F, {{kNbinsPt, 0., kPtMax}}); + histos.add("h_AllReco", ";p_{T}", kTH1F, {{kNbinsPt, 0., kPtMax}}); + + histos.add("hReco_ParticleWeight", ";cent;p_{T};#eta", kTH3F, {{centAxis}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsPtRes, -kEtaFineMax, kEtaFineMax}}); + histos.add("hTruth_ParticleWeight", ";cent;p_{T};#eta", kTH3F, {{centAxis}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsPtRes, -kEtaFineMax, kEtaFineMax}}); + + histos.add("hDCAxy_Unmatched", ";DCA_{xy} (cm)", kTH1F, {{kNbinsDca, -kDcaMax, kDcaMax}}); + histos.add("hDCAz_Unmatched", ";DCA_{z} (cm)", kTH1F, {{kNbinsDca, -kDcaMax, kDcaMax}}); + histos.add("hDCAxy_NotPrimary", ";DCA_{xy} (cm)", kTH1F, {{kNbinsDca, -kDcaMax, kDcaMax}}); + histos.add("hDCAz_NotPrimary", ";DCA_{z} (cm)", kTH1F, {{kNbinsDca, -kDcaMax, kDcaMax}}); + } -void declareDataGetFlatHists() -{ - // histos.add("hCentEtaPhi", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), -0.8, 0.8}, {30, 0, TMath::TwoPi()}}); - histos.add("hCentEtaPhi_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); -} + void declareMCMeanHists() + { + // Eff/Fake and weights vs observables + histos.add("Eff_cent", ";cent;#epsilon", kTProfile, {centAxis}); + histos.add("Fake_cent", ";cent;f_{fake}", kTProfile, {centAxis}); + histos.add("wgt_cent", ";cent;w", kTProfile, {centAxis}); + histos.add("Eff_Ntrk", ";N_{PV};#epsilon", kTProfile, {nChAxis2}); + histos.add("Fake_Ntrk", ";N_{PV};f_{fake}", kTProfile, {nChAxis2}); + histos.add("wgt_Ntrk", ";N_{PV};w", kTProfile, {nChAxis2}); + histos.add("Eff_pT", ";p_{T};#epsilon", kTProfile, {{kNbinsPtRes, 0., cfgPtMax}}); + histos.add("Fake_pT", ";p_{T};f_{fake}", kTProfile, {{kNbinsPtRes, 0., cfgPtMax}}); + histos.add("wgt_pT", ";p_{T};w", kTProfile, {{kNbinsPtRes, 0., kPtMax}}); + histos.add("Eff_eta", ";#eta;#epsilon", kTProfile, {{kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + histos.add("Fake_eta", ";#eta;f_{fake}", kTProfile, {{kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + histos.add("wgt_eta", ";#eta;w", kTProfile, {{kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + // MC mean profiles (pT & Et) for various selections + histos.add("MCGen/Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanpT_Mult", ";N_{PV};#LT p_{T}#GT", kTProfile, {nChAxis}); + histos.add("pmeanTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); + histos.add("pmeanRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); + histos.add("pmeanRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); + histos.add("pmeanRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); + histos.add("pmeanRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); + // Et versions + histos.add("MCGen/Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanEt_Mult", ";N_{PV};#LT E_{T}#GT", kTProfile, {nChAxis}); + histos.add("pmeanEtTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); + histos.add("pmeanEtRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); + histos.add("pmeanEtRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); + histos.add("pmeanEtRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); + histos.add("pmeanEtRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); + // Clone sets for Reco/Matched/EffCorr variants + + histos.addClone("MCGen/", "MCReco/"); + histos.addClone("MCGen/", "MCRecoMatched/"); + histos.addClone("MCGen/", "MCRecoEffCorr/"); + histos.addClone("MCGen/", "MCRecoMatchedEffCorr/"); + } + void declareMCFlucHists() + { + static constexpr int kNbinsNchFluc = 1000; + // pT cumulants + histos.add("MCGen/Prof_C2_Cent", ";cent;C_{2}", kTProfile, {centAxis}); + histos.add("MCGen/Prof_C2_Mult", ";N_{PV};C_{2}", kTProfile, {nChAxis}); + histos.add("MCGen/Prof_C2Sub_Mult_etabin_ptbin", + ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, + {{kNbinsNchFluc, kNchMin, kNchCoarseMax}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("MCGen/Prof_ipt0_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt0_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt0_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); + histos.add("MCGen/Prof_C2Et_Cent", ";cent;C_{2}^{E_{T}}", kTProfile, {centAxis}); + histos.add("MCGen/Prof_C2Et_Mult", ";N_{PV};C_{2}^{E_{T}}", kTProfile, {nChAxis}); + histos.add("MCGen/Prof_C2EtSub_Mult_etabin_ptbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, + {{kNbinsNchFluc, kNchMin, kNchCoarseMax}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("MCGen/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt0_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt0_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); + + histos.add("MCGen/Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanpT_Mult", ";N_{PV};#LT p_{T}#GT", kTProfile, {nChAxis}); + + histos.add("pmeanTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("pmeanRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("pmeanRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("pmeanRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("pmeanRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + + histos.add("MCGen/Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanEt_Mult", ";N_{PV};#LT E_{T}#GT", kTProfile, {nChAxis}); + histos.add("pmeanEtTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("pmeanEtRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("pmeanEtRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("pmeanEtRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("pmeanEtRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + } + void declareDataMeanHists() + { + histos.add("Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); + histos.add("Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); + histos.add("pmean_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + // Et + histos.add("Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); + histos.add("pmeanEt_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + } -void declareDataFlucHists() -{ - histos.add("pmean_nch_etabin_ptbin",";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - histos.add("Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); - histos.add("pmeanEt_nch_etabin_ptbin",";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - - histos.add("Prof_C2_Cent", ";cent;C_{2}", kTProfile, {centAxis}); - histos.add("Prof_MeanpT_Cent",";cent;#LT p_{T}#GT", kTProfile, {centAxis}); - histos.add("Prof_MeanpT_Mult",";N_{PV};#LT p_{T}#GT", kTProfile, {nChAxis}); - histos.add("Prof_C2_Mult_etabin_ptbin",";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - - histos.add("Prof_ipt0_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta-1)/2, 0, kEtaAxisMax}}); - histos.add("Prof_ipt0_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta-1)/2, 0., kEtaAxisMax}}); - histos.add("Prof_ipt1_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta-1)/2, 0, kEtaAxisMax}}); - histos.add("Prof_ipt1_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta-1)/2, 0., kEtaAxisMax}}); - histos.add("Prof_ipt2_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta-1)/2, 0, kEtaAxisMax}}); - histos.add("Prof_ipt2_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta-1)/2, 0., kEtaAxisMax}}); - - histos.add("Prof_C2Et_Cent", ";cent;C_{2}^{E_{T}}", kTProfile, {centAxis}); - histos.add("Prof_MeanEt_Mult", ";N_{PV};#LT E_{T}#GT", kTProfile, {nChAxis}); - histos.add("Prof_C2Et_Mult_etabin_ptbin",";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D,{{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - - histos.add("Prof_ipt0_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta-1)/2, 0, kEtaAxisMax}}); - histos.add("Prof_ipt0_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta-1)/2, 0., kEtaAxisMax}}); - histos.add("Prof_ipt1_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta-1)/2, 0, kEtaAxisMax}}); - histos.add("Prof_ipt1_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta-1)/2, 0., kEtaAxisMax}}); - histos.add("Prof_ipt2_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta-1)/2, 0, kEtaAxisMax}}); - histos.add("Prof_ipt2_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta-1)/2, 0., kEtaAxisMax}}); - - histos.add("Prof_ipt0_C2Sub2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); - histos.add("Prof_ipt1_C2Sub2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); - histos.add("Prof_ipt2_C2Sub2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); - histos.add("Prof_ipt0_C2SubEt2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); - histos.add("Prof_ipt1_C2SubEt2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); - histos.add("Prof_ipt2_C2SubEt2D_Mult_etaA_etaC",";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis},{KNEta-1,kEtaAxisMin,kEtaAxisMax},{KNEta-1,kEtaAxisMin,kEtaAxisMax}}); -} + void declareDataGetFlatHists() + { + // histos.add("hCentEtaPhi", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), -0.8, 0.8}, {30, 0, TMath::TwoPi()}}); + histos.add("hCentEtaPhi_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + } -TH3F* buildWeightMapFromRaw(TH3F* hRaw, const char* mapName) -{ - if (!hRaw) { - LOGF(error, "Raw eta-phi map for '%s' is null; no flattening will be applied.", mapName); - return nullptr; + void declareDataFlucHists() + { + histos.add("pmean_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); + histos.add("pmeanEt_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + + histos.add("Prof_C2_Cent", ";cent;C_{2}", kTProfile, {centAxis}); + histos.add("Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); + histos.add("Prof_MeanpT_Mult", ";N_{PV};#LT p_{T}#GT", kTProfile, {nChAxis}); + histos.add("Prof_C2_Mult_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + + histos.add("Prof_ipt0_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); + histos.add("Prof_ipt0_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); + histos.add("Prof_ipt1_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); + histos.add("Prof_ipt1_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); + histos.add("Prof_ipt2_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); + histos.add("Prof_ipt2_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); + + histos.add("Prof_C2Et_Cent", ";cent;C_{2}^{E_{T}}", kTProfile, {centAxis}); + histos.add("Prof_MeanEt_Mult", ";N_{PV};#LT E_{T}#GT", kTProfile, {nChAxis}); + histos.add("Prof_C2Et_Mult_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + + histos.add("Prof_ipt0_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); + histos.add("Prof_ipt0_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); + histos.add("Prof_ipt1_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); + histos.add("Prof_ipt1_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); + histos.add("Prof_ipt2_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); + histos.add("Prof_ipt2_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); + + histos.add("Prof_ipt0_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); + histos.add("Prof_ipt1_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); + histos.add("Prof_ipt2_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); + histos.add("Prof_ipt0_C2SubEt2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); + histos.add("Prof_ipt1_C2SubEt2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); + histos.add("Prof_ipt2_C2SubEt2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); } - auto hWeightMap = (TH3F*)hRaw->Clone(mapName); - hWeightMap->SetTitle(Form("Flattening Weight Map %s (w_{#phi} = / N_{#phi})", mapName)); - hWeightMap->SetDirectory(nullptr); - hWeightMap->Reset(); - auto axC = hRaw->GetXaxis(); - auto axE = hRaw->GetYaxis(); - auto axP = hRaw->GetZaxis(); - for (int ic = 1; ic <= axC->GetNbins(); ++ic) { - for (int ie = 1; ie <= axE->GetNbins(); ++ie) { - // average over phi at fixed (cent,eta) - double sum = 0.0; - int nphi = axP->GetNbins(); - for (int ip = 1; ip <= nphi; ++ip) sum += hRaw->GetBinContent(ic, ie, ip); - const double avg = (nphi > 0 ? sum / nphi : 0.0); - for (int ip = 1; ip <= nphi; ++ip) { - const double raw = hRaw->GetBinContent(ic, ie, ip); - const double w = (avg > 0.0 && raw > 0.0) ? (avg / raw) : 1.0; - hWeightMap->SetBinContent(ic, ie, ip, w); + + TH3F* buildWeightMapFromRaw(TH3F* hRaw, const char* mapName) + { + if (!hRaw) { + LOGF(error, "Raw eta-phi map for '%s' is null; no flattening will be applied.", mapName); + return nullptr; + } + auto hWeightMap = (TH3F*)hRaw->Clone(mapName); + hWeightMap->SetTitle(Form("Flattening Weight Map %s (w_{#phi} = / N_{#phi})", mapName)); + hWeightMap->SetDirectory(nullptr); + hWeightMap->Reset(); + auto axC = hRaw->GetXaxis(); + auto axE = hRaw->GetYaxis(); + auto axP = hRaw->GetZaxis(); + for (int ic = 1; ic <= axC->GetNbins(); ++ic) { + for (int ie = 1; ie <= axE->GetNbins(); ++ie) { + // average over phi at fixed (cent,eta) + double sum = 0.0; + int nphi = axP->GetNbins(); + for (int ip = 1; ip <= nphi; ++ip) + sum += hRaw->GetBinContent(ic, ie, ip); + const double avg = (nphi > 0 ? sum / nphi : 0.0); + for (int ip = 1; ip <= nphi; ++ip) { + const double raw = hRaw->GetBinContent(ic, ie, ip); + const double w = (avg > 0.0 && raw > 0.0) ? (avg / raw) : 1.0; + hWeightMap->SetBinContent(ic, ie, ip, w); + } } } + LOGF(info, "Flattening weight map '%s' built.", mapName); + return hWeightMap; } - LOGF(info, "Flattening weight map '%s' built.", mapName); - return hWeightMap; -} -void init(InitContext&) -{ - // CCDB - ccdb->setURL("http://alice-ccdb.cern.ch"); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - int64_t nowMs = std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()).count(); + void init(InitContext&) + { + // CCDB + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + int64_t nowMs = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()) + .count(); ccdb->setCreatedNotAfter(nowMs); // Always-on common QA declareCommonQA(); @@ -1028,35 +1053,43 @@ void init(InitContext&) if (cfgRunDataFluc) { loadTProfile3D("Job1_DataMean.root", "pmean_nch_etabin_ptbin", pmeanNchEtabinPtbinStep2); loadTProfile3D("Job1_DataMean.root", "pmeanEt_nch_etabin_ptbin", pmeanEtNchEtabinPtbinStep2); - }} + } + } void processGetEffHists(aod::McCollisions const& mcColl, soa::SmallGroups const& collisions, TCs const& tracks, FilteredTCs const& /*filteredTracks*/, aod::McParticles const& mcParticles) { for (const auto& mcCollision : mcColl) { auto colSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex()); - if (colSlice.size() != 1) continue; + if (colSlice.size() != 1) + continue; for (const auto& col : colSlice) { - if (!col.has_mcCollision()) continue; - if (!isEventSelected(col)) continue; + if (!col.has_mcCollision()) + continue; + if (!isEventSelected(col)) + continue; auto trackSlice = tracks.sliceBy(trackPerCollision, col.globalIndex()); - if (trackSlice.size() < 1) continue; - + if (trackSlice.size() < 1) + continue; auto partSlice = mcParticles.sliceBy(partPerMcCollision, mcCollision.globalIndex()); - if (partSlice.size() < 1) continue; + if (partSlice.size() < 1) + continue; if (col.globalIndex() >= trackSlice.size()) { - LOGF(warning, "Skipping invalid globalIndex=%d for tracks (tracks.size=%d)",col.globalIndex(), tracks.size()); + LOGF(warning, "Skipping invalid globalIndex=%d for tracks (tracks.size=%d)", col.globalIndex(), tracks.size()); continue; } float cent = getCentrality(col); - if (cent < 0 || cent > 80) continue; + if (cent < 0 || cent > 80) + continue; for (const auto& particle : partSlice) { - if (!isParticleSelected(particle)) continue; - if (!particle.isPhysicalPrimary()) continue; + if (!isParticleSelected(particle)) + continue; + if (!particle.isPhysicalPrimary()) + continue; const int absPdgId = std::abs(particle.pdgCode()); const bool isPion = (absPdgId == kPiPlus); @@ -1068,22 +1101,23 @@ void init(InitContext&) histos.fill(HIST("hCentEtaPhiTrue"), cent, particle.eta(), particle.phi()); histos.fill(HIST("h3_AllPrimary"), col.multNTracksPV(), particle.pt(), particle.eta()); - if (cent < kCentTestMin) histos.fill(HIST("hCent1EtaPhi"), particle.eta(), particle.phi()); - if (cent > kCentTestMaxLo && cent < kCentTestMaxHi) histos.fill(HIST("hCent7EtaPhi"), particle.eta(), particle.phi()); + if (cent < kCentTestMin) + histos.fill(HIST("hCent1EtaPhi"), particle.eta(), particle.phi()); + if (cent > kCentTestMaxLo && cent < kCentTestMaxHi) + histos.fill(HIST("hCent7EtaPhi"), particle.eta(), particle.phi()); if (isPid) { histos.fill(HIST("hCentEtaPhiTrue_PID"), cent, particle.eta(), particle.phi()); histos.fill(HIST("h3_AllPrimary_PID"), col.multNTracksPV(), particle.pt(), particle.eta()); } - } histos.fill(HIST("TruthTrackVZ"), mcCollision.posZ(), col.posZ()); histos.fill(HIST("vzResolution"), mcCollision.posZ(), mcCollision.posZ() - col.posZ()); - // Reconstructed for (const auto& track : trackSlice) { - if (!isTrackSelected(track)) continue; + if (!isTrackSelected(track)) + continue; const bool isPion = selectionPion(track); const bool isKaon = selectionKaon(track); @@ -1120,8 +1154,7 @@ void init(InitContext&) histos.fill(HIST("hCentEtaPhiRecoMatched_PID"), cent, mcPart2.eta(), mcPart2.phi()); } - } - else { + } else { // Matched to secondary histos.fill(HIST("h3_RecoUnMatchedToPrimary_Secondary"), col.multNTracksPV(), track.pt(), track.eta()); histos.fill(HIST("hDCAxy_Unmatched"), track.dcaXY()); @@ -1130,8 +1163,7 @@ void init(InitContext&) histos.fill(HIST("h3_RecoUnMatchedToPrimary_Secondary_PID"), col.multNTracksPV(), track.pt(), track.eta()); } } - } - else { + } else { // Fake track histos.fill(HIST("h3_RecoUnMatchedToPrimary_Fake"), col.multNTracksPV(), track.pt(), track.eta()); histos.fill(HIST("hDCAxy_NotPrimary"), track.dcaXY()); @@ -1147,7 +1179,6 @@ void init(InitContext&) } PROCESS_SWITCH(RadFlowDecorr, processGetEffHists, "process MC to calculate Eff and Fakes", cfgRunGetEff); - void processMCMean(aod::McCollisions const& mcColl, MyRun3MCCollisions const& collisions, TCs const& tracks, FilteredTCs const& /*filteredTracks*/, aod::McParticles const& mcParticles) { float sumWiTruth[KNEta][KNpT], sumWiptiTruth[KNEta][KNpT]; @@ -1161,32 +1192,35 @@ void init(InitContext&) float sumWiRecoEffCorrEt[KNEta][KNpT], sumWiptiRecoEffCorrEt[KNEta][KNpT]; float sumWiRecoMatchedEffCorrEt[KNEta][KNpT], sumWiptiRecoMatchedEffCorrEt[KNEta][KNpT]; - for (const auto& mcCollision : mcColl) { auto colSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex()); - if (colSlice.size() != 1) continue; + if (colSlice.size() != 1) + continue; for (const auto& col : colSlice) { - if (!col.has_mcCollision()) continue; - if (!isEventSelected(col)) continue; + if (!col.has_mcCollision()) + continue; + if (!isEventSelected(col)) + continue; auto trackSlice = tracks.sliceBy(trackPerCollision, col.globalIndex()); - if (trackSlice.size() < 1) continue; - + if (trackSlice.size() < 1) + continue; auto partSlice = mcParticles.sliceBy(partPerMcCollision, mcCollision.globalIndex()); - if (partSlice.size() < 1) continue; + if (partSlice.size() < 1) + continue; if (col.globalIndex() >= trackSlice.size()) { - LOGF(warning, "Skipping invalid globalIndex=%d for tracks (tracks.size=%d)",col.globalIndex(), tracks.size()); + LOGF(warning, "Skipping invalid globalIndex=%d for tracks (tracks.size=%d)", col.globalIndex(), tracks.size()); continue; } float cent = getCentrality(col); - if (cent < 0 || cent > 80) continue; - + if (cent < 0 || cent > 80) + continue; if (col.globalIndex() >= trackSlice.size()) { - LOGF(warning, "Skipping invalid globalIndex=%d for tracks (tracks.size=%d)",col.globalIndex(), tracks.size()); + LOGF(warning, "Skipping invalid globalIndex=%d for tracks (tracks.size=%d)", col.globalIndex(), tracks.size()); continue; } @@ -1214,8 +1248,10 @@ void init(InitContext&) // Truth for (const auto& particle : partSlice) { - if (!isParticleSelected(particle)) continue; - if (!particle.isPhysicalPrimary()) continue; + if (!isParticleSelected(particle)) + continue; + if (!particle.isPhysicalPrimary()) + continue; const int absPdgId = std::abs(particle.pdgCode()); const bool isPion = (absPdgId == kPiPlus); @@ -1228,13 +1264,16 @@ void init(InitContext&) const double wi = 1.0; for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; sumWiTruth[ieta][ipt] += 1.0; sumWiptiTruth[ieta][ipt] += 1.0 * pt; if (isPion || isKaon || isProton) { - float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus : o2::constants::physics::MassProton; + float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus + : o2::constants::physics::MassProton; float E = std::sqrt(p * p + m * m); float Et = E * (pt / p); // E_T = E * sin(theta) = E * (pT / p) sumWiTruthEt[ieta][ipt] += 1.0; @@ -1245,17 +1284,19 @@ void init(InitContext&) } for (const auto& track : trackSlice) { - if (!isTrackSelected(track)) continue; + if (!isTrackSelected(track)) + continue; float pt = track.pt(); float eta = track.eta(); float p = track.p(); float phi = track.phi(); - histos.fill(HIST("hCentEtaPhi"), cent, eta, phi); - if (cent < kCentTestMin) histos.fill(HIST("hCent1EtaPhi"), eta, phi); - if (cent > kCentTestMaxLo && cent < kCentTestMaxHi) histos.fill(HIST("hCent7EtaPhi"), eta, phi); + if (cent < kCentTestMin) + histos.fill(HIST("hCent1EtaPhi"), eta, phi); + if (cent > kCentTestMaxLo && cent < kCentTestMaxHi) + histos.fill(HIST("hCent7EtaPhi"), eta, phi); float effIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 0); float fakeIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 1); @@ -1263,24 +1304,31 @@ void init(InitContext&) float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; histos.fill(HIST("hCentEtaPhiWtd"), cent, eta, track.phi(), flatWeightIncl); - if (cent < kCentTestMin) histos.fill(HIST("hCent1EtaPhiWtd"), track.eta(), track.phi(), flatWeightIncl); - if (cent > kCentTestMaxLo && cent < kCentTestMaxHi) histos.fill(HIST("hCent7EtaPhiWtd"), track.eta(), track.phi(), flatWeightIncl); + if (cent < kCentTestMin) + histos.fill(HIST("hCent1EtaPhiWtd"), track.eta(), track.phi(), flatWeightIncl); + if (cent > kCentTestMaxLo && cent < kCentTestMaxHi) + histos.fill(HIST("hCent7EtaPhiWtd"), track.eta(), track.phi(), flatWeightIncl); for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; sumWiReco[ieta][ipt] += 1.0; sumWiptiReco[ieta][ipt] += pt; } } - if (effIncl <= 0 || !isfinite(wIncl) || !isfinite(fakeIncl) || !isfinite(flatWeightIncl)) continue; + if (effIncl <= 0 || !isfinite(wIncl) || !isfinite(fakeIncl) || !isfinite(flatWeightIncl)) + continue; for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; sumWiRecoEffCorr[ieta][ipt] += wIncl; sumWiptiRecoEffCorr[ieta][ipt] += wIncl * pt; } @@ -1296,35 +1344,43 @@ void init(InitContext&) float wPid =  flatWeightPid * (1.0 - fakePid) / effPid; histos.fill(HIST("hCentEtaPhiWtd_PID"), cent, eta, track.phi(), flatWeightPid); - if (cent < kCentTestMin) histos.fill(HIST("hCent1EtaPhiWtd_PID"), track.eta(), track.phi(), flatWeightPid); - if (cent > kCentTestMaxLo && cent < kCentTestMaxHi) histos.fill(HIST("hCent7EtaPhiWtd_PID"), track.eta(), track.phi(), flatWeightPid); + if (cent < kCentTestMin) + histos.fill(HIST("hCent1EtaPhiWtd_PID"), track.eta(), track.phi(), flatWeightPid); + if (cent > kCentTestMaxLo && cent < kCentTestMaxHi) + histos.fill(HIST("hCent7EtaPhiWtd_PID"), track.eta(), track.phi(), flatWeightPid); - float m = isPion ? o2::constants::physics::MassPiPlus :isKaon ? o2::constants::physics::MassKPlus :o2::constants::physics::MassProton; + float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus + : o2::constants::physics::MassProton; float E = std::sqrt(p * p + m * m); float Et = E * (pt / p); // E_T = E * sin(theta) for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; sumWiRecoEt[ieta][ipt] += 1.0; sumWiptiRecoEt[ieta][ipt] += Et; } } - if (effPid <= kFloatEpsilon || !isfinite(wPid) || !isfinite(fakePid) || !isfinite(flatWeightPid)) continue; + if (effPid <= kFloatEpsilon || !isfinite(wPid) || !isfinite(fakePid) || !isfinite(flatWeightPid)) + continue; for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; sumWiRecoEffCorrEt[ieta][ipt] += wPid; sumWiptiRecoEffCorrEt[ieta][ipt] += wPid * Et; } } } - if (isfinite(wIncl)){ - if(cent < kCentTestMin){ + if (isfinite(wIncl)) { + if (cent < kCentTestMin) { histos.fill(HIST("wgt_pT"), pt, wIncl); histos.fill(HIST("Eff_pT"), pt, effIncl); histos.fill(HIST("Fake_pT"), pt, fakeIncl); @@ -1344,24 +1400,30 @@ void init(InitContext&) if (isfinite(sumWiTruth[0][0])) { float meanpT_truth = sumWiptiTruth[0][0] / sumWiTruth[0][0]; - if(!isfinite(meanpT_truth)) LOGF(info, "meanpT_truth = %.3f, num = %.3f, den =%.3f", meanpT_truth, sumWiptiTruth[0][0], sumWiTruth[0][0]); - if(!isfinite(meanpT_truth)) continue; + if (!isfinite(meanpT_truth)) + LOGF(info, "meanpT_truth = %.3f, num = %.3f, den =%.3f", meanpT_truth, sumWiptiTruth[0][0], sumWiTruth[0][0]); + if (!isfinite(meanpT_truth)) + continue; histos.fill(HIST("MCGen/Prof_cent_Nchrec"), cent, sumWiTruth[0][0]); histos.fill(HIST("MCGen/Prof_MeanpT_Cent"), cent, meanpT_truth); histos.fill(HIST("MCGen/Prof_MeanpT_Mult"), col.multNTracksPV(), meanpT_truth); } if (isfinite(sumWiReco[0][0])) { float meanpT_reco = sumWiptiReco[0][0] / sumWiReco[0][0]; - if(!isfinite(meanpT_reco)) LOGF(info, "meanpT_reco = %.3f, num = %.3f, den =%.3f", meanpT_reco, sumWiptiReco[0][0], sumWiReco[0][0]); - if(!isfinite(meanpT_reco)) continue; + if (!isfinite(meanpT_reco)) + LOGF(info, "meanpT_reco = %.3f, num = %.3f, den =%.3f", meanpT_reco, sumWiptiReco[0][0], sumWiReco[0][0]); + if (!isfinite(meanpT_reco)) + continue; histos.fill(HIST("MCReco/Prof_cent_Nchrec"), cent, sumWiReco[0][0]); histos.fill(HIST("MCReco/Prof_MeanpT_Cent"), cent, meanpT_reco); histos.fill(HIST("MCReco/Prof_MeanpT_Mult"), col.multNTracksPV(), meanpT_reco); } if (isfinite(sumWiRecoEffCorr[0][0])) { float meanpT_effcorr = sumWiptiRecoEffCorr[0][0] / sumWiRecoEffCorr[0][0]; - if(!isfinite(meanpT_effcorr)) LOGF(info, "meanpT_recoEffcorr = %.3f, num = %.3f, den =%.3f", meanpT_effcorr, sumWiptiRecoEffCorr[0][0], sumWiRecoEffCorr[0][0]); - if(!isfinite(meanpT_effcorr)) continue; + if (!isfinite(meanpT_effcorr)) + LOGF(info, "meanpT_recoEffcorr = %.3f, num = %.3f, den =%.3f", meanpT_effcorr, sumWiptiRecoEffCorr[0][0], sumWiRecoEffCorr[0][0]); + if (!isfinite(meanpT_effcorr)) + continue; histos.fill(HIST("MCRecoEffCorr/Prof_cent_Nchrec"), cent, sumWiRecoEffCorr[0][0]); histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Cent"), cent, meanpT_effcorr); histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Mult"), col.multNTracksPV(), meanpT_effcorr); @@ -1369,38 +1431,50 @@ void init(InitContext&) if (isfinite(sumWiTruthEt[0][0])) { float meanEt = sumWiptiTruthEt[0][0] / sumWiTruthEt[0][0]; - if(!isfinite(meanEt)) LOGF(info, "meanEtTruthEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiTruthEt[0][0], sumWiTruthEt[0][0]); - if(!isfinite(meanEt)) continue; + if (!isfinite(meanEt)) + LOGF(info, "meanEtTruthEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiTruthEt[0][0], sumWiTruthEt[0][0]); + if (!isfinite(meanEt)) + continue; histos.fill(HIST("MCGen/Prof_MeanEt_Cent"), cent, meanEt); histos.fill(HIST("MCGen/Prof_MeanEt_Mult"), col.multNTracksPV(), meanEt); } // "MCReco" if (isfinite(sumWiRecoEt[0][0])) { float meanEt = sumWiptiRecoEt[0][0] / sumWiRecoEt[0][0]; - if(!isfinite(meanEt)) LOGF(info, "meanEtRecoEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiRecoEt[0][0], sumWiRecoEt[0][0]); - if(!isfinite(meanEt)) continue; + if (!isfinite(meanEt)) + LOGF(info, "meanEtRecoEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiRecoEt[0][0], sumWiRecoEt[0][0]); + if (!isfinite(meanEt)) + continue; histos.fill(HIST("MCReco/Prof_MeanEt_Cent"), cent, meanEt); histos.fill(HIST("MCReco/Prof_MeanEt_Mult"), col.multNTracksPV(), meanEt); } // "MCRecoEffCorr" if (isfinite(sumWiRecoEffCorrEt[0][0])) { float meanEt = sumWiptiRecoEffCorrEt[0][0] / sumWiRecoEffCorrEt[0][0]; - if(!isfinite(meanEt)) LOGF(info, "meanEtRecoEffcorrEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiRecoEffCorrEt[0][0], sumWiRecoEffCorrEt[0][0]); - if(!isfinite(meanEt)) continue; + if (!isfinite(meanEt)) + LOGF(info, "meanEtRecoEffcorrEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiRecoEffCorrEt[0][0], sumWiRecoEffCorrEt[0][0]); + if (!isfinite(meanEt)) + continue; histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Cent"), cent, meanEt); histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Mult"), col.multNTracksPV(), meanEt); } // --- Fill 3D pT Profiles --- - for (int ieta = 0; ieta < KNEta; ++ieta){ - for (int ipt = 0; ipt < KNpT; ++ipt){ - if (isfinite(sumWiTruth[ieta][ipt])) histos.fill(HIST("pmeanTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiTruth[ieta][ipt] / sumWiTruth[ieta][ipt]); - if (isfinite(sumWiReco[ieta][ipt])) histos.fill(HIST("pmeanRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt,sumWiptiReco[ieta][ipt] / sumWiReco[ieta][ipt]); - if (isfinite(sumWiRecoEffCorr[ieta][ipt])) histos.fill(HIST("pmeanRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt,sumWiptiRecoEffCorr[ieta][ipt] / sumWiRecoEffCorr[ieta][ipt]); + for (int ieta = 0; ieta < KNEta; ++ieta) { + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (isfinite(sumWiTruth[ieta][ipt])) + histos.fill(HIST("pmeanTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiTruth[ieta][ipt] / sumWiTruth[ieta][ipt]); + if (isfinite(sumWiReco[ieta][ipt])) + histos.fill(HIST("pmeanRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiReco[ieta][ipt] / sumWiReco[ieta][ipt]); + if (isfinite(sumWiRecoEffCorr[ieta][ipt])) + histos.fill(HIST("pmeanRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiRecoEffCorr[ieta][ipt] / sumWiRecoEffCorr[ieta][ipt]); // --- Fill 3D Et Profiles --- - if (isfinite(sumWiTruthEt[ieta][ipt])) histos.fill(HIST("pmeanEtTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiTruthEt[ieta][ipt] / sumWiTruthEt[ieta][ipt]); - if (isfinite(sumWiRecoEt[ieta][ipt])) histos.fill(HIST("pmeanEtRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiRecoEt[ieta][ipt] / sumWiRecoEt[ieta][ipt]); - if (isfinite(sumWiRecoEffCorrEt[ieta][ipt])) histos.fill(HIST("pmeanEtRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiRecoEffCorrEt[ieta][ipt] / sumWiRecoEffCorrEt[ieta][ipt]); + if (isfinite(sumWiTruthEt[ieta][ipt])) + histos.fill(HIST("pmeanEtTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiTruthEt[ieta][ipt] / sumWiTruthEt[ieta][ipt]); + if (isfinite(sumWiRecoEt[ieta][ipt])) + histos.fill(HIST("pmeanEtRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiRecoEt[ieta][ipt] / sumWiRecoEt[ieta][ipt]); + if (isfinite(sumWiRecoEffCorrEt[ieta][ipt])) + histos.fill(HIST("pmeanEtRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiRecoEffCorrEt[ieta][ipt] / sumWiRecoEffCorrEt[ieta][ipt]); } } } // end col loop @@ -1434,12 +1508,14 @@ void init(InitContext&) for (const auto& mcCollision : mcColl) { auto partSlice = mcParticles.sliceBy(partPerMcCollision, mcCollision.globalIndex()); auto colSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex()); - if (colSlice.size() != 1) continue; + if (colSlice.size() != 1) + continue; histos.fill(HIST("MCGen/hVtxZ"), mcCollision.posZ()); // This histogram was not declared, commenting out. for (const auto& col : colSlice) { auto trackSlice = tracks.sliceBy(trackPerCollision, col.globalIndex()); - if (trackSlice.size() < 1) continue; + if (trackSlice.size() < 1) + continue; memset(sumPmwkTru, 0, sizeof(sumPmwkTru)); memset(sumWkTru, 0, sizeof(sumWkTru)); @@ -1455,22 +1531,32 @@ void init(InitContext&) memset(sumPmwkRecoEffCorEt, 0, sizeof(sumPmwkRecoEffCorEt)); memset(sumWkRecoEffCorEt, 0, sizeof(sumWkRecoEffCorEt)); - memset(meanTru, 0, sizeof(meanTru)); memset(c2Tru, 0, sizeof(c2Tru)); - memset(meanReco, 0, sizeof(meanReco)); memset(c2Reco, 0, sizeof(c2Reco)); - memset(meanRecoEffCor, 0, sizeof(meanRecoEffCor)); memset(c2RecoEffCor, 0, sizeof(c2RecoEffCor)); - - memset(meanTruEt, 0, sizeof(meanTruEt)); memset(c2TruEt, 0, sizeof(c2TruEt)); - memset(meanRecoEt, 0, sizeof(meanRecoEt)); memset(c2RecoEt, 0, sizeof(c2RecoEt)); - memset(meanRecoEffCorEt, 0, sizeof(meanRecoEffCorEt)); memset(c2RecoEffCorEt, 0, sizeof(c2RecoEffCorEt)); - - if (!col.has_mcCollision() || !isEventSelected(col)) continue; + memset(meanTru, 0, sizeof(meanTru)); + memset(c2Tru, 0, sizeof(c2Tru)); + memset(meanReco, 0, sizeof(meanReco)); + memset(c2Reco, 0, sizeof(c2Reco)); + memset(meanRecoEffCor, 0, sizeof(meanRecoEffCor)); + memset(c2RecoEffCor, 0, sizeof(c2RecoEffCor)); + + memset(meanTruEt, 0, sizeof(meanTruEt)); + memset(c2TruEt, 0, sizeof(c2TruEt)); + memset(meanRecoEt, 0, sizeof(meanRecoEt)); + memset(c2RecoEt, 0, sizeof(c2RecoEt)); + memset(meanRecoEffCorEt, 0, sizeof(meanRecoEffCorEt)); + memset(c2RecoEffCorEt, 0, sizeof(c2RecoEffCorEt)); + + if (!col.has_mcCollision() || !isEventSelected(col)) + continue; float cent = getCentrality(col); - if (cent < 0 || cent > 80) continue; + if (cent < 0 || cent > 80) + continue; // truth for (const auto& particle : partSlice) { - if (!isParticleSelected(particle)) continue; - if (!particle.isPhysicalPrimary()) continue; + if (!isParticleSelected(particle)) + continue; + if (!particle.isPhysicalPrimary()) + continue; float pt = particle.pt(); float eta = particle.eta(); float p = particle.p(); @@ -1478,9 +1564,11 @@ void init(InitContext&) // pT (Inclusive) for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; for (int k = 0; k < KIntK; ++k) { for (int m = 0; m < KIntM; ++m) { sumPmwkTru[ieta][ipt][m][k] += std::pow(wi, k) * std::pow(pt, m); @@ -1493,15 +1581,18 @@ void init(InitContext&) const bool isPion = (absPdgId == kPiPlus); const bool isKaon = (absPdgId == kKPlus); const bool isProton = (absPdgId == kProton); - if (isPion || isKaon || isProton){ + if (isPion || isKaon || isProton) { - float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus : o2::constants::physics::MassProton; + float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus + : o2::constants::physics::MassProton; float E = std::sqrt(p * p + m * m); float Et = E * (pt / p); for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; for (int k = 0; k < KIntK; ++k) { for (int m = 0; m < KIntM; ++m) { sumPmwkTruEt[ieta][ipt][m][k] += std::pow(wi, k) * std::pow(Et, m); @@ -1515,7 +1606,8 @@ void init(InitContext&) } // end truth loop for (const auto& track : trackSlice) { - if (!isTrackSelected(track)) continue; + if (!isTrackSelected(track)) + continue; float pt = track.pt(); float eta = track.eta(); float p = track.p(); @@ -1525,13 +1617,17 @@ void init(InitContext&) float fakeIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 1); float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; - if (!std::isfinite(wIncl) || wIncl <= 0.f) continue; - if (effIncl <= 0 || !isfinite(effIncl) || !isfinite(fakeIncl) || !isfinite(flatWeightIncl))  continue; + if (!std::isfinite(wIncl) || wIncl <= 0.f) + continue; + if (effIncl <= 0 || !isfinite(effIncl) || !isfinite(fakeIncl) || !isfinite(flatWeightIncl)) +  continue; for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; for (int k = 0; k < KIntK; ++k) { for (int m = 0; m < KIntM; ++m) { sumPmwkReco[ieta][ipt][m][k] += std::pow(1.0f, k) * std::pow(pt, m); @@ -1547,20 +1643,24 @@ void init(InitContext&) const bool isKaon = selectionKaon(track); const bool isProton = selectionProton(track); - if (isPion || isKaon || isProton){ - float m = isPion ? o2::constants::physics::MassPiPlus :isKaon ? o2::constants::physics::MassKPlus :o2::constants::physics::MassProton; + if (isPion || isKaon || isProton) { + float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus + : o2::constants::physics::MassProton; float E = std::sqrt(p * p + m * m); float Et = E * (pt / p); // E_T = E * sin(theta) float effPid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 0); float fakePid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 1); float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); float wPid = flatWeightPid * (1.0 - fakePid) / effPid; - if(effPid >= 1.f || fakePid >= 1.f || !isfinite(effPid) || effPid <= kFloatEpsilon || !isfinite(fakePid) || !isfinite(flatWeightPid)) continue; + if (effPid >= 1.f || fakePid >= 1.f || !isfinite(effPid) || effPid <= kFloatEpsilon || !isfinite(fakePid) || !isfinite(flatWeightPid)) + continue; for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; for (int k = 0; k < KIntK; ++k) { for (int m = 0; m < KIntM; ++m) { sumPmwkRecoEt[ieta][ipt][m][k] += std::pow(1.0f, k) * std::pow(Et, m); @@ -1573,7 +1673,6 @@ void init(InitContext&) } } - for (int ieta = 0; ieta < KNEta; ++ieta) { for (int ipt = 0; ipt < KNpT; ++ipt) { const int ibx = pmeanTruNchEtabinPtbinStep2->GetXaxis()->FindBin(col.multNTracksPV()); @@ -1587,13 +1686,19 @@ void init(InitContext&) float mmetReco = pmeanEtRecoNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); float mmetRecoEffCor = pmeanEtRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - if (isfinite(mmptTru)) std::tie(meanTru[ieta][ipt], c2Tru[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkTru[ieta][ipt], sumWkTru[ieta][ipt], mmptTru); - if (isfinite(mmptReco)) std::tie(meanReco[ieta][ipt], c2Reco[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkReco[ieta][ipt], sumWkReco[ieta][ipt], mmptReco); - if (isfinite(mmptRecoEffCor)) std::tie(meanRecoEffCor[ieta][ipt], c2RecoEffCor[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEffCor[ieta][ipt], sumWkRecoEffCor[ieta][ipt], mmptRecoEffCor); - - if (isfinite(mmetTru)) std::tie(meanTruEt[ieta][ipt], c2TruEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkTruEt[ieta][ipt], sumWkTruEt[ieta][ipt], mmetTru); - if (isfinite(mmetReco)) std::tie(meanRecoEt[ieta][ipt], c2RecoEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEt[ieta][ipt], sumWkRecoEt[ieta][ipt], mmetReco); - if (isfinite(mmetRecoEffCor)) std::tie(meanRecoEffCorEt[ieta][ipt], c2RecoEffCorEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEffCorEt[ieta][ipt], sumWkRecoEffCorEt[ieta][ipt], mmetRecoEffCor); + if (isfinite(mmptTru)) + std::tie(meanTru[ieta][ipt], c2Tru[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkTru[ieta][ipt], sumWkTru[ieta][ipt], mmptTru); + if (isfinite(mmptReco)) + std::tie(meanReco[ieta][ipt], c2Reco[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkReco[ieta][ipt], sumWkReco[ieta][ipt], mmptReco); + if (isfinite(mmptRecoEffCor)) + std::tie(meanRecoEffCor[ieta][ipt], c2RecoEffCor[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEffCor[ieta][ipt], sumWkRecoEffCor[ieta][ipt], mmptRecoEffCor); + + if (isfinite(mmetTru)) + std::tie(meanTruEt[ieta][ipt], c2TruEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkTruEt[ieta][ipt], sumWkTruEt[ieta][ipt], mmetTru); + if (isfinite(mmetReco)) + std::tie(meanRecoEt[ieta][ipt], c2RecoEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEt[ieta][ipt], sumWkRecoEt[ieta][ipt], mmetReco); + if (isfinite(mmetRecoEffCor)) + std::tie(meanRecoEffCorEt[ieta][ipt], c2RecoEffCorEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEffCorEt[ieta][ipt], sumWkRecoEffCorEt[ieta][ipt], mmetRecoEffCor); } } } @@ -1654,18 +1759,24 @@ void init(InitContext&) histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Mult"), col.multNTracksPV(), meanRecoEffCorEt[0][0]); } - for (int ieta = 0; ieta < KNEta; ++ieta){ - for (int ipt = 0; ipt < KNpT; ++ipt){ - if (std::isfinite(sumWkTru[ieta][ipt][1])) histos.fill(HIST("pmeanTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt,meanTru[ieta][ipt]); - if (std::isfinite(sumWkReco[ieta][ipt][1])) histos.fill(HIST("pmeanRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt,meanReco[ieta][ipt]); - if (std::isfinite(sumWkRecoEffCor[ieta][ipt][1])) histos.fill(HIST("pmeanRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt,meanRecoEffCor[ieta][ipt]); - if (std::isfinite(sumWkTruEt[ieta][ipt][1])) histos.fill(HIST("pmeanEtTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt,meanTruEt[ieta][ipt]); - if (std::isfinite(sumWkRecoEt[ieta][ipt][1])) histos.fill(HIST("pmeanEtRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt,meanRecoEt[ieta][ipt]); - if (std::isfinite(sumWkRecoEffCorEt[ieta][ipt][1])) histos.fill(HIST("pmeanEtRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt,meanRecoEffCorEt[ieta][ipt]); + for (int ieta = 0; ieta < KNEta; ++ieta) { + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (std::isfinite(sumWkTru[ieta][ipt][1])) + histos.fill(HIST("pmeanTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanTru[ieta][ipt]); + if (std::isfinite(sumWkReco[ieta][ipt][1])) + histos.fill(HIST("pmeanRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanReco[ieta][ipt]); + if (std::isfinite(sumWkRecoEffCor[ieta][ipt][1])) + histos.fill(HIST("pmeanRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanRecoEffCor[ieta][ipt]); + if (std::isfinite(sumWkTruEt[ieta][ipt][1])) + histos.fill(HIST("pmeanEtTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanTruEt[ieta][ipt]); + if (std::isfinite(sumWkRecoEt[ieta][ipt][1])) + histos.fill(HIST("pmeanEtRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanRecoEt[ieta][ipt]); + if (std::isfinite(sumWkRecoEffCorEt[ieta][ipt][1])) + histos.fill(HIST("pmeanEtRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanRecoEffCorEt[ieta][ipt]); } } - float p1kBarTru[KNEta][KNpT]{}, p1kBarReco[KNEta][KNpT]{},p1kBarRecoEffCor[KNEta][KNpT]{}; + float p1kBarTru[KNEta][KNpT]{}, p1kBarReco[KNEta][KNpT]{}, p1kBarRecoEffCor[KNEta][KNpT]{}; float p1kBarTruEt[KNEta][KNpT]{}, p1kBarRecoEt[KNEta][KNpT]{}, p1kBarRecoEffCorEt[KNEta][KNpT]{}; for (int ieta = 0; ieta < KNEta; ++ieta) { for (int ipt = 0; ipt < KNpT; ++ipt) { @@ -1681,19 +1792,24 @@ void init(InitContext&) float mmetRecoEffCor = pmeanEtRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); // pT deviations - if (mmptTru != 0.0) p1kBarTru[ieta][ipt] = meanTru[ieta][ipt] - mmptTru; - if (mmptReco != 0.0) p1kBarReco[ieta][ipt] = meanReco[ieta][ipt] - mmptReco; - if (mmptRecoEffCor != 0.0) p1kBarRecoEffCor[ieta][ipt] = meanRecoEffCor[ieta][ipt] - mmptRecoEffCor; + if (mmptTru != 0.0) + p1kBarTru[ieta][ipt] = meanTru[ieta][ipt] - mmptTru; + if (mmptReco != 0.0) + p1kBarReco[ieta][ipt] = meanReco[ieta][ipt] - mmptReco; + if (mmptRecoEffCor != 0.0) + p1kBarRecoEffCor[ieta][ipt] = meanRecoEffCor[ieta][ipt] - mmptRecoEffCor; // Et deviations - if (mmetTru != 0.0) p1kBarTruEt[ieta][ipt] = meanTruEt[ieta][ipt] - mmetTru; - if (mmetReco != 0.0) p1kBarRecoEt[ieta][ipt] = meanRecoEt[ieta][ipt] - mmetReco; - if (mmetRecoEffCor != 0.0)p1kBarRecoEffCorEt[ieta][ipt] = meanRecoEffCorEt[ieta][ipt] - mmetRecoEffCor; + if (mmetTru != 0.0) + p1kBarTruEt[ieta][ipt] = meanTruEt[ieta][ipt] - mmetTru; + if (mmetReco != 0.0) + p1kBarRecoEt[ieta][ipt] = meanRecoEt[ieta][ipt] - mmetReco; + if (mmetRecoEffCor != 0.0) + p1kBarRecoEffCorEt[ieta][ipt] = meanRecoEffCorEt[ieta][ipt] - mmetRecoEffCor; } } - // 1D Covariance (vs eta) - for (int ietaA = 1; ietaA <=(KNEta-1)/2; ++ietaA) { + for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { int ietaC = KNEta - ietaA; float valy = kHalf * (etaLw[ietaC] + etaUp[ietaC]); { @@ -1702,13 +1818,15 @@ void init(InitContext&) if (std::isfinite(c2Sub)) { histos.fill(HIST("MCGen/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); histos.fill(HIST("MCGen/Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) histos.fill(HIST("MCGen/Prof_ipt0_Cov_Eta"), valy, c2Sub); + if (cent < kCentCovCut) + histos.fill(HIST("MCGen/Prof_ipt0_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("MCGen/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); histos.fill(HIST("MCGen/Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) histos.fill(HIST("MCGen/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); + if (cent < kCentCovCut) + histos.fill(HIST("MCGen/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); } } @@ -1719,13 +1837,15 @@ void init(InitContext&) if (std::isfinite(c2Sub)) { histos.fill(HIST("MCGen/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); histos.fill(HIST("MCGen/Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) histos.fill(HIST("MCGen/Prof_ipt0_Cov_Eta"), valy, c2Sub); + if (cent < kCentCovCut) + histos.fill(HIST("MCGen/Prof_ipt0_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("MCGen/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); histos.fill(HIST("MCGen/Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) histos.fill(HIST("MCGen/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); + if (cent < kCentCovCut) + histos.fill(HIST("MCGen/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); } } // ipt = 2 @@ -1735,13 +1855,15 @@ void init(InitContext&) if (std::isfinite(c2Sub)) { histos.fill(HIST("MCGen/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); histos.fill(HIST("MCGen/Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) histos.fill(HIST("MCGen/Prof_ipt2_Cov_Eta"), valy, c2Sub); + if (cent < kCentCovCut) + histos.fill(HIST("MCGen/Prof_ipt2_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("MCGen/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); histos.fill(HIST("MCGen/Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) histos.fill(HIST("MCGen/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); + if (cent < kCentCovCut) + histos.fill(HIST("MCGen/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); } } } @@ -1754,30 +1876,35 @@ void init(InitContext&) { const int ipt = 0; float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; - if(std::isfinite(c2Sub)) histos.fill(HIST("MCGen/Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCGen/Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; - if(std::isfinite(c2SubEt)) histos.fill(HIST("MCGen/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCGen/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); } // ipt = 1 { const int ipt = 1; float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; - if(std::isfinite(c2Sub)) histos.fill(HIST("MCGen/Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCGen/Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; - if(std::isfinite(c2SubEt)) histos.fill(HIST("MCGen/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCGen/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); } // ipt = 2 { const int ipt = 2; float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; - if(std::isfinite(c2Sub)) histos.fill(HIST("MCGen/Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCGen/Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; - if(std::isfinite(c2SubEt)) histos.fill(HIST("MCGen/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCGen/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); } } } - // --- MCReco Covariance (1D vs eta) --- for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { int ietaC = KNEta - ietaA; @@ -1790,13 +1917,15 @@ void init(InitContext&) if (std::isfinite(c2Sub)) { histos.fill(HIST("MCReco/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); histos.fill(HIST("MCReco/Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) histos.fill(HIST("MCReco/Prof_ipt0_Cov_Eta"), valy, c2Sub); + if (cent < kCentCovCut) + histos.fill(HIST("MCReco/Prof_ipt0_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("MCReco/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); histos.fill(HIST("MCReco/Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) histos.fill(HIST("MCReco/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); + if (cent < kCentCovCut) + histos.fill(HIST("MCReco/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); } } @@ -1807,13 +1936,15 @@ void init(InitContext&) if (std::isfinite(c2Sub)) { histos.fill(HIST("MCReco/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); histos.fill(HIST("MCReco/Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) histos.fill(HIST("MCReco/Prof_ipt1_Cov_Eta"), valy, c2Sub); + if (cent < kCentCovCut) + histos.fill(HIST("MCReco/Prof_ipt1_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("MCReco/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); histos.fill(HIST("MCReco/Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) histos.fill(HIST("MCReco/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); + if (cent < kCentCovCut) + histos.fill(HIST("MCReco/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); } } @@ -1824,13 +1955,15 @@ void init(InitContext&) if (std::isfinite(c2Sub)) { histos.fill(HIST("MCReco/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); histos.fill(HIST("MCReco/Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) histos.fill(HIST("MCReco/Prof_ipt2_Cov_Eta"), valy, c2Sub); + if (cent < kCentCovCut) + histos.fill(HIST("MCReco/Prof_ipt2_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("MCReco/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); histos.fill(HIST("MCReco/Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) histos.fill(HIST("MCReco/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); + if (cent < kCentCovCut) + histos.fill(HIST("MCReco/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); } } } @@ -1845,27 +1978,33 @@ void init(InitContext&) { const int ipt = 0; float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; - if (std::isfinite(c2Sub)) histos.fill(HIST("MCReco/Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCReco/Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) histos.fill(HIST("MCReco/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCReco/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); } // ipt = 1 { const int ipt = 1; float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; - if (std::isfinite(c2Sub)) histos.fill(HIST("MCReco/Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCReco/Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) histos.fill(HIST("MCReco/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCReco/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); } // ipt = 2 { const int ipt = 2; float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; - if (std::isfinite(c2Sub)) histos.fill(HIST("MCReco/Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCReco/Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) histos.fill(HIST("MCReco/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCReco/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); } } } @@ -1882,13 +2021,15 @@ void init(InitContext&) if (std::isfinite(c2Sub)) { histos.fill(HIST("MCRecoEffCorr/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_Cov_Eta"), valy, c2Sub); + if (cent < kCentCovCut) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("MCRecoEffCorr/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); + if (cent < kCentCovCut) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); } } @@ -1899,13 +2040,15 @@ void init(InitContext&) if (std::isfinite(c2Sub)) { histos.fill(HIST("MCRecoEffCorr/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_Cov_Eta"), valy, c2Sub); + if (cent < kCentCovCut) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("MCRecoEffCorr/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); + if (cent < kCentCovCut) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); } } @@ -1916,13 +2059,15 @@ void init(InitContext&) if (std::isfinite(c2Sub)) { histos.fill(HIST("MCRecoEffCorr/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_Cov_Eta"), valy, c2Sub); + if (cent < kCentCovCut) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("MCRecoEffCorr/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); + if (cent < kCentCovCut) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); } } } @@ -1937,48 +2082,57 @@ void init(InitContext&) { const int ipt = 0; float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; - if (std::isfinite(c2Sub)) histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); } // ipt = 1 { const int ipt = 1; float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; - if (std::isfinite(c2Sub)) histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); } // ipt = 2 { const int ipt = 2; float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; - if (std::isfinite(c2Sub)) histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); } } } - } } LOGF(info, "FINISHED RUNNING processMCFluc (pT + Et)"); } PROCESS_SWITCH(RadFlowDecorr, processMCFluc, "process MC to calculate pt/Et fluc", cfgRunMCFluc); - void processGetFlat(AodCollisionsSel::iterator const& coll,aod::BCsWithTimestamps const&,AodTracksSel const& tracks) + void processGetFlat(AodCollisionsSel::iterator const& coll, aod::BCsWithTimestamps const&, AodTracksSel const& tracks) { - if (!isEventSelected(coll)) return; + if (!isEventSelected(coll)) + return; float cent = getCentrality(coll); - if (cent < 0 || cent > 80) return; + if (cent < 0 || cent > 80) + return; for (const auto& track : tracks) { - if (!isTrackSelected(track)) continue; + if (!isTrackSelected(track)) + continue; float p = track.p(); // ADDED float eta = track.eta(); float phi = track.phi(); - if (p < kFloatEpsilon) continue; + if (p < kFloatEpsilon) + continue; histos.fill(HIST("hCentEtaPhi"), cent, eta, phi); const bool isPion = selectionPion(track); const bool isKaon = selectionKaon(track); @@ -1988,15 +2142,17 @@ void init(InitContext&) } } } - PROCESS_SWITCH(RadFlowDecorr, processGetFlat,"process real data to calculate mean pT and Et", cfgRunGetFlat); + PROCESS_SWITCH(RadFlowDecorr, processGetFlat, "process real data to calculate mean pT and Et", cfgRunGetFlat); - void processDataMean(AodCollisionsSel::iterator const& coll,aod::BCsWithTimestamps const&,AodTracksSel const& tracks) + void processDataMean(AodCollisionsSel::iterator const& coll, aod::BCsWithTimestamps const&, AodTracksSel const& tracks) { float sumWi[KNEta][KNpT]{}, sumWipti[KNEta][KNpT]{}; float sumWiEt[KNEta][KNpT]{}, sumWiEtVal[KNEta][KNpT]{}; - if (!isEventSelected(coll)) return; + if (!isEventSelected(coll)) + return; float cent = getCentrality(coll); - if (cent < 0 || cent > 80) return; + if (cent < 0 || cent > 80) + return; histos.fill(HIST("hZvtx_after_sel"), coll.posZ()); histos.fill(HIST("hCentrality"), cent); @@ -2004,12 +2160,14 @@ void init(InitContext&) histos.fill(HIST("Hist2D_cent_nch"), tracks.size(), cent); for (const auto& track : tracks) { - if (!isTrackSelected(track)) continue; + if (!isTrackSelected(track)) + continue; float pt = track.pt(); float eta = track.eta(); float p = track.p(); float phi = track.phi(); - if (p < kFloatEpsilon) continue; + if (p < kFloatEpsilon) + continue; histos.fill(HIST("hP"), p); histos.fill(HIST("hPt"), pt); histos.fill(HIST("hEta"), eta); @@ -2019,15 +2177,18 @@ void init(InitContext&) float fakeIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 1); float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; - if (!std::isfinite(wIncl) || wIncl <= kFloatEpsilon || effIncl <= kFloatEpsilon) continue; + if (!std::isfinite(wIncl) || wIncl <= kFloatEpsilon || effIncl <= kFloatEpsilon) + continue; histos.fill(HIST("hCentEtaPhi"), cent, eta, track.phi()); histos.fill(HIST("hCentEtaPhiWtd"), cent, eta, track.phi(), flatWeightIncl); for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; sumWi[ieta][ipt] += wIncl; sumWipti[ieta][ipt] += wIncl * pt; } @@ -2042,18 +2203,20 @@ void init(InitContext&) float fakePid = getEfficiency(coll.multNTracksPV(), pt, eta, kCombinedPID, 1); float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); float wPid = flatWeightPid * (1.0 - fakePid) / effPid; - if (!std::isfinite(wPid) || wPid <= kFloatEpsilon || effPid <= kFloatEpsilon) continue; + if (!std::isfinite(wPid) || wPid <= kFloatEpsilon || effPid <= kFloatEpsilon) + continue; histos.fill(HIST("hCentEtaPhiWtd_PID"), cent, eta, track.phi(), flatWeightPid); - float m = isPion ? o2::constants::physics::MassPiPlus : - isKaon ? o2::constants::physics::MassKPlus : - o2::constants::physics::MassProton; + float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus + : o2::constants::physics::MassProton; float E = std::sqrt(p * p + m * m); float Et = E * (pt / p); // E_T = E * sin(theta) for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; sumWiEt[ieta][ipt] += wPid; sumWiEtVal[ieta][ipt] += wPid * Et; } @@ -2061,34 +2224,37 @@ void init(InitContext&) } } histos.fill(HIST("Prof_cent_Nchrec"), cent, sumWi[0][0]); - if (isfinite(sumWi[0][0])) histos.fill(HIST("Prof_MeanpT_Cent"), cent, sumWipti[0][0] / sumWi[0][0]); - if (isfinite(sumWiEt[0][0])) histos.fill(HIST("Prof_MeanEt_Cent"), cent, sumWiEtVal[0][0] / sumWiEt[0][0]); + if (isfinite(sumWi[0][0])) + histos.fill(HIST("Prof_MeanpT_Cent"), cent, sumWipti[0][0] / sumWi[0][0]); + if (isfinite(sumWiEt[0][0])) + histos.fill(HIST("Prof_MeanEt_Cent"), cent, sumWiEtVal[0][0] / sumWiEt[0][0]); - for (int ieta = 0; ieta < KNEta; ++ieta){ + for (int ieta = 0; ieta < KNEta; ++ieta) { for (int ipt = 0; ipt < KNpT; ++ipt) { if (isfinite(sumWi[ieta][ipt])) - histos.fill(HIST("pmean_nch_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, - sumWipti[ieta][ipt] / sumWi[ieta][ipt]); + histos.fill(HIST("pmean_nch_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, + sumWipti[ieta][ipt] / sumWi[ieta][ipt]); if (isfinite(sumWiEt[ieta][ipt])) - histos.fill(HIST("pmeanEt_nch_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, - sumWiEtVal[ieta][ipt] / sumWiEt[ieta][ipt]); + histos.fill(HIST("pmeanEt_nch_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, + sumWiEtVal[ieta][ipt] / sumWiEt[ieta][ipt]); } } } - PROCESS_SWITCH(RadFlowDecorr, processDataMean,"process real data to calculate mean pT and Et", cfgRunDataMean); - + PROCESS_SWITCH(RadFlowDecorr, processDataMean, "process real data to calculate mean pT and Et", cfgRunDataMean); - void processDataFluc(AodCollisionsSel::iterator const& coll,aod::BCsWithTimestamps const&,AodTracksSel const& tracks) + void processDataFluc(AodCollisionsSel::iterator const& coll, aod::BCsWithTimestamps const&, AodTracksSel const& tracks) { - if (!isEventSelected(coll)) return; + if (!isEventSelected(coll)) + return; float cent = getCentrality(coll); - if (cent < 0 || cent > 80) return; + if (cent < 0 || cent > 80) + return; if (!pmeanNchEtabinPtbinStep2 || !pmeanEtNchEtabinPtbinStep2) { LOGF(warning, "Data fluc: Mean pT or Et map missing"); return; } - if (!hEff[kInclusive] || !hFake[kInclusive] || !hWeightMap3D[kInclusive] ||!hEff[kCombinedPID] || !hFake[kCombinedPID] || !hWeightMap3D[kCombinedPID]) { + if (!hEff[kInclusive] || !hFake[kInclusive] || !hWeightMap3D[kInclusive] || !hEff[kCombinedPID] || !hFake[kCombinedPID] || !hWeightMap3D[kCombinedPID]) { LOGF(warning, "Data fluc: Inclusive or PID correction maps are null"); return; } @@ -2102,27 +2268,32 @@ void init(InitContext&) double p1kBarEt[KNEta][KNpT]{}; for (const auto& track : tracks) { - if (!isTrackSelected(track)) continue; + if (!isTrackSelected(track)) + continue; float pt = track.pt(); float eta = track.eta(); float p = track.p(); float phi = track.phi(); - if (p < kFloatEpsilon) continue; + if (p < kFloatEpsilon) + continue; float effIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 0); float fakeIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 1); float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; - if (!std::isfinite(wIncl) || wIncl <= kFloatEpsilon || effIncl <= kFloatEpsilon) continue; + if (!std::isfinite(wIncl) || wIncl <= kFloatEpsilon || effIncl <= kFloatEpsilon) + continue; for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; for (int k = 0; k < KIntK; ++k) { for (int m = 0; m < KIntM; ++m) - sumpmwk[ieta][ipt][m][k] += std::pow(wIncl, k) * std::pow(pt, m); + sumpmwk[ieta][ipt][m][k] += std::pow(wIncl, k) * std::pow(pt, m); sumwk[ieta][ipt][k] += std::pow(wIncl, k); } } @@ -2137,21 +2308,23 @@ void init(InitContext&) float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); float wPid = flatWeightPid * (1.0 - fakePid) / effPid; - if (!std::isfinite(wPid) || wPid <= kFloatEpsilon || effPid <= kFloatEpsilon) continue; + if (!std::isfinite(wPid) || wPid <= kFloatEpsilon || effPid <= kFloatEpsilon) + continue; - float m = isPion ? o2::constants::physics::MassPiPlus : - isKaon ? o2::constants::physics::MassKPlus : - o2::constants::physics::MassProton; + float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus + : o2::constants::physics::MassProton; float E = std::sqrt(p * p + m * m); float Et = E * (pt / p); // E_T = E * sin(theta) for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; for (int k = 0; k < KIntK; ++k) { for (int m = 0; m < KIntM; ++m) - sumpmwkEt[ieta][ipt][m][k] += std::pow(wPid, k) * std::pow(Et, m); + sumpmwkEt[ieta][ipt][m][k] += std::pow(wPid, k) * std::pow(Et, m); sumwkEt[ieta][ipt][k] += std::pow(wPid, k); } } @@ -2159,30 +2332,32 @@ void init(InitContext&) } } for (int ieta = 0; ieta < KNEta; ++ieta) - for (int ipt = 0; ipt < KNpT; ++ipt) { - const int ibx = pmeanNchEtabinPtbinStep2->GetXaxis()->FindBin(coll.multNTracksPV()); - const int iby = ieta + 1; - const int ibz = ipt + 1; - float mmpt = pmeanNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmet = pmeanEtNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - - mean[ieta][ipt] = sumpmwk[ieta][ipt][1][1]/sumwk[ieta][ipt][1]; - meanEt[ieta][ipt] = sumpmwkEt[ieta][ipt][1][1]/sumwkEt[ieta][ipt][1]; - - if (std::isfinite(mmpt)) { - std::tie(mean[ieta][ipt], c2[ieta][ipt]) = - calculateMeanAndC2FromSums(sumpmwk[ieta][ipt], sumwk[ieta][ipt], mmpt); - p1kBar[ieta][ipt] = mean[ieta][ipt] - mmpt; - } - if (std::isfinite(mmet)) { - std::tie(meanEt[ieta][ipt], c2Et[ieta][ipt]) = - calculateMeanAndC2FromSums(sumpmwkEt[ieta][ipt], sumwkEt[ieta][ipt], mmet); - p1kBarEt[ieta][ipt] = meanEt[ieta][ipt] - mmet; + for (int ipt = 0; ipt < KNpT; ++ipt) { + const int ibx = pmeanNchEtabinPtbinStep2->GetXaxis()->FindBin(coll.multNTracksPV()); + const int iby = ieta + 1; + const int ibz = ipt + 1; + float mmpt = pmeanNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmet = pmeanEtNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + + mean[ieta][ipt] = sumpmwk[ieta][ipt][1][1] / sumwk[ieta][ipt][1]; + meanEt[ieta][ipt] = sumpmwkEt[ieta][ipt][1][1] / sumwkEt[ieta][ipt][1]; + + if (std::isfinite(mmpt)) { + std::tie(mean[ieta][ipt], c2[ieta][ipt]) = + calculateMeanAndC2FromSums(sumpmwk[ieta][ipt], sumwk[ieta][ipt], mmpt); + p1kBar[ieta][ipt] = mean[ieta][ipt] - mmpt; + } + if (std::isfinite(mmet)) { + std::tie(meanEt[ieta][ipt], c2Et[ieta][ipt]) = + calculateMeanAndC2FromSums(sumpmwkEt[ieta][ipt], sumwkEt[ieta][ipt], mmet); + p1kBarEt[ieta][ipt] = meanEt[ieta][ipt] - mmet; + } } - } - if (std::isfinite(c2[0][0])) histos.fill(HIST("Prof_C2_Cent"), cent, c2[0][0]); - if (std::isfinite(c2Et[0][0])) histos.fill(HIST("Prof_C2Et_Cent"), cent, c2Et[0][0]); + if (std::isfinite(c2[0][0])) + histos.fill(HIST("Prof_C2_Cent"), cent, c2[0][0]); + if (std::isfinite(c2Et[0][0])) + histos.fill(HIST("Prof_C2Et_Cent"), cent, c2Et[0][0]); if (std::isfinite(sumwk[0][0][1])) { histos.fill(HIST("Prof_MeanpT_Cent"), cent, mean[0][0]); histos.fill(HIST("Prof_MeanpT_Mult"), coll.multNTracksPV(), mean[0][0]); @@ -2193,12 +2368,14 @@ void init(InitContext&) } for (int ieta = 0; ieta < KNEta; ++ieta) - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (std::isfinite(c2[ieta][ipt])) histos.fill(HIST("Prof_C2_Mult_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, c2[ieta][ipt]); - if (std::isfinite(c2Et[ieta][ipt])) histos.fill(HIST("Prof_C2Et_Mult_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, c2Et[ieta][ipt]); - } + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (std::isfinite(c2[ieta][ipt])) + histos.fill(HIST("Prof_C2_Mult_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, c2[ieta][ipt]); + if (std::isfinite(c2Et[ieta][ipt])) + histos.fill(HIST("Prof_C2Et_Mult_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, c2Et[ieta][ipt]); + } - for (int ietaA = 1; ietaA <= (KNEta-1)/2; ++ietaA) { + for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { int ietaC = KNEta - ietaA; float valy = kHalf * (etaLw[ietaC] + etaUp[ietaC]); @@ -2207,12 +2384,14 @@ void init(InitContext&) float c2Sub = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; if (std::isfinite(c2Sub)) { histos.fill(HIST("Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) histos.fill(HIST("Prof_ipt0_Cov_Eta"), valy, c2Sub); + if (cent < kCentCovCut) + histos.fill(HIST("Prof_ipt0_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) histos.fill(HIST("Prof_ipt0_CovEt_Eta"), valy, c2SubEt); + if (cent < kCentCovCut) + histos.fill(HIST("Prof_ipt0_CovEt_Eta"), valy, c2SubEt); } } @@ -2221,12 +2400,14 @@ void init(InitContext&) float c2Sub = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; if (std::isfinite(c2Sub)) { histos.fill(HIST("Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) histos.fill(HIST("Prof_ipt1_Cov_Eta"), valy, c2Sub); + if (cent < kCentCovCut) + histos.fill(HIST("Prof_ipt1_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) histos.fill(HIST("Prof_ipt1_CovEt_Eta"), valy, c2SubEt); + if (cent < kCentCovCut) + histos.fill(HIST("Prof_ipt1_CovEt_Eta"), valy, c2SubEt); } } @@ -2235,51 +2416,58 @@ void init(InitContext&) float c2Sub = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; if (std::isfinite(c2Sub)) { histos.fill(HIST("Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) histos.fill(HIST("Prof_ipt2_Cov_Eta"), valy, c2Sub); + if (cent < kCentCovCut) + histos.fill(HIST("Prof_ipt2_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) histos.fill(HIST("Prof_ipt2_CovEt_Eta"), valy, c2SubEt); + if (cent < kCentCovCut) + histos.fill(HIST("Prof_ipt2_CovEt_Eta"), valy, c2SubEt); } } } - for (int ietaA = 1; ietaA < KNEta; ++ietaA){ + for (int ietaA = 1; ietaA < KNEta; ++ietaA) { for (int ietaC = 1; ietaC < KNEta; ++ietaC) { float valx = 0.5f * (etaLw[ietaA] + etaUp[ietaA]); float valy = kHalf * (etaLw[ietaC] + etaUp[ietaC]); { const int ipt = 0; float covpt = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; - if (std::isfinite(covpt)) histos.fill(HIST("Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, covpt); + if (std::isfinite(covpt)) + histos.fill(HIST("Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, covpt); float covet = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; - if (std::isfinite(covet)) histos.fill(HIST("Prof_ipt0_C2SubEt2D_Mult_etaA_etaC"), cent, valx, valy, covet); + if (std::isfinite(covet)) + histos.fill(HIST("Prof_ipt0_C2SubEt2D_Mult_etaA_etaC"), cent, valx, valy, covet); } - { const int ipt = 1; float covpt = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; - if (std::isfinite(covpt)) histos.fill(HIST("Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, covpt); + if (std::isfinite(covpt)) + histos.fill(HIST("Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, covpt); float covet = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; - if (std::isfinite(covet)) histos.fill(HIST("Prof_ipt1_C2SubEt2D_Mult_etaA_etaC"), cent, valx, valy, covet); + if (std::isfinite(covet)) + histos.fill(HIST("Prof_ipt1_C2SubEt2D_Mult_etaA_etaC"), cent, valx, valy, covet); } { const int ipt = 2; float covpt = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; - if (std::isfinite(covpt)) histos.fill(HIST("Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, covpt); + if (std::isfinite(covpt)) + histos.fill(HIST("Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, covpt); float covet = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; - if (std::isfinite(covet)) histos.fill(HIST("Prof_ipt2_C2SubEt2D_Mult_etaA_etaC"), cent, valx, valy, covet); + if (std::isfinite(covet)) + histos.fill(HIST("Prof_ipt2_C2SubEt2D_Mult_etaA_etaC"), cent, valx, valy, covet); } } } } - PROCESS_SWITCH(RadFlowDecorr, processDataFluc,"process real data to calculate fluc pT and Et", cfgRunDataFluc); + PROCESS_SWITCH(RadFlowDecorr, processDataFluc, "process real data to calculate fluc pT and Et", cfgRunDataFluc); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) From 26db4bddcda30fba79116d38d33b11ba952268bf Mon Sep 17 00:00:00 2001 From: Somadutta Bhatta Date: Mon, 10 Nov 2025 20:41:54 +0100 Subject: [PATCH 03/10] =?UTF-8?q?Rename=20RadFlowDecorr.cxx=20=E2=86=92=20?= =?UTF-8?q?radFlowDecorr.cxx=20and=20update=20workflow=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PWGCF/EbyEFluctuations/Tasks/CMakeLists.txt | 2 +- .../{RadFlowDecorr.cxx => radFlowDecorr.cxx} | 117 ++++-------------- 2 files changed, 23 insertions(+), 96 deletions(-) rename PWGCF/EbyEFluctuations/Tasks/{RadFlowDecorr.cxx => radFlowDecorr.cxx} (97%) diff --git a/PWGCF/EbyEFluctuations/Tasks/CMakeLists.txt b/PWGCF/EbyEFluctuations/Tasks/CMakeLists.txt index b3e37d174d9..ce59e861390 100644 --- a/PWGCF/EbyEFluctuations/Tasks/CMakeLists.txt +++ b/PWGCF/EbyEFluctuations/Tasks/CMakeLists.txt @@ -80,6 +80,6 @@ o2physics_add_dpl_workflow(part-num-fluc COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(radial-flow-decorr - SOURCES RadFlowDecorr.cxx + SOURCES radFlowDecorr.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore COMPONENT_NAME Analysis) diff --git a/PWGCF/EbyEFluctuations/Tasks/RadFlowDecorr.cxx b/PWGCF/EbyEFluctuations/Tasks/radFlowDecorr.cxx similarity index 97% rename from PWGCF/EbyEFluctuations/Tasks/RadFlowDecorr.cxx rename to PWGCF/EbyEFluctuations/Tasks/radFlowDecorr.cxx index 9bf63b4d27d..aaca32317a4 100644 --- a/PWGCF/EbyEFluctuations/Tasks/RadFlowDecorr.cxx +++ b/PWGCF/EbyEFluctuations/Tasks/radFlowDecorr.cxx @@ -111,10 +111,11 @@ struct RadFlowDecorr { static constexpr int kNbinsDca = 400; static constexpr float kDcaMax = 0.2f; static constexpr int kNbinsPtCoarse = 50; - - enum PID { kInclusive = 0, - kCombinedPID, - kNumPID }; + static constexpr float kPtMinDefault = 0.2f; + static constexpr float kPtMidMax = 3.0f; + static constexpr float kPtHighMax = 5.0f; + static constexpr float kPtFullMax = 10.0f; + enum PID { kInclusive = 0, kCombinedPID, kNumPID }; const std::vector pidSuffix = {"", "_PID"}; const std::vector etaLw = { @@ -124,20 +125,20 @@ struct RadFlowDecorr { 0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8}; - const std::vector pTLw = {0.2, 0.2, 0.2}; - const std::vector pTUp = {3, 5.0, 10.0}; - //============================== - //  Configurables - //============================== - Configurable cfgVtxZCut{"cfgVtxZCut", 10.f, "z-vertex range"}; - Configurable cfgPtMin{"cfgPtMin", 0.2f, "min pT"}; - Configurable cfgPtMax{"cfgPtMax", 10.0f, "max pT"}; - Configurable cfgEtaCut{"cfgEtaCut", 0.8f, "|η| cut"}; - Configurable cfgDCAXY{"cfgDCAXY", 2.4f, "DCAxy cut"}; - Configurable cfgDCAZ{"cfgDCAZ", 3.2f, "DCAz cut"}; - Configurable cfgTPCClsMin{"cfgTPCClsMin", 70.f, "min TPC clusters"}; - Configurable cfgChi2TPCMax{"cfgChi2TPCMax", 4.0f, "max TPC χ²"}; - Configurable cfgPIDnSigmaCut{"cfgPIDnSigmaCut", 3.f, "TPC PID |nσ| cut"}; + const std::vector pTLw = {kPtMinDefault, kPtMinDefault, kPtMinDefault}; + const std::vector pTUp = {kPtMidMax, kPtHighMax, kPtFullMax}; + //============================== + // Configurables + //============================== + Configurable cfgVtxZCut{"cfgVtxZCut", 10.f, "z-vertex range"}; + Configurable cfgPtMin{"cfgPtMin", 0.2f, "min pT"}; + Configurable cfgPtMax{"cfgPtMax", 10.0f, "max pT"}; + Configurable cfgEtaCut{"cfgEtaCut", 0.8f, "|η| cut"}; + Configurable cfgDCAXY{"cfgDCAXY", 2.4f, "DCAxy cut"}; + Configurable cfgDCAZ{"cfgDCAZ", 3.2f, "DCAz cut"}; + Configurable cfgTPCClsMin{"cfgTPCClsMin", 70.f, "min TPC clusters"}; + Configurable cfgChi2TPCMax{"cfgChi2TPCMax", 4.0f, "max TPC χ²"}; + Configurable cfgPIDnSigmaCut{"cfgPIDnSigmaCut", 3.f, "TPC PID |nσ| cut"}; Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; Configurable cfgCutTpcChi2NCl{"cfgCutTpcChi2NCl", 2.5f, "Maximum TPCchi2NCl"}; @@ -413,80 +414,6 @@ struct RadFlowDecorr { return val; } - /* - float getEfficiency(float mult, float pt, float eta, PID pidType, int effidx) const { - TH3F* h; - if(effidx==0) h = hEff[pidType]; // Efficiency map - if(effidx==1) h = hFake[pidType]; // Fake map - - if (!h) { - LOGF(error, "getEfficiency: Histogram is null for pidType %d, effidx %d", pidType, effidx); - return -1.0; -} - -const int ibx = h->GetXaxis()->FindBin(mult); -const int iby = h->GetYaxis()->FindBin(pt); -const int ibz = h->GetZaxis()->FindBin(eta); -float val = h->GetBinContent(ibx, iby, ibz); - -if (effidx == 1) { // This is a FAKE map -// For fakes, "it's ok if it is zero" -// But it's not ok if it's < 0 or >= 1. Set those to 0. -if (val < 0.f || val >= 1.0) { -return -1; -} -return val; // Return the valid fake value (which can be 0) -} - -// If we are here, this is an EFFICIENCY map (effidx == 0) -// For efficiency, "it's ok if it is 1" -// "but not vice versa" (i.e., val <= 0 is the problem) - -if (val > 0.f || val<1.1) { -// val > 0 is valid (including 1.0). -return val; -} - -// --- PROBLEM CASE: val <= 0. We must interpolate. --- -// We will scan along the pT axis (iby) to find neighbors - -// 1. Find bin "before" (lower pT) -int yBinBefore = iby - 1; -float valBefore = 0.f; -while (yBinBefore >= 1) { -valBefore = h->GetBinContent(ibx, yBinBefore, ibz); -if (valBefore > 0.f) break; // Found a valid bin -yBinBefore--; -} - -// 2. Find bin "after" (higher pT) -int yBinAfter = iby + 1; -float valAfter = 0.f; -int nBinsY = h->GetNbinsY(); -while (yBinAfter <= nBinsY) { -valAfter = h->GetBinContent(ibx, yBinAfter, ibz); -if (valAfter > 0.f) break; // Found a valid bin -yBinAfter++; -} - -// 3. Interpolate/Extrapolate -if (valBefore > 0.f && valAfter > 0.f) { -// We found valid bins on both sides. Do linear interpolation. -float m = (valAfter - valBefore) / (yBinAfter - yBinBefore); -float interpolatedVal = valBefore + m * (iby - yBinBefore); -return interpolatedVal; -} else if (valBefore > 0.f) { -// Only found a bin before. Extrapolate using that value. -return valBefore; -} else if (valAfter > 0.f) { -// Only found a bin after. Extrapolate using that value. -return valAfter; -} else { -return -1; -} -} -*/ - // Getter for (Cent, eta, phi) maps (Flattening) float getFlatteningWeight(float cent, float eta, float phi, PID pidType) const { TH3F* h = hWeightMap3D[pidType]; @@ -900,7 +827,7 @@ return -1; // --- Efficiency --- if (auto* hNum = dynamic_cast(dir->Get(hEff_NumName.c_str()))) { - hEff[pidType] = (TH3F*)hNum->Clone(Form("hEff%s", suffix.c_str())); + hEff[pidType] = reinterpret_cast(hNum->Clone(Form("hEff%s", suffix.c_str()))); hEff[pidType]->SetDirectory(nullptr); if (auto* hDen = dynamic_cast(dir->Get(hEff_DenName.c_str()))) { hDen->SetDirectory(nullptr); @@ -916,7 +843,7 @@ return -1; if (auto* hNumS = dynamic_cast(dir->Get(hFake_NumSecName.c_str()))) { auto* hNumF = dynamic_cast(dir->Get(hFake_NumFakName.c_str())); if (hNumS && hNumF) { - hFake[pidType] = (TH3F*)hNumS->Clone(Form("hFake%s", suffix.c_str())); + hFake[pidType] = reinterpret_cast(hNumS->Clone(Form("hFake%s", suffix.c_str()))); hFake[pidType]->Add(hNumF); hFake[pidType]->SetDirectory(nullptr); if (auto* hDenF = dynamic_cast(dir->Get(hFake_DenName.c_str()))) { @@ -1017,7 +944,7 @@ return -1; if (!f->IsZombie()) { if (auto* dir = dynamic_cast(f->Get("rad-flow-decorr"))) { if (auto* tp = dynamic_cast(dir->Get(histname))) { - target = (TProfile3D*)tp->Clone(); + target = reinterpret_cast(tp->Clone()); target->SetDirectory(nullptr); } else { LOGF(error, "Histogram %s missing in %s", histname, filename); From c961bb0570d9d918aadcdf0e78e9010fbe67bbb9 Mon Sep 17 00:00:00 2001 From: Somadutta Bhatta Date: Mon, 10 Nov 2025 20:53:45 +0100 Subject: [PATCH 04/10] =?UTF-8?q?Rename=20radFlowDecorr.cxx=20=E2=86=92=20?= =?UTF-8?q?radialFlowDecorr.cxx=20and=20update=20workflow=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PWGCF/EbyEFluctuations/Tasks/CMakeLists.txt | 2 +- .../Tasks/{radFlowDecorr.cxx => radialFlowDecorr.cxx} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename PWGCF/EbyEFluctuations/Tasks/{radFlowDecorr.cxx => radialFlowDecorr.cxx} (100%) diff --git a/PWGCF/EbyEFluctuations/Tasks/CMakeLists.txt b/PWGCF/EbyEFluctuations/Tasks/CMakeLists.txt index ce59e861390..c65d1705a93 100644 --- a/PWGCF/EbyEFluctuations/Tasks/CMakeLists.txt +++ b/PWGCF/EbyEFluctuations/Tasks/CMakeLists.txt @@ -80,6 +80,6 @@ o2physics_add_dpl_workflow(part-num-fluc COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(radial-flow-decorr - SOURCES radFlowDecorr.cxx + SOURCES radialFlowDecorr.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGCFCore COMPONENT_NAME Analysis) diff --git a/PWGCF/EbyEFluctuations/Tasks/radFlowDecorr.cxx b/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx similarity index 100% rename from PWGCF/EbyEFluctuations/Tasks/radFlowDecorr.cxx rename to PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx From be5002bf81cf6968a399557cffa9a433e94447a8 Mon Sep 17 00:00:00 2001 From: Somadutta Bhatta Date: Mon, 10 Nov 2025 21:51:50 +0100 Subject: [PATCH 05/10] Fix build errors and Unicode spaces in radialFlowDecorr.cxx; replace PDG and bin constants --- .../Tasks/radialFlowDecorr.cxx | 660 +++++++++--------- 1 file changed, 326 insertions(+), 334 deletions(-) diff --git a/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx b/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx index aaca32317a4..6ce71c39b80 100644 --- a/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx +++ b/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx @@ -8,9 +8,11 @@ // In applying this license CERN does not waive the privileges and immunities // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// \file RadFlowDecorr.cxx -/// \brief Task for Radial Flow Decorrelation Measurement + +/// \file radialFlowDecorr.cxx +/// \brief Analysis task for event-by-event radial-flow decorrelation measurement. /// \author Somadutta Bhatta + #include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" #include "Common/DataModel/Centrality.h" @@ -62,60 +64,71 @@ using namespace o2::framework; using namespace o2::framework::expressions; using namespace constants::math; -struct RadFlowDecorr { +struct RadialFlowDecorr { static constexpr int KIntM = 3; static constexpr int KIntK = 3; - // static constexpr int KNEta = 33; + static constexpr int KNEta = 17; static constexpr int KNpT = 3; // --- Linter Fixes: Magic Numbers --- - static constexpr float kFloatEpsilon = 1e-6f; - // static constexpr int kPiPlus = o2::constants::physics::Pdg::kPiPlus; - //   static constexpr int kKPlus = o2::constants::physics::Pdg::kKaPlus; - //   static constexpr int kProton = o2::constants::physics::Pdg::kProton; - static constexpr float kCentTestMin = 10.f; - static constexpr float kCentTestMaxLo = 60.f; - static constexpr float kCentTestMaxHi = 70.f; - static constexpr float kCentCovCut = 1.0f; - static constexpr float kBinOffset = 0.5f; - static constexpr float kHalf = 0.5f; + static constexpr float KFloatEpsilon = 1e-6f; + // static constexpr int KPiPlus = o2::constants::physics::Pdg::kPiPlus; + // static constexpr int KKPlus = o2::constants::physics::Pdg::kKaPlus; + // static constexpr int KProton = o2::constants::physics::Pdg::kProton; + static constexpr float KCentTestMin = 10.f; + static constexpr float KCentTestMaxLo = 60.f; + static constexpr float KCentTestMaxHi = 70.f; + static constexpr float KCentCovCut = 1.0f; + static constexpr float KBinOffset = 0.5f; + static constexpr float KHalf = 0.5f; + static constexpr float KPhiMin = 0.f; // Added for magic number fix // Histogram axis definitions - static constexpr int kNbinsZvtx = 240; - static constexpr float kZvtxMin = -12.f; - static constexpr float kZvtxMax = 12.f; - static constexpr int kNbinsP = 100; - static constexpr float kPMin = 0.f; - static constexpr float kPMax = 10.f; - static constexpr int kNbinsPt = 200; - static constexpr float kPtMin = 0.f; - static constexpr float kPtMax = 10.f; - static constexpr int kNbinsEta = 120; - static constexpr float kEtaMin = -1.2f; - static constexpr float kEtaMax = 1.2f; - static constexpr int kNbinsPhi = 64; - static constexpr float kEtaAxisMin = -0.8f; - static constexpr float kEtaAxisMax = 0.8f; - static constexpr int kNbinsPhiFine = 30; - static constexpr int kNbinsPtRes = 50; - static constexpr float kPtResMax = 1.f; - static constexpr int kNbinsEtaRes = 100; - static constexpr float kEtaResMax = 0.5f; - static constexpr int kNbinsVz = 80; - static constexpr float kVzMin = -40.f; - static constexpr float kVzMax = 40.f; - static constexpr float kVzResMax = 20.f; - static constexpr int kNbinsEtaFine = 20; - static constexpr float kEtaFineMax = 1.f; - static constexpr int kNbinsDca = 400; - static constexpr float kDcaMax = 0.2f; - static constexpr int kNbinsPtCoarse = 50; - static constexpr float kPtMinDefault = 0.2f; - static constexpr float kPtMidMax = 3.0f; - static constexpr float kPtHighMax = 5.0f; - static constexpr float kPtFullMax = 10.0f; - enum PID { kInclusive = 0, kCombinedPID, kNumPID }; + static constexpr int KNbinsZvtx = 240; + static constexpr float KZvtxMin = -12.f; + static constexpr float KZvtxMax = 12.f; + static constexpr int KNbinsP = 100; + static constexpr float KPMin = 0.f; + static constexpr float KPMax = 10.f; + static constexpr int KNbinsPt = 200; + static constexpr float KPtMin = 0.f; + static constexpr float KPtMax = 10.f; + static constexpr int KNbinsEta = 120; + static constexpr float KEtaMin = -1.2f; + static constexpr float KEtaMax = 1.2f; + static constexpr int KNbinsPhi = 64; + static constexpr float KEtaAxisMin = -0.8f; + static constexpr float KEtaAxisMax = 0.8f; + static constexpr int KNbinsPhiFine = 30; + static constexpr int KNbinsPtRes = 50; + static constexpr float KPtResMax = 1.f; + static constexpr int KNbinsEtaRes = 100; + static constexpr float KEtaResMax = 0.5f; + static constexpr int KNbinsVz = 80; + static constexpr float KVzMin = -40.f; + static constexpr float KVzMax = 40.f; + static constexpr float KVzResMax = 20.f; + static constexpr int KNbinsEtaFine = 20; + static constexpr float KEtaFineMax = 1.f; + static constexpr int KNbinsDca = 400; + static constexpr float KDcaMax = 0.2f; + static constexpr int KNbinsPtCoarse = 50; + static constexpr float KPtMinDefault = 0.2f; + static constexpr float KPtMidMax = 3.0f; + static constexpr float KPtHighMax = 5.0f; + static constexpr float KPtFullMax = 10.0f; + static constexpr float KCentMax = 90; + enum PID { kInclusive = 0, + kCombinedPID, + kNumPID }; + enum ECentralityEstimator { + kCentFT0C = 1, + kCentFT0A = 2, + kCentFT0M = 3, + kCentFV0A = 4 + }; + static constexpr float kInvalidCentrality = -1.0f; const std::vector pidSuffix = {"", "_PID"}; const std::vector etaLw = { @@ -125,26 +138,26 @@ struct RadFlowDecorr { 0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8}; - const std::vector pTLw = {kPtMinDefault, kPtMinDefault, kPtMinDefault}; - const std::vector pTUp = {kPtMidMax, kPtHighMax, kPtFullMax}; - //============================== - // Configurables - //============================== - Configurable cfgVtxZCut{"cfgVtxZCut", 10.f, "z-vertex range"}; - Configurable cfgPtMin{"cfgPtMin", 0.2f, "min pT"}; - Configurable cfgPtMax{"cfgPtMax", 10.0f, "max pT"}; - Configurable cfgEtaCut{"cfgEtaCut", 0.8f, "|η| cut"}; - Configurable cfgDCAXY{"cfgDCAXY", 2.4f, "DCAxy cut"}; - Configurable cfgDCAZ{"cfgDCAZ", 3.2f, "DCAz cut"}; - Configurable cfgTPCClsMin{"cfgTPCClsMin", 70.f, "min TPC clusters"}; - Configurable cfgChi2TPCMax{"cfgChi2TPCMax", 4.0f, "max TPC χ²"}; - Configurable cfgPIDnSigmaCut{"cfgPIDnSigmaCut", 3.f, "TPC PID |nσ| cut"}; + const std::vector pTLw = {KPtMinDefault, KPtMinDefault, KPtMinDefault}; + const std::vector pTUp = {KPtMidMax, KPtHighMax, KPtFullMax}; + //============================== + //  Configurables + //============================== + Configurable cfgVtxZCut{"cfgVtxZCut", 10.f, "z-vertex range"}; + Configurable cfgPtMin{"cfgPtMin", 0.2f, "min pT"}; + Configurable cfgPtMax{"cfgPtMax", 10.0f, "max pT"}; + Configurable cfgEtaCut{"cfgEtaCut", 0.8f, "|η| cut"}; + Configurable cfgDCAXY{"cfgDCAXY", 2.4f, "DCAxy cut"}; + Configurable cfgDCAZ{"cfgDCAZ", 3.2f, "DCAz cut"}; + Configurable cfgTPCClsMin{"cfgTPCClsMin", 70.f, "min TPC clusters"}; + Configurable cfgChi2TPCMax{"cfgChi2TPCMax", 4.0f, "max TPC χ²"}; + Configurable cfgPIDnSigmaCut{"cfgPIDnSigmaCut", 3.f, "TPC PID |nσ| cut"}; Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; Configurable cfgCutTpcChi2NCl{"cfgCutTpcChi2NCl", 2.5f, "Maximum TPCchi2NCl"}; Configurable cfgCutItsChi2NCl{"cfgCutItsChi2NCl", 36.0f, "Maximum ITSchi2NCl"}; - Configurable cfgCutTrackDcaZ{"cfgCutTrackDcaZ", 2.0f, "Maximum DcaZ"}; - Configurable cfgCutTrackDcaXY{"cfgCutTrackDcaXY", 0.2f, "Maximum DcaZ"}; + Configurable cfgCutTracKDcaMaxZ{"cfgCutTracKDcaMaxZ", 2.0f, "Maximum DcaZ"}; + Configurable cfgCutTracKDcaMaxXY{"cfgCutTracKDcaMaxXY", 0.2f, "Maximum DcaZ"}; Configurable cfgITScluster{"cfgITScluster", 1, "Minimum Number of ITS cluster"}; Configurable cfgTPCcluster{"cfgTPCcluster", 80, "Minimum Number of TPC cluster"}; @@ -168,23 +181,14 @@ struct RadFlowDecorr { Configurable cfgEvSelkNoITSROFrameBorder{"cfgEvSelkNoITSROFrameBorder", true, "ITSROFrame border event selection cut"}; Configurable cfgEvSelkNoTimeFrameBorder{"cfgEvSelkNoTimeFrameBorder", true, "TimeFrame border event selection cut"}; - //============================== - //  Services and registry - //============================== Service ccdb; Service pdg; HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - //============================== - //  External objects (shared across processes) - //============================== - // ### MODIFICATION ### - // Store maps in arrays, one for each PID type (kInclusive, kCombinedPID) + std::array hEff{}; std::array hFake{}; std::array hWeightMap3D{}; // (cent, eta, phi) - // #################### - // mean pT / Et profiles loaded in init() - // --- pT Profiles --- + TProfile3D* pmeanTruNchEtabinPtbinStep2 = nullptr; TProfile3D* pmeanRecoNchEtabinPtbinStep2 = nullptr; TProfile3D* pmeanRecoMatchedNchEtabinPtbinStep2 = nullptr; @@ -199,10 +203,7 @@ struct RadFlowDecorr { // --- Data Profiles --- TProfile3D* pmeanNchEtabinPtbinStep2 = nullptr; TProfile3D* pmeanEtNchEtabinPtbinStep2 = nullptr; - //============================== - //  Basic helpers - //============================== - // Line 131 + template bool isEventSelected(const T& col) { @@ -238,7 +239,7 @@ struct RadFlowDecorr { if (trk.pt() < cfgCutPtLower || trk.pt() > cfgCutPtUpper || std::abs(trk.eta()) > cfgCutEta) return false; - if (std::abs(trk.dcaXY()) > cfgCutTrackDcaXY || std::abs(trk.dcaZ()) > cfgCutTrackDcaZ) + if (std::abs(trk.dcaXY()) > cfgCutTracKDcaMaxXY || std::abs(trk.dcaZ()) > cfgCutTracKDcaMaxZ) return false; return true; } @@ -382,21 +383,19 @@ struct RadFlowDecorr { return false; } - //  Utility helpers - //============================== float getCentrality(const auto& col) const { - if (cfgCentralityChoice.value == 1) + if (cfgCentralityChoice.value == kCentFT0C) return col.centFT0C(); - if (cfgCentralityChoice.value == 2) + if (cfgCentralityChoice.value == kCentFT0A) return col.centFT0A(); - if (cfgCentralityChoice.value == 3) + if (cfgCentralityChoice.value == kCentFT0M) return col.centFT0M(); - if (cfgCentralityChoice.value == 4) + if (cfgCentralityChoice.value == kCentFV0A) return col.centFV0A(); - return -1.0f; + return kInvalidCentrality; } - // + float getEfficiency(float mult, float pt, float eta, PID pidType, int effidx) const { TH3F* h; @@ -431,14 +430,13 @@ struct RadFlowDecorr { { // --- Safety Checks --- if (sumwk[1] == 0.) { - return {0.f, 0.f}; // No tracks, return 0 + return {0.f, 0.f}; } double tau1 = sumwk[2] / (sumwk[1] * sumwk[1]); double denom2 = 1. - tau1; - if (std::abs(denom2) < kFloatEpsilon) { // Protect against divide-by-zero (e.g., N=1) - // Return mean, but C2 is undefined + if (std::abs(denom2) < KFloatEpsilon) { double pmk11_safe = sumpmwk[1][1] / sumwk[1]; return {static_cast(pmk11_safe), 0.f}; } @@ -470,13 +468,13 @@ struct RadFlowDecorr { ConfigurableAxis cfgAxisCent{"cfgAxisCent", {0.0, 1.0, 3.0, 5.0, 10, 20, 30, 40, 50, 60, 70, 80, 100}, "centrality axis (percentile)"}; // FT0*/FV0A style const AxisSpec centAxis{cfgAxisCent, "Centrality (%)"}; - static constexpr int kNbinsNch = 5000; - static constexpr float kNchMin = 0.5f; - static constexpr float kNchMax = 5000.5f; - static constexpr int kNbinsNchCoarse = 500; - static constexpr float kNchCoarseMax = 5000.5f; - ConfigurableAxis nChAxis{"nChAxis", {kNbinsNch, kNchMin, kNchMax}, "PV-contributor track multiplicity axis"}; - ConfigurableAxis nChAxis2{"nChAxis2", {kNbinsNchCoarse, kNchMin, kNchCoarseMax}, "PV-contributor track multiplicity axis"}; + static constexpr int KNbinsNch = 5000; + static constexpr float KNchMin = 0.5f; + static constexpr float KNchMax = 5000.5f; + static constexpr int KNbinsNchCoarse = 500; + static constexpr float KNchCoarseMax = 5000.5f; + ConfigurableAxis nChAxis{"nChAxis", {KNbinsNch, KNchMin, KNchMax}, "PV-contributor track multiplicity axis"}; + ConfigurableAxis nChAxis2{"nChAxis2", {KNbinsNchCoarse, KNchMin, KNchCoarseMax}, "PV-contributor track multiplicity axis"}; // run switches Configurable cfgRunGetEff{"cfgRunGetEff", false, "Run MC pass to build efficiency/fake maps"}; @@ -530,69 +528,70 @@ struct RadFlowDecorr { void declareCommonQA() { - histos.add("hZvtx_after_sel", ";z_{vtx} (cm)", kTH1F, {{kNbinsZvtx, kZvtxMin, kZvtxMax}}); + histos.add("hZvtx_after_sel", ";z_{vtx} (cm)", kTH1F, {{KNbinsZvtx, KZvtxMin, KZvtxMax}}); + histos.add("hVtxZ", ";z_{vtx} (cm)", kTH1F, {{KNbinsZvtx, KZvtxMin, KZvtxMax}}); histos.add("hCentrality", ";centrality (%)", kTH1F, {{centAxis}}); histos.add("Hist2D_globalTracks_PVTracks", ";N_{global};N_{PV}", kTH2F, {{nChAxis2}, {nChAxis2}}); histos.add("Hist2D_cent_nch", ";N_{PV};cent (%)", kTH2F, {{nChAxis2}, {centAxis}}); - histos.add("hP", ";p (GeV/c)", kTH1F, {{kNbinsP, kPMin, kPMax}}); - histos.add("hPt", ";p_{T} (GeV/c)", kTH1F, {{kNbinsPt, kPtMin, kPtMax}}); - histos.add("hEta", ";#eta", kTH1F, {{kNbinsEta, kEtaMin, kEtaMax}}); - histos.add("hPhi", ";#phi", kTH1F, {{kNbinsPhi, 0., TwoPI}}); - - histos.add("hCentEtaPhi", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - histos.add("hCent1EtaPhi", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - histos.add("hCent7EtaPhi", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - histos.add("hCentEtaPhiWtd", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - histos.add("hCent1EtaPhiWtd", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - histos.add("hCent7EtaPhiWtd", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - - histos.add("hCentEtaPhiWtd_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - histos.add("hCent1EtaPhiWtd_PID", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - histos.add("hCent7EtaPhiWtd_PID", ";#eta;#phi", kTH2F, {{(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - - histos.add("hCentEtaPhiTrue", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - histos.add("hCentEtaPhiReco", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - histos.add("hCentEtaPhiRecoMatched", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - - histos.add("hCentEtaPhiTrue_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - histos.add("hCentEtaPhiReco_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); - histos.add("hCentEtaPhiRecoMatched_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hP", ";p (GeV/c)", kTH1F, {{KNbinsP, KPMin, KPMax}}); + histos.add("hPt", ";p_{T} (GeV/c)", kTH1F, {{KNbinsPt, KPtMin, KPtMax}}); + histos.add("hEta", ";#eta", kTH1F, {{KNbinsEta, KEtaMin, KEtaMax}}); + histos.add("hPhi", ";#phi", kTH1F, {{KNbinsPhi, KPhiMin, TwoPI}}); + + histos.add("hCentEtaPhi", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCent1EtaPhi", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCent7EtaPhi", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCentEtaPhiWtd", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCent1EtaPhiWtd", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCent7EtaPhiWtd", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + + histos.add("hCentEtaPhiWtd_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCent1EtaPhiWtd_PID", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCent7EtaPhiWtd_PID", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + + histos.add("hCentEtaPhiTrue", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCentEtaPhiReco", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCentEtaPhiRecoMatched", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + + histos.add("hCentEtaPhiTrue_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCentEtaPhiReco_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCentEtaPhiRecoMatched_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); } void declareMCCommonHists() { - histos.add("ptResolution", ";p_{T}^{MC};p_{T}^{MC}-p_{T}^{reco}", kTH2F, {{kNbinsPtRes, 0., cfgPtMax}, {kNbinsPtRes, -kPtResMax, kPtResMax}}); - histos.add("ptTruthReco", ";p_{T}^{MC};p_{T}^{reco}", kTH2F, {{kNbinsPtRes, 0., cfgPtMax}, {kNbinsPtRes, 0., cfgPtMax}}); - histos.add("etaResolution", ";#eta^{MC};#eta^{MC}-#eta^{reco}", kTH2F, {{kNbinsEtaRes, -kEtaFineMax, kEtaFineMax}, {kNbinsPtRes, -kEtaResMax, kEtaResMax}}); - histos.add("etaTruthReco", ";#eta^{MC};#eta^{reco}", kTH2F, {{kNbinsPtRes, -kEtaFineMax, kEtaFineMax}, {kNbinsPtRes, -kEtaFineMax, kEtaFineMax}}); - - histos.add("TruthTrackVZ", ";Vz^{MC};Vz^{Reco}", kTH2F, {{kNbinsVz, kVzMin, kVzMax}, {kNbinsVz, kVzMin, kVzMax}}); - histos.add("vzResolution", ";Vz^{MC};Vz^{MC}-Vz^{Reco}", kTH2F, {{kNbinsVz, kVzMin, kVzMax}, {kNbinsVz, -kVzResMax, kVzResMax}}); - - histos.add("h3_AllPrimary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - histos.add("h3_RecoMatchedToPrimary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - histos.add("h3_RecoUnMatchedToPrimary_Secondary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - histos.add("h3_RecoUnMatchedToPrimary_Fake", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - histos.add("h3_AllReco", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - - histos.add("h3_AllPrimary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - histos.add("h3_RecoMatchedToPrimary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - histos.add("h3_RecoUnMatchedToPrimary_Secondary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - histos.add("h3_RecoUnMatchedToPrimary_Fake_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - histos.add("h3_AllReco_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - - histos.add("h_AllPrimary", ";p_{T}", kTH1F, {{kNbinsP, 0., cfgPtMax}}); - histos.add("h_RecoMatchedToPrimary", ";p_{T}", kTH1F, {{kNbinsPt, 0., kPtMax}}); - histos.add("h_RecoUnMatchedToPrimary", ";p_{T}", kTH1F, {{kNbinsPt, 0., kPtMax}}); - histos.add("h_AllReco", ";p_{T}", kTH1F, {{kNbinsPt, 0., kPtMax}}); - - histos.add("hReco_ParticleWeight", ";cent;p_{T};#eta", kTH3F, {{centAxis}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsPtRes, -kEtaFineMax, kEtaFineMax}}); - histos.add("hTruth_ParticleWeight", ";cent;p_{T};#eta", kTH3F, {{centAxis}, {kNbinsPtRes, 0., cfgPtMax}, {kNbinsPtRes, -kEtaFineMax, kEtaFineMax}}); - - histos.add("hDCAxy_Unmatched", ";DCA_{xy} (cm)", kTH1F, {{kNbinsDca, -kDcaMax, kDcaMax}}); - histos.add("hDCAz_Unmatched", ";DCA_{z} (cm)", kTH1F, {{kNbinsDca, -kDcaMax, kDcaMax}}); - histos.add("hDCAxy_NotPrimary", ";DCA_{xy} (cm)", kTH1F, {{kNbinsDca, -kDcaMax, kDcaMax}}); - histos.add("hDCAz_NotPrimary", ";DCA_{z} (cm)", kTH1F, {{kNbinsDca, -kDcaMax, kDcaMax}}); + histos.add("ptResolution", ";p_{T}^{MC};p_{T}^{MC}-p_{T}^{reco}", kTH2F, {{KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsPtRes, -KPtResMax, KPtResMax}}); + histos.add("ptTruthReco", ";p_{T}^{MC};p_{T}^{reco}", kTH2F, {{KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsPtRes, cfgPtMin, cfgPtMax}}); + histos.add("etaResolution", ";#eta^{MC};#eta^{MC}-#eta^{reco}", kTH2F, {{KNbinsEtaRes, -KEtaFineMax, KEtaFineMax}, {KNbinsPtRes, -KEtaResMax, KEtaResMax}}); + histos.add("etaTruthReco", ";#eta^{MC};#eta^{reco}", kTH2F, {{KNbinsPtRes, -KEtaFineMax, KEtaFineMax}, {KNbinsPtRes, -KEtaFineMax, KEtaFineMax}}); + + histos.add("TruthTracKVz", ";Vz^{MC};Vz^{Reco}", kTH2F, {{KNbinsVz, KVzMin, KVzMax}, {KNbinsVz, KVzMin, KVzMax}}); + histos.add("vzResolution", ";Vz^{MC};Vz^{MC}-Vz^{Reco}", kTH2F, {{KNbinsVz, KVzMin, KVzMax}, {KNbinsVz, -KVzResMax, KVzResMax}}); + + histos.add("h3_AllPrimary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_RecoMatchedToPrimary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_RecoUnMatchedToPrimary_Secondary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_RecoUnMatchedToPrimary_Fake", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_AllReco", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + + histos.add("h3_AllPrimary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_RecoMatchedToPrimary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_RecoUnMatchedToPrimary_Secondary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_RecoUnMatchedToPrimary_Fake_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_AllReco_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + + histos.add("h_AllPrimary", ";p_{T}", kTH1F, {{KNbinsP, cfgPtMin, cfgPtMax}}); + histos.add("h_RecoMatchedToPrimary", ";p_{T}", kTH1F, {{KNbinsPt, KPtMin, KPtMax}}); + histos.add("h_RecoUnMatchedToPrimary", ";p_{T}", kTH1F, {{KNbinsPt, KPtMin, KPtMax}}); + histos.add("h_AllReco", ";p_{T}", kTH1F, {{KNbinsPt, KPtMin, KPtMax}}); + + histos.add("hReco_ParticleWeight", ";cent;p_{T};#eta", kTH3F, {{centAxis}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsPtRes, -KEtaFineMax, KEtaFineMax}}); + histos.add("hTruth_ParticleWeight", ";cent;p_{T};#eta", kTH3F, {{centAxis}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsPtRes, -KEtaFineMax, KEtaFineMax}}); + + histos.add("hDCAxy_Unmatched", ";DCA_{xy} (cm)", kTH1F, {{KNbinsDca, -KDcaMax, KDcaMax}}); + histos.add("hDCAz_Unmatched", ";DCA_{z} (cm)", kTH1F, {{KNbinsDca, -KDcaMax, KDcaMax}}); + histos.add("hDCAxy_NotPrimary", ";DCA_{xy} (cm)", kTH1F, {{KNbinsDca, -KDcaMax, KDcaMax}}); + histos.add("hDCAz_NotPrimary", ";DCA_{z} (cm)", kTH1F, {{KNbinsDca, -KDcaMax, KDcaMax}}); } void declareMCMeanHists() @@ -604,12 +603,12 @@ struct RadFlowDecorr { histos.add("Eff_Ntrk", ";N_{PV};#epsilon", kTProfile, {nChAxis2}); histos.add("Fake_Ntrk", ";N_{PV};f_{fake}", kTProfile, {nChAxis2}); histos.add("wgt_Ntrk", ";N_{PV};w", kTProfile, {nChAxis2}); - histos.add("Eff_pT", ";p_{T};#epsilon", kTProfile, {{kNbinsPtRes, 0., cfgPtMax}}); - histos.add("Fake_pT", ";p_{T};f_{fake}", kTProfile, {{kNbinsPtRes, 0., cfgPtMax}}); - histos.add("wgt_pT", ";p_{T};w", kTProfile, {{kNbinsPtRes, 0., kPtMax}}); - histos.add("Eff_eta", ";#eta;#epsilon", kTProfile, {{kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - histos.add("Fake_eta", ";#eta;f_{fake}", kTProfile, {{kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); - histos.add("wgt_eta", ";#eta;w", kTProfile, {{kNbinsEtaFine, -kEtaFineMax, kEtaFineMax}}); + histos.add("Eff_pT", ";p_{T};#epsilon", kTProfile, {{KNbinsPtRes, cfgPtMin, cfgPtMax}}); + histos.add("Fake_pT", ";p_{T};f_{fake}", kTProfile, {{KNbinsPtRes, cfgPtMin, cfgPtMax}}); + histos.add("wgt_pT", ";p_{T};w", kTProfile, {{KNbinsPtRes, KPtMin, KPtMax}}); + histos.add("Eff_eta", ";#eta;#epsilon", kTProfile, {{KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("Fake_eta", ";#eta;f_{fake}", kTProfile, {{KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("wgt_eta", ";#eta;w", kTProfile, {{KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); // MC mean profiles (pT & Et) for various selections histos.add("MCGen/Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); histos.add("MCGen/Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); @@ -636,105 +635,104 @@ struct RadFlowDecorr { } void declareMCFlucHists() { - static constexpr int kNbinsNchFluc = 1000; + static constexpr int KNbinsNchFluc = 1000; // pT cumulants histos.add("MCGen/Prof_C2_Cent", ";cent;C_{2}", kTProfile, {centAxis}); histos.add("MCGen/Prof_C2_Mult", ";N_{PV};C_{2}", kTProfile, {nChAxis}); histos.add("MCGen/Prof_C2Sub_Mult_etabin_ptbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, - {{kNbinsNchFluc, kNchMin, kNchCoarseMax}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - histos.add("MCGen/Prof_ipt0_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt0_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt0_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); + {{KNbinsNchFluc, KNchMin, KNchCoarseMax}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("MCGen/Prof_ipt0_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt0_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt0_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); histos.add("MCGen/Prof_C2Et_Cent", ";cent;C_{2}^{E_{T}}", kTProfile, {centAxis}); histos.add("MCGen/Prof_C2Et_Mult", ";N_{PV};C_{2}^{E_{T}}", kTProfile, {nChAxis}); histos.add("MCGen/Prof_C2EtSub_Mult_etabin_ptbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, - {{kNbinsNchFluc, kNchMin, kNchCoarseMax}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - histos.add("MCGen/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt0_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt0_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); + {{KNbinsNchFluc, KNchMin, KNchCoarseMax}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("MCGen/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt0_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt0_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); histos.add("MCGen/Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); histos.add("MCGen/Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); histos.add("MCGen/Prof_MeanpT_Mult", ";N_{PV};#LT p_{T}#GT", kTProfile, {nChAxis}); - histos.add("pmeanTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - histos.add("pmeanRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - histos.add("pmeanRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - histos.add("pmeanRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - histos.add("pmeanRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("pmeanTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); histos.add("MCGen/Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); histos.add("MCGen/Prof_MeanEt_Mult", ";N_{PV};#LT E_{T}#GT", kTProfile, {nChAxis}); - histos.add("pmeanEtTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - histos.add("pmeanEtRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - histos.add("pmeanEtRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - histos.add("pmeanEtRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - histos.add("pmeanEtRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("pmeanEtTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanEtRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanEtRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanEtRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanEtRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); } void declareDataMeanHists() { histos.add("Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); histos.add("Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); - histos.add("pmean_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("pmean_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); // Et histos.add("Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); - histos.add("pmeanEt_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("pmeanEt_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); } void declareDataGetFlatHists() { - // histos.add("hCentEtaPhi", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), -0.8, 0.8}, {30, 0, TMath::TwoPi()}}); - histos.add("hCentEtaPhi_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), kEtaAxisMin, kEtaAxisMax}, {kNbinsPhiFine, 0, TwoPI}}); + histos.add("hCentEtaPhi_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, 0, TwoPI}}); } void declareDataFlucHists() { - histos.add("pmean_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("pmean_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); histos.add("Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); - histos.add("pmeanEt_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("pmeanEt_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); histos.add("Prof_C2_Cent", ";cent;C_{2}", kTProfile, {centAxis}); histos.add("Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); histos.add("Prof_MeanpT_Mult", ";N_{PV};#LT p_{T}#GT", kTProfile, {nChAxis}); - histos.add("Prof_C2_Mult_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); + histos.add("Prof_C2_Mult_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("Prof_ipt0_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); - histos.add("Prof_ipt0_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); - histos.add("Prof_ipt1_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); - histos.add("Prof_ipt1_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); - histos.add("Prof_ipt2_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); - histos.add("Prof_ipt2_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); + histos.add("Prof_ipt0_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("Prof_ipt0_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("Prof_ipt1_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("Prof_ipt1_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("Prof_ipt2_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("Prof_ipt2_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); histos.add("Prof_C2Et_Cent", ";cent;C_{2}^{E_{T}}", kTProfile, {centAxis}); histos.add("Prof_MeanEt_Mult", ";N_{PV};#LT E_{T}#GT", kTProfile, {nChAxis}); - histos.add("Prof_C2Et_Mult_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -kBinOffset, KNEta + kBinOffset}, {KNpT + 1, -kBinOffset, KNpT + kBinOffset}}); - - histos.add("Prof_ipt0_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); - histos.add("Prof_ipt0_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); - histos.add("Prof_ipt1_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); - histos.add("Prof_ipt1_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); - histos.add("Prof_ipt2_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, kEtaAxisMax}}); - histos.add("Prof_ipt2_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., kEtaAxisMax}}); - - histos.add("Prof_ipt0_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); - histos.add("Prof_ipt1_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); - histos.add("Prof_ipt2_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); - histos.add("Prof_ipt0_C2SubEt2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); - histos.add("Prof_ipt1_C2SubEt2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); - histos.add("Prof_ipt2_C2SubEt2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}, {KNEta - 1, kEtaAxisMin, kEtaAxisMax}}); + histos.add("Prof_C2Et_Mult_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + + histos.add("Prof_ipt0_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("Prof_ipt0_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("Prof_ipt1_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("Prof_ipt1_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("Prof_ipt2_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("Prof_ipt2_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + + histos.add("Prof_ipt0_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("Prof_ipt1_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("Prof_ipt2_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("Prof_ipt0_C2SubEt2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("Prof_ipt1_C2SubEt2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("Prof_ipt2_C2SubEt2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); } TH3F* buildWeightMapFromRaw(TH3F* hRaw, const char* mapName) @@ -743,7 +741,7 @@ struct RadFlowDecorr { LOGF(error, "Raw eta-phi map for '%s' is null; no flattening will be applied.", mapName); return nullptr; } - auto hWeightMap = (TH3F*)hRaw->Clone(mapName); + auto hWeightMap = reinterpret_cast(hRaw->Clone(mapName)); hWeightMap->SetTitle(Form("Flattening Weight Map %s (w_{#phi} = / N_{#phi})", mapName)); hWeightMap->SetDirectory(nullptr); hWeightMap->Reset(); @@ -819,39 +817,39 @@ struct RadFlowDecorr { // Helper lambda to load Eff/Fake maps for a given PID type auto loadEffFakeForPID = [&](PID pidType) { std::string suffix = pidSuffix[pidType]; - std::string hEff_NumName = "h3_RecoMatchedToPrimary" + suffix; - std::string hEff_DenName = "h3_AllPrimary" + suffix; - std::string hFake_NumSecName = "h3_RecoUnMatchedToPrimary_Secondary" + suffix; - std::string hFake_NumFakName = "h3_RecoUnMatchedToPrimary_Fake" + suffix; - std::string hFake_DenName = "h3_AllReco" + suffix; + std::string hEffNumName = "h3_RecoMatchedToPrimary" + suffix; + std::string hEffDenName = "h3_AllPrimary" + suffix; + std::string hFakeNumSecName = "h3_RecoUnMatchedToPrimary_Secondary" + suffix; + std::string hFakeNumFakName = "h3_RecoUnMatchedToPrimary_Fake" + suffix; + std::string hFakeDenName = "h3_AllReco" + suffix; // --- Efficiency --- - if (auto* hNum = dynamic_cast(dir->Get(hEff_NumName.c_str()))) { + if (auto* hNum = dynamic_cast(dir->Get(hEffNumName.c_str()))) { hEff[pidType] = reinterpret_cast(hNum->Clone(Form("hEff%s", suffix.c_str()))); hEff[pidType]->SetDirectory(nullptr); - if (auto* hDen = dynamic_cast(dir->Get(hEff_DenName.c_str()))) { + if (auto* hDen = dynamic_cast(dir->Get(hEffDenName.c_str()))) { hDen->SetDirectory(nullptr); hEff[pidType]->Divide(hDen); delete hDen; } else { - LOGF(error, "Missing denominator %s for efficiency.", hEff_DenName.c_str()); + LOGF(error, "Missing denominator %s for efficiency.", hEffDenName.c_str()); } } else { - LOGF(error, "Missing numerator %s for efficiency.", hEff_NumName.c_str()); + LOGF(error, "Missing numerator %s for efficiency.", hEffNumName.c_str()); } // --- Fakes --- - if (auto* hNumS = dynamic_cast(dir->Get(hFake_NumSecName.c_str()))) { - auto* hNumF = dynamic_cast(dir->Get(hFake_NumFakName.c_str())); + if (auto* hNumS = dynamic_cast(dir->Get(hFakeNumSecName.c_str()))) { + auto* hNumF = dynamic_cast(dir->Get(hFakeNumFakName.c_str())); if (hNumS && hNumF) { hFake[pidType] = reinterpret_cast(hNumS->Clone(Form("hFake%s", suffix.c_str()))); hFake[pidType]->Add(hNumF); hFake[pidType]->SetDirectory(nullptr); - if (auto* hDenF = dynamic_cast(dir->Get(hFake_DenName.c_str()))) { + if (auto* hDenF = dynamic_cast(dir->Get(hFakeDenName.c_str()))) { hDenF->SetDirectory(nullptr); hFake[pidType]->Divide(hDenF); delete hDenF; } else { - LOGF(error, "Missing denominator %s for fakes.", hFake_DenName.c_str()); + LOGF(error, "Missing denominator %s for fakes.", hFakeDenName.c_str()); } } else { LOGF(error, "Missing fake numerator(s) for %s in EffMaps file.", suffix.c_str()); @@ -912,12 +910,11 @@ struct RadFlowDecorr { if (auto* dir = dynamic_cast(f->Get("rad-flow-decorr"))) { auto loadFlatForPID = [&](PID pidType) { std::string suffix = pidSuffix[pidType]; - // std::string hFlat_SrcName = "hCentEtaPhiRecoMatched" + suffix; - std::string hFlat_SrcName = "hCentEtaPhiReco" + suffix; // As in original code - if (auto* hRaw = dynamic_cast(dir->Get(hFlat_SrcName.c_str()))) { + std::string hFlatSrcName = "hCentEtaPhiReco" + suffix; + if (auto* hRaw = dynamic_cast(dir->Get(hFlatSrcName.c_str()))) { hWeightMap3D[pidType] = buildWeightMapFromRaw(hRaw, Form("hWeightMap3D%s", suffix.c_str())); } else { - LOGF(warning, "MC flattening source '%s' not found; proceeding without flattening for this PID.", hFlat_SrcName.c_str()); + LOGF(warning, "MC flattening source '%s' not found; proceeding without flattening for this PID.", hFlatSrcName.c_str()); } }; loadFlatForPID(kInclusive); @@ -936,9 +933,6 @@ struct RadFlowDecorr { } } - //======================== - // Load Step-2 mean profiles (pT and Et) - //======================== auto loadTProfile3D = [&](const char* filename, const char* histname, TProfile3D*& target) { if (auto* f = TFile::Open(filename, "READ")) { if (!f->IsZombie()) { @@ -1009,7 +1003,7 @@ struct RadFlowDecorr { } float cent = getCentrality(col); - if (cent < 0 || cent > 80) + if (cent > KCentMax) continue; for (const auto& particle : partSlice) { @@ -1028,9 +1022,9 @@ struct RadFlowDecorr { histos.fill(HIST("hCentEtaPhiTrue"), cent, particle.eta(), particle.phi()); histos.fill(HIST("h3_AllPrimary"), col.multNTracksPV(), particle.pt(), particle.eta()); - if (cent < kCentTestMin) + if (cent < KCentTestMin) histos.fill(HIST("hCent1EtaPhi"), particle.eta(), particle.phi()); - if (cent > kCentTestMaxLo && cent < kCentTestMaxHi) + if (cent > KCentTestMaxLo && cent < KCentTestMaxHi) histos.fill(HIST("hCent7EtaPhi"), particle.eta(), particle.phi()); if (isPid) { @@ -1038,7 +1032,7 @@ struct RadFlowDecorr { histos.fill(HIST("h3_AllPrimary_PID"), col.multNTracksPV(), particle.pt(), particle.eta()); } } - histos.fill(HIST("TruthTrackVZ"), mcCollision.posZ(), col.posZ()); + histos.fill(HIST("TruthTracKVz"), mcCollision.posZ(), col.posZ()); histos.fill(HIST("vzResolution"), mcCollision.posZ(), mcCollision.posZ() - col.posZ()); // Reconstructed @@ -1104,7 +1098,7 @@ struct RadFlowDecorr { } // mcColl LOGF(info, "FINISHED RUNNING processGetEffHists"); } - PROCESS_SWITCH(RadFlowDecorr, processGetEffHists, "process MC to calculate Eff and Fakes", cfgRunGetEff); + PROCESS_SWITCH(RadialFlowDecorr, processGetEffHists, "process MC to calculate Eff and Fakes", cfgRunGetEff); void processMCMean(aod::McCollisions const& mcColl, MyRun3MCCollisions const& collisions, TCs const& tracks, FilteredTCs const& /*filteredTracks*/, aod::McParticles const& mcParticles) { @@ -1143,7 +1137,7 @@ struct RadFlowDecorr { } float cent = getCentrality(col); - if (cent < 0 || cent > 80) + if (cent > KCentMax) continue; if (col.globalIndex() >= trackSlice.size()) { @@ -1188,7 +1182,6 @@ struct RadFlowDecorr { float pt = particle.pt(); float eta = particle.eta(); float p = particle.p(); - const double wi = 1.0; for (int ieta = 0; ieta < KNEta; ++ieta) { if (eta <= etaLw[ieta] || eta > etaUp[ieta]) @@ -1196,14 +1189,14 @@ struct RadFlowDecorr { for (int ipt = 0; ipt < KNpT; ++ipt) { if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; - sumWiTruth[ieta][ipt] += 1.0; - sumWiptiTruth[ieta][ipt] += 1.0 * pt; + sumWiTruth[ieta][ipt]++; + sumWiptiTruth[ieta][ipt] += pt; if (isPion || isKaon || isProton) { float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus : o2::constants::physics::MassProton; float E = std::sqrt(p * p + m * m); float Et = E * (pt / p); // E_T = E * sin(theta) = E * (pT / p) - sumWiTruthEt[ieta][ipt] += 1.0; + sumWiTruthEt[ieta][ipt]++; sumWiptiTruthEt[ieta][ipt] += Et; } } @@ -1220,9 +1213,9 @@ struct RadFlowDecorr { float phi = track.phi(); histos.fill(HIST("hCentEtaPhi"), cent, eta, phi); - if (cent < kCentTestMin) + if (cent < KCentTestMin) histos.fill(HIST("hCent1EtaPhi"), eta, phi); - if (cent > kCentTestMaxLo && cent < kCentTestMaxHi) + if (cent > KCentTestMaxLo && cent < KCentTestMaxHi) histos.fill(HIST("hCent7EtaPhi"), eta, phi); float effIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 0); @@ -1231,9 +1224,9 @@ struct RadFlowDecorr { float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; histos.fill(HIST("hCentEtaPhiWtd"), cent, eta, track.phi(), flatWeightIncl); - if (cent < kCentTestMin) + if (cent < KCentTestMin) histos.fill(HIST("hCent1EtaPhiWtd"), track.eta(), track.phi(), flatWeightIncl); - if (cent > kCentTestMaxLo && cent < kCentTestMaxHi) + if (cent > KCentTestMaxLo && cent < KCentTestMaxHi) histos.fill(HIST("hCent7EtaPhiWtd"), track.eta(), track.phi(), flatWeightIncl); for (int ieta = 0; ieta < KNEta; ++ieta) { @@ -1268,12 +1261,12 @@ struct RadFlowDecorr { float effPid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 0); float fakePid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 1); float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); - float wPid =  flatWeightPid * (1.0 - fakePid) / effPid; + float wPid = flatWeightPid * (1.0 - fakePid) / effPid; histos.fill(HIST("hCentEtaPhiWtd_PID"), cent, eta, track.phi(), flatWeightPid); - if (cent < kCentTestMin) + if (cent < KCentTestMin) histos.fill(HIST("hCent1EtaPhiWtd_PID"), track.eta(), track.phi(), flatWeightPid); - if (cent > kCentTestMaxLo && cent < kCentTestMaxHi) + if (cent > KCentTestMaxLo && cent < KCentTestMaxHi) histos.fill(HIST("hCent7EtaPhiWtd_PID"), track.eta(), track.phi(), flatWeightPid); float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus @@ -1291,7 +1284,7 @@ struct RadFlowDecorr { } } - if (effPid <= kFloatEpsilon || !isfinite(wPid) || !isfinite(fakePid) || !isfinite(flatWeightPid)) + if (effPid <= KFloatEpsilon || !isfinite(wPid) || !isfinite(fakePid) || !isfinite(flatWeightPid)) continue; for (int ieta = 0; ieta < KNEta; ++ieta) { @@ -1307,7 +1300,7 @@ struct RadFlowDecorr { } if (isfinite(wIncl)) { - if (cent < kCentTestMin) { + if (cent < KCentTestMin) { histos.fill(HIST("wgt_pT"), pt, wIncl); histos.fill(HIST("Eff_pT"), pt, effIncl); histos.fill(HIST("Fake_pT"), pt, fakeIncl); @@ -1326,34 +1319,34 @@ struct RadFlowDecorr { } // end track loop if (isfinite(sumWiTruth[0][0])) { - float meanpT_truth = sumWiptiTruth[0][0] / sumWiTruth[0][0]; - if (!isfinite(meanpT_truth)) - LOGF(info, "meanpT_truth = %.3f, num = %.3f, den =%.3f", meanpT_truth, sumWiptiTruth[0][0], sumWiTruth[0][0]); - if (!isfinite(meanpT_truth)) + float meanPtTruth = sumWiptiTruth[0][0] / sumWiTruth[0][0]; + if (!isfinite(meanPtTruth)) + LOGF(info, "meanPtTruth = %.3f, num = %.3f, den =%.3f", meanPtTruth, sumWiptiTruth[0][0], sumWiTruth[0][0]); + if (!isfinite(meanPtTruth)) continue; histos.fill(HIST("MCGen/Prof_cent_Nchrec"), cent, sumWiTruth[0][0]); - histos.fill(HIST("MCGen/Prof_MeanpT_Cent"), cent, meanpT_truth); - histos.fill(HIST("MCGen/Prof_MeanpT_Mult"), col.multNTracksPV(), meanpT_truth); + histos.fill(HIST("MCGen/Prof_MeanpT_Cent"), cent, meanPtTruth); + histos.fill(HIST("MCGen/Prof_MeanpT_Mult"), col.multNTracksPV(), meanPtTruth); } if (isfinite(sumWiReco[0][0])) { - float meanpT_reco = sumWiptiReco[0][0] / sumWiReco[0][0]; - if (!isfinite(meanpT_reco)) - LOGF(info, "meanpT_reco = %.3f, num = %.3f, den =%.3f", meanpT_reco, sumWiptiReco[0][0], sumWiReco[0][0]); - if (!isfinite(meanpT_reco)) + float meanPtReco = sumWiptiReco[0][0] / sumWiReco[0][0]; + if (!isfinite(meanPtReco)) + LOGF(info, "meanPtReco = %.3f, num = %.3f, den =%.3f", meanPtReco, sumWiptiReco[0][0], sumWiReco[0][0]); + if (!isfinite(meanPtReco)) continue; histos.fill(HIST("MCReco/Prof_cent_Nchrec"), cent, sumWiReco[0][0]); - histos.fill(HIST("MCReco/Prof_MeanpT_Cent"), cent, meanpT_reco); - histos.fill(HIST("MCReco/Prof_MeanpT_Mult"), col.multNTracksPV(), meanpT_reco); + histos.fill(HIST("MCReco/Prof_MeanpT_Cent"), cent, meanPtReco); + histos.fill(HIST("MCReco/Prof_MeanpT_Mult"), col.multNTracksPV(), meanPtReco); } if (isfinite(sumWiRecoEffCorr[0][0])) { - float meanpT_effcorr = sumWiptiRecoEffCorr[0][0] / sumWiRecoEffCorr[0][0]; - if (!isfinite(meanpT_effcorr)) - LOGF(info, "meanpT_recoEffcorr = %.3f, num = %.3f, den =%.3f", meanpT_effcorr, sumWiptiRecoEffCorr[0][0], sumWiRecoEffCorr[0][0]); - if (!isfinite(meanpT_effcorr)) + float meanpTeffcorr = sumWiptiRecoEffCorr[0][0] / sumWiRecoEffCorr[0][0]; + if (!isfinite(meanpTeffcorr)) + LOGF(info, "meanPtRecoEffcorr = %.3f, num = %.3f, den =%.3f", meanpTeffcorr, sumWiptiRecoEffCorr[0][0], sumWiRecoEffCorr[0][0]); + if (!isfinite(meanpTeffcorr)) continue; histos.fill(HIST("MCRecoEffCorr/Prof_cent_Nchrec"), cent, sumWiRecoEffCorr[0][0]); - histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Cent"), cent, meanpT_effcorr); - histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Mult"), col.multNTracksPV(), meanpT_effcorr); + histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Cent"), cent, meanpTeffcorr); + histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Mult"), col.multNTracksPV(), meanpTeffcorr); } if (isfinite(sumWiTruthEt[0][0])) { @@ -1409,7 +1402,7 @@ struct RadFlowDecorr { LOGF(info, "FINISHED RUNNING processMCMean (pT + Et)"); } - PROCESS_SWITCH(RadFlowDecorr, processMCMean, "process MC to calculate mean pt/Et and Eff Hists", cfgRunMCMean); + PROCESS_SWITCH(RadialFlowDecorr, processMCMean, "process MC to calculate mean pt/Et and Eff Hists", cfgRunMCMean); void processMCFluc(aod::McCollisions const& mcColl, MyRun3MCCollisions const& collisions, TCs const& tracks, FilteredTCs const& /*filteredTracks*/, aod::McParticles const& mcParticles) { @@ -1437,7 +1430,7 @@ struct RadFlowDecorr { auto colSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex()); if (colSlice.size() != 1) continue; - histos.fill(HIST("MCGen/hVtxZ"), mcCollision.posZ()); // This histogram was not declared, commenting out. + // histos.fill(HIST("MCGen/hVtxZ"), mcCollision.posZ()); for (const auto& col : colSlice) { auto trackSlice = tracks.sliceBy(trackPerCollision, col.globalIndex()); @@ -1475,7 +1468,7 @@ struct RadFlowDecorr { if (!col.has_mcCollision() || !isEventSelected(col)) continue; float cent = getCentrality(col); - if (cent < 0 || cent > 80) + if (cent > KCentMax) continue; // truth @@ -1487,7 +1480,6 @@ struct RadFlowDecorr { float pt = particle.pt(); float eta = particle.eta(); float p = particle.p(); - const double wi = 1.0; // pT (Inclusive) for (int ieta = 0; ieta < KNEta; ++ieta) { @@ -1498,9 +1490,9 @@ struct RadFlowDecorr { continue; for (int k = 0; k < KIntK; ++k) { for (int m = 0; m < KIntM; ++m) { - sumPmwkTru[ieta][ipt][m][k] += std::pow(wi, k) * std::pow(pt, m); + sumPmwkTru[ieta][ipt][m][k] += std::pow(pt, m); } - sumWkTru[ieta][ipt][k] += std::pow(wi, k); + sumWkTru[ieta][ipt][k]++; } } } @@ -1522,9 +1514,9 @@ struct RadFlowDecorr { continue; for (int k = 0; k < KIntK; ++k) { for (int m = 0; m < KIntM; ++m) { - sumPmwkTruEt[ieta][ipt][m][k] += std::pow(wi, k) * std::pow(Et, m); + sumPmwkTruEt[ieta][ipt][m][k] += std::pow(Et, m); } - sumWkTruEt[ieta][ipt][k] += std::pow(wi, k); + sumWkTruEt[ieta][ipt][k]++; } } } @@ -1547,7 +1539,7 @@ struct RadFlowDecorr { if (!std::isfinite(wIncl) || wIncl <= 0.f) continue; if (effIncl <= 0 || !isfinite(effIncl) || !isfinite(fakeIncl) || !isfinite(flatWeightIncl)) -  continue; + continue; for (int ieta = 0; ieta < KNEta; ++ieta) { if (eta <= etaLw[ieta] || eta > etaUp[ieta]) @@ -1579,7 +1571,7 @@ struct RadFlowDecorr { float fakePid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 1); float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); float wPid = flatWeightPid * (1.0 - fakePid) / effPid; - if (effPid >= 1.f || fakePid >= 1.f || !isfinite(effPid) || effPid <= kFloatEpsilon || !isfinite(fakePid) || !isfinite(flatWeightPid)) + if (effPid >= 1.f || fakePid >= 1.f || !isfinite(effPid) || effPid <= KFloatEpsilon || !isfinite(fakePid) || !isfinite(flatWeightPid)) continue; for (int ieta = 0; ieta < KNEta; ++ieta) { @@ -1738,21 +1730,21 @@ struct RadFlowDecorr { // 1D Covariance (vs eta) for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { int ietaC = KNEta - ietaA; - float valy = kHalf * (etaLw[ietaC] + etaUp[ietaC]); + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); { const int ipt = 0; float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; if (std::isfinite(c2Sub)) { histos.fill(HIST("MCGen/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); histos.fill(HIST("MCGen/Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("MCGen/Prof_ipt0_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("MCGen/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); histos.fill(HIST("MCGen/Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("MCGen/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); } } @@ -1764,14 +1756,14 @@ struct RadFlowDecorr { if (std::isfinite(c2Sub)) { histos.fill(HIST("MCGen/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); histos.fill(HIST("MCGen/Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("MCGen/Prof_ipt0_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("MCGen/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); histos.fill(HIST("MCGen/Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("MCGen/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); } } @@ -1782,14 +1774,14 @@ struct RadFlowDecorr { if (std::isfinite(c2Sub)) { histos.fill(HIST("MCGen/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); histos.fill(HIST("MCGen/Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("MCGen/Prof_ipt2_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("MCGen/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); histos.fill(HIST("MCGen/Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("MCGen/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); } } @@ -1798,7 +1790,7 @@ struct RadFlowDecorr { for (int ietaA = 1; ietaA < KNEta; ++ietaA) { for (int ietaC = 1; ietaC < KNEta; ++ietaC) { float valx = 0.5f * (etaLw[ietaA] + etaUp[ietaA]); - float valy = kHalf * (etaLw[ietaC] + etaUp[ietaC]); + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); // ipt = 0 { const int ipt = 0; @@ -1835,7 +1827,7 @@ struct RadFlowDecorr { // --- MCReco Covariance (1D vs eta) --- for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { int ietaC = KNEta - ietaA; - float valy = kHalf * (etaLw[ietaC] + etaUp[ietaC]); // 0.5 for averaging + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); // 0.5 for averaging // ipt = 0 { @@ -1844,14 +1836,14 @@ struct RadFlowDecorr { if (std::isfinite(c2Sub)) { histos.fill(HIST("MCReco/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); histos.fill(HIST("MCReco/Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("MCReco/Prof_ipt0_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("MCReco/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); histos.fill(HIST("MCReco/Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("MCReco/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); } } @@ -1863,14 +1855,14 @@ struct RadFlowDecorr { if (std::isfinite(c2Sub)) { histos.fill(HIST("MCReco/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); histos.fill(HIST("MCReco/Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("MCReco/Prof_ipt1_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("MCReco/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); histos.fill(HIST("MCReco/Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("MCReco/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); } } @@ -1882,14 +1874,14 @@ struct RadFlowDecorr { if (std::isfinite(c2Sub)) { histos.fill(HIST("MCReco/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); histos.fill(HIST("MCReco/Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("MCReco/Prof_ipt2_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("MCReco/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); histos.fill(HIST("MCReco/Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("MCReco/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); } } @@ -1899,7 +1891,7 @@ struct RadFlowDecorr { for (int ietaA = 1; ietaA < KNEta; ++ietaA) { for (int ietaC = 1; ietaC < KNEta; ++ietaC) { float valx = 0.5f * (etaLw[ietaA] + etaUp[ietaA]); - float valy = kHalf * (etaLw[ietaC] + etaUp[ietaC]); + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); // ipt = 0 { @@ -1939,7 +1931,7 @@ struct RadFlowDecorr { // --- MCRecoEffCorr Covariance (1D vs eta) --- for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { int ietaC = KNEta - ietaA; - float valy = kHalf * (etaLw[ietaC] + etaUp[ietaC]); + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); // ipt = 0 { @@ -1948,14 +1940,14 @@ struct RadFlowDecorr { if (std::isfinite(c2Sub)) { histos.fill(HIST("MCRecoEffCorr/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("MCRecoEffCorr/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); } } @@ -1967,14 +1959,14 @@ struct RadFlowDecorr { if (std::isfinite(c2Sub)) { histos.fill(HIST("MCRecoEffCorr/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("MCRecoEffCorr/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); } } @@ -1986,14 +1978,14 @@ struct RadFlowDecorr { if (std::isfinite(c2Sub)) { histos.fill(HIST("MCRecoEffCorr/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("MCRecoEffCorr/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); } } @@ -2003,7 +1995,7 @@ struct RadFlowDecorr { for (int ietaA = 1; ietaA < KNEta; ++ietaA) { for (int ietaC = 1; ietaC < KNEta; ++ietaC) { float valx = 0.5f * (etaLw[ietaA] + etaUp[ietaA]); - float valy = kHalf * (etaLw[ietaC] + etaUp[ietaC]); + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); // ipt = 0 { @@ -2043,14 +2035,14 @@ struct RadFlowDecorr { } LOGF(info, "FINISHED RUNNING processMCFluc (pT + Et)"); } - PROCESS_SWITCH(RadFlowDecorr, processMCFluc, "process MC to calculate pt/Et fluc", cfgRunMCFluc); + PROCESS_SWITCH(RadialFlowDecorr, processMCFluc, "process MC to calculate pt/Et fluc", cfgRunMCFluc); void processGetFlat(AodCollisionsSel::iterator const& coll, aod::BCsWithTimestamps const&, AodTracksSel const& tracks) { if (!isEventSelected(coll)) return; float cent = getCentrality(coll); - if (cent < 0 || cent > 80) + if (cent > KCentMax) return; for (const auto& track : tracks) { if (!isTrackSelected(track)) @@ -2058,7 +2050,7 @@ struct RadFlowDecorr { float p = track.p(); // ADDED float eta = track.eta(); float phi = track.phi(); - if (p < kFloatEpsilon) + if (p < KFloatEpsilon) continue; histos.fill(HIST("hCentEtaPhi"), cent, eta, phi); const bool isPion = selectionPion(track); @@ -2069,7 +2061,7 @@ struct RadFlowDecorr { } } } - PROCESS_SWITCH(RadFlowDecorr, processGetFlat, "process real data to calculate mean pT and Et", cfgRunGetFlat); + PROCESS_SWITCH(RadialFlowDecorr, processGetFlat, "process real data to calculate mean pT and Et", cfgRunGetFlat); void processDataMean(AodCollisionsSel::iterator const& coll, aod::BCsWithTimestamps const&, AodTracksSel const& tracks) { @@ -2078,7 +2070,7 @@ struct RadFlowDecorr { if (!isEventSelected(coll)) return; float cent = getCentrality(coll); - if (cent < 0 || cent > 80) + if (cent > KCentMax) return; histos.fill(HIST("hZvtx_after_sel"), coll.posZ()); histos.fill(HIST("hCentrality"), cent); @@ -2093,7 +2085,7 @@ struct RadFlowDecorr { float eta = track.eta(); float p = track.p(); float phi = track.phi(); - if (p < kFloatEpsilon) + if (p < KFloatEpsilon) continue; histos.fill(HIST("hP"), p); histos.fill(HIST("hPt"), pt); @@ -2104,7 +2096,7 @@ struct RadFlowDecorr { float fakeIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 1); float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; - if (!std::isfinite(wIncl) || wIncl <= kFloatEpsilon || effIncl <= kFloatEpsilon) + if (!std::isfinite(wIncl) || wIncl <= KFloatEpsilon || effIncl <= KFloatEpsilon) continue; histos.fill(HIST("hCentEtaPhi"), cent, eta, track.phi()); @@ -2130,7 +2122,7 @@ struct RadFlowDecorr { float fakePid = getEfficiency(coll.multNTracksPV(), pt, eta, kCombinedPID, 1); float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); float wPid = flatWeightPid * (1.0 - fakePid) / effPid; - if (!std::isfinite(wPid) || wPid <= kFloatEpsilon || effPid <= kFloatEpsilon) + if (!std::isfinite(wPid) || wPid <= KFloatEpsilon || effPid <= KFloatEpsilon) continue; histos.fill(HIST("hCentEtaPhiWtd_PID"), cent, eta, track.phi(), flatWeightPid); @@ -2167,14 +2159,14 @@ struct RadFlowDecorr { } } } - PROCESS_SWITCH(RadFlowDecorr, processDataMean, "process real data to calculate mean pT and Et", cfgRunDataMean); + PROCESS_SWITCH(RadialFlowDecorr, processDataMean, "process real data to calculate mean pT and Et", cfgRunDataMean); void processDataFluc(AodCollisionsSel::iterator const& coll, aod::BCsWithTimestamps const&, AodTracksSel const& tracks) { if (!isEventSelected(coll)) return; float cent = getCentrality(coll); - if (cent < 0 || cent > 80) + if (cent > KCentMax) return; if (!pmeanNchEtabinPtbinStep2 || !pmeanEtNchEtabinPtbinStep2) { LOGF(warning, "Data fluc: Mean pT or Et map missing"); @@ -2201,7 +2193,7 @@ struct RadFlowDecorr { float eta = track.eta(); float p = track.p(); float phi = track.phi(); - if (p < kFloatEpsilon) + if (p < KFloatEpsilon) continue; float effIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 0); @@ -2209,7 +2201,7 @@ struct RadFlowDecorr { float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; - if (!std::isfinite(wIncl) || wIncl <= kFloatEpsilon || effIncl <= kFloatEpsilon) + if (!std::isfinite(wIncl) || wIncl <= KFloatEpsilon || effIncl <= KFloatEpsilon) continue; for (int ieta = 0; ieta < KNEta; ++ieta) { @@ -2235,7 +2227,7 @@ struct RadFlowDecorr { float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); float wPid = flatWeightPid * (1.0 - fakePid) / effPid; - if (!std::isfinite(wPid) || wPid <= kFloatEpsilon || effPid <= kFloatEpsilon) + if (!std::isfinite(wPid) || wPid <= KFloatEpsilon || effPid <= KFloatEpsilon) continue; float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus @@ -2304,20 +2296,20 @@ struct RadFlowDecorr { for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { int ietaC = KNEta - ietaA; - float valy = kHalf * (etaLw[ietaC] + etaUp[ietaC]); + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); { const int ipt = 0; float c2Sub = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; if (std::isfinite(c2Sub)) { histos.fill(HIST("Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("Prof_ipt0_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("Prof_ipt0_CovEt_Eta"), valy, c2SubEt); } } @@ -2327,13 +2319,13 @@ struct RadFlowDecorr { float c2Sub = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; if (std::isfinite(c2Sub)) { histos.fill(HIST("Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("Prof_ipt1_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("Prof_ipt1_CovEt_Eta"), valy, c2SubEt); } } @@ -2343,13 +2335,13 @@ struct RadFlowDecorr { float c2Sub = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; if (std::isfinite(c2Sub)) { histos.fill(HIST("Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("Prof_ipt2_Cov_Eta"), valy, c2Sub); } float c2SubEt = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; if (std::isfinite(c2SubEt)) { histos.fill(HIST("Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < kCentCovCut) + if (cent < KCentCovCut) histos.fill(HIST("Prof_ipt2_CovEt_Eta"), valy, c2SubEt); } } @@ -2358,7 +2350,7 @@ struct RadFlowDecorr { for (int ietaA = 1; ietaA < KNEta; ++ietaA) { for (int ietaC = 1; ietaC < KNEta; ++ietaC) { float valx = 0.5f * (etaLw[ietaA] + etaUp[ietaA]); - float valy = kHalf * (etaLw[ietaC] + etaUp[ietaC]); + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); { const int ipt = 0; float covpt = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; @@ -2394,11 +2386,11 @@ struct RadFlowDecorr { } } } - PROCESS_SWITCH(RadFlowDecorr, processDataFluc, "process real data to calculate fluc pT and Et", cfgRunDataFluc); + PROCESS_SWITCH(RadialFlowDecorr, processDataFluc, "process real data to calculate fluc pT and Et", cfgRunDataFluc); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; + WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; return workflow; } From 5b34c42117e47eed63407c4a6da14f70feea9d1b Mon Sep 17 00:00:00 2001 From: Somadutta Bhatta Date: Tue, 11 Nov 2025 21:20:51 +0100 Subject: [PATCH 06/10] Add CCDB-based map loading --- .../Tasks/radialFlowDecorr.cxx | 4216 ++++++++--------- 1 file changed, 2048 insertions(+), 2168 deletions(-) diff --git a/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx b/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx index 6ce71c39b80..7323496488c 100644 --- a/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx +++ b/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx @@ -18,7 +18,8 @@ #include "Common/DataModel/Centrality.h" #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" -#include "Common/DataModel/PIDResponse.h" +#include "Common/DataModel/PIDResponseTOF.h" +#include "Common/DataModel/PIDResponseTPC.h" #include "Common/DataModel/TrackSelectionTables.h" #include "CCDB/BasicCCDBManager.h" @@ -72,19 +73,19 @@ struct RadialFlowDecorr { static constexpr int KNEta = 17; static constexpr int KNpT = 3; - // --- Linter Fixes: Magic Numbers --- static constexpr float KFloatEpsilon = 1e-6f; - // static constexpr int KPiPlus = o2::constants::physics::Pdg::kPiPlus; - // static constexpr int KKPlus = o2::constants::physics::Pdg::kKaPlus; - // static constexpr int KProton = o2::constants::physics::Pdg::kProton; + static constexpr int KPiPlus = 211; + static constexpr int KKPlus = 321; + static constexpr int KProton = 2212; + static constexpr float KCentTestMin = 10.f; static constexpr float KCentTestMaxLo = 60.f; static constexpr float KCentTestMaxHi = 70.f; static constexpr float KCentCovCut = 1.0f; static constexpr float KBinOffset = 0.5f; static constexpr float KHalf = 0.5f; - static constexpr float KPhiMin = 0.f; // Added for magic number fix - // Histogram axis definitions + static constexpr float KPhiMin = 0.f; + static constexpr int KNbinsZvtx = 240; static constexpr float KZvtxMin = -12.f; static constexpr float KZvtxMax = 12.f; @@ -120,2277 +121,2156 @@ struct RadialFlowDecorr { static constexpr float KPtFullMax = 10.0f; static constexpr float KCentMax = 90; enum PID { kInclusive = 0, - kCombinedPID, - kNumPID }; - enum ECentralityEstimator { - kCentFT0C = 1, - kCentFT0A = 2, - kCentFT0M = 3, - kCentFV0A = 4 - }; - static constexpr float kInvalidCentrality = -1.0f; - const std::vector pidSuffix = {"", "_PID"}; - - const std::vector etaLw = { - -0.8, - -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7}; - const std::vector etaUp = { - 0.8, - -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8}; - - const std::vector pTLw = {KPtMinDefault, KPtMinDefault, KPtMinDefault}; - const std::vector pTUp = {KPtMidMax, KPtHighMax, KPtFullMax}; - //============================== - //  Configurables - //============================== - Configurable cfgVtxZCut{"cfgVtxZCut", 10.f, "z-vertex range"}; - Configurable cfgPtMin{"cfgPtMin", 0.2f, "min pT"}; - Configurable cfgPtMax{"cfgPtMax", 10.0f, "max pT"}; - Configurable cfgEtaCut{"cfgEtaCut", 0.8f, "|η| cut"}; - Configurable cfgDCAXY{"cfgDCAXY", 2.4f, "DCAxy cut"}; - Configurable cfgDCAZ{"cfgDCAZ", 3.2f, "DCAz cut"}; - Configurable cfgTPCClsMin{"cfgTPCClsMin", 70.f, "min TPC clusters"}; - Configurable cfgChi2TPCMax{"cfgChi2TPCMax", 4.0f, "max TPC χ²"}; - Configurable cfgPIDnSigmaCut{"cfgPIDnSigmaCut", 3.f, "TPC PID |nσ| cut"}; - - Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; - Configurable cfgCutTpcChi2NCl{"cfgCutTpcChi2NCl", 2.5f, "Maximum TPCchi2NCl"}; - Configurable cfgCutItsChi2NCl{"cfgCutItsChi2NCl", 36.0f, "Maximum ITSchi2NCl"}; - Configurable cfgCutTracKDcaMaxZ{"cfgCutTracKDcaMaxZ", 2.0f, "Maximum DcaZ"}; - Configurable cfgCutTracKDcaMaxXY{"cfgCutTracKDcaMaxXY", 0.2f, "Maximum DcaZ"}; - - Configurable cfgITScluster{"cfgITScluster", 1, "Minimum Number of ITS cluster"}; - Configurable cfgTPCcluster{"cfgTPCcluster", 80, "Minimum Number of TPC cluster"}; - Configurable cfgTPCnCrossedRows{"cfgTPCnCrossedRows", 70, "Minimum Number of TPC crossed-rows"}; - Configurable cfgCutPtUpperTPC{"cfgCutPtUpperTPC", 0.6f, "Upper pT cut for PID using TPC only"}; - Configurable cfgnSigmaOtherParticles{"cfgnSigmaOtherParticles", 3.0f, "PID nSigma cut to remove other particles (default:3)"}; - Configurable cfgnSigmaCutTPC{"cfgnSigmaCutTPC", 2.0f, "PID nSigma cut for TPC"}; - Configurable cfgnSigmaCutTOF{"cfgnSigmaCutTOF", 2.0f, "PID nSigma cut for TOF"}; - Configurable cfgnSigmaCutCombTPCTOF{"cfgnSigmaCutCombTPCTOF", 2.0f, "PID nSigma combined cut for TPC and TOF"}; - Configurable cfgCutPtLower{"cfgCutPtLower", 0.2f, "Lower pT cut"}; - Configurable cfgCutPtLowerProt{"cfgCutPtLowerProt", 0.2f, "Lower pT cut"}; - Configurable cfgCutPtUpper{"cfgCutPtUpper", 10.0f, "Higher pT cut for inclusive hadron analysis"}; - Configurable cfgCutPtUpperPID{"cfgCutPtUpperPID", 6.0f, "Higher pT cut for identified particle analysis"}; - Configurable cfgCutEta{"cfgCutEta", 0.8f, "absolute Eta cut"}; - Configurable cfgCutEtaLeft{"cfgCutEtaLeft", 0.8f, "Left end of eta gap"}; - Configurable cfgCutEtaRight{"cfgCutEtaRight", 0.8f, "Right end of eta gap"}; - Configurable cfgNSubsample{"cfgNSubsample", 10, "Number of subsamples"}; - Configurable cfgCentralityChoice{"cfgCentralityChoice", 1, "Which centrality estimator? 1-->FT0C, 2-->FT0A, 3-->FT0M, 4-->FV0A"}; - Configurable cfgEvSelkNoSameBunchPileup{"cfgEvSelkNoSameBunchPileup", true, "Pileup removal"}; - Configurable cfgUseGoodITSLayerAllCut{"cfgUseGoodITSLayerAllCut", true, "Remove time interval with dead ITS zone"}; - Configurable cfgEvSelkNoITSROFrameBorder{"cfgEvSelkNoITSROFrameBorder", true, "ITSROFrame border event selection cut"}; - Configurable cfgEvSelkNoTimeFrameBorder{"cfgEvSelkNoTimeFrameBorder", true, "TimeFrame border event selection cut"}; - - Service ccdb; - Service pdg; - HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - - std::array hEff{}; - std::array hFake{}; - std::array hWeightMap3D{}; // (cent, eta, phi) - - TProfile3D* pmeanTruNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanRecoNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanRecoMatchedNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanRecoEffcorrNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanRecoMatchedEffcorrNchEtabinPtbinStep2 = nullptr; - // --- Et Profiles --- - TProfile3D* pmeanEtTruNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanEtRecoNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanEtRecoMatchedNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanEtRecoEffcorrNchEtabinPtbinStep2 = nullptr; // This one was already here - TProfile3D* pmeanEtRecoMatchedEffcorrNchEtabinPtbinStep2 = nullptr; - // --- Data Profiles --- - TProfile3D* pmeanNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanEtNchEtabinPtbinStep2 = nullptr; - - template - bool isEventSelected(const T& col) - { - if (!col.sel8()) - return false; - if (std::abs(col.posZ()) > cfgCutVertex) - return false; - if (cfgEvSelkNoSameBunchPileup && !col.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) - return false; - if (cfgEvSelkNoITSROFrameBorder && !col.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) - return false; - if (cfgEvSelkNoTimeFrameBorder && !col.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) - return false; - return true; - } - - // Line 137 - template - bool isTrackSelected(const T& trk) - { - if (trk.sign() == 0) - return false; - if (!trk.has_collision()) - return false; - if (!trk.isPVContributor()) - return false; - if (!(trk.itsNCls() > cfgITScluster)) - return false; - if (!(trk.tpcNClsFound() >= cfgTPCcluster)) - return false; - if (!(trk.tpcNClsCrossedRows() >= cfgTPCnCrossedRows)) - return false; - - if (trk.pt() < cfgCutPtLower || trk.pt() > cfgCutPtUpper || std::abs(trk.eta()) > cfgCutEta) - return false; - if (std::abs(trk.dcaXY()) > cfgCutTracKDcaMaxXY || std::abs(trk.dcaZ()) > cfgCutTracKDcaMaxZ) - return false; - return true; - } - - template - bool isParticleSelected(const T& particle) - { - auto* pd = pdg->GetParticle(particle.pdgCode()); - if (!pd) - return false; - // if (dpt::isStrangeBaryonPDG(particle.pdgCode())) return false; - if (std::abs(pd->Charge()) == 0) - return false; - if (particle.pt() < cfgCutPtLower || particle.pt() > cfgCutPtUpper || std::abs(particle.eta()) > cfgCutEta) - return false; - if (std::abs(particle.vz()) > cfgCutVertex) - return false; - return true; - } - - // - // // Lines 153-155 - // template bool selectionPion (const T& trk) { return std::abs(trk.tpcNSigmaPi()) < cfgPIDnSigmaCut; } - // template bool selectionKaon (const T& trk) { return std::abs(trk.tpcNSigmaKa()) < cfgPIDnSigmaCut; } - // template bool selectionProton(const T& trk) { return std::abs(trk.tpcNSigmaPr()) < cfgPIDnSigmaCut; } - //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - template - bool selectionProton(const T& candidate) - { - if (!candidate.hasTPC()) - return false; - int flag = 0; //! pid check main flag - - if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { - if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC) { - flag = 1; - } - if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaPr()) < cfgnSigmaCutTOF) { - flag = 1; - } - } - if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { - float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); - float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); - float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); - - int flag2 = 0; - if (combNSigmaPr < cfgnSigmaOtherParticles) - flag2 += 1; - if (combNSigmaPi < cfgnSigmaOtherParticles) - flag2 += 1; - if (combNSigmaKa < cfgnSigmaOtherParticles) - flag2 += 1; - if (!(flag2 > 1) && !(combNSigmaPr > combNSigmaPi) && !(combNSigmaPr > combNSigmaKa)) { - if (combNSigmaPr < cfgnSigmaCutCombTPCTOF) { - flag = 1; - } - } - } - if (flag == 1) - return true; - else - return false; - } - - template - bool selectionPion(const T& candidate) - { - if (!candidate.hasTPC()) - return false; - int flag = 0; //! pid check main flag - - if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { - if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < cfgnSigmaCutTPC) { - flag = 1; - } - if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaPi()) < cfgnSigmaCutTOF) { - flag = 1; - } - } - if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { - float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); - float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); - float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); - - int flag2 = 0; - if (combNSigmaPr < cfgnSigmaOtherParticles) - flag2 += 1; - if (combNSigmaPi < cfgnSigmaOtherParticles) - flag2 += 1; - if (combNSigmaKa < cfgnSigmaOtherParticles) - flag2 += 1; - if (!(flag2 > 1) && !(combNSigmaPi > combNSigmaPr) && !(combNSigmaPi > combNSigmaKa)) { - if (combNSigmaPi < cfgnSigmaCutCombTPCTOF) { - flag = 1; + kCombinedPID, + kNumPID }; + enum ECentralityEstimator { + kCentFT0C = 1, + kCentFT0A = 2, + kCentFT0M = 3, + kCentFV0A = 4 + }; + static constexpr float KinvalidCentrality = -1.0f; + const std::vector pidSuffix = {"", "_PID"}; + + const std::vector etaLw = { + -0.8, + -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7}; + const std::vector etaUp = { + 0.8, + -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8}; + + const std::vector pTLw = {KPtMinDefault, KPtMinDefault, KPtMinDefault}; + const std::vector pTUp = {KPtMidMax, KPtHighMax, KPtFullMax}; + + Configurable cfgVtxZCut{"cfgVtxZCut", 10.f, "z-vertex range"}; + Configurable cfgPtMin{"cfgPtMin", 0.2f, "min pT"}; + Configurable cfgPtMax{"cfgPtMax", 10.0f, "max pT"}; + Configurable cfgEtaCut{"cfgEtaCut", 0.8f, "|η| cut"}; + Configurable cfgDCAXY{"cfgDCAXY", 2.4f, "DCAxy cut"}; + Configurable cfgDCAZ{"cfgDCAZ", 3.2f, "DCAz cut"}; + Configurable cfgTPCClsMin{"cfgTPCClsMin", 70.f, "min TPC clusters"}; + Configurable cfgChi2TPCMax{"cfgChi2TPCMax", 4.0f, "max TPC χ²"}; + Configurable cfgPIDnSigmaCut{"cfgPIDnSigmaCut", 3.f, "TPC PID |nσ| cut"}; + + Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; + Configurable cfgCutTpcChi2NCl{"cfgCutTpcChi2NCl", 2.5f, "Maximum TPCchi2NCl"}; + Configurable cfgCutItsChi2NCl{"cfgCutItsChi2NCl", 36.0f, "Maximum ITSchi2NCl"}; + Configurable cfgCutTracKDcaMaxZ{"cfgCutTracKDcaMaxZ", 2.0f, "Maximum DcaZ"}; + Configurable cfgCutTracKDcaMaxXY{"cfgCutTracKDcaMaxXY", 0.2f, "Maximum DcaZ"}; + + Configurable cfgITScluster{"cfgITScluster", 1, "Minimum Number of ITS cluster"}; + Configurable cfgTPCcluster{"cfgTPCcluster", 80, "Minimum Number of TPC cluster"}; + Configurable cfgTPCnCrossedRows{"cfgTPCnCrossedRows", 70, "Minimum Number of TPC crossed-rows"}; + Configurable cfgCutPtUpperTPC{"cfgCutPtUpperTPC", 0.6f, "Upper pT cut for PID using TPC only"}; + Configurable cfgnSigmaOtherParticles{"cfgnSigmaOtherParticles", 3.0f, "PID nSigma cut to remove other particles (default:3)"}; + Configurable cfgnSigmaCutTPC{"cfgnSigmaCutTPC", 2.0f, "PID nSigma cut for TPC"}; + Configurable cfgnSigmaCutTOF{"cfgnSigmaCutTOF", 2.0f, "PID nSigma cut for TOF"}; + Configurable cfgnSigmaCutCombTPCTOF{"cfgnSigmaCutCombTPCTOF", 2.0f, "PID nSigma combined cut for TPC and TOF"}; + Configurable cfgCutPtLower{"cfgCutPtLower", 0.2f, "Lower pT cut"}; + Configurable cfgCutPtLowerProt{"cfgCutPtLowerProt", 0.2f, "Lower pT cut"}; + Configurable cfgCutPtUpper{"cfgCutPtUpper", 10.0f, "Higher pT cut for inclusive hadron analysis"}; + Configurable cfgCutPtUpperPID{"cfgCutPtUpperPID", 6.0f, "Higher pT cut for identified particle analysis"}; + Configurable cfgCutEta{"cfgCutEta", 0.8f, "absolute Eta cut"}; + Configurable cfgCutEtaLeft{"cfgCutEtaLeft", 0.8f, "Left end of eta gap"}; + Configurable cfgCutEtaRight{"cfgCutEtaRight", 0.8f, "Right end of eta gap"}; + Configurable cfgNSubsample{"cfgNSubsample", 10, "Number of subsamples"}; + Configurable cfgCentralityChoice{"cfgCentralityChoice", 1, "Which centrality estimator? 1-->FT0C, 2-->FT0A, 3-->FT0M, 4-->FV0A"}; + Configurable cfgEvSelkNoSameBunchPileup{"cfgEvSelkNoSameBunchPileup", true, "Pileup removal"}; + Configurable cfgUseGoodITSLayerAllCut{"cfgUseGoodITSLayerAllCut", true, "Remove time interval with dead ITS zone"}; + Configurable cfgEvSelkNoITSROFrameBorder{"cfgEvSelkNoITSROFrameBorder", true, "ITSROFrame border event selection cut"}; + Configurable cfgEvSelkNoTimeFrameBorder{"cfgEvSelkNoTimeFrameBorder", true, "TimeFrame border event selection cut"}; + + Service ccdb; + Service pdg; + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + std::array hEff{}; + std::array hFake{}; + std::array hWeightMap3D{}; + + TProfile3D* pmeanTruNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanRecoNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanRecoMatchedNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanRecoEffcorrNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanRecoMatchedEffcorrNchEtabinPtbinStep2 = nullptr; + + TProfile3D* pmeanEtTruNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanEtRecoNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanEtRecoMatchedNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanEtRecoEffcorrNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanEtRecoMatchedEffcorrNchEtabinPtbinStep2 = nullptr; + + TProfile3D* pmeanNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanEtNchEtabinPtbinStep2 = nullptr; + + template + bool isEventSelected(const T& col) + { + if (!col.sel8()) + return false; + if (std::abs(col.posZ()) > cfgCutVertex) + return false; + if (cfgEvSelkNoSameBunchPileup && !col.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) + return false; + if (cfgEvSelkNoITSROFrameBorder && !col.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) + return false; + if (cfgEvSelkNoTimeFrameBorder && !col.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) + return false; + return true; } - } - } - if (flag == 1) - return true; - else - return false; - } - - template - bool selectionKaon(const T& candidate) - { - if (!candidate.hasTPC()) - return false; - int flag = 0; //! pid check main flag - - if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { - if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < cfgnSigmaCutTPC) { - flag = 1; - } - if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaKa()) < cfgnSigmaCutTOF) { - flag = 1; - } - } - if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { - float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); - float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); - float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); - - int flag2 = 0; - if (combNSigmaPr < cfgnSigmaOtherParticles) - flag2 += 1; - if (combNSigmaPi < cfgnSigmaOtherParticles) - flag2 += 1; - if (combNSigmaKa < cfgnSigmaOtherParticles) - flag2 += 1; - if (!(flag2 > 1) && !(combNSigmaKa > combNSigmaPi) && !(combNSigmaKa > combNSigmaPr)) { - if (combNSigmaKa < cfgnSigmaCutCombTPCTOF) { - flag = 1; + + template + bool isTrackSelected(const T& trk) + { + if (trk.sign() == 0) + return false; + if (!trk.has_collision()) + return false; + if (!trk.isPVContributor()) + return false; + if (!(trk.itsNCls() > cfgITScluster)) + return false; + if (!(trk.tpcNClsFound() >= cfgTPCcluster)) + return false; + if (!(trk.tpcNClsCrossedRows() >= cfgTPCnCrossedRows)) + return false; + + if (trk.pt() < cfgCutPtLower || trk.pt() > cfgCutPtUpper || std::abs(trk.eta()) > cfgCutEta) + return false; + if (std::abs(trk.dcaXY()) > cfgCutTracKDcaMaxXY || std::abs(trk.dcaZ()) > cfgCutTracKDcaMaxZ) + return false; + return true; } - } - } - if (flag == 1) - return true; - else - return false; - } - - float getCentrality(const auto& col) const - { - if (cfgCentralityChoice.value == kCentFT0C) - return col.centFT0C(); - if (cfgCentralityChoice.value == kCentFT0A) - return col.centFT0A(); - if (cfgCentralityChoice.value == kCentFT0M) - return col.centFT0M(); - if (cfgCentralityChoice.value == kCentFV0A) - return col.centFV0A(); - return kInvalidCentrality; - } - - float getEfficiency(float mult, float pt, float eta, PID pidType, int effidx) const - { - TH3F* h; - if (effidx == 0) - h = hEff[pidType]; - if (effidx == 1) - h = hFake[pidType]; - - if (!h) - return -1; - const int ibx = h->GetXaxis()->FindBin(mult); - const int iby = h->GetYaxis()->FindBin(pt); - const int ibz = h->GetZaxis()->FindBin(eta); - float val = h->GetBinContent(ibx, iby, ibz); - return val; - } - - float getFlatteningWeight(float cent, float eta, float phi, PID pidType) const - { - TH3F* h = hWeightMap3D[pidType]; - if (!h) - return -1; - const int ibx = h->GetXaxis()->FindBin(cent); - const int iby = h->GetYaxis()->FindBin(eta); - const int ibz = h->GetZaxis()->FindBin(phi); - float val = h->GetBinContent(ibx, iby, ibz); - return val; - } - - template - std::pair calculateMeanAndC2FromSums(const double sumpmwk[KIntM][KIntK], const double sumwk[KIntK], float referenceMeanPt) const - { - // --- Safety Checks --- - if (sumwk[1] == 0.) { - return {0.f, 0.f}; - } - - double tau1 = sumwk[2] / (sumwk[1] * sumwk[1]); - double denom2 = 1. - tau1; - - if (std::abs(denom2) < KFloatEpsilon) { - double pmk11_safe = sumpmwk[1][1] / sumwk[1]; - return {static_cast(pmk11_safe), 0.f}; - } - - // --- Calculations --- - double pmk11 = sumpmwk[1][1] / sumwk[1]; - - double pmk12 = 0.; - if (sumwk[2] != 0.) { - pmk12 = sumpmwk[1][2] / sumwk[2]; - } - - double pmk22 = 0.; - if (sumwk[2] != 0.) { - pmk22 = sumpmwk[2][2] / sumwk[2]; - } - - float calculatedMeanPt = pmk11; // Mean pT is / - - double p1kBar1 = pmk11 - referenceMeanPt; - double p2kBar2 = pmk22 - 2. * pmk12 * referenceMeanPt + referenceMeanPt * referenceMeanPt; - - double p1kBar1_sq = p1kBar1 * p1kBar1; - double numerator2 = p1kBar1_sq - (tau1 * p2kBar2); - - float C2 = numerator2 / denom2; - return {calculatedMeanPt, C2}; - } - - ConfigurableAxis cfgAxisCent{"cfgAxisCent", {0.0, 1.0, 3.0, 5.0, 10, 20, 30, 40, 50, 60, 70, 80, 100}, "centrality axis (percentile)"}; // FT0*/FV0A style - const AxisSpec centAxis{cfgAxisCent, "Centrality (%)"}; - static constexpr int KNbinsNch = 5000; - static constexpr float KNchMin = 0.5f; - static constexpr float KNchMax = 5000.5f; - static constexpr int KNbinsNchCoarse = 500; - static constexpr float KNchCoarseMax = 5000.5f; - ConfigurableAxis nChAxis{"nChAxis", {KNbinsNch, KNchMin, KNchMax}, "PV-contributor track multiplicity axis"}; - ConfigurableAxis nChAxis2{"nChAxis2", {KNbinsNchCoarse, KNchMin, KNchCoarseMax}, "PV-contributor track multiplicity axis"}; - - // run switches - Configurable cfgRunGetEff{"cfgRunGetEff", false, "Run MC pass to build efficiency/fake maps"}; - Configurable cfgRunMCMean{"cfgRunMCMean", false, "Run MC mean(pT) & mean(Et)"}; - Configurable cfgRunMCFluc{"cfgRunMCFluc", false, "Run MC fluctuations (C2, subevent)"}; - Configurable cfgRunGetFlat{"cfgRunGetFlat", false, "Run Data Get Flattening Weights"}; - Configurable cfgRunDataMean{"cfgRunDataMean", false, "Run DATA mean(pT) & mean(Et)"}; - Configurable cfgRunDataFluc{"cfgRunDataFluc", false, "Run DATA fluctuations (C2, subevent)"}; - // --- DATA: collisions with centralities and selections --- - using GeneralCollisions = soa::Join< - aod::Collisions, - aod::EvSels, - aod::Mults, - aod::CentFT0As, aod::CentFT0Cs, aod::CentFT0Ms, aod::CentFV0As, - aod::CentNGlobals>; - Filter collisionFilter = nabs(aod::collision::posZ) < cfgVtxZCut; - using AodCollisionsSel = soa::Filtered; - - using UnfilteredTracks = soa::Join< - aod::Tracks, - aod::TracksExtra, - aod::TrackSelection, - aod::TracksDCA, - aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, - aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr>; - Filter trackFilter = nabs(aod::track::eta) < cfgEtaCut && - aod::track::pt > cfgPtMin&& - aod::track::pt < cfgPtMax&& - nabs(aod::track::dcaXY) < cfgDCAXY&& nabs(aod::track::dcaZ) < cfgDCAZ; - using AodTracksSel = soa::Filtered; - // --- MC: reconstructed tracks with truth labels --- - using TCs = soa::Join; - using FilteredTCs = soa::Filtered; - // --- MC: collisions with labels --- - using MyRun3MCCollisions = soa::Join< - aod::Collisions, aod::EvSels, aod::Mults, aod::MultsExtra, - aod::CentFT0As, aod::CentFT0Cs, aod::CentFT0Ms, aod::CentFV0As, - aod::CentNGlobals, aod::McCollisionLabels>; - // --- MC: truth-matched tracks --- - using MyMCTracks = soa::Join< - aod::Tracks, aod::TrackSelection, aod::TracksExtra, aod::TracksDCA, - aod::McTrackLabels, - aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, - aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr>; - // --- Preslices (consistent policies) --- - PresliceUnsorted partPerMcCollision = aod::mcparticle::mcCollisionId; - PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; - PresliceUnsorted trackPerMcParticle = aod::mctracklabel::mcParticleId; - Preslice perCollision = aod::track::collisionId; - Preslice trackPerCollision = aod::track::collisionId; - - void declareCommonQA() - { - histos.add("hZvtx_after_sel", ";z_{vtx} (cm)", kTH1F, {{KNbinsZvtx, KZvtxMin, KZvtxMax}}); - histos.add("hVtxZ", ";z_{vtx} (cm)", kTH1F, {{KNbinsZvtx, KZvtxMin, KZvtxMax}}); - histos.add("hCentrality", ";centrality (%)", kTH1F, {{centAxis}}); - histos.add("Hist2D_globalTracks_PVTracks", ";N_{global};N_{PV}", kTH2F, {{nChAxis2}, {nChAxis2}}); - histos.add("Hist2D_cent_nch", ";N_{PV};cent (%)", kTH2F, {{nChAxis2}, {centAxis}}); - histos.add("hP", ";p (GeV/c)", kTH1F, {{KNbinsP, KPMin, KPMax}}); - histos.add("hPt", ";p_{T} (GeV/c)", kTH1F, {{KNbinsPt, KPtMin, KPtMax}}); - histos.add("hEta", ";#eta", kTH1F, {{KNbinsEta, KEtaMin, KEtaMax}}); - histos.add("hPhi", ";#phi", kTH1F, {{KNbinsPhi, KPhiMin, TwoPI}}); - - histos.add("hCentEtaPhi", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - histos.add("hCent1EtaPhi", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - histos.add("hCent7EtaPhi", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - histos.add("hCentEtaPhiWtd", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - histos.add("hCent1EtaPhiWtd", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - histos.add("hCent7EtaPhiWtd", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - - histos.add("hCentEtaPhiWtd_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - histos.add("hCent1EtaPhiWtd_PID", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - histos.add("hCent7EtaPhiWtd_PID", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - - histos.add("hCentEtaPhiTrue", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - histos.add("hCentEtaPhiReco", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - histos.add("hCentEtaPhiRecoMatched", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - - histos.add("hCentEtaPhiTrue_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - histos.add("hCentEtaPhiReco_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - histos.add("hCentEtaPhiRecoMatched_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - } - void declareMCCommonHists() - { - - histos.add("ptResolution", ";p_{T}^{MC};p_{T}^{MC}-p_{T}^{reco}", kTH2F, {{KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsPtRes, -KPtResMax, KPtResMax}}); - histos.add("ptTruthReco", ";p_{T}^{MC};p_{T}^{reco}", kTH2F, {{KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsPtRes, cfgPtMin, cfgPtMax}}); - histos.add("etaResolution", ";#eta^{MC};#eta^{MC}-#eta^{reco}", kTH2F, {{KNbinsEtaRes, -KEtaFineMax, KEtaFineMax}, {KNbinsPtRes, -KEtaResMax, KEtaResMax}}); - histos.add("etaTruthReco", ";#eta^{MC};#eta^{reco}", kTH2F, {{KNbinsPtRes, -KEtaFineMax, KEtaFineMax}, {KNbinsPtRes, -KEtaFineMax, KEtaFineMax}}); - - histos.add("TruthTracKVz", ";Vz^{MC};Vz^{Reco}", kTH2F, {{KNbinsVz, KVzMin, KVzMax}, {KNbinsVz, KVzMin, KVzMax}}); - histos.add("vzResolution", ";Vz^{MC};Vz^{MC}-Vz^{Reco}", kTH2F, {{KNbinsVz, KVzMin, KVzMax}, {KNbinsVz, -KVzResMax, KVzResMax}}); - - histos.add("h3_AllPrimary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - histos.add("h3_RecoMatchedToPrimary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - histos.add("h3_RecoUnMatchedToPrimary_Secondary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - histos.add("h3_RecoUnMatchedToPrimary_Fake", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - histos.add("h3_AllReco", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - - histos.add("h3_AllPrimary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - histos.add("h3_RecoMatchedToPrimary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - histos.add("h3_RecoUnMatchedToPrimary_Secondary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - histos.add("h3_RecoUnMatchedToPrimary_Fake_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - histos.add("h3_AllReco_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - - histos.add("h_AllPrimary", ";p_{T}", kTH1F, {{KNbinsP, cfgPtMin, cfgPtMax}}); - histos.add("h_RecoMatchedToPrimary", ";p_{T}", kTH1F, {{KNbinsPt, KPtMin, KPtMax}}); - histos.add("h_RecoUnMatchedToPrimary", ";p_{T}", kTH1F, {{KNbinsPt, KPtMin, KPtMax}}); - histos.add("h_AllReco", ";p_{T}", kTH1F, {{KNbinsPt, KPtMin, KPtMax}}); - - histos.add("hReco_ParticleWeight", ";cent;p_{T};#eta", kTH3F, {{centAxis}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsPtRes, -KEtaFineMax, KEtaFineMax}}); - histos.add("hTruth_ParticleWeight", ";cent;p_{T};#eta", kTH3F, {{centAxis}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsPtRes, -KEtaFineMax, KEtaFineMax}}); - - histos.add("hDCAxy_Unmatched", ";DCA_{xy} (cm)", kTH1F, {{KNbinsDca, -KDcaMax, KDcaMax}}); - histos.add("hDCAz_Unmatched", ";DCA_{z} (cm)", kTH1F, {{KNbinsDca, -KDcaMax, KDcaMax}}); - histos.add("hDCAxy_NotPrimary", ";DCA_{xy} (cm)", kTH1F, {{KNbinsDca, -KDcaMax, KDcaMax}}); - histos.add("hDCAz_NotPrimary", ";DCA_{z} (cm)", kTH1F, {{KNbinsDca, -KDcaMax, KDcaMax}}); - } - - void declareMCMeanHists() - { - // Eff/Fake and weights vs observables - histos.add("Eff_cent", ";cent;#epsilon", kTProfile, {centAxis}); - histos.add("Fake_cent", ";cent;f_{fake}", kTProfile, {centAxis}); - histos.add("wgt_cent", ";cent;w", kTProfile, {centAxis}); - histos.add("Eff_Ntrk", ";N_{PV};#epsilon", kTProfile, {nChAxis2}); - histos.add("Fake_Ntrk", ";N_{PV};f_{fake}", kTProfile, {nChAxis2}); - histos.add("wgt_Ntrk", ";N_{PV};w", kTProfile, {nChAxis2}); - histos.add("Eff_pT", ";p_{T};#epsilon", kTProfile, {{KNbinsPtRes, cfgPtMin, cfgPtMax}}); - histos.add("Fake_pT", ";p_{T};f_{fake}", kTProfile, {{KNbinsPtRes, cfgPtMin, cfgPtMax}}); - histos.add("wgt_pT", ";p_{T};w", kTProfile, {{KNbinsPtRes, KPtMin, KPtMax}}); - histos.add("Eff_eta", ";#eta;#epsilon", kTProfile, {{KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - histos.add("Fake_eta", ";#eta;f_{fake}", kTProfile, {{KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - histos.add("wgt_eta", ";#eta;w", kTProfile, {{KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - // MC mean profiles (pT & Et) for various selections - histos.add("MCGen/Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); - histos.add("MCGen/Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); - histos.add("MCGen/Prof_MeanpT_Mult", ";N_{PV};#LT p_{T}#GT", kTProfile, {nChAxis}); - histos.add("pmeanTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); - histos.add("pmeanRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); - histos.add("pmeanRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); - histos.add("pmeanRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); - histos.add("pmeanRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); - // Et versions - histos.add("MCGen/Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); - histos.add("MCGen/Prof_MeanEt_Mult", ";N_{PV};#LT E_{T}#GT", kTProfile, {nChAxis}); - histos.add("pmeanEtTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); - histos.add("pmeanEtRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); - histos.add("pmeanEtRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); - histos.add("pmeanEtRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); - histos.add("pmeanEtRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -0.5, KNEta + 0.5}, {KNpT + 1, -0.5, KNpT + 0.5}}); - // Clone sets for Reco/Matched/EffCorr variants - - histos.addClone("MCGen/", "MCReco/"); - histos.addClone("MCGen/", "MCRecoMatched/"); - histos.addClone("MCGen/", "MCRecoEffCorr/"); - histos.addClone("MCGen/", "MCRecoMatchedEffCorr/"); - } - void declareMCFlucHists() - { - static constexpr int KNbinsNchFluc = 1000; - // pT cumulants - histos.add("MCGen/Prof_C2_Cent", ";cent;C_{2}", kTProfile, {centAxis}); - histos.add("MCGen/Prof_C2_Mult", ";N_{PV};C_{2}", kTProfile, {nChAxis}); - histos.add("MCGen/Prof_C2Sub_Mult_etabin_ptbin", - ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, - {{KNbinsNchFluc, KNchMin, KNchCoarseMax}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("MCGen/Prof_ipt0_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt0_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt0_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - histos.add("MCGen/Prof_C2Et_Cent", ";cent;C_{2}^{E_{T}}", kTProfile, {centAxis}); - histos.add("MCGen/Prof_C2Et_Mult", ";N_{PV};C_{2}^{E_{T}}", kTProfile, {nChAxis}); - histos.add("MCGen/Prof_C2EtSub_Mult_etabin_ptbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, - {{KNbinsNchFluc, KNchMin, KNchCoarseMax}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("MCGen/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt0_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt0_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - - histos.add("MCGen/Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); - histos.add("MCGen/Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); - histos.add("MCGen/Prof_MeanpT_Mult", ";N_{PV};#LT p_{T}#GT", kTProfile, {nChAxis}); - - histos.add("pmeanTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - - histos.add("MCGen/Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); - histos.add("MCGen/Prof_MeanEt_Mult", ";N_{PV};#LT E_{T}#GT", kTProfile, {nChAxis}); - histos.add("pmeanEtTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanEtRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanEtRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanEtRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanEtRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - } - void declareDataMeanHists() - { - histos.add("Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); - histos.add("Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); - histos.add("pmean_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - // Et - histos.add("Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); - histos.add("pmeanEt_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - } - - void declareDataGetFlatHists() - { - histos.add("hCentEtaPhi_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, 0, TwoPI}}); - } - - void declareDataFlucHists() - { - histos.add("pmean_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); - histos.add("pmeanEt_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - - histos.add("Prof_C2_Cent", ";cent;C_{2}", kTProfile, {centAxis}); - histos.add("Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); - histos.add("Prof_MeanpT_Mult", ";N_{PV};#LT p_{T}#GT", kTProfile, {nChAxis}); - histos.add("Prof_C2_Mult_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - - histos.add("Prof_ipt0_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("Prof_ipt0_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - histos.add("Prof_ipt1_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("Prof_ipt1_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - histos.add("Prof_ipt2_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("Prof_ipt2_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - - histos.add("Prof_C2Et_Cent", ";cent;C_{2}^{E_{T}}", kTProfile, {centAxis}); - histos.add("Prof_MeanEt_Mult", ";N_{PV};#LT E_{T}#GT", kTProfile, {nChAxis}); - histos.add("Prof_C2Et_Mult_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - - histos.add("Prof_ipt0_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("Prof_ipt0_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - histos.add("Prof_ipt1_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("Prof_ipt1_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - histos.add("Prof_ipt2_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("Prof_ipt2_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - - histos.add("Prof_ipt0_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - histos.add("Prof_ipt1_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - histos.add("Prof_ipt2_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - histos.add("Prof_ipt0_C2SubEt2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - histos.add("Prof_ipt1_C2SubEt2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - histos.add("Prof_ipt2_C2SubEt2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - } - - TH3F* buildWeightMapFromRaw(TH3F* hRaw, const char* mapName) - { - if (!hRaw) { - LOGF(error, "Raw eta-phi map for '%s' is null; no flattening will be applied.", mapName); - return nullptr; - } - auto hWeightMap = reinterpret_cast(hRaw->Clone(mapName)); - hWeightMap->SetTitle(Form("Flattening Weight Map %s (w_{#phi} = / N_{#phi})", mapName)); - hWeightMap->SetDirectory(nullptr); - hWeightMap->Reset(); - auto axC = hRaw->GetXaxis(); - auto axE = hRaw->GetYaxis(); - auto axP = hRaw->GetZaxis(); - for (int ic = 1; ic <= axC->GetNbins(); ++ic) { - for (int ie = 1; ie <= axE->GetNbins(); ++ie) { - // average over phi at fixed (cent,eta) - double sum = 0.0; - int nphi = axP->GetNbins(); - for (int ip = 1; ip <= nphi; ++ip) - sum += hRaw->GetBinContent(ic, ie, ip); - const double avg = (nphi > 0 ? sum / nphi : 0.0); - for (int ip = 1; ip <= nphi; ++ip) { - const double raw = hRaw->GetBinContent(ic, ie, ip); - const double w = (avg > 0.0 && raw > 0.0) ? (avg / raw) : 1.0; - hWeightMap->SetBinContent(ic, ie, ip, w); + + template + bool isParticleSelected(const T& particle) + { + auto* pd = pdg->GetParticle(particle.pdgCode()); + if (!pd) + return false; + // if (dpt::isStrangeBaryonPDG(particle.pdgCode())) return false; + if (std::abs(pd->Charge()) == 0) + return false; + if (particle.pt() < cfgCutPtLower || particle.pt() > cfgCutPtUpper || std::abs(particle.eta()) > cfgCutEta) + return false; + if (std::abs(particle.vz()) > cfgCutVertex) + return false; + return true; } - } - } - LOGF(info, "Flattening weight map '%s' built.", mapName); - return hWeightMap; - } - - void init(InitContext&) - { - // CCDB - ccdb->setURL("http://alice-ccdb.cern.ch"); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - int64_t nowMs = std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()) - .count(); - ccdb->setCreatedNotAfter(nowMs); - // Always-on common QA - declareCommonQA(); - // Conditionally declare sets - if (cfgRunMCMean || cfgRunMCFluc || cfgRunGetEff) { - declareMCCommonHists(); - } - if (cfgRunMCMean) { - declareMCMeanHists(); - } - if (cfgRunMCFluc) { - declareMCFlucHists(); - - histos.addClone("MCGen/", "MCReco/"); - histos.addClone("MCGen/", "MCRecoMatched/"); - histos.addClone("MCGen/", "MCRecoEffCorr/"); - histos.addClone("MCGen/", "MCRecoMatchedEffCorr/"); - } - if (cfgRunGetFlat) { - declareDataGetFlatHists(); - } - if (cfgRunDataMean) { - declareDataMeanHists(); - } - if (cfgRunDataFluc) { - declareDataFlucHists(); - } - - //======================== - // Load correction maps - //======================== - const bool needEffMaps = cfgRunMCMean || cfgRunMCFluc || cfgRunDataMean || cfgRunDataFluc; - if (needEffMaps && !cfgRunGetEff) { - - // --- 1. Load Efficiency and Fake maps (always from MC file) --- - if (auto* f = TFile::Open("Job1_EffMaps.root", "READ")) { - if (!f->IsZombie()) { - if (auto* dir = dynamic_cast(f->Get("rad-flow-decorr"))) { - // Helper lambda to load Eff/Fake maps for a given PID type - auto loadEffFakeForPID = [&](PID pidType) { - std::string suffix = pidSuffix[pidType]; - std::string hEffNumName = "h3_RecoMatchedToPrimary" + suffix; - std::string hEffDenName = "h3_AllPrimary" + suffix; - std::string hFakeNumSecName = "h3_RecoUnMatchedToPrimary_Secondary" + suffix; - std::string hFakeNumFakName = "h3_RecoUnMatchedToPrimary_Fake" + suffix; - std::string hFakeDenName = "h3_AllReco" + suffix; - - // --- Efficiency --- - if (auto* hNum = dynamic_cast(dir->Get(hEffNumName.c_str()))) { - hEff[pidType] = reinterpret_cast(hNum->Clone(Form("hEff%s", suffix.c_str()))); - hEff[pidType]->SetDirectory(nullptr); - if (auto* hDen = dynamic_cast(dir->Get(hEffDenName.c_str()))) { - hDen->SetDirectory(nullptr); - hEff[pidType]->Divide(hDen); - delete hDen; - } else { - LOGF(error, "Missing denominator %s for efficiency.", hEffDenName.c_str()); - } - } else { - LOGF(error, "Missing numerator %s for efficiency.", hEffNumName.c_str()); - } - // --- Fakes --- - if (auto* hNumS = dynamic_cast(dir->Get(hFakeNumSecName.c_str()))) { - auto* hNumF = dynamic_cast(dir->Get(hFakeNumFakName.c_str())); - if (hNumS && hNumF) { - hFake[pidType] = reinterpret_cast(hNumS->Clone(Form("hFake%s", suffix.c_str()))); - hFake[pidType]->Add(hNumF); - hFake[pidType]->SetDirectory(nullptr); - if (auto* hDenF = dynamic_cast(dir->Get(hFakeDenName.c_str()))) { - hDenF->SetDirectory(nullptr); - hFake[pidType]->Divide(hDenF); - delete hDenF; - } else { - LOGF(error, "Missing denominator %s for fakes.", hFakeDenName.c_str()); - } - } else { - LOGF(error, "Missing fake numerator(s) for %s in EffMaps file.", suffix.c_str()); - } - } - }; - // Load Eff/Fake maps for both Inclusive and CombinedPID - loadEffFakeForPID(kInclusive); - loadEffFakeForPID(kCombinedPID); - } else { - LOGF(error, "Directory 'rad-flow-decorr' not found in Job1_EffMaps.root"); + + template + bool selectionProton(const T& candidate) + { + if (!candidate.hasTPC()) + return false; + int flag = 0; + + if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC) { + flag = 1; + } + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaPr()) < cfgnSigmaCutTOF) { + flag = 1; + } } - } else { - LOGF(error, "Job1_EffMaps.root is a zombie."); - } - f->Close(); - delete f; - } else { - LOGF(error, "Cannot open Job1_EffMaps.root for Eff/Fake maps"); - } - - // --- 2. Load Flattening maps (source depends on run mode) --- - const bool isDataRun = cfgRunDataMean || cfgRunDataFluc; - if (isDataRun) { - // Load from Data flattening file (produced by processGetFlat) - LOGF(info, "Data Run: Loading flattening maps from Job1_DataFlat.root"); - if (auto* fFlat = TFile::Open("Job1_DataFlat.root", "READ")) { - if (!fFlat->IsZombie()) { - if (auto* dirFlat = dynamic_cast(fFlat->Get("rad-flow-decorr"))) { - // Inclusive - if (auto* hRawIncl = dynamic_cast(dirFlat->Get("hCentEtaPhi"))) { - hWeightMap3D[kInclusive] = buildWeightMapFromRaw(hRawIncl, "hWeightMap3D"); - } else { - LOGF(error, "Data flattening source 'hCentEtaPhi' not found in Job1_DataFlat.root"); + if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { + float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); + float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); + float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); + + int flag2 = 0; + if (combNSigmaPr < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaPi < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaKa < cfgnSigmaOtherParticles) + flag2 += 1; + if (!(flag2 > 1) && !(combNSigmaPr > combNSigmaPi) && !(combNSigmaPr > combNSigmaKa)) { + if (combNSigmaPr < cfgnSigmaCutCombTPCTOF) { + flag = 1; } - // PID - if (auto* hRawPID = dynamic_cast(dirFlat->Get("hCentEtaPhi_PID"))) { - hWeightMap3D[kCombinedPID] = buildWeightMapFromRaw(hRawPID, "hWeightMap3D_PID"); - } else { - LOGF(error, "Data flattening source 'hCentEtaPhi_PID' not found in Job1_DataFlat.root"); - } - } else { - LOGF(error, "Directory 'rad-flow-decorr' not found in Job1_DataFlat.root"); } - } else { - LOGF(error, "Job1_DataFlat.root is a zombie."); } - fFlat->Close(); - delete fFlat; - } else { - LOGF(error, "Cannot open Job1_DataFlat.root"); + if (flag == 1) + return true; + else + return false; } - } else { - // Load from MC efficiency file (as before, but ONLY flattening) - LOGF(info, "MC Run: Loading flattening maps from Job1_EffMaps.root"); - if (auto* f = TFile::Open("Job1_EffMaps.root", "READ")) { - if (!f->IsZombie()) { - if (auto* dir = dynamic_cast(f->Get("rad-flow-decorr"))) { - auto loadFlatForPID = [&](PID pidType) { - std::string suffix = pidSuffix[pidType]; - std::string hFlatSrcName = "hCentEtaPhiReco" + suffix; - if (auto* hRaw = dynamic_cast(dir->Get(hFlatSrcName.c_str()))) { - hWeightMap3D[pidType] = buildWeightMapFromRaw(hRaw, Form("hWeightMap3D%s", suffix.c_str())); - } else { - LOGF(warning, "MC flattening source '%s' not found; proceeding without flattening for this PID.", hFlatSrcName.c_str()); - } - }; - loadFlatForPID(kInclusive); - loadFlatForPID(kCombinedPID); - } else { - LOGF(error, "Directory 'rad-flow-decorr' not found in Job1_EffMaps.root (for MC flat)"); + + template + bool selectionPion(const T& candidate) + { + if (!candidate.hasTPC()) + return false; + int flag = 0; + + if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < cfgnSigmaCutTPC) { + flag = 1; } - } else { - LOGF(error, "Job1_EffMaps.root is a zombie (for MC flat)."); - } - f->Close(); - delete f; - } else { - LOGF(error, "Cannot open Job1_EffMaps.root (for MC flat)"); - } - } - } - - auto loadTProfile3D = [&](const char* filename, const char* histname, TProfile3D*& target) { - if (auto* f = TFile::Open(filename, "READ")) { - if (!f->IsZombie()) { - if (auto* dir = dynamic_cast(f->Get("rad-flow-decorr"))) { - if (auto* tp = dynamic_cast(dir->Get(histname))) { - target = reinterpret_cast(tp->Clone()); - target->SetDirectory(nullptr); - } else { - LOGF(error, "Histogram %s missing in %s", histname, filename); + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaPi()) < cfgnSigmaCutTOF) { + flag = 1; } - } else { - LOGF(error, "Directory 'rad-flow-decorr' missing in %s", filename); } - } else { - LOGF(error, "%s is a zombie", filename); - } - f->Close(); - delete f; - } else { - LOGF(error, "Cannot open %s", filename); - } - }; - // === THIS BLOCK IS UPDATED === - if (cfgRunMCFluc) { - // pT profiles - loadTProfile3D("Job2_MCMean.root", "pmeanTruNchEtabinPtbin", pmeanTruNchEtabinPtbinStep2); - loadTProfile3D("Job2_MCMean.root", "pmeanRecoNchEtabinPtbin", pmeanRecoNchEtabinPtbinStep2); - loadTProfile3D("Job2_MCMean.root", "pmeanRecoMatchedNchEtabinPtbin", pmeanRecoMatchedNchEtabinPtbinStep2); - loadTProfile3D("Job2_MCMean.root", "pmeanRecoEffcorrNchEtabinPtbin", pmeanRecoEffcorrNchEtabinPtbinStep2); - loadTProfile3D("Job2_MCMean.root", "pmeanRecoMatchedEffcorrNchEtabinPtbin", pmeanRecoMatchedEffcorrNchEtabinPtbinStep2); - // Et profiles - loadTProfile3D("Job2_MCMean.root", "pmeanEtTruNchEtabinPtbin", pmeanEtTruNchEtabinPtbinStep2); - loadTProfile3D("Job2_MCMean.root", "pmeanEtRecoNchEtabinPtbin", pmeanEtRecoNchEtabinPtbinStep2); - loadTProfile3D("Job2_MCMean.root", "pmeanEtRecoMatchedNchEtabinPtbin", pmeanEtRecoMatchedNchEtabinPtbinStep2); - loadTProfile3D("Job2_MCMean.root", "pmeanEtRecoEffcorrNchEtabinPtbin", pmeanEtRecoEffcorrNchEtabinPtbinStep2); - loadTProfile3D("Job2_MCMean.root", "pmeanEtRecoMatchedEffcorrNchEtabinPtbin", pmeanEtRecoMatchedEffcorrNchEtabinPtbinStep2); - } - // ============================= - if (cfgRunDataFluc) { - loadTProfile3D("Job1_DataMean.root", "pmean_nch_etabin_ptbin", pmeanNchEtabinPtbinStep2); - loadTProfile3D("Job1_DataMean.root", "pmeanEt_nch_etabin_ptbin", pmeanEtNchEtabinPtbinStep2); - } - } - - void processGetEffHists(aod::McCollisions const& mcColl, soa::SmallGroups const& collisions, TCs const& tracks, FilteredTCs const& /*filteredTracks*/, aod::McParticles const& mcParticles) - { - for (const auto& mcCollision : mcColl) { - auto colSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex()); - if (colSlice.size() != 1) - continue; - - for (const auto& col : colSlice) { - if (!col.has_mcCollision()) - continue; - if (!isEventSelected(col)) - continue; - - auto trackSlice = tracks.sliceBy(trackPerCollision, col.globalIndex()); - if (trackSlice.size() < 1) - continue; - - auto partSlice = mcParticles.sliceBy(partPerMcCollision, mcCollision.globalIndex()); - if (partSlice.size() < 1) - continue; - if (col.globalIndex() >= trackSlice.size()) { - LOGF(warning, "Skipping invalid globalIndex=%d for tracks (tracks.size=%d)", col.globalIndex(), tracks.size()); - continue; - } - - float cent = getCentrality(col); - if (cent > KCentMax) - continue; - - for (const auto& particle : partSlice) { - if (!isParticleSelected(particle)) - continue; - if (!particle.isPhysicalPrimary()) - continue; - - const int absPdgId = std::abs(particle.pdgCode()); - const bool isPion = (absPdgId == kPiPlus); - const bool isKaon = (absPdgId == kKPlus); - const bool isProton = (absPdgId == kProton); - const bool isPid = (isPion || isKaon || isProton); - - histos.fill(HIST("hTruth_ParticleWeight"), cent, particle.pt(), particle.eta(), particle.weight()); - histos.fill(HIST("hCentEtaPhiTrue"), cent, particle.eta(), particle.phi()); - histos.fill(HIST("h3_AllPrimary"), col.multNTracksPV(), particle.pt(), particle.eta()); - - if (cent < KCentTestMin) - histos.fill(HIST("hCent1EtaPhi"), particle.eta(), particle.phi()); - if (cent > KCentTestMaxLo && cent < KCentTestMaxHi) - histos.fill(HIST("hCent7EtaPhi"), particle.eta(), particle.phi()); - - if (isPid) { - histos.fill(HIST("hCentEtaPhiTrue_PID"), cent, particle.eta(), particle.phi()); - histos.fill(HIST("h3_AllPrimary_PID"), col.multNTracksPV(), particle.pt(), particle.eta()); + if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { + float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); + float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); + float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); + + int flag2 = 0; + if (combNSigmaPr < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaPi < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaKa < cfgnSigmaOtherParticles) + flag2 += 1; + if (!(flag2 > 1) && !(combNSigmaPi > combNSigmaPr) && !(combNSigmaPi > combNSigmaKa)) { + if (combNSigmaPi < cfgnSigmaCutCombTPCTOF) { + flag = 1; + } + } } + if (flag == 1) + return true; + else + return false; } - histos.fill(HIST("TruthTracKVz"), mcCollision.posZ(), col.posZ()); - histos.fill(HIST("vzResolution"), mcCollision.posZ(), mcCollision.posZ() - col.posZ()); - // Reconstructed - for (const auto& track : trackSlice) { - if (!isTrackSelected(track)) - continue; - - const bool isPion = selectionPion(track); - const bool isKaon = selectionKaon(track); - const bool isProton = selectionProton(track); - const bool isPid = (isPion || isKaon || isProton); - - histos.fill(HIST("h3_AllReco"), col.multNTracksPV(), track.pt(), track.eta()); - histos.fill(HIST("hCentEtaPhiReco"), cent, track.eta(), track.phi()); + template + bool selectionKaon(const T& candidate) + { + if (!candidate.hasTPC()) + return false; + int flag = 0; - if (isPid) { - histos.fill(HIST("h3_AllReco_PID"), col.multNTracksPV(), track.pt(), track.eta()); - histos.fill(HIST("hCentEtaPhiReco_PID"), cent, track.eta(), track.phi()); + if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < cfgnSigmaCutTPC) { + flag = 1; + } + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaKa()) < cfgnSigmaCutTOF) { + flag = 1; + } } - - if (track.has_mcParticle()) { - auto mcPart2 = track.mcParticle(); - if (mcPart2.isPhysicalPrimary()) { - const int absPdgId = std::abs(mcPart2.pdgCode()); - const bool isPionTrue = (absPdgId == kPiPlus); - const bool isKaonTrue = (absPdgId == kKPlus); - const bool isProtonTrue = (absPdgId == kProton); - const bool isPidTrue = (isPionTrue || isKaonTrue || isProtonTrue); - // Fill inclusive hists - histos.fill(HIST("hReco_ParticleWeight"), cent, mcPart2.pt(), mcPart2.eta(), mcPart2.weight()); - histos.fill(HIST("ptResolution"), mcPart2.pt(), mcPart2.pt() - track.pt()); - histos.fill(HIST("ptTruthReco"), mcPart2.pt(), track.pt()); - histos.fill(HIST("etaResolution"), mcPart2.eta(), mcPart2.eta() - track.eta()); - histos.fill(HIST("etaTruthReco"), mcPart2.eta(), track.eta()); - histos.fill(HIST("h3_RecoMatchedToPrimary"), col.multNTracksPV(), mcPart2.pt(), mcPart2.eta()); - histos.fill(HIST("hCentEtaPhiRecoMatched"), cent, mcPart2.eta(), mcPart2.phi()); - - if (isPid && isPidTrue) { - histos.fill(HIST("h3_RecoMatchedToPrimary_PID"), col.multNTracksPV(), mcPart2.pt(), mcPart2.eta()); - histos.fill(HIST("hCentEtaPhiRecoMatched_PID"), cent, mcPart2.eta(), mcPart2.phi()); - } - - } else { - // Matched to secondary - histos.fill(HIST("h3_RecoUnMatchedToPrimary_Secondary"), col.multNTracksPV(), track.pt(), track.eta()); - histos.fill(HIST("hDCAxy_Unmatched"), track.dcaXY()); - histos.fill(HIST("hDCAz_Unmatched"), track.dcaZ()); - if (isPid) { - histos.fill(HIST("h3_RecoUnMatchedToPrimary_Secondary_PID"), col.multNTracksPV(), track.pt(), track.eta()); + if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { + float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); + float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); + float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); + + int flag2 = 0; + if (combNSigmaPr < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaPi < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaKa < cfgnSigmaOtherParticles) + flag2 += 1; + if (!(flag2 > 1) && !(combNSigmaKa > combNSigmaPi) && !(combNSigmaKa > combNSigmaPr)) { + if (combNSigmaKa < cfgnSigmaCutCombTPCTOF) { + flag = 1; } } - } else { - // Fake track - histos.fill(HIST("h3_RecoUnMatchedToPrimary_Fake"), col.multNTracksPV(), track.pt(), track.eta()); - histos.fill(HIST("hDCAxy_NotPrimary"), track.dcaXY()); - histos.fill(HIST("hDCAz_NotPrimary"), track.dcaZ()); - if (isPid) { - histos.fill(HIST("h3_RecoUnMatchedToPrimary_Fake_PID"), col.multNTracksPV(), track.pt(), track.eta()); - } } - } // tracks - } // cols - } // mcColl - LOGF(info, "FINISHED RUNNING processGetEffHists"); - } - PROCESS_SWITCH(RadialFlowDecorr, processGetEffHists, "process MC to calculate Eff and Fakes", cfgRunGetEff); - - void processMCMean(aod::McCollisions const& mcColl, MyRun3MCCollisions const& collisions, TCs const& tracks, FilteredTCs const& /*filteredTracks*/, aod::McParticles const& mcParticles) - { - float sumWiTruth[KNEta][KNpT], sumWiptiTruth[KNEta][KNpT]; - float sumWiReco[KNEta][KNpT], sumWiptiReco[KNEta][KNpT]; - float sumWiRecoMatched[KNEta][KNpT], sumWiptiRecoMatched[KNEta][KNpT]; - float sumWiRecoEffCorr[KNEta][KNpT], sumWiptiRecoEffCorr[KNEta][KNpT]; - float sumWiRecoMatchedEffCorr[KNEta][KNpT], sumWiptiRecoMatchedEffCorr[KNEta][KNpT]; - float sumWiTruthEt[KNEta][KNpT], sumWiptiTruthEt[KNEta][KNpT]; - float sumWiRecoEt[KNEta][KNpT], sumWiptiRecoEt[KNEta][KNpT]; - float sumWiRecoMatchedEt[KNEta][KNpT], sumWiptiRecoMatchedEt[KNEta][KNpT]; - float sumWiRecoEffCorrEt[KNEta][KNpT], sumWiptiRecoEffCorrEt[KNEta][KNpT]; - float sumWiRecoMatchedEffCorrEt[KNEta][KNpT], sumWiptiRecoMatchedEffCorrEt[KNEta][KNpT]; - - for (const auto& mcCollision : mcColl) { - auto colSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex()); - - if (colSlice.size() != 1) - continue; - for (const auto& col : colSlice) { - if (!col.has_mcCollision()) - continue; - if (!isEventSelected(col)) - continue; - - auto trackSlice = tracks.sliceBy(trackPerCollision, col.globalIndex()); - if (trackSlice.size() < 1) - continue; - - auto partSlice = mcParticles.sliceBy(partPerMcCollision, mcCollision.globalIndex()); - if (partSlice.size() < 1) - continue; - if (col.globalIndex() >= trackSlice.size()) { - LOGF(warning, "Skipping invalid globalIndex=%d for tracks (tracks.size=%d)", col.globalIndex(), tracks.size()); - continue; + if (flag == 1) + return true; + else + return false; } - float cent = getCentrality(col); - if (cent > KCentMax) - continue; + float getCentrality(const auto& col) const + { + if (cfgCentralityChoice.value == kCentFT0C) + return col.centFT0C(); + if (cfgCentralityChoice.value == kCentFT0A) + return col.centFT0A(); + if (cfgCentralityChoice.value == kCentFT0M) + return col.centFT0M(); + if (cfgCentralityChoice.value == kCentFV0A) + return col.centFV0A(); + return KinvalidCentrality; + } - if (col.globalIndex() >= trackSlice.size()) { - LOGF(warning, "Skipping invalid globalIndex=%d for tracks (tracks.size=%d)", col.globalIndex(), tracks.size()); - continue; + float getEfficiency(float mult, float pt, float eta, PID pidType, int effidx) const + { + TH3F* h; + if (effidx == 0) + h = hEff[pidType]; + if (effidx == 1) + h = hFake[pidType]; + + if (!h) + return -1; + const int ibx = h->GetXaxis()->FindBin(mult); + const int iby = h->GetYaxis()->FindBin(pt); + const int ibz = h->GetZaxis()->FindBin(eta); + float val = h->GetBinContent(ibx, iby, ibz); + return val; } - LOGF(info, "Event Check: cent = %.1f, nTracks = %d", cent, (int)trackSlice.size()); - memset(sumWiTruth, 0, sizeof(sumWiTruth)); - memset(sumWiptiTruth, 0, sizeof(sumWiptiTruth)); - memset(sumWiReco, 0, sizeof(sumWiReco)); - memset(sumWiptiReco, 0, sizeof(sumWiptiReco)); - memset(sumWiRecoMatched, 0, sizeof(sumWiRecoMatched)); - memset(sumWiptiRecoMatched, 0, sizeof(sumWiptiRecoMatched)); - memset(sumWiRecoEffCorr, 0, sizeof(sumWiRecoEffCorr)); - memset(sumWiptiRecoEffCorr, 0, sizeof(sumWiptiRecoEffCorr)); - memset(sumWiRecoMatchedEffCorr, 0, sizeof(sumWiRecoMatchedEffCorr)); - memset(sumWiptiRecoMatchedEffCorr, 0, sizeof(sumWiptiRecoMatchedEffCorr)); - memset(sumWiTruthEt, 0, sizeof(sumWiTruthEt)); - memset(sumWiptiTruthEt, 0, sizeof(sumWiptiTruthEt)); - memset(sumWiRecoEt, 0, sizeof(sumWiRecoEt)); - memset(sumWiptiRecoEt, 0, sizeof(sumWiptiRecoEt)); - memset(sumWiRecoMatchedEt, 0, sizeof(sumWiRecoMatchedEt)); - memset(sumWiptiRecoMatchedEt, 0, sizeof(sumWiptiRecoMatchedEt)); - memset(sumWiRecoEffCorrEt, 0, sizeof(sumWiRecoEffCorrEt)); - memset(sumWiptiRecoEffCorrEt, 0, sizeof(sumWiptiRecoEffCorrEt)); - memset(sumWiRecoMatchedEffCorrEt, 0, sizeof(sumWiRecoMatchedEffCorrEt)); - memset(sumWiptiRecoMatchedEffCorrEt, 0, sizeof(sumWiptiRecoMatchedEffCorrEt)); - - // Truth - for (const auto& particle : partSlice) { - if (!isParticleSelected(particle)) - continue; - if (!particle.isPhysicalPrimary()) - continue; - - const int absPdgId = std::abs(particle.pdgCode()); - const bool isPion = (absPdgId == kPiPlus); - const bool isKaon = (absPdgId == kKPlus); - const bool isProton = (absPdgId == kProton); - - float pt = particle.pt(); - float eta = particle.eta(); - float p = particle.p(); - - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) - continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) - continue; - sumWiTruth[ieta][ipt]++; - sumWiptiTruth[ieta][ipt] += pt; - if (isPion || isKaon || isProton) { - float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus - : o2::constants::physics::MassProton; - float E = std::sqrt(p * p + m * m); - float Et = E * (pt / p); // E_T = E * sin(theta) = E * (pT / p) - sumWiTruthEt[ieta][ipt]++; - sumWiptiTruthEt[ieta][ipt] += Et; - } - } - } + float getFlatteningWeight(float cent, float eta, float phi, PID pidType) const + { + TH3F* h = hWeightMap3D[pidType]; + if (!h) + return -1; + const int ibx = h->GetXaxis()->FindBin(cent); + const int iby = h->GetYaxis()->FindBin(eta); + const int ibz = h->GetZaxis()->FindBin(phi); + float val = h->GetBinContent(ibx, iby, ibz); + return val; } - for (const auto& track : trackSlice) { - if (!isTrackSelected(track)) - continue; - - float pt = track.pt(); - float eta = track.eta(); - float p = track.p(); - float phi = track.phi(); - - histos.fill(HIST("hCentEtaPhi"), cent, eta, phi); - if (cent < KCentTestMin) - histos.fill(HIST("hCent1EtaPhi"), eta, phi); - if (cent > KCentTestMaxLo && cent < KCentTestMaxHi) - histos.fill(HIST("hCent7EtaPhi"), eta, phi); - - float effIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 0); - float fakeIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 1); - float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); - float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; - - histos.fill(HIST("hCentEtaPhiWtd"), cent, eta, track.phi(), flatWeightIncl); - if (cent < KCentTestMin) - histos.fill(HIST("hCent1EtaPhiWtd"), track.eta(), track.phi(), flatWeightIncl); - if (cent > KCentTestMaxLo && cent < KCentTestMaxHi) - histos.fill(HIST("hCent7EtaPhiWtd"), track.eta(), track.phi(), flatWeightIncl); - - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) - continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) - continue; - sumWiReco[ieta][ipt] += 1.0; - sumWiptiReco[ieta][ipt] += pt; - } + template + std::pair calculateMeanAndC2FromSums(const double sumpmwk[KIntM][KIntK], const double sumwk[KIntK], float referenceMeanPt) const + { + if (sumwk[1] == 0.) { + return {0.f, 0.f}; } - if (effIncl <= 0 || !isfinite(wIncl) || !isfinite(fakeIncl) || !isfinite(flatWeightIncl)) - continue; + double tau1 = sumwk[2] / (sumwk[1] * sumwk[1]); + double denom2 = 1. - tau1; - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) - continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) - continue; - sumWiRecoEffCorr[ieta][ipt] += wIncl; - sumWiptiRecoEffCorr[ieta][ipt] += wIncl * pt; - } + if (std::abs(denom2) < KFloatEpsilon) { + double pmk11safe = sumpmwk[1][1] / sumwk[1]; + return {static_cast(pmk11safe), 0.f}; } - const bool isPion = selectionPion(track); - const bool isKaon = selectionKaon(track); - const bool isProton = selectionProton(track); - if (isPion || isKaon || isProton) { - float effPid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 0); - float fakePid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 1); - float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); - float wPid = flatWeightPid * (1.0 - fakePid) / effPid; - - histos.fill(HIST("hCentEtaPhiWtd_PID"), cent, eta, track.phi(), flatWeightPid); - if (cent < KCentTestMin) - histos.fill(HIST("hCent1EtaPhiWtd_PID"), track.eta(), track.phi(), flatWeightPid); - if (cent > KCentTestMaxLo && cent < KCentTestMaxHi) - histos.fill(HIST("hCent7EtaPhiWtd_PID"), track.eta(), track.phi(), flatWeightPid); - - float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus - : o2::constants::physics::MassProton; - float E = std::sqrt(p * p + m * m); - float Et = E * (pt / p); // E_T = E * sin(theta) - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) - continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) - continue; - sumWiRecoEt[ieta][ipt] += 1.0; - sumWiptiRecoEt[ieta][ipt] += Et; - } - } + double pmk11 = sumpmwk[1][1] / sumwk[1]; - if (effPid <= KFloatEpsilon || !isfinite(wPid) || !isfinite(fakePid) || !isfinite(flatWeightPid)) - continue; - - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) - continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) - continue; - sumWiRecoEffCorrEt[ieta][ipt] += wPid; - sumWiptiRecoEffCorrEt[ieta][ipt] += wPid * Et; - } - } + double pmk12 = 0.f; + if (sumwk[2] != 0.f) { + pmk12 = sumpmwk[1][2] / sumwk[2]; } - if (isfinite(wIncl)) { - if (cent < KCentTestMin) { - histos.fill(HIST("wgt_pT"), pt, wIncl); - histos.fill(HIST("Eff_pT"), pt, effIncl); - histos.fill(HIST("Fake_pT"), pt, fakeIncl); - histos.fill(HIST("Eff_eta"), eta, effIncl); - histos.fill(HIST("Fake_eta"), eta, fakeIncl); - histos.fill(HIST("wgt_eta"), eta, wIncl); - } - histos.fill(HIST("Eff_cent"), cent, effIncl); - histos.fill(HIST("Eff_Ntrk"), col.multNTracksPV(), effIncl); - histos.fill(HIST("Fake_cent"), cent, fakeIncl); - histos.fill(HIST("Fake_Ntrk"), col.multNTracksPV(), fakeIncl); - histos.fill(HIST("wgt_cent"), cent, wIncl); - histos.fill(HIST("wgt_Ntrk"), col.multNTracksPV(), wIncl); + double pmk22 = 0.f; + if (sumwk[2] != 0.f) { + pmk22 = sumpmwk[2][2] / sumwk[2]; } - } // end track loop - - if (isfinite(sumWiTruth[0][0])) { - float meanPtTruth = sumWiptiTruth[0][0] / sumWiTruth[0][0]; - if (!isfinite(meanPtTruth)) - LOGF(info, "meanPtTruth = %.3f, num = %.3f, den =%.3f", meanPtTruth, sumWiptiTruth[0][0], sumWiTruth[0][0]); - if (!isfinite(meanPtTruth)) - continue; - histos.fill(HIST("MCGen/Prof_cent_Nchrec"), cent, sumWiTruth[0][0]); - histos.fill(HIST("MCGen/Prof_MeanpT_Cent"), cent, meanPtTruth); - histos.fill(HIST("MCGen/Prof_MeanpT_Mult"), col.multNTracksPV(), meanPtTruth); + float calculatedMeanPt = pmk11; + + double p1kBar1 = pmk11 - referenceMeanPt; + double p2kBar2 = pmk22 - 2.0f * pmk12 * referenceMeanPt + referenceMeanPt * referenceMeanPt; + + double p1kBar1sq = p1kBar1 * p1kBar1; + double numerator2 = p1kBar1sq - (tau1 * p2kBar2); + + float twopcorr = numerator2 / denom2; + return {calculatedMeanPt, twopcorr}; } - if (isfinite(sumWiReco[0][0])) { - float meanPtReco = sumWiptiReco[0][0] / sumWiReco[0][0]; - if (!isfinite(meanPtReco)) - LOGF(info, "meanPtReco = %.3f, num = %.3f, den =%.3f", meanPtReco, sumWiptiReco[0][0], sumWiReco[0][0]); - if (!isfinite(meanPtReco)) - continue; - histos.fill(HIST("MCReco/Prof_cent_Nchrec"), cent, sumWiReco[0][0]); - histos.fill(HIST("MCReco/Prof_MeanpT_Cent"), cent, meanPtReco); - histos.fill(HIST("MCReco/Prof_MeanpT_Mult"), col.multNTracksPV(), meanPtReco); + + ConfigurableAxis cfgAxisCent{"cfgAxisCent", {0.0, 1.0, 3.0, 5.0, 10, 20, 30, 40, 50, 60, 70, 80, 100}, "centrality axis (percentile)"}; // FT0*/FV0A style + const AxisSpec centAxis{cfgAxisCent, "Centrality (%)"}; + static constexpr int KNbinsNch = 5000; + static constexpr float KNchMax = 5000.5f; + static constexpr int KNbinsNchCoarse = 500; + ConfigurableAxis nChAxis{"nChAxis", {KNbinsNch, KBinOffset, KNchMax}, "PV-contributor track multiplicity axis"}; + ConfigurableAxis nChAxis2{"nChAxis2", {KNbinsNchCoarse, KBinOffset, KNchMax}, "PV-contributor track multiplicity axis"}; + + Configurable cfgRunGetEff{"cfgRunGetEff", false, "Run MC pass to build efficiency/fake maps"}; + Configurable cfgRunMCMean{"cfgRunMCMean", false, "Run MC mean(pT) & mean(Et)"}; + Configurable cfgRunMCFluc{"cfgRunMCFluc", false, "Run MC fluctuations (C2, subevent)"}; + Configurable cfgRunGetFlat{"cfgRunGetFlat", false, "Run Data Get Flattening Weights"}; + Configurable cfgRunDataMean{"cfgRunDataMean", false, "Run DATA mean(pT) & mean(Et)"}; + Configurable cfgRunDataFluc{"cfgRunDataFluc", false, "Run DATA fluctuations (C2, subevent)"}; + + using GeneralCollisions = soa::Join< + aod::Collisions, + aod::EvSels, + aod::Mults, + aod::CentFT0As, aod::CentFT0Cs, aod::CentFT0Ms, aod::CentFV0As, + aod::CentNGlobals>; + Filter collisionFilter = nabs(aod::collision::posZ) < cfgVtxZCut; + using AodCollisionsSel = soa::Filtered; + + using UnfilteredTracks = soa::Join< + aod::Tracks, + aod::TracksExtra, + aod::TrackSelection, + aod::TracksDCA, + aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, + aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr>; + Filter trackFilter = nabs(aod::track::eta) < cfgEtaCut && + aod::track::pt > cfgPtMin&& + aod::track::pt < cfgPtMax&& + nabs(aod::track::dcaXY) < cfgDCAXY&& nabs(aod::track::dcaZ) < cfgDCAZ; + using AodTracksSel = soa::Filtered; + using TCs = soa::Join; + using FilteredTCs = soa::Filtered; + + using MyRun3MCCollisions = soa::Join< + aod::Collisions, aod::EvSels, aod::Mults, aod::MultsExtra, + aod::CentFT0As, aod::CentFT0Cs, aod::CentFT0Ms, aod::CentFV0As, + aod::CentNGlobals, aod::McCollisionLabels>; + + using MyMCTracks = soa::Join< + aod::Tracks, aod::TrackSelection, aod::TracksExtra, aod::TracksDCA, + aod::McTrackLabels, + aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, + aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr>; + + PresliceUnsorted partPerMcCollision = aod::mcparticle::mcCollisionId; + PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; + PresliceUnsorted trackPerMcParticle = aod::mctracklabel::mcParticleId; + Preslice perCollision = aod::track::collisionId; + Preslice trackPerCollision = aod::track::collisionId; + + void declareCommonQA() + { + histos.add("hZvtx_after_sel", ";z_{vtx} (cm)", kTH1F, {{KNbinsZvtx, KZvtxMin, KZvtxMax}}); + histos.add("hVtxZ", ";z_{vtx} (cm)", kTH1F, {{KNbinsZvtx, KZvtxMin, KZvtxMax}}); + histos.add("hCentrality", ";centrality (%)", kTH1F, {{centAxis}}); + histos.add("Hist2D_globalTracks_PVTracks", ";N_{global};N_{PV}", kTH2F, {{nChAxis2}, {nChAxis2}}); + histos.add("Hist2D_cent_nch", ";N_{PV};cent (%)", kTH2F, {{nChAxis2}, {centAxis}}); + histos.add("hP", ";p (GeV/c)", kTH1F, {{KNbinsP, KPMin, KPMax}}); + histos.add("hPt", ";p_{T} (GeV/c)", kTH1F, {{KNbinsPt, KPtMin, KPtMax}}); + histos.add("hEta", ";#eta", kTH1F, {{KNbinsEta, KEtaMin, KEtaMax}}); + histos.add("hPhi", ";#phi", kTH1F, {{KNbinsPhi, KPhiMin, TwoPI}}); + + histos.add("hCentEtaPhi", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCent1EtaPhi", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCent7EtaPhi", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCentEtaPhiWtd", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCent1EtaPhiWtd", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCent7EtaPhiWtd", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + + histos.add("hCentEtaPhiWtd_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCent1EtaPhiWtd_PID", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCent7EtaPhiWtd_PID", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + + histos.add("hCentEtaPhiTrue", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCentEtaPhiReco", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCentEtaPhiRecoMatched", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + + histos.add("hCentEtaPhiTrue_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCentEtaPhiReco_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCentEtaPhiRecoMatched_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); } - if (isfinite(sumWiRecoEffCorr[0][0])) { - float meanpTeffcorr = sumWiptiRecoEffCorr[0][0] / sumWiRecoEffCorr[0][0]; - if (!isfinite(meanpTeffcorr)) - LOGF(info, "meanPtRecoEffcorr = %.3f, num = %.3f, den =%.3f", meanpTeffcorr, sumWiptiRecoEffCorr[0][0], sumWiRecoEffCorr[0][0]); - if (!isfinite(meanpTeffcorr)) - continue; - histos.fill(HIST("MCRecoEffCorr/Prof_cent_Nchrec"), cent, sumWiRecoEffCorr[0][0]); - histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Cent"), cent, meanpTeffcorr); - histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Mult"), col.multNTracksPV(), meanpTeffcorr); + void declareMCCommonHists() + { + + histos.add("ptResolution", ";p_{T}^{MC};p_{T}^{MC}-p_{T}^{reco}", kTH2F, {{KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsPtRes, -KPtResMax, KPtResMax}}); + histos.add("ptTruthReco", ";p_{T}^{MC};p_{T}^{reco}", kTH2F, {{KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsPtRes, cfgPtMin, cfgPtMax}}); + histos.add("etaResolution", ";#eta^{MC};#eta^{MC}-#eta^{reco}", kTH2F, {{KNbinsEtaRes, -KEtaFineMax, KEtaFineMax}, {KNbinsPtRes, -KEtaResMax, KEtaResMax}}); + histos.add("etaTruthReco", ";#eta^{MC};#eta^{reco}", kTH2F, {{KNbinsPtRes, -KEtaFineMax, KEtaFineMax}, {KNbinsPtRes, -KEtaFineMax, KEtaFineMax}}); + + histos.add("TruthTracKVz", ";Vz^{MC};Vz^{Reco}", kTH2F, {{KNbinsVz, KVzMin, KVzMax}, {KNbinsVz, KVzMin, KVzMax}}); + histos.add("vzResolution", ";Vz^{MC};Vz^{MC}-Vz^{Reco}", kTH2F, {{KNbinsVz, KVzMin, KVzMax}, {KNbinsVz, -KVzResMax, KVzResMax}}); + + histos.add("h3_AllPrimary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_RecoMatchedToPrimary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_RecoUnMatchedToPrimary_Secondary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_RecoUnMatchedToPrimary_Fake", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_AllReco", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + + histos.add("h3_AllPrimary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_RecoMatchedToPrimary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_RecoUnMatchedToPrimary_Secondary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_RecoUnMatchedToPrimary_Fake_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_AllReco_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + + histos.add("h_AllPrimary", ";p_{T}", kTH1F, {{KNbinsP, cfgPtMin, cfgPtMax}}); + histos.add("h_RecoMatchedToPrimary", ";p_{T}", kTH1F, {{KNbinsPt, KPtMin, KPtMax}}); + histos.add("h_RecoUnMatchedToPrimary", ";p_{T}", kTH1F, {{KNbinsPt, KPtMin, KPtMax}}); + histos.add("h_AllReco", ";p_{T}", kTH1F, {{KNbinsPt, KPtMin, KPtMax}}); + + histos.add("hReco_ParticleWeight", ";cent;p_{T};#eta", kTH3F, {{centAxis}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsPtRes, -KEtaFineMax, KEtaFineMax}}); + histos.add("hTruth_ParticleWeight", ";cent;p_{T};#eta", kTH3F, {{centAxis}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsPtRes, -KEtaFineMax, KEtaFineMax}}); + + histos.add("hDCAxy_Unmatched", ";DCA_{xy} (cm)", kTH1F, {{KNbinsDca, -KDcaMax, KDcaMax}}); + histos.add("hDCAz_Unmatched", ";DCA_{z} (cm)", kTH1F, {{KNbinsDca, -KDcaMax, KDcaMax}}); + histos.add("hDCAxy_NotPrimary", ";DCA_{xy} (cm)", kTH1F, {{KNbinsDca, -KDcaMax, KDcaMax}}); + histos.add("hDCAz_NotPrimary", ";DCA_{z} (cm)", kTH1F, {{KNbinsDca, -KDcaMax, KDcaMax}}); } - if (isfinite(sumWiTruthEt[0][0])) { - float meanEt = sumWiptiTruthEt[0][0] / sumWiTruthEt[0][0]; - if (!isfinite(meanEt)) - LOGF(info, "meanEtTruthEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiTruthEt[0][0], sumWiTruthEt[0][0]); - if (!isfinite(meanEt)) - continue; - histos.fill(HIST("MCGen/Prof_MeanEt_Cent"), cent, meanEt); - histos.fill(HIST("MCGen/Prof_MeanEt_Mult"), col.multNTracksPV(), meanEt); + void declareMCMeanHists() + { + histos.add("Eff_cent", ";cent;#epsilon", kTProfile, {centAxis}); + histos.add("Fake_cent", ";cent;f_{fake}", kTProfile, {centAxis}); + histos.add("wgt_cent", ";cent;w", kTProfile, {centAxis}); + histos.add("Eff_Ntrk", ";N_{PV};#epsilon", kTProfile, {nChAxis2}); + histos.add("Fake_Ntrk", ";N_{PV};f_{fake}", kTProfile, {nChAxis2}); + histos.add("wgt_Ntrk", ";N_{PV};w", kTProfile, {nChAxis2}); + histos.add("Eff_pT", ";p_{T};#epsilon", kTProfile, {{KNbinsPtRes, cfgPtMin, cfgPtMax}}); + histos.add("Fake_pT", ";p_{T};f_{fake}", kTProfile, {{KNbinsPtRes, cfgPtMin, cfgPtMax}}); + histos.add("wgt_pT", ";p_{T};w", kTProfile, {{KNbinsPtRes, KPtMin, KPtMax}}); + histos.add("Eff_eta", ";#eta;#epsilon", kTProfile, {{KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("Fake_eta", ";#eta;f_{fake}", kTProfile, {{KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("wgt_eta", ";#eta;w", kTProfile, {{KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + // MC mean profiles (pT & Et) for various selections + histos.add("MCGen/Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanpT_Mult", ";N_{PV};#LT p_{T}#GT", kTProfile, {nChAxis}); + histos.add("pmeanTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + + histos.add("MCGen/Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanEt_Mult", ";N_{PV};#LT E_{T}#GT", kTProfile, {nChAxis}); + histos.add("pmeanEtTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanEtRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanEtRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanEtRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanEtRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + + histos.addClone("MCGen/", "MCReco/"); + histos.addClone("MCGen/", "MCRecoMatched/"); + histos.addClone("MCGen/", "MCRecoEffCorr/"); + histos.addClone("MCGen/", "MCRecoMatchedEffCorr/"); } - // "MCReco" - if (isfinite(sumWiRecoEt[0][0])) { - float meanEt = sumWiptiRecoEt[0][0] / sumWiRecoEt[0][0]; - if (!isfinite(meanEt)) - LOGF(info, "meanEtRecoEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiRecoEt[0][0], sumWiRecoEt[0][0]); - if (!isfinite(meanEt)) - continue; - histos.fill(HIST("MCReco/Prof_MeanEt_Cent"), cent, meanEt); - histos.fill(HIST("MCReco/Prof_MeanEt_Mult"), col.multNTracksPV(), meanEt); + void declareMCFlucHists() + { + static constexpr int KNbinsNchFluc = 1000; + // pT cumulants + histos.add("MCGen/Prof_C2_Cent", ";cent;C_{2}", kTProfile, {centAxis}); + histos.add("MCGen/Prof_C2_Mult", ";N_{PV};C_{2}", kTProfile, {nChAxis}); + histos.add("MCGen/Prof_C2Sub_Mult_etabin_ptbin", + ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, + {{KNbinsNchFluc, KNchMin, KNchCoarseMax}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("MCGen/Prof_ipt0_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt0_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt0_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("MCGen/Prof_C2Et_Cent", ";cent;C_{2}^{E_{T}}", kTProfile, {centAxis}); + histos.add("MCGen/Prof_C2Et_Mult", ";N_{PV};C_{2}^{E_{T}}", kTProfile, {nChAxis}); + histos.add("MCGen/Prof_C2EtSub_Mult_etabin_ptbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, + {{KNbinsNchFluc, KNchMin, KNchCoarseMax}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("MCGen/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt0_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt0_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + + histos.add("MCGen/Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanpT_Mult", ";N_{PV};#LT p_{T}#GT", kTProfile, {nChAxis}); + + histos.add("pmeanTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + + histos.add("MCGen/Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanEt_Mult", ";N_{PV};#LT E_{T}#GT", kTProfile, {nChAxis}); + histos.add("pmeanEtTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanEtRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanEtRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanEtRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanEtRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); } - // "MCRecoEffCorr" - if (isfinite(sumWiRecoEffCorrEt[0][0])) { - float meanEt = sumWiptiRecoEffCorrEt[0][0] / sumWiRecoEffCorrEt[0][0]; - if (!isfinite(meanEt)) - LOGF(info, "meanEtRecoEffcorrEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiRecoEffCorrEt[0][0], sumWiRecoEffCorrEt[0][0]); - if (!isfinite(meanEt)) - continue; - histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Cent"), cent, meanEt); - histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Mult"), col.multNTracksPV(), meanEt); + void declareDataMeanHists() + { + histos.add("Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); + histos.add("Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); + histos.add("pmean_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + // Et + histos.add("Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); + histos.add("pmeanEt_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); } - // --- Fill 3D pT Profiles --- - for (int ieta = 0; ieta < KNEta; ++ieta) { - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (isfinite(sumWiTruth[ieta][ipt])) - histos.fill(HIST("pmeanTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiTruth[ieta][ipt] / sumWiTruth[ieta][ipt]); - if (isfinite(sumWiReco[ieta][ipt])) - histos.fill(HIST("pmeanRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiReco[ieta][ipt] / sumWiReco[ieta][ipt]); - if (isfinite(sumWiRecoEffCorr[ieta][ipt])) - histos.fill(HIST("pmeanRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiRecoEffCorr[ieta][ipt] / sumWiRecoEffCorr[ieta][ipt]); - // --- Fill 3D Et Profiles --- - if (isfinite(sumWiTruthEt[ieta][ipt])) - histos.fill(HIST("pmeanEtTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiTruthEt[ieta][ipt] / sumWiTruthEt[ieta][ipt]); - if (isfinite(sumWiRecoEt[ieta][ipt])) - histos.fill(HIST("pmeanEtRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiRecoEt[ieta][ipt] / sumWiRecoEt[ieta][ipt]); - if (isfinite(sumWiRecoEffCorrEt[ieta][ipt])) - histos.fill(HIST("pmeanEtRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiRecoEffCorrEt[ieta][ipt] / sumWiRecoEffCorrEt[ieta][ipt]); - } + void declareDataGetFlatHists() + { + histos.add("hCentEtaPhi_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, 0, TwoPI}}); } - } // end col loop - } - - LOGF(info, "FINISHED RUNNING processMCMean (pT + Et)"); - } - PROCESS_SWITCH(RadialFlowDecorr, processMCMean, "process MC to calculate mean pt/Et and Eff Hists", cfgRunMCMean); - - void processMCFluc(aod::McCollisions const& mcColl, MyRun3MCCollisions const& collisions, TCs const& tracks, FilteredTCs const& /*filteredTracks*/, aod::McParticles const& mcParticles) - { - double sumPmwkTru[KNEta][KNpT][KIntM][KIntK]{}; - double sumWkTru[KNEta][KNpT][KIntK]{}; - double sumPmwkReco[KNEta][KNpT][KIntM][KIntK]{}; - double sumWkReco[KNEta][KNpT][KIntK]{}; - double sumPmwkRecoEffCor[KNEta][KNpT][KIntM][KIntK]{}; - double sumWkRecoEffCor[KNEta][KNpT][KIntK]{}; - double sumPmwkTruEt[KNEta][KNpT][KIntM][KIntK]{}; - double sumWkTruEt[KNEta][KNpT][KIntK]{}; - double sumPmwkRecoEt[KNEta][KNpT][KIntM][KIntK]{}; - double sumWkRecoEt[KNEta][KNpT][KIntK]{}; - double sumPmwkRecoEffCorEt[KNEta][KNpT][KIntM][KIntK]{}; - double sumWkRecoEffCorEt[KNEta][KNpT][KIntK]{}; - double meanTru[KNEta][KNpT]{}, c2Tru[KNEta][KNpT]{}; - double meanReco[KNEta][KNpT]{}, c2Reco[KNEta][KNpT]{}; - double meanRecoEffCor[KNEta][KNpT]{}, c2RecoEffCor[KNEta][KNpT]{}; - double meanTruEt[KNEta][KNpT]{}, c2TruEt[KNEta][KNpT]{}; - double meanRecoEt[KNEta][KNpT]{}, c2RecoEt[KNEta][KNpT]{}; - double meanRecoEffCorEt[KNEta][KNpT]{}, c2RecoEffCorEt[KNEta][KNpT]{}; - - for (const auto& mcCollision : mcColl) { - auto partSlice = mcParticles.sliceBy(partPerMcCollision, mcCollision.globalIndex()); - auto colSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex()); - if (colSlice.size() != 1) - continue; - // histos.fill(HIST("MCGen/hVtxZ"), mcCollision.posZ()); - for (const auto& col : colSlice) { - - auto trackSlice = tracks.sliceBy(trackPerCollision, col.globalIndex()); - if (trackSlice.size() < 1) - continue; - - memset(sumPmwkTru, 0, sizeof(sumPmwkTru)); - memset(sumWkTru, 0, sizeof(sumWkTru)); - memset(sumPmwkReco, 0, sizeof(sumPmwkReco)); - memset(sumWkReco, 0, sizeof(sumWkReco)); - memset(sumPmwkRecoEffCor, 0, sizeof(sumPmwkRecoEffCor)); - memset(sumWkRecoEffCor, 0, sizeof(sumWkRecoEffCor)); - - memset(sumPmwkTruEt, 0, sizeof(sumPmwkTruEt)); - memset(sumWkTruEt, 0, sizeof(sumWkTruEt)); - memset(sumPmwkRecoEt, 0, sizeof(sumPmwkRecoEt)); - memset(sumWkRecoEt, 0, sizeof(sumWkRecoEt)); - memset(sumPmwkRecoEffCorEt, 0, sizeof(sumPmwkRecoEffCorEt)); - memset(sumWkRecoEffCorEt, 0, sizeof(sumWkRecoEffCorEt)); - - memset(meanTru, 0, sizeof(meanTru)); - memset(c2Tru, 0, sizeof(c2Tru)); - memset(meanReco, 0, sizeof(meanReco)); - memset(c2Reco, 0, sizeof(c2Reco)); - memset(meanRecoEffCor, 0, sizeof(meanRecoEffCor)); - memset(c2RecoEffCor, 0, sizeof(c2RecoEffCor)); - - memset(meanTruEt, 0, sizeof(meanTruEt)); - memset(c2TruEt, 0, sizeof(c2TruEt)); - memset(meanRecoEt, 0, sizeof(meanRecoEt)); - memset(c2RecoEt, 0, sizeof(c2RecoEt)); - memset(meanRecoEffCorEt, 0, sizeof(meanRecoEffCorEt)); - memset(c2RecoEffCorEt, 0, sizeof(c2RecoEffCorEt)); - - if (!col.has_mcCollision() || !isEventSelected(col)) - continue; - float cent = getCentrality(col); - if (cent > KCentMax) - continue; - - // truth - for (const auto& particle : partSlice) { - if (!isParticleSelected(particle)) - continue; - if (!particle.isPhysicalPrimary()) - continue; - float pt = particle.pt(); - float eta = particle.eta(); - float p = particle.p(); - - // pT (Inclusive) - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) - continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) - continue; - for (int k = 0; k < KIntK; ++k) { - for (int m = 0; m < KIntM; ++m) { - sumPmwkTru[ieta][ipt][m][k] += std::pow(pt, m); - } - sumWkTru[ieta][ipt][k]++; - } - } + + void declareDataFlucHists() + { + histos.add("pmean_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); + histos.add("pmeanEt_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + + histos.add("Prof_C2_Cent", ";cent;C_{2}", kTProfile, {centAxis}); + histos.add("Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); + histos.add("Prof_MeanpT_Mult", ";N_{PV};#LT p_{T}#GT", kTProfile, {nChAxis}); + histos.add("Prof_C2_Mult_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + + histos.add("Prof_ipt0_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("Prof_ipt0_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("Prof_ipt1_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("Prof_ipt1_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("Prof_ipt2_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("Prof_ipt2_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + + histos.add("Prof_C2Et_Cent", ";cent;C_{2}^{E_{T}}", kTProfile, {centAxis}); + histos.add("Prof_MeanEt_Mult", ";N_{PV};#LT E_{T}#GT", kTProfile, {nChAxis}); + histos.add("Prof_C2Et_Mult_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + + histos.add("Prof_ipt0_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("Prof_ipt0_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("Prof_ipt1_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("Prof_ipt1_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("Prof_ipt2_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("Prof_ipt2_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + + histos.add("Prof_ipt0_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("Prof_ipt1_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("Prof_ipt2_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("Prof_ipt0_C2SubEt2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("Prof_ipt1_C2SubEt2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("Prof_ipt2_C2SubEt2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + } + + TH3F* buildWeightMapFromRaw(TH3F* hRaw, const char* mapName) + { + if (!hRaw) { + LOGF(error, "Raw eta-phi map for '%s' is null; no flattening will be applied.", mapName); + return nullptr; } - const int absPdgId = std::abs(particle.pdgCode()); - const bool isPion = (absPdgId == kPiPlus); - const bool isKaon = (absPdgId == kKPlus); - const bool isProton = (absPdgId == kProton); - if (isPion || isKaon || isProton) { - - float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus - : o2::constants::physics::MassProton; - float E = std::sqrt(p * p + m * m); - float Et = E * (pt / p); - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) - continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) - continue; - for (int k = 0; k < KIntK; ++k) { - for (int m = 0; m < KIntM; ++m) { - sumPmwkTruEt[ieta][ipt][m][k] += std::pow(Et, m); - } - sumWkTruEt[ieta][ipt][k]++; - } + auto hWeightMap = reinterpret_cast(hRaw->Clone(mapName)); + hWeightMap->SetTitle(Form("Flattening Weight Map %s (w_{#phi} = / N_{#phi})", mapName)); + hWeightMap->SetDirectory(nullptr); + hWeightMap->Reset(); + auto axC = hRaw->GetXaxis(); + auto axE = hRaw->GetYaxis(); + auto axP = hRaw->GetZaxis(); + for (int ic = 1; ic <= axC->GetNbins(); ++ic) { + for (int ie = 1; ie <= axE->GetNbins(); ++ie) { + // average over phi at fixed (cent,eta) + double sum = 0.0; + int nphi = axP->GetNbins(); + for (int ip = 1; ip <= nphi; ++ip) + sum += hRaw->GetBinContent(ic, ie, ip); + const double avg = (nphi > 0 ? sum / nphi : 0.0); + for (int ip = 1; ip <= nphi; ++ip) { + const double raw = hRaw->GetBinContent(ic, ie, ip); + const double w = (avg > 0.0 && raw > 0.0) ? (avg / raw) : 1.0; + hWeightMap->SetBinContent(ic, ie, ip, w); } } } + LOGF(info, "Flattening weight map '%s' built.", mapName); + return hWeightMap; + } - } // end truth loop - - for (const auto& track : trackSlice) { - if (!isTrackSelected(track)) - continue; - float pt = track.pt(); - float eta = track.eta(); - float p = track.p(); - float phi = track.phi(); - - float effIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 0); - float fakeIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 1); - float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); - float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; - if (!std::isfinite(wIncl) || wIncl <= 0.f) - continue; - if (effIncl <= 0 || !isfinite(effIncl) || !isfinite(fakeIncl) || !isfinite(flatWeightIncl)) - continue; - - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) - continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) - continue; - for (int k = 0; k < KIntK; ++k) { - for (int m = 0; m < KIntM; ++m) { - sumPmwkReco[ieta][ipt][m][k] += std::pow(1.0f, k) * std::pow(pt, m); - sumPmwkRecoEffCor[ieta][ipt][m][k] += std::pow(wIncl, k) * std::pow(pt, m); - } - sumWkReco[ieta][ipt][k] += std::pow(1.0f, k); - sumWkRecoEffCor[ieta][ipt][k] += std::pow(wIncl, k); - } - } + inline void loadTProfile3D(TDirectory* dir, const char* name, TProfile3D*& target) + { + if (!dir) { + LOGF(error, "loadTProfile3D: directory is null for object %s", name); + return; } - const bool isPion = selectionPion(track); - const bool isKaon = selectionKaon(track); - const bool isProton = selectionProton(track); - - if (isPion || isKaon || isProton) { - float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus - : o2::constants::physics::MassProton; - float E = std::sqrt(p * p + m * m); - float Et = E * (pt / p); // E_T = E * sin(theta) - float effPid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 0); - float fakePid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 1); - float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); - float wPid = flatWeightPid * (1.0 - fakePid) / effPid; - if (effPid >= 1.f || fakePid >= 1.f || !isfinite(effPid) || effPid <= KFloatEpsilon || !isfinite(fakePid) || !isfinite(flatWeightPid)) - continue; - - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) - continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) - continue; - for (int k = 0; k < KIntK; ++k) { - for (int m = 0; m < KIntM; ++m) { - sumPmwkRecoEt[ieta][ipt][m][k] += std::pow(1.0f, k) * std::pow(Et, m); - sumPmwkRecoEffCorEt[ieta][ipt][m][k] += std::pow(wPid, k) * std::pow(Et, m); - } - sumWkRecoEt[ieta][ipt][k] += std::pow(1.0f, k); - sumWkRecoEffCorEt[ieta][ipt][k] += std::pow(wPid, k); - } - } - } + auto* obj = dir->Get(name); + if (!obj) { + LOGF(error, "loadTProfile3D: object '%s' not found in directory %s", name, dir->GetName()); + return; } - for (int ieta = 0; ieta < KNEta; ++ieta) { - for (int ipt = 0; ipt < KNpT; ++ipt) { - const int ibx = pmeanTruNchEtabinPtbinStep2->GetXaxis()->FindBin(col.multNTracksPV()); - const int iby = ieta + 1; - const int ibz = ipt + 1; - - float mmptTru = pmeanTruNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmptReco = pmeanRecoNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmptRecoEffCor = pmeanRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmetTru = pmeanEtTruNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmetReco = pmeanEtRecoNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmetRecoEffCor = pmeanEtRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - - if (isfinite(mmptTru)) - std::tie(meanTru[ieta][ipt], c2Tru[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkTru[ieta][ipt], sumWkTru[ieta][ipt], mmptTru); - if (isfinite(mmptReco)) - std::tie(meanReco[ieta][ipt], c2Reco[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkReco[ieta][ipt], sumWkReco[ieta][ipt], mmptReco); - if (isfinite(mmptRecoEffCor)) - std::tie(meanRecoEffCor[ieta][ipt], c2RecoEffCor[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEffCor[ieta][ipt], sumWkRecoEffCor[ieta][ipt], mmptRecoEffCor); - - if (isfinite(mmetTru)) - std::tie(meanTruEt[ieta][ipt], c2TruEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkTruEt[ieta][ipt], sumWkTruEt[ieta][ipt], mmetTru); - if (isfinite(mmetReco)) - std::tie(meanRecoEt[ieta][ipt], c2RecoEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEt[ieta][ipt], sumWkRecoEt[ieta][ipt], mmetReco); - if (isfinite(mmetRecoEffCor)) - std::tie(meanRecoEffCorEt[ieta][ipt], c2RecoEffCorEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEffCorEt[ieta][ipt], sumWkRecoEffCorEt[ieta][ipt], mmetRecoEffCor); - } + auto* prof = dynamic_cast(obj); + if (!prof) { + LOGF(error, "loadTProfile3D: object '%s' is not a TProfile3D (it is %s)", name, obj->ClassName()); + return; } - } - if (std::isfinite(c2Tru[0][0])) { - histos.fill(HIST("MCGen/Prof_C2_Cent"), cent, c2Tru[0][0]); - histos.fill(HIST("MCGen/Prof_C2_Mult"), col.multNTracksPV(), c2Tru[0][0]); - } - if (std::isfinite(c2TruEt[0][0])) { - histos.fill(HIST("MCGen/Prof_C2Et_Cent"), cent, c2TruEt[0][0]); - histos.fill(HIST("MCGen/Prof_C2Et_Mult"), col.multNTracksPV(), c2TruEt[0][0]); - } - // "MCReco" - if (std::isfinite(c2Reco[0][0])) { - histos.fill(HIST("MCReco/Prof_C2_Cent"), cent, c2Reco[0][0]); - histos.fill(HIST("MCReco/Prof_C2_Mult"), col.multNTracksPV(), c2Reco[0][0]); - } - if (std::isfinite(c2RecoEt[0][0])) { - histos.fill(HIST("MCReco/Prof_C2Et_Cent"), cent, c2RecoEt[0][0]); - histos.fill(HIST("MCReco/Prof_C2Et_Mult"), col.multNTracksPV(), c2RecoEt[0][0]); - } - if (std::isfinite(c2RecoEffCor[0][0])) { - histos.fill(HIST("MCRecoEffCorr/Prof_C2_Cent"), cent, c2RecoEffCor[0][0]); - histos.fill(HIST("MCRecoEffCorr/Prof_C2_Mult"), col.multNTracksPV(), c2RecoEffCor[0][0]); - } - if (std::isfinite(c2RecoEffCorEt[0][0])) { - histos.fill(HIST("MCRecoEffCorr/Prof_C2Et_Cent"), cent, c2RecoEffCorEt[0][0]); - histos.fill(HIST("MCRecoEffCorr/Prof_C2Et_Mult"), col.multNTracksPV(), c2RecoEffCorEt[0][0]); + target = reinterpret_cast(prof->Clone(Form("%s_clone", name))); + target->SetDirectory(nullptr); + LOGF(info, "Loaded TProfile3D '%s' with entries = %.0f", name, target->GetEntries()); } - if (std::isfinite(sumWkTru[0][0][1])) { - histos.fill(HIST("MCGen/Prof_cent_Nchrec"), cent, sumWkTru[0][0][1]); - histos.fill(HIST("MCGen/Prof_MeanpT_Cent"), cent, meanTru[0][0]); - histos.fill(HIST("MCGen/Prof_MeanpT_Mult"), col.multNTracksPV(), meanTru[0][0]); - } - if (std::isfinite(sumWkTruEt[0][0][1])) { - histos.fill(HIST("MCGen/Prof_MeanEt_Cent"), cent, meanTruEt[0][0]); - histos.fill(HIST("MCGen/Prof_MeanEt_Mult"), col.multNTracksPV(), meanTruEt[0][0]); - } - // "MCReco" - if (std::isfinite(sumWkReco[0][0][1])) { - histos.fill(HIST("MCReco/Prof_cent_Nchrec"), cent, sumWkReco[0][0][1]); - histos.fill(HIST("MCReco/Prof_MeanpT_Cent"), cent, meanReco[0][0]); - histos.fill(HIST("MCReco/Prof_MeanpT_Mult"), col.multNTracksPV(), meanReco[0][0]); - } - if (std::isfinite(sumWkRecoEt[0][0][1])) { - histos.fill(HIST("MCReco/Prof_MeanEt_Cent"), cent, meanRecoEt[0][0]); - histos.fill(HIST("MCReco/Prof_MeanEt_Mult"), col.multNTracksPV(), meanRecoEt[0][0]); - } - // "MCRecoEffCorr" - if (std::isfinite(sumWkRecoEffCor[0][0][1])) { - histos.fill(HIST("MCRecoEffCorr/Prof_cent_Nchrec"), cent, sumWkRecoEffCor[0][0][1]); - histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Cent"), cent, meanRecoEffCor[0][0]); - histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Mult"), col.multNTracksPV(), meanRecoEffCor[0][0]); - } - if (std::isfinite(sumWkRecoEffCorEt[0][0][1])) { - histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Cent"), cent, meanRecoEffCorEt[0][0]); - histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Mult"), col.multNTracksPV(), meanRecoEffCorEt[0][0]); - } + void init(InitContext&) + { + ccdb->setURL("https://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + int64_t now = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()) + .count(); + ccdb->setCreatedNotAfter(now); - for (int ieta = 0; ieta < KNEta; ++ieta) { - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (std::isfinite(sumWkTru[ieta][ipt][1])) - histos.fill(HIST("pmeanTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanTru[ieta][ipt]); - if (std::isfinite(sumWkReco[ieta][ipt][1])) - histos.fill(HIST("pmeanRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanReco[ieta][ipt]); - if (std::isfinite(sumWkRecoEffCor[ieta][ipt][1])) - histos.fill(HIST("pmeanRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanRecoEffCor[ieta][ipt]); - if (std::isfinite(sumWkTruEt[ieta][ipt][1])) - histos.fill(HIST("pmeanEtTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanTruEt[ieta][ipt]); - if (std::isfinite(sumWkRecoEt[ieta][ipt][1])) - histos.fill(HIST("pmeanEtRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanRecoEt[ieta][ipt]); - if (std::isfinite(sumWkRecoEffCorEt[ieta][ipt][1])) - histos.fill(HIST("pmeanEtRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanRecoEffCorEt[ieta][ipt]); - } - } + declareCommonQA(); - float p1kBarTru[KNEta][KNpT]{}, p1kBarReco[KNEta][KNpT]{}, p1kBarRecoEffCor[KNEta][KNpT]{}; - float p1kBarTruEt[KNEta][KNpT]{}, p1kBarRecoEt[KNEta][KNpT]{}, p1kBarRecoEffCorEt[KNEta][KNpT]{}; - for (int ieta = 0; ieta < KNEta; ++ieta) { - for (int ipt = 0; ipt < KNpT; ++ipt) { - const int ibx = pmeanTruNchEtabinPtbinStep2->GetXaxis()->FindBin(col.multNTracksPV()); - const int iby = ieta + 1; - const int ibz = ipt + 1; - - float mmptTru = pmeanTruNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmptReco = pmeanRecoNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmptRecoEffCor = pmeanRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmetTru = pmeanEtTruNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmetReco = pmeanEtRecoNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmetRecoEffCor = pmeanEtRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - - // pT deviations - if (mmptTru != 0.0) - p1kBarTru[ieta][ipt] = meanTru[ieta][ipt] - mmptTru; - if (mmptReco != 0.0) - p1kBarReco[ieta][ipt] = meanReco[ieta][ipt] - mmptReco; - if (mmptRecoEffCor != 0.0) - p1kBarRecoEffCor[ieta][ipt] = meanRecoEffCor[ieta][ipt] - mmptRecoEffCor; - // Et deviations - if (mmetTru != 0.0) - p1kBarTruEt[ieta][ipt] = meanTruEt[ieta][ipt] - mmetTru; - if (mmetReco != 0.0) - p1kBarRecoEt[ieta][ipt] = meanRecoEt[ieta][ipt] - mmetReco; - if (mmetRecoEffCor != 0.0) - p1kBarRecoEffCorEt[ieta][ipt] = meanRecoEffCorEt[ieta][ipt] - mmetRecoEffCor; - } - } + const std::string userCcdbPath = "/Users/s/somadutt/PbPbTest/"; - // 1D Covariance (vs eta) - for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { - int ietaC = KNEta - ietaA; - float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); - { - const int ipt = 0; - float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("MCGen/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); - histos.fill(HIST("MCGen/Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("MCGen/Prof_ipt0_Cov_Eta"), valy, c2Sub); + if (cfgRunMCMean || cfgRunMCFluc || cfgRunGetEff) { + declareMCCommonHists(); } - float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("MCGen/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); - histos.fill(HIST("MCGen/Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("MCGen/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); + if (cfgRunMCMean) { + declareMCMeanHists(); } - } + if (cfgRunMCFluc) { + declareMCFlucHists(); - // ipt = 1 - { - const int ipt = 1; - float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("MCGen/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); - histos.fill(HIST("MCGen/Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("MCGen/Prof_ipt0_Cov_Eta"), valy, c2Sub); + histos.addClone("MCGen/", "MCReco/"); + histos.addClone("MCGen/", "MCRecoMatched/"); + histos.addClone("MCGen/", "MCRecoEffCorr/"); + histos.addClone("MCGen/", "MCRecoMatchedEffCorr/"); } - float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("MCGen/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); - histos.fill(HIST("MCGen/Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("MCGen/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); + if (cfgRunGetFlat) { + declareDataGetFlatHists(); } - } - // ipt = 2 - { - const int ipt = 2; - float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("MCGen/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); - histos.fill(HIST("MCGen/Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("MCGen/Prof_ipt2_Cov_Eta"), valy, c2Sub); + if (cfgRunDataMean) { + declareDataMeanHists(); } - float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("MCGen/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); - histos.fill(HIST("MCGen/Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("MCGen/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); + if (cfgRunDataFluc) { + declareDataFlucHists(); } - } - } - for (int ietaA = 1; ietaA < KNEta; ++ietaA) { - for (int ietaC = 1; ietaC < KNEta; ++ietaC) { - float valx = 0.5f * (etaLw[ietaA] + etaUp[ietaA]); - float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); - // ipt = 0 - { - const int ipt = 0; - float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; - if (std::isfinite(c2Sub)) - histos.fill(HIST("MCGen/Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); - float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) - histos.fill(HIST("MCGen/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + const bool needEffMaps = cfgRunMCMean || cfgRunMCFluc || cfgRunDataMean || cfgRunDataFluc; + if (needEffMaps && !cfgRunGetEff) { + + LOGF(info, "Loading Eff/Fake maps from CCDB path: %s", userCcdbPath.c_str()); + + auto loadEffFakeForPID = [&](PID pidType) { + std::string suffix = pidSuffix[pidType]; + std::string hEffNumName = "h3_RecoMatchedToPrimary" + suffix; + std::string hEffDenName = "h3_AllPrimary" + suffix; + std::string hFakeNumSecName = "h3_RecoUnMatchedToPrimary_Secondary" + suffix; + std::string hFakeNumFakName = "h3_RecoUnMatchedToPrimary_Fake" + suffix; + std::string hFakeDenName = "h3_AllReco" + suffix; + + // --- Efficiency --- + auto* hNum = ccdb->get(userCcdbPath + hEffNumName); + auto* hDen = ccdb->get(userCcdbPath + hEffDenName); + if (hNum && hDen) { + hEff[pidType] = reinterpret_cast(hNum->Clone(Form("hEff%s", suffix.c_str()))); + hEff[pidType]->SetDirectory(nullptr); + hEff[pidType]->Divide(hDen); + } else { + LOGF(error, "Missing CCDB objects for efficiency. Checked:\n%s\n%s", + (userCcdbPath + hEffNumName).c_str(), + (userCcdbPath + hEffDenName).c_str()); + } + + // --- Fakes --- + auto* hNumS = ccdb->get(userCcdbPath + hFakeNumSecName); + auto* hNumF = ccdb->get(userCcdbPath + hFakeNumFakName); + auto* hDenF = ccdb->get(userCcdbPath + hFakeDenName); + if (hNumS && hNumF && hDenF) { + hFake[pidType] = reinterpret_cast(hNumS->Clone(Form("hFake%s", suffix.c_str()))); + hFake[pidType]->Add(hNumF); + hFake[pidType]->SetDirectory(nullptr); + hFake[pidType]->Divide(hDenF); + } else { + LOGF(error, "Missing CCDB object(s) for fakes for %s. Checked path prefix: %s", + suffix.c_str(), userCcdbPath.c_str()); + } + }; + + loadEffFakeForPID(kInclusive); + loadEffFakeForPID(kCombinedPID); + + const bool isDataRun = cfgRunDataMean || cfgRunDataFluc; + if (isDataRun) { + LOGF(info, "Data Run: Loading flattening maps from CCDB path: %s", userCcdbPath.c_str()); + + auto* hRawIncl = ccdb->get(userCcdbPath + "hCentEtaPhi"); + if (hRawIncl) { + hWeightMap3D[kInclusive] = buildWeightMapFromRaw(hRawIncl, "hWeightMap3D"); + } else { + LOGF(error, "Data flattening 'hCentEtaPhi' not found at path %s", + (userCcdbPath + "hCentEtaPhi").c_str()); + } + + auto* hRawPID = ccdb->get(userCcdbPath + "hCentEtaPhi_PID"); + if (hRawPID) { + hWeightMap3D[kCombinedPID] = buildWeightMapFromRaw(hRawPID, "hWeightMap3D_PID"); + } else { + LOGF(error, "Data flattening 'hCentEtaPhi_PID' not found at path %s", + (userCcdbPath + "hCentEtaPhi_PID").c_str()); + } + } else { + LOGF(info, "MC Run: Loading flattening maps from CCDB path: %s", userCcdbPath.c_str()); + + auto loadFlatForPID = [&](PID pidType) { + std::string suffix = pidSuffix[pidType]; + std::string hFlatSrcName = "hCentEtaPhiReco" + suffix; + auto* hRaw = ccdb->get(userCcdbPath + hFlatSrcName); + if (hRaw) { + hWeightMap3D[pidType] = buildWeightMapFromRaw(hRaw, Form("hWeightMap3D%s", suffix.c_str())); + } else { + LOGF(warning, "MC flattening source '%s' not found at %s; skipping this PID.", + hFlatSrcName.c_str(), (userCcdbPath + hFlatSrcName).c_str()); + } + }; + loadFlatForPID(kInclusive); + loadFlatForPID(kCombinedPID); + } } - // ipt = 1 - { - const int ipt = 1; - float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; - if (std::isfinite(c2Sub)) - histos.fill(HIST("MCGen/Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); - float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) - histos.fill(HIST("MCGen/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + + auto loadTProfile3DFromCCDB = [&](const std::string& ccdbPath, const char* objName, TProfile3D*& target) { + std::string fullPath = ccdbPath + objName; + LOGF(info, "Loading TProfile3D from CCDB: %s", fullPath.c_str()); + if (auto* tp = ccdb->get(fullPath)) { + target = reinterpret_cast(tp->Clone()); + target->SetDirectory(nullptr); + } else { + LOGF(error, "Histogram %s missing in CCDB at path: %s", objName, fullPath.c_str()); + } + }; + + if (cfgRunMCFluc) { + LOGF(info, "Loading MC Mean profiles from CCDB path: %s", userCcdbPath.c_str()); + + loadTProfile3DFromCCDB(userCcdbPath, "pmeanTruNchEtabinPtbin", pmeanTruNchEtabinPtbinStep2); + loadTProfile3DFromCCDB(userCcdbPath, "pmeanRecoNchEtabinPtbin", pmeanRecoNchEtabinPtbinStep2); + loadTProfile3DFromCCDB(userCcdbPath, "pmeanRecoMatchedNchEtabinPtbin", pmeanRecoMatchedNchEtabinPtbinStep2); + loadTProfile3DFromCCDB(userCcdbPath, "pmeanRecoEffcorrNchEtabinPtbin", pmeanRecoEffcorrNchEtabinPtbinStep2); + loadTProfile3DFromCCDB(userCcdbPath, "pmeanRecoMatchedEffcorrNchEtabinPtbin", pmeanRecoMatchedEffcorrNchEtabinPtbinStep2); + + loadTProfile3DFromCCDB(userCcdbPath, "pmeanEtTruNchEtabinPtbin", pmeanEtTruNchEtabinPtbinStep2); + loadTProfile3DFromCCDB(userCcdbPath, "pmeanEtRecoNchEtabinPtbin", pmeanEtRecoNchEtabinPtbinStep2); + loadTProfile3DFromCCDB(userCcdbPath, "pmeanEtRecoMatchedNchEtabinPtbin", pmeanEtRecoMatchedNchEtabinPtbinStep2); + loadTProfile3DFromCCDB(userCcdbPath, "pmeanEtRecoEffcorrNchEtabinPtbin", pmeanEtRecoEffcorrNchEtabinPtbinStep2); + loadTProfile3DFromCCDB(userCcdbPath, "pmeanEtRecoMatchedEffcorrNchEtabinPtbin", pmeanEtRecoMatchedEffcorrNchEtabinPtbinStep2); } - // ipt = 2 - { - const int ipt = 2; - float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; - if (std::isfinite(c2Sub)) - histos.fill(HIST("MCGen/Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); - float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) - histos.fill(HIST("MCGen/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + + if (cfgRunDataFluc) { + LOGF(info, "Loading Data Mean profiles from CCDB path: %s", userCcdbPath.c_str()); + loadTProfile3DFromCCDB(userCcdbPath, "pmean_nch_etabin_ptbin", pmeanNchEtabinPtbinStep2); + loadTProfile3DFromCCDB(userCcdbPath, "pmeanEt_nch_etabin_ptbin", pmeanEtNchEtabinPtbinStep2); } + + LOGF(info, "CCDB initialization complete for RadialFlowDecorr."); } - } - // --- MCReco Covariance (1D vs eta) --- - for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { - int ietaC = KNEta - ietaA; - float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); // 0.5 for averaging - // ipt = 0 + void processGetEffHists(aod::McCollisions const& mcColl, soa::SmallGroups const& collisions, TCs const& tracks, FilteredTCs const& /*filteredTracks*/, aod::McParticles const& mcParticles) { - const int ipt = 0; - float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("MCReco/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); - histos.fill(HIST("MCReco/Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("MCReco/Prof_ipt0_Cov_Eta"), valy, c2Sub); - } - float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("MCReco/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); - histos.fill(HIST("MCReco/Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("MCReco/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); - } + for (const auto& mcCollision : mcColl) { + auto colSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex()); + if (colSlice.size() != 1) continue; + + for (const auto& col : colSlice) { + if (!col.has_mcCollision()) continue; + if (!isEventSelected(col)) continue; + + auto trackSlice = tracks.sliceBy(trackPerCollision, col.globalIndex()); + if (trackSlice.size() < 1) continue; + + auto partSlice = mcParticles.sliceBy(partPerMcCollision, mcCollision.globalIndex()); + if (partSlice.size() < 1) continue; + if (col.globalIndex() >= trackSlice.size()) { + LOGF(warning, "Skipping invalid globalIndex=%d for tracks (tracks.size=%d)", col.globalIndex(), tracks.size()); + continue; + } + + float cent = getCentrality(col); + if (cent > KCentMax) continue; + + for (const auto& particle : partSlice) { + if (!isParticleSelected(particle)) continue; + if (!particle.isPhysicalPrimary()) continue; + + const int absPdgId = std::abs(particle.pdgCode()); + const bool isPion = (absPdgId == KPiPlus); + const bool isKaon = (absPdgId == KKPlus); + const bool isProton = (absPdgId == KProton); + const bool isPid = (isPion || isKaon || isProton); + + histos.fill(HIST("hTruth_ParticleWeight"), cent, particle.pt(), particle.eta(), particle.weight()); + histos.fill(HIST("hCentEtaPhiTrue"), cent, particle.eta(), particle.phi()); + histos.fill(HIST("h3_AllPrimary"), col.multNTracksPV(), particle.pt(), particle.eta()); + + if (cent < KCentTestMin) + histos.fill(HIST("hCent1EtaPhi"), particle.eta(), particle.phi()); + if (cent > KCentTestMaxLo && cent < KCentTestMaxHi) + histos.fill(HIST("hCent7EtaPhi"), particle.eta(), particle.phi()); + + if (isPid) { + histos.fill(HIST("hCentEtaPhiTrue_PID"), cent, particle.eta(), particle.phi()); + histos.fill(HIST("h3_AllPrimary_PID"), col.multNTracksPV(), particle.pt(), particle.eta()); + } + } + histos.fill(HIST("TruthTracKVz"), mcCollision.posZ(), col.posZ()); + histos.fill(HIST("vzResolution"), mcCollision.posZ(), mcCollision.posZ() - col.posZ()); + + // Reconstructed + for (const auto& track : trackSlice) { + if (!isTrackSelected(track)) continue; + + const bool isPion = selectionPion(track); + const bool isKaon = selectionKaon(track); + const bool isProton = selectionProton(track); + const bool isPid = (isPion || isKaon || isProton); + + histos.fill(HIST("h3_AllReco"), col.multNTracksPV(), track.pt(), track.eta()); + histos.fill(HIST("hCentEtaPhiReco"), cent, track.eta(), track.phi()); + + if (isPid) { + histos.fill(HIST("h3_AllReco_PID"), col.multNTracksPV(), track.pt(), track.eta()); + histos.fill(HIST("hCentEtaPhiReco_PID"), cent, track.eta(), track.phi()); + } + + if (track.has_mcParticle()) { + auto mcPart2 = track.mcParticle(); + if (mcPart2.isPhysicalPrimary()) { + const int absPdgId = std::abs(mcPart2.pdgCode()); + const bool isPionTrue = (absPdgId == kPiPlus); + const bool isKaonTrue = (absPdgId == kKPlus); + const bool isProtonTrue = (absPdgId == kProton); + const bool isPidTrue = (isPionTrue || isKaonTrue || isProtonTrue); + + histos.fill(HIST("hReco_ParticleWeight"), cent, mcPart2.pt(), mcPart2.eta(), mcPart2.weight()); + histos.fill(HIST("ptResolution"), mcPart2.pt(), mcPart2.pt() - track.pt()); + histos.fill(HIST("ptTruthReco"), mcPart2.pt(), track.pt()); + histos.fill(HIST("etaResolution"), mcPart2.eta(), mcPart2.eta() - track.eta()); + histos.fill(HIST("etaTruthReco"), mcPart2.eta(), track.eta()); + histos.fill(HIST("h3_RecoMatchedToPrimary"), col.multNTracksPV(), mcPart2.pt(), mcPart2.eta()); + histos.fill(HIST("hCentEtaPhiRecoMatched"), cent, mcPart2.eta(), mcPart2.phi()); + + if (isPid && isPidTrue) { + histos.fill(HIST("h3_RecoMatchedToPrimary_PID"), col.multNTracksPV(), mcPart2.pt(), mcPart2.eta()); + histos.fill(HIST("hCentEtaPhiRecoMatched_PID"), cent, mcPart2.eta(), mcPart2.phi()); + } + + } else { + // Matched to secondary + histos.fill(HIST("h3_RecoUnMatchedToPrimary_Secondary"), col.multNTracksPV(), track.pt(), track.eta()); + histos.fill(HIST("hDCAxy_Unmatched"), track.dcaXY()); + histos.fill(HIST("hDCAz_Unmatched"), track.dcaZ()); + if (isPid) { + histos.fill(HIST("h3_RecoUnMatchedToPrimary_Secondary_PID"), col.multNTracksPV(), track.pt(), track.eta()); + } + } + } else { + // Fake track + histos.fill(HIST("h3_RecoUnMatchedToPrimary_Fake"), col.multNTracksPV(), track.pt(), track.eta()); + histos.fill(HIST("hDCAxy_NotPrimary"), track.dcaXY()); + histos.fill(HIST("hDCAz_NotPrimary"), track.dcaZ()); + if (isPid) { + histos.fill(HIST("h3_RecoUnMatchedToPrimary_Fake_PID"), col.multNTracksPV(), track.pt(), track.eta()); + } + } + } // tracks + } // cols + } // mcColl + LOGF(info, "FINISHED RUNNING processGetEffHists"); } + PROCESS_SWITCH(RadialFlowDecorr, processGetEffHists, "process MC to calculate Eff and Fakes", cfgRunGetEff); - // ipt = 1 + void processMCMean(aod::McCollisions const& mcColl, MyRun3MCCollisions const& collisions, TCs const& tracks, FilteredTCs const& /*filteredTracks*/, aod::McParticles const& mcParticles) { - const int ipt = 1; - float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("MCReco/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); - histos.fill(HIST("MCReco/Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("MCReco/Prof_ipt1_Cov_Eta"), valy, c2Sub); - } - float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("MCReco/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); - histos.fill(HIST("MCReco/Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("MCReco/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); + float sumWiTruth[KNEta][KNpT], sumWiptiTruth[KNEta][KNpT]; + float sumWiReco[KNEta][KNpT], sumWiptiReco[KNEta][KNpT]; + float sumWiRecoMatched[KNEta][KNpT], sumWiptiRecoMatched[KNEta][KNpT]; + float sumWiRecoEffCorr[KNEta][KNpT], sumWiptiRecoEffCorr[KNEta][KNpT]; + float sumWiRecoMatchedEffCorr[KNEta][KNpT], sumWiptiRecoMatchedEffCorr[KNEta][KNpT]; + float sumWiTruthEt[KNEta][KNpT], sumWiptiTruthEt[KNEta][KNpT]; + float sumWiRecoEt[KNEta][KNpT], sumWiptiRecoEt[KNEta][KNpT]; + float sumWiRecoMatchedEt[KNEta][KNpT], sumWiptiRecoMatchedEt[KNEta][KNpT]; + float sumWiRecoEffCorrEt[KNEta][KNpT], sumWiptiRecoEffCorrEt[KNEta][KNpT]; + float sumWiRecoMatchedEffCorrEt[KNEta][KNpT], sumWiptiRecoMatchedEffCorrEt[KNEta][KNpT]; + + for (const auto& mcCollision : mcColl) { + auto colSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex()); + + if (colSlice.size() != 1) continue; + for (const auto& col : colSlice) { + if (!col.has_mcCollision()) continue; + if (!isEventSelected(col)) continue; + + auto trackSlice = tracks.sliceBy(trackPerCollision, col.globalIndex()); + if (trackSlice.size() < 1) continue; + + auto partSlice = mcParticles.sliceBy(partPerMcCollision, mcCollision.globalIndex()); + if (partSlice.size() < 1) continue; + if (col.globalIndex() >= trackSlice.size()) { + LOGF(warning, "Skipping invalid globalIndex=%d for tracks (tracks.size=%d)", col.globalIndex(), tracks.size()); + continue; + } + + float cent = getCentrality(col); + if (cent > KCentMax) continue; + + if (col.globalIndex() >= trackSlice.size()) { + LOGF(warning, "Skipping invalid globalIndex=%d for tracks (tracks.size=%d)", col.globalIndex(), tracks.size()); + continue; + } + + LOGF(info, "Event Check: cent = %.1f, nTracks = %d", cent, (int)trackSlice.size()); + memset(sumWiTruth, 0, sizeof(sumWiTruth)); + memset(sumWiptiTruth, 0, sizeof(sumWiptiTruth)); + memset(sumWiReco, 0, sizeof(sumWiReco)); + memset(sumWiptiReco, 0, sizeof(sumWiptiReco)); + memset(sumWiRecoMatched, 0, sizeof(sumWiRecoMatched)); + memset(sumWiptiRecoMatched, 0, sizeof(sumWiptiRecoMatched)); + memset(sumWiRecoEffCorr, 0, sizeof(sumWiRecoEffCorr)); + memset(sumWiptiRecoEffCorr, 0, sizeof(sumWiptiRecoEffCorr)); + memset(sumWiRecoMatchedEffCorr, 0, sizeof(sumWiRecoMatchedEffCorr)); + memset(sumWiptiRecoMatchedEffCorr, 0, sizeof(sumWiptiRecoMatchedEffCorr)); + memset(sumWiTruthEt, 0, sizeof(sumWiTruthEt)); + memset(sumWiptiTruthEt, 0, sizeof(sumWiptiTruthEt)); + memset(sumWiRecoEt, 0, sizeof(sumWiRecoEt)); + memset(sumWiptiRecoEt, 0, sizeof(sumWiptiRecoEt)); + memset(sumWiRecoMatchedEt, 0, sizeof(sumWiRecoMatchedEt)); + memset(sumWiptiRecoMatchedEt, 0, sizeof(sumWiptiRecoMatchedEt)); + memset(sumWiRecoEffCorrEt, 0, sizeof(sumWiRecoEffCorrEt)); + memset(sumWiptiRecoEffCorrEt, 0, sizeof(sumWiptiRecoEffCorrEt)); + memset(sumWiRecoMatchedEffCorrEt, 0, sizeof(sumWiRecoMatchedEffCorrEt)); + memset(sumWiptiRecoMatchedEffCorrEt, 0, sizeof(sumWiptiRecoMatchedEffCorrEt)); + + // Truth + for (const auto& particle : partSlice) { + if (!isParticleSelected(particle)) continue; + if (!particle.isPhysicalPrimary()) continue; + + const int absPdgId = std::abs(particle.pdgCode()); + const bool isPion = (absPdgId == kPiPlus); + const bool isKaon = (absPdgId == kKPlus); + const bool isProton = (absPdgId == kProton); + + float pt = particle.pt(); + float eta = particle.eta(); + float p = particle.p(); + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + sumWiTruth[ieta][ipt]++; + sumWiptiTruth[ieta][ipt] += pt; + if (isPion || isKaon || isProton) { + float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus + : o2::constants::physics::MassProton; + float energy = std::sqrt(p * p + m * m); + float et = energy * (pt / p); // E_T = E * sin(theta) = E * (pT / p) + sumWiTruthEt[ieta][ipt]++; + sumWiptiTruthEt[ieta][ipt] += et; + } + } + } + } + + for (const auto& track : trackSlice) { + if (!isTrackSelected(track)) continue; + + float pt = track.pt(); + float eta = track.eta(); + float p = track.p(); + float phi = track.phi(); + + histos.fill(HIST("hCentEtaPhi"), cent, eta, phi); + if (cent < KCentTestMin) + histos.fill(HIST("hCent1EtaPhi"), eta, phi); + if (cent > KCentTestMaxLo && cent < KCentTestMaxHi) + histos.fill(HIST("hCent7EtaPhi"), eta, phi); + + float effIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 0); + float fakeIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 1); + float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); + float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; + + histos.fill(HIST("hCentEtaPhiWtd"), cent, eta, track.phi(), flatWeightIncl); + if (cent < KCentTestMin) histos.fill(HIST("hCent1EtaPhiWtd"), track.eta(), track.phi(), flatWeightIncl); + if (cent > KCentTestMaxLo && cent < KCentTestMaxHi) histos.fill(HIST("hCent7EtaPhiWtd"), track.eta(), track.phi(), flatWeightIncl); + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + sumWiReco[ieta][ipt] += 1.0; + sumWiptiReco[ieta][ipt] += pt; + } + } + + if (effIncl <= 0 || !isfinite(wIncl) || !isfinite(fakeIncl) || !isfinite(flatWeightIncl)) continue; + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + sumWiRecoEffCorr[ieta][ipt] += wIncl; + sumWiptiRecoEffCorr[ieta][ipt] += wIncl * pt; + } + } + + const bool isPion = selectionPion(track); + const bool isKaon = selectionKaon(track); + const bool isProton = selectionProton(track); + if (isPion || isKaon || isProton) { + float effPid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 0); + float fakePid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 1); + float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); + float wPid = flatWeightPid * (1.0 - fakePid) / effPid; + + histos.fill(HIST("hCentEtaPhiWtd_PID"), cent, eta, track.phi(), flatWeightPid); + if (cent < KCentTestMin) histos.fill(HIST("hCent1EtaPhiWtd_PID"), track.eta(), track.phi(), flatWeightPid); + if (cent > KCentTestMaxLo && cent < KCentTestMaxHi) histos.fill(HIST("hCent7EtaPhiWtd_PID"), track.eta(), track.phi(), flatWeightPid); + + float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus : o2::constants::physics::MassProton; + float energy = std::sqrt(p * p + m * m); + float et = energy * (pt / p); // E_T = E * sin(theta) + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + sumWiRecoEt[ieta][ipt] += 1.0; + sumWiptiRecoEt[ieta][ipt] += et; + } + } + + if (effPid <= KFloatEpsilon || !isfinite(wPid) || !isfinite(fakePid) || !isfinite(flatWeightPid)) continue; + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; + sumWiRecoEffCorrEt[ieta][ipt] += wPid; + sumWiptiRecoEffCorrEt[ieta][ipt] += wPid * et; + } + } + } + + if (isfinite(wIncl)) { + if (cent < KCentTestMin) { + histos.fill(HIST("wgt_pT"), pt, wIncl); + histos.fill(HIST("Eff_pT"), pt, effIncl); + histos.fill(HIST("Fake_pT"), pt, fakeIncl); + histos.fill(HIST("Eff_eta"), eta, effIncl); + histos.fill(HIST("Fake_eta"), eta, fakeIncl); + histos.fill(HIST("wgt_eta"), eta, wIncl); + } + histos.fill(HIST("Eff_cent"), cent, effIncl); + histos.fill(HIST("Eff_Ntrk"), col.multNTracksPV(), effIncl); + histos.fill(HIST("Fake_cent"), cent, fakeIncl); + histos.fill(HIST("Fake_Ntrk"), col.multNTracksPV(), fakeIncl); + histos.fill(HIST("wgt_cent"), cent, wIncl); + histos.fill(HIST("wgt_Ntrk"), col.multNTracksPV(), wIncl); + } + + } // end track loop + + if (isfinite(sumWiTruth[0][0])) { + float meanPtTruth = sumWiptiTruth[0][0] / sumWiTruth[0][0]; + if (!isfinite(meanPtTruth)) LOGF(info, "meanPtTruth = %.3f, num = %.3f, den =%.3f", meanPtTruth, sumWiptiTruth[0][0], sumWiTruth[0][0]); + if (!isfinite(meanPtTruth)) continue; + histos.fill(HIST("MCGen/Prof_cent_Nchrec"), cent, sumWiTruth[0][0]); + histos.fill(HIST("MCGen/Prof_MeanpT_Cent"), cent, meanPtTruth); + histos.fill(HIST("MCGen/Prof_MeanpT_Mult"), col.multNTracksPV(), meanPtTruth); + } + if (isfinite(sumWiReco[0][0])) { + float meanPtReco = sumWiptiReco[0][0] / sumWiReco[0][0]; + if (!isfinite(meanPtReco)) LOGF(info, "meanPtReco = %.3f, num = %.3f, den =%.3f", meanPtReco, sumWiptiReco[0][0], sumWiReco[0][0]); + if (!isfinite(meanPtReco)) continue; + histos.fill(HIST("MCReco/Prof_cent_Nchrec"), cent, sumWiReco[0][0]); + histos.fill(HIST("MCReco/Prof_MeanpT_Cent"), cent, meanPtReco); + histos.fill(HIST("MCReco/Prof_MeanpT_Mult"), col.multNTracksPV(), meanPtReco); + } + if (isfinite(sumWiRecoEffCorr[0][0])) { + float meanpTeffcorr = sumWiptiRecoEffCorr[0][0] / sumWiRecoEffCorr[0][0]; + if (!isfinite(meanpTeffcorr)) LOGF(info, "meanPtRecoEffcorr = %.3f, num = %.3f, den =%.3f", meanpTeffcorr, sumWiptiRecoEffCorr[0][0], sumWiRecoEffCorr[0][0]); + if (!isfinite(meanpTeffcorr)) continue; + histos.fill(HIST("MCRecoEffCorr/Prof_cent_Nchrec"), cent, sumWiRecoEffCorr[0][0]); + histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Cent"), cent, meanpTeffcorr); + histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Mult"), col.multNTracksPV(), meanpTeffcorr); + } + + if (isfinite(sumWiTruthEt[0][0])) { + float meanEt = sumWiptiTruthEt[0][0] / sumWiTruthEt[0][0]; + if (!isfinite(meanEt)) LOGF(info, "meanEtTruthEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiTruthEt[0][0], sumWiTruthEt[0][0]); + if (!isfinite(meanEt)) continue; + histos.fill(HIST("MCGen/Prof_MeanEt_Cent"), cent, meanEt); + histos.fill(HIST("MCGen/Prof_MeanEt_Mult"), col.multNTracksPV(), meanEt); + } + // "MCReco" + if (isfinite(sumWiRecoEt[0][0])) { + float meanEt = sumWiptiRecoEt[0][0] / sumWiRecoEt[0][0]; + if (!isfinite(meanEt)) LOGF(info, "meanEtRecoEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiRecoEt[0][0], sumWiRecoEt[0][0]); + if (!isfinite(meanEt)) continue; + histos.fill(HIST("MCReco/Prof_MeanEt_Cent"), cent, meanEt); + histos.fill(HIST("MCReco/Prof_MeanEt_Mult"), col.multNTracksPV(), meanEt); + } + // "MCRecoEffCorr" + if (isfinite(sumWiRecoEffCorrEt[0][0])) { + float meanEt = sumWiptiRecoEffCorrEt[0][0] / sumWiRecoEffCorrEt[0][0]; + if (!isfinite(meanEt)) LOGF(info, "meanEtRecoEffcorrEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiRecoEffCorrEt[0][0], sumWiRecoEffCorrEt[0][0]); + if (!isfinite(meanEt)) continue; + histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Cent"), cent, meanEt); + histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Mult"), col.multNTracksPV(), meanEt); + } + + for (int ieta = 0; ieta < KNEta; ++ieta) { + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (isfinite(sumWiTruth[ieta][ipt])) + histos.fill(HIST("pmeanTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiTruth[ieta][ipt] / sumWiTruth[ieta][ipt]); + if (isfinite(sumWiReco[ieta][ipt])) + histos.fill(HIST("pmeanRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiReco[ieta][ipt] / sumWiReco[ieta][ipt]); + if (isfinite(sumWiRecoEffCorr[ieta][ipt])) + histos.fill(HIST("pmeanRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiRecoEffCorr[ieta][ipt] / sumWiRecoEffCorr[ieta][ipt]); + + if (isfinite(sumWiTruthEt[ieta][ipt])) + histos.fill(HIST("pmeanEtTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiTruthEt[ieta][ipt] / sumWiTruthEt[ieta][ipt]); + if (isfinite(sumWiRecoEt[ieta][ipt])) + histos.fill(HIST("pmeanEtRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiRecoEt[ieta][ipt] / sumWiRecoEt[ieta][ipt]); + if (isfinite(sumWiRecoEffCorrEt[ieta][ipt])) + histos.fill(HIST("pmeanEtRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiRecoEffCorrEt[ieta][ipt] / sumWiRecoEffCorrEt[ieta][ipt]); + } + } + } // end col loop } + + LOGF(info, "FINISHED RUNNING processMCMean (pT + Et)"); } + PROCESS_SWITCH(RadialFlowDecorr, processMCMean, "process MC to calculate mean pt/Et and Eff Hists", cfgRunMCMean); - // ipt = 2 + void processMCFluc(aod::McCollisions const& mcColl, MyRun3MCCollisions const& collisions, TCs const& tracks, FilteredTCs const& /*filteredTracks*/, aod::McParticles const& mcParticles) { - const int ipt = 2; - float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("MCReco/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); - histos.fill(HIST("MCReco/Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("MCReco/Prof_ipt2_Cov_Eta"), valy, c2Sub); - } - float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("MCReco/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); - histos.fill(HIST("MCReco/Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("MCReco/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); - } - } - } + double sumPmwkTru[KNEta][KNpT][KIntM][KIntK]{}; + double sumWkTru[KNEta][KNpT][KIntK]{}; + double sumPmwkReco[KNEta][KNpT][KIntM][KIntK]{}; + double sumWkReco[KNEta][KNpT][KIntK]{}; + double sumPmwkRecoEffCor[KNEta][KNpT][KIntM][KIntK]{}; + double sumWkRecoEffCor[KNEta][KNpT][KIntK]{}; + double sumPmwkTruEt[KNEta][KNpT][KIntM][KIntK]{}; + double sumWkTruEt[KNEta][KNpT][KIntK]{}; + double sumPmwkRecoEt[KNEta][KNpT][KIntM][KIntK]{}; + double sumWkRecoEt[KNEta][KNpT][KIntK]{}; + double sumPmwkRecoEffCorEt[KNEta][KNpT][KIntM][KIntK]{}; + double sumWkRecoEffCorEt[KNEta][KNpT][KIntK]{}; + double meanTru[KNEta][KNpT]{}, c2Tru[KNEta][KNpT]{}; + double meanReco[KNEta][KNpT]{}, c2Reco[KNEta][KNpT]{}; + double meanRecoEffCor[KNEta][KNpT]{}, c2RecoEffCor[KNEta][KNpT]{}; + double meanTruEt[KNEta][KNpT]{}, c2TruEt[KNEta][KNpT]{}; + double meanRecoEt[KNEta][KNpT]{}, c2RecoEt[KNEta][KNpT]{}; + double meanRecoEffCorEt[KNEta][KNpT]{}, c2RecoEffCorEt[KNEta][KNpT]{}; + + for (const auto& mcCollision : mcColl) { + auto partSlice = mcParticles.sliceBy(partPerMcCollision, mcCollision.globalIndex()); + auto colSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex()); + if (colSlice.size() != 1) continue; + // histos.fill(HIST("MCGen/hVtxZ"), mcCollision.posZ()); + for (const auto& col : colSlice) { + + auto trackSlice = tracks.sliceBy(trackPerCollision, col.globalIndex()); + if (trackSlice.size() < 1) continue; + + memset(sumPmwkTru, 0, sizeof(sumPmwkTru)); + memset(sumWkTru, 0, sizeof(sumWkTru)); + memset(sumPmwkReco, 0, sizeof(sumPmwkReco)); + memset(sumWkReco, 0, sizeof(sumWkReco)); + memset(sumPmwkRecoEffCor, 0, sizeof(sumPmwkRecoEffCor)); + memset(sumWkRecoEffCor, 0, sizeof(sumWkRecoEffCor)); + + memset(sumPmwkTruEt, 0, sizeof(sumPmwkTruEt)); + memset(sumWkTruEt, 0, sizeof(sumWkTruEt)); + memset(sumPmwkRecoEt, 0, sizeof(sumPmwkRecoEt)); + memset(sumWkRecoEt, 0, sizeof(sumWkRecoEt)); + memset(sumPmwkRecoEffCorEt, 0, sizeof(sumPmwkRecoEffCorEt)); + memset(sumWkRecoEffCorEt, 0, sizeof(sumWkRecoEffCorEt)); + + memset(meanTru, 0, sizeof(meanTru)); + memset(c2Tru, 0, sizeof(c2Tru)); + memset(meanReco, 0, sizeof(meanReco)); + memset(c2Reco, 0, sizeof(c2Reco)); + memset(meanRecoEffCor, 0, sizeof(meanRecoEffCor)); + memset(c2RecoEffCor, 0, sizeof(c2RecoEffCor)); + + memset(meanTruEt, 0, sizeof(meanTruEt)); + memset(c2TruEt, 0, sizeof(c2TruEt)); + memset(meanRecoEt, 0, sizeof(meanRecoEt)); + memset(c2RecoEt, 0, sizeof(c2RecoEt)); + memset(meanRecoEffCorEt, 0, sizeof(meanRecoEffCorEt)); + memset(c2RecoEffCorEt, 0, sizeof(c2RecoEffCorEt)); + + if (!col.has_mcCollision() || !isEventSelected(col)) + continue; + float cent = getCentrality(col); + if (cent > KCentMax) + continue; - // --- MCReco Covariance (2D etaA vs etaC) --- - for (int ietaA = 1; ietaA < KNEta; ++ietaA) { - for (int ietaC = 1; ietaC < KNEta; ++ietaC) { - float valx = 0.5f * (etaLw[ietaA] + etaUp[ietaA]); - float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); - - // ipt = 0 - { - const int ipt = 0; - float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; - if (std::isfinite(c2Sub)) - histos.fill(HIST("MCReco/Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); - float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) - histos.fill(HIST("MCReco/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); - } + // truth + for (const auto& particle : partSlice) { + if (!isParticleSelected(particle)) + continue; + if (!particle.isPhysicalPrimary()) + continue; + float pt = particle.pt(); + float eta = particle.eta(); + float p = particle.p(); + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; + for (int k = 0; k < KIntK; ++k) { + for (int m = 0; m < KIntM; ++m) { + sumPmwkTru[ieta][ipt][m][k] += std::pow(pt, m); + } + sumWkTru[ieta][ipt][k]++; + } + } + } + const int absPdgId = std::abs(particle.pdgCode()); + const bool isPion = (absPdgId == kPiPlus); + const bool isKaon = (absPdgId == kKPlus); + const bool isProton = (absPdgId == kProton); + if (isPion || isKaon || isProton) { + + float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus + : o2::constants::physics::MassProton; + float energy = std::sqrt(p * p + m * m); + float et = energy * (pt / p); + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; + for (int k = 0; k < KIntK; ++k) { + for (int m = 0; m < KIntM; ++m) { + sumPmwkTruEt[ieta][ipt][m][k] += std::pow(et, m); + } + sumWkTruEt[ieta][ipt][k]++; + } + } + } + } - // ipt = 1 - { - const int ipt = 1; - float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; - if (std::isfinite(c2Sub)) - histos.fill(HIST("MCReco/Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); - float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) - histos.fill(HIST("MCReco/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); - } + } // end truth loop + + for (const auto& track : trackSlice) { + if (!isTrackSelected(track)) + continue; + float pt = track.pt(); + float eta = track.eta(); + float p = track.p(); + float phi = track.phi(); + + float effIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 0); + float fakeIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 1); + float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); + float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; + if (!std::isfinite(wIncl) || wIncl <= 0.f) + continue; + if (effIncl <= 0 || !isfinite(effIncl) || !isfinite(fakeIncl) || !isfinite(flatWeightIncl)) + continue; + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; + for (int k = 0; k < KIntK; ++k) { + for (int m = 0; m < KIntM; ++m) { + sumPmwkReco[ieta][ipt][m][k] += std::pow(1.0f, k) * std::pow(pt, m); + sumPmwkRecoEffCor[ieta][ipt][m][k] += std::pow(wIncl, k) * std::pow(pt, m); + } + sumWkReco[ieta][ipt][k] += std::pow(1.0f, k); + sumWkRecoEffCor[ieta][ipt][k] += std::pow(wIncl, k); + } + } + } + + const bool isPion = selectionPion(track); + const bool isKaon = selectionKaon(track); + const bool isProton = selectionProton(track); + + if (isPion || isKaon || isProton) { + float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus + : o2::constants::physics::MassProton; + float energy = std::sqrt(p * p + m * m); + float et = energy * (pt / p); // E_T = E * sin(theta) + float effPid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 0); + float fakePid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 1); + float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); + float wPid = flatWeightPid * (1.0 - fakePid) / effPid; + if (effPid >= 1.f || fakePid >= 1.f || !isfinite(effPid) || effPid <= KFloatEpsilon || !isfinite(fakePid) || !isfinite(flatWeightPid)) + continue; + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; + for (int k = 0; k < KIntK; ++k) { + for (int m = 0; m < KIntM; ++m) { + sumPmwkRecoEt[ieta][ipt][m][k] += std::pow(1.0f, k) * std::pow(et, m); + sumPmwkRecoEffCorEt[ieta][ipt][m][k] += std::pow(wPid, k) * std::pow(et, m); + } + sumWkRecoEt[ieta][ipt][k] += std::pow(1.0f, k); + sumWkRecoEffCorEt[ieta][ipt][k] += std::pow(wPid, k); + } + } + } + } + + for (int ieta = 0; ieta < KNEta; ++ieta) { + for (int ipt = 0; ipt < KNpT; ++ipt) { + const int ibx = pmeanTruNchEtabinPtbinStep2->GetXaxis()->FindBin(col.multNTracksPV()); + const int iby = ieta + 1; + const int ibz = ipt + 1; + + float mmptTru = pmeanTruNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmptReco = pmeanRecoNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmptRecoEffCor = pmeanRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmetTru = pmeanEtTruNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmetReco = pmeanEtRecoNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmetRecoEffCor = pmeanEtRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + + if (isfinite(mmptTru)) + std::tie(meanTru[ieta][ipt], c2Tru[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkTru[ieta][ipt], sumWkTru[ieta][ipt], mmptTru); + if (isfinite(mmptReco)) + std::tie(meanReco[ieta][ipt], c2Reco[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkReco[ieta][ipt], sumWkReco[ieta][ipt], mmptReco); + if (isfinite(mmptRecoEffCor)) + std::tie(meanRecoEffCor[ieta][ipt], c2RecoEffCor[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEffCor[ieta][ipt], sumWkRecoEffCor[ieta][ipt], mmptRecoEffCor); + + if (isfinite(mmetTru)) + std::tie(meanTruEt[ieta][ipt], c2TruEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkTruEt[ieta][ipt], sumWkTruEt[ieta][ipt], mmetTru); + if (isfinite(mmetReco)) + std::tie(meanRecoEt[ieta][ipt], c2RecoEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEt[ieta][ipt], sumWkRecoEt[ieta][ipt], mmetReco); + if (isfinite(mmetRecoEffCor)) + std::tie(meanRecoEffCorEt[ieta][ipt], c2RecoEffCorEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEffCorEt[ieta][ipt], sumWkRecoEffCorEt[ieta][ipt], mmetRecoEffCor); + } + } + } + if (std::isfinite(c2Tru[0][0])) { + histos.fill(HIST("MCGen/Prof_C2_Cent"), cent, c2Tru[0][0]); + histos.fill(HIST("MCGen/Prof_C2_Mult"), col.multNTracksPV(), c2Tru[0][0]); + } + if (std::isfinite(c2TruEt[0][0])) { + histos.fill(HIST("MCGen/Prof_C2Et_Cent"), cent, c2TruEt[0][0]); + histos.fill(HIST("MCGen/Prof_C2Et_Mult"), col.multNTracksPV(), c2TruEt[0][0]); + } + // "MCReco" + if (std::isfinite(c2Reco[0][0])) { + histos.fill(HIST("MCReco/Prof_C2_Cent"), cent, c2Reco[0][0]); + histos.fill(HIST("MCReco/Prof_C2_Mult"), col.multNTracksPV(), c2Reco[0][0]); + } + if (std::isfinite(c2RecoEt[0][0])) { + histos.fill(HIST("MCReco/Prof_C2Et_Cent"), cent, c2RecoEt[0][0]); + histos.fill(HIST("MCReco/Prof_C2Et_Mult"), col.multNTracksPV(), c2RecoEt[0][0]); + } + + if (std::isfinite(c2RecoEffCor[0][0])) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2_Cent"), cent, c2RecoEffCor[0][0]); + histos.fill(HIST("MCRecoEffCorr/Prof_C2_Mult"), col.multNTracksPV(), c2RecoEffCor[0][0]); + } + if (std::isfinite(c2RecoEffCorEt[0][0])) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2Et_Cent"), cent, c2RecoEffCorEt[0][0]); + histos.fill(HIST("MCRecoEffCorr/Prof_C2Et_Mult"), col.multNTracksPV(), c2RecoEffCorEt[0][0]); + } + + if (std::isfinite(sumWkTru[0][0][1])) { + histos.fill(HIST("MCGen/Prof_cent_Nchrec"), cent, sumWkTru[0][0][1]); + histos.fill(HIST("MCGen/Prof_MeanpT_Cent"), cent, meanTru[0][0]); + histos.fill(HIST("MCGen/Prof_MeanpT_Mult"), col.multNTracksPV(), meanTru[0][0]); + } + if (std::isfinite(sumWkTruEt[0][0][1])) { + histos.fill(HIST("MCGen/Prof_MeanEt_Cent"), cent, meanTruEt[0][0]); + histos.fill(HIST("MCGen/Prof_MeanEt_Mult"), col.multNTracksPV(), meanTruEt[0][0]); + } + // "MCReco" + if (std::isfinite(sumWkReco[0][0][1])) { + histos.fill(HIST("MCReco/Prof_cent_Nchrec"), cent, sumWkReco[0][0][1]); + histos.fill(HIST("MCReco/Prof_MeanpT_Cent"), cent, meanReco[0][0]); + histos.fill(HIST("MCReco/Prof_MeanpT_Mult"), col.multNTracksPV(), meanReco[0][0]); + } + if (std::isfinite(sumWkRecoEt[0][0][1])) { + histos.fill(HIST("MCReco/Prof_MeanEt_Cent"), cent, meanRecoEt[0][0]); + histos.fill(HIST("MCReco/Prof_MeanEt_Mult"), col.multNTracksPV(), meanRecoEt[0][0]); + } + // "MCRecoEffCorr" + if (std::isfinite(sumWkRecoEffCor[0][0][1])) { + histos.fill(HIST("MCRecoEffCorr/Prof_cent_Nchrec"), cent, sumWkRecoEffCor[0][0][1]); + histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Cent"), cent, meanRecoEffCor[0][0]); + histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Mult"), col.multNTracksPV(), meanRecoEffCor[0][0]); + } + if (std::isfinite(sumWkRecoEffCorEt[0][0][1])) { + histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Cent"), cent, meanRecoEffCorEt[0][0]); + histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Mult"), col.multNTracksPV(), meanRecoEffCorEt[0][0]); + } + + for (int ieta = 0; ieta < KNEta; ++ieta) { + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (std::isfinite(sumWkTru[ieta][ipt][1])) + histos.fill(HIST("pmeanTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanTru[ieta][ipt]); + if (std::isfinite(sumWkReco[ieta][ipt][1])) + histos.fill(HIST("pmeanRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanReco[ieta][ipt]); + if (std::isfinite(sumWkRecoEffCor[ieta][ipt][1])) + histos.fill(HIST("pmeanRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanRecoEffCor[ieta][ipt]); + if (std::isfinite(sumWkTruEt[ieta][ipt][1])) + histos.fill(HIST("pmeanEtTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanTruEt[ieta][ipt]); + if (std::isfinite(sumWkRecoEt[ieta][ipt][1])) + histos.fill(HIST("pmeanEtRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanRecoEt[ieta][ipt]); + if (std::isfinite(sumWkRecoEffCorEt[ieta][ipt][1])) + histos.fill(HIST("pmeanEtRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanRecoEffCorEt[ieta][ipt]); + } + } + + float p1kBarTru[KNEta][KNpT]{}, p1kBarReco[KNEta][KNpT]{}, p1kBarRecoEffCor[KNEta][KNpT]{}; + float p1kBarTruEt[KNEta][KNpT]{}, p1kBarRecoEt[KNEta][KNpT]{}, p1kBarRecoEffCorEt[KNEta][KNpT]{}; + for (int ieta = 0; ieta < KNEta; ++ieta) { + for (int ipt = 0; ipt < KNpT; ++ipt) { + const int ibx = pmeanTruNchEtabinPtbinStep2->GetXaxis()->FindBin(col.multNTracksPV()); + const int iby = ieta + 1; + const int ibz = ipt + 1; + + float mmptTru = pmeanTruNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmptReco = pmeanRecoNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmptRecoEffCor = pmeanRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmetTru = pmeanEtTruNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmetReco = pmeanEtRecoNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmetRecoEffCor = pmeanEtRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + + if (mmptTru != 0.0f) p1kBarTru[ieta][ipt] = meanTru[ieta][ipt] - mmptTru; + if (mmptReco != 0.0f) p1kBarReco[ieta][ipt] = meanReco[ieta][ipt] - mmptReco; + if (mmptRecoEffCor != 0.0f) p1kBarRecoEffCor[ieta][ipt] = meanRecoEffCor[ieta][ipt] - mmptRecoEffCor; + + if (mmetTru != 0.0f) p1kBarTruEt[ieta][ipt] = meanTruEt[ieta][ipt] - mmetTru; + if (mmetReco != 0.0f) p1kBarRecoEt[ieta][ipt] = meanRecoEt[ieta][ipt] - mmetReco; + if (mmetRecoEffCor != 0.0f) p1kBarRecoEffCorEt[ieta][ipt] = meanRecoEffCorEt[ieta][ipt] - mmetRecoEffCor; + } + } + + // 1D Covariance (vs eta) + for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { + int ietaC = KNEta - ietaA; + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); + { + const int ipt = 0; + float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCGen/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCGen/Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("MCGen/Prof_ipt0_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCGen/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCGen/Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("MCGen/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); + } + } + // ipt = 1 + { + const int ipt = 1; + float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCGen/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCGen/Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("MCGen/Prof_ipt0_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCGen/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCGen/Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("MCGen/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); + } + } + // ipt = 2 + { + const int ipt = 2; + float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCGen/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCGen/Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("MCGen/Prof_ipt2_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCGen/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCGen/Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("MCGen/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); + } + } + } + + for (int ietaA = 1; ietaA < KNEta; ++ietaA) { + for (int ietaC = 1; ietaC < KNEta; ++ietaC) { + float valx = KHalf * (etaLw[ietaA] + etaUp[ietaA]); + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); + // ipt = 0 + { + const int ipt = 0; + float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCGen/Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCGen/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + } + // ipt = 1 + { + const int ipt = 1; + float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCGen/Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCGen/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + } + // ipt = 2 + { + const int ipt = 2; + float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCGen/Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCGen/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + } + } + } + + for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { + int ietaC = KNEta - ietaA; + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); + // ipt = 0 + { + const int ipt = 0; + float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCReco/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCReco/Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("MCReco/Prof_ipt0_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCReco/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCReco/Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("MCReco/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); + } + } + + // ipt = 1 + { + const int ipt = 1; + float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCReco/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCReco/Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("MCReco/Prof_ipt1_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCReco/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCReco/Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("MCReco/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); + } + } + + // ipt = 2 + { + const int ipt = 2; + float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCReco/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCReco/Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("MCReco/Prof_ipt2_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCReco/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCReco/Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("MCReco/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); + } + } + } + + for (int ietaA = 1; ietaA < KNEta; ++ietaA) { + for (int ietaC = 1; ietaC < KNEta; ++ietaC) { + float valx = KHalf * (etaLw[ietaA] + etaUp[ietaA]); + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); + + // ipt = 0 + { + const int ipt = 0; + float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCReco/Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCReco/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + } + + // ipt = 1 + { + const int ipt = 1; + float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCReco/Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCReco/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + } + + // ipt = 2 + { + const int ipt = 2; + float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCReco/Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCReco/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + } + } + } + + for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { + int ietaC = KNEta - ietaA; + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); + + // ipt = 0 + { + const int ipt = 0; + float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); + } + } + + // ipt = 1 + { + const int ipt = 1; + float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); + } + } + + // ipt = 2 + { + const int ipt = 2; + float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); + } + } + } - // ipt = 2 - { - const int ipt = 2; - float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; - if (std::isfinite(c2Sub)) - histos.fill(HIST("MCReco/Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); - float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) - histos.fill(HIST("MCReco/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + for (int ietaA = 1; ietaA < KNEta; ++ietaA) { + for (int ietaC = 1; ietaC < KNEta; ++ietaC) { + float valx = 0.5f * (etaLw[ietaA] + etaUp[ietaA]); + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); + + // ipt = 0 + { + const int ipt = 0; + float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + } + + // ipt = 1 + { + const int ipt = 1; + float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + } + + // ipt = 2 + { + const int ipt = 2; + float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + } + } + } + + } } + LOGF(info, "FINISHED RUNNING processMCFluc (pT + Et)"); } - } - - // --- MCRecoEffCorr Covariance (1D vs eta) --- - for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { - int ietaC = KNEta - ietaA; - float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); + PROCESS_SWITCH(RadialFlowDecorr, processMCFluc, "process MC to calculate pt/Et fluc", cfgRunMCFluc); - // ipt = 0 + void processGetFlat(AodCollisionsSel::iterator const& coll, aod::BCsWithTimestamps const&, AodTracksSel const& tracks) { - const int ipt = 0; - float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("MCRecoEffCorr/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); - histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_Cov_Eta"), valy, c2Sub); - } - float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("MCRecoEffCorr/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); - histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); + if (!isEventSelected(coll)) return; + float cent = getCentrality(coll); + if (cent > KCentMax) return; + for (const auto& track : tracks) { + if (!isTrackSelected(track)) continue; + float p = track.p(); + float eta = track.eta(); + float phi = track.phi(); + if (p < KFloatEpsilon) continue; + histos.fill(HIST("hCentEtaPhi"), cent, eta, phi); + const bool isPion = selectionPion(track); + const bool isKaon = selectionKaon(track); + const bool isProton = selectionProton(track); + if (isPion || isKaon || isProton) { + histos.fill(HIST("hCentEtaPhi_PID"), cent, eta, phi); + } } } + PROCESS_SWITCH(RadialFlowDecorr, processGetFlat, "process real data to calculate mean pT and Et", cfgRunGetFlat); - // ipt = 1 + void processDataMean(AodCollisionsSel::iterator const& coll, aod::BCsWithTimestamps const&, AodTracksSel const& tracks) { - const int ipt = 1; - float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("MCRecoEffCorr/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); - histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_Cov_Eta"), valy, c2Sub); + float sumWi[KNEta][KNpT]{}, sumWipti[KNEta][KNpT]{}; + float sumWiEt[KNEta][KNpT]{}, sumWiEtVal[KNEta][KNpT]{}; + if (!isEventSelected(coll)) return; + + float cent = getCentrality(coll); + if (cent > KCentMax) return; + + histos.fill(HIST("hZvtx_after_sel"), coll.posZ()); + histos.fill(HIST("hCentrality"), cent); + + histos.fill(HIST("Hist2D_globalTracks_PVTracks"), coll.multNTracksPV(), tracks.size()); + histos.fill(HIST("Hist2D_cent_nch"), tracks.size(), cent); + + for (const auto& track : tracks) { + if (!isTrackSelected(track)) continue; + float pt = track.pt(); + float eta = track.eta(); + float p = track.p(); + float phi = track.phi(); + if (p < KFloatEpsilon) continue; + histos.fill(HIST("hP"), p); + histos.fill(HIST("hPt"), pt); + histos.fill(HIST("hEta"), eta); + histos.fill(HIST("hPhi"), track.phi()); + + float effIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 0); + float fakeIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 1); + float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); + float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; + if (!std::isfinite(wIncl) || wIncl <= KFloatEpsilon || effIncl <= KFloatEpsilon) continue; + + histos.fill(HIST("hCentEtaPhi"), cent, eta, track.phi()); + histos.fill(HIST("hCentEtaPhiWtd"), cent, eta, track.phi(), flatWeightIncl); + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; + sumWi[ieta][ipt] += wIncl; + sumWipti[ieta][ipt] += wIncl * pt; + } + } + + const bool isPion = selectionPion(track); + const bool isKaon = selectionKaon(track); + const bool isProton = selectionProton(track); + if (isPion || isKaon || isProton) { + + float effPid = getEfficiency(coll.multNTracksPV(), pt, eta, kCombinedPID, 0); + float fakePid = getEfficiency(coll.multNTracksPV(), pt, eta, kCombinedPID, 1); + float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); + float wPid = flatWeightPid * (1.0 - fakePid) / effPid; + if (!std::isfinite(wPid) || wPid <= KFloatEpsilon || effPid <= KFloatEpsilon) + continue; + + histos.fill(HIST("hCentEtaPhiWtd_PID"), cent, eta, track.phi(), flatWeightPid); + float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus + : o2::constants::physics::MassProton; + float energy = std::sqrt(p * p + m * m); + float et = energy * (pt / p); // E_T = E * sin(theta) + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; + sumWiEt[ieta][ipt] += wPid; + sumWiEtVal[ieta][ipt] += wPid * et; + } + } + } } - float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("MCRecoEffCorr/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); - histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); + histos.fill(HIST("Prof_cent_Nchrec"), cent, sumWi[0][0]); + if (isfinite(sumWi[0][0])) histos.fill(HIST("Prof_MeanpT_Cent"), cent, sumWipti[0][0] / sumWi[0][0]); + if (isfinite(sumWiEt[0][0])) histos.fill(HIST("Prof_MeanEt_Cent"), cent, sumWiEtVal[0][0] / sumWiEt[0][0]); + + for (int ieta = 0; ieta < KNEta; ++ieta) { + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (isfinite(sumWi[ieta][ipt])) + histos.fill(HIST("pmean_nch_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, sumWipti[ieta][ipt] / sumWi[ieta][ipt]); + if (isfinite(sumWiEt[ieta][ipt])) + histos.fill(HIST("pmeanEt_nch_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, sumWiEtVal[ieta][ipt] / sumWiEt[ieta][ipt]); + } } } + PROCESS_SWITCH(RadialFlowDecorr, processDataMean, "process real data to calculate mean pT and Et", cfgRunDataMean); - // ipt = 2 + void processDataFluc(AodCollisionsSel::iterator const& coll, aod::BCsWithTimestamps const&, AodTracksSel const& tracks) { - const int ipt = 2; - float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("MCRecoEffCorr/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); - histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_Cov_Eta"), valy, c2Sub); + if (!isEventSelected(coll)) + return; + float cent = getCentrality(coll); + if (cent > KCentMax) + return; + if (!pmeanNchEtabinPtbinStep2 || !pmeanEtNchEtabinPtbinStep2) { + LOGF(warning, "Data fluc: Mean pT or Et map missing"); + return; } - float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("MCRecoEffCorr/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); - histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); + + if (!hEff[kInclusive] || !hFake[kInclusive] || !hWeightMap3D[kInclusive] || !hEff[kCombinedPID] || !hFake[kCombinedPID] || !hWeightMap3D[kCombinedPID]) { + LOGF(warning, "Data fluc: Inclusive or PID correction maps are null"); + return; } - } - } + double sumpmwk[KNEta][KNpT][KIntM][KIntK]{}; + double sumwk[KNEta][KNpT][KIntK]{}; + double sumpmwkEt[KNEta][KNpT][KIntM][KIntK]{}; + double sumwkEt[KNEta][KNpT][KIntK]{}; + double mean[KNEta][KNpT]{}, c2[KNEta][KNpT]{}; + double p1kBar[KNEta][KNpT]{}; + double meanEt[KNEta][KNpT]{}, c2Et[KNEta][KNpT]{}; + double p1kBarEt[KNEta][KNpT]{}; + + for (const auto& track : tracks) { + if (!isTrackSelected(track)) + continue; + float pt = track.pt(); + float eta = track.eta(); + float p = track.p(); + float phi = track.phi(); + if (p < KFloatEpsilon) + continue; + + float effIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 0); + float fakeIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 1); + float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); + + float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; + if (!std::isfinite(wIncl) || wIncl <= KFloatEpsilon || effIncl <= KFloatEpsilon) + continue; + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; + for (int k = 0; k < KIntK; ++k) { + for (int m = 0; m < KIntM; ++m) + sumpmwk[ieta][ipt][m][k] += std::pow(wIncl, k) * std::pow(pt, m); + sumwk[ieta][ipt][k] += std::pow(wIncl, k); + } + } + } + + const bool isPion = selectionPion(track); + const bool isKaon = selectionKaon(track); + const bool isProton = selectionProton(track); + if (isPion || isKaon || isProton) { + float effPid = getEfficiency(coll.multNTracksPV(), pt, eta, kCombinedPID, 0); + float fakePid = getEfficiency(coll.multNTracksPV(), pt, eta, kCombinedPID, 1); + float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); + + float wPid = flatWeightPid * (1.0 - fakePid) / effPid; + if (!std::isfinite(wPid) || wPid <= KFloatEpsilon || effPid <= KFloatEpsilon) + continue; + + float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus + : o2::constants::physics::MassProton; - // --- MCRecoEffCorr Covariance (2D etaA vs etaC) --- - for (int ietaA = 1; ietaA < KNEta; ++ietaA) { - for (int ietaC = 1; ietaC < KNEta; ++ietaC) { - float valx = 0.5f * (etaLw[ietaA] + etaUp[ietaA]); - float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); - - // ipt = 0 - { - const int ipt = 0; - float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; - if (std::isfinite(c2Sub)) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); - float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + float energy = std::sqrt(p * p + m * m); + float et = energy * (pt / p); // E_T = E * sin(theta) + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; + for (int k = 0; k < KIntK; ++k) { + for (int m = 0; m < KIntM; ++m) + sumpmwkEt[ieta][ipt][m][k] += std::pow(wPid, k) * std::pow(et, m); + sumwkEt[ieta][ipt][k] += std::pow(wPid, k); + } + } + } + } } - // ipt = 1 - { - const int ipt = 1; - float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; - if (std::isfinite(c2Sub)) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); - float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + for (int ieta = 0; ieta < KNEta; ++ieta){ + for (int ipt = 0; ipt < KNpT; ++ipt) { + const int ibx = pmeanNchEtabinPtbinStep2->GetXaxis()->FindBin(coll.multNTracksPV()); + const int iby = ieta + 1; + const int ibz = ipt + 1; + float mmpt = pmeanNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmet = pmeanEtNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + + mean[ieta][ipt] = sumpmwk[ieta][ipt][1][1] / sumwk[ieta][ipt][1]; + meanEt[ieta][ipt] = sumpmwkEt[ieta][ipt][1][1] / sumwkEt[ieta][ipt][1]; + + if (std::isfinite(mmpt)) { + std::tie(mean[ieta][ipt], c2[ieta][ipt]) = + calculateMeanAndC2FromSums(sumpmwk[ieta][ipt], sumwk[ieta][ipt], mmpt); + p1kBar[ieta][ipt] = mean[ieta][ipt] - mmpt; + } + if (std::isfinite(mmet)) { + std::tie(meanEt[ieta][ipt], c2Et[ieta][ipt]) = + calculateMeanAndC2FromSums(sumpmwkEt[ieta][ipt], sumwkEt[ieta][ipt], mmet); + p1kBarEt[ieta][ipt] = meanEt[ieta][ipt] - mmet; + } + } } - // ipt = 2 - { - const int ipt = 2; - float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; - if (std::isfinite(c2Sub)) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); - float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + if (std::isfinite(c2[0][0])) histos.fill(HIST("Prof_C2_Cent"), cent, c2[0][0]); + if (std::isfinite(c2Et[0][0])) histos.fill(HIST("Prof_C2Et_Cent"), cent, c2Et[0][0]); + if (std::isfinite(sumwk[0][0][1])) { + histos.fill(HIST("Prof_MeanpT_Cent"), cent, mean[0][0]); + histos.fill(HIST("Prof_MeanpT_Mult"), coll.multNTracksPV(), mean[0][0]); } - } - } - } - } - LOGF(info, "FINISHED RUNNING processMCFluc (pT + Et)"); - } - PROCESS_SWITCH(RadialFlowDecorr, processMCFluc, "process MC to calculate pt/Et fluc", cfgRunMCFluc); - - void processGetFlat(AodCollisionsSel::iterator const& coll, aod::BCsWithTimestamps const&, AodTracksSel const& tracks) - { - if (!isEventSelected(coll)) - return; - float cent = getCentrality(coll); - if (cent > KCentMax) - return; - for (const auto& track : tracks) { - if (!isTrackSelected(track)) - continue; - float p = track.p(); // ADDED - float eta = track.eta(); - float phi = track.phi(); - if (p < KFloatEpsilon) - continue; - histos.fill(HIST("hCentEtaPhi"), cent, eta, phi); - const bool isPion = selectionPion(track); - const bool isKaon = selectionKaon(track); - const bool isProton = selectionProton(track); - if (isPion || isKaon || isProton) { - histos.fill(HIST("hCentEtaPhi_PID"), cent, eta, phi); - } - } - } - PROCESS_SWITCH(RadialFlowDecorr, processGetFlat, "process real data to calculate mean pT and Et", cfgRunGetFlat); - - void processDataMean(AodCollisionsSel::iterator const& coll, aod::BCsWithTimestamps const&, AodTracksSel const& tracks) - { - float sumWi[KNEta][KNpT]{}, sumWipti[KNEta][KNpT]{}; - float sumWiEt[KNEta][KNpT]{}, sumWiEtVal[KNEta][KNpT]{}; - if (!isEventSelected(coll)) - return; - float cent = getCentrality(coll); - if (cent > KCentMax) - return; - histos.fill(HIST("hZvtx_after_sel"), coll.posZ()); - histos.fill(HIST("hCentrality"), cent); - - histos.fill(HIST("Hist2D_globalTracks_PVTracks"), coll.multNTracksPV(), tracks.size()); - histos.fill(HIST("Hist2D_cent_nch"), tracks.size(), cent); - - for (const auto& track : tracks) { - if (!isTrackSelected(track)) - continue; - float pt = track.pt(); - float eta = track.eta(); - float p = track.p(); - float phi = track.phi(); - if (p < KFloatEpsilon) - continue; - histos.fill(HIST("hP"), p); - histos.fill(HIST("hPt"), pt); - histos.fill(HIST("hEta"), eta); - histos.fill(HIST("hPhi"), track.phi()); - - float effIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 0); - float fakeIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 1); - float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); - float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; - if (!std::isfinite(wIncl) || wIncl <= KFloatEpsilon || effIncl <= KFloatEpsilon) - continue; - - histos.fill(HIST("hCentEtaPhi"), cent, eta, track.phi()); - histos.fill(HIST("hCentEtaPhiWtd"), cent, eta, track.phi(), flatWeightIncl); - - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) - continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) - continue; - sumWi[ieta][ipt] += wIncl; - sumWipti[ieta][ipt] += wIncl * pt; - } - } - - const bool isPion = selectionPion(track); - const bool isKaon = selectionKaon(track); - const bool isProton = selectionProton(track); - if (isPion || isKaon || isProton) { - - float effPid = getEfficiency(coll.multNTracksPV(), pt, eta, kCombinedPID, 0); - float fakePid = getEfficiency(coll.multNTracksPV(), pt, eta, kCombinedPID, 1); - float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); - float wPid = flatWeightPid * (1.0 - fakePid) / effPid; - if (!std::isfinite(wPid) || wPid <= KFloatEpsilon || effPid <= KFloatEpsilon) - continue; - - histos.fill(HIST("hCentEtaPhiWtd_PID"), cent, eta, track.phi(), flatWeightPid); - float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus - : o2::constants::physics::MassProton; - float E = std::sqrt(p * p + m * m); - float Et = E * (pt / p); // E_T = E * sin(theta) - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) - continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) - continue; - sumWiEt[ieta][ipt] += wPid; - sumWiEtVal[ieta][ipt] += wPid * Et; - } - } - } - } - histos.fill(HIST("Prof_cent_Nchrec"), cent, sumWi[0][0]); - if (isfinite(sumWi[0][0])) - histos.fill(HIST("Prof_MeanpT_Cent"), cent, sumWipti[0][0] / sumWi[0][0]); - if (isfinite(sumWiEt[0][0])) - histos.fill(HIST("Prof_MeanEt_Cent"), cent, sumWiEtVal[0][0] / sumWiEt[0][0]); - - for (int ieta = 0; ieta < KNEta; ++ieta) { - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (isfinite(sumWi[ieta][ipt])) - histos.fill(HIST("pmean_nch_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, - sumWipti[ieta][ipt] / sumWi[ieta][ipt]); - if (isfinite(sumWiEt[ieta][ipt])) - histos.fill(HIST("pmeanEt_nch_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, - sumWiEtVal[ieta][ipt] / sumWiEt[ieta][ipt]); - } - } - } - PROCESS_SWITCH(RadialFlowDecorr, processDataMean, "process real data to calculate mean pT and Et", cfgRunDataMean); - - void processDataFluc(AodCollisionsSel::iterator const& coll, aod::BCsWithTimestamps const&, AodTracksSel const& tracks) - { - if (!isEventSelected(coll)) - return; - float cent = getCentrality(coll); - if (cent > KCentMax) - return; - if (!pmeanNchEtabinPtbinStep2 || !pmeanEtNchEtabinPtbinStep2) { - LOGF(warning, "Data fluc: Mean pT or Et map missing"); - return; - } - - if (!hEff[kInclusive] || !hFake[kInclusive] || !hWeightMap3D[kInclusive] || !hEff[kCombinedPID] || !hFake[kCombinedPID] || !hWeightMap3D[kCombinedPID]) { - LOGF(warning, "Data fluc: Inclusive or PID correction maps are null"); - return; - } - double sumpmwk[KNEta][KNpT][KIntM][KIntK]{}; - double sumwk[KNEta][KNpT][KIntK]{}; - double sumpmwkEt[KNEta][KNpT][KIntM][KIntK]{}; - double sumwkEt[KNEta][KNpT][KIntK]{}; - double mean[KNEta][KNpT]{}, c2[KNEta][KNpT]{}; - double p1kBar[KNEta][KNpT]{}; - double meanEt[KNEta][KNpT]{}, c2Et[KNEta][KNpT]{}; - double p1kBarEt[KNEta][KNpT]{}; - - for (const auto& track : tracks) { - if (!isTrackSelected(track)) - continue; - float pt = track.pt(); - float eta = track.eta(); - float p = track.p(); - float phi = track.phi(); - if (p < KFloatEpsilon) - continue; - - float effIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 0); - float fakeIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 1); - float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); - - float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; - if (!std::isfinite(wIncl) || wIncl <= KFloatEpsilon || effIncl <= KFloatEpsilon) - continue; - - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) - continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) - continue; - for (int k = 0; k < KIntK; ++k) { - for (int m = 0; m < KIntM; ++m) - sumpmwk[ieta][ipt][m][k] += std::pow(wIncl, k) * std::pow(pt, m); - sumwk[ieta][ipt][k] += std::pow(wIncl, k); - } - } - } - - const bool isPion = selectionPion(track); - const bool isKaon = selectionKaon(track); - const bool isProton = selectionProton(track); - if (isPion || isKaon || isProton) { - float effPid = getEfficiency(coll.multNTracksPV(), pt, eta, kCombinedPID, 0); - float fakePid = getEfficiency(coll.multNTracksPV(), pt, eta, kCombinedPID, 1); - float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); - - float wPid = flatWeightPid * (1.0 - fakePid) / effPid; - if (!std::isfinite(wPid) || wPid <= KFloatEpsilon || effPid <= KFloatEpsilon) - continue; - - float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus - : o2::constants::physics::MassProton; - - float E = std::sqrt(p * p + m * m); - float Et = E * (pt / p); // E_T = E * sin(theta) - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) - continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) - continue; - for (int k = 0; k < KIntK; ++k) { - for (int m = 0; m < KIntM; ++m) - sumpmwkEt[ieta][ipt][m][k] += std::pow(wPid, k) * std::pow(Et, m); - sumwkEt[ieta][ipt][k] += std::pow(wPid, k); + if (std::isfinite(sumwkEt[0][0][1])) { + histos.fill(HIST("Prof_MeanEt_Cent"), cent, meanEt[0][0]); + histos.fill(HIST("Prof_MeanEt_Mult"), coll.multNTracksPV(), meanEt[0][0]); } - } - } - } - } - for (int ieta = 0; ieta < KNEta; ++ieta) - for (int ipt = 0; ipt < KNpT; ++ipt) { - const int ibx = pmeanNchEtabinPtbinStep2->GetXaxis()->FindBin(coll.multNTracksPV()); - const int iby = ieta + 1; - const int ibz = ipt + 1; - float mmpt = pmeanNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmet = pmeanEtNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - - mean[ieta][ipt] = sumpmwk[ieta][ipt][1][1] / sumwk[ieta][ipt][1]; - meanEt[ieta][ipt] = sumpmwkEt[ieta][ipt][1][1] / sumwkEt[ieta][ipt][1]; - - if (std::isfinite(mmpt)) { - std::tie(mean[ieta][ipt], c2[ieta][ipt]) = - calculateMeanAndC2FromSums(sumpmwk[ieta][ipt], sumwk[ieta][ipt], mmpt); - p1kBar[ieta][ipt] = mean[ieta][ipt] - mmpt; - } - if (std::isfinite(mmet)) { - std::tie(meanEt[ieta][ipt], c2Et[ieta][ipt]) = - calculateMeanAndC2FromSums(sumpmwkEt[ieta][ipt], sumwkEt[ieta][ipt], mmet); - p1kBarEt[ieta][ipt] = meanEt[ieta][ipt] - mmet; - } - } - - if (std::isfinite(c2[0][0])) - histos.fill(HIST("Prof_C2_Cent"), cent, c2[0][0]); - if (std::isfinite(c2Et[0][0])) - histos.fill(HIST("Prof_C2Et_Cent"), cent, c2Et[0][0]); - if (std::isfinite(sumwk[0][0][1])) { - histos.fill(HIST("Prof_MeanpT_Cent"), cent, mean[0][0]); - histos.fill(HIST("Prof_MeanpT_Mult"), coll.multNTracksPV(), mean[0][0]); - } - if (std::isfinite(sumwkEt[0][0][1])) { - histos.fill(HIST("Prof_MeanEt_Cent"), cent, meanEt[0][0]); - histos.fill(HIST("Prof_MeanEt_Mult"), coll.multNTracksPV(), meanEt[0][0]); - } - - for (int ieta = 0; ieta < KNEta; ++ieta) - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (std::isfinite(c2[ieta][ipt])) - histos.fill(HIST("Prof_C2_Mult_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, c2[ieta][ipt]); - if (std::isfinite(c2Et[ieta][ipt])) - histos.fill(HIST("Prof_C2Et_Mult_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, c2Et[ieta][ipt]); - } - - for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { - int ietaC = KNEta - ietaA; - float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); - - { - const int ipt = 0; - float c2Sub = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("Prof_ipt0_Cov_Eta"), valy, c2Sub); - } - float c2SubEt = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("Prof_ipt0_CovEt_Eta"), valy, c2SubEt); - } - } - - { - const int ipt = 1; - float c2Sub = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("Prof_ipt1_Cov_Eta"), valy, c2Sub); - } - float c2SubEt = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("Prof_ipt1_CovEt_Eta"), valy, c2SubEt); - } - } - - { - const int ipt = 2; - float c2Sub = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("Prof_ipt2_Cov_Eta"), valy, c2Sub); - } - float c2SubEt = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("Prof_ipt2_CovEt_Eta"), valy, c2SubEt); - } - } - } - for (int ietaA = 1; ietaA < KNEta; ++ietaA) { - for (int ietaC = 1; ietaC < KNEta; ++ietaC) { - float valx = 0.5f * (etaLw[ietaA] + etaUp[ietaA]); - float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); - { - const int ipt = 0; - float covpt = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; - if (std::isfinite(covpt)) - histos.fill(HIST("Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, covpt); - - float covet = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; - if (std::isfinite(covet)) - histos.fill(HIST("Prof_ipt0_C2SubEt2D_Mult_etaA_etaC"), cent, valx, valy, covet); - } + for (int ieta = 0; ieta < KNEta; ++ieta){ + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (std::isfinite(c2[ieta][ipt])) + histos.fill(HIST("Prof_C2_Mult_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, c2[ieta][ipt]); + if (std::isfinite(c2Et[ieta][ipt])) + histos.fill(HIST("Prof_C2Et_Mult_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, c2Et[ieta][ipt]); + } + } - { - const int ipt = 1; - float covpt = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; - if (std::isfinite(covpt)) - histos.fill(HIST("Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, covpt); - - float covet = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; - if (std::isfinite(covet)) - histos.fill(HIST("Prof_ipt1_C2SubEt2D_Mult_etaA_etaC"), cent, valx, valy, covet); - } - { - const int ipt = 2; + for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { + int ietaC = KNEta - ietaA; + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); + + { + const int ipt = 0; + float c2Sub = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("Prof_ipt0_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("Prof_ipt0_CovEt_Eta"), valy, c2SubEt); + } + } + + { + const int ipt = 1; + float c2Sub = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("Prof_ipt1_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("Prof_ipt1_CovEt_Eta"), valy, c2SubEt); + } + } + + { + const int ipt = 2; + float c2Sub = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) histos.fill(HIST("Prof_ipt2_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) histos.fill(HIST("Prof_ipt2_CovEt_Eta"), valy, c2SubEt); + } + } + } + + for (int ietaA = 1; ietaA < KNEta; ++ietaA) { + for (int ietaC = 1; ietaC < KNEta; ++ietaC) { + float valx = KHalf * (etaLw[ietaA] + etaUp[ietaA]); + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); + { + const int ipt = 0; + float covpt = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; + if (std::isfinite(covpt)) + histos.fill(HIST("Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, covpt); + + float covet = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; + if (std::isfinite(covet)) + histos.fill(HIST("Prof_ipt0_C2SubEt2D_Mult_etaA_etaC"), cent, valx, valy, covet); + } + + { + const int ipt = 1; + float covpt = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; + if (std::isfinite(covpt)) + histos.fill(HIST("Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, covpt); + + float covet = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; + if (std::isfinite(covet)) + histos.fill(HIST("Prof_ipt1_C2SubEt2D_Mult_etaA_etaC"), cent, valx, valy, covet); + } + { + const int ipt = 2; - float covpt = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; - if (std::isfinite(covpt)) - histos.fill(HIST("Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, covpt); + float covpt = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; + if (std::isfinite(covpt)) + histos.fill(HIST("Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, covpt); - float covet = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; - if (std::isfinite(covet)) - histos.fill(HIST("Prof_ipt2_C2SubEt2D_Mult_etaA_etaC"), cent, valx, valy, covet); + float covet = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; + if (std::isfinite(covet)) + histos.fill(HIST("Prof_ipt2_C2SubEt2D_Mult_etaA_etaC"), cent, valx, valy, covet); + } + } + } + } + PROCESS_SWITCH(RadialFlowDecorr, processDataFluc, "process real data to calculate fluc pT and Et", cfgRunDataFluc); + }; + + WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) + { + WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; + return workflow; } - } - } - } - PROCESS_SWITCH(RadialFlowDecorr, processDataFluc, "process real data to calculate fluc pT and Et", cfgRunDataFluc); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; - return workflow; -} From 08c2426aaa2e6618489c0a0448f2d975c78ced4c Mon Sep 17 00:00:00 2001 From: Somadutta Bhatta Date: Tue, 11 Nov 2025 21:29:35 +0100 Subject: [PATCH 07/10] Apply clang-format to radialFlowDecorr.cxx --- .../Tasks/radialFlowDecorr.cxx | 4156 +++++++++-------- 1 file changed, 2112 insertions(+), 2044 deletions(-) diff --git a/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx b/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx index 7323496488c..68f2d90066e 100644 --- a/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx +++ b/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx @@ -121,2156 +121,2224 @@ struct RadialFlowDecorr { static constexpr float KPtFullMax = 10.0f; static constexpr float KCentMax = 90; enum PID { kInclusive = 0, - kCombinedPID, - kNumPID }; - enum ECentralityEstimator { - kCentFT0C = 1, - kCentFT0A = 2, - kCentFT0M = 3, - kCentFV0A = 4 - }; - static constexpr float KinvalidCentrality = -1.0f; - const std::vector pidSuffix = {"", "_PID"}; - - const std::vector etaLw = { - -0.8, - -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7}; - const std::vector etaUp = { - 0.8, - -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8}; - - const std::vector pTLw = {KPtMinDefault, KPtMinDefault, KPtMinDefault}; - const std::vector pTUp = {KPtMidMax, KPtHighMax, KPtFullMax}; - - Configurable cfgVtxZCut{"cfgVtxZCut", 10.f, "z-vertex range"}; - Configurable cfgPtMin{"cfgPtMin", 0.2f, "min pT"}; - Configurable cfgPtMax{"cfgPtMax", 10.0f, "max pT"}; - Configurable cfgEtaCut{"cfgEtaCut", 0.8f, "|η| cut"}; - Configurable cfgDCAXY{"cfgDCAXY", 2.4f, "DCAxy cut"}; - Configurable cfgDCAZ{"cfgDCAZ", 3.2f, "DCAz cut"}; - Configurable cfgTPCClsMin{"cfgTPCClsMin", 70.f, "min TPC clusters"}; - Configurable cfgChi2TPCMax{"cfgChi2TPCMax", 4.0f, "max TPC χ²"}; - Configurable cfgPIDnSigmaCut{"cfgPIDnSigmaCut", 3.f, "TPC PID |nσ| cut"}; - - Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; - Configurable cfgCutTpcChi2NCl{"cfgCutTpcChi2NCl", 2.5f, "Maximum TPCchi2NCl"}; - Configurable cfgCutItsChi2NCl{"cfgCutItsChi2NCl", 36.0f, "Maximum ITSchi2NCl"}; - Configurable cfgCutTracKDcaMaxZ{"cfgCutTracKDcaMaxZ", 2.0f, "Maximum DcaZ"}; - Configurable cfgCutTracKDcaMaxXY{"cfgCutTracKDcaMaxXY", 0.2f, "Maximum DcaZ"}; - - Configurable cfgITScluster{"cfgITScluster", 1, "Minimum Number of ITS cluster"}; - Configurable cfgTPCcluster{"cfgTPCcluster", 80, "Minimum Number of TPC cluster"}; - Configurable cfgTPCnCrossedRows{"cfgTPCnCrossedRows", 70, "Minimum Number of TPC crossed-rows"}; - Configurable cfgCutPtUpperTPC{"cfgCutPtUpperTPC", 0.6f, "Upper pT cut for PID using TPC only"}; - Configurable cfgnSigmaOtherParticles{"cfgnSigmaOtherParticles", 3.0f, "PID nSigma cut to remove other particles (default:3)"}; - Configurable cfgnSigmaCutTPC{"cfgnSigmaCutTPC", 2.0f, "PID nSigma cut for TPC"}; - Configurable cfgnSigmaCutTOF{"cfgnSigmaCutTOF", 2.0f, "PID nSigma cut for TOF"}; - Configurable cfgnSigmaCutCombTPCTOF{"cfgnSigmaCutCombTPCTOF", 2.0f, "PID nSigma combined cut for TPC and TOF"}; - Configurable cfgCutPtLower{"cfgCutPtLower", 0.2f, "Lower pT cut"}; - Configurable cfgCutPtLowerProt{"cfgCutPtLowerProt", 0.2f, "Lower pT cut"}; - Configurable cfgCutPtUpper{"cfgCutPtUpper", 10.0f, "Higher pT cut for inclusive hadron analysis"}; - Configurable cfgCutPtUpperPID{"cfgCutPtUpperPID", 6.0f, "Higher pT cut for identified particle analysis"}; - Configurable cfgCutEta{"cfgCutEta", 0.8f, "absolute Eta cut"}; - Configurable cfgCutEtaLeft{"cfgCutEtaLeft", 0.8f, "Left end of eta gap"}; - Configurable cfgCutEtaRight{"cfgCutEtaRight", 0.8f, "Right end of eta gap"}; - Configurable cfgNSubsample{"cfgNSubsample", 10, "Number of subsamples"}; - Configurable cfgCentralityChoice{"cfgCentralityChoice", 1, "Which centrality estimator? 1-->FT0C, 2-->FT0A, 3-->FT0M, 4-->FV0A"}; - Configurable cfgEvSelkNoSameBunchPileup{"cfgEvSelkNoSameBunchPileup", true, "Pileup removal"}; - Configurable cfgUseGoodITSLayerAllCut{"cfgUseGoodITSLayerAllCut", true, "Remove time interval with dead ITS zone"}; - Configurable cfgEvSelkNoITSROFrameBorder{"cfgEvSelkNoITSROFrameBorder", true, "ITSROFrame border event selection cut"}; - Configurable cfgEvSelkNoTimeFrameBorder{"cfgEvSelkNoTimeFrameBorder", true, "TimeFrame border event selection cut"}; - - Service ccdb; - Service pdg; - HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - - std::array hEff{}; - std::array hFake{}; - std::array hWeightMap3D{}; - - TProfile3D* pmeanTruNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanRecoNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanRecoMatchedNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanRecoEffcorrNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanRecoMatchedEffcorrNchEtabinPtbinStep2 = nullptr; - - TProfile3D* pmeanEtTruNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanEtRecoNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanEtRecoMatchedNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanEtRecoEffcorrNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanEtRecoMatchedEffcorrNchEtabinPtbinStep2 = nullptr; - - TProfile3D* pmeanNchEtabinPtbinStep2 = nullptr; - TProfile3D* pmeanEtNchEtabinPtbinStep2 = nullptr; - - template - bool isEventSelected(const T& col) - { - if (!col.sel8()) - return false; - if (std::abs(col.posZ()) > cfgCutVertex) - return false; - if (cfgEvSelkNoSameBunchPileup && !col.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) - return false; - if (cfgEvSelkNoITSROFrameBorder && !col.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) - return false; - if (cfgEvSelkNoTimeFrameBorder && !col.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) - return false; - return true; + kCombinedPID, + kNumPID }; + enum ECentralityEstimator { + kCentFT0C = 1, + kCentFT0A = 2, + kCentFT0M = 3, + kCentFV0A = 4 + }; + static constexpr float KinvalidCentrality = -1.0f; + const std::vector pidSuffix = {"", "_PID"}; + + const std::vector etaLw = { + -0.8, + -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7}; + const std::vector etaUp = { + 0.8, + -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8}; + + const std::vector pTLw = {KPtMinDefault, KPtMinDefault, KPtMinDefault}; + const std::vector pTUp = {KPtMidMax, KPtHighMax, KPtFullMax}; + + Configurable cfgVtxZCut{"cfgVtxZCut", 10.f, "z-vertex range"}; + Configurable cfgPtMin{"cfgPtMin", 0.2f, "min pT"}; + Configurable cfgPtMax{"cfgPtMax", 10.0f, "max pT"}; + Configurable cfgEtaCut{"cfgEtaCut", 0.8f, "|η| cut"}; + Configurable cfgDCAXY{"cfgDCAXY", 2.4f, "DCAxy cut"}; + Configurable cfgDCAZ{"cfgDCAZ", 3.2f, "DCAz cut"}; + Configurable cfgTPCClsMin{"cfgTPCClsMin", 70.f, "min TPC clusters"}; + Configurable cfgChi2TPCMax{"cfgChi2TPCMax", 4.0f, "max TPC χ²"}; + Configurable cfgPIDnSigmaCut{"cfgPIDnSigmaCut", 3.f, "TPC PID |nσ| cut"}; + + Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; + Configurable cfgCutTpcChi2NCl{"cfgCutTpcChi2NCl", 2.5f, "Maximum TPCchi2NCl"}; + Configurable cfgCutItsChi2NCl{"cfgCutItsChi2NCl", 36.0f, "Maximum ITSchi2NCl"}; + Configurable cfgCutTracKDcaMaxZ{"cfgCutTracKDcaMaxZ", 2.0f, "Maximum DcaZ"}; + Configurable cfgCutTracKDcaMaxXY{"cfgCutTracKDcaMaxXY", 0.2f, "Maximum DcaZ"}; + + Configurable cfgITScluster{"cfgITScluster", 1, "Minimum Number of ITS cluster"}; + Configurable cfgTPCcluster{"cfgTPCcluster", 80, "Minimum Number of TPC cluster"}; + Configurable cfgTPCnCrossedRows{"cfgTPCnCrossedRows", 70, "Minimum Number of TPC crossed-rows"}; + Configurable cfgCutPtUpperTPC{"cfgCutPtUpperTPC", 0.6f, "Upper pT cut for PID using TPC only"}; + Configurable cfgnSigmaOtherParticles{"cfgnSigmaOtherParticles", 3.0f, "PID nSigma cut to remove other particles (default:3)"}; + Configurable cfgnSigmaCutTPC{"cfgnSigmaCutTPC", 2.0f, "PID nSigma cut for TPC"}; + Configurable cfgnSigmaCutTOF{"cfgnSigmaCutTOF", 2.0f, "PID nSigma cut for TOF"}; + Configurable cfgnSigmaCutCombTPCTOF{"cfgnSigmaCutCombTPCTOF", 2.0f, "PID nSigma combined cut for TPC and TOF"}; + Configurable cfgCutPtLower{"cfgCutPtLower", 0.2f, "Lower pT cut"}; + Configurable cfgCutPtLowerProt{"cfgCutPtLowerProt", 0.2f, "Lower pT cut"}; + Configurable cfgCutPtUpper{"cfgCutPtUpper", 10.0f, "Higher pT cut for inclusive hadron analysis"}; + Configurable cfgCutPtUpperPID{"cfgCutPtUpperPID", 6.0f, "Higher pT cut for identified particle analysis"}; + Configurable cfgCutEta{"cfgCutEta", 0.8f, "absolute Eta cut"}; + Configurable cfgCutEtaLeft{"cfgCutEtaLeft", 0.8f, "Left end of eta gap"}; + Configurable cfgCutEtaRight{"cfgCutEtaRight", 0.8f, "Right end of eta gap"}; + Configurable cfgNSubsample{"cfgNSubsample", 10, "Number of subsamples"}; + Configurable cfgCentralityChoice{"cfgCentralityChoice", 1, "Which centrality estimator? 1-->FT0C, 2-->FT0A, 3-->FT0M, 4-->FV0A"}; + Configurable cfgEvSelkNoSameBunchPileup{"cfgEvSelkNoSameBunchPileup", true, "Pileup removal"}; + Configurable cfgUseGoodITSLayerAllCut{"cfgUseGoodITSLayerAllCut", true, "Remove time interval with dead ITS zone"}; + Configurable cfgEvSelkNoITSROFrameBorder{"cfgEvSelkNoITSROFrameBorder", true, "ITSROFrame border event selection cut"}; + Configurable cfgEvSelkNoTimeFrameBorder{"cfgEvSelkNoTimeFrameBorder", true, "TimeFrame border event selection cut"}; + + Service ccdb; + Service pdg; + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + std::array hEff{}; + std::array hFake{}; + std::array hWeightMap3D{}; + + TProfile3D* pmeanTruNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanRecoNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanRecoMatchedNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanRecoEffcorrNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanRecoMatchedEffcorrNchEtabinPtbinStep2 = nullptr; + + TProfile3D* pmeanEtTruNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanEtRecoNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanEtRecoMatchedNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanEtRecoEffcorrNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanEtRecoMatchedEffcorrNchEtabinPtbinStep2 = nullptr; + + TProfile3D* pmeanNchEtabinPtbinStep2 = nullptr; + TProfile3D* pmeanEtNchEtabinPtbinStep2 = nullptr; + + template + bool isEventSelected(const T& col) + { + if (!col.sel8()) + return false; + if (std::abs(col.posZ()) > cfgCutVertex) + return false; + if (cfgEvSelkNoSameBunchPileup && !col.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) + return false; + if (cfgEvSelkNoITSROFrameBorder && !col.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) + return false; + if (cfgEvSelkNoTimeFrameBorder && !col.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) + return false; + return true; + } + + template + bool isTrackSelected(const T& trk) + { + if (trk.sign() == 0) + return false; + if (!trk.has_collision()) + return false; + if (!trk.isPVContributor()) + return false; + if (!(trk.itsNCls() > cfgITScluster)) + return false; + if (!(trk.tpcNClsFound() >= cfgTPCcluster)) + return false; + if (!(trk.tpcNClsCrossedRows() >= cfgTPCnCrossedRows)) + return false; + + if (trk.pt() < cfgCutPtLower || trk.pt() > cfgCutPtUpper || std::abs(trk.eta()) > cfgCutEta) + return false; + if (std::abs(trk.dcaXY()) > cfgCutTracKDcaMaxXY || std::abs(trk.dcaZ()) > cfgCutTracKDcaMaxZ) + return false; + return true; + } + + template + bool isParticleSelected(const T& particle) + { + auto* pd = pdg->GetParticle(particle.pdgCode()); + if (!pd) + return false; + // if (dpt::isStrangeBaryonPDG(particle.pdgCode())) return false; + if (std::abs(pd->Charge()) == 0) + return false; + if (particle.pt() < cfgCutPtLower || particle.pt() > cfgCutPtUpper || std::abs(particle.eta()) > cfgCutEta) + return false; + if (std::abs(particle.vz()) > cfgCutVertex) + return false; + return true; + } + + template + bool selectionProton(const T& candidate) + { + if (!candidate.hasTPC()) + return false; + int flag = 0; + + if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC) { + flag = 1; + } + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaPr()) < cfgnSigmaCutTOF) { + flag = 1; + } + } + if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { + float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); + float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); + float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); + + int flag2 = 0; + if (combNSigmaPr < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaPi < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaKa < cfgnSigmaOtherParticles) + flag2 += 1; + if (!(flag2 > 1) && !(combNSigmaPr > combNSigmaPi) && !(combNSigmaPr > combNSigmaKa)) { + if (combNSigmaPr < cfgnSigmaCutCombTPCTOF) { + flag = 1; } - - template - bool isTrackSelected(const T& trk) - { - if (trk.sign() == 0) - return false; - if (!trk.has_collision()) - return false; - if (!trk.isPVContributor()) - return false; - if (!(trk.itsNCls() > cfgITScluster)) - return false; - if (!(trk.tpcNClsFound() >= cfgTPCcluster)) - return false; - if (!(trk.tpcNClsCrossedRows() >= cfgTPCnCrossedRows)) - return false; - - if (trk.pt() < cfgCutPtLower || trk.pt() > cfgCutPtUpper || std::abs(trk.eta()) > cfgCutEta) - return false; - if (std::abs(trk.dcaXY()) > cfgCutTracKDcaMaxXY || std::abs(trk.dcaZ()) > cfgCutTracKDcaMaxZ) - return false; - return true; + } + } + if (flag == 1) + return true; + else + return false; + } + + template + bool selectionPion(const T& candidate) + { + if (!candidate.hasTPC()) + return false; + int flag = 0; + + if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < cfgnSigmaCutTPC) { + flag = 1; + } + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaPi()) < cfgnSigmaCutTOF) { + flag = 1; + } + } + if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { + float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); + float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); + float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); + + int flag2 = 0; + if (combNSigmaPr < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaPi < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaKa < cfgnSigmaOtherParticles) + flag2 += 1; + if (!(flag2 > 1) && !(combNSigmaPi > combNSigmaPr) && !(combNSigmaPi > combNSigmaKa)) { + if (combNSigmaPi < cfgnSigmaCutCombTPCTOF) { + flag = 1; + } + } + } + if (flag == 1) + return true; + else + return false; + } + + template + bool selectionKaon(const T& candidate) + { + if (!candidate.hasTPC()) + return false; + int flag = 0; + + if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { + if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < cfgnSigmaCutTPC) { + flag = 1; + } + if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaKa()) < cfgnSigmaCutTOF) { + flag = 1; + } + } + if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { + float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); + float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); + float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); + + int flag2 = 0; + if (combNSigmaPr < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaPi < cfgnSigmaOtherParticles) + flag2 += 1; + if (combNSigmaKa < cfgnSigmaOtherParticles) + flag2 += 1; + if (!(flag2 > 1) && !(combNSigmaKa > combNSigmaPi) && !(combNSigmaKa > combNSigmaPr)) { + if (combNSigmaKa < cfgnSigmaCutCombTPCTOF) { + flag = 1; + } + } + } + if (flag == 1) + return true; + else + return false; + } + + float getCentrality(const auto& col) const + { + if (cfgCentralityChoice.value == kCentFT0C) + return col.centFT0C(); + if (cfgCentralityChoice.value == kCentFT0A) + return col.centFT0A(); + if (cfgCentralityChoice.value == kCentFT0M) + return col.centFT0M(); + if (cfgCentralityChoice.value == kCentFV0A) + return col.centFV0A(); + return KinvalidCentrality; + } + + float getEfficiency(float mult, float pt, float eta, PID pidType, int effidx) const + { + TH3F* h; + if (effidx == 0) + h = hEff[pidType]; + if (effidx == 1) + h = hFake[pidType]; + + if (!h) + return -1; + const int ibx = h->GetXaxis()->FindBin(mult); + const int iby = h->GetYaxis()->FindBin(pt); + const int ibz = h->GetZaxis()->FindBin(eta); + float val = h->GetBinContent(ibx, iby, ibz); + return val; + } + + float getFlatteningWeight(float cent, float eta, float phi, PID pidType) const + { + TH3F* h = hWeightMap3D[pidType]; + if (!h) + return -1; + const int ibx = h->GetXaxis()->FindBin(cent); + const int iby = h->GetYaxis()->FindBin(eta); + const int ibz = h->GetZaxis()->FindBin(phi); + float val = h->GetBinContent(ibx, iby, ibz); + return val; + } + + template + std::pair calculateMeanAndC2FromSums(const double sumpmwk[KIntM][KIntK], const double sumwk[KIntK], float referenceMeanPt) const + { + if (sumwk[1] == 0.) { + return {0.f, 0.f}; + } + + double tau1 = sumwk[2] / (sumwk[1] * sumwk[1]); + double denom2 = 1. - tau1; + + if (std::abs(denom2) < KFloatEpsilon) { + double pmk11safe = sumpmwk[1][1] / sumwk[1]; + return {static_cast(pmk11safe), 0.f}; + } + + double pmk11 = sumpmwk[1][1] / sumwk[1]; + + double pmk12 = 0.f; + if (sumwk[2] != 0.f) { + pmk12 = sumpmwk[1][2] / sumwk[2]; + } + + double pmk22 = 0.f; + if (sumwk[2] != 0.f) { + pmk22 = sumpmwk[2][2] / sumwk[2]; + } + + float calculatedMeanPt = pmk11; + + double p1kBar1 = pmk11 - referenceMeanPt; + double p2kBar2 = pmk22 - 2.0f * pmk12 * referenceMeanPt + referenceMeanPt * referenceMeanPt; + + double p1kBar1sq = p1kBar1 * p1kBar1; + double numerator2 = p1kBar1sq - (tau1 * p2kBar2); + + float twopcorr = numerator2 / denom2; + return {calculatedMeanPt, twopcorr}; + } + + ConfigurableAxis cfgAxisCent{"cfgAxisCent", {0.0, 1.0, 3.0, 5.0, 10, 20, 30, 40, 50, 60, 70, 80, 100}, "centrality axis (percentile)"}; // FT0*/FV0A style + const AxisSpec centAxis{cfgAxisCent, "Centrality (%)"}; + static constexpr int KNbinsNch = 5000; + static constexpr float KNchMax = 5000.5f; + static constexpr int KNbinsNchCoarse = 500; + ConfigurableAxis nChAxis{"nChAxis", {KNbinsNch, KBinOffset, KNchMax}, "PV-contributor track multiplicity axis"}; + ConfigurableAxis nChAxis2{"nChAxis2", {KNbinsNchCoarse, KBinOffset, KNchMax}, "PV-contributor track multiplicity axis"}; + + Configurable cfgRunGetEff{"cfgRunGetEff", false, "Run MC pass to build efficiency/fake maps"}; + Configurable cfgRunMCMean{"cfgRunMCMean", false, "Run MC mean(pT) & mean(Et)"}; + Configurable cfgRunMCFluc{"cfgRunMCFluc", false, "Run MC fluctuations (C2, subevent)"}; + Configurable cfgRunGetFlat{"cfgRunGetFlat", false, "Run Data Get Flattening Weights"}; + Configurable cfgRunDataMean{"cfgRunDataMean", false, "Run DATA mean(pT) & mean(Et)"}; + Configurable cfgRunDataFluc{"cfgRunDataFluc", false, "Run DATA fluctuations (C2, subevent)"}; + + using GeneralCollisions = soa::Join< + aod::Collisions, + aod::EvSels, + aod::Mults, + aod::CentFT0As, aod::CentFT0Cs, aod::CentFT0Ms, aod::CentFV0As, + aod::CentNGlobals>; + Filter collisionFilter = nabs(aod::collision::posZ) < cfgVtxZCut; + using AodCollisionsSel = soa::Filtered; + + using UnfilteredTracks = soa::Join< + aod::Tracks, + aod::TracksExtra, + aod::TrackSelection, + aod::TracksDCA, + aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, + aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr>; + Filter trackFilter = nabs(aod::track::eta) < cfgEtaCut && + aod::track::pt > cfgPtMin&& + aod::track::pt < cfgPtMax&& + nabs(aod::track::dcaXY) < cfgDCAXY&& nabs(aod::track::dcaZ) < cfgDCAZ; + using AodTracksSel = soa::Filtered; + using TCs = soa::Join; + using FilteredTCs = soa::Filtered; + + using MyRun3MCCollisions = soa::Join< + aod::Collisions, aod::EvSels, aod::Mults, aod::MultsExtra, + aod::CentFT0As, aod::CentFT0Cs, aod::CentFT0Ms, aod::CentFV0As, + aod::CentNGlobals, aod::McCollisionLabels>; + + using MyMCTracks = soa::Join< + aod::Tracks, aod::TrackSelection, aod::TracksExtra, aod::TracksDCA, + aod::McTrackLabels, + aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, + aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr>; + + PresliceUnsorted partPerMcCollision = aod::mcparticle::mcCollisionId; + PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; + PresliceUnsorted trackPerMcParticle = aod::mctracklabel::mcParticleId; + Preslice perCollision = aod::track::collisionId; + Preslice trackPerCollision = aod::track::collisionId; + + void declareCommonQA() + { + histos.add("hZvtx_after_sel", ";z_{vtx} (cm)", kTH1F, {{KNbinsZvtx, KZvtxMin, KZvtxMax}}); + histos.add("hVtxZ", ";z_{vtx} (cm)", kTH1F, {{KNbinsZvtx, KZvtxMin, KZvtxMax}}); + histos.add("hCentrality", ";centrality (%)", kTH1F, {{centAxis}}); + histos.add("Hist2D_globalTracks_PVTracks", ";N_{global};N_{PV}", kTH2F, {{nChAxis2}, {nChAxis2}}); + histos.add("Hist2D_cent_nch", ";N_{PV};cent (%)", kTH2F, {{nChAxis2}, {centAxis}}); + histos.add("hP", ";p (GeV/c)", kTH1F, {{KNbinsP, KPMin, KPMax}}); + histos.add("hPt", ";p_{T} (GeV/c)", kTH1F, {{KNbinsPt, KPtMin, KPtMax}}); + histos.add("hEta", ";#eta", kTH1F, {{KNbinsEta, KEtaMin, KEtaMax}}); + histos.add("hPhi", ";#phi", kTH1F, {{KNbinsPhi, KPhiMin, TwoPI}}); + + histos.add("hCentEtaPhi", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCent1EtaPhi", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCent7EtaPhi", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCentEtaPhiWtd", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCent1EtaPhiWtd", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCent7EtaPhiWtd", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + + histos.add("hCentEtaPhiWtd_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCent1EtaPhiWtd_PID", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCent7EtaPhiWtd_PID", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + + histos.add("hCentEtaPhiTrue", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCentEtaPhiReco", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCentEtaPhiRecoMatched", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + + histos.add("hCentEtaPhiTrue_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCentEtaPhiReco_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + histos.add("hCentEtaPhiRecoMatched_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + } + void declareMCCommonHists() + { + + histos.add("ptResolution", ";p_{T}^{MC};p_{T}^{MC}-p_{T}^{reco}", kTH2F, {{KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsPtRes, -KPtResMax, KPtResMax}}); + histos.add("ptTruthReco", ";p_{T}^{MC};p_{T}^{reco}", kTH2F, {{KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsPtRes, cfgPtMin, cfgPtMax}}); + histos.add("etaResolution", ";#eta^{MC};#eta^{MC}-#eta^{reco}", kTH2F, {{KNbinsEtaRes, -KEtaFineMax, KEtaFineMax}, {KNbinsPtRes, -KEtaResMax, KEtaResMax}}); + histos.add("etaTruthReco", ";#eta^{MC};#eta^{reco}", kTH2F, {{KNbinsPtRes, -KEtaFineMax, KEtaFineMax}, {KNbinsPtRes, -KEtaFineMax, KEtaFineMax}}); + + histos.add("TruthTracKVz", ";Vz^{MC};Vz^{Reco}", kTH2F, {{KNbinsVz, KVzMin, KVzMax}, {KNbinsVz, KVzMin, KVzMax}}); + histos.add("vzResolution", ";Vz^{MC};Vz^{MC}-Vz^{Reco}", kTH2F, {{KNbinsVz, KVzMin, KVzMax}, {KNbinsVz, -KVzResMax, KVzResMax}}); + + histos.add("h3_AllPrimary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_RecoMatchedToPrimary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_RecoUnMatchedToPrimary_Secondary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_RecoUnMatchedToPrimary_Fake", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_AllReco", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + + histos.add("h3_AllPrimary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_RecoMatchedToPrimary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_RecoUnMatchedToPrimary_Secondary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_RecoUnMatchedToPrimary_Fake_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("h3_AllReco_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + + histos.add("h_AllPrimary", ";p_{T}", kTH1F, {{KNbinsP, cfgPtMin, cfgPtMax}}); + histos.add("h_RecoMatchedToPrimary", ";p_{T}", kTH1F, {{KNbinsPt, KPtMin, KPtMax}}); + histos.add("h_RecoUnMatchedToPrimary", ";p_{T}", kTH1F, {{KNbinsPt, KPtMin, KPtMax}}); + histos.add("h_AllReco", ";p_{T}", kTH1F, {{KNbinsPt, KPtMin, KPtMax}}); + + histos.add("hReco_ParticleWeight", ";cent;p_{T};#eta", kTH3F, {{centAxis}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsPtRes, -KEtaFineMax, KEtaFineMax}}); + histos.add("hTruth_ParticleWeight", ";cent;p_{T};#eta", kTH3F, {{centAxis}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsPtRes, -KEtaFineMax, KEtaFineMax}}); + + histos.add("hDCAxy_Unmatched", ";DCA_{xy} (cm)", kTH1F, {{KNbinsDca, -KDcaMax, KDcaMax}}); + histos.add("hDCAz_Unmatched", ";DCA_{z} (cm)", kTH1F, {{KNbinsDca, -KDcaMax, KDcaMax}}); + histos.add("hDCAxy_NotPrimary", ";DCA_{xy} (cm)", kTH1F, {{KNbinsDca, -KDcaMax, KDcaMax}}); + histos.add("hDCAz_NotPrimary", ";DCA_{z} (cm)", kTH1F, {{KNbinsDca, -KDcaMax, KDcaMax}}); + } + + void declareMCMeanHists() + { + histos.add("Eff_cent", ";cent;#epsilon", kTProfile, {centAxis}); + histos.add("Fake_cent", ";cent;f_{fake}", kTProfile, {centAxis}); + histos.add("wgt_cent", ";cent;w", kTProfile, {centAxis}); + histos.add("Eff_Ntrk", ";N_{PV};#epsilon", kTProfile, {nChAxis2}); + histos.add("Fake_Ntrk", ";N_{PV};f_{fake}", kTProfile, {nChAxis2}); + histos.add("wgt_Ntrk", ";N_{PV};w", kTProfile, {nChAxis2}); + histos.add("Eff_pT", ";p_{T};#epsilon", kTProfile, {{KNbinsPtRes, cfgPtMin, cfgPtMax}}); + histos.add("Fake_pT", ";p_{T};f_{fake}", kTProfile, {{KNbinsPtRes, cfgPtMin, cfgPtMax}}); + histos.add("wgt_pT", ";p_{T};w", kTProfile, {{KNbinsPtRes, KPtMin, KPtMax}}); + histos.add("Eff_eta", ";#eta;#epsilon", kTProfile, {{KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("Fake_eta", ";#eta;f_{fake}", kTProfile, {{KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + histos.add("wgt_eta", ";#eta;w", kTProfile, {{KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); + // MC mean profiles (pT & Et) for various selections + histos.add("MCGen/Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanpT_Mult", ";N_{PV};#LT p_{T}#GT", kTProfile, {nChAxis}); + histos.add("pmeanTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + + histos.add("MCGen/Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanEt_Mult", ";N_{PV};#LT E_{T}#GT", kTProfile, {nChAxis}); + histos.add("pmeanEtTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanEtRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanEtRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanEtRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanEtRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + + histos.addClone("MCGen/", "MCReco/"); + histos.addClone("MCGen/", "MCRecoMatched/"); + histos.addClone("MCGen/", "MCRecoEffCorr/"); + histos.addClone("MCGen/", "MCRecoMatchedEffCorr/"); + } + void declareMCFlucHists() + { + static constexpr int KNbinsNchFluc = 1000; + // pT cumulants + histos.add("MCGen/Prof_C2_Cent", ";cent;C_{2}", kTProfile, {centAxis}); + histos.add("MCGen/Prof_C2_Mult", ";N_{PV};C_{2}", kTProfile, {nChAxis}); + histos.add("MCGen/Prof_C2Sub_Mult_etabin_ptbin", + ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, + {{KNbinsNchFluc, KNchMin, KNchCoarseMax}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("MCGen/Prof_ipt0_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt0_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt0_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("MCGen/Prof_C2Et_Cent", ";cent;C_{2}^{E_{T}}", kTProfile, {centAxis}); + histos.add("MCGen/Prof_C2Et_Mult", ";N_{PV};C_{2}^{E_{T}}", kTProfile, {nChAxis}); + histos.add("MCGen/Prof_C2EtSub_Mult_etabin_ptbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, + {{KNbinsNchFluc, KNchMin, KNchCoarseMax}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("MCGen/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt0_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt0_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt1_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("MCGen/Prof_ipt2_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + + histos.add("MCGen/Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanpT_Mult", ";N_{PV};#LT p_{T}#GT", kTProfile, {nChAxis}); + + histos.add("pmeanTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + + histos.add("MCGen/Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); + histos.add("MCGen/Prof_MeanEt_Mult", ";N_{PV};#LT E_{T}#GT", kTProfile, {nChAxis}); + histos.add("pmeanEtTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanEtRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanEtRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanEtRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("pmeanEtRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + } + void declareDataMeanHists() + { + histos.add("Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); + histos.add("Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); + histos.add("pmean_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + // Et + histos.add("Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); + histos.add("pmeanEt_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + } + + void declareDataGetFlatHists() + { + histos.add("hCentEtaPhi_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, 0, TwoPI}}); + } + + void declareDataFlucHists() + { + histos.add("pmean_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); + histos.add("pmeanEt_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + + histos.add("Prof_C2_Cent", ";cent;C_{2}", kTProfile, {centAxis}); + histos.add("Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); + histos.add("Prof_MeanpT_Mult", ";N_{PV};#LT p_{T}#GT", kTProfile, {nChAxis}); + histos.add("Prof_C2_Mult_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + + histos.add("Prof_ipt0_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("Prof_ipt0_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("Prof_ipt1_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("Prof_ipt1_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("Prof_ipt2_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("Prof_ipt2_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + + histos.add("Prof_C2Et_Cent", ";cent;C_{2}^{E_{T}}", kTProfile, {centAxis}); + histos.add("Prof_MeanEt_Mult", ";N_{PV};#LT E_{T}#GT", kTProfile, {nChAxis}); + histos.add("Prof_C2Et_Mult_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + + histos.add("Prof_ipt0_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("Prof_ipt0_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("Prof_ipt1_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("Prof_ipt1_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + histos.add("Prof_ipt2_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); + histos.add("Prof_ipt2_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); + + histos.add("Prof_ipt0_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("Prof_ipt1_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("Prof_ipt2_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("Prof_ipt0_C2SubEt2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("Prof_ipt1_C2SubEt2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + histos.add("Prof_ipt2_C2SubEt2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + } + + TH3F* buildWeightMapFromRaw(TH3F* hRaw, const char* mapName) + { + if (!hRaw) { + LOGF(error, "Raw eta-phi map for '%s' is null; no flattening will be applied.", mapName); + return nullptr; + } + auto hWeightMap = reinterpret_cast(hRaw->Clone(mapName)); + hWeightMap->SetTitle(Form("Flattening Weight Map %s (w_{#phi} = / N_{#phi})", mapName)); + hWeightMap->SetDirectory(nullptr); + hWeightMap->Reset(); + auto axC = hRaw->GetXaxis(); + auto axE = hRaw->GetYaxis(); + auto axP = hRaw->GetZaxis(); + for (int ic = 1; ic <= axC->GetNbins(); ++ic) { + for (int ie = 1; ie <= axE->GetNbins(); ++ie) { + // average over phi at fixed (cent,eta) + double sum = 0.0; + int nphi = axP->GetNbins(); + for (int ip = 1; ip <= nphi; ++ip) + sum += hRaw->GetBinContent(ic, ie, ip); + const double avg = (nphi > 0 ? sum / nphi : 0.0); + for (int ip = 1; ip <= nphi; ++ip) { + const double raw = hRaw->GetBinContent(ic, ie, ip); + const double w = (avg > 0.0 && raw > 0.0) ? (avg / raw) : 1.0; + hWeightMap->SetBinContent(ic, ie, ip, w); + } + } + } + LOGF(info, "Flattening weight map '%s' built.", mapName); + return hWeightMap; + } + + inline void loadTProfile3D(TDirectory* dir, const char* name, TProfile3D*& target) + { + if (!dir) { + LOGF(error, "loadTProfile3D: directory is null for object %s", name); + return; + } + + auto* obj = dir->Get(name); + if (!obj) { + LOGF(error, "loadTProfile3D: object '%s' not found in directory %s", name, dir->GetName()); + return; + } + + auto* prof = dynamic_cast(obj); + if (!prof) { + LOGF(error, "loadTProfile3D: object '%s' is not a TProfile3D (it is %s)", name, obj->ClassName()); + return; + } + + target = reinterpret_cast(prof->Clone(Form("%s_clone", name))); + target->SetDirectory(nullptr); + LOGF(info, "Loaded TProfile3D '%s' with entries = %.0f", name, target->GetEntries()); + } + + void init(InitContext&) + { + ccdb->setURL("https://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + int64_t now = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()) + .count(); + ccdb->setCreatedNotAfter(now); + + declareCommonQA(); + + const std::string userCcdbPath = "/Users/s/somadutt/PbPbTest/"; + + if (cfgRunMCMean || cfgRunMCFluc || cfgRunGetEff) { + declareMCCommonHists(); + } + if (cfgRunMCMean) { + declareMCMeanHists(); + } + if (cfgRunMCFluc) { + declareMCFlucHists(); + + histos.addClone("MCGen/", "MCReco/"); + histos.addClone("MCGen/", "MCRecoMatched/"); + histos.addClone("MCGen/", "MCRecoEffCorr/"); + histos.addClone("MCGen/", "MCRecoMatchedEffCorr/"); + } + if (cfgRunGetFlat) { + declareDataGetFlatHists(); + } + if (cfgRunDataMean) { + declareDataMeanHists(); + } + if (cfgRunDataFluc) { + declareDataFlucHists(); + } + + const bool needEffMaps = cfgRunMCMean || cfgRunMCFluc || cfgRunDataMean || cfgRunDataFluc; + if (needEffMaps && !cfgRunGetEff) { + + LOGF(info, "Loading Eff/Fake maps from CCDB path: %s", userCcdbPath.c_str()); + + auto loadEffFakeForPID = [&](PID pidType) { + std::string suffix = pidSuffix[pidType]; + std::string hEffNumName = "h3_RecoMatchedToPrimary" + suffix; + std::string hEffDenName = "h3_AllPrimary" + suffix; + std::string hFakeNumSecName = "h3_RecoUnMatchedToPrimary_Secondary" + suffix; + std::string hFakeNumFakName = "h3_RecoUnMatchedToPrimary_Fake" + suffix; + std::string hFakeDenName = "h3_AllReco" + suffix; + + // --- Efficiency --- + auto* hNum = ccdb->get(userCcdbPath + hEffNumName); + auto* hDen = ccdb->get(userCcdbPath + hEffDenName); + if (hNum && hDen) { + hEff[pidType] = reinterpret_cast(hNum->Clone(Form("hEff%s", suffix.c_str()))); + hEff[pidType]->SetDirectory(nullptr); + hEff[pidType]->Divide(hDen); + } else { + LOGF(error, "Missing CCDB objects for efficiency. Checked:\n%s\n%s", + (userCcdbPath + hEffNumName).c_str(), + (userCcdbPath + hEffDenName).c_str()); } - template - bool isParticleSelected(const T& particle) - { - auto* pd = pdg->GetParticle(particle.pdgCode()); - if (!pd) - return false; - // if (dpt::isStrangeBaryonPDG(particle.pdgCode())) return false; - if (std::abs(pd->Charge()) == 0) - return false; - if (particle.pt() < cfgCutPtLower || particle.pt() > cfgCutPtUpper || std::abs(particle.eta()) > cfgCutEta) - return false; - if (std::abs(particle.vz()) > cfgCutVertex) - return false; - return true; + // --- Fakes --- + auto* hNumS = ccdb->get(userCcdbPath + hFakeNumSecName); + auto* hNumF = ccdb->get(userCcdbPath + hFakeNumFakName); + auto* hDenF = ccdb->get(userCcdbPath + hFakeDenName); + if (hNumS && hNumF && hDenF) { + hFake[pidType] = reinterpret_cast(hNumS->Clone(Form("hFake%s", suffix.c_str()))); + hFake[pidType]->Add(hNumF); + hFake[pidType]->SetDirectory(nullptr); + hFake[pidType]->Divide(hDenF); + } else { + LOGF(error, "Missing CCDB object(s) for fakes for %s. Checked path prefix: %s", + suffix.c_str(), userCcdbPath.c_str()); } + }; - template - bool selectionProton(const T& candidate) - { - if (!candidate.hasTPC()) - return false; - int flag = 0; + loadEffFakeForPID(kInclusive); + loadEffFakeForPID(kCombinedPID); - if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { - if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC) { - flag = 1; - } - if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPr()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaPr()) < cfgnSigmaCutTOF) { - flag = 1; - } - } - if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { - float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); - float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); - float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); - - int flag2 = 0; - if (combNSigmaPr < cfgnSigmaOtherParticles) - flag2 += 1; - if (combNSigmaPi < cfgnSigmaOtherParticles) - flag2 += 1; - if (combNSigmaKa < cfgnSigmaOtherParticles) - flag2 += 1; - if (!(flag2 > 1) && !(combNSigmaPr > combNSigmaPi) && !(combNSigmaPr > combNSigmaKa)) { - if (combNSigmaPr < cfgnSigmaCutCombTPCTOF) { - flag = 1; - } - } - } - if (flag == 1) - return true; - else - return false; - } + const bool isDataRun = cfgRunDataMean || cfgRunDataFluc; + if (isDataRun) { + LOGF(info, "Data Run: Loading flattening maps from CCDB path: %s", userCcdbPath.c_str()); - template - bool selectionPion(const T& candidate) - { - if (!candidate.hasTPC()) - return false; - int flag = 0; + auto* hRawIncl = ccdb->get(userCcdbPath + "hCentEtaPhi"); + if (hRawIncl) { + hWeightMap3D[kInclusive] = buildWeightMapFromRaw(hRawIncl, "hWeightMap3D"); + } else { + LOGF(error, "Data flattening 'hCentEtaPhi' not found at path %s", + (userCcdbPath + "hCentEtaPhi").c_str()); + } - if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { - if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < cfgnSigmaCutTPC) { - flag = 1; - } - if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaPi()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaPi()) < cfgnSigmaCutTOF) { - flag = 1; - } + auto* hRawPID = ccdb->get(userCcdbPath + "hCentEtaPhi_PID"); + if (hRawPID) { + hWeightMap3D[kCombinedPID] = buildWeightMapFromRaw(hRawPID, "hWeightMap3D_PID"); + } else { + LOGF(error, "Data flattening 'hCentEtaPhi_PID' not found at path %s", + (userCcdbPath + "hCentEtaPhi_PID").c_str()); + } + } else { + LOGF(info, "MC Run: Loading flattening maps from CCDB path: %s", userCcdbPath.c_str()); + + auto loadFlatForPID = [&](PID pidType) { + std::string suffix = pidSuffix[pidType]; + std::string hFlatSrcName = "hCentEtaPhiReco" + suffix; + auto* hRaw = ccdb->get(userCcdbPath + hFlatSrcName); + if (hRaw) { + hWeightMap3D[pidType] = buildWeightMapFromRaw(hRaw, Form("hWeightMap3D%s", suffix.c_str())); + } else { + LOGF(warning, "MC flattening source '%s' not found at %s; skipping this PID.", + hFlatSrcName.c_str(), (userCcdbPath + hFlatSrcName).c_str()); } - if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { - float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); - float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); - float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); - - int flag2 = 0; - if (combNSigmaPr < cfgnSigmaOtherParticles) - flag2 += 1; - if (combNSigmaPi < cfgnSigmaOtherParticles) - flag2 += 1; - if (combNSigmaKa < cfgnSigmaOtherParticles) - flag2 += 1; - if (!(flag2 > 1) && !(combNSigmaPi > combNSigmaPr) && !(combNSigmaPi > combNSigmaKa)) { - if (combNSigmaPi < cfgnSigmaCutCombTPCTOF) { - flag = 1; - } - } + }; + loadFlatForPID(kInclusive); + loadFlatForPID(kCombinedPID); + } + } + + auto loadTProfile3DFromCCDB = [&](const std::string& ccdbPath, const char* objName, TProfile3D*& target) { + std::string fullPath = ccdbPath + objName; + LOGF(info, "Loading TProfile3D from CCDB: %s", fullPath.c_str()); + if (auto* tp = ccdb->get(fullPath)) { + target = reinterpret_cast(tp->Clone()); + target->SetDirectory(nullptr); + } else { + LOGF(error, "Histogram %s missing in CCDB at path: %s", objName, fullPath.c_str()); + } + }; + + if (cfgRunMCFluc) { + LOGF(info, "Loading MC Mean profiles from CCDB path: %s", userCcdbPath.c_str()); + + loadTProfile3DFromCCDB(userCcdbPath, "pmeanTruNchEtabinPtbin", pmeanTruNchEtabinPtbinStep2); + loadTProfile3DFromCCDB(userCcdbPath, "pmeanRecoNchEtabinPtbin", pmeanRecoNchEtabinPtbinStep2); + loadTProfile3DFromCCDB(userCcdbPath, "pmeanRecoMatchedNchEtabinPtbin", pmeanRecoMatchedNchEtabinPtbinStep2); + loadTProfile3DFromCCDB(userCcdbPath, "pmeanRecoEffcorrNchEtabinPtbin", pmeanRecoEffcorrNchEtabinPtbinStep2); + loadTProfile3DFromCCDB(userCcdbPath, "pmeanRecoMatchedEffcorrNchEtabinPtbin", pmeanRecoMatchedEffcorrNchEtabinPtbinStep2); + + loadTProfile3DFromCCDB(userCcdbPath, "pmeanEtTruNchEtabinPtbin", pmeanEtTruNchEtabinPtbinStep2); + loadTProfile3DFromCCDB(userCcdbPath, "pmeanEtRecoNchEtabinPtbin", pmeanEtRecoNchEtabinPtbinStep2); + loadTProfile3DFromCCDB(userCcdbPath, "pmeanEtRecoMatchedNchEtabinPtbin", pmeanEtRecoMatchedNchEtabinPtbinStep2); + loadTProfile3DFromCCDB(userCcdbPath, "pmeanEtRecoEffcorrNchEtabinPtbin", pmeanEtRecoEffcorrNchEtabinPtbinStep2); + loadTProfile3DFromCCDB(userCcdbPath, "pmeanEtRecoMatchedEffcorrNchEtabinPtbin", pmeanEtRecoMatchedEffcorrNchEtabinPtbinStep2); + } + + if (cfgRunDataFluc) { + LOGF(info, "Loading Data Mean profiles from CCDB path: %s", userCcdbPath.c_str()); + loadTProfile3DFromCCDB(userCcdbPath, "pmean_nch_etabin_ptbin", pmeanNchEtabinPtbinStep2); + loadTProfile3DFromCCDB(userCcdbPath, "pmeanEt_nch_etabin_ptbin", pmeanEtNchEtabinPtbinStep2); + } + + LOGF(info, "CCDB initialization complete for RadialFlowDecorr."); + } + + void processGetEffHists(aod::McCollisions const& mcColl, soa::SmallGroups const& collisions, TCs const& tracks, FilteredTCs const& /*filteredTracks*/, aod::McParticles const& mcParticles) + { + for (const auto& mcCollision : mcColl) { + auto colSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex()); + if (colSlice.size() != 1) + continue; + + for (const auto& col : colSlice) { + if (!col.has_mcCollision()) + continue; + if (!isEventSelected(col)) + continue; + + auto trackSlice = tracks.sliceBy(trackPerCollision, col.globalIndex()); + if (trackSlice.size() < 1) + continue; + + auto partSlice = mcParticles.sliceBy(partPerMcCollision, mcCollision.globalIndex()); + if (partSlice.size() < 1) + continue; + if (col.globalIndex() >= trackSlice.size()) { + LOGF(warning, "Skipping invalid globalIndex=%d for tracks (tracks.size=%d)", col.globalIndex(), tracks.size()); + continue; + } + + float cent = getCentrality(col); + if (cent > KCentMax) + continue; + + for (const auto& particle : partSlice) { + if (!isParticleSelected(particle)) + continue; + if (!particle.isPhysicalPrimary()) + continue; + + const int absPdgId = std::abs(particle.pdgCode()); + const bool isPion = (absPdgId == KPiPlus); + const bool isKaon = (absPdgId == KKPlus); + const bool isProton = (absPdgId == KProton); + const bool isPid = (isPion || isKaon || isProton); + + histos.fill(HIST("hTruth_ParticleWeight"), cent, particle.pt(), particle.eta(), particle.weight()); + histos.fill(HIST("hCentEtaPhiTrue"), cent, particle.eta(), particle.phi()); + histos.fill(HIST("h3_AllPrimary"), col.multNTracksPV(), particle.pt(), particle.eta()); + + if (cent < KCentTestMin) + histos.fill(HIST("hCent1EtaPhi"), particle.eta(), particle.phi()); + if (cent > KCentTestMaxLo && cent < KCentTestMaxHi) + histos.fill(HIST("hCent7EtaPhi"), particle.eta(), particle.phi()); + + if (isPid) { + histos.fill(HIST("hCentEtaPhiTrue_PID"), cent, particle.eta(), particle.phi()); + histos.fill(HIST("h3_AllPrimary_PID"), col.multNTracksPV(), particle.pt(), particle.eta()); } - if (flag == 1) - return true; - else - return false; } + histos.fill(HIST("TruthTracKVz"), mcCollision.posZ(), col.posZ()); + histos.fill(HIST("vzResolution"), mcCollision.posZ(), mcCollision.posZ() - col.posZ()); - template - bool selectionKaon(const T& candidate) - { - if (!candidate.hasTPC()) - return false; - int flag = 0; + // Reconstructed + for (const auto& track : trackSlice) { + if (!isTrackSelected(track)) + continue; - if (candidate.pt() > cfgCutPtLower && candidate.pt() <= cfgCutPtUpperTPC) { - if (!candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < cfgnSigmaCutTPC) { - flag = 1; - } - if (candidate.hasTOF() && std::abs(candidate.tpcNSigmaKa()) < cfgnSigmaCutTPC && std::abs(candidate.tofNSigmaKa()) < cfgnSigmaCutTOF) { - flag = 1; - } + const bool isPion = selectionPion(track); + const bool isKaon = selectionKaon(track); + const bool isProton = selectionProton(track); + const bool isPid = (isPion || isKaon || isProton); + + histos.fill(HIST("h3_AllReco"), col.multNTracksPV(), track.pt(), track.eta()); + histos.fill(HIST("hCentEtaPhiReco"), cent, track.eta(), track.phi()); + + if (isPid) { + histos.fill(HIST("h3_AllReco_PID"), col.multNTracksPV(), track.pt(), track.eta()); + histos.fill(HIST("hCentEtaPhiReco_PID"), cent, track.eta(), track.phi()); } - if (candidate.hasTOF() && candidate.pt() > cfgCutPtUpperTPC && candidate.pt() < cfgCutPtUpperPID) { - float combNSigmaPr = std::sqrt(std::pow(candidate.tpcNSigmaPr(), 2.0) + std::pow(candidate.tofNSigmaPr(), 2.0)); - float combNSigmaPi = std::sqrt(std::pow(candidate.tpcNSigmaPi(), 2.0) + std::pow(candidate.tofNSigmaPi(), 2.0)); - float combNSigmaKa = std::sqrt(std::pow(candidate.tpcNSigmaKa(), 2.0) + std::pow(candidate.tofNSigmaKa(), 2.0)); - - int flag2 = 0; - if (combNSigmaPr < cfgnSigmaOtherParticles) - flag2 += 1; - if (combNSigmaPi < cfgnSigmaOtherParticles) - flag2 += 1; - if (combNSigmaKa < cfgnSigmaOtherParticles) - flag2 += 1; - if (!(flag2 > 1) && !(combNSigmaKa > combNSigmaPi) && !(combNSigmaKa > combNSigmaPr)) { - if (combNSigmaKa < cfgnSigmaCutCombTPCTOF) { - flag = 1; + + if (track.has_mcParticle()) { + auto mcPart2 = track.mcParticle(); + if (mcPart2.isPhysicalPrimary()) { + const int absPdgId = std::abs(mcPart2.pdgCode()); + const bool isPionTrue = (absPdgId == kPiPlus); + const bool isKaonTrue = (absPdgId == kKPlus); + const bool isProtonTrue = (absPdgId == kProton); + const bool isPidTrue = (isPionTrue || isKaonTrue || isProtonTrue); + + histos.fill(HIST("hReco_ParticleWeight"), cent, mcPart2.pt(), mcPart2.eta(), mcPart2.weight()); + histos.fill(HIST("ptResolution"), mcPart2.pt(), mcPart2.pt() - track.pt()); + histos.fill(HIST("ptTruthReco"), mcPart2.pt(), track.pt()); + histos.fill(HIST("etaResolution"), mcPart2.eta(), mcPart2.eta() - track.eta()); + histos.fill(HIST("etaTruthReco"), mcPart2.eta(), track.eta()); + histos.fill(HIST("h3_RecoMatchedToPrimary"), col.multNTracksPV(), mcPart2.pt(), mcPart2.eta()); + histos.fill(HIST("hCentEtaPhiRecoMatched"), cent, mcPart2.eta(), mcPart2.phi()); + + if (isPid && isPidTrue) { + histos.fill(HIST("h3_RecoMatchedToPrimary_PID"), col.multNTracksPV(), mcPart2.pt(), mcPart2.eta()); + histos.fill(HIST("hCentEtaPhiRecoMatched_PID"), cent, mcPart2.eta(), mcPart2.phi()); } + + } else { + // Matched to secondary + histos.fill(HIST("h3_RecoUnMatchedToPrimary_Secondary"), col.multNTracksPV(), track.pt(), track.eta()); + histos.fill(HIST("hDCAxy_Unmatched"), track.dcaXY()); + histos.fill(HIST("hDCAz_Unmatched"), track.dcaZ()); + if (isPid) { + histos.fill(HIST("h3_RecoUnMatchedToPrimary_Secondary_PID"), col.multNTracksPV(), track.pt(), track.eta()); + } + } + } else { + // Fake track + histos.fill(HIST("h3_RecoUnMatchedToPrimary_Fake"), col.multNTracksPV(), track.pt(), track.eta()); + histos.fill(HIST("hDCAxy_NotPrimary"), track.dcaXY()); + histos.fill(HIST("hDCAz_NotPrimary"), track.dcaZ()); + if (isPid) { + histos.fill(HIST("h3_RecoUnMatchedToPrimary_Fake_PID"), col.multNTracksPV(), track.pt(), track.eta()); } } - if (flag == 1) - return true; - else - return false; + } // tracks + } // cols + } // mcColl + LOGF(info, "FINISHED RUNNING processGetEffHists"); + } + PROCESS_SWITCH(RadialFlowDecorr, processGetEffHists, "process MC to calculate Eff and Fakes", cfgRunGetEff); + + void processMCMean(aod::McCollisions const& mcColl, MyRun3MCCollisions const& collisions, TCs const& tracks, FilteredTCs const& /*filteredTracks*/, aod::McParticles const& mcParticles) + { + float sumWiTruth[KNEta][KNpT], sumWiptiTruth[KNEta][KNpT]; + float sumWiReco[KNEta][KNpT], sumWiptiReco[KNEta][KNpT]; + float sumWiRecoMatched[KNEta][KNpT], sumWiptiRecoMatched[KNEta][KNpT]; + float sumWiRecoEffCorr[KNEta][KNpT], sumWiptiRecoEffCorr[KNEta][KNpT]; + float sumWiRecoMatchedEffCorr[KNEta][KNpT], sumWiptiRecoMatchedEffCorr[KNEta][KNpT]; + float sumWiTruthEt[KNEta][KNpT], sumWiptiTruthEt[KNEta][KNpT]; + float sumWiRecoEt[KNEta][KNpT], sumWiptiRecoEt[KNEta][KNpT]; + float sumWiRecoMatchedEt[KNEta][KNpT], sumWiptiRecoMatchedEt[KNEta][KNpT]; + float sumWiRecoEffCorrEt[KNEta][KNpT], sumWiptiRecoEffCorrEt[KNEta][KNpT]; + float sumWiRecoMatchedEffCorrEt[KNEta][KNpT], sumWiptiRecoMatchedEffCorrEt[KNEta][KNpT]; + + for (const auto& mcCollision : mcColl) { + auto colSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex()); + + if (colSlice.size() != 1) + continue; + for (const auto& col : colSlice) { + if (!col.has_mcCollision()) + continue; + if (!isEventSelected(col)) + continue; + + auto trackSlice = tracks.sliceBy(trackPerCollision, col.globalIndex()); + if (trackSlice.size() < 1) + continue; + + auto partSlice = mcParticles.sliceBy(partPerMcCollision, mcCollision.globalIndex()); + if (partSlice.size() < 1) + continue; + if (col.globalIndex() >= trackSlice.size()) { + LOGF(warning, "Skipping invalid globalIndex=%d for tracks (tracks.size=%d)", col.globalIndex(), tracks.size()); + continue; } - float getCentrality(const auto& col) const - { - if (cfgCentralityChoice.value == kCentFT0C) - return col.centFT0C(); - if (cfgCentralityChoice.value == kCentFT0A) - return col.centFT0A(); - if (cfgCentralityChoice.value == kCentFT0M) - return col.centFT0M(); - if (cfgCentralityChoice.value == kCentFV0A) - return col.centFV0A(); - return KinvalidCentrality; - } + float cent = getCentrality(col); + if (cent > KCentMax) + continue; - float getEfficiency(float mult, float pt, float eta, PID pidType, int effidx) const - { - TH3F* h; - if (effidx == 0) - h = hEff[pidType]; - if (effidx == 1) - h = hFake[pidType]; - - if (!h) - return -1; - const int ibx = h->GetXaxis()->FindBin(mult); - const int iby = h->GetYaxis()->FindBin(pt); - const int ibz = h->GetZaxis()->FindBin(eta); - float val = h->GetBinContent(ibx, iby, ibz); - return val; + if (col.globalIndex() >= trackSlice.size()) { + LOGF(warning, "Skipping invalid globalIndex=%d for tracks (tracks.size=%d)", col.globalIndex(), tracks.size()); + continue; } - float getFlatteningWeight(float cent, float eta, float phi, PID pidType) const - { - TH3F* h = hWeightMap3D[pidType]; - if (!h) - return -1; - const int ibx = h->GetXaxis()->FindBin(cent); - const int iby = h->GetYaxis()->FindBin(eta); - const int ibz = h->GetZaxis()->FindBin(phi); - float val = h->GetBinContent(ibx, iby, ibz); - return val; + LOGF(info, "Event Check: cent = %.1f, nTracks = %d", cent, (int)trackSlice.size()); + memset(sumWiTruth, 0, sizeof(sumWiTruth)); + memset(sumWiptiTruth, 0, sizeof(sumWiptiTruth)); + memset(sumWiReco, 0, sizeof(sumWiReco)); + memset(sumWiptiReco, 0, sizeof(sumWiptiReco)); + memset(sumWiRecoMatched, 0, sizeof(sumWiRecoMatched)); + memset(sumWiptiRecoMatched, 0, sizeof(sumWiptiRecoMatched)); + memset(sumWiRecoEffCorr, 0, sizeof(sumWiRecoEffCorr)); + memset(sumWiptiRecoEffCorr, 0, sizeof(sumWiptiRecoEffCorr)); + memset(sumWiRecoMatchedEffCorr, 0, sizeof(sumWiRecoMatchedEffCorr)); + memset(sumWiptiRecoMatchedEffCorr, 0, sizeof(sumWiptiRecoMatchedEffCorr)); + memset(sumWiTruthEt, 0, sizeof(sumWiTruthEt)); + memset(sumWiptiTruthEt, 0, sizeof(sumWiptiTruthEt)); + memset(sumWiRecoEt, 0, sizeof(sumWiRecoEt)); + memset(sumWiptiRecoEt, 0, sizeof(sumWiptiRecoEt)); + memset(sumWiRecoMatchedEt, 0, sizeof(sumWiRecoMatchedEt)); + memset(sumWiptiRecoMatchedEt, 0, sizeof(sumWiptiRecoMatchedEt)); + memset(sumWiRecoEffCorrEt, 0, sizeof(sumWiRecoEffCorrEt)); + memset(sumWiptiRecoEffCorrEt, 0, sizeof(sumWiptiRecoEffCorrEt)); + memset(sumWiRecoMatchedEffCorrEt, 0, sizeof(sumWiRecoMatchedEffCorrEt)); + memset(sumWiptiRecoMatchedEffCorrEt, 0, sizeof(sumWiptiRecoMatchedEffCorrEt)); + + // Truth + for (const auto& particle : partSlice) { + if (!isParticleSelected(particle)) + continue; + if (!particle.isPhysicalPrimary()) + continue; + + const int absPdgId = std::abs(particle.pdgCode()); + const bool isPion = (absPdgId == kPiPlus); + const bool isKaon = (absPdgId == kKPlus); + const bool isProton = (absPdgId == kProton); + + float pt = particle.pt(); + float eta = particle.eta(); + float p = particle.p(); + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; + sumWiTruth[ieta][ipt]++; + sumWiptiTruth[ieta][ipt] += pt; + if (isPion || isKaon || isProton) { + float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus + : o2::constants::physics::MassProton; + float energy = std::sqrt(p * p + m * m); + float et = energy * (pt / p); // E_T = E * sin(theta) = E * (pT / p) + sumWiTruthEt[ieta][ipt]++; + sumWiptiTruthEt[ieta][ipt] += et; + } + } + } } - template - std::pair calculateMeanAndC2FromSums(const double sumpmwk[KIntM][KIntK], const double sumwk[KIntK], float referenceMeanPt) const - { - if (sumwk[1] == 0.) { - return {0.f, 0.f}; + for (const auto& track : trackSlice) { + if (!isTrackSelected(track)) + continue; + + float pt = track.pt(); + float eta = track.eta(); + float p = track.p(); + float phi = track.phi(); + + histos.fill(HIST("hCentEtaPhi"), cent, eta, phi); + if (cent < KCentTestMin) + histos.fill(HIST("hCent1EtaPhi"), eta, phi); + if (cent > KCentTestMaxLo && cent < KCentTestMaxHi) + histos.fill(HIST("hCent7EtaPhi"), eta, phi); + + float effIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 0); + float fakeIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 1); + float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); + float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; + + histos.fill(HIST("hCentEtaPhiWtd"), cent, eta, track.phi(), flatWeightIncl); + if (cent < KCentTestMin) + histos.fill(HIST("hCent1EtaPhiWtd"), track.eta(), track.phi(), flatWeightIncl); + if (cent > KCentTestMaxLo && cent < KCentTestMaxHi) + histos.fill(HIST("hCent7EtaPhiWtd"), track.eta(), track.phi(), flatWeightIncl); + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; + sumWiReco[ieta][ipt] += 1.0; + sumWiptiReco[ieta][ipt] += pt; + } } - double tau1 = sumwk[2] / (sumwk[1] * sumwk[1]); - double denom2 = 1. - tau1; + if (effIncl <= 0 || !isfinite(wIncl) || !isfinite(fakeIncl) || !isfinite(flatWeightIncl)) + continue; - if (std::abs(denom2) < KFloatEpsilon) { - double pmk11safe = sumpmwk[1][1] / sumwk[1]; - return {static_cast(pmk11safe), 0.f}; + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; + sumWiRecoEffCorr[ieta][ipt] += wIncl; + sumWiptiRecoEffCorr[ieta][ipt] += wIncl * pt; + } } - double pmk11 = sumpmwk[1][1] / sumwk[1]; + const bool isPion = selectionPion(track); + const bool isKaon = selectionKaon(track); + const bool isProton = selectionProton(track); + if (isPion || isKaon || isProton) { + float effPid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 0); + float fakePid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 1); + float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); + float wPid = flatWeightPid * (1.0 - fakePid) / effPid; + + histos.fill(HIST("hCentEtaPhiWtd_PID"), cent, eta, track.phi(), flatWeightPid); + if (cent < KCentTestMin) + histos.fill(HIST("hCent1EtaPhiWtd_PID"), track.eta(), track.phi(), flatWeightPid); + if (cent > KCentTestMaxLo && cent < KCentTestMaxHi) + histos.fill(HIST("hCent7EtaPhiWtd_PID"), track.eta(), track.phi(), flatWeightPid); + + float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus + : o2::constants::physics::MassProton; + float energy = std::sqrt(p * p + m * m); + float et = energy * (pt / p); // E_T = E * sin(theta) + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; + sumWiRecoEt[ieta][ipt] += 1.0; + sumWiptiRecoEt[ieta][ipt] += et; + } + } - double pmk12 = 0.f; - if (sumwk[2] != 0.f) { - pmk12 = sumpmwk[1][2] / sumwk[2]; - } + if (effPid <= KFloatEpsilon || !isfinite(wPid) || !isfinite(fakePid) || !isfinite(flatWeightPid)) + continue; - double pmk22 = 0.f; - if (sumwk[2] != 0.f) { - pmk22 = sumpmwk[2][2] / sumwk[2]; + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; + sumWiRecoEffCorrEt[ieta][ipt] += wPid; + sumWiptiRecoEffCorrEt[ieta][ipt] += wPid * et; + } + } } - float calculatedMeanPt = pmk11; - - double p1kBar1 = pmk11 - referenceMeanPt; - double p2kBar2 = pmk22 - 2.0f * pmk12 * referenceMeanPt + referenceMeanPt * referenceMeanPt; - - double p1kBar1sq = p1kBar1 * p1kBar1; - double numerator2 = p1kBar1sq - (tau1 * p2kBar2); + if (isfinite(wIncl)) { + if (cent < KCentTestMin) { + histos.fill(HIST("wgt_pT"), pt, wIncl); + histos.fill(HIST("Eff_pT"), pt, effIncl); + histos.fill(HIST("Fake_pT"), pt, fakeIncl); + histos.fill(HIST("Eff_eta"), eta, effIncl); + histos.fill(HIST("Fake_eta"), eta, fakeIncl); + histos.fill(HIST("wgt_eta"), eta, wIncl); + } + histos.fill(HIST("Eff_cent"), cent, effIncl); + histos.fill(HIST("Eff_Ntrk"), col.multNTracksPV(), effIncl); + histos.fill(HIST("Fake_cent"), cent, fakeIncl); + histos.fill(HIST("Fake_Ntrk"), col.multNTracksPV(), fakeIncl); + histos.fill(HIST("wgt_cent"), cent, wIncl); + histos.fill(HIST("wgt_Ntrk"), col.multNTracksPV(), wIncl); + } - float twopcorr = numerator2 / denom2; - return {calculatedMeanPt, twopcorr}; + } // end track loop + + if (isfinite(sumWiTruth[0][0])) { + float meanPtTruth = sumWiptiTruth[0][0] / sumWiTruth[0][0]; + if (!isfinite(meanPtTruth)) + LOGF(info, "meanPtTruth = %.3f, num = %.3f, den =%.3f", meanPtTruth, sumWiptiTruth[0][0], sumWiTruth[0][0]); + if (!isfinite(meanPtTruth)) + continue; + histos.fill(HIST("MCGen/Prof_cent_Nchrec"), cent, sumWiTruth[0][0]); + histos.fill(HIST("MCGen/Prof_MeanpT_Cent"), cent, meanPtTruth); + histos.fill(HIST("MCGen/Prof_MeanpT_Mult"), col.multNTracksPV(), meanPtTruth); } - - ConfigurableAxis cfgAxisCent{"cfgAxisCent", {0.0, 1.0, 3.0, 5.0, 10, 20, 30, 40, 50, 60, 70, 80, 100}, "centrality axis (percentile)"}; // FT0*/FV0A style - const AxisSpec centAxis{cfgAxisCent, "Centrality (%)"}; - static constexpr int KNbinsNch = 5000; - static constexpr float KNchMax = 5000.5f; - static constexpr int KNbinsNchCoarse = 500; - ConfigurableAxis nChAxis{"nChAxis", {KNbinsNch, KBinOffset, KNchMax}, "PV-contributor track multiplicity axis"}; - ConfigurableAxis nChAxis2{"nChAxis2", {KNbinsNchCoarse, KBinOffset, KNchMax}, "PV-contributor track multiplicity axis"}; - - Configurable cfgRunGetEff{"cfgRunGetEff", false, "Run MC pass to build efficiency/fake maps"}; - Configurable cfgRunMCMean{"cfgRunMCMean", false, "Run MC mean(pT) & mean(Et)"}; - Configurable cfgRunMCFluc{"cfgRunMCFluc", false, "Run MC fluctuations (C2, subevent)"}; - Configurable cfgRunGetFlat{"cfgRunGetFlat", false, "Run Data Get Flattening Weights"}; - Configurable cfgRunDataMean{"cfgRunDataMean", false, "Run DATA mean(pT) & mean(Et)"}; - Configurable cfgRunDataFluc{"cfgRunDataFluc", false, "Run DATA fluctuations (C2, subevent)"}; - - using GeneralCollisions = soa::Join< - aod::Collisions, - aod::EvSels, - aod::Mults, - aod::CentFT0As, aod::CentFT0Cs, aod::CentFT0Ms, aod::CentFV0As, - aod::CentNGlobals>; - Filter collisionFilter = nabs(aod::collision::posZ) < cfgVtxZCut; - using AodCollisionsSel = soa::Filtered; - - using UnfilteredTracks = soa::Join< - aod::Tracks, - aod::TracksExtra, - aod::TrackSelection, - aod::TracksDCA, - aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, - aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr>; - Filter trackFilter = nabs(aod::track::eta) < cfgEtaCut && - aod::track::pt > cfgPtMin&& - aod::track::pt < cfgPtMax&& - nabs(aod::track::dcaXY) < cfgDCAXY&& nabs(aod::track::dcaZ) < cfgDCAZ; - using AodTracksSel = soa::Filtered; - using TCs = soa::Join; - using FilteredTCs = soa::Filtered; - - using MyRun3MCCollisions = soa::Join< - aod::Collisions, aod::EvSels, aod::Mults, aod::MultsExtra, - aod::CentFT0As, aod::CentFT0Cs, aod::CentFT0Ms, aod::CentFV0As, - aod::CentNGlobals, aod::McCollisionLabels>; - - using MyMCTracks = soa::Join< - aod::Tracks, aod::TrackSelection, aod::TracksExtra, aod::TracksDCA, - aod::McTrackLabels, - aod::pidTPCFullPi, aod::pidTPCFullKa, aod::pidTPCFullPr, - aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullPr>; - - PresliceUnsorted partPerMcCollision = aod::mcparticle::mcCollisionId; - PresliceUnsorted colPerMcCollision = aod::mccollisionlabel::mcCollisionId; - PresliceUnsorted trackPerMcParticle = aod::mctracklabel::mcParticleId; - Preslice perCollision = aod::track::collisionId; - Preslice trackPerCollision = aod::track::collisionId; - - void declareCommonQA() - { - histos.add("hZvtx_after_sel", ";z_{vtx} (cm)", kTH1F, {{KNbinsZvtx, KZvtxMin, KZvtxMax}}); - histos.add("hVtxZ", ";z_{vtx} (cm)", kTH1F, {{KNbinsZvtx, KZvtxMin, KZvtxMax}}); - histos.add("hCentrality", ";centrality (%)", kTH1F, {{centAxis}}); - histos.add("Hist2D_globalTracks_PVTracks", ";N_{global};N_{PV}", kTH2F, {{nChAxis2}, {nChAxis2}}); - histos.add("Hist2D_cent_nch", ";N_{PV};cent (%)", kTH2F, {{nChAxis2}, {centAxis}}); - histos.add("hP", ";p (GeV/c)", kTH1F, {{KNbinsP, KPMin, KPMax}}); - histos.add("hPt", ";p_{T} (GeV/c)", kTH1F, {{KNbinsPt, KPtMin, KPtMax}}); - histos.add("hEta", ";#eta", kTH1F, {{KNbinsEta, KEtaMin, KEtaMax}}); - histos.add("hPhi", ";#phi", kTH1F, {{KNbinsPhi, KPhiMin, TwoPI}}); - - histos.add("hCentEtaPhi", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - histos.add("hCent1EtaPhi", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - histos.add("hCent7EtaPhi", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - histos.add("hCentEtaPhiWtd", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - histos.add("hCent1EtaPhiWtd", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - histos.add("hCent7EtaPhiWtd", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - - histos.add("hCentEtaPhiWtd_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - histos.add("hCent1EtaPhiWtd_PID", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - histos.add("hCent7EtaPhiWtd_PID", ";#eta;#phi", kTH2F, {{(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - - histos.add("hCentEtaPhiTrue", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - histos.add("hCentEtaPhiReco", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - histos.add("hCentEtaPhiRecoMatched", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - - histos.add("hCentEtaPhiTrue_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - histos.add("hCentEtaPhiReco_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); - histos.add("hCentEtaPhiRecoMatched_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, KPhiMin, TwoPI}}); + if (isfinite(sumWiReco[0][0])) { + float meanPtReco = sumWiptiReco[0][0] / sumWiReco[0][0]; + if (!isfinite(meanPtReco)) + LOGF(info, "meanPtReco = %.3f, num = %.3f, den =%.3f", meanPtReco, sumWiptiReco[0][0], sumWiReco[0][0]); + if (!isfinite(meanPtReco)) + continue; + histos.fill(HIST("MCReco/Prof_cent_Nchrec"), cent, sumWiReco[0][0]); + histos.fill(HIST("MCReco/Prof_MeanpT_Cent"), cent, meanPtReco); + histos.fill(HIST("MCReco/Prof_MeanpT_Mult"), col.multNTracksPV(), meanPtReco); } - void declareMCCommonHists() - { - - histos.add("ptResolution", ";p_{T}^{MC};p_{T}^{MC}-p_{T}^{reco}", kTH2F, {{KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsPtRes, -KPtResMax, KPtResMax}}); - histos.add("ptTruthReco", ";p_{T}^{MC};p_{T}^{reco}", kTH2F, {{KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsPtRes, cfgPtMin, cfgPtMax}}); - histos.add("etaResolution", ";#eta^{MC};#eta^{MC}-#eta^{reco}", kTH2F, {{KNbinsEtaRes, -KEtaFineMax, KEtaFineMax}, {KNbinsPtRes, -KEtaResMax, KEtaResMax}}); - histos.add("etaTruthReco", ";#eta^{MC};#eta^{reco}", kTH2F, {{KNbinsPtRes, -KEtaFineMax, KEtaFineMax}, {KNbinsPtRes, -KEtaFineMax, KEtaFineMax}}); - - histos.add("TruthTracKVz", ";Vz^{MC};Vz^{Reco}", kTH2F, {{KNbinsVz, KVzMin, KVzMax}, {KNbinsVz, KVzMin, KVzMax}}); - histos.add("vzResolution", ";Vz^{MC};Vz^{MC}-Vz^{Reco}", kTH2F, {{KNbinsVz, KVzMin, KVzMax}, {KNbinsVz, -KVzResMax, KVzResMax}}); - - histos.add("h3_AllPrimary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - histos.add("h3_RecoMatchedToPrimary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - histos.add("h3_RecoUnMatchedToPrimary_Secondary", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - histos.add("h3_RecoUnMatchedToPrimary_Fake", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - histos.add("h3_AllReco", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - - histos.add("h3_AllPrimary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - histos.add("h3_RecoMatchedToPrimary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - histos.add("h3_RecoUnMatchedToPrimary_Secondary_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - histos.add("h3_RecoUnMatchedToPrimary_Fake_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - histos.add("h3_AllReco_PID", ";N_{PV};p_{T};#eta", kTH3F, {{nChAxis2}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - - histos.add("h_AllPrimary", ";p_{T}", kTH1F, {{KNbinsP, cfgPtMin, cfgPtMax}}); - histos.add("h_RecoMatchedToPrimary", ";p_{T}", kTH1F, {{KNbinsPt, KPtMin, KPtMax}}); - histos.add("h_RecoUnMatchedToPrimary", ";p_{T}", kTH1F, {{KNbinsPt, KPtMin, KPtMax}}); - histos.add("h_AllReco", ";p_{T}", kTH1F, {{KNbinsPt, KPtMin, KPtMax}}); - - histos.add("hReco_ParticleWeight", ";cent;p_{T};#eta", kTH3F, {{centAxis}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsPtRes, -KEtaFineMax, KEtaFineMax}}); - histos.add("hTruth_ParticleWeight", ";cent;p_{T};#eta", kTH3F, {{centAxis}, {KNbinsPtRes, cfgPtMin, cfgPtMax}, {KNbinsPtRes, -KEtaFineMax, KEtaFineMax}}); - - histos.add("hDCAxy_Unmatched", ";DCA_{xy} (cm)", kTH1F, {{KNbinsDca, -KDcaMax, KDcaMax}}); - histos.add("hDCAz_Unmatched", ";DCA_{z} (cm)", kTH1F, {{KNbinsDca, -KDcaMax, KDcaMax}}); - histos.add("hDCAxy_NotPrimary", ";DCA_{xy} (cm)", kTH1F, {{KNbinsDca, -KDcaMax, KDcaMax}}); - histos.add("hDCAz_NotPrimary", ";DCA_{z} (cm)", kTH1F, {{KNbinsDca, -KDcaMax, KDcaMax}}); + if (isfinite(sumWiRecoEffCorr[0][0])) { + float meanpTeffcorr = sumWiptiRecoEffCorr[0][0] / sumWiRecoEffCorr[0][0]; + if (!isfinite(meanpTeffcorr)) + LOGF(info, "meanPtRecoEffcorr = %.3f, num = %.3f, den =%.3f", meanpTeffcorr, sumWiptiRecoEffCorr[0][0], sumWiRecoEffCorr[0][0]); + if (!isfinite(meanpTeffcorr)) + continue; + histos.fill(HIST("MCRecoEffCorr/Prof_cent_Nchrec"), cent, sumWiRecoEffCorr[0][0]); + histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Cent"), cent, meanpTeffcorr); + histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Mult"), col.multNTracksPV(), meanpTeffcorr); } - void declareMCMeanHists() - { - histos.add("Eff_cent", ";cent;#epsilon", kTProfile, {centAxis}); - histos.add("Fake_cent", ";cent;f_{fake}", kTProfile, {centAxis}); - histos.add("wgt_cent", ";cent;w", kTProfile, {centAxis}); - histos.add("Eff_Ntrk", ";N_{PV};#epsilon", kTProfile, {nChAxis2}); - histos.add("Fake_Ntrk", ";N_{PV};f_{fake}", kTProfile, {nChAxis2}); - histos.add("wgt_Ntrk", ";N_{PV};w", kTProfile, {nChAxis2}); - histos.add("Eff_pT", ";p_{T};#epsilon", kTProfile, {{KNbinsPtRes, cfgPtMin, cfgPtMax}}); - histos.add("Fake_pT", ";p_{T};f_{fake}", kTProfile, {{KNbinsPtRes, cfgPtMin, cfgPtMax}}); - histos.add("wgt_pT", ";p_{T};w", kTProfile, {{KNbinsPtRes, KPtMin, KPtMax}}); - histos.add("Eff_eta", ";#eta;#epsilon", kTProfile, {{KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - histos.add("Fake_eta", ";#eta;f_{fake}", kTProfile, {{KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - histos.add("wgt_eta", ";#eta;w", kTProfile, {{KNbinsEtaFine, -KEtaFineMax, KEtaFineMax}}); - // MC mean profiles (pT & Et) for various selections - histos.add("MCGen/Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); - histos.add("MCGen/Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); - histos.add("MCGen/Prof_MeanpT_Mult", ";N_{PV};#LT p_{T}#GT", kTProfile, {nChAxis}); - histos.add("pmeanTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - - histos.add("MCGen/Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); - histos.add("MCGen/Prof_MeanEt_Mult", ";N_{PV};#LT E_{T}#GT", kTProfile, {nChAxis}); - histos.add("pmeanEtTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanEtRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanEtRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanEtRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanEtRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - - histos.addClone("MCGen/", "MCReco/"); - histos.addClone("MCGen/", "MCRecoMatched/"); - histos.addClone("MCGen/", "MCRecoEffCorr/"); - histos.addClone("MCGen/", "MCRecoMatchedEffCorr/"); - } - void declareMCFlucHists() - { - static constexpr int KNbinsNchFluc = 1000; - // pT cumulants - histos.add("MCGen/Prof_C2_Cent", ";cent;C_{2}", kTProfile, {centAxis}); - histos.add("MCGen/Prof_C2_Mult", ";N_{PV};C_{2}", kTProfile, {nChAxis}); - histos.add("MCGen/Prof_C2Sub_Mult_etabin_ptbin", - ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, - {{KNbinsNchFluc, KNchMin, KNchCoarseMax}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("MCGen/Prof_ipt0_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt0_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt0_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - histos.add("MCGen/Prof_C2Et_Cent", ";cent;C_{2}^{E_{T}}", kTProfile, {centAxis}); - histos.add("MCGen/Prof_C2Et_Mult", ";N_{PV};C_{2}^{E_{T}}", kTProfile, {nChAxis}); - histos.add("MCGen/Prof_C2EtSub_Mult_etabin_ptbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, - {{KNbinsNchFluc, KNchMin, KNchCoarseMax}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("MCGen/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt0_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt0_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt1_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("MCGen/Prof_ipt2_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - - histos.add("MCGen/Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); - histos.add("MCGen/Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); - histos.add("MCGen/Prof_MeanpT_Mult", ";N_{PV};#LT p_{T}#GT", kTProfile, {nChAxis}); - - histos.add("pmeanTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - - histos.add("MCGen/Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); - histos.add("MCGen/Prof_MeanEt_Mult", ";N_{PV};#LT E_{T}#GT", kTProfile, {nChAxis}); - histos.add("pmeanEtTruNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanEtRecoNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanEtRecoMatchedNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanEtRecoEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("pmeanEtRecoMatchedEffcorrNchEtabinPtbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + if (isfinite(sumWiTruthEt[0][0])) { + float meanEt = sumWiptiTruthEt[0][0] / sumWiTruthEt[0][0]; + if (!isfinite(meanEt)) + LOGF(info, "meanEtTruthEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiTruthEt[0][0], sumWiTruthEt[0][0]); + if (!isfinite(meanEt)) + continue; + histos.fill(HIST("MCGen/Prof_MeanEt_Cent"), cent, meanEt); + histos.fill(HIST("MCGen/Prof_MeanEt_Mult"), col.multNTracksPV(), meanEt); } - void declareDataMeanHists() - { - histos.add("Prof_cent_Nchrec", ";cent;#LT N_{PV}#GT", kTProfile, {centAxis}); - histos.add("Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); - histos.add("pmean_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - // Et - histos.add("Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); - histos.add("pmeanEt_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + // "MCReco" + if (isfinite(sumWiRecoEt[0][0])) { + float meanEt = sumWiptiRecoEt[0][0] / sumWiRecoEt[0][0]; + if (!isfinite(meanEt)) + LOGF(info, "meanEtRecoEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiRecoEt[0][0], sumWiRecoEt[0][0]); + if (!isfinite(meanEt)) + continue; + histos.fill(HIST("MCReco/Prof_MeanEt_Cent"), cent, meanEt); + histos.fill(HIST("MCReco/Prof_MeanEt_Mult"), col.multNTracksPV(), meanEt); } - - void declareDataGetFlatHists() - { - histos.add("hCentEtaPhi_PID", ";cent;#eta;#phi", kTH3F, {{centAxis}, {(KNEta - 1), KEtaAxisMin, KEtaAxisMax}, {KNbinsPhiFine, 0, TwoPI}}); + // "MCRecoEffCorr" + if (isfinite(sumWiRecoEffCorrEt[0][0])) { + float meanEt = sumWiptiRecoEffCorrEt[0][0] / sumWiRecoEffCorrEt[0][0]; + if (!isfinite(meanEt)) + LOGF(info, "meanEtRecoEffcorrEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiRecoEffCorrEt[0][0], sumWiRecoEffCorrEt[0][0]); + if (!isfinite(meanEt)) + continue; + histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Cent"), cent, meanEt); + histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Mult"), col.multNTracksPV(), meanEt); } - void declareDataFlucHists() - { - histos.add("pmean_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - histos.add("Prof_MeanEt_Cent", ";cent;#LT E_{T}#GT", kTProfile, {centAxis}); - histos.add("pmeanEt_nch_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - - histos.add("Prof_C2_Cent", ";cent;C_{2}", kTProfile, {centAxis}); - histos.add("Prof_MeanpT_Cent", ";cent;#LT p_{T}#GT", kTProfile, {centAxis}); - histos.add("Prof_MeanpT_Mult", ";N_{PV};#LT p_{T}#GT", kTProfile, {nChAxis}); - histos.add("Prof_C2_Mult_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - - histos.add("Prof_ipt0_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("Prof_ipt0_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - histos.add("Prof_ipt1_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("Prof_ipt1_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - histos.add("Prof_ipt2_Cov_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("Prof_ipt2_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - - histos.add("Prof_C2Et_Cent", ";cent;C_{2}^{E_{T}}", kTProfile, {centAxis}); - histos.add("Prof_MeanEt_Mult", ";N_{PV};#LT E_{T}#GT", kTProfile, {nChAxis}); - histos.add("Prof_C2Et_Mult_etabin_ptbin", ";N_{PV};#eta-bin;p_{T}-bin", kTProfile3D, {{nChAxis}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); - - histos.add("Prof_ipt0_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("Prof_ipt0_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - histos.add("Prof_ipt1_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("Prof_ipt1_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - histos.add("Prof_ipt2_CovEt_Cent_eta", ";cent;#eta", kTProfile2D, {{centAxis}, {(KNEta - 1) / 2, 0, KEtaAxisMax}}); - histos.add("Prof_ipt2_CovEt_Eta", ";#eta;cov^{E_{T}}", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); - - histos.add("Prof_ipt0_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - histos.add("Prof_ipt1_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - histos.add("Prof_ipt2_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - histos.add("Prof_ipt0_C2SubEt2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - histos.add("Prof_ipt1_C2SubEt2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); - histos.add("Prof_ipt2_C2SubEt2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); + for (int ieta = 0; ieta < KNEta; ++ieta) { + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (isfinite(sumWiTruth[ieta][ipt])) + histos.fill(HIST("pmeanTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiTruth[ieta][ipt] / sumWiTruth[ieta][ipt]); + if (isfinite(sumWiReco[ieta][ipt])) + histos.fill(HIST("pmeanRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiReco[ieta][ipt] / sumWiReco[ieta][ipt]); + if (isfinite(sumWiRecoEffCorr[ieta][ipt])) + histos.fill(HIST("pmeanRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiRecoEffCorr[ieta][ipt] / sumWiRecoEffCorr[ieta][ipt]); + + if (isfinite(sumWiTruthEt[ieta][ipt])) + histos.fill(HIST("pmeanEtTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiTruthEt[ieta][ipt] / sumWiTruthEt[ieta][ipt]); + if (isfinite(sumWiRecoEt[ieta][ipt])) + histos.fill(HIST("pmeanEtRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiRecoEt[ieta][ipt] / sumWiRecoEt[ieta][ipt]); + if (isfinite(sumWiRecoEffCorrEt[ieta][ipt])) + histos.fill(HIST("pmeanEtRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiRecoEffCorrEt[ieta][ipt] / sumWiRecoEffCorrEt[ieta][ipt]); + } } - - TH3F* buildWeightMapFromRaw(TH3F* hRaw, const char* mapName) - { - if (!hRaw) { - LOGF(error, "Raw eta-phi map for '%s' is null; no flattening will be applied.", mapName); - return nullptr; + } // end col loop + } + + LOGF(info, "FINISHED RUNNING processMCMean (pT + Et)"); + } + PROCESS_SWITCH(RadialFlowDecorr, processMCMean, "process MC to calculate mean pt/Et and Eff Hists", cfgRunMCMean); + + void processMCFluc(aod::McCollisions const& mcColl, MyRun3MCCollisions const& collisions, TCs const& tracks, FilteredTCs const& /*filteredTracks*/, aod::McParticles const& mcParticles) + { + double sumPmwkTru[KNEta][KNpT][KIntM][KIntK]{}; + double sumWkTru[KNEta][KNpT][KIntK]{}; + double sumPmwkReco[KNEta][KNpT][KIntM][KIntK]{}; + double sumWkReco[KNEta][KNpT][KIntK]{}; + double sumPmwkRecoEffCor[KNEta][KNpT][KIntM][KIntK]{}; + double sumWkRecoEffCor[KNEta][KNpT][KIntK]{}; + double sumPmwkTruEt[KNEta][KNpT][KIntM][KIntK]{}; + double sumWkTruEt[KNEta][KNpT][KIntK]{}; + double sumPmwkRecoEt[KNEta][KNpT][KIntM][KIntK]{}; + double sumWkRecoEt[KNEta][KNpT][KIntK]{}; + double sumPmwkRecoEffCorEt[KNEta][KNpT][KIntM][KIntK]{}; + double sumWkRecoEffCorEt[KNEta][KNpT][KIntK]{}; + double meanTru[KNEta][KNpT]{}, c2Tru[KNEta][KNpT]{}; + double meanReco[KNEta][KNpT]{}, c2Reco[KNEta][KNpT]{}; + double meanRecoEffCor[KNEta][KNpT]{}, c2RecoEffCor[KNEta][KNpT]{}; + double meanTruEt[KNEta][KNpT]{}, c2TruEt[KNEta][KNpT]{}; + double meanRecoEt[KNEta][KNpT]{}, c2RecoEt[KNEta][KNpT]{}; + double meanRecoEffCorEt[KNEta][KNpT]{}, c2RecoEffCorEt[KNEta][KNpT]{}; + + for (const auto& mcCollision : mcColl) { + auto partSlice = mcParticles.sliceBy(partPerMcCollision, mcCollision.globalIndex()); + auto colSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex()); + if (colSlice.size() != 1) + continue; + // histos.fill(HIST("MCGen/hVtxZ"), mcCollision.posZ()); + for (const auto& col : colSlice) { + + auto trackSlice = tracks.sliceBy(trackPerCollision, col.globalIndex()); + if (trackSlice.size() < 1) + continue; + + memset(sumPmwkTru, 0, sizeof(sumPmwkTru)); + memset(sumWkTru, 0, sizeof(sumWkTru)); + memset(sumPmwkReco, 0, sizeof(sumPmwkReco)); + memset(sumWkReco, 0, sizeof(sumWkReco)); + memset(sumPmwkRecoEffCor, 0, sizeof(sumPmwkRecoEffCor)); + memset(sumWkRecoEffCor, 0, sizeof(sumWkRecoEffCor)); + + memset(sumPmwkTruEt, 0, sizeof(sumPmwkTruEt)); + memset(sumWkTruEt, 0, sizeof(sumWkTruEt)); + memset(sumPmwkRecoEt, 0, sizeof(sumPmwkRecoEt)); + memset(sumWkRecoEt, 0, sizeof(sumWkRecoEt)); + memset(sumPmwkRecoEffCorEt, 0, sizeof(sumPmwkRecoEffCorEt)); + memset(sumWkRecoEffCorEt, 0, sizeof(sumWkRecoEffCorEt)); + + memset(meanTru, 0, sizeof(meanTru)); + memset(c2Tru, 0, sizeof(c2Tru)); + memset(meanReco, 0, sizeof(meanReco)); + memset(c2Reco, 0, sizeof(c2Reco)); + memset(meanRecoEffCor, 0, sizeof(meanRecoEffCor)); + memset(c2RecoEffCor, 0, sizeof(c2RecoEffCor)); + + memset(meanTruEt, 0, sizeof(meanTruEt)); + memset(c2TruEt, 0, sizeof(c2TruEt)); + memset(meanRecoEt, 0, sizeof(meanRecoEt)); + memset(c2RecoEt, 0, sizeof(c2RecoEt)); + memset(meanRecoEffCorEt, 0, sizeof(meanRecoEffCorEt)); + memset(c2RecoEffCorEt, 0, sizeof(c2RecoEffCorEt)); + + if (!col.has_mcCollision() || !isEventSelected(col)) + continue; + float cent = getCentrality(col); + if (cent > KCentMax) + continue; + + // truth + for (const auto& particle : partSlice) { + if (!isParticleSelected(particle)) + continue; + if (!particle.isPhysicalPrimary()) + continue; + float pt = particle.pt(); + float eta = particle.eta(); + float p = particle.p(); + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; + for (int k = 0; k < KIntK; ++k) { + for (int m = 0; m < KIntM; ++m) { + sumPmwkTru[ieta][ipt][m][k] += std::pow(pt, m); + } + sumWkTru[ieta][ipt][k]++; + } + } } - auto hWeightMap = reinterpret_cast(hRaw->Clone(mapName)); - hWeightMap->SetTitle(Form("Flattening Weight Map %s (w_{#phi} = / N_{#phi})", mapName)); - hWeightMap->SetDirectory(nullptr); - hWeightMap->Reset(); - auto axC = hRaw->GetXaxis(); - auto axE = hRaw->GetYaxis(); - auto axP = hRaw->GetZaxis(); - for (int ic = 1; ic <= axC->GetNbins(); ++ic) { - for (int ie = 1; ie <= axE->GetNbins(); ++ie) { - // average over phi at fixed (cent,eta) - double sum = 0.0; - int nphi = axP->GetNbins(); - for (int ip = 1; ip <= nphi; ++ip) - sum += hRaw->GetBinContent(ic, ie, ip); - const double avg = (nphi > 0 ? sum / nphi : 0.0); - for (int ip = 1; ip <= nphi; ++ip) { - const double raw = hRaw->GetBinContent(ic, ie, ip); - const double w = (avg > 0.0 && raw > 0.0) ? (avg / raw) : 1.0; - hWeightMap->SetBinContent(ic, ie, ip, w); + const int absPdgId = std::abs(particle.pdgCode()); + const bool isPion = (absPdgId == kPiPlus); + const bool isKaon = (absPdgId == kKPlus); + const bool isProton = (absPdgId == kProton); + if (isPion || isKaon || isProton) { + + float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus + : o2::constants::physics::MassProton; + float energy = std::sqrt(p * p + m * m); + float et = energy * (pt / p); + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; + for (int k = 0; k < KIntK; ++k) { + for (int m = 0; m < KIntM; ++m) { + sumPmwkTruEt[ieta][ipt][m][k] += std::pow(et, m); + } + sumWkTruEt[ieta][ipt][k]++; + } } } } - LOGF(info, "Flattening weight map '%s' built.", mapName); - return hWeightMap; - } - inline void loadTProfile3D(TDirectory* dir, const char* name, TProfile3D*& target) - { - if (!dir) { - LOGF(error, "loadTProfile3D: directory is null for object %s", name); - return; + } // end truth loop + + for (const auto& track : trackSlice) { + if (!isTrackSelected(track)) + continue; + float pt = track.pt(); + float eta = track.eta(); + float p = track.p(); + float phi = track.phi(); + + float effIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 0); + float fakeIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 1); + float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); + float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; + if (!std::isfinite(wIncl) || wIncl <= 0.f) + continue; + if (effIncl <= 0 || !isfinite(effIncl) || !isfinite(fakeIncl) || !isfinite(flatWeightIncl)) + continue; + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; + for (int k = 0; k < KIntK; ++k) { + for (int m = 0; m < KIntM; ++m) { + sumPmwkReco[ieta][ipt][m][k] += std::pow(1.0f, k) * std::pow(pt, m); + sumPmwkRecoEffCor[ieta][ipt][m][k] += std::pow(wIncl, k) * std::pow(pt, m); + } + sumWkReco[ieta][ipt][k] += std::pow(1.0f, k); + sumWkRecoEffCor[ieta][ipt][k] += std::pow(wIncl, k); + } + } } - auto* obj = dir->Get(name); - if (!obj) { - LOGF(error, "loadTProfile3D: object '%s' not found in directory %s", name, dir->GetName()); - return; + const bool isPion = selectionPion(track); + const bool isKaon = selectionKaon(track); + const bool isProton = selectionProton(track); + + if (isPion || isKaon || isProton) { + float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus + : o2::constants::physics::MassProton; + float energy = std::sqrt(p * p + m * m); + float et = energy * (pt / p); // E_T = E * sin(theta) + float effPid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 0); + float fakePid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 1); + float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); + float wPid = flatWeightPid * (1.0 - fakePid) / effPid; + if (effPid >= 1.f || fakePid >= 1.f || !isfinite(effPid) || effPid <= KFloatEpsilon || !isfinite(fakePid) || !isfinite(flatWeightPid)) + continue; + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; + for (int k = 0; k < KIntK; ++k) { + for (int m = 0; m < KIntM; ++m) { + sumPmwkRecoEt[ieta][ipt][m][k] += std::pow(1.0f, k) * std::pow(et, m); + sumPmwkRecoEffCorEt[ieta][ipt][m][k] += std::pow(wPid, k) * std::pow(et, m); + } + sumWkRecoEt[ieta][ipt][k] += std::pow(1.0f, k); + sumWkRecoEffCorEt[ieta][ipt][k] += std::pow(wPid, k); + } + } + } } - auto* prof = dynamic_cast(obj); - if (!prof) { - LOGF(error, "loadTProfile3D: object '%s' is not a TProfile3D (it is %s)", name, obj->ClassName()); - return; + for (int ieta = 0; ieta < KNEta; ++ieta) { + for (int ipt = 0; ipt < KNpT; ++ipt) { + const int ibx = pmeanTruNchEtabinPtbinStep2->GetXaxis()->FindBin(col.multNTracksPV()); + const int iby = ieta + 1; + const int ibz = ipt + 1; + + float mmptTru = pmeanTruNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmptReco = pmeanRecoNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmptRecoEffCor = pmeanRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmetTru = pmeanEtTruNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmetReco = pmeanEtRecoNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmetRecoEffCor = pmeanEtRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + + if (isfinite(mmptTru)) + std::tie(meanTru[ieta][ipt], c2Tru[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkTru[ieta][ipt], sumWkTru[ieta][ipt], mmptTru); + if (isfinite(mmptReco)) + std::tie(meanReco[ieta][ipt], c2Reco[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkReco[ieta][ipt], sumWkReco[ieta][ipt], mmptReco); + if (isfinite(mmptRecoEffCor)) + std::tie(meanRecoEffCor[ieta][ipt], c2RecoEffCor[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEffCor[ieta][ipt], sumWkRecoEffCor[ieta][ipt], mmptRecoEffCor); + + if (isfinite(mmetTru)) + std::tie(meanTruEt[ieta][ipt], c2TruEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkTruEt[ieta][ipt], sumWkTruEt[ieta][ipt], mmetTru); + if (isfinite(mmetReco)) + std::tie(meanRecoEt[ieta][ipt], c2RecoEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEt[ieta][ipt], sumWkRecoEt[ieta][ipt], mmetReco); + if (isfinite(mmetRecoEffCor)) + std::tie(meanRecoEffCorEt[ieta][ipt], c2RecoEffCorEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEffCorEt[ieta][ipt], sumWkRecoEffCorEt[ieta][ipt], mmetRecoEffCor); + } } + } + if (std::isfinite(c2Tru[0][0])) { + histos.fill(HIST("MCGen/Prof_C2_Cent"), cent, c2Tru[0][0]); + histos.fill(HIST("MCGen/Prof_C2_Mult"), col.multNTracksPV(), c2Tru[0][0]); + } + if (std::isfinite(c2TruEt[0][0])) { + histos.fill(HIST("MCGen/Prof_C2Et_Cent"), cent, c2TruEt[0][0]); + histos.fill(HIST("MCGen/Prof_C2Et_Mult"), col.multNTracksPV(), c2TruEt[0][0]); + } + // "MCReco" + if (std::isfinite(c2Reco[0][0])) { + histos.fill(HIST("MCReco/Prof_C2_Cent"), cent, c2Reco[0][0]); + histos.fill(HIST("MCReco/Prof_C2_Mult"), col.multNTracksPV(), c2Reco[0][0]); + } + if (std::isfinite(c2RecoEt[0][0])) { + histos.fill(HIST("MCReco/Prof_C2Et_Cent"), cent, c2RecoEt[0][0]); + histos.fill(HIST("MCReco/Prof_C2Et_Mult"), col.multNTracksPV(), c2RecoEt[0][0]); + } - target = reinterpret_cast(prof->Clone(Form("%s_clone", name))); - target->SetDirectory(nullptr); - LOGF(info, "Loaded TProfile3D '%s' with entries = %.0f", name, target->GetEntries()); + if (std::isfinite(c2RecoEffCor[0][0])) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2_Cent"), cent, c2RecoEffCor[0][0]); + histos.fill(HIST("MCRecoEffCorr/Prof_C2_Mult"), col.multNTracksPV(), c2RecoEffCor[0][0]); + } + if (std::isfinite(c2RecoEffCorEt[0][0])) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2Et_Cent"), cent, c2RecoEffCorEt[0][0]); + histos.fill(HIST("MCRecoEffCorr/Prof_C2Et_Mult"), col.multNTracksPV(), c2RecoEffCorEt[0][0]); } - void init(InitContext&) - { - ccdb->setURL("https://alice-ccdb.cern.ch"); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - int64_t now = std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch()) - .count(); - ccdb->setCreatedNotAfter(now); + if (std::isfinite(sumWkTru[0][0][1])) { + histos.fill(HIST("MCGen/Prof_cent_Nchrec"), cent, sumWkTru[0][0][1]); + histos.fill(HIST("MCGen/Prof_MeanpT_Cent"), cent, meanTru[0][0]); + histos.fill(HIST("MCGen/Prof_MeanpT_Mult"), col.multNTracksPV(), meanTru[0][0]); + } + if (std::isfinite(sumWkTruEt[0][0][1])) { + histos.fill(HIST("MCGen/Prof_MeanEt_Cent"), cent, meanTruEt[0][0]); + histos.fill(HIST("MCGen/Prof_MeanEt_Mult"), col.multNTracksPV(), meanTruEt[0][0]); + } + // "MCReco" + if (std::isfinite(sumWkReco[0][0][1])) { + histos.fill(HIST("MCReco/Prof_cent_Nchrec"), cent, sumWkReco[0][0][1]); + histos.fill(HIST("MCReco/Prof_MeanpT_Cent"), cent, meanReco[0][0]); + histos.fill(HIST("MCReco/Prof_MeanpT_Mult"), col.multNTracksPV(), meanReco[0][0]); + } + if (std::isfinite(sumWkRecoEt[0][0][1])) { + histos.fill(HIST("MCReco/Prof_MeanEt_Cent"), cent, meanRecoEt[0][0]); + histos.fill(HIST("MCReco/Prof_MeanEt_Mult"), col.multNTracksPV(), meanRecoEt[0][0]); + } + // "MCRecoEffCorr" + if (std::isfinite(sumWkRecoEffCor[0][0][1])) { + histos.fill(HIST("MCRecoEffCorr/Prof_cent_Nchrec"), cent, sumWkRecoEffCor[0][0][1]); + histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Cent"), cent, meanRecoEffCor[0][0]); + histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Mult"), col.multNTracksPV(), meanRecoEffCor[0][0]); + } + if (std::isfinite(sumWkRecoEffCorEt[0][0][1])) { + histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Cent"), cent, meanRecoEffCorEt[0][0]); + histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Mult"), col.multNTracksPV(), meanRecoEffCorEt[0][0]); + } - declareCommonQA(); + for (int ieta = 0; ieta < KNEta; ++ieta) { + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (std::isfinite(sumWkTru[ieta][ipt][1])) + histos.fill(HIST("pmeanTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanTru[ieta][ipt]); + if (std::isfinite(sumWkReco[ieta][ipt][1])) + histos.fill(HIST("pmeanRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanReco[ieta][ipt]); + if (std::isfinite(sumWkRecoEffCor[ieta][ipt][1])) + histos.fill(HIST("pmeanRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanRecoEffCor[ieta][ipt]); + if (std::isfinite(sumWkTruEt[ieta][ipt][1])) + histos.fill(HIST("pmeanEtTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanTruEt[ieta][ipt]); + if (std::isfinite(sumWkRecoEt[ieta][ipt][1])) + histos.fill(HIST("pmeanEtRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanRecoEt[ieta][ipt]); + if (std::isfinite(sumWkRecoEffCorEt[ieta][ipt][1])) + histos.fill(HIST("pmeanEtRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanRecoEffCorEt[ieta][ipt]); + } + } - const std::string userCcdbPath = "/Users/s/somadutt/PbPbTest/"; + float p1kBarTru[KNEta][KNpT]{}, p1kBarReco[KNEta][KNpT]{}, p1kBarRecoEffCor[KNEta][KNpT]{}; + float p1kBarTruEt[KNEta][KNpT]{}, p1kBarRecoEt[KNEta][KNpT]{}, p1kBarRecoEffCorEt[KNEta][KNpT]{}; + for (int ieta = 0; ieta < KNEta; ++ieta) { + for (int ipt = 0; ipt < KNpT; ++ipt) { + const int ibx = pmeanTruNchEtabinPtbinStep2->GetXaxis()->FindBin(col.multNTracksPV()); + const int iby = ieta + 1; + const int ibz = ipt + 1; + + float mmptTru = pmeanTruNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmptReco = pmeanRecoNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmptRecoEffCor = pmeanRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmetTru = pmeanEtTruNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmetReco = pmeanEtRecoNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmetRecoEffCor = pmeanEtRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + + if (mmptTru != 0.0f) + p1kBarTru[ieta][ipt] = meanTru[ieta][ipt] - mmptTru; + if (mmptReco != 0.0f) + p1kBarReco[ieta][ipt] = meanReco[ieta][ipt] - mmptReco; + if (mmptRecoEffCor != 0.0f) + p1kBarRecoEffCor[ieta][ipt] = meanRecoEffCor[ieta][ipt] - mmptRecoEffCor; + + if (mmetTru != 0.0f) + p1kBarTruEt[ieta][ipt] = meanTruEt[ieta][ipt] - mmetTru; + if (mmetReco != 0.0f) + p1kBarRecoEt[ieta][ipt] = meanRecoEt[ieta][ipt] - mmetReco; + if (mmetRecoEffCor != 0.0f) + p1kBarRecoEffCorEt[ieta][ipt] = meanRecoEffCorEt[ieta][ipt] - mmetRecoEffCor; + } + } - if (cfgRunMCMean || cfgRunMCFluc || cfgRunGetEff) { - declareMCCommonHists(); + // 1D Covariance (vs eta) + for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { + int ietaC = KNEta - ietaA; + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); + { + const int ipt = 0; + float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCGen/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCGen/Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("MCGen/Prof_ipt0_Cov_Eta"), valy, c2Sub); } - if (cfgRunMCMean) { - declareMCMeanHists(); + float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCGen/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCGen/Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("MCGen/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); } - if (cfgRunMCFluc) { - declareMCFlucHists(); - - histos.addClone("MCGen/", "MCReco/"); - histos.addClone("MCGen/", "MCRecoMatched/"); - histos.addClone("MCGen/", "MCRecoEffCorr/"); - histos.addClone("MCGen/", "MCRecoMatchedEffCorr/"); + } + // ipt = 1 + { + const int ipt = 1; + float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCGen/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCGen/Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("MCGen/Prof_ipt0_Cov_Eta"), valy, c2Sub); } - if (cfgRunGetFlat) { - declareDataGetFlatHists(); + float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCGen/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCGen/Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("MCGen/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); } - if (cfgRunDataMean) { - declareDataMeanHists(); + } + // ipt = 2 + { + const int ipt = 2; + float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCGen/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCGen/Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("MCGen/Prof_ipt2_Cov_Eta"), valy, c2Sub); } - if (cfgRunDataFluc) { - declareDataFlucHists(); + float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCGen/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCGen/Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("MCGen/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); } + } + } - const bool needEffMaps = cfgRunMCMean || cfgRunMCFluc || cfgRunDataMean || cfgRunDataFluc; - if (needEffMaps && !cfgRunGetEff) { - - LOGF(info, "Loading Eff/Fake maps from CCDB path: %s", userCcdbPath.c_str()); - - auto loadEffFakeForPID = [&](PID pidType) { - std::string suffix = pidSuffix[pidType]; - std::string hEffNumName = "h3_RecoMatchedToPrimary" + suffix; - std::string hEffDenName = "h3_AllPrimary" + suffix; - std::string hFakeNumSecName = "h3_RecoUnMatchedToPrimary_Secondary" + suffix; - std::string hFakeNumFakName = "h3_RecoUnMatchedToPrimary_Fake" + suffix; - std::string hFakeDenName = "h3_AllReco" + suffix; - - // --- Efficiency --- - auto* hNum = ccdb->get(userCcdbPath + hEffNumName); - auto* hDen = ccdb->get(userCcdbPath + hEffDenName); - if (hNum && hDen) { - hEff[pidType] = reinterpret_cast(hNum->Clone(Form("hEff%s", suffix.c_str()))); - hEff[pidType]->SetDirectory(nullptr); - hEff[pidType]->Divide(hDen); - } else { - LOGF(error, "Missing CCDB objects for efficiency. Checked:\n%s\n%s", - (userCcdbPath + hEffNumName).c_str(), - (userCcdbPath + hEffDenName).c_str()); - } - - // --- Fakes --- - auto* hNumS = ccdb->get(userCcdbPath + hFakeNumSecName); - auto* hNumF = ccdb->get(userCcdbPath + hFakeNumFakName); - auto* hDenF = ccdb->get(userCcdbPath + hFakeDenName); - if (hNumS && hNumF && hDenF) { - hFake[pidType] = reinterpret_cast(hNumS->Clone(Form("hFake%s", suffix.c_str()))); - hFake[pidType]->Add(hNumF); - hFake[pidType]->SetDirectory(nullptr); - hFake[pidType]->Divide(hDenF); - } else { - LOGF(error, "Missing CCDB object(s) for fakes for %s. Checked path prefix: %s", - suffix.c_str(), userCcdbPath.c_str()); - } - }; - - loadEffFakeForPID(kInclusive); - loadEffFakeForPID(kCombinedPID); - - const bool isDataRun = cfgRunDataMean || cfgRunDataFluc; - if (isDataRun) { - LOGF(info, "Data Run: Loading flattening maps from CCDB path: %s", userCcdbPath.c_str()); - - auto* hRawIncl = ccdb->get(userCcdbPath + "hCentEtaPhi"); - if (hRawIncl) { - hWeightMap3D[kInclusive] = buildWeightMapFromRaw(hRawIncl, "hWeightMap3D"); - } else { - LOGF(error, "Data flattening 'hCentEtaPhi' not found at path %s", - (userCcdbPath + "hCentEtaPhi").c_str()); - } - - auto* hRawPID = ccdb->get(userCcdbPath + "hCentEtaPhi_PID"); - if (hRawPID) { - hWeightMap3D[kCombinedPID] = buildWeightMapFromRaw(hRawPID, "hWeightMap3D_PID"); - } else { - LOGF(error, "Data flattening 'hCentEtaPhi_PID' not found at path %s", - (userCcdbPath + "hCentEtaPhi_PID").c_str()); - } - } else { - LOGF(info, "MC Run: Loading flattening maps from CCDB path: %s", userCcdbPath.c_str()); - - auto loadFlatForPID = [&](PID pidType) { - std::string suffix = pidSuffix[pidType]; - std::string hFlatSrcName = "hCentEtaPhiReco" + suffix; - auto* hRaw = ccdb->get(userCcdbPath + hFlatSrcName); - if (hRaw) { - hWeightMap3D[pidType] = buildWeightMapFromRaw(hRaw, Form("hWeightMap3D%s", suffix.c_str())); - } else { - LOGF(warning, "MC flattening source '%s' not found at %s; skipping this PID.", - hFlatSrcName.c_str(), (userCcdbPath + hFlatSrcName).c_str()); - } - }; - loadFlatForPID(kInclusive); - loadFlatForPID(kCombinedPID); - } + for (int ietaA = 1; ietaA < KNEta; ++ietaA) { + for (int ietaC = 1; ietaC < KNEta; ++ietaC) { + float valx = KHalf * (etaLw[ietaA] + etaUp[ietaA]); + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); + // ipt = 0 + { + const int ipt = 0; + float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCGen/Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCGen/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); } - - auto loadTProfile3DFromCCDB = [&](const std::string& ccdbPath, const char* objName, TProfile3D*& target) { - std::string fullPath = ccdbPath + objName; - LOGF(info, "Loading TProfile3D from CCDB: %s", fullPath.c_str()); - if (auto* tp = ccdb->get(fullPath)) { - target = reinterpret_cast(tp->Clone()); - target->SetDirectory(nullptr); - } else { - LOGF(error, "Histogram %s missing in CCDB at path: %s", objName, fullPath.c_str()); - } - }; - - if (cfgRunMCFluc) { - LOGF(info, "Loading MC Mean profiles from CCDB path: %s", userCcdbPath.c_str()); - - loadTProfile3DFromCCDB(userCcdbPath, "pmeanTruNchEtabinPtbin", pmeanTruNchEtabinPtbinStep2); - loadTProfile3DFromCCDB(userCcdbPath, "pmeanRecoNchEtabinPtbin", pmeanRecoNchEtabinPtbinStep2); - loadTProfile3DFromCCDB(userCcdbPath, "pmeanRecoMatchedNchEtabinPtbin", pmeanRecoMatchedNchEtabinPtbinStep2); - loadTProfile3DFromCCDB(userCcdbPath, "pmeanRecoEffcorrNchEtabinPtbin", pmeanRecoEffcorrNchEtabinPtbinStep2); - loadTProfile3DFromCCDB(userCcdbPath, "pmeanRecoMatchedEffcorrNchEtabinPtbin", pmeanRecoMatchedEffcorrNchEtabinPtbinStep2); - - loadTProfile3DFromCCDB(userCcdbPath, "pmeanEtTruNchEtabinPtbin", pmeanEtTruNchEtabinPtbinStep2); - loadTProfile3DFromCCDB(userCcdbPath, "pmeanEtRecoNchEtabinPtbin", pmeanEtRecoNchEtabinPtbinStep2); - loadTProfile3DFromCCDB(userCcdbPath, "pmeanEtRecoMatchedNchEtabinPtbin", pmeanEtRecoMatchedNchEtabinPtbinStep2); - loadTProfile3DFromCCDB(userCcdbPath, "pmeanEtRecoEffcorrNchEtabinPtbin", pmeanEtRecoEffcorrNchEtabinPtbinStep2); - loadTProfile3DFromCCDB(userCcdbPath, "pmeanEtRecoMatchedEffcorrNchEtabinPtbin", pmeanEtRecoMatchedEffcorrNchEtabinPtbinStep2); + // ipt = 1 + { + const int ipt = 1; + float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCGen/Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCGen/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); } - - if (cfgRunDataFluc) { - LOGF(info, "Loading Data Mean profiles from CCDB path: %s", userCcdbPath.c_str()); - loadTProfile3DFromCCDB(userCcdbPath, "pmean_nch_etabin_ptbin", pmeanNchEtabinPtbinStep2); - loadTProfile3DFromCCDB(userCcdbPath, "pmeanEt_nch_etabin_ptbin", pmeanEtNchEtabinPtbinStep2); + // ipt = 2 + { + const int ipt = 2; + float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCGen/Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCGen/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); } - - LOGF(info, "CCDB initialization complete for RadialFlowDecorr."); } + } - - void processGetEffHists(aod::McCollisions const& mcColl, soa::SmallGroups const& collisions, TCs const& tracks, FilteredTCs const& /*filteredTracks*/, aod::McParticles const& mcParticles) + for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { + int ietaC = KNEta - ietaA; + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); + // ipt = 0 { - for (const auto& mcCollision : mcColl) { - auto colSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex()); - if (colSlice.size() != 1) continue; - - for (const auto& col : colSlice) { - if (!col.has_mcCollision()) continue; - if (!isEventSelected(col)) continue; - - auto trackSlice = tracks.sliceBy(trackPerCollision, col.globalIndex()); - if (trackSlice.size() < 1) continue; - - auto partSlice = mcParticles.sliceBy(partPerMcCollision, mcCollision.globalIndex()); - if (partSlice.size() < 1) continue; - if (col.globalIndex() >= trackSlice.size()) { - LOGF(warning, "Skipping invalid globalIndex=%d for tracks (tracks.size=%d)", col.globalIndex(), tracks.size()); - continue; - } - - float cent = getCentrality(col); - if (cent > KCentMax) continue; - - for (const auto& particle : partSlice) { - if (!isParticleSelected(particle)) continue; - if (!particle.isPhysicalPrimary()) continue; - - const int absPdgId = std::abs(particle.pdgCode()); - const bool isPion = (absPdgId == KPiPlus); - const bool isKaon = (absPdgId == KKPlus); - const bool isProton = (absPdgId == KProton); - const bool isPid = (isPion || isKaon || isProton); - - histos.fill(HIST("hTruth_ParticleWeight"), cent, particle.pt(), particle.eta(), particle.weight()); - histos.fill(HIST("hCentEtaPhiTrue"), cent, particle.eta(), particle.phi()); - histos.fill(HIST("h3_AllPrimary"), col.multNTracksPV(), particle.pt(), particle.eta()); - - if (cent < KCentTestMin) - histos.fill(HIST("hCent1EtaPhi"), particle.eta(), particle.phi()); - if (cent > KCentTestMaxLo && cent < KCentTestMaxHi) - histos.fill(HIST("hCent7EtaPhi"), particle.eta(), particle.phi()); - - if (isPid) { - histos.fill(HIST("hCentEtaPhiTrue_PID"), cent, particle.eta(), particle.phi()); - histos.fill(HIST("h3_AllPrimary_PID"), col.multNTracksPV(), particle.pt(), particle.eta()); - } - } - histos.fill(HIST("TruthTracKVz"), mcCollision.posZ(), col.posZ()); - histos.fill(HIST("vzResolution"), mcCollision.posZ(), mcCollision.posZ() - col.posZ()); - - // Reconstructed - for (const auto& track : trackSlice) { - if (!isTrackSelected(track)) continue; - - const bool isPion = selectionPion(track); - const bool isKaon = selectionKaon(track); - const bool isProton = selectionProton(track); - const bool isPid = (isPion || isKaon || isProton); - - histos.fill(HIST("h3_AllReco"), col.multNTracksPV(), track.pt(), track.eta()); - histos.fill(HIST("hCentEtaPhiReco"), cent, track.eta(), track.phi()); - - if (isPid) { - histos.fill(HIST("h3_AllReco_PID"), col.multNTracksPV(), track.pt(), track.eta()); - histos.fill(HIST("hCentEtaPhiReco_PID"), cent, track.eta(), track.phi()); - } - - if (track.has_mcParticle()) { - auto mcPart2 = track.mcParticle(); - if (mcPart2.isPhysicalPrimary()) { - const int absPdgId = std::abs(mcPart2.pdgCode()); - const bool isPionTrue = (absPdgId == kPiPlus); - const bool isKaonTrue = (absPdgId == kKPlus); - const bool isProtonTrue = (absPdgId == kProton); - const bool isPidTrue = (isPionTrue || isKaonTrue || isProtonTrue); - - histos.fill(HIST("hReco_ParticleWeight"), cent, mcPart2.pt(), mcPart2.eta(), mcPart2.weight()); - histos.fill(HIST("ptResolution"), mcPart2.pt(), mcPart2.pt() - track.pt()); - histos.fill(HIST("ptTruthReco"), mcPart2.pt(), track.pt()); - histos.fill(HIST("etaResolution"), mcPart2.eta(), mcPart2.eta() - track.eta()); - histos.fill(HIST("etaTruthReco"), mcPart2.eta(), track.eta()); - histos.fill(HIST("h3_RecoMatchedToPrimary"), col.multNTracksPV(), mcPart2.pt(), mcPart2.eta()); - histos.fill(HIST("hCentEtaPhiRecoMatched"), cent, mcPart2.eta(), mcPart2.phi()); - - if (isPid && isPidTrue) { - histos.fill(HIST("h3_RecoMatchedToPrimary_PID"), col.multNTracksPV(), mcPart2.pt(), mcPart2.eta()); - histos.fill(HIST("hCentEtaPhiRecoMatched_PID"), cent, mcPart2.eta(), mcPart2.phi()); - } - - } else { - // Matched to secondary - histos.fill(HIST("h3_RecoUnMatchedToPrimary_Secondary"), col.multNTracksPV(), track.pt(), track.eta()); - histos.fill(HIST("hDCAxy_Unmatched"), track.dcaXY()); - histos.fill(HIST("hDCAz_Unmatched"), track.dcaZ()); - if (isPid) { - histos.fill(HIST("h3_RecoUnMatchedToPrimary_Secondary_PID"), col.multNTracksPV(), track.pt(), track.eta()); - } - } - } else { - // Fake track - histos.fill(HIST("h3_RecoUnMatchedToPrimary_Fake"), col.multNTracksPV(), track.pt(), track.eta()); - histos.fill(HIST("hDCAxy_NotPrimary"), track.dcaXY()); - histos.fill(HIST("hDCAz_NotPrimary"), track.dcaZ()); - if (isPid) { - histos.fill(HIST("h3_RecoUnMatchedToPrimary_Fake_PID"), col.multNTracksPV(), track.pt(), track.eta()); - } - } - } // tracks - } // cols - } // mcColl - LOGF(info, "FINISHED RUNNING processGetEffHists"); + const int ipt = 0; + float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCReco/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCReco/Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("MCReco/Prof_ipt0_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCReco/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCReco/Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("MCReco/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); + } } - PROCESS_SWITCH(RadialFlowDecorr, processGetEffHists, "process MC to calculate Eff and Fakes", cfgRunGetEff); - void processMCMean(aod::McCollisions const& mcColl, MyRun3MCCollisions const& collisions, TCs const& tracks, FilteredTCs const& /*filteredTracks*/, aod::McParticles const& mcParticles) + // ipt = 1 { - float sumWiTruth[KNEta][KNpT], sumWiptiTruth[KNEta][KNpT]; - float sumWiReco[KNEta][KNpT], sumWiptiReco[KNEta][KNpT]; - float sumWiRecoMatched[KNEta][KNpT], sumWiptiRecoMatched[KNEta][KNpT]; - float sumWiRecoEffCorr[KNEta][KNpT], sumWiptiRecoEffCorr[KNEta][KNpT]; - float sumWiRecoMatchedEffCorr[KNEta][KNpT], sumWiptiRecoMatchedEffCorr[KNEta][KNpT]; - float sumWiTruthEt[KNEta][KNpT], sumWiptiTruthEt[KNEta][KNpT]; - float sumWiRecoEt[KNEta][KNpT], sumWiptiRecoEt[KNEta][KNpT]; - float sumWiRecoMatchedEt[KNEta][KNpT], sumWiptiRecoMatchedEt[KNEta][KNpT]; - float sumWiRecoEffCorrEt[KNEta][KNpT], sumWiptiRecoEffCorrEt[KNEta][KNpT]; - float sumWiRecoMatchedEffCorrEt[KNEta][KNpT], sumWiptiRecoMatchedEffCorrEt[KNEta][KNpT]; - - for (const auto& mcCollision : mcColl) { - auto colSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex()); - - if (colSlice.size() != 1) continue; - for (const auto& col : colSlice) { - if (!col.has_mcCollision()) continue; - if (!isEventSelected(col)) continue; - - auto trackSlice = tracks.sliceBy(trackPerCollision, col.globalIndex()); - if (trackSlice.size() < 1) continue; - - auto partSlice = mcParticles.sliceBy(partPerMcCollision, mcCollision.globalIndex()); - if (partSlice.size() < 1) continue; - if (col.globalIndex() >= trackSlice.size()) { - LOGF(warning, "Skipping invalid globalIndex=%d for tracks (tracks.size=%d)", col.globalIndex(), tracks.size()); - continue; - } - - float cent = getCentrality(col); - if (cent > KCentMax) continue; - - if (col.globalIndex() >= trackSlice.size()) { - LOGF(warning, "Skipping invalid globalIndex=%d for tracks (tracks.size=%d)", col.globalIndex(), tracks.size()); - continue; - } - - LOGF(info, "Event Check: cent = %.1f, nTracks = %d", cent, (int)trackSlice.size()); - memset(sumWiTruth, 0, sizeof(sumWiTruth)); - memset(sumWiptiTruth, 0, sizeof(sumWiptiTruth)); - memset(sumWiReco, 0, sizeof(sumWiReco)); - memset(sumWiptiReco, 0, sizeof(sumWiptiReco)); - memset(sumWiRecoMatched, 0, sizeof(sumWiRecoMatched)); - memset(sumWiptiRecoMatched, 0, sizeof(sumWiptiRecoMatched)); - memset(sumWiRecoEffCorr, 0, sizeof(sumWiRecoEffCorr)); - memset(sumWiptiRecoEffCorr, 0, sizeof(sumWiptiRecoEffCorr)); - memset(sumWiRecoMatchedEffCorr, 0, sizeof(sumWiRecoMatchedEffCorr)); - memset(sumWiptiRecoMatchedEffCorr, 0, sizeof(sumWiptiRecoMatchedEffCorr)); - memset(sumWiTruthEt, 0, sizeof(sumWiTruthEt)); - memset(sumWiptiTruthEt, 0, sizeof(sumWiptiTruthEt)); - memset(sumWiRecoEt, 0, sizeof(sumWiRecoEt)); - memset(sumWiptiRecoEt, 0, sizeof(sumWiptiRecoEt)); - memset(sumWiRecoMatchedEt, 0, sizeof(sumWiRecoMatchedEt)); - memset(sumWiptiRecoMatchedEt, 0, sizeof(sumWiptiRecoMatchedEt)); - memset(sumWiRecoEffCorrEt, 0, sizeof(sumWiRecoEffCorrEt)); - memset(sumWiptiRecoEffCorrEt, 0, sizeof(sumWiptiRecoEffCorrEt)); - memset(sumWiRecoMatchedEffCorrEt, 0, sizeof(sumWiRecoMatchedEffCorrEt)); - memset(sumWiptiRecoMatchedEffCorrEt, 0, sizeof(sumWiptiRecoMatchedEffCorrEt)); - - // Truth - for (const auto& particle : partSlice) { - if (!isParticleSelected(particle)) continue; - if (!particle.isPhysicalPrimary()) continue; - - const int absPdgId = std::abs(particle.pdgCode()); - const bool isPion = (absPdgId == kPiPlus); - const bool isKaon = (absPdgId == kKPlus); - const bool isProton = (absPdgId == kProton); - - float pt = particle.pt(); - float eta = particle.eta(); - float p = particle.p(); - - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; - sumWiTruth[ieta][ipt]++; - sumWiptiTruth[ieta][ipt] += pt; - if (isPion || isKaon || isProton) { - float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus - : o2::constants::physics::MassProton; - float energy = std::sqrt(p * p + m * m); - float et = energy * (pt / p); // E_T = E * sin(theta) = E * (pT / p) - sumWiTruthEt[ieta][ipt]++; - sumWiptiTruthEt[ieta][ipt] += et; - } - } - } - } - - for (const auto& track : trackSlice) { - if (!isTrackSelected(track)) continue; - - float pt = track.pt(); - float eta = track.eta(); - float p = track.p(); - float phi = track.phi(); - - histos.fill(HIST("hCentEtaPhi"), cent, eta, phi); - if (cent < KCentTestMin) - histos.fill(HIST("hCent1EtaPhi"), eta, phi); - if (cent > KCentTestMaxLo && cent < KCentTestMaxHi) - histos.fill(HIST("hCent7EtaPhi"), eta, phi); - - float effIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 0); - float fakeIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 1); - float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); - float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; - - histos.fill(HIST("hCentEtaPhiWtd"), cent, eta, track.phi(), flatWeightIncl); - if (cent < KCentTestMin) histos.fill(HIST("hCent1EtaPhiWtd"), track.eta(), track.phi(), flatWeightIncl); - if (cent > KCentTestMaxLo && cent < KCentTestMaxHi) histos.fill(HIST("hCent7EtaPhiWtd"), track.eta(), track.phi(), flatWeightIncl); - - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; - sumWiReco[ieta][ipt] += 1.0; - sumWiptiReco[ieta][ipt] += pt; - } - } - - if (effIncl <= 0 || !isfinite(wIncl) || !isfinite(fakeIncl) || !isfinite(flatWeightIncl)) continue; - - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; - sumWiRecoEffCorr[ieta][ipt] += wIncl; - sumWiptiRecoEffCorr[ieta][ipt] += wIncl * pt; - } - } - - const bool isPion = selectionPion(track); - const bool isKaon = selectionKaon(track); - const bool isProton = selectionProton(track); - if (isPion || isKaon || isProton) { - float effPid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 0); - float fakePid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 1); - float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); - float wPid = flatWeightPid * (1.0 - fakePid) / effPid; - - histos.fill(HIST("hCentEtaPhiWtd_PID"), cent, eta, track.phi(), flatWeightPid); - if (cent < KCentTestMin) histos.fill(HIST("hCent1EtaPhiWtd_PID"), track.eta(), track.phi(), flatWeightPid); - if (cent > KCentTestMaxLo && cent < KCentTestMaxHi) histos.fill(HIST("hCent7EtaPhiWtd_PID"), track.eta(), track.phi(), flatWeightPid); - - float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus : o2::constants::physics::MassProton; - float energy = std::sqrt(p * p + m * m); - float et = energy * (pt / p); // E_T = E * sin(theta) - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; - sumWiRecoEt[ieta][ipt] += 1.0; - sumWiptiRecoEt[ieta][ipt] += et; - } - } - - if (effPid <= KFloatEpsilon || !isfinite(wPid) || !isfinite(fakePid) || !isfinite(flatWeightPid)) continue; - - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) continue; - sumWiRecoEffCorrEt[ieta][ipt] += wPid; - sumWiptiRecoEffCorrEt[ieta][ipt] += wPid * et; - } - } - } - - if (isfinite(wIncl)) { - if (cent < KCentTestMin) { - histos.fill(HIST("wgt_pT"), pt, wIncl); - histos.fill(HIST("Eff_pT"), pt, effIncl); - histos.fill(HIST("Fake_pT"), pt, fakeIncl); - histos.fill(HIST("Eff_eta"), eta, effIncl); - histos.fill(HIST("Fake_eta"), eta, fakeIncl); - histos.fill(HIST("wgt_eta"), eta, wIncl); - } - histos.fill(HIST("Eff_cent"), cent, effIncl); - histos.fill(HIST("Eff_Ntrk"), col.multNTracksPV(), effIncl); - histos.fill(HIST("Fake_cent"), cent, fakeIncl); - histos.fill(HIST("Fake_Ntrk"), col.multNTracksPV(), fakeIncl); - histos.fill(HIST("wgt_cent"), cent, wIncl); - histos.fill(HIST("wgt_Ntrk"), col.multNTracksPV(), wIncl); - } - - } // end track loop - - if (isfinite(sumWiTruth[0][0])) { - float meanPtTruth = sumWiptiTruth[0][0] / sumWiTruth[0][0]; - if (!isfinite(meanPtTruth)) LOGF(info, "meanPtTruth = %.3f, num = %.3f, den =%.3f", meanPtTruth, sumWiptiTruth[0][0], sumWiTruth[0][0]); - if (!isfinite(meanPtTruth)) continue; - histos.fill(HIST("MCGen/Prof_cent_Nchrec"), cent, sumWiTruth[0][0]); - histos.fill(HIST("MCGen/Prof_MeanpT_Cent"), cent, meanPtTruth); - histos.fill(HIST("MCGen/Prof_MeanpT_Mult"), col.multNTracksPV(), meanPtTruth); - } - if (isfinite(sumWiReco[0][0])) { - float meanPtReco = sumWiptiReco[0][0] / sumWiReco[0][0]; - if (!isfinite(meanPtReco)) LOGF(info, "meanPtReco = %.3f, num = %.3f, den =%.3f", meanPtReco, sumWiptiReco[0][0], sumWiReco[0][0]); - if (!isfinite(meanPtReco)) continue; - histos.fill(HIST("MCReco/Prof_cent_Nchrec"), cent, sumWiReco[0][0]); - histos.fill(HIST("MCReco/Prof_MeanpT_Cent"), cent, meanPtReco); - histos.fill(HIST("MCReco/Prof_MeanpT_Mult"), col.multNTracksPV(), meanPtReco); - } - if (isfinite(sumWiRecoEffCorr[0][0])) { - float meanpTeffcorr = sumWiptiRecoEffCorr[0][0] / sumWiRecoEffCorr[0][0]; - if (!isfinite(meanpTeffcorr)) LOGF(info, "meanPtRecoEffcorr = %.3f, num = %.3f, den =%.3f", meanpTeffcorr, sumWiptiRecoEffCorr[0][0], sumWiRecoEffCorr[0][0]); - if (!isfinite(meanpTeffcorr)) continue; - histos.fill(HIST("MCRecoEffCorr/Prof_cent_Nchrec"), cent, sumWiRecoEffCorr[0][0]); - histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Cent"), cent, meanpTeffcorr); - histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Mult"), col.multNTracksPV(), meanpTeffcorr); - } - - if (isfinite(sumWiTruthEt[0][0])) { - float meanEt = sumWiptiTruthEt[0][0] / sumWiTruthEt[0][0]; - if (!isfinite(meanEt)) LOGF(info, "meanEtTruthEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiTruthEt[0][0], sumWiTruthEt[0][0]); - if (!isfinite(meanEt)) continue; - histos.fill(HIST("MCGen/Prof_MeanEt_Cent"), cent, meanEt); - histos.fill(HIST("MCGen/Prof_MeanEt_Mult"), col.multNTracksPV(), meanEt); - } - // "MCReco" - if (isfinite(sumWiRecoEt[0][0])) { - float meanEt = sumWiptiRecoEt[0][0] / sumWiRecoEt[0][0]; - if (!isfinite(meanEt)) LOGF(info, "meanEtRecoEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiRecoEt[0][0], sumWiRecoEt[0][0]); - if (!isfinite(meanEt)) continue; - histos.fill(HIST("MCReco/Prof_MeanEt_Cent"), cent, meanEt); - histos.fill(HIST("MCReco/Prof_MeanEt_Mult"), col.multNTracksPV(), meanEt); - } - // "MCRecoEffCorr" - if (isfinite(sumWiRecoEffCorrEt[0][0])) { - float meanEt = sumWiptiRecoEffCorrEt[0][0] / sumWiRecoEffCorrEt[0][0]; - if (!isfinite(meanEt)) LOGF(info, "meanEtRecoEffcorrEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiRecoEffCorrEt[0][0], sumWiRecoEffCorrEt[0][0]); - if (!isfinite(meanEt)) continue; - histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Cent"), cent, meanEt); - histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Mult"), col.multNTracksPV(), meanEt); - } - - for (int ieta = 0; ieta < KNEta; ++ieta) { - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (isfinite(sumWiTruth[ieta][ipt])) - histos.fill(HIST("pmeanTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiTruth[ieta][ipt] / sumWiTruth[ieta][ipt]); - if (isfinite(sumWiReco[ieta][ipt])) - histos.fill(HIST("pmeanRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiReco[ieta][ipt] / sumWiReco[ieta][ipt]); - if (isfinite(sumWiRecoEffCorr[ieta][ipt])) - histos.fill(HIST("pmeanRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiRecoEffCorr[ieta][ipt] / sumWiRecoEffCorr[ieta][ipt]); - - if (isfinite(sumWiTruthEt[ieta][ipt])) - histos.fill(HIST("pmeanEtTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiTruthEt[ieta][ipt] / sumWiTruthEt[ieta][ipt]); - if (isfinite(sumWiRecoEt[ieta][ipt])) - histos.fill(HIST("pmeanEtRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiRecoEt[ieta][ipt] / sumWiRecoEt[ieta][ipt]); - if (isfinite(sumWiRecoEffCorrEt[ieta][ipt])) - histos.fill(HIST("pmeanEtRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiRecoEffCorrEt[ieta][ipt] / sumWiRecoEffCorrEt[ieta][ipt]); - } - } - } // end col loop + const int ipt = 1; + float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCReco/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCReco/Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("MCReco/Prof_ipt1_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCReco/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCReco/Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("MCReco/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); } - - LOGF(info, "FINISHED RUNNING processMCMean (pT + Et)"); } - PROCESS_SWITCH(RadialFlowDecorr, processMCMean, "process MC to calculate mean pt/Et and Eff Hists", cfgRunMCMean); - void processMCFluc(aod::McCollisions const& mcColl, MyRun3MCCollisions const& collisions, TCs const& tracks, FilteredTCs const& /*filteredTracks*/, aod::McParticles const& mcParticles) + // ipt = 2 { - double sumPmwkTru[KNEta][KNpT][KIntM][KIntK]{}; - double sumWkTru[KNEta][KNpT][KIntK]{}; - double sumPmwkReco[KNEta][KNpT][KIntM][KIntK]{}; - double sumWkReco[KNEta][KNpT][KIntK]{}; - double sumPmwkRecoEffCor[KNEta][KNpT][KIntM][KIntK]{}; - double sumWkRecoEffCor[KNEta][KNpT][KIntK]{}; - double sumPmwkTruEt[KNEta][KNpT][KIntM][KIntK]{}; - double sumWkTruEt[KNEta][KNpT][KIntK]{}; - double sumPmwkRecoEt[KNEta][KNpT][KIntM][KIntK]{}; - double sumWkRecoEt[KNEta][KNpT][KIntK]{}; - double sumPmwkRecoEffCorEt[KNEta][KNpT][KIntM][KIntK]{}; - double sumWkRecoEffCorEt[KNEta][KNpT][KIntK]{}; - double meanTru[KNEta][KNpT]{}, c2Tru[KNEta][KNpT]{}; - double meanReco[KNEta][KNpT]{}, c2Reco[KNEta][KNpT]{}; - double meanRecoEffCor[KNEta][KNpT]{}, c2RecoEffCor[KNEta][KNpT]{}; - double meanTruEt[KNEta][KNpT]{}, c2TruEt[KNEta][KNpT]{}; - double meanRecoEt[KNEta][KNpT]{}, c2RecoEt[KNEta][KNpT]{}; - double meanRecoEffCorEt[KNEta][KNpT]{}, c2RecoEffCorEt[KNEta][KNpT]{}; - - for (const auto& mcCollision : mcColl) { - auto partSlice = mcParticles.sliceBy(partPerMcCollision, mcCollision.globalIndex()); - auto colSlice = collisions.sliceBy(colPerMcCollision, mcCollision.globalIndex()); - if (colSlice.size() != 1) continue; - // histos.fill(HIST("MCGen/hVtxZ"), mcCollision.posZ()); - for (const auto& col : colSlice) { - - auto trackSlice = tracks.sliceBy(trackPerCollision, col.globalIndex()); - if (trackSlice.size() < 1) continue; - - memset(sumPmwkTru, 0, sizeof(sumPmwkTru)); - memset(sumWkTru, 0, sizeof(sumWkTru)); - memset(sumPmwkReco, 0, sizeof(sumPmwkReco)); - memset(sumWkReco, 0, sizeof(sumWkReco)); - memset(sumPmwkRecoEffCor, 0, sizeof(sumPmwkRecoEffCor)); - memset(sumWkRecoEffCor, 0, sizeof(sumWkRecoEffCor)); - - memset(sumPmwkTruEt, 0, sizeof(sumPmwkTruEt)); - memset(sumWkTruEt, 0, sizeof(sumWkTruEt)); - memset(sumPmwkRecoEt, 0, sizeof(sumPmwkRecoEt)); - memset(sumWkRecoEt, 0, sizeof(sumWkRecoEt)); - memset(sumPmwkRecoEffCorEt, 0, sizeof(sumPmwkRecoEffCorEt)); - memset(sumWkRecoEffCorEt, 0, sizeof(sumWkRecoEffCorEt)); - - memset(meanTru, 0, sizeof(meanTru)); - memset(c2Tru, 0, sizeof(c2Tru)); - memset(meanReco, 0, sizeof(meanReco)); - memset(c2Reco, 0, sizeof(c2Reco)); - memset(meanRecoEffCor, 0, sizeof(meanRecoEffCor)); - memset(c2RecoEffCor, 0, sizeof(c2RecoEffCor)); - - memset(meanTruEt, 0, sizeof(meanTruEt)); - memset(c2TruEt, 0, sizeof(c2TruEt)); - memset(meanRecoEt, 0, sizeof(meanRecoEt)); - memset(c2RecoEt, 0, sizeof(c2RecoEt)); - memset(meanRecoEffCorEt, 0, sizeof(meanRecoEffCorEt)); - memset(c2RecoEffCorEt, 0, sizeof(c2RecoEffCorEt)); - - if (!col.has_mcCollision() || !isEventSelected(col)) - continue; - float cent = getCentrality(col); - if (cent > KCentMax) - continue; - - // truth - for (const auto& particle : partSlice) { - if (!isParticleSelected(particle)) - continue; - if (!particle.isPhysicalPrimary()) - continue; - float pt = particle.pt(); - float eta = particle.eta(); - float p = particle.p(); - - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) - continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) - continue; - for (int k = 0; k < KIntK; ++k) { - for (int m = 0; m < KIntM; ++m) { - sumPmwkTru[ieta][ipt][m][k] += std::pow(pt, m); - } - sumWkTru[ieta][ipt][k]++; - } - } - } - const int absPdgId = std::abs(particle.pdgCode()); - const bool isPion = (absPdgId == kPiPlus); - const bool isKaon = (absPdgId == kKPlus); - const bool isProton = (absPdgId == kProton); - if (isPion || isKaon || isProton) { - - float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus - : o2::constants::physics::MassProton; - float energy = std::sqrt(p * p + m * m); - float et = energy * (pt / p); - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) - continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) - continue; - for (int k = 0; k < KIntK; ++k) { - for (int m = 0; m < KIntM; ++m) { - sumPmwkTruEt[ieta][ipt][m][k] += std::pow(et, m); - } - sumWkTruEt[ieta][ipt][k]++; - } - } - } - } - - } // end truth loop - - for (const auto& track : trackSlice) { - if (!isTrackSelected(track)) - continue; - float pt = track.pt(); - float eta = track.eta(); - float p = track.p(); - float phi = track.phi(); - - float effIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 0); - float fakeIncl = getEfficiency(col.multNTracksPV(), pt, eta, kInclusive, 1); - float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); - float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; - if (!std::isfinite(wIncl) || wIncl <= 0.f) - continue; - if (effIncl <= 0 || !isfinite(effIncl) || !isfinite(fakeIncl) || !isfinite(flatWeightIncl)) - continue; - - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) - continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) - continue; - for (int k = 0; k < KIntK; ++k) { - for (int m = 0; m < KIntM; ++m) { - sumPmwkReco[ieta][ipt][m][k] += std::pow(1.0f, k) * std::pow(pt, m); - sumPmwkRecoEffCor[ieta][ipt][m][k] += std::pow(wIncl, k) * std::pow(pt, m); - } - sumWkReco[ieta][ipt][k] += std::pow(1.0f, k); - sumWkRecoEffCor[ieta][ipt][k] += std::pow(wIncl, k); - } - } - } - - const bool isPion = selectionPion(track); - const bool isKaon = selectionKaon(track); - const bool isProton = selectionProton(track); - - if (isPion || isKaon || isProton) { - float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus - : o2::constants::physics::MassProton; - float energy = std::sqrt(p * p + m * m); - float et = energy * (pt / p); // E_T = E * sin(theta) - float effPid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 0); - float fakePid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 1); - float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); - float wPid = flatWeightPid * (1.0 - fakePid) / effPid; - if (effPid >= 1.f || fakePid >= 1.f || !isfinite(effPid) || effPid <= KFloatEpsilon || !isfinite(fakePid) || !isfinite(flatWeightPid)) - continue; - - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) - continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) - continue; - for (int k = 0; k < KIntK; ++k) { - for (int m = 0; m < KIntM; ++m) { - sumPmwkRecoEt[ieta][ipt][m][k] += std::pow(1.0f, k) * std::pow(et, m); - sumPmwkRecoEffCorEt[ieta][ipt][m][k] += std::pow(wPid, k) * std::pow(et, m); - } - sumWkRecoEt[ieta][ipt][k] += std::pow(1.0f, k); - sumWkRecoEffCorEt[ieta][ipt][k] += std::pow(wPid, k); - } - } - } - } - - for (int ieta = 0; ieta < KNEta; ++ieta) { - for (int ipt = 0; ipt < KNpT; ++ipt) { - const int ibx = pmeanTruNchEtabinPtbinStep2->GetXaxis()->FindBin(col.multNTracksPV()); - const int iby = ieta + 1; - const int ibz = ipt + 1; - - float mmptTru = pmeanTruNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmptReco = pmeanRecoNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmptRecoEffCor = pmeanRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmetTru = pmeanEtTruNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmetReco = pmeanEtRecoNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmetRecoEffCor = pmeanEtRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - - if (isfinite(mmptTru)) - std::tie(meanTru[ieta][ipt], c2Tru[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkTru[ieta][ipt], sumWkTru[ieta][ipt], mmptTru); - if (isfinite(mmptReco)) - std::tie(meanReco[ieta][ipt], c2Reco[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkReco[ieta][ipt], sumWkReco[ieta][ipt], mmptReco); - if (isfinite(mmptRecoEffCor)) - std::tie(meanRecoEffCor[ieta][ipt], c2RecoEffCor[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEffCor[ieta][ipt], sumWkRecoEffCor[ieta][ipt], mmptRecoEffCor); - - if (isfinite(mmetTru)) - std::tie(meanTruEt[ieta][ipt], c2TruEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkTruEt[ieta][ipt], sumWkTruEt[ieta][ipt], mmetTru); - if (isfinite(mmetReco)) - std::tie(meanRecoEt[ieta][ipt], c2RecoEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEt[ieta][ipt], sumWkRecoEt[ieta][ipt], mmetReco); - if (isfinite(mmetRecoEffCor)) - std::tie(meanRecoEffCorEt[ieta][ipt], c2RecoEffCorEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEffCorEt[ieta][ipt], sumWkRecoEffCorEt[ieta][ipt], mmetRecoEffCor); - } - } - } - if (std::isfinite(c2Tru[0][0])) { - histos.fill(HIST("MCGen/Prof_C2_Cent"), cent, c2Tru[0][0]); - histos.fill(HIST("MCGen/Prof_C2_Mult"), col.multNTracksPV(), c2Tru[0][0]); - } - if (std::isfinite(c2TruEt[0][0])) { - histos.fill(HIST("MCGen/Prof_C2Et_Cent"), cent, c2TruEt[0][0]); - histos.fill(HIST("MCGen/Prof_C2Et_Mult"), col.multNTracksPV(), c2TruEt[0][0]); - } - // "MCReco" - if (std::isfinite(c2Reco[0][0])) { - histos.fill(HIST("MCReco/Prof_C2_Cent"), cent, c2Reco[0][0]); - histos.fill(HIST("MCReco/Prof_C2_Mult"), col.multNTracksPV(), c2Reco[0][0]); - } - if (std::isfinite(c2RecoEt[0][0])) { - histos.fill(HIST("MCReco/Prof_C2Et_Cent"), cent, c2RecoEt[0][0]); - histos.fill(HIST("MCReco/Prof_C2Et_Mult"), col.multNTracksPV(), c2RecoEt[0][0]); - } - - if (std::isfinite(c2RecoEffCor[0][0])) { - histos.fill(HIST("MCRecoEffCorr/Prof_C2_Cent"), cent, c2RecoEffCor[0][0]); - histos.fill(HIST("MCRecoEffCorr/Prof_C2_Mult"), col.multNTracksPV(), c2RecoEffCor[0][0]); - } - if (std::isfinite(c2RecoEffCorEt[0][0])) { - histos.fill(HIST("MCRecoEffCorr/Prof_C2Et_Cent"), cent, c2RecoEffCorEt[0][0]); - histos.fill(HIST("MCRecoEffCorr/Prof_C2Et_Mult"), col.multNTracksPV(), c2RecoEffCorEt[0][0]); - } - - if (std::isfinite(sumWkTru[0][0][1])) { - histos.fill(HIST("MCGen/Prof_cent_Nchrec"), cent, sumWkTru[0][0][1]); - histos.fill(HIST("MCGen/Prof_MeanpT_Cent"), cent, meanTru[0][0]); - histos.fill(HIST("MCGen/Prof_MeanpT_Mult"), col.multNTracksPV(), meanTru[0][0]); - } - if (std::isfinite(sumWkTruEt[0][0][1])) { - histos.fill(HIST("MCGen/Prof_MeanEt_Cent"), cent, meanTruEt[0][0]); - histos.fill(HIST("MCGen/Prof_MeanEt_Mult"), col.multNTracksPV(), meanTruEt[0][0]); - } - // "MCReco" - if (std::isfinite(sumWkReco[0][0][1])) { - histos.fill(HIST("MCReco/Prof_cent_Nchrec"), cent, sumWkReco[0][0][1]); - histos.fill(HIST("MCReco/Prof_MeanpT_Cent"), cent, meanReco[0][0]); - histos.fill(HIST("MCReco/Prof_MeanpT_Mult"), col.multNTracksPV(), meanReco[0][0]); - } - if (std::isfinite(sumWkRecoEt[0][0][1])) { - histos.fill(HIST("MCReco/Prof_MeanEt_Cent"), cent, meanRecoEt[0][0]); - histos.fill(HIST("MCReco/Prof_MeanEt_Mult"), col.multNTracksPV(), meanRecoEt[0][0]); - } - // "MCRecoEffCorr" - if (std::isfinite(sumWkRecoEffCor[0][0][1])) { - histos.fill(HIST("MCRecoEffCorr/Prof_cent_Nchrec"), cent, sumWkRecoEffCor[0][0][1]); - histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Cent"), cent, meanRecoEffCor[0][0]); - histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Mult"), col.multNTracksPV(), meanRecoEffCor[0][0]); - } - if (std::isfinite(sumWkRecoEffCorEt[0][0][1])) { - histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Cent"), cent, meanRecoEffCorEt[0][0]); - histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Mult"), col.multNTracksPV(), meanRecoEffCorEt[0][0]); - } - - for (int ieta = 0; ieta < KNEta; ++ieta) { - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (std::isfinite(sumWkTru[ieta][ipt][1])) - histos.fill(HIST("pmeanTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanTru[ieta][ipt]); - if (std::isfinite(sumWkReco[ieta][ipt][1])) - histos.fill(HIST("pmeanRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanReco[ieta][ipt]); - if (std::isfinite(sumWkRecoEffCor[ieta][ipt][1])) - histos.fill(HIST("pmeanRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanRecoEffCor[ieta][ipt]); - if (std::isfinite(sumWkTruEt[ieta][ipt][1])) - histos.fill(HIST("pmeanEtTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanTruEt[ieta][ipt]); - if (std::isfinite(sumWkRecoEt[ieta][ipt][1])) - histos.fill(HIST("pmeanEtRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanRecoEt[ieta][ipt]); - if (std::isfinite(sumWkRecoEffCorEt[ieta][ipt][1])) - histos.fill(HIST("pmeanEtRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, meanRecoEffCorEt[ieta][ipt]); - } - } - - float p1kBarTru[KNEta][KNpT]{}, p1kBarReco[KNEta][KNpT]{}, p1kBarRecoEffCor[KNEta][KNpT]{}; - float p1kBarTruEt[KNEta][KNpT]{}, p1kBarRecoEt[KNEta][KNpT]{}, p1kBarRecoEffCorEt[KNEta][KNpT]{}; - for (int ieta = 0; ieta < KNEta; ++ieta) { - for (int ipt = 0; ipt < KNpT; ++ipt) { - const int ibx = pmeanTruNchEtabinPtbinStep2->GetXaxis()->FindBin(col.multNTracksPV()); - const int iby = ieta + 1; - const int ibz = ipt + 1; - - float mmptTru = pmeanTruNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmptReco = pmeanRecoNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmptRecoEffCor = pmeanRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmetTru = pmeanEtTruNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmetReco = pmeanEtRecoNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmetRecoEffCor = pmeanEtRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - - if (mmptTru != 0.0f) p1kBarTru[ieta][ipt] = meanTru[ieta][ipt] - mmptTru; - if (mmptReco != 0.0f) p1kBarReco[ieta][ipt] = meanReco[ieta][ipt] - mmptReco; - if (mmptRecoEffCor != 0.0f) p1kBarRecoEffCor[ieta][ipt] = meanRecoEffCor[ieta][ipt] - mmptRecoEffCor; - - if (mmetTru != 0.0f) p1kBarTruEt[ieta][ipt] = meanTruEt[ieta][ipt] - mmetTru; - if (mmetReco != 0.0f) p1kBarRecoEt[ieta][ipt] = meanRecoEt[ieta][ipt] - mmetReco; - if (mmetRecoEffCor != 0.0f) p1kBarRecoEffCorEt[ieta][ipt] = meanRecoEffCorEt[ieta][ipt] - mmetRecoEffCor; - } - } - - // 1D Covariance (vs eta) - for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { - int ietaC = KNEta - ietaA; - float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); - { - const int ipt = 0; - float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("MCGen/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); - histos.fill(HIST("MCGen/Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("MCGen/Prof_ipt0_Cov_Eta"), valy, c2Sub); - } - float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("MCGen/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); - histos.fill(HIST("MCGen/Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("MCGen/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); - } - } - // ipt = 1 - { - const int ipt = 1; - float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("MCGen/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); - histos.fill(HIST("MCGen/Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("MCGen/Prof_ipt0_Cov_Eta"), valy, c2Sub); - } - float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("MCGen/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); - histos.fill(HIST("MCGen/Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("MCGen/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); - } - } - // ipt = 2 - { - const int ipt = 2; - float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("MCGen/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); - histos.fill(HIST("MCGen/Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("MCGen/Prof_ipt2_Cov_Eta"), valy, c2Sub); - } - float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("MCGen/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); - histos.fill(HIST("MCGen/Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("MCGen/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); - } - } - } - - for (int ietaA = 1; ietaA < KNEta; ++ietaA) { - for (int ietaC = 1; ietaC < KNEta; ++ietaC) { - float valx = KHalf * (etaLw[ietaA] + etaUp[ietaA]); - float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); - // ipt = 0 - { - const int ipt = 0; - float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; - if (std::isfinite(c2Sub)) - histos.fill(HIST("MCGen/Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); - float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) - histos.fill(HIST("MCGen/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); - } - // ipt = 1 - { - const int ipt = 1; - float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; - if (std::isfinite(c2Sub)) - histos.fill(HIST("MCGen/Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); - float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) - histos.fill(HIST("MCGen/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); - } - // ipt = 2 - { - const int ipt = 2; - float c2Sub = p1kBarTru[ietaA][ipt] * p1kBarTru[ietaC][ipt]; - if (std::isfinite(c2Sub)) - histos.fill(HIST("MCGen/Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); - float c2SubEt = p1kBarTruEt[ietaA][ipt] * p1kBarTruEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) - histos.fill(HIST("MCGen/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); - } - } - } - - for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { - int ietaC = KNEta - ietaA; - float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); - // ipt = 0 - { - const int ipt = 0; - float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("MCReco/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); - histos.fill(HIST("MCReco/Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("MCReco/Prof_ipt0_Cov_Eta"), valy, c2Sub); - } - float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("MCReco/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); - histos.fill(HIST("MCReco/Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("MCReco/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); - } - } - - // ipt = 1 - { - const int ipt = 1; - float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("MCReco/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); - histos.fill(HIST("MCReco/Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("MCReco/Prof_ipt1_Cov_Eta"), valy, c2Sub); - } - float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("MCReco/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); - histos.fill(HIST("MCReco/Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("MCReco/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); - } - } - - // ipt = 2 - { - const int ipt = 2; - float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("MCReco/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); - histos.fill(HIST("MCReco/Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("MCReco/Prof_ipt2_Cov_Eta"), valy, c2Sub); - } - float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("MCReco/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); - histos.fill(HIST("MCReco/Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("MCReco/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); - } - } - } - - for (int ietaA = 1; ietaA < KNEta; ++ietaA) { - for (int ietaC = 1; ietaC < KNEta; ++ietaC) { - float valx = KHalf * (etaLw[ietaA] + etaUp[ietaA]); - float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); - - // ipt = 0 - { - const int ipt = 0; - float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; - if (std::isfinite(c2Sub)) - histos.fill(HIST("MCReco/Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); - float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) - histos.fill(HIST("MCReco/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); - } - - // ipt = 1 - { - const int ipt = 1; - float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; - if (std::isfinite(c2Sub)) - histos.fill(HIST("MCReco/Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); - float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) - histos.fill(HIST("MCReco/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); - } - - // ipt = 2 - { - const int ipt = 2; - float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; - if (std::isfinite(c2Sub)) - histos.fill(HIST("MCReco/Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); - float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) - histos.fill(HIST("MCReco/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); - } - } - } - - for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { - int ietaC = KNEta - ietaA; - float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); - - // ipt = 0 - { - const int ipt = 0; - float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("MCRecoEffCorr/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); - histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_Cov_Eta"), valy, c2Sub); - } - float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("MCRecoEffCorr/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); - histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); - } - } - - // ipt = 1 - { - const int ipt = 1; - float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("MCRecoEffCorr/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); - histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_Cov_Eta"), valy, c2Sub); - } - float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("MCRecoEffCorr/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); - histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); - } - } + const int ipt = 2; + float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCReco/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCReco/Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("MCReco/Prof_ipt2_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCReco/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCReco/Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("MCReco/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); + } + } + } - // ipt = 2 - { - const int ipt = 2; - float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("MCRecoEffCorr/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); - histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_Cov_Eta"), valy, c2Sub); - } - float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("MCRecoEffCorr/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); - histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); - } - } - } + for (int ietaA = 1; ietaA < KNEta; ++ietaA) { + for (int ietaC = 1; ietaC < KNEta; ++ietaC) { + float valx = KHalf * (etaLw[ietaA] + etaUp[ietaA]); + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); + + // ipt = 0 + { + const int ipt = 0; + float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCReco/Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCReco/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + } - for (int ietaA = 1; ietaA < KNEta; ++ietaA) { - for (int ietaC = 1; ietaC < KNEta; ++ietaC) { - float valx = 0.5f * (etaLw[ietaA] + etaUp[ietaA]); - float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); - - // ipt = 0 - { - const int ipt = 0; - float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; - if (std::isfinite(c2Sub)) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); - float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); - } - - // ipt = 1 - { - const int ipt = 1; - float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; - if (std::isfinite(c2Sub)) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); - float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); - } - - // ipt = 2 - { - const int ipt = 2; - float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; - if (std::isfinite(c2Sub)) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); - float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) - histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); - } - } - } + // ipt = 1 + { + const int ipt = 1; + float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCReco/Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCReco/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); + } - } + // ipt = 2 + { + const int ipt = 2; + float c2Sub = p1kBarReco[ietaA][ipt] * p1kBarReco[ietaC][ipt]; + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCReco/Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarRecoEt[ietaA][ipt] * p1kBarRecoEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCReco/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); } - LOGF(info, "FINISHED RUNNING processMCFluc (pT + Et)"); } - PROCESS_SWITCH(RadialFlowDecorr, processMCFluc, "process MC to calculate pt/Et fluc", cfgRunMCFluc); + } - void processGetFlat(AodCollisionsSel::iterator const& coll, aod::BCsWithTimestamps const&, AodTracksSel const& tracks) + for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { + int ietaC = KNEta - ietaA; + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); + + // ipt = 0 { - if (!isEventSelected(coll)) return; - float cent = getCentrality(coll); - if (cent > KCentMax) return; - for (const auto& track : tracks) { - if (!isTrackSelected(track)) continue; - float p = track.p(); - float eta = track.eta(); - float phi = track.phi(); - if (p < KFloatEpsilon) continue; - histos.fill(HIST("hCentEtaPhi"), cent, eta, phi); - const bool isPion = selectionPion(track); - const bool isKaon = selectionKaon(track); - const bool isProton = selectionProton(track); - if (isPion || isKaon || isProton) { - histos.fill(HIST("hCentEtaPhi_PID"), cent, eta, phi); - } + const int ipt = 0; + float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_CovEt_Eta"), valy, c2SubEt); } } - PROCESS_SWITCH(RadialFlowDecorr, processGetFlat, "process real data to calculate mean pT and Et", cfgRunGetFlat); - void processDataMean(AodCollisionsSel::iterator const& coll, aod::BCsWithTimestamps const&, AodTracksSel const& tracks) + // ipt = 1 { - float sumWi[KNEta][KNpT]{}, sumWipti[KNEta][KNpT]{}; - float sumWiEt[KNEta][KNpT]{}, sumWiEtVal[KNEta][KNpT]{}; - if (!isEventSelected(coll)) return; - - float cent = getCentrality(coll); - if (cent > KCentMax) return; - - histos.fill(HIST("hZvtx_after_sel"), coll.posZ()); - histos.fill(HIST("hCentrality"), cent); - - histos.fill(HIST("Hist2D_globalTracks_PVTracks"), coll.multNTracksPV(), tracks.size()); - histos.fill(HIST("Hist2D_cent_nch"), tracks.size(), cent); - - for (const auto& track : tracks) { - if (!isTrackSelected(track)) continue; - float pt = track.pt(); - float eta = track.eta(); - float p = track.p(); - float phi = track.phi(); - if (p < KFloatEpsilon) continue; - histos.fill(HIST("hP"), p); - histos.fill(HIST("hPt"), pt); - histos.fill(HIST("hEta"), eta); - histos.fill(HIST("hPhi"), track.phi()); - - float effIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 0); - float fakeIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 1); - float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); - float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; - if (!std::isfinite(wIncl) || wIncl <= KFloatEpsilon || effIncl <= KFloatEpsilon) continue; - - histos.fill(HIST("hCentEtaPhi"), cent, eta, track.phi()); - histos.fill(HIST("hCentEtaPhiWtd"), cent, eta, track.phi(), flatWeightIncl); - - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) - continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) - continue; - sumWi[ieta][ipt] += wIncl; - sumWipti[ieta][ipt] += wIncl * pt; - } - } - - const bool isPion = selectionPion(track); - const bool isKaon = selectionKaon(track); - const bool isProton = selectionProton(track); - if (isPion || isKaon || isProton) { - - float effPid = getEfficiency(coll.multNTracksPV(), pt, eta, kCombinedPID, 0); - float fakePid = getEfficiency(coll.multNTracksPV(), pt, eta, kCombinedPID, 1); - float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); - float wPid = flatWeightPid * (1.0 - fakePid) / effPid; - if (!std::isfinite(wPid) || wPid <= KFloatEpsilon || effPid <= KFloatEpsilon) - continue; - - histos.fill(HIST("hCentEtaPhiWtd_PID"), cent, eta, track.phi(), flatWeightPid); - float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus - : o2::constants::physics::MassProton; - float energy = std::sqrt(p * p + m * m); - float et = energy * (pt / p); // E_T = E * sin(theta) - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) - continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) - continue; - sumWiEt[ieta][ipt] += wPid; - sumWiEtVal[ieta][ipt] += wPid * et; - } - } - } + const int ipt = 1; + float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_Cov_Eta"), valy, c2Sub); } - histos.fill(HIST("Prof_cent_Nchrec"), cent, sumWi[0][0]); - if (isfinite(sumWi[0][0])) histos.fill(HIST("Prof_MeanpT_Cent"), cent, sumWipti[0][0] / sumWi[0][0]); - if (isfinite(sumWiEt[0][0])) histos.fill(HIST("Prof_MeanEt_Cent"), cent, sumWiEtVal[0][0] / sumWiEt[0][0]); - - for (int ieta = 0; ieta < KNEta; ++ieta) { - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (isfinite(sumWi[ieta][ipt])) - histos.fill(HIST("pmean_nch_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, sumWipti[ieta][ipt] / sumWi[ieta][ipt]); - if (isfinite(sumWiEt[ieta][ipt])) - histos.fill(HIST("pmeanEt_nch_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, sumWiEtVal[ieta][ipt] / sumWiEt[ieta][ipt]); - } + float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_CovEt_Eta"), valy, c2SubEt); } } - PROCESS_SWITCH(RadialFlowDecorr, processDataMean, "process real data to calculate mean pT and Et", cfgRunDataMean); - void processDataFluc(AodCollisionsSel::iterator const& coll, aod::BCsWithTimestamps const&, AodTracksSel const& tracks) + // ipt = 2 { - if (!isEventSelected(coll)) - return; - float cent = getCentrality(coll); - if (cent > KCentMax) - return; - if (!pmeanNchEtabinPtbinStep2 || !pmeanEtNchEtabinPtbinStep2) { - LOGF(warning, "Data fluc: Mean pT or Et map missing"); - return; + const int ipt = 2; + float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2Sub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2Sub); + histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_Cov_Eta"), valy, c2Sub); } - - if (!hEff[kInclusive] || !hFake[kInclusive] || !hWeightMap3D[kInclusive] || !hEff[kCombinedPID] || !hFake[kCombinedPID] || !hWeightMap3D[kCombinedPID]) { - LOGF(warning, "Data fluc: Inclusive or PID correction maps are null"); - return; + float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("MCRecoEffCorr/Prof_C2EtSub_Mult_etabin_ptbin"), col.multNTracksPV(), ietaA, ipt, c2SubEt); + histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_CovEt_Eta"), valy, c2SubEt); } - double sumpmwk[KNEta][KNpT][KIntM][KIntK]{}; - double sumwk[KNEta][KNpT][KIntK]{}; - double sumpmwkEt[KNEta][KNpT][KIntM][KIntK]{}; - double sumwkEt[KNEta][KNpT][KIntK]{}; - double mean[KNEta][KNpT]{}, c2[KNEta][KNpT]{}; - double p1kBar[KNEta][KNpT]{}; - double meanEt[KNEta][KNpT]{}, c2Et[KNEta][KNpT]{}; - double p1kBarEt[KNEta][KNpT]{}; - - for (const auto& track : tracks) { - if (!isTrackSelected(track)) - continue; - float pt = track.pt(); - float eta = track.eta(); - float p = track.p(); - float phi = track.phi(); - if (p < KFloatEpsilon) - continue; - - float effIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 0); - float fakeIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 1); - float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); - - float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; - if (!std::isfinite(wIncl) || wIncl <= KFloatEpsilon || effIncl <= KFloatEpsilon) - continue; - - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) - continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) - continue; - for (int k = 0; k < KIntK; ++k) { - for (int m = 0; m < KIntM; ++m) - sumpmwk[ieta][ipt][m][k] += std::pow(wIncl, k) * std::pow(pt, m); - sumwk[ieta][ipt][k] += std::pow(wIncl, k); - } - } - } - - const bool isPion = selectionPion(track); - const bool isKaon = selectionKaon(track); - const bool isProton = selectionProton(track); - if (isPion || isKaon || isProton) { - float effPid = getEfficiency(coll.multNTracksPV(), pt, eta, kCombinedPID, 0); - float fakePid = getEfficiency(coll.multNTracksPV(), pt, eta, kCombinedPID, 1); - float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); - - float wPid = flatWeightPid * (1.0 - fakePid) / effPid; - if (!std::isfinite(wPid) || wPid <= KFloatEpsilon || effPid <= KFloatEpsilon) - continue; - - float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus - : o2::constants::physics::MassProton; + } + } - float energy = std::sqrt(p * p + m * m); - float et = energy * (pt / p); // E_T = E * sin(theta) - for (int ieta = 0; ieta < KNEta; ++ieta) { - if (eta <= etaLw[ieta] || eta > etaUp[ieta]) - continue; - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (pt <= pTLw[ipt] || pt > pTUp[ipt]) - continue; - for (int k = 0; k < KIntK; ++k) { - for (int m = 0; m < KIntM; ++m) - sumpmwkEt[ieta][ipt][m][k] += std::pow(wPid, k) * std::pow(et, m); - sumwkEt[ieta][ipt][k] += std::pow(wPid, k); - } - } - } - } + for (int ietaA = 1; ietaA < KNEta; ++ietaA) { + for (int ietaC = 1; ietaC < KNEta; ++ietaC) { + float valx = 0.5f * (etaLw[ietaA] + etaUp[ietaA]); + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); + + // ipt = 0 + { + const int ipt = 0; + float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); } - for (int ieta = 0; ieta < KNEta; ++ieta){ - for (int ipt = 0; ipt < KNpT; ++ipt) { - const int ibx = pmeanNchEtabinPtbinStep2->GetXaxis()->FindBin(coll.multNTracksPV()); - const int iby = ieta + 1; - const int ibz = ipt + 1; - float mmpt = pmeanNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - float mmet = pmeanEtNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - - mean[ieta][ipt] = sumpmwk[ieta][ipt][1][1] / sumwk[ieta][ipt][1]; - meanEt[ieta][ipt] = sumpmwkEt[ieta][ipt][1][1] / sumwkEt[ieta][ipt][1]; - - if (std::isfinite(mmpt)) { - std::tie(mean[ieta][ipt], c2[ieta][ipt]) = - calculateMeanAndC2FromSums(sumpmwk[ieta][ipt], sumwk[ieta][ipt], mmpt); - p1kBar[ieta][ipt] = mean[ieta][ipt] - mmpt; - } - if (std::isfinite(mmet)) { - std::tie(meanEt[ieta][ipt], c2Et[ieta][ipt]) = - calculateMeanAndC2FromSums(sumpmwkEt[ieta][ipt], sumwkEt[ieta][ipt], mmet); - p1kBarEt[ieta][ipt] = meanEt[ieta][ipt] - mmet; - } - } + // ipt = 1 + { + const int ipt = 1; + float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); } - if (std::isfinite(c2[0][0])) histos.fill(HIST("Prof_C2_Cent"), cent, c2[0][0]); - if (std::isfinite(c2Et[0][0])) histos.fill(HIST("Prof_C2Et_Cent"), cent, c2Et[0][0]); - if (std::isfinite(sumwk[0][0][1])) { - histos.fill(HIST("Prof_MeanpT_Cent"), cent, mean[0][0]); - histos.fill(HIST("Prof_MeanpT_Mult"), coll.multNTracksPV(), mean[0][0]); + // ipt = 2 + { + const int ipt = 2; + float c2Sub = p1kBarRecoEffCor[ietaA][ipt] * p1kBarRecoEffCor[ietaC][ipt]; + if (std::isfinite(c2Sub)) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, c2Sub); + float c2SubEt = p1kBarRecoEffCorEt[ietaA][ipt] * p1kBarRecoEffCorEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) + histos.fill(HIST("MCRecoEffCorr/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC"), cent, valx, valy, c2SubEt); } - if (std::isfinite(sumwkEt[0][0][1])) { - histos.fill(HIST("Prof_MeanEt_Cent"), cent, meanEt[0][0]); - histos.fill(HIST("Prof_MeanEt_Mult"), coll.multNTracksPV(), meanEt[0][0]); - } - - for (int ieta = 0; ieta < KNEta; ++ieta){ - for (int ipt = 0; ipt < KNpT; ++ipt) { - if (std::isfinite(c2[ieta][ipt])) - histos.fill(HIST("Prof_C2_Mult_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, c2[ieta][ipt]); - if (std::isfinite(c2Et[ieta][ipt])) - histos.fill(HIST("Prof_C2Et_Mult_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, c2Et[ieta][ipt]); - } - } - - for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { - int ietaC = KNEta - ietaA; - float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); - - { - const int ipt = 0; - float c2Sub = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("Prof_ipt0_Cov_Eta"), valy, c2Sub); - } - float c2SubEt = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("Prof_ipt0_CovEt_Eta"), valy, c2SubEt); - } - } - - { - const int ipt = 1; - float c2Sub = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) - histos.fill(HIST("Prof_ipt1_Cov_Eta"), valy, c2Sub); - } - float c2SubEt = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) - histos.fill(HIST("Prof_ipt1_CovEt_Eta"), valy, c2SubEt); - } - } - - { - const int ipt = 2; - float c2Sub = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; - if (std::isfinite(c2Sub)) { - histos.fill(HIST("Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); - if (cent < KCentCovCut) histos.fill(HIST("Prof_ipt2_Cov_Eta"), valy, c2Sub); - } - float c2SubEt = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; - if (std::isfinite(c2SubEt)) { - histos.fill(HIST("Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); - if (cent < KCentCovCut) histos.fill(HIST("Prof_ipt2_CovEt_Eta"), valy, c2SubEt); - } - } + } + } + } + } + LOGF(info, "FINISHED RUNNING processMCFluc (pT + Et)"); + } + PROCESS_SWITCH(RadialFlowDecorr, processMCFluc, "process MC to calculate pt/Et fluc", cfgRunMCFluc); + + void processGetFlat(AodCollisionsSel::iterator const& coll, aod::BCsWithTimestamps const&, AodTracksSel const& tracks) + { + if (!isEventSelected(coll)) + return; + float cent = getCentrality(coll); + if (cent > KCentMax) + return; + for (const auto& track : tracks) { + if (!isTrackSelected(track)) + continue; + float p = track.p(); + float eta = track.eta(); + float phi = track.phi(); + if (p < KFloatEpsilon) + continue; + histos.fill(HIST("hCentEtaPhi"), cent, eta, phi); + const bool isPion = selectionPion(track); + const bool isKaon = selectionKaon(track); + const bool isProton = selectionProton(track); + if (isPion || isKaon || isProton) { + histos.fill(HIST("hCentEtaPhi_PID"), cent, eta, phi); + } + } + } + PROCESS_SWITCH(RadialFlowDecorr, processGetFlat, "process real data to calculate mean pT and Et", cfgRunGetFlat); + + void processDataMean(AodCollisionsSel::iterator const& coll, aod::BCsWithTimestamps const&, AodTracksSel const& tracks) + { + float sumWi[KNEta][KNpT]{}, sumWipti[KNEta][KNpT]{}; + float sumWiEt[KNEta][KNpT]{}, sumWiEtVal[KNEta][KNpT]{}; + if (!isEventSelected(coll)) + return; + + float cent = getCentrality(coll); + if (cent > KCentMax) + return; + + histos.fill(HIST("hZvtx_after_sel"), coll.posZ()); + histos.fill(HIST("hCentrality"), cent); + + histos.fill(HIST("Hist2D_globalTracks_PVTracks"), coll.multNTracksPV(), tracks.size()); + histos.fill(HIST("Hist2D_cent_nch"), tracks.size(), cent); + + for (const auto& track : tracks) { + if (!isTrackSelected(track)) + continue; + float pt = track.pt(); + float eta = track.eta(); + float p = track.p(); + float phi = track.phi(); + if (p < KFloatEpsilon) + continue; + histos.fill(HIST("hP"), p); + histos.fill(HIST("hPt"), pt); + histos.fill(HIST("hEta"), eta); + histos.fill(HIST("hPhi"), track.phi()); + + float effIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 0); + float fakeIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 1); + float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); + float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; + if (!std::isfinite(wIncl) || wIncl <= KFloatEpsilon || effIncl <= KFloatEpsilon) + continue; + + histos.fill(HIST("hCentEtaPhi"), cent, eta, track.phi()); + histos.fill(HIST("hCentEtaPhiWtd"), cent, eta, track.phi(), flatWeightIncl); + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; + sumWi[ieta][ipt] += wIncl; + sumWipti[ieta][ipt] += wIncl * pt; + } + } + + const bool isPion = selectionPion(track); + const bool isKaon = selectionKaon(track); + const bool isProton = selectionProton(track); + if (isPion || isKaon || isProton) { + + float effPid = getEfficiency(coll.multNTracksPV(), pt, eta, kCombinedPID, 0); + float fakePid = getEfficiency(coll.multNTracksPV(), pt, eta, kCombinedPID, 1); + float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); + float wPid = flatWeightPid * (1.0 - fakePid) / effPid; + if (!std::isfinite(wPid) || wPid <= KFloatEpsilon || effPid <= KFloatEpsilon) + continue; + + histos.fill(HIST("hCentEtaPhiWtd_PID"), cent, eta, track.phi(), flatWeightPid); + float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus + : o2::constants::physics::MassProton; + float energy = std::sqrt(p * p + m * m); + float et = energy * (pt / p); // E_T = E * sin(theta) + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; + sumWiEt[ieta][ipt] += wPid; + sumWiEtVal[ieta][ipt] += wPid * et; + } + } + } + } + histos.fill(HIST("Prof_cent_Nchrec"), cent, sumWi[0][0]); + if (isfinite(sumWi[0][0])) + histos.fill(HIST("Prof_MeanpT_Cent"), cent, sumWipti[0][0] / sumWi[0][0]); + if (isfinite(sumWiEt[0][0])) + histos.fill(HIST("Prof_MeanEt_Cent"), cent, sumWiEtVal[0][0] / sumWiEt[0][0]); + + for (int ieta = 0; ieta < KNEta; ++ieta) { + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (isfinite(sumWi[ieta][ipt])) + histos.fill(HIST("pmean_nch_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, sumWipti[ieta][ipt] / sumWi[ieta][ipt]); + if (isfinite(sumWiEt[ieta][ipt])) + histos.fill(HIST("pmeanEt_nch_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, sumWiEtVal[ieta][ipt] / sumWiEt[ieta][ipt]); + } + } + } + PROCESS_SWITCH(RadialFlowDecorr, processDataMean, "process real data to calculate mean pT and Et", cfgRunDataMean); + + void processDataFluc(AodCollisionsSel::iterator const& coll, aod::BCsWithTimestamps const&, AodTracksSel const& tracks) + { + if (!isEventSelected(coll)) + return; + float cent = getCentrality(coll); + if (cent > KCentMax) + return; + if (!pmeanNchEtabinPtbinStep2 || !pmeanEtNchEtabinPtbinStep2) { + LOGF(warning, "Data fluc: Mean pT or Et map missing"); + return; + } + + if (!hEff[kInclusive] || !hFake[kInclusive] || !hWeightMap3D[kInclusive] || !hEff[kCombinedPID] || !hFake[kCombinedPID] || !hWeightMap3D[kCombinedPID]) { + LOGF(warning, "Data fluc: Inclusive or PID correction maps are null"); + return; + } + double sumpmwk[KNEta][KNpT][KIntM][KIntK]{}; + double sumwk[KNEta][KNpT][KIntK]{}; + double sumpmwkEt[KNEta][KNpT][KIntM][KIntK]{}; + double sumwkEt[KNEta][KNpT][KIntK]{}; + double mean[KNEta][KNpT]{}, c2[KNEta][KNpT]{}; + double p1kBar[KNEta][KNpT]{}; + double meanEt[KNEta][KNpT]{}, c2Et[KNEta][KNpT]{}; + double p1kBarEt[KNEta][KNpT]{}; + + for (const auto& track : tracks) { + if (!isTrackSelected(track)) + continue; + float pt = track.pt(); + float eta = track.eta(); + float p = track.p(); + float phi = track.phi(); + if (p < KFloatEpsilon) + continue; + + float effIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 0); + float fakeIncl = getEfficiency(coll.multNTracksPV(), pt, eta, kInclusive, 1); + float flatWeightIncl = getFlatteningWeight(cent, eta, phi, kInclusive); + + float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; + if (!std::isfinite(wIncl) || wIncl <= KFloatEpsilon || effIncl <= KFloatEpsilon) + continue; + + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; + for (int k = 0; k < KIntK; ++k) { + for (int m = 0; m < KIntM; ++m) + sumpmwk[ieta][ipt][m][k] += std::pow(wIncl, k) * std::pow(pt, m); + sumwk[ieta][ipt][k] += std::pow(wIncl, k); + } + } + } + + const bool isPion = selectionPion(track); + const bool isKaon = selectionKaon(track); + const bool isProton = selectionProton(track); + if (isPion || isKaon || isProton) { + float effPid = getEfficiency(coll.multNTracksPV(), pt, eta, kCombinedPID, 0); + float fakePid = getEfficiency(coll.multNTracksPV(), pt, eta, kCombinedPID, 1); + float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); + + float wPid = flatWeightPid * (1.0 - fakePid) / effPid; + if (!std::isfinite(wPid) || wPid <= KFloatEpsilon || effPid <= KFloatEpsilon) + continue; + + float m = isPion ? o2::constants::physics::MassPiPlus : isKaon ? o2::constants::physics::MassKPlus + : o2::constants::physics::MassProton; + + float energy = std::sqrt(p * p + m * m); + float et = energy * (pt / p); // E_T = E * sin(theta) + for (int ieta = 0; ieta < KNEta; ++ieta) { + if (eta <= etaLw[ieta] || eta > etaUp[ieta]) + continue; + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (pt <= pTLw[ipt] || pt > pTUp[ipt]) + continue; + for (int k = 0; k < KIntK; ++k) { + for (int m = 0; m < KIntM; ++m) + sumpmwkEt[ieta][ipt][m][k] += std::pow(wPid, k) * std::pow(et, m); + sumwkEt[ieta][ipt][k] += std::pow(wPid, k); } + } + } + } + } + + for (int ieta = 0; ieta < KNEta; ++ieta) { + for (int ipt = 0; ipt < KNpT; ++ipt) { + const int ibx = pmeanNchEtabinPtbinStep2->GetXaxis()->FindBin(coll.multNTracksPV()); + const int iby = ieta + 1; + const int ibz = ipt + 1; + float mmpt = pmeanNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + float mmet = pmeanEtNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); + + mean[ieta][ipt] = sumpmwk[ieta][ipt][1][1] / sumwk[ieta][ipt][1]; + meanEt[ieta][ipt] = sumpmwkEt[ieta][ipt][1][1] / sumwkEt[ieta][ipt][1]; + + if (std::isfinite(mmpt)) { + std::tie(mean[ieta][ipt], c2[ieta][ipt]) = + calculateMeanAndC2FromSums(sumpmwk[ieta][ipt], sumwk[ieta][ipt], mmpt); + p1kBar[ieta][ipt] = mean[ieta][ipt] - mmpt; + } + if (std::isfinite(mmet)) { + std::tie(meanEt[ieta][ipt], c2Et[ieta][ipt]) = + calculateMeanAndC2FromSums(sumpmwkEt[ieta][ipt], sumwkEt[ieta][ipt], mmet); + p1kBarEt[ieta][ipt] = meanEt[ieta][ipt] - mmet; + } + } + } + + if (std::isfinite(c2[0][0])) + histos.fill(HIST("Prof_C2_Cent"), cent, c2[0][0]); + if (std::isfinite(c2Et[0][0])) + histos.fill(HIST("Prof_C2Et_Cent"), cent, c2Et[0][0]); + if (std::isfinite(sumwk[0][0][1])) { + histos.fill(HIST("Prof_MeanpT_Cent"), cent, mean[0][0]); + histos.fill(HIST("Prof_MeanpT_Mult"), coll.multNTracksPV(), mean[0][0]); + } + if (std::isfinite(sumwkEt[0][0][1])) { + histos.fill(HIST("Prof_MeanEt_Cent"), cent, meanEt[0][0]); + histos.fill(HIST("Prof_MeanEt_Mult"), coll.multNTracksPV(), meanEt[0][0]); + } + + for (int ieta = 0; ieta < KNEta; ++ieta) { + for (int ipt = 0; ipt < KNpT; ++ipt) { + if (std::isfinite(c2[ieta][ipt])) + histos.fill(HIST("Prof_C2_Mult_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, c2[ieta][ipt]); + if (std::isfinite(c2Et[ieta][ipt])) + histos.fill(HIST("Prof_C2Et_Mult_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, c2Et[ieta][ipt]); + } + } + + for (int ietaA = 1; ietaA <= (KNEta - 1) / 2; ++ietaA) { + int ietaC = KNEta - ietaA; + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); + + { + const int ipt = 0; + float c2Sub = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("Prof_ipt0_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("Prof_ipt0_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("Prof_ipt0_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("Prof_ipt0_CovEt_Eta"), valy, c2SubEt); + } + } + + { + const int ipt = 1; + float c2Sub = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("Prof_ipt1_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("Prof_ipt1_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("Prof_ipt1_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("Prof_ipt1_CovEt_Eta"), valy, c2SubEt); + } + } + + { + const int ipt = 2; + float c2Sub = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; + if (std::isfinite(c2Sub)) { + histos.fill(HIST("Prof_ipt2_Cov_Cent_eta"), cent, valy, c2Sub); + if (cent < KCentCovCut) + histos.fill(HIST("Prof_ipt2_Cov_Eta"), valy, c2Sub); + } + float c2SubEt = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; + if (std::isfinite(c2SubEt)) { + histos.fill(HIST("Prof_ipt2_CovEt_Cent_eta"), cent, valy, c2SubEt); + if (cent < KCentCovCut) + histos.fill(HIST("Prof_ipt2_CovEt_Eta"), valy, c2SubEt); + } + } + } - for (int ietaA = 1; ietaA < KNEta; ++ietaA) { - for (int ietaC = 1; ietaC < KNEta; ++ietaC) { - float valx = KHalf * (etaLw[ietaA] + etaUp[ietaA]); - float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); - { - const int ipt = 0; - float covpt = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; - if (std::isfinite(covpt)) - histos.fill(HIST("Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, covpt); - - float covet = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; - if (std::isfinite(covet)) - histos.fill(HIST("Prof_ipt0_C2SubEt2D_Mult_etaA_etaC"), cent, valx, valy, covet); - } - - { - const int ipt = 1; - float covpt = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; - if (std::isfinite(covpt)) - histos.fill(HIST("Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, covpt); - - float covet = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; - if (std::isfinite(covet)) - histos.fill(HIST("Prof_ipt1_C2SubEt2D_Mult_etaA_etaC"), cent, valx, valy, covet); - } - { - const int ipt = 2; + for (int ietaA = 1; ietaA < KNEta; ++ietaA) { + for (int ietaC = 1; ietaC < KNEta; ++ietaC) { + float valx = KHalf * (etaLw[ietaA] + etaUp[ietaA]); + float valy = KHalf * (etaLw[ietaC] + etaUp[ietaC]); + { + const int ipt = 0; + float covpt = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; + if (std::isfinite(covpt)) + histos.fill(HIST("Prof_ipt0_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, covpt); + + float covet = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; + if (std::isfinite(covet)) + histos.fill(HIST("Prof_ipt0_C2SubEt2D_Mult_etaA_etaC"), cent, valx, valy, covet); + } - float covpt = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; - if (std::isfinite(covpt)) - histos.fill(HIST("Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, covpt); + { + const int ipt = 1; + float covpt = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; + if (std::isfinite(covpt)) + histos.fill(HIST("Prof_ipt1_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, covpt); + + float covet = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; + if (std::isfinite(covet)) + histos.fill(HIST("Prof_ipt1_C2SubEt2D_Mult_etaA_etaC"), cent, valx, valy, covet); + } + { + const int ipt = 2; - float covet = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; - if (std::isfinite(covet)) - histos.fill(HIST("Prof_ipt2_C2SubEt2D_Mult_etaA_etaC"), cent, valx, valy, covet); - } - } - } - } - PROCESS_SWITCH(RadialFlowDecorr, processDataFluc, "process real data to calculate fluc pT and Et", cfgRunDataFluc); - }; + float covpt = p1kBar[ietaA][ipt] * p1kBar[ietaC][ipt]; + if (std::isfinite(covpt)) + histos.fill(HIST("Prof_ipt2_C2Sub2D_Mult_etaA_etaC"), cent, valx, valy, covpt); - WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) - { - WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; - return workflow; + float covet = p1kBarEt[ietaA][ipt] * p1kBarEt[ietaC][ipt]; + if (std::isfinite(covet)) + histos.fill(HIST("Prof_ipt2_C2SubEt2D_Mult_etaA_etaC"), cent, valx, valy, covet); } + } + } + } + PROCESS_SWITCH(RadialFlowDecorr, processDataFluc, "process real data to calculate fluc pT and Et", cfgRunDataFluc); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + WorkflowSpec workflow{adaptAnalysisTask(cfgc)}; + return workflow; +} From f957d68c4acf87234ae8b01748927b53c74bc283 Mon Sep 17 00:00:00 2001 From: Somadutta Bhatta Date: Tue, 11 Nov 2025 23:17:53 +0100 Subject: [PATCH 08/10] Fixing isfinite to std:isfinite --- .../Tasks/radialFlowDecorr.cxx | 89 ++++++++++--------- 1 file changed, 45 insertions(+), 44 deletions(-) diff --git a/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx b/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx index 68f2d90066e..48edf68acbb 100644 --- a/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx +++ b/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx @@ -620,12 +620,14 @@ struct RadialFlowDecorr { void declareMCFlucHists() { static constexpr int KNbinsNchFluc = 1000; + + ConfigurableAxis nChAxis{"nChAxis", {KNbinsNch, KBinOffset, KNchMax}, "PV-contributor track multiplicity axis"}; + ConfigurableAxis nChAxis2{"nChAxis2", {KNbinsNchCoarse, KBinOffset, KNchMax}, "PV-contributor track multiplicity axis"}; + // pT cumulants histos.add("MCGen/Prof_C2_Cent", ";cent;C_{2}", kTProfile, {centAxis}); histos.add("MCGen/Prof_C2_Mult", ";N_{PV};C_{2}", kTProfile, {nChAxis}); - histos.add("MCGen/Prof_C2Sub_Mult_etabin_ptbin", - ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, - {{KNbinsNchFluc, KNchMin, KNchCoarseMax}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("MCGen/Prof_C2Sub_Mult_etabin_ptbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{KNbinsNchFluc, KBinOffset, KNchMax}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); histos.add("MCGen/Prof_ipt0_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); histos.add("MCGen/Prof_ipt1_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); histos.add("MCGen/Prof_ipt2_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); @@ -637,8 +639,7 @@ struct RadialFlowDecorr { histos.add("MCGen/Prof_ipt2_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); histos.add("MCGen/Prof_C2Et_Cent", ";cent;C_{2}^{E_{T}}", kTProfile, {centAxis}); histos.add("MCGen/Prof_C2Et_Mult", ";N_{PV};C_{2}^{E_{T}}", kTProfile, {nChAxis}); - histos.add("MCGen/Prof_C2EtSub_Mult_etabin_ptbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, - {{KNbinsNchFluc, KNchMin, KNchCoarseMax}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("MCGen/Prof_C2EtSub_Mult_etabin_ptbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{KNbinsNchFluc, KBinOffset, KNchMax}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); histos.add("MCGen/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); histos.add("MCGen/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); histos.add("MCGen/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); @@ -1194,7 +1195,7 @@ struct RadialFlowDecorr { } } - if (effIncl <= 0 || !isfinite(wIncl) || !isfinite(fakeIncl) || !isfinite(flatWeightIncl)) + if (effIncl <= 0 || !std::isfinite(wIncl) || !std::isfinite(fakeIncl) || !std::isfinite(flatWeightIncl)) continue; for (int ieta = 0; ieta < KNEta; ++ieta) { @@ -1238,7 +1239,7 @@ struct RadialFlowDecorr { } } - if (effPid <= KFloatEpsilon || !isfinite(wPid) || !isfinite(fakePid) || !isfinite(flatWeightPid)) + if (effPid <= KFloatEpsilon || !std::isfinite(wPid) || !std::isfinite(fakePid) || !std::isfinite(flatWeightPid)) continue; for (int ieta = 0; ieta < KNEta; ++ieta) { @@ -1253,7 +1254,7 @@ struct RadialFlowDecorr { } } - if (isfinite(wIncl)) { + if (std::isfinite(wIncl)) { if (cent < KCentTestMin) { histos.fill(HIST("wgt_pT"), pt, wIncl); histos.fill(HIST("Eff_pT"), pt, effIncl); @@ -1272,62 +1273,62 @@ struct RadialFlowDecorr { } // end track loop - if (isfinite(sumWiTruth[0][0])) { + if (std::isfinite(sumWiTruth[0][0])) { float meanPtTruth = sumWiptiTruth[0][0] / sumWiTruth[0][0]; - if (!isfinite(meanPtTruth)) + if (!std::isfinite(meanPtTruth)) LOGF(info, "meanPtTruth = %.3f, num = %.3f, den =%.3f", meanPtTruth, sumWiptiTruth[0][0], sumWiTruth[0][0]); - if (!isfinite(meanPtTruth)) + if (!std::isfinite(meanPtTruth)) continue; histos.fill(HIST("MCGen/Prof_cent_Nchrec"), cent, sumWiTruth[0][0]); histos.fill(HIST("MCGen/Prof_MeanpT_Cent"), cent, meanPtTruth); histos.fill(HIST("MCGen/Prof_MeanpT_Mult"), col.multNTracksPV(), meanPtTruth); } - if (isfinite(sumWiReco[0][0])) { + if (std::isfinite(sumWiReco[0][0])) { float meanPtReco = sumWiptiReco[0][0] / sumWiReco[0][0]; - if (!isfinite(meanPtReco)) + if (!std::isfinite(meanPtReco)) LOGF(info, "meanPtReco = %.3f, num = %.3f, den =%.3f", meanPtReco, sumWiptiReco[0][0], sumWiReco[0][0]); - if (!isfinite(meanPtReco)) + if (!std::isfinite(meanPtReco)) continue; histos.fill(HIST("MCReco/Prof_cent_Nchrec"), cent, sumWiReco[0][0]); histos.fill(HIST("MCReco/Prof_MeanpT_Cent"), cent, meanPtReco); histos.fill(HIST("MCReco/Prof_MeanpT_Mult"), col.multNTracksPV(), meanPtReco); } - if (isfinite(sumWiRecoEffCorr[0][0])) { + if (std::isfinite(sumWiRecoEffCorr[0][0])) { float meanpTeffcorr = sumWiptiRecoEffCorr[0][0] / sumWiRecoEffCorr[0][0]; - if (!isfinite(meanpTeffcorr)) + if (!std::isfinite(meanpTeffcorr)) LOGF(info, "meanPtRecoEffcorr = %.3f, num = %.3f, den =%.3f", meanpTeffcorr, sumWiptiRecoEffCorr[0][0], sumWiRecoEffCorr[0][0]); - if (!isfinite(meanpTeffcorr)) + if (!std::isfinite(meanpTeffcorr)) continue; histos.fill(HIST("MCRecoEffCorr/Prof_cent_Nchrec"), cent, sumWiRecoEffCorr[0][0]); histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Cent"), cent, meanpTeffcorr); histos.fill(HIST("MCRecoEffCorr/Prof_MeanpT_Mult"), col.multNTracksPV(), meanpTeffcorr); } - if (isfinite(sumWiTruthEt[0][0])) { + if (std::isfinite(sumWiTruthEt[0][0])) { float meanEt = sumWiptiTruthEt[0][0] / sumWiTruthEt[0][0]; - if (!isfinite(meanEt)) + if (!std::isfinite(meanEt)) LOGF(info, "meanEtTruthEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiTruthEt[0][0], sumWiTruthEt[0][0]); - if (!isfinite(meanEt)) + if (!std::isfinite(meanEt)) continue; histos.fill(HIST("MCGen/Prof_MeanEt_Cent"), cent, meanEt); histos.fill(HIST("MCGen/Prof_MeanEt_Mult"), col.multNTracksPV(), meanEt); } // "MCReco" - if (isfinite(sumWiRecoEt[0][0])) { + if (std::isfinite(sumWiRecoEt[0][0])) { float meanEt = sumWiptiRecoEt[0][0] / sumWiRecoEt[0][0]; - if (!isfinite(meanEt)) + if (!std::isfinite(meanEt)) LOGF(info, "meanEtRecoEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiRecoEt[0][0], sumWiRecoEt[0][0]); - if (!isfinite(meanEt)) + if (!std::isfinite(meanEt)) continue; histos.fill(HIST("MCReco/Prof_MeanEt_Cent"), cent, meanEt); histos.fill(HIST("MCReco/Prof_MeanEt_Mult"), col.multNTracksPV(), meanEt); } // "MCRecoEffCorr" - if (isfinite(sumWiRecoEffCorrEt[0][0])) { + if (std::isfinite(sumWiRecoEffCorrEt[0][0])) { float meanEt = sumWiptiRecoEffCorrEt[0][0] / sumWiRecoEffCorrEt[0][0]; - if (!isfinite(meanEt)) + if (!std::isfinite(meanEt)) LOGF(info, "meanEtRecoEffcorrEt = %.3f, num = %.3f, den =%.3f", meanEt, sumWiptiRecoEffCorrEt[0][0], sumWiRecoEffCorrEt[0][0]); - if (!isfinite(meanEt)) + if (!std::isfinite(meanEt)) continue; histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Cent"), cent, meanEt); histos.fill(HIST("MCRecoEffCorr/Prof_MeanEt_Mult"), col.multNTracksPV(), meanEt); @@ -1335,18 +1336,18 @@ struct RadialFlowDecorr { for (int ieta = 0; ieta < KNEta; ++ieta) { for (int ipt = 0; ipt < KNpT; ++ipt) { - if (isfinite(sumWiTruth[ieta][ipt])) + if (std::isfinite(sumWiTruth[ieta][ipt])) histos.fill(HIST("pmeanTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiTruth[ieta][ipt] / sumWiTruth[ieta][ipt]); - if (isfinite(sumWiReco[ieta][ipt])) + if (std::isfinite(sumWiReco[ieta][ipt])) histos.fill(HIST("pmeanRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiReco[ieta][ipt] / sumWiReco[ieta][ipt]); - if (isfinite(sumWiRecoEffCorr[ieta][ipt])) + if (std::isfinite(sumWiRecoEffCorr[ieta][ipt])) histos.fill(HIST("pmeanRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiRecoEffCorr[ieta][ipt] / sumWiRecoEffCorr[ieta][ipt]); - if (isfinite(sumWiTruthEt[ieta][ipt])) + if (std::isfinite(sumWiTruthEt[ieta][ipt])) histos.fill(HIST("pmeanEtTruNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiTruthEt[ieta][ipt] / sumWiTruthEt[ieta][ipt]); - if (isfinite(sumWiRecoEt[ieta][ipt])) + if (std::isfinite(sumWiRecoEt[ieta][ipt])) histos.fill(HIST("pmeanEtRecoNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiRecoEt[ieta][ipt] / sumWiRecoEt[ieta][ipt]); - if (isfinite(sumWiRecoEffCorrEt[ieta][ipt])) + if (std::isfinite(sumWiRecoEffCorrEt[ieta][ipt])) histos.fill(HIST("pmeanEtRecoEffcorrNchEtabinPtbin"), col.multNTracksPV(), ieta, ipt, sumWiptiRecoEffCorrEt[ieta][ipt] / sumWiRecoEffCorrEt[ieta][ipt]); } } @@ -1490,7 +1491,7 @@ struct RadialFlowDecorr { float wIncl = flatWeightIncl * (1.0 - fakeIncl) / effIncl; if (!std::isfinite(wIncl) || wIncl <= 0.f) continue; - if (effIncl <= 0 || !isfinite(effIncl) || !isfinite(fakeIncl) || !isfinite(flatWeightIncl)) + if (effIncl <= 0 || !std::isfinite(effIncl) || !std::isfinite(fakeIncl) || !std::isfinite(flatWeightIncl)) continue; for (int ieta = 0; ieta < KNEta; ++ieta) { @@ -1523,7 +1524,7 @@ struct RadialFlowDecorr { float fakePid = getEfficiency(col.multNTracksPV(), pt, eta, kCombinedPID, 1); float flatWeightPid = getFlatteningWeight(cent, eta, phi, kCombinedPID); float wPid = flatWeightPid * (1.0 - fakePid) / effPid; - if (effPid >= 1.f || fakePid >= 1.f || !isfinite(effPid) || effPid <= KFloatEpsilon || !isfinite(fakePid) || !isfinite(flatWeightPid)) + if (effPid >= 1.f || fakePid >= 1.f || !std::isfinite(effPid) || effPid <= KFloatEpsilon || !std::isfinite(fakePid) || !std::isfinite(flatWeightPid)) continue; for (int ieta = 0; ieta < KNEta; ++ieta) { @@ -1557,18 +1558,18 @@ struct RadialFlowDecorr { float mmetReco = pmeanEtRecoNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); float mmetRecoEffCor = pmeanEtRecoEffcorrNchEtabinPtbinStep2->GetBinContent(ibx, iby, ibz); - if (isfinite(mmptTru)) + if (std::isfinite(mmptTru)) std::tie(meanTru[ieta][ipt], c2Tru[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkTru[ieta][ipt], sumWkTru[ieta][ipt], mmptTru); - if (isfinite(mmptReco)) + if (std::isfinite(mmptReco)) std::tie(meanReco[ieta][ipt], c2Reco[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkReco[ieta][ipt], sumWkReco[ieta][ipt], mmptReco); - if (isfinite(mmptRecoEffCor)) + if (std::isfinite(mmptRecoEffCor)) std::tie(meanRecoEffCor[ieta][ipt], c2RecoEffCor[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEffCor[ieta][ipt], sumWkRecoEffCor[ieta][ipt], mmptRecoEffCor); - if (isfinite(mmetTru)) + if (std::isfinite(mmetTru)) std::tie(meanTruEt[ieta][ipt], c2TruEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkTruEt[ieta][ipt], sumWkTruEt[ieta][ipt], mmetTru); - if (isfinite(mmetReco)) + if (std::isfinite(mmetReco)) std::tie(meanRecoEt[ieta][ipt], c2RecoEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEt[ieta][ipt], sumWkRecoEt[ieta][ipt], mmetReco); - if (isfinite(mmetRecoEffCor)) + if (std::isfinite(mmetRecoEffCor)) std::tie(meanRecoEffCorEt[ieta][ipt], c2RecoEffCorEt[ieta][ipt]) = calculateMeanAndC2FromSums(sumPmwkRecoEffCorEt[ieta][ipt], sumWkRecoEffCorEt[ieta][ipt], mmetRecoEffCor); } } @@ -2090,16 +2091,16 @@ struct RadialFlowDecorr { } } histos.fill(HIST("Prof_cent_Nchrec"), cent, sumWi[0][0]); - if (isfinite(sumWi[0][0])) + if (std::isfinite(sumWi[0][0])) histos.fill(HIST("Prof_MeanpT_Cent"), cent, sumWipti[0][0] / sumWi[0][0]); - if (isfinite(sumWiEt[0][0])) + if (std::isfinite(sumWiEt[0][0])) histos.fill(HIST("Prof_MeanEt_Cent"), cent, sumWiEtVal[0][0] / sumWiEt[0][0]); for (int ieta = 0; ieta < KNEta; ++ieta) { for (int ipt = 0; ipt < KNpT; ++ipt) { - if (isfinite(sumWi[ieta][ipt])) + if (std::isfinite(sumWi[ieta][ipt])) histos.fill(HIST("pmean_nch_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, sumWipti[ieta][ipt] / sumWi[ieta][ipt]); - if (isfinite(sumWiEt[ieta][ipt])) + if (std::isfinite(sumWiEt[ieta][ipt])) histos.fill(HIST("pmeanEt_nch_etabin_ptbin"), coll.multNTracksPV(), ieta, ipt, sumWiEtVal[ieta][ipt] / sumWiEt[ieta][ipt]); } } From 9108e7e8415888722c278bf49045340cdd25e7fd Mon Sep 17 00:00:00 2001 From: Somadutta Bhatta Date: Tue, 11 Nov 2025 23:22:55 +0100 Subject: [PATCH 09/10] Apply minor clang-format fix --- PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx b/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx index 48edf68acbb..ba662ae8133 100644 --- a/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx +++ b/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx @@ -627,7 +627,7 @@ struct RadialFlowDecorr { // pT cumulants histos.add("MCGen/Prof_C2_Cent", ";cent;C_{2}", kTProfile, {centAxis}); histos.add("MCGen/Prof_C2_Mult", ";N_{PV};C_{2}", kTProfile, {nChAxis}); - histos.add("MCGen/Prof_C2Sub_Mult_etabin_ptbin",";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{KNbinsNchFluc, KBinOffset, KNchMax}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("MCGen/Prof_C2Sub_Mult_etabin_ptbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{KNbinsNchFluc, KBinOffset, KNchMax}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); histos.add("MCGen/Prof_ipt0_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); histos.add("MCGen/Prof_ipt1_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); histos.add("MCGen/Prof_ipt2_C2Sub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); @@ -639,7 +639,7 @@ struct RadialFlowDecorr { histos.add("MCGen/Prof_ipt2_Cov_Eta", ";#eta;cov", kTProfile, {{(KNEta - 1) / 2, 0., KEtaAxisMax}}); histos.add("MCGen/Prof_C2Et_Cent", ";cent;C_{2}^{E_{T}}", kTProfile, {centAxis}); histos.add("MCGen/Prof_C2Et_Mult", ";N_{PV};C_{2}^{E_{T}}", kTProfile, {nChAxis}); - histos.add("MCGen/Prof_C2EtSub_Mult_etabin_ptbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D,{{KNbinsNchFluc, KBinOffset, KNchMax}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); + histos.add("MCGen/Prof_C2EtSub_Mult_etabin_ptbin", ";N_{PV};#eta-bin; p_{T}-bin", kTProfile3D, {{KNbinsNchFluc, KBinOffset, KNchMax}, {KNEta + 1, -KBinOffset, KNEta + KBinOffset}, {KNpT + 1, -KBinOffset, KNpT + KBinOffset}}); histos.add("MCGen/Prof_ipt0_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); histos.add("MCGen/Prof_ipt1_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); histos.add("MCGen/Prof_ipt2_C2EtSub2D_Mult_etaA_etaC", ";cent;#eta_{A};#eta_{C}", kTProfile3D, {{centAxis}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}, {KNEta - 1, KEtaAxisMin, KEtaAxisMax}}); From 3bab3d647b8fb8cf8672fd7aeea196e3a1ebc4db Mon Sep 17 00:00:00 2001 From: Somadutta Bhatta Date: Wed, 12 Nov 2025 02:18:16 +0100 Subject: [PATCH 10/10] fixed O2Physics/O2 build issue --- PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx b/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx index ba662ae8133..a3e9bd56fcd 100644 --- a/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx +++ b/PWGCF/EbyEFluctuations/Tasks/radialFlowDecorr.cxx @@ -390,7 +390,7 @@ struct RadialFlowDecorr { float getEfficiency(float mult, float pt, float eta, PID pidType, int effidx) const { - TH3F* h; + TH3F* h = nullptr; if (effidx == 0) h = hEff[pidType]; if (effidx == 1)