ATLAS Offline Software
Loading...
Searching...
No Matches
Trigger
TriggerCommon
TriggerMenuMT
python
HLT
Config
JSON
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
HLTPrescaleJSON.generatePrescaleJSON
generatePrescaleJSON(flags, chainDicts)
Definition
HLTPrescaleJSON.py:8
Generated on
for ATLAS Offline Software by
1.14.0