Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #!/usr/bin/env python3
0002 import sys
0003 import os
0004 import argparse
0005 
0006 from HLTrigger.Configuration.extend_argparse import *
0007 import HLTrigger.Configuration.Tools.confdb as confdb
0008 import HLTrigger.Configuration.Tools.options as options
0009 
0010 # define an argparse parser to parse our options
0011 textwidth = int( 80 )
0012 try:
0013     textwidth = int( os.popen("stty size 2> /dev/null", "r").read().split()[1] )
0014 except:
0015     pass
0016 formatter = FixedWidthFormatter( HelpFormatterRespectNewlines, width = textwidth )
0017 
0018 parser = argparse.ArgumentParser(
0019   description       = 'Extract an HLT configuration (or fragment thereof) from the ConfDB database.''',
0020   argument_default  = argparse.SUPPRESS,
0021   formatter_class   = formatter,
0022   add_help          = False )
0023 
0024 # read defaults
0025 defaults = options.HLTProcessOptions()
0026 
0027 # required argument
0028 parser.add_argument('menu',
0029                     action  = 'store',
0030                     type    = options.ConnectionHLTMenu,
0031                     metavar = 'MENU',
0032                     help    = 'HLT menu to dump from the database. Supported formats are:\n  - /path/to/configuration[/Vn]\n  - [[{v1|v2|v3}/]{run3|run2|online|adg}:]/path/to/configuration[/Vn]\n  - run:runnumber\nThe possible converters are "v1", "v2, and "v3" (default).\nThe possible databases are "run3" (default, used for offline development), "run2" (used for accessing run2 offline development menus), "online" (used to extract online menus within Point 5) and "adg" (used to extract the online menus outside Point 5).\nIf no menu version is specified, the latest one is automatically used.\nIf "run:" is used instead, the HLT menu used for the given run number is looked up and used.\nNote other converters and databases exist as options but they are only for expert/special use.' )
0033 
0034 # options
0035 parser.add_argument('--process',
0036                     dest    = 'name',
0037                     action  = 'store',
0038                     default = defaults.name,
0039                     metavar = 'PROCESS',
0040                     help    = 'Override the process name (the default is %(default)s)' )
0041 parser.add_argument('--type',
0042                     dest    = 'type',
0043                     action  = 'store',
0044                     metavar = 'TYPE',
0045                     choices = options.globalTag,
0046                     default = defaults.type,
0047                     help    = 'Set global options according to a specific HLT luminosity and type (%(choices)s).' )
0048 parser.add_argument('--globaltag',
0049                     dest    = 'globaltag',
0050                     action  = 'store',
0051                     metavar = 'TAG',
0052                     default = defaults.globaltag,
0053                     help    = 'Override the GlobalTag in the HLT menu:\n- when running on data, the default behaviour is to not override the GobalTag in the HLT menu\n- when running on MC, the default behaviour is to use the GlobalTag from "type" and the current PyRelVal configuration.\nTo run on data with a different release than the menu was designed for, try "auto:hltonline"' )
0054 parser.add_argument('--l1',
0055                     dest    = 'l1',
0056                     action  = 'store',
0057                     type    = options.ConnectionL1TMenu,
0058                     default = defaults.l1,
0059                     metavar = 'MENU',
0060                     help    = 'Override the L1 menu, using the given payload from the database. %(metavar)s should have the format "L1GtTriggerMenu_MENU_mc".\nThe default behaviour is to run with the L1 menu from the GlobalTag' )
0061 parser.add_argument('--l1Xml',
0062                     dest    = 'l1Xml',
0063                     action  = 'store',
0064                     type    = options.ConnectionL1TMenuXml,
0065                     default = defaults.l1Xml,
0066                     metavar = 'MENU',
0067                     help    = 'Override the L1 menu, using the given Xml file. %(metavar)s should have the format "L1Menu_Collisions2012_v0_L1T_Scales_20101224_Imp0_0x1027.xml".\nThe default behaviour is to run with the L1 menu from the GlobalTag' )
0068 parser.add_argument('--l1-emulator',
0069                     dest    = 'emulator',
0070                     action  = 'store',
0071                     metavar = 'EMULATOR',
0072                     nargs   = '?',
0073                     choices = [ 'Full', 'FullMC', 'Full2015Data', 'uGT' ],
0074                     default = defaults.emulator,
0075                     const   = 'Full',
0076                     help    = 'Run the Full stage-2 L1T emulator.' )
0077 
0078 group = parser.add_mutually_exclusive_group()
0079 group.add_argument('--dbproxy',
0080                     dest    = 'proxy',
0081                     action  = 'store_true',
0082                     default = defaults.proxy,
0083                     help    = 'Use a socks proxy to connect outside CERN network (default: False)' )
0084 group.add_argument('--dbtunnel',
0085                     dest    = 'tunnel',
0086                     action  = 'store_true',
0087                     default = defaults.tunnel,
0088                     help    = 'Use direct tunnel to connect outside CERN network (default: False)' )
0089 
0090 parser.add_argument('--dbproxyport',
0091                     dest    = 'proxy_port',
0092                     action  = 'store',
0093                     metavar = 'PROXYPORT',
0094                     default = defaults.proxy_port,
0095                     help    = 'Port of the socks proxy (default: 8080)' )
0096 parser.add_argument('--dbproxyhost',
0097                     dest    = 'proxy_host',
0098                     action  = 'store',
0099                     metavar = 'PROXYHOST',
0100                     default = defaults.proxy_host,
0101                     help    = 'Host of the socks proxy (default: "localhost")' )
0102 parser.add_argument('--dbtunnelport',
0103                     dest    = 'tunnel_port',
0104                     action  = 'store',
0105                     metavar = 'TUNNELPORT',
0106                     default = defaults.tunnel_port,
0107                     help    = 'Port when using a direct tunnel on localhost (default: 10121)' )
0108 
0109 group = parser.add_mutually_exclusive_group()
0110 group.add_argument('--prescale',
0111                     dest    = 'prescale',
0112                     action  = 'store',
0113                     default = defaults.prescale,
0114                     help    = 'Force using one specific prescale column.\nUse "--prescale none" to run without any HLT prescales' )
0115 group.add_argument('--no-prescale',
0116                     dest    = 'prescale',
0117                     action  = 'store_const',
0118                     const   = 'none',
0119                     help    = 'Same as "--prescale none"' )
0120 group.add_argument('--unprescale',
0121                     dest    = 'prescale',
0122                     action  = 'store_const',
0123                     const   = 'none',
0124                     help    = 'Same as "--prescale none"' )
0125 
0126 parser.add_argument('--open',
0127                     dest    = 'open',
0128                     action  = 'store_true',
0129                     default = defaults.open,
0130                     help    = 'Run the HLT in "open" mode, overriding all ED/HLTFilters to always pass (overrides "--prescale" and implies "--prescale none")' )
0131 parser.add_argument('--eras',
0132                     dest    = 'eras',
0133                     action  = 'store',
0134                     type    = str,
0135                     default = defaults.eras,
0136                     metavar = 'ERAS',
0137                     help    = 'Select the defined Eras in HLT configuration (e.g. phase1Pixel)' )
0138 parser.add_argument('--customise',
0139                     dest    = 'customise',
0140                     action  = 'store',
0141                     type    = str,
0142                     default = defaults.customise,
0143                     metavar = 'CUSTOMISE',
0144                     help    = 'Apply the user-defined customization functions using the format HLTrigger/Configuration/customizeHLTTrackingForPhaseI2017.customizeHLTForPFTrackingPhaseI2017' )
0145 parser.add_argument('--error-events',
0146                     dest    = 'errortype',
0147                     action  = 'store_true',
0148                     default = defaults.errortype,
0149                     help    = 'Modify all HLTTriggerTypeFilter EDFilters to accept only error events (SelectedTriggerType = 0)' )
0150 parser.add_argument('--profiling',
0151                     dest    = 'profiling',
0152                     action  = 'store_true',
0153                     default = defaults.profiling,
0154                     help    = 'Instrument the menu with the modules for profiling studies (hltGetRaw and hltGetConditions), disable options' )
0155 parser.add_argument('--timing',
0156                     dest    = 'timing',
0157                     action  = 'store_true',
0158                     default = defaults.timing,
0159                     help    = 'Instrument the menu with the Service, EDModules and EndPath needed for timing studies (implies --profiling)' )
0160 parser.add_argument('--paths',
0161                     dest    = 'paths',
0162                     action  = 'store',
0163                     type    = str,
0164                     default = defaults.paths,
0165                     metavar = 'PATHS',
0166                     help    = 'Include only the given comma-separated-list of paths in the dump (wildcards are accepted)\nNote that in a full dump the "smart prescale" modules will likely fail, unless removed with "--output none" or "--output minimal"' )
0167 parser.add_argument('--input',
0168                     dest    = 'input',
0169                     action  = 'store',
0170                     type    = str,
0171                     default = defaults.input,
0172                     metavar = 'SOURCE',
0173                     help    = 'If set, specify the SOURCE input file(s) or dataset, otherwise a default is chosen up depending on the other options.\nSOURCE can be a single file nane, a comma-separated list of file names, or have the format "dataset:DATASET" to query a DATASET definition from DAS' )
0174 parser.add_argument('--parent',
0175                     dest    = 'parent',
0176                     action  = 'store',
0177                     type    = str,
0178                     default = defaults.parent,
0179                     metavar = 'PARENT',
0180                     help    = 'If set, specify the PARENT input file(s) or dataset, using the same syntax as SOURCE, above' )
0181 parser.add_argument('--max-events',
0182                     dest    = 'events',
0183                     action  = 'store',
0184                     type    = int,
0185                     default = defaults.events,
0186                     metavar = 'EVENTS',
0187                     help    = 'Run on EVENTS events (-1 for unlimited)' )
0188 parser.add_argument('--setup',
0189                     dest    = 'setup',
0190                     action  = 'store',
0191                     type    = str,
0192                     default = defaults.setup,
0193                     metavar = 'STORE',
0194                     help    = 'If set, download setup_cff from the specified configuration and load it. Note, it is forced to be the same database and converter as specified by primary menu configuration, in fact it is an error to specify a converter/database here and the command will fail' )
0195 
0196 group = parser.add_mutually_exclusive_group()
0197 group.add_argument('--output',
0198                     dest    = 'output',
0199                     action  = 'store',
0200                     metavar = 'OUTPUT',
0201                     choices = [ 'all', 'minimal', 'none', 'full' ],
0202                     default = defaults.output,
0203                     help    = 'Use:\n- "all" to output all output modules (default)\n- "minimal" to only output the TriggerResults\n- "none" to remove all output modules\n- "full" to output a single root file with "keep *" event content.' )
0204 group.add_argument('--no-output',
0205                     dest    = 'output',
0206                     action  = 'store_const',
0207                     const   = 'none',
0208                     help    = 'Same as "--output none"' )
0209 
0210 group = parser.add_mutually_exclusive_group()
0211 group.add_argument('--data',
0212                     dest    = 'data',
0213                     action  = 'store_true',
0214                     default = defaults.data,
0215                     help    = 'Prepare a menu for running on data (raw events in "source") (default)' )
0216 group.add_argument('--mc',
0217                     dest    = 'data',
0218                     action  = 'store_false',
0219                     default = not defaults.data,
0220                     help    = 'Prepare a menu for running on MC (raw events in "rawDataCollector")' )
0221 
0222 parser.add_argument('--hilton',
0223                     dest    = 'hilton',
0224                     action  = 'store_true',
0225                     default = defaults.hilton,
0226                     help    = 'Keep the hilton-specific modules' )
0227 
0228 group = parser.add_mutually_exclusive_group()
0229 group.add_argument('--full',
0230                     dest    = 'fragment',
0231                     action  = 'store_false',
0232                     default = not defaults.fragment,
0233                     help    = 'Generate a full configuration file, with minimal modifications (default)' )
0234 group.add_argument('--fragment', '--cff',
0235                     dest    = 'fragment',
0236                     action  = 'store_true',
0237                     default = defaults.fragment,
0238                     help    = 'Generate a stripped down configuration file fragment, for inclusion by e.g. cmsDriver.py (with no input or output sections)' )
0239 
0240 group = parser.add_mutually_exclusive_group()
0241 group.add_argument('--online',
0242                     dest    = 'unused',
0243                     action  = 'store_true',
0244                     help    = 'Ignored' )
0245 group.add_argument('--offline',
0246                     dest    = 'unused',
0247                     action  = 'store_true',
0248                     help    = 'Ignored' )
0249 
0250 # redefine "--help" to be the last option, and use a customized message
0251 parser.add_argument('--help',
0252                     action  = 'help',
0253                     help    = 'Show this help message and exit' )
0254 
0255 # parse command line arguments and options
0256 config = parser.parse_args(namespace = options.HLTProcessOptions())
0257 
0258 # do not include db-proxy/tunnel options in 1st-line comment
0259 cmdArgs, skipNext = [], False
0260 for cmdArg in sys.argv:
0261   if skipNext:
0262     skipNext = False
0263     continue
0264   if cmdArg.startswith('--dbproxy') or cmdArg.startswith('--dbtunnel'):
0265     if cmdArg.startswith('--dbproxyh') or cmdArg.startswith('--dbproxyp') or cmdArg.startswith('--dbtunnelp'):
0266       skipNext = '=' not in cmdArg
0267     continue
0268   cmdArgs += [cmdArg]
0269 cmdArgs[0] = os.path.basename(cmdArgs[0])
0270 
0271 cmdLine = ' '.join(cmdArgs)
0272 print('# ' + cmdLine)
0273 print()
0274 print(confdb.HLTProcess(config).dump())