ATLAS Offline Software
TrigADHypoConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaCommon.Logging import logging
4 from AthenaConfiguration.ComponentFactory import CompFactory
5 from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
6 from TrigEDMConfig.TriggerEDM import recordable
7 
8 log = logging.getLogger('TrigADHypoAlgs')
9 
10 # Object cuts sets used to configure the AD input multiplicity and pT threshold
11 object_cuts_sets = {
12  "default": {
13  "max_jets": 6,
14  "max_electrons": 3,
15  "max_muons": 3,
16  "max_photons": 3,
17  }
18 }
19 
20 # cuts applied for each config value
21 config_dict = {
22  "default":{
23  "object_cuts": "default",
24  "adScoreThres": 0.5,
25  },
26  "L":{
27  "object_cuts": "default",
28  "adScoreThres": 6.174, # 20 Hz est. w/ v2
29  },
30  "M":{
31  "object_cuts": "default",
32  "adScoreThres": 6.929, # 10 Hz est. w/ v2
33  },
34  "T":{
35  "object_cuts": "default",
36  "adScoreThres": 8.358, # 5 Hz est. w/ v2
37  }
38 
39 }
40 
41 def TrigADGetConfigValue(chainDict, key):
42  values = [i.strip(key) for i in chainDict['topo']]
43 
44  if len(values) != 1:
45  raise RuntimeError("Invalid chain dictionary for AD trigger, unable to find config value in {}".format(str(chainDict)))
46 
47  return values[0]
48 
49 def TrigADComboHypoToolFromDict(flags, chainDict):
50  name = chainDict['chainName']
51  group = chainDict['groups']
52 
53  log.debug("Inside AD ComboHypoToolFromDict")
54  log.debug("chainDict: %s", chainDict)
55 
56  cfg_name = TrigADGetConfigValue(chainDict, "anomdet")
57  cfg = config_dict[cfg_name]
58 
59  obj_cuts = object_cuts_sets[cfg["object_cuts"]]
60 
61  if "adWrite" in group:
62  adScoreName = recordable("HLT_AnomDet_ComboHypo")
63  else:
64  adScoreName = ""
65 
66  tool = CompFactory.TrigADComboHypoTool(
67  name,
68  max_jets = obj_cuts["max_jets"],
69  max_electrons = obj_cuts["max_electrons"],
70  max_muons = obj_cuts["max_muons"],
71  max_photons = obj_cuts["max_photons"],
72  ModelFileName = "TrigAnomalyDetectionHypo/2025-03-12/HLT_AD_v2.onnx",
73  adScoreThres = float(cfg["adScoreThres"]),
74  adScoreKey = adScoreName,
75  )
76 
77  if "adMon:online" in group:
78  monTool = GenericMonitoringTool(flags, 'MonTool', HistPath='TrigADComboHypoTool/'+name.replace("leg000_",""))
79  monTool.defineHistogram("adScore", path='EXPERT', type='TH1F', title="HLT AD Score;;Entries", xbins=200, xmin=0, xmax=20 )
80  monFlag = True
81  tool.monTool = monTool
82  tool.monFlag = monFlag
83  else:
84  monFlag = False
85  tool.monFlag = monFlag
86 
87  return tool
TrigADHypoConfig.TrigADComboHypoToolFromDict
def TrigADComboHypoToolFromDict(flags, chainDict)
Definition: TrigADHypoConfig.py:49
vtune_athena.format
format
Definition: vtune_athena.py:14
TrigADHypoConfig.TrigADGetConfigValue
def TrigADGetConfigValue(chainDict, key)
Definition: TrigADHypoConfig.py:41
GenericMonitoringTool
Definition: GenericMonitoringTool.py:1
python.TriggerEDM.recordable
def recordable(arg, runVersion=3)
Definition: TriggerEDM.py:37
str
Definition: BTagTrackIpAccessor.cxx:11
python.LArMinBiasAlgConfig.float
float
Definition: LArMinBiasAlgConfig.py:65