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