From b26cdcabf0048ea709c38cbfb49276d6105903d9 Mon Sep 17 00:00:00 2001 From: mkruger Date: Fri, 17 Oct 2025 17:24:55 +0200 Subject: [PATCH 1/3] read PCC weights from CCDB --- .../particleCompositionCorrectionTable.h | 8 ++--- .../Nuspex/particleCompositionCorrection.cxx | 30 ++++++++++++++----- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/PWGLF/DataModel/particleCompositionCorrectionTable.h b/PWGLF/DataModel/particleCompositionCorrectionTable.h index b91ee3df50d..f57d2165e76 100644 --- a/PWGLF/DataModel/particleCompositionCorrectionTable.h +++ b/PWGLF/DataModel/particleCompositionCorrectionTable.h @@ -25,11 +25,11 @@ namespace o2::aod { namespace PCC { -DECLARE_SOA_COLUMN(Pccweight, pccweight, float); -DECLARE_SOA_COLUMN(Pccweightsysup, pccweightsysup, float); -DECLARE_SOA_COLUMN(Pccweightsysdown, pccweightsysdown, float); +DECLARE_SOA_COLUMN(PccWeight, pccWeight, float); +DECLARE_SOA_COLUMN(PccWeightSysUp, pccWeightSysUp, float); +DECLARE_SOA_COLUMN(PccWeightSysDown, pccWeightSysDown, float); } // namespace PCC -DECLARE_SOA_TABLE(ParticleCompositionCorrection, "AOD", "PARTICLECOMPOSITIONCORRECTION", PCC::Pccweight, PCC::Pccweightsysup, PCC::Pccweightsysdown); +DECLARE_SOA_TABLE(ParticleCompositionCorrection, "AOD", "PARTICLECOMPOSITIONCORRECTION", PCC::PccWeight, PCC::PccWeightSysUp, PCC::PccWeightSysDown); } // namespace o2::aod #endif // PWGLF_DATAMODEL_PARTICLECOMPOSITIONCORRECTIONTABLE_H_ diff --git a/PWGLF/TableProducer/Nuspex/particleCompositionCorrection.cxx b/PWGLF/TableProducer/Nuspex/particleCompositionCorrection.cxx index c8cdb79bb57..e44266d7371 100644 --- a/PWGLF/TableProducer/Nuspex/particleCompositionCorrection.cxx +++ b/PWGLF/TableProducer/Nuspex/particleCompositionCorrection.cxx @@ -17,6 +17,7 @@ #include "Tools/ML/model.h" +#include #include #include #include @@ -45,7 +46,6 @@ struct ParticleCompositionCorrection { /* backlog: - - store final neural networks in ccdb and implement accessing them - support collision systems beyond pp - add QA task illustrating improved mc/data matching of DCA distributions after scaling of secondaries - extend PCC weight table by columns with systematic variations (up/down) @@ -54,14 +54,18 @@ struct ParticleCompositionCorrection { */ Service pdg; + o2::ccdb::CcdbApi ccdbApi; + + Configurable skipAll{"skipAll", false, "run table producer in dummy mode, i.e. skip all computations and fill with 1"}; + Configurable skipSec{"skipSec", false, "dont calculate weights for secondaries"}; Configurable etaCut{"etaCut", 0.8f, "eta cut"}; Configurable ptMinCut{"ptMinCut", 0.15f, "pt min cut"}; Configurable ptMaxCut{"ptMaxCut", 10.f, "pt max cut"}; - Configurable skipSec{"skipSec", false, "dont calculate weights for secondaries"}; Configurable enableQAHistos{"enableQAHistos", true, "enable qa histograms showing the effect of the PCC"}; - Configurable modelNameData{"modelNameData", "ParticleFractions_pp_data.onnx", "Path to the .onnx file containing the particle fractions in data"}; - Configurable modelNameMC{"modelNameMC", "ParticleFractions_pp_pythia.onnx", "Path to the .onnx file containing the particle fractions in MC"}; + Configurable ccdbBasePath{"ccdbBasePath", "/Users/m/makruger/", "ccdb directory contianing the particle fraction networks"}; + Configurable modelPathData{"modelPathData", "PCC/data/pp", "Path to the .onnx file containing the particle fractions in data"}; + Configurable modelPathMC{"modelPathMC", "PCC/pythia/pp", "Path to the .onnx file containing the particle fractions in MC"}; OnnxModel particleFractionsData; OnnxModel particleFractionsMC; @@ -80,8 +84,18 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) void ParticleCompositionCorrection::init(InitContext const&) { - particleFractionsData.initModel(modelNameData.value, true); - particleFractionsMC.initModel(modelNameMC.value, true); + if (skipAll) { + return; + } + if (!ccdbBasePath.value.empty()) { + ccdbApi.init("http://ccdb-test.cern.ch:8080"); + static const long dummyTimeStamp = 2; + if (!ccdbApi.retrieveBlob(ccdbBasePath.value + modelPathData.value, modelPathData.value, {}, dummyTimeStamp, false, "ParticleFractions_Data.onnx") || !ccdbApi.retrieveBlob(ccdbBasePath.value + modelPathMC.value, modelPathMC.value, {}, dummyTimeStamp, false, "ParticleFractions_MC.onnx")) { + LOGP(fatal, "Could not download particle fraction networks!"); + } + } + particleFractionsData.initModel(modelPathData.value + "/ParticleFractions_Data.onnx", true); + particleFractionsMC.initModel(modelPathMC.value + "/ParticleFractions_MC.onnx", true); if (enableQAHistos) { std::vector ptBinEdges = {0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, @@ -129,7 +143,7 @@ void ParticleCompositionCorrection::process(aod::McCollisions::iterator const&, float weight = 1.f; // calculate weights only inside the configured kinematic range - if (std::abs(particle.eta()) < etaCut && particle.pt() > ptMinCut && particle.pt() < ptMaxCut) { + if (!skipAll && std::abs(particle.eta()) < etaCut && particle.pt() > ptMinCut && particle.pt() < ptMaxCut) { auto refParticleID = particle.index(); // find initial particle of secondaries from decays or interactions with material @@ -165,6 +179,8 @@ void ParticleCompositionCorrection::process(aod::McCollisions::iterator const&, {PDG_t::kSigma0, 3.f}, {PDG_t::kXiMinus, 3.f}, // TODO: potentially extend by xi0/eta/omega/rho/phi/Delta... + // pdg codes defined in AliceO2/Common/Constants/include/CommonConstants/PhysicsConstants.h + // e.g. o2::constants::physics::Pdg::kEta }; if (auto iterMapPID = mapPID.find(absPDGCode); iterMapPID != mapPID.end()) { From 021609b4c0af1b56d5650f8222583f42f94e95d9 Mon Sep 17 00:00:00 2001 From: mkruger Date: Fri, 17 Oct 2025 17:35:07 +0200 Subject: [PATCH 2/3] fix for megalinter --- PWGLF/TableProducer/Nuspex/particleCompositionCorrection.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGLF/TableProducer/Nuspex/particleCompositionCorrection.cxx b/PWGLF/TableProducer/Nuspex/particleCompositionCorrection.cxx index e44266d7371..875ff4ff7c5 100644 --- a/PWGLF/TableProducer/Nuspex/particleCompositionCorrection.cxx +++ b/PWGLF/TableProducer/Nuspex/particleCompositionCorrection.cxx @@ -89,7 +89,7 @@ void ParticleCompositionCorrection::init(InitContext const&) } if (!ccdbBasePath.value.empty()) { ccdbApi.init("http://ccdb-test.cern.ch:8080"); - static const long dummyTimeStamp = 2; + static const int64_t dummyTimeStamp = 2; if (!ccdbApi.retrieveBlob(ccdbBasePath.value + modelPathData.value, modelPathData.value, {}, dummyTimeStamp, false, "ParticleFractions_Data.onnx") || !ccdbApi.retrieveBlob(ccdbBasePath.value + modelPathMC.value, modelPathMC.value, {}, dummyTimeStamp, false, "ParticleFractions_MC.onnx")) { LOGP(fatal, "Could not download particle fraction networks!"); } From 583df74daa030d209c7321b1855fd5597409ca38 Mon Sep 17 00:00:00 2001 From: mkruger Date: Fri, 17 Oct 2025 20:49:37 +0200 Subject: [PATCH 3/3] fix string scope --- PWGLF/TableProducer/Nuspex/particleCompositionCorrection.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGLF/TableProducer/Nuspex/particleCompositionCorrection.cxx b/PWGLF/TableProducer/Nuspex/particleCompositionCorrection.cxx index 875ff4ff7c5..457cee3120a 100644 --- a/PWGLF/TableProducer/Nuspex/particleCompositionCorrection.cxx +++ b/PWGLF/TableProducer/Nuspex/particleCompositionCorrection.cxx @@ -63,7 +63,7 @@ struct ParticleCompositionCorrection { Configurable ptMaxCut{"ptMaxCut", 10.f, "pt max cut"}; Configurable enableQAHistos{"enableQAHistos", true, "enable qa histograms showing the effect of the PCC"}; - Configurable ccdbBasePath{"ccdbBasePath", "/Users/m/makruger/", "ccdb directory contianing the particle fraction networks"}; + Configurable ccdbBasePath{"ccdbBasePath", "/Users/m/makruger/", "ccdb directory contianing the particle fraction networks"}; Configurable modelPathData{"modelPathData", "PCC/data/pp", "Path to the .onnx file containing the particle fractions in data"}; Configurable modelPathMC{"modelPathMC", "PCC/pythia/pp", "Path to the .onnx file containing the particle fractions in MC"};