ATLAS Offline Software
Loading...
Searching...
No Matches
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
9from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
10from AthenaConfiguration.ComponentFactory import CompFactory
11from AthenaConfiguration.Enums import LHCPeriod
12
13def MuonLoosenedNonCalibratedSelectionToolCfg(flags, name="MuonLoosenedNonCalibratedSelectionTool", **kwargs):
14 """Configure the muon selection tool"""
15 kwargs.setdefault("DisablePtCuts", True)
16 kwargs.setdefault("TurnOffMomCorr", True)
17 return MuonSelectionToolCfg(flags, name, **kwargs)
18
19
20#Pretty much copy of the above but without expert flags on disabling pt cuts and turning off momentum corrections. This is for use in physics analysis
21def MuonSelectionToolCfg(flags, name="MuonSelectionTool", **kwargs):
22 """Configure the muon selection tool"""
23 acc = ComponentAccumulator()
24
25 # Configure the Onnx tool FIRST
26 from AthOnnxComps.OnnxRuntimeFlags import OnnxRuntimeType
27 from AthOnnxComps.OnnxRuntimeInferenceConfig import OnnxRuntimeInferenceToolCfg
28
29 model_fname = "MuonSelectorTools/TightNN_Experimental_18062025/model_DNN3norm_MC20ade.onnx"
30 if flags.GeoModel.Run >= LHCPeriod.Run3:
31 model_fname = "MuonSelectorTools/TightNN_Experimental_18062025/model_DNN3norm_MC23ad.onnx"
32
33 execution_provider = OnnxRuntimeType.CPU
34 # Set defaults AFTER ort_tool is available
35 kwargs.setdefault("IsRun3Geo", flags.GeoModel.Run >= LHCPeriod.Run3)
36 kwargs.setdefault("ORTInferenceTool",
37 acc.popToolsAndMerge(OnnxRuntimeInferenceToolCfg(flags, model_fname, execution_provider, name=f"{name}_ORTInferenceTool")))
38
39
40 # Now construct the tool with all kwargs set
41 the_tool = CompFactory.CP.MuonSelectionTool(name, **kwargs)
42 acc.setPrivateTools(the_tool)
43 return acc
44
MuonSelectionToolCfg(flags, name="MuonSelectionTool", **kwargs)
MuonLoosenedNonCalibratedSelectionToolCfg(flags, name="MuonLoosenedNonCalibratedSelectionTool", **kwargs)