diff --git a/Trigger/TrigConfiguration/TrigConfIO/python/JsonUtils.py b/Trigger/TrigConfiguration/TrigConfIO/python/JsonUtils.py index f6af2e64a016eb39d11c9b5656dacfcd13cb340f..794b4ffd1507c807ad7682b86053181cc244b0b9 100644 --- a/Trigger/TrigConfiguration/TrigConfIO/python/JsonUtils.py +++ b/Trigger/TrigConfiguration/TrigConfIO/python/JsonUtils.py @@ -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 diff --git a/Trigger/TrigConfiguration/TrigConfigSvc/python/TrigConfigSvcCfg.py b/Trigger/TrigConfiguration/TrigConfigSvc/python/TrigConfigSvcCfg.py index 442c7bac22577b3f7f617c935c1e0151ac25a3a7..346393999241294cec5b94fe7eab8949125ba427 100644 --- a/Trigger/TrigConfiguration/TrigConfigSvc/python/TrigConfigSvcCfg.py +++ b/Trigger/TrigConfiguration/TrigConfigSvc/python/TrigConfigSvcCfg.py @@ -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 diff --git a/Trigger/TriggerCommon/TriggerJobOpts/share/runHLT_standalone.py b/Trigger/TriggerCommon/TriggerJobOpts/share/runHLT_standalone.py index 1e093f673114936c5d61013769b611b838c48410..ae95a2d6750aa509eb5321e2a63fb8a504ebe67b 100644 --- a/Trigger/TriggerCommon/TriggerJobOpts/share/runHLT_standalone.py +++ b/Trigger/TriggerCommon/TriggerJobOpts/share/runHLT_standalone.py @@ -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()