Skip to content

Commit 72c8012

Browse files
committed
Allow different species' models to live in different CCDB paths in mlBasedTrackSelector task
1 parent 8d580a4 commit 72c8012

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

PWGHF/D2H/TableProducer/mlBasedTrackSelector.cxx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ struct HfTrackSelectorTagSelTracks {
327327
Configurable<double> thresholdScoreKaonDs{"thresholdScoreKaonDs", 0., "min. Ds kaon-class score"};
328328
// ONNX runtime
329329
Configurable<bool> loadModelsFromCcdb{"loadModelsFromCcdb", false, "load the ONNX models from CCDB instead of a local path"};
330-
Configurable<std::string> mlModelPathCcdb{"mlModelPathCcdb", "path/to/ml/models", "CCDB path of the ML models"};
330+
Configurable<std::string> mlModelPathCcdbDplus{"mlModelPathCcdbDplus", "path/to/ml/models/Dplus", "CCDB path of the D+ track model"};
331+
Configurable<std::string> mlModelPathCcdbDs{"mlModelPathCcdbDs", "path/to/ml/models/Ds", "CCDB path of the Ds track model"};
331332
Configurable<int64_t> timestampCcdbForMlModels{"timestampCcdbForMlModels", -1, "timestamp of the ONNX files to be queried in CCDB"};
332333
Configurable<bool> enableOnnxOptimizations{"enableOnnxOptimizations", true, "enable the ONNX graph optimisations"};
333334
Configurable<int> onnxThreads{"onnxThreads", 1, "number of threads used by the ONNX runtime (0 = let onnxruntime decide)"};
@@ -384,11 +385,13 @@ struct HfTrackSelectorTagSelTracks {
384385
/// Configure one model from its configurables.
385386
/// \param model is the model to configure
386387
/// \param onnxFile is the ONNX file name
388+
/// \param ccdbPath is the CCDB path of the model, used if the models are loaded from CCDB
387389
/// \param features are the input feature names, in the order the model expects
388390
/// \param thrPion, thrKaon are the score thresholds
389391
/// \param name is used in the log message
390392
void configureModel(HfTrackModel& model,
391393
std::string const& onnxFile,
394+
std::string const& ccdbPath,
392395
std::vector<std::string> const& features,
393396
const double thrPion,
394397
const double thrKaon,
@@ -407,15 +410,15 @@ struct HfTrackSelectorTagSelTracks {
407410
model.response.configure(binsPtSingle, dummyCuts, cutDir, static_cast<uint8_t>(nOut));
408411
if (config.loadModelsFromCcdb) {
409412
ccdbApi.init(config.ccdbUrl);
410-
model.response.setModelPathsCCDB(onnxFiles, ccdbApi, std::vector<std::string>{config.mlModelPathCcdb.value}, config.timestampCcdbForMlModels);
413+
model.response.setModelPathsCCDB(onnxFiles, ccdbApi, std::vector<std::string>{ccdbPath}, config.timestampCcdbForMlModels);
411414
} else {
412415
model.response.setModelPathsLocal(onnxFiles);
413416
}
414417
model.response.cacheInputFeaturesIndices(features);
415418
model.response.init(config.enableOnnxOptimizations, config.onnxThreads);
416419
model.enabled = true;
417420
LOGP(info, "{}: configured from {} with {} input features and {} output classes (pion score > {}, kaon score > {})",
418-
name, onnxFile, features.size(), nOut, thrPion, thrKaon);
421+
name, config.loadModelsFromCcdb ? "CCDB " + ccdbPath : onnxFile, features.size(), nOut, thrPion, thrKaon);
419422
}
420423

421424
void init(InitContext const&)
@@ -430,11 +433,11 @@ struct HfTrackSelectorTagSelTracks {
430433
}
431434

432435
if (config.applyMlDplus) {
433-
configureModel(models[ChannelDplusToPiKPi], config.onnxFileNameDplus, config.inputFeaturesDplus,
436+
configureModel(models[ChannelDplusToPiKPi], config.onnxFileNameDplus, config.mlModelPathCcdbDplus, config.inputFeaturesDplus,
434437
config.thresholdScorePionDplus, config.thresholdScoreKaonDplus, "D+ track model");
435438
}
436439
if (config.applyMlDs) {
437-
configureModel(models[ChannelDsToKKPi], config.onnxFileNameDs, config.inputFeaturesDs,
440+
configureModel(models[ChannelDsToKKPi], config.onnxFileNameDs, config.mlModelPathCcdbDs, config.inputFeaturesDs,
438441
config.thresholdScorePionDs, config.thresholdScoreKaonDs, "Ds track model");
439442
}
440443
if (!models[ChannelDplusToPiKPi].enabled && !models[ChannelDsToKKPi].enabled) {

0 commit comments

Comments
 (0)