Skip to content

Commit 644fdef

Browse files
[PWGLF] read PCC weights from CCDB (#13442)
1 parent 82bd634 commit 644fdef

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

PWGLF/DataModel/particleCompositionCorrectionTable.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ namespace o2::aod
2525
{
2626
namespace PCC
2727
{
28-
DECLARE_SOA_COLUMN(Pccweight, pccweight, float);
29-
DECLARE_SOA_COLUMN(Pccweightsysup, pccweightsysup, float);
30-
DECLARE_SOA_COLUMN(Pccweightsysdown, pccweightsysdown, float);
28+
DECLARE_SOA_COLUMN(PccWeight, pccWeight, float);
29+
DECLARE_SOA_COLUMN(PccWeightSysUp, pccWeightSysUp, float);
30+
DECLARE_SOA_COLUMN(PccWeightSysDown, pccWeightSysDown, float);
3131
} // namespace PCC
32-
DECLARE_SOA_TABLE(ParticleCompositionCorrection, "AOD", "PARTICLECOMPOSITIONCORRECTION", PCC::Pccweight, PCC::Pccweightsysup, PCC::Pccweightsysdown);
32+
DECLARE_SOA_TABLE(ParticleCompositionCorrection, "AOD", "PARTICLECOMPOSITIONCORRECTION", PCC::PccWeight, PCC::PccWeightSysUp, PCC::PccWeightSysDown);
3333
} // namespace o2::aod
3434

3535
#endif // PWGLF_DATAMODEL_PARTICLECOMPOSITIONCORRECTIONTABLE_H_

PWGLF/TableProducer/Nuspex/particleCompositionCorrection.cxx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "Tools/ML/model.h"
1919

20+
#include <CCDB/CcdbApi.h>
2021
#include <Framework/AnalysisTask.h>
2122
#include <Framework/HistogramRegistry.h>
2223
#include <Framework/O2DatabasePDGPlugin.h>
@@ -45,7 +46,6 @@ struct ParticleCompositionCorrection {
4546

4647
/*
4748
backlog:
48-
- store final neural networks in ccdb and implement accessing them
4949
- support collision systems beyond pp
5050
- add QA task illustrating improved mc/data matching of DCA distributions after scaling of secondaries
5151
- extend PCC weight table by columns with systematic variations (up/down)
@@ -54,14 +54,18 @@ struct ParticleCompositionCorrection {
5454
*/
5555

5656
Service<o2::framework::O2DatabasePDG> pdg;
57+
o2::ccdb::CcdbApi ccdbApi;
58+
59+
Configurable<bool> skipAll{"skipAll", false, "run table producer in dummy mode, i.e. skip all computations and fill with 1"};
60+
Configurable<bool> skipSec{"skipSec", false, "dont calculate weights for secondaries"};
5761
Configurable<float> etaCut{"etaCut", 0.8f, "eta cut"};
5862
Configurable<float> ptMinCut{"ptMinCut", 0.15f, "pt min cut"};
5963
Configurable<float> ptMaxCut{"ptMaxCut", 10.f, "pt max cut"};
60-
Configurable<bool> skipSec{"skipSec", false, "dont calculate weights for secondaries"};
6164
Configurable<bool> enableQAHistos{"enableQAHistos", true, "enable qa histograms showing the effect of the PCC"};
6265

63-
Configurable<std::string> modelNameData{"modelNameData", "ParticleFractions_pp_data.onnx", "Path to the .onnx file containing the particle fractions in data"};
64-
Configurable<std::string> modelNameMC{"modelNameMC", "ParticleFractions_pp_pythia.onnx", "Path to the .onnx file containing the particle fractions in MC"};
66+
Configurable<std::string> ccdbBasePath{"ccdbBasePath", "/Users/m/makruger/", "ccdb directory contianing the particle fraction networks"};
67+
Configurable<std::string> modelPathData{"modelPathData", "PCC/data/pp", "Path to the .onnx file containing the particle fractions in data"};
68+
Configurable<std::string> modelPathMC{"modelPathMC", "PCC/pythia/pp", "Path to the .onnx file containing the particle fractions in MC"};
6569

6670
OnnxModel particleFractionsData;
6771
OnnxModel particleFractionsMC;
@@ -80,8 +84,18 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
8084

8185
void ParticleCompositionCorrection::init(InitContext const&)
8286
{
83-
particleFractionsData.initModel(modelNameData.value, true);
84-
particleFractionsMC.initModel(modelNameMC.value, true);
87+
if (skipAll) {
88+
return;
89+
}
90+
if (!ccdbBasePath.value.empty()) {
91+
ccdbApi.init("http://ccdb-test.cern.ch:8080");
92+
static const int64_t dummyTimeStamp = 2;
93+
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")) {
94+
LOGP(fatal, "Could not download particle fraction networks!");
95+
}
96+
}
97+
particleFractionsData.initModel(modelPathData.value + "/ParticleFractions_Data.onnx", true);
98+
particleFractionsMC.initModel(modelPathMC.value + "/ParticleFractions_MC.onnx", true);
8599

86100
if (enableQAHistos) {
87101
std::vector<double> 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&,
129143
float weight = 1.f;
130144

131145
// calculate weights only inside the configured kinematic range
132-
if (std::abs(particle.eta()) < etaCut && particle.pt() > ptMinCut && particle.pt() < ptMaxCut) {
146+
if (!skipAll && std::abs(particle.eta()) < etaCut && particle.pt() > ptMinCut && particle.pt() < ptMaxCut) {
133147
auto refParticleID = particle.index();
134148

135149
// find initial particle of secondaries from decays or interactions with material
@@ -165,6 +179,8 @@ void ParticleCompositionCorrection::process(aod::McCollisions::iterator const&,
165179
{PDG_t::kSigma0, 3.f},
166180
{PDG_t::kXiMinus, 3.f},
167181
// TODO: potentially extend by xi0/eta/omega/rho/phi/Delta...
182+
// pdg codes defined in AliceO2/Common/Constants/include/CommonConstants/PhysicsConstants.h
183+
// e.g. o2::constants::physics::Pdg::kEta
168184
};
169185

170186
if (auto iterMapPID = mapPID.find(absPDGCode); iterMapPID != mapPID.end()) {

0 commit comments

Comments
 (0)