Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:17:07

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 import HLTrigger.Configuration.Tools.options as _options
0004 import HLTrigger.Configuration.Tools.confdb  as _confdb
0005 
0006 def _build_options(**args):
0007     options = _options.HLTProcessOptions()
0008     for key, val in args.items():
0009         setattr(options, key, val)
0010     return options
0011 
0012 
0013 def getHltConfiguration(menu, **args):
0014     args['menu'] = menu
0015     args['fragment'] = False
0016     options = _build_options(**args)
0017 
0018     try:
0019         foo = {'process': None}
0020         exec(_confdb.HLTProcess(options).dump(), globals(), foo)
0021         process = foo['process']
0022     except:
0023         raise Exception(f'query to ConfDB failed (output is not a valid python file)\n  args={args}')
0024 
0025     if not isinstance(process, cms.Process):
0026         raise Exception(f'query to ConfDB did not return a valid HLT menu (cms.Process not found)\n  args={args}')
0027 
0028     return process
0029 
0030 
0031 def loadHltConfiguration(process, menu, **args):
0032     args['menu'] = menu
0033     args['fragment'] = True
0034     options = _build_options(**args)
0035 
0036     try:
0037         hlt = {'fragment': None}
0038         exec(_confdb.HLTProcess(options).dump(), globals(), hlt)
0039         process2 = hlt['fragment']
0040     except:
0041         raise Exception(f'query to ConfDB failed (output is not a valid python file)\n  args={args}')
0042 
0043     if not isinstance(process2, cms.Process):
0044         raise Exception(f'query to ConfDB did not return a valid HLT menu (cms.Process not found)\n  args={args}')
0045 
0046     process.extend( process2 )
0047 
0048     return process
0049 
0050 
0051 import FWCore.ParameterSet.Config as _cms
0052 _cms.Process.loadHltConfiguration = loadHltConfiguration