Back to home page

Project CMSSW displayed by LXR

 
 

    


Warning, /HLTrigger/Configuration/scripts/hltCheckPrescaleModules is written in an unsupported language. File is not indexed.

0001 #!/usr/bin/env python3
0002 import sys
0003 import types
0004 import re
0005 
0006 # global options
0007 enableWarnings = False
0008 
0009 if '-w' in sys.argv:
0010   sys.argv.remove('-w')
0011   enableWarnings = True
0012 
0013 if len(sys.argv) != 2:
0014   print("usage: %s [-w] menu.py" % sys.argv[0])
0015   sys.exit(1)
0016 
0017 # whitelist paths exempt from validation
0018 whitelist = [
0019   'HLTriggerFirstPath',
0020   'HLTriggerFinalPath',
0021   'Status_OnCPU',
0022   'Status_OnGPU',
0023 ]
0024 
0025 # load the menu and get the "process" object
0026 menu = types.ModuleType('menu')
0027 name = sys.argv[1]
0028 exec(open(name).read(), globals(), menu.__dict__)
0029 process = menu.process
0030 
0031 # get all paths
0032 paths = process.paths_()
0033 
0034 # keep track of prescaler names, and of duplicates
0035 prescalerNames = set()
0036 duplicateNames = set()
0037 
0038 # prescaler name generator
0039 generatePrescalerName = re.compile(r'^HLT_|_v\d+$|_')
0040 
0041 # loop over all paths and look for duplicate prescaler modules
0042 for path in paths:
0043     if path in whitelist:
0044       continue
0045 
0046     goodLabel = 'hltPre' + generatePrescalerName.sub('', path)
0047     found = False
0048 
0049     for module in paths[path].moduleNames():
0050         if module in process.filters_(): # found a filter
0051             if process.filters_()[module].type_() == 'HLTPrescaler': # it's a prescaler
0052                 if found:
0053                     print('ERROR: path %s has more than one HLTPrescaler module' % path)
0054                 found = True
0055                 label = process.filters_()[module].label()
0056                 if enableWarnings and label != goodLabel:
0057                     print('WARNING: path %s has an HLTPrescaler module labaled "%s", while the suggested label is "%s"' % (path, label, goodLabel))
0058                 if label in prescalerNames:
0059                     duplicateNames.add(label)
0060                 else:
0061                     prescalerNames.add(label)
0062     if not found:
0063         print('ERROR: path %s dos not have an HLTPrescaler module' % path)
0064 
0065 # print the duplicate prescales, and the affected paths
0066 for label in duplicateNames:
0067     print('ERROR: prescale  "%s"  is shared by the paths' % label)
0068     for path in paths:
0069         if label in paths[path].moduleNames():
0070             print('\t%s' % path)
0071     print()
0072