ATLAS Offline Software
ValidateEBMenu.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 #
5 
6 import json
7 
8 from AthenaCommon.Logging import logging
9 log = logging.getLogger('ValidateEBMenu.py')
10 
11 
12 def getL1Category(chainName):
13  return chainName.replace("HLT_noalg_L1", "L1_").replace("_noPS", "")
14 
15 
16 if __name__=='__main__':
17  from argparse import ArgumentParser
18  parser = ArgumentParser()
19  parser.add_argument('--hltPsk', type=str, help='HLTPrescale.json file')
20  parser.add_argument('--l1Psk', type=str, help='HLTPrescale.json file')
21  args = parser.parse_args()
22 
23  ebChains = [
24  "HLT_eb_low_L1RD2_FILLED", "HLT_eb_medium_L1RD2_FILLED",
25  "HLT_noalg_L1PhysicsHigh_noPS", "HLT_noalg_L1PhysicsVeryHigh_noPS",
26  "HLT_noalg_L1RD3_FILLED", "HLT_noalg_L1RD3_EMPTY",
27  "HLT_noalg_L1EMPTY_noPS", "HLT_noalg_L1FIRSTEMPTY_noPS",
28  "HLT_noalg_L1UNPAIRED_ISO_noPS", "HLT_noalg_L1UNPAIRED_NONISO_noPS"
29  ]
30 
31  if not args.hltPsk or not args.l1Psk:
32  log.error("Prescale files are required!")
33  exit(-1)
34 
35  with open(args.hltPsk) as f:
36  HLTPrescales = json.load(f)["prescales"]
37 
38  with open(args.l1Psk) as f:
39  L1Prescales = json.load(f)["cutValues"]
40 
41  from TriggerMenuMT.HLT.Menu.L1Seeds import getEBnoL1PSSeed
42  from TriggerMenuMT.HLT.CalibCosmicMon.EnhancedBiasChainConfiguration import l1seeds
43 
44  alreadyProcessed = {}
45 
46  for chainName in ebChains:
47  log.info(f"Processing chain {chainName}...")
48  hltPrescale = HLTPrescales[chainName]
49  if not hltPrescale:
50  log.error(f"Chain {chainName} not found in the HLT Prescales file")
51  continue
52 
53  if not hltPrescale["enabled"]:
54  log.error(f"Chain {chainName} disabled in the HLT Prescales file")
55  continue
56 
57  if "noalg" not in chainName: # randomly seeded chains
58  if "medium" in chainName:
59  currentSeeds = l1seeds["medium"]
60  else:
61  currentSeeds = l1seeds["low"]
62 
63  for seedName in currentSeeds:
64  if seedName in alreadyProcessed:
65  log.error(f"Seed {seedName} is already part of eb chain {alreadyProcessed[seedName]}")
66  else:
67  alreadyProcessed[seedName] = chainName
68 
69  l1Prescale = L1Prescales[seedName]
70  if not l1Prescale:
71  log.error(f"Seed {seedName} of chain {chainName} not found in the L1 Prescales file")
72  continue
73 
74  if not l1Prescale["enabled"]:
75  log.error(f"Seed {seedName} of chain {chainName} is disabled in the L1 Prescales file")
76  continue
77 
78  elif "_noPS" in chainName:
79  currentSeeds = getEBnoL1PSSeed([], getL1Category(chainName))
80  for seedName in currentSeeds:
81  if seedName in alreadyProcessed:
82  log.error(f"Seed {seedName} is already part of eb chain {alreadyProcessed[seedName]}")
83  else:
84  alreadyProcessed[seedName] = chainName
85 
86  l1Prescale = L1Prescales[seedName]
87  if not l1Prescale:
88  log.error(f"Seed {seedName} of chain {chainName} not found in the L1 Prescales file")
89  continue
90 
91  if not l1Prescale["enabled"]:
92  log.error(f"Seed {seedName} of chain {chainName} is disabled in the L1 Prescales file")
93  continue
94 
95  if l1Prescale["cut"] != 1:
96  log.error(f"Seed {seedName} of chain {chainName} is prescaled in the L1 Prescales file (it is in no prescale category)")
97  continue
98  else:
99  # randoms
100  seedName = getL1Category(chainName)
101  l1Prescale = L1Prescales[seedName]
102  if not l1Prescale:
103  log.error(f"Seed {seedName} of chain {chainName} not found in the L1 Prescales file")
104  continue
105 
106  if not l1Prescale["enabled"]:
107  log.error(f"Seed {seedName} of chain {chainName} is disabled in the L1 Prescales file")
108  continue
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
python.HLT.Menu.L1Seeds.getEBnoL1PSSeed
def getEBnoL1PSSeed(l1items, l1seedname)
Definition: L1Seeds.py:108
ValidateEBMenu.getL1Category
def getL1Category(chainName)
Definition: ValidateEBMenu.py:12
calibdata.exit
exit
Definition: calibdata.py:236
Trk::open
@ open
Definition: BinningType.h:40