ATLAS Offline Software
CaloClusterMLCalibToolLiteCfg.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4 from AthenaConfiguration.ComponentFactory import CompFactory
5 from AthOnnxComps.OnnxRuntimeInferenceConfig import OnnxRuntimeInferenceToolCfg
6 from PathResolver import PathResolver
7 import yaml
8 
9 
11  flags,
12  name="CaloClusterMLCalibToolLite",
13  config_file="CaloClusterCorrection/config_hgm_mc20.yaml",
14 ):
15  with open(PathResolver.FindCalibFile(config_file)) as f:
16  config = yaml.safe_load(f)
17 
18  onnx_model_path = config["model"]["onnx_path"]
19  features = config["data"]["features"]
20  sorted_features = sorted(features.items(), key=lambda item: item[1]["position"])
21  transform_names = [
22  item[1]["preprocessing"]["processors"][0] for item in sorted_features
23  ]
24  transform_params = [
25  [float(x) for x in item[1]["preprocessing"]["parameters"]]
26  for item in sorted_features
27  ]
28 
30  onnx_tool = ca.popToolsAndMerge(OnnxRuntimeInferenceToolCfg(flags, onnx_model_path))
31  CaloClusterMLCalibToolLite = CompFactory.CaloClusterMLCalibToolLite(name)
32  CaloClusterMLCalibToolLite.ORTInferenceTool = onnx_tool
33  CaloClusterMLCalibToolLite.PreprocessingTransformNames = transform_names
34  CaloClusterMLCalibToolLite.PreprocessingTransformParams = transform_params
35  ca.setPrivateTools(CaloClusterMLCalibToolLite)
36 
37  return ca
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename R::value_type > sorted(const R &r, PROJ proj={})
Helper function to create a sorted vector from an unsorted range.
PathResolver::FindCalibFile
static std::string FindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.h:63
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.OnnxRuntimeInferenceConfig.OnnxRuntimeInferenceToolCfg
def OnnxRuntimeInferenceToolCfg(flags, str model_fname=None, Optional[OnnxRuntimeType] execution_provider=None, name="OnnxRuntimeInferenceTool", **kwargs)
Definition: OnnxRuntimeInferenceConfig.py:9
Trk::open
@ open
Definition: BinningType.h:40
CaloClusterMLCalibToolLiteCfg.CaloClusterMLCalibToolLiteCfg
def CaloClusterMLCalibToolLiteCfg(flags, name="CaloClusterMLCalibToolLite", config_file="CaloClusterCorrection/config_hgm_mc20.yaml")
Definition: CaloClusterMLCalibToolLiteCfg.py:10
python.LArMinBiasAlgConfig.float
float
Definition: LArMinBiasAlgConfig.py:65