ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Calorimeter
CaloClusterCorrection
python
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
10
def
CaloClusterMLCalibToolLiteCfg
(
11
flags,
12
name="CaloClusterMLCalibToolLite",
13
config_file="CaloClusterCorrection/config_hgm_mc20.yaml",
14
):
15
if
flags.Input.MCCampaign.value.startswith(
"mc23"
):
16
config_file =
"CaloClusterCorrection/config_hgm_mc23.yaml"
17
18
with
open(
PathResolver.FindCalibFile
(config_file))
as
f:
19
config = yaml.safe_load(f)
20
21
onnx_model_path = config[
"model"
][
"onnx_path"
]
22
features = config[
"data"
][
"features"
]
23
sorted_features = sorted(features.items(), key=
lambda
item: item[1][
"position"
])
24
transform_names = [
25
item[1][
"preprocessing"
][
"processors"
][0]
for
item
in
sorted_features
26
]
27
transform_params = [
28
[float(x)
for
x
in
item[1][
"preprocessing"
][
"parameters"
]]
29
for
item
in
sorted_features
30
]
31
32
ca = ComponentAccumulator()
33
onnx_tool = ca.popToolsAndMerge(OnnxRuntimeInferenceToolCfg(flags, onnx_model_path))
34
CaloClusterMLCalibToolLite = CompFactory.CaloClusterMLCalibToolLite(name)
35
CaloClusterMLCalibToolLite.ORTInferenceTool = onnx_tool
36
CaloClusterMLCalibToolLite.PreprocessingTransformNames = transform_names
37
CaloClusterMLCalibToolLite.PreprocessingTransformParams = transform_params
38
ca.setPrivateTools(CaloClusterMLCalibToolLite)
39
40
return
ca
41
PathResolver::FindCalibFile
static std::string FindCalibFile(const std::string &logical_file_name)
Definition
PathResolver.h:63
CaloClusterMLCalibToolLiteCfg
Definition
CaloClusterMLCalibToolLiteCfg.py:1
Generated on
for ATLAS Offline Software by
1.17.0