Commit 83a60d38 authored by Joerg Stelzer's avatar Joerg Stelzer
Browse files

Simplify menu generation

* Enable creation of a default L1PrescaleSet file
* create a joboptions json file that is modified for db upload
parent 1336ee2f
......@@ -12,3 +12,35 @@ def create_joboptions_json(properties, filename="HLTJobOptions.json"):
with open(filename,'w') as f:
hlt_json['properties'] = properties
json.dump(hlt_json, f, sort_keys=True, indent=4)
""" also create a configuration JSON file that can be uploaded
to the triggerdb for running at P1
"""
base, ending = (filename.rsplit('.',1) + ["json"])[:2]
filenameUpload = base + ".db." + ending
modifyConfigForP1(properties)
with open(filenameUpload,'w') as f:
hlt_json['properties'] = properties
json.dump(hlt_json, f, sort_keys=True, indent=4)
def modifyConfigForP1(properties):
""" modifies (in place) a number of job properties to run from the TriggerDB
modification in place is OK, as the original properties are temporary
"""
def mod(props, alg, prop, fnc):
if alg in props and prop in props[alg]:
origVal = props[alg][prop]
else:
origVal = ""
props[alg][prop] = fnc(origVal)
# L1 and HLT Config Svc must read from db
mod( properties, "LVL1ConfigSvc", "InputType", lambda x : "db" )
mod( properties, "HLTConfigSvc", "InputType", lambda x : "db" )
mod( properties, "HLTPrescaleCondAlg", "Source", lambda x : "COOL" ) # prescales will be read from COOL online
mod( properties, "HLTPrescaleCondAlg", "TriggerDB", lambda x : "JOSVC" ) # configuration will be taken from the JOSvc at P1
......@@ -32,6 +32,15 @@ def getHLTMenuFileName( flags=None ):
hltMenuFileName = hltMenuFileName.replace("_newJO","")
return hltMenuFileName
# L1 Prescales set json file name
def getL1PrescalesSetFileName( flags=None ):
if flags is None:
from TriggerJobOpts.TriggerFlags import TriggerFlags as tf
l1PrescalesSetFileName = 'L1PrescalesSet_'+tf.triggerMenuSetup()+'_'+tf.menuVersion()+'.json'
else:
l1PrescalesSetFileName = 'L1PrescalesSet_'+flags.Trigger.triggerMenuSetup+'_'+flags.Trigger.menuVersion+'.json'
return l1PrescalesSetFileName
# HLT Prescales set json file name
def getHLTPrescalesSetFileName( flags=None ):
......@@ -42,10 +51,34 @@ def getHLTPrescalesSetFileName( flags=None ):
hltPrescalesSetFileName = 'HLTPrescalesSet_'+flags.Trigger.triggerMenuSetup+'_'+flags.Trigger.menuVersion+'.json'
return hltPrescalesSetFileName
# Creates an L1 Prescale file from the menu
# this is a temporary solution, in the final version the L1PrescalesSet file should come from the menu
def createL1PrescalesFileFromMenu( flags=None ):
log = logging.getLogger('TrigConfigSvcCfg')
menuFN = getL1MenuFileName( flags )
with open(menuFN,'r') as fh:
data = json.load(fh)
pso = odict()
pso['filetype'] = 'l1prescale'
pso['name'] = data['name']
pso['cutValues'] = odict()
ps = pso['cutValues']
for name, item in sorted(data['items'].items()):
ps[name] = odict([
("cut", 1),
("enabled", True),
("info", "prescale: 1")
])
psFN = getL1PrescalesSetFileName( flags )
with open(psFN, 'w') as outfile:
json.dump(pso, outfile, indent = 4)
log.info("Generated default L1 prescale set %s", outfile.name)
# Creates an HLT Prescale file from the menu
# this is a temporary solution, in the final version the HLTPrescalesSet file should come from the menu
def createHLTPrescalesFileFromMenu( flags=None ):
log = logging.getLogger('TrigConfigSvcCfg')
menuFN = getHLTMenuFileName( flags )
with open(menuFN,'r') as fh:
data = json.load(fh)
......@@ -60,11 +93,13 @@ def createHLTPrescalesFileFromMenu( flags=None ):
("name", chName),
("counter", ch['counter']),
("hash", ch['nameHash']),
("prescale", 1)
("prescale", 1),
("enabled", 1)
])
psFN = getHLTPrescalesSetFileName( flags )
with open(psFN, 'w') as outfile:
json.dump(pso, outfile, indent = 4)
log.info("Generated default HLT prescale set %s", outfile.name)
def getTrigConfigFromFlag( flags=None ):
......@@ -189,12 +224,15 @@ def setupHLTPrescaleCondAlg( flags = None ):
if tc["source"] == "COOL":
if flags is None: # old style config
from AthenaCommon.AlgSequence import AthSequencer
condSequence = AthSequencer("AthCondSeq")
condSequence += hltPrescaleCondAlg
from IOVDbSvc.CondDB import conddb
conddb.addFolder( "TRIGGER", getHLTPrescaleFolderName(), className="AthenaAttributeList" )
log.info("Adding folder %s to conddb", getHLTPrescaleFolderName() )
# add the hltPrescaleCondAlg to condseq
if flags is None: # old style config
from AthenaCommon.AlgSequence import AthSequencer
condSequence = AthSequencer("AthCondSeq")
condSequence += hltPrescaleCondAlg
log.info("Adding HLTPrescaleCondAlg to AthCondSeq")
return hltPrescaleCondAlg
......
......@@ -399,8 +399,9 @@ TriggerFlags.triggerMenuSetup = opt.setMenu
TriggerFlags.readLVL1configFromXML = True
TriggerFlags.outputLVL1configFile = None
from TrigConfigSvc.TrigConfigSvcCfg import generateL1Menu
l1JsonFile = generateL1Menu()
from TrigConfigSvc.TrigConfigSvcCfg import generateL1Menu, createL1PrescalesFileFromMenu
generateL1Menu()
createL1PrescalesFileFromMenu()
from TrigConfigSvc.TrigConfigSvcCfg import getL1ConfigSvc
svcMgr += getL1ConfigSvc()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment