ATLAS Offline Software
MuonSelectorToolsConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2 
3 #********************************************************************
4 # MuonsSelectionToolConfig.py
5 # Configures muon selection tool which is used to select muons
6 # for use in physics analysis
7 #********************************************************************
8 
9 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
10 from AthenaConfiguration.ComponentFactory import CompFactory
11 from AthenaConfiguration.Enums import LHCPeriod
12 
13 def MuonSelectionToolCfg(flags, name="MuonSelectionTool", **kwargs):
14  """Configure the muon selection tool"""
15  acc = ComponentAccumulator()
16 
17  # Configure the Onnx tool FIRST
18  from AthOnnxComps.OnnxRuntimeFlags import OnnxRuntimeType
19  from AthOnnxComps.OnnxRuntimeInferenceConfig import OnnxRuntimeInferenceToolCfg
20 
21  model_fname = "MuonSelectorTools/TightNN_Experimental_18062025/model_DNN3norm_MC20ade.onnx"
22  if flags.GeoModel.Run >= LHCPeriod.Run3:
23  model_fname = "MuonSelectorTools/TightNN_Experimental_18062025/model_DNN3norm_MC23ad.onnx"
24 
25  execution_provider = OnnxRuntimeType.CPU
26  # Set defaults AFTER ort_tool is available
27  kwargs.setdefault("IsRun3Geo", flags.GeoModel.Run >= LHCPeriod.Run3)
28  kwargs.setdefault("DisablePtCuts", True)
29  kwargs.setdefault("TurnOffMomCorr", True)
30  kwargs.setdefault("ORTInferenceTool", acc.popToolsAndMerge(
31  OnnxRuntimeInferenceToolCfg(flags, model_fname, execution_provider, name=name+"_ORTInferenceTool")
32  ))
33 
34 
35  # Now construct the tool with all kwargs set
36  the_tool = CompFactory.CP.MuonSelectionTool(name, **kwargs)
37  acc.setPrivateTools(the_tool)
38  acc.printConfig(withDetails=True)
39 
40  return acc
41 
42 
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.MuonSelectorToolsConfig.MuonSelectionToolCfg
def MuonSelectionToolCfg(flags, name="MuonSelectionTool", **kwargs)
Definition: MuonSelectorToolsConfig.py:13
python.OnnxRuntimeInferenceConfig.OnnxRuntimeInferenceToolCfg
def OnnxRuntimeInferenceToolCfg(flags, str model_fname=None, Optional[OnnxRuntimeType] execution_provider=None, name="OnnxRuntimeInferenceTool", **kwargs)
Definition: OnnxRuntimeInferenceConfig.py:9