From 8a24243ed7b9fbe66b4251c2603216625a2ce8e1 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Tue, 25 Aug 2026 22:28:37 +0000 Subject: [PATCH] Please consider the following formatting changes --- .../Strangeness/strangenessMcCentrality.cxx | 2 +- PWGLF/Utils/mcCentralityModule.h | 145 +++++++++--------- 2 files changed, 74 insertions(+), 73 deletions(-) diff --git a/PWGLF/TableProducer/Strangeness/strangenessMcCentrality.cxx b/PWGLF/TableProducer/Strangeness/strangenessMcCentrality.cxx index d51f3e60b78..31c969b5303 100644 --- a/PWGLF/TableProducer/Strangeness/strangenessMcCentrality.cxx +++ b/PWGLF/TableProducer/Strangeness/strangenessMcCentrality.cxx @@ -15,8 +15,8 @@ /// \brief Task to produce the MC centrality table for strangeness derived data /// -#include "PWGLF/Utils/mcCentralityModule.h" #include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/Utils/mcCentralityModule.h" #include #include diff --git a/PWGLF/Utils/mcCentralityModule.h b/PWGLF/Utils/mcCentralityModule.h index 3e9a98013a9..d982442a3fc 100644 --- a/PWGLF/Utils/mcCentralityModule.h +++ b/PWGLF/Utils/mcCentralityModule.h @@ -23,10 +23,10 @@ #include #include #include -#include #include -#include +#include #include +#include #include #include #include @@ -36,14 +36,15 @@ #include #include #include -#include #include +#include + #include #include +#include #include #include -#include #include #include #include @@ -66,17 +67,16 @@ namespace mccentrality // avoid polluting other namespaces // statics necessary for the configurables in this namespace static constexpr int nParameters = 1; static const std::vector tableNames{ - "McCentFV0As", - "McCentFT0Ms", - "McCentFT0As", - "McCentFT0Cs", - "McCentFT0CVariant1s", - "McCentFT0CVariant2s", - "McCentFDDMs", - "McCentNTPVs", - "McCentNGlobals", - "McCentMFTs" -}; + "McCentFV0As", + "McCentFT0Ms", + "McCentFT0As", + "McCentFT0Cs", + "McCentFT0CVariant1s", + "McCentFT0CVariant2s", + "McCentFDDMs", + "McCentNTPVs", + "McCentNGlobals", + "McCentMFTs"}; static constexpr int nTablesConst = 10; static const std::vector parameterNames{"enable"}; @@ -103,20 +103,19 @@ enum tableIndex { kFV0A = 0, kNTPV, kNGlobal, kMFT, - kNestimators}; + kNestimators }; static constexpr const char* DirList[] = { - "FV0A", - "FT0M", - "FT0A", - "FT0C", - "FT0CVariant1", - "FT0CVariant2", - "FDDM", - "NTPV", - "NGlobal", - "MFT" -}; + "FV0A", + "FT0M", + "FT0A", + "FT0C", + "FT0CVariant1", + "FT0CVariant2", + "FDDM", + "NTPV", + "NGlobal", + "MFT"}; // mcCentralityModule: 1st-order configurables struct coreConfigurables : o2::framework::ConfigurableGroup { @@ -136,7 +135,7 @@ struct coreConfigurables : o2::framework::ConfigurableGroup { ConfigurableAxis binsPercentileFine{"binsPercentileFine", {VARIABLE_WIDTH, 0, 0.001, 0.01, 1.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0}, "Binning of the percentile axis"}; ConfigurableAxis binsMultiplicity{"binsMultiplicity", {1000, 0, 5000}, "Binning of the multiplicity axis"}; - //ccdb configurables + // ccdb configurables Configurable path{"path", "/tmp/InputCalibMC.root", "path to calib file or ccdb path if begins with ccdb://"}; // debug option @@ -159,11 +158,11 @@ struct products : o2::framework::ProducesGroup { template concept HasMcMults = requires(typename T::iterator a) { - { a.multMCFT0A() } -> std::convertible_to; - { a.multMCFT0C() } -> std::convertible_to; - { a.multMCFV0A() } -> std::convertible_to; - { a.multMCFDDA() } -> std::convertible_to; - { a.multMCFDDC() } -> std::convertible_to; + { a.multMCFT0A() } -> std::convertible_to; + { a.multMCFT0C() } -> std::convertible_to; + { a.multMCFV0A() } -> std::convertible_to; + { a.multMCFDDA() } -> std::convertible_to; + { a.multMCFDDC() } -> std::convertible_to; { a.multMCNParticlesEta08() } -> std::convertible_to; { a.multMCNParticlesEta05() } -> std::convertible_to; }; @@ -378,7 +377,8 @@ struct BuilderModule { } template - THist* getHist(const char* name) { + THist* getHist(const char* name) + { if (!this->MCCentralityCalibObjects) { return (THist*)0x0; } @@ -396,17 +396,18 @@ struct BuilderModule { return hist; } - TH1D* extractCentralityCalibration(int idx, const char* name, bool reverse = false) { + TH1D* extractCentralityCalibration(int idx, const char* name, bool reverse = false) + { - auto CalibMC = [&](TString estimator){ + auto CalibMC = [&](TString estimator) { LOGF(info, "\e[1;31mCalibration for %s estimator\e[0;00m -> Starting...\n", estimator.Data()); std::vector percentile_center(nCentBins); std::vector epercentile_center(nCentBins); - //Histograms - TH2D *h2dMultVsCent_Data = getHist(Form("h2dMultVsCent%s_Data", estimator.Data())); - TH2D *h2dMultRecoVsMultGen_MC = getHist(Form("hMultEta05VsGenMult%s", estimator.Data())); + // Histograms + TH2D* h2dMultVsCent_Data = getHist(Form("h2dMultVsCent%s_Data", estimator.Data())); + TH2D* h2dMultRecoVsMultGen_MC = getHist(Form("hMultEta05VsGenMult%s", estimator.Data())); if (!h2dMultVsCent_Data || !h2dMultRecoVsMultGen_MC) { return (TH1D*)0x0; } @@ -418,12 +419,12 @@ struct BuilderModule { TProfile* hPVData = hCalibPVData[idx].get(); TProfile* hPVMC = hCalibPVMC[idx].get(); - TH1D *h1dCalib = h2dMultRecoVsMultGen_MC->ProjectionX(Form("h1d%s", estimator.Data()), 1, h2dMultRecoVsMultGen_MC->GetNbinsX()); + TH1D* h1dCalib = h2dMultRecoVsMultGen_MC->ProjectionX(Form("h1d%s", estimator.Data()), 1, h2dMultRecoVsMultGen_MC->GetNbinsX()); h1dCalib->Reset(); h1dCalib->SetTitle(Form("%s calibration object", estimator.Data())); h1dCalib->GetXaxis()->SetTitle(Form("#it{N}_{%s, gen.}", estimator.Data())); h1dCalib->GetYaxis()->SetTitle(Form("%s percentile (%%)", estimator.Data())); - + // NOTE: candidate-by-candidate assignment (assignCentralityPerCandidate) does not go through this // mean-matching path at all. It samples directly from the "hGenMultEta05VsCentrality" // joint histogram (x = reco centrality of the matched MC collision, y = generated mult |eta|<0.5) @@ -432,16 +433,16 @@ struct BuilderModule { if (reverse) { for (int i = 0; i < nCentBins; i++) { int irev = i; - percentile_center[i] = (centralityBins[irev] + centralityBins[irev+1]) / 2; - epercentile_center[i] = (centralityBins[irev] - centralityBins[irev+1]) / 2; + percentile_center[i] = (centralityBins[irev] + centralityBins[irev + 1]) / 2; + epercentile_center[i] = (centralityBins[irev] - centralityBins[irev + 1]) / 2; } int startBinMc = h1dCalib->GetNbinsX(); for (int i = 0; i < nCentBins; i++) { // Loop over centrality bins // start from the end (from the high multiplicity collisions) int irev = i; - TH1D* projData = h2dMultVsCent_Data->ProjectionY(Form("projData_%d", i), h2dMultVsCent_Data->GetXaxis()->FindBin(centralityBins[irev]+1e-5), - h2dMultVsCent_Data->GetXaxis()->FindBin(centralityBins[irev+1]-1e-5)); + TH1D* projData = h2dMultVsCent_Data->ProjectionY(Form("projData_%d", i), h2dMultVsCent_Data->GetXaxis()->FindBin(centralityBins[irev] + 1e-5), + h2dMultVsCent_Data->GetXaxis()->FindBin(centralityBins[irev + 1] - 1e-5)); double meanMult_Data = projData->GetMean(); @@ -467,7 +468,7 @@ struct BuilderModule { endBinMc = j; } } - if (i == nCentBins-1) { + if (i == nCentBins - 1) { endBinMc = 1; } @@ -492,14 +493,14 @@ struct BuilderModule { } } - LOGF(info, "\e[1;31mCalibration for %s estimator\e[0;00m -> Data centrality bin \e[1;31m%g-%g%%\e[0;00m\n", estimator.Data(), centralityBins[irev], centralityBins[irev+1]); + LOGF(info, "\e[1;31mCalibration for %s estimator\e[0;00m -> Data centrality bin \e[1;31m%g-%g%%\e[0;00m\n", estimator.Data(), centralityBins[irev], centralityBins[irev + 1]); LOGF(info, "\e[1;31mCalibration for %s estimator\e[0;00m -> MC multiplicity range %g-%g\n", estimator.Data(), projMC->GetBinLowEdge(endBinMc), projMC->GetBinLowEdge(startBinMc)); - LOGF(info, "\e[1;31mCalibration for %s estimator\e[0;00m -> data = %.4f Vs MC = %.4f (MC/Data = %.4f%%)\n", estimator.Data(), meanMult_Data, meanMult_MC, (meanMult_MC-meanMult_Data) * 100 / meanMult_Data); + LOGF(info, "\e[1;31mCalibration for %s estimator\e[0;00m -> data = %.4f Vs MC = %.4f (MC/Data = %.4f%%)\n", estimator.Data(), meanMult_Data, meanMult_MC, (meanMult_MC - meanMult_Data) * 100 / meanMult_Data); LOGF(info, "\e[1;31mCalibration for %s estimator\e[0;00m -> N entries Data = %g Vs N entries MC = %g\n", estimator.Data(), projData->Integral(), projMC->Integral()); LOGF(info, "\n"); for (int ibin = 1; ibin <= h1dCalib->GetNbinsX(); ibin++) { - if (ibin <= startBinMc && ibin >= endBinMc){ - h1dCalib->SetBinContent(ibin, percentile_center[i]); + if (ibin <= startBinMc && ibin >= endBinMc) { + h1dCalib->SetBinContent(ibin, percentile_center[i]); } } startBinMc = endBinMc; @@ -507,15 +508,15 @@ struct BuilderModule { } else { for (int i = 0; i < nCentBins; i++) { int irev = nCentBins - i; - percentile_center[i] = (centralityBins[irev-1] + centralityBins[irev]) / 2; - epercentile_center[i] = (centralityBins[irev] - centralityBins[irev-1]) / 2; + percentile_center[i] = (centralityBins[irev - 1] + centralityBins[irev]) / 2; + epercentile_center[i] = (centralityBins[irev] - centralityBins[irev - 1]) / 2; } int startBinMc = 1; for (int i = 0; i < nCentBins; i++) { // Loop over centrality bins // start from the end (from the low multiplicity collisions) int irev = nCentBins - i; - TH1D* projData = h2dMultVsCent_Data->ProjectionY(Form("projData_%d", i), h2dMultVsCent_Data->GetXaxis()->FindBin(centralityBins[irev-1]+1e-5), - h2dMultVsCent_Data->GetXaxis()->FindBin(centralityBins[irev]-1e-5)); + TH1D* projData = h2dMultVsCent_Data->ProjectionY(Form("projData_%d", i), h2dMultVsCent_Data->GetXaxis()->FindBin(centralityBins[irev - 1] + 1e-5), + h2dMultVsCent_Data->GetXaxis()->FindBin(centralityBins[irev] - 1e-5)); double meanMult_Data = projData->GetMean(); @@ -541,8 +542,8 @@ struct BuilderModule { endBinMc = j; } } - if (i == nCentBins-1) { - endBinMc = h2dMultRecoVsMultGen_MC->GetNbinsX(); + if (i == nCentBins - 1) { + endBinMc = h2dMultRecoVsMultGen_MC->GetNbinsX(); } TH1D* projMC = h2dMultRecoVsMultGen_MC->ProjectionY(Form("projMC_%d", i), startBinMc, endBinMc); @@ -566,17 +567,17 @@ struct BuilderModule { } } - LOGF(info, "\e[1;31mCalibration for %s estimator\e[0;00m -> Data centrality bin \e[1;31m%g-%g%%\e[0;00m\n", estimator.Data(), centralityBins[irev-1], centralityBins[irev]); - LOGF(info, "\e[1;31mCalibration for %s estimator\e[0;00m -> MC multiplicity range %g-%g\n", estimator.Data(), projMC->GetBinLowEdge(startBinMc), projMC->GetBinLowEdge(endBinMc+1)); + LOGF(info, "\e[1;31mCalibration for %s estimator\e[0;00m -> Data centrality bin \e[1;31m%g-%g%%\e[0;00m\n", estimator.Data(), centralityBins[irev - 1], centralityBins[irev]); + LOGF(info, "\e[1;31mCalibration for %s estimator\e[0;00m -> MC multiplicity range %g-%g\n", estimator.Data(), projMC->GetBinLowEdge(startBinMc), projMC->GetBinLowEdge(endBinMc + 1)); LOGF(info, "\e[1;31mCalibration for %s estimator\e[0;00m -> data = %.4f Vs MC = %.4f\n", estimator.Data(), meanMult_Data, meanMult_MC); LOGF(info, "\e[1;31mCalibration for %s estimator\e[0;00m -> N entries Data = %g Vs N entries MC = %g\n", estimator.Data(), projData->Integral(), projMC->Integral()); for (int ibin = 1; ibin <= h1dCalib->GetNbinsX(); ibin++) { - if (ibin <= endBinMc && ibin >= startBinMc){ - h1dCalib->SetBinContent(ibin, percentile_center[i]); + if (ibin <= endBinMc && ibin >= startBinMc) { + h1dCalib->SetBinContent(ibin, percentile_center[i]); } } - startBinMc = endBinMc+1; + startBinMc = endBinMc + 1; } // End loop over centrality bins } @@ -662,8 +663,8 @@ struct BuilderModule { // which has no systematic effect on the sampled distribution. ULong64_t computeSamplingSeed(int64_t collisionIndex, int tableIdx) const { - static constexpr ULong64_t kCollisionStride = 131ull; // > kNestimators, so tableIdx can't alias into the collision term - static constexpr ULong64_t kRunStride = 1000003ull; // prime, well above kCollisionStride * (typical collisions per DF) + static constexpr ULong64_t kCollisionStride = 131ull; // > kNestimators, so tableIdx can't alias into the collision term + static constexpr ULong64_t kRunStride = 1000003ull; // prime, well above kCollisionStride * (typical collisions per DF) return baseOpts.centralitySamplingSeed.value + kRunStride * static_cast(mRunNumber) + kCollisionStride * static_cast(collisionIndex) + static_cast(tableIdx); } @@ -717,15 +718,15 @@ struct BuilderModule { return percentile; }; - populateTable(products.centFV0A, h1dFV0A, h2dCentVsGenMult[kFV0A], nFV0A, std::integral_constant{}); - populateTable(products.centFT0M, h1dFT0M, h2dCentVsGenMult[kFT0M], nFT0M, std::integral_constant{}); - populateTable(products.centFT0A, h1dFT0A, h2dCentVsGenMult[kFT0A], nFT0A, std::integral_constant{}); - populateTable(products.centFT0C, h1dFT0C, h2dCentVsGenMult[kFT0C], nFT0C, std::integral_constant{}); - populateTable(products.centFT0CVariant1, h1dFT0CVariant1, h2dCentVsGenMult[kFT0CVariant1], nFT0C, std::integral_constant{}); - populateTable(products.centFT0CVariant2, h1dFT0CVariant2, h2dCentVsGenMult[kFT0CVariant2], nFT0C, std::integral_constant{}); - populateTable(products.centFDDM, h1dFDDM, h2dCentVsGenMult[kFDDM], nFDDM, std::integral_constant{}); - populateTable(products.centNTPV, h1dNTPV, h2dCentVsGenMult[kNTPV], nGlobal, std::integral_constant{}); - populateTable(products.centNGlobal, h1dNGlobal, h2dCentVsGenMult[kNGlobal], nGlobal, std::integral_constant{}); + populateTable(products.centFV0A, h1dFV0A, h2dCentVsGenMult[kFV0A], nFV0A, std::integral_constant{}); + populateTable(products.centFT0M, h1dFT0M, h2dCentVsGenMult[kFT0M], nFT0M, std::integral_constant{}); + populateTable(products.centFT0A, h1dFT0A, h2dCentVsGenMult[kFT0A], nFT0A, std::integral_constant{}); + populateTable(products.centFT0C, h1dFT0C, h2dCentVsGenMult[kFT0C], nFT0C, std::integral_constant{}); + populateTable(products.centFT0CVariant1, h1dFT0CVariant1, h2dCentVsGenMult[kFT0CVariant1], nFT0C, std::integral_constant{}); + populateTable(products.centFT0CVariant2, h1dFT0CVariant2, h2dCentVsGenMult[kFT0CVariant2], nFT0C, std::integral_constant{}); + populateTable(products.centFDDM, h1dFDDM, h2dCentVsGenMult[kFDDM], nFDDM, std::integral_constant{}); + populateTable(products.centNTPV, h1dNTPV, h2dCentVsGenMult[kNTPV], nGlobal, std::integral_constant{}); + populateTable(products.centNGlobal, h1dNGlobal, h2dCentVsGenMult[kNGlobal], nGlobal, std::integral_constant{}); // populateTable(products.centMFT, h1dMFT, h2dCentVsGenMult[kMFT], nMFT, std::integral_constant{}); // to be added later mcCollisionCounter++;