ATLAS Offline Software
HLTPrescaleJSON.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 import json
4 from TrigConfigSvc.TrigConfigSvcCfg import getHLTPrescalesSetFileName
5 from AthenaCommon.Logging import logging
6 __log = logging.getLogger( __name__ )
7 
8 def generatePrescaleJSON(flags, chainDicts):
9  """ Generates JSON given the ChainProps and sequences
10  """
11  # Prescale dictionary that is used to create the JSON content
12  prescaleDict = {
13  "filetype": "hltprescale",
14  "name": flags.Trigger.triggerMenuSetup,
15  "prescales": {}
16  }
17  # Sort chains by name not counter for easier post processing
18  for chain in sorted(chainDicts, key=lambda d: d['chainName']):
19  # Enabled flag is what determines disabling (here is based on prescale list from MenuPrescaleConfig)
20  chainEnabled = True
21  if (int(chain["prescale"]) <= 0):
22  chainEnabled = False
23 
24  # Now have all information to write the chain to the prescale dictionary
25  chainName = chain["chainName"]
26  prescaleDict["prescales"][chainName] = {
27  "hash": chain["chainNameHash"],
28  "prescale": chain["prescale"],
29  "enabled": chainEnabled
30  }
31  # Add express stream information
32  if "express" in chain["stream"]:
33  prescaleDict["prescales"][chainName]['prescale_express'] = chain["prescale"]
34  prescaleDict["prescales"][chainName]['enabled_express'] = chainEnabled
35 
36  # Prescale dictionary now completed, write to JSON
37  fileName = getHLTPrescalesSetFileName(flags)
38  __log.info( "Writing HLT Prescale JSON to %s", fileName )
39  with open( fileName, 'w' ) as fp:
40  json.dump( prescaleDict, fp, indent=4, sort_keys=False )
41 
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
Trk::open
@ open
Definition: BinningType.h:40
HLTPrescaleJSON.generatePrescaleJSON
def generatePrescaleJSON(flags, chainDicts)
Definition: HLTPrescaleJSON.py:8
python.TrigConfigSvcCfg.getHLTPrescalesSetFileName
def getHLTPrescalesSetFileName(flags)
Definition: TrigConfigSvcCfg.py:152