Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489
#! /usr/bin/env python3

# A Pyrelval Wrapper

from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
import sys
import os
import re
import Configuration.Applications
from Configuration.Applications.ConfigBuilder import ConfigBuilder, defaultOptions
import traceback
# Prepare a parser to read the options
usage=\
"""%(prog)s <TYPE> [options].
Example:

%(prog)s reco -s RAW2DIGI,RECO --conditions STARTUP_V4::All --eventcontent RECOSIM
"""
parser = ArgumentParser(usage=usage, formatter_class=ArgumentDefaultsHelpFormatter)

expertSettings = parser.add_argument_group('===============\n  Expert Options', 'Caution: please use only if you know what you are doing.')

parser.add_argument("evt_type", metavar="TYPE", nargs='?', type=str)
parser.add_argument("-s", "--step",
                    help="The desired step. The possible values are: "+\
                         "GEN,SIM,DIGI,L1,DIGI2RAW,HLT,RAW2DIGI,RECO,POSTRECO,DQM,ALCA,VALIDATION,HARVESTING, NONE or ALL.",
                    default="ALL",
                    type=str,
                    dest="step")

parser.add_argument("--conditions",
                    help="What conditions to use (required; provide value 'help' to get list of options)",
                    required=True,
                    type=str,
                    dest="conditions")

parser.add_argument("--eventcontent",
                    help="What event content to write out",
                    default='RECOSIM',
                    type=str,
                    dest="eventcontent")

parser.add_argument("--filein",
                    help="The infile name.",
                    default="", #to be changed in the default form later
                    type=str,
                    dest="filein")

parser.add_argument("--fileout",
                    help="The outfile name. If absent a default value is assigned",
                    default="", #to be changed in the default form later
                    type=str,
                    dest="fileout")

parser.add_argument("--rntuple_out",
                    help="If possible, use RNTuple format for output.",
                    action="store_true",
                    default=defaultOptions.rntuple_out,
                    dest="rntuple_out")

parser.add_argument("--filetype",
                    help="The type of the infile",
                    default=defaultOptions.filetype,
                    type=str,
                    dest="filetype",
                    choices=['EDM','DAT','LHE','MDCB','DQM','DQMDAQ', 'EDM_RNTUPLE']
                  )

parser.add_argument("-n", "--number",
                    help="The number of events.",
                    default=1,
                    type=int,
                    dest="number")

parser.add_argument("-o", "--number_out",
                    help="The number of events in output.",
                    default=None,
                    type=int,
                    dest="number_out")

parser.add_argument("--mc",
                    help="Specify that simulation is to be processed (default = guess based on options)",
                    action="store_true",
                    default=False,
                    dest="isMC")

parser.add_argument("--data",
                    help="Specify that data is to be processed (default = guess based on options)",
                    action="store_true",
                    default=False,
                    dest="isData")

parser.add_argument("--no_exec",
                    help="Do not exec cmsRun. Just prepare the python config file.",
                    action="store_true",
                    default=False,
                    dest="no_exec_flag")

parser.add_argument("--fast",
                    help="Specify that the configuration is for FASTSIM",
                    action="store_true",
                    default=False)

parser.add_argument("--runsAndWeightsForMC",
                    help="Assign run numbers to MC source according to relative weights. [(run1,weight1),...,(runN,weightN)])",
                    default=None,
                    dest="runsAndWeightsForMC")

parser.add_argument("--runsScenarioForMC",
                    help="Load a scenario to set run numbers in MC.)",
                    default=None,
                    dest="runsScenarioForMC")

parser.add_argument("--runsAndWeightsForMCIntegerWeights",
                    help="Assign run numbers to MC source according to relative weights where weighting is determined by the number of times the run number appears. [(run1,run2,...,runN)])",
                    default=None,
                    dest="runsAndWeightsForMCIntegerWeights")

parser.add_argument("--runsScenarioForMCIntegerWeights",
                    help="Load a scenario to set run numbers in MC with integer IOV weights.",
                    default=None,
                    dest="runsScenarioForMCIntegerWeights")

parser.add_argument("--runUnscheduled",
                    help="Automatically convert configuration to run unscheduled the EDProducers/EDFilters that were scheduled",
                    action="store_true",
                    default=False,
                    dest="runUnscheduled")

# expert settings
expertSettings.add_argument("--beamspot",
                            help="What beam spot to use (from Configuration/StandardSequences). Default depends on scenario",
                            default=None,
                            type=str,
                            dest="beamspot")

expertSettings.add_argument("--customise",
                            help="Specify the file where the code to modify the process object is stored.",
                            default=[],
                            action="append",
                            type=str,
                            dest="customisation_file")

expertSettings.add_argument("--customise_unsch",
                            help="Specify the file where the code to modify the process object is stored.",
                            default=[],
                            action="append",
                            type=str,
                            dest="customisation_file_unsch")

expertSettings.add_argument("--customise_commands",
                            help="Specify a string of commands",
                            default="",
                            type=str,
                            dest="customise_commands")

expertSettings.add_argument("--inline_custom",
                            help="inline the customisation file",
                            default=False,
                            action="store_true",
                            dest="inline_custom")

expertSettings.add_argument("--datatier",
                            help="What data tier to use.",
                            default='',
                            type=str,
                            dest="datatier")

expertSettings.add_argument( "--dirin",
                            help="The infile directory.",
                            default="",
                            type=str,
                            dest="dirin")

expertSettings.add_argument( "--dirout",
                            help="The outfile directory.",
                            default="",
                            type=str,
                            dest="dirout")

expertSettings.add_argument("--filtername",
                            help="What filter name to specify in output module",
                            default="",
                            type=str,
                            dest="filtername")

expertSettings.add_argument("--geometry",
                            help="What simulation geometry to use. Comma-separated SimGeometry,RecoGeometry is supported.",
                            default=defaultOptions.geometry,
                            type=str,
                            dest="geometry")

expertSettings.add_argument("--magField",
                            help="What magnetic field to use (from Configuration/StandardSequences).",
                            default=defaultOptions.magField,
                            type=str,
                            dest="magField")

expertSettings.add_argument("--no_output",
                            help="Do not write anything to disk. This is for "+\
                            "benchmarking purposes.",
                            action="store_true",
                            default=False,
                            dest="no_output_flag")

expertSettings.add_argument("--prefix",
                            help="Specify a prefix to the cmsRun command.",
                            default="",
                            type=str,
                            dest="prefix")

expertSettings.add_argument("--suffix",
                            help="Specify a suffix to the cmsRun command.",
                            default="",
                            type=str,
                            dest="suffix")

expertSettings.add_argument("--relval",
                            help="Set total number of events and events per job.", #this does not get used but get parsed in the command by DataOps
                            default="",
                            dest="relval")

expertSettings.add_argument("--dump_python",
                            help="Dump the config file in python "+\
                            "and do a full expansion of imports.",
                            action="store_true",
                            default=False,
                            dest="dump_python")

expertSettings.add_argument("--pileup",
                            help="What pileup config to use",
                            default=defaultOptions.pileup,
                            type=str,
                            dest="pileup")
    
expertSettings.add_argument("--pileup_input",
                            help="define the pile up files to mix with",
                            default=None,
                            type=str,
                            dest="pileup_input")

expertSettings.add_argument("--pileup_dasoption",
                            help="Additional option for DAS query of pile up",
                            default="",
                            type=str,
                            dest="pileup_dasoption")

expertSettings.add_argument("--datamix",
                            help="What datamix config to use",
                            default=defaultOptions.datamix,
                            type=str,
                            dest="datamix")

expertSettings.add_argument("--gflash",
                            help="Run the FULL SIM using the GFlash parameterization.",
                            action="store_true",
                            default=defaultOptions.gflash,
                            dest="gflash")

expertSettings.add_argument("--python_filename",
                            help="Change the name of the created config file",
                            default='',
                            type=str,
                            dest="python_filename")

expertSettings.add_argument("--secondfilein",
                            help="The secondary infile name."+\
                                "for the two-file solution. Default is no file",
                            default="", #to be changed in the default form later
                            type=str,
                            dest="secondfilein")

expertSettings.add_argument("--processName",
                            help="set process name explicitly",
                            default = None,
                            type=str,
                            dest="name")

expertSettings.add_argument("--triggerResultsProcess",
                            help="for splitting jobs specify from which process to take edm::TriggerResults",
                            default = None,
                            type=str,
                            dest="triggerResultsProcess")

expertSettings.add_argument("--hltProcess",
                            help="modify the DQM sequence to look for HLT trigger results with the specified process name",
                            default = None,
                            type=str,
                            dest="hltProcess")

expertSettings.add_argument("--scenario",
                            help="Select scenario overriding standard settings",
                            default='pp',
                            type=str,
                            dest="scenario",
                            choices=defaultOptions.scenarioOptions)

expertSettings.add_argument("--harvesting",
                            help="What harvesting to use (from Configuration/StandardSequences)",
                            default=defaultOptions.harvesting,
                            type=str,
                            dest="harvesting")

expertSettings.add_argument("--particle_table",
                            help="Which particle properties table is loaded",
                            default=defaultOptions.particleTable,
                            type=str,
                            dest="particleTable")

expertSettings.add_argument("--dasquery",
                            help="Allow to define the source.fileNames from the das search command",
                            default='',
                            type=str,
                            dest="dasquery")

expertSettings.add_argument("--dasoption",
                            help="Additional option for DAS query",
                            default='',
                            type=str,
                            dest="dasoption")

expertSettings.add_argument("--dbsquery",
                            help="Deprecated. Please use dasquery option. Functions for backward compatibility",
                            default='',
                            type=str,
                            dest="dasquery")

expertSettings.add_argument("--lazy_download",
                            help="Enable lazy downloading of input files",
                            action="store_true",
                            default=False,
                            dest="lazy_download")

expertSettings.add_argument("--repacked",
                            help="When the input file is a file with repacked raw data with label rawDataRepacker",
                            action="store_true",
                            default=False,
                            dest="isRepacked")

expertSettings.add_argument("--custom_conditions",
                            help="Allow to give a few overriding tags for the GT",
                            default='',
                            type=str,
                            dest='custom_conditions')

expertSettings.add_argument("--inline_eventcontent",
                            help="expand event content definitions",
                            action="store_true",
                            default=False,
                            dest="inlineEventContent")

expertSettings.add_argument("--inline_object",
                            help="expand explicitly the definition of a list of objects",
                            default='',
                            type=str,
                            dest="inlineObjects")

expertSettings.add_argument("--hideGen",
                            help="do not inline the generator information, just load it",
                            default=False,
                            action="store_true")

expertSettings.add_argument("--output",
                            help="specify the list of output modules using dict",
                            default='',
                            type=str,
                            dest="outputDefinition")

expertSettings.add_argument("--inputCommands",
                            help="specify the input commands; i.e dropping products",
                            default=None,
                            type=str,
                            dest="inputCommands")

expertSettings.add_argument("--outputCommands",
                            help="specify the extra output commands;",
                            default=None,
                            type=str,
                            dest="outputCommands")

expertSettings.add_argument("--inputEventContent",
                            help="specify the input event content",
                            default=defaultOptions.inputEventContent,
                            type=str,
                            dest="inputEventContent")

expertSettings.add_argument("--dropDescendant",
                            help="allow to drop descendant on input",
                            default=defaultOptions.dropDescendant,
                            action="store_true")

expertSettings.add_argument("--donotDropOnInput",
                            help="when using reSTEP, prevent the automatic product dropping on input",
                            default=defaultOptions.donotDropOnInput,
                            type=str)

# specifying '--restoreRNDSeeds' results in 'options.restoreRNDSeeds = True'
# specifying '--restoreRNDSeeds arg' results in 'options.restoreRNDSeeds = arg'
expertSettings.add_argument("--restoreRNDSeeds",
                            help="restore the random number engine state",
                            default=False,
                            const=True,
                            type=str,
                            nargs='?')

expertSettings.add_argument("--era",
                            help="Specify which era to use (e.g. \"run2\")",
                            default=None,
                            type=str,
                            dest="era")

expertSettings.add_argument("--procModifiers",
                            help="Specify any process Modifiers to include (in Configuration/ProcessModiers) - comma separated list",
                            default=[],
                            action="append",
                            type=str,
                            dest="procModifiers")

expertSettings.add_argument("--evt_type",
                            help="specify the gen fragment",
                            default=None,
                            type=str,
                            dest="evt_type")

expertSettings.add_argument("--profile",
                            help="add the IgprofService with the parameter provided PROFILER:START:STEP:PEREVENOUTPUTFORMAT:ENDOFJOBOUTPUTFORMAT",
                            default=None,
                            type=str,
                            dest="profile")

expertSettings.add_argument("--heap_profile",
                            help="add the JeProfService with the parameter provided PROFILER:START:STEP:PEREVENOUTPUTFORMAT:ENDOFJOBOUTPUTFORMAT",
                            default=False,
                            action="store_true",
                            dest="heap_profile")

expertSettings.add_argument("--maxmem_profile",
                            help="add the PerfTools/MaxMemoryPreload monitor",
                            default=False,
                            action="store_true",
                            dest="maxmem_profile")

expertSettings.add_argument("--io",
                            help="Create a json file with io informations",
                            default=None,
                            type=str,
                            dest="io")

expertSettings.add_argument("--lumiToProcess",
                            help="specify a certification json file in input to run on certified data",
                            default=None,
                            type=str,
                            dest='lumiToProcess')

expertSettings.add_argument("--timeoutOutput",
                            help="use a TimeoutPoolOutputModule instead of a PoolOutputModule (needed for evt. display)",
                            default=False,
                            action="store_true",
                            dest='timeoutOutput')

expertSettings.add_argument("--nThreads",
                            help="How many threads should CMSSW use",
                            default=defaultOptions.nThreads,
                            type=int,
                            dest='nThreads')

expertSettings.add_argument("--nStreams",
                            help="How many streams should CMSSW use if nThreads > 1 (default is 0 which makes it same as nThreads)",
                            default=defaultOptions.nStreams,
                            type=int,
                            dest='nStreams')

expertSettings.add_argument("--nConcurrentLumis",
                            help="How many concurrent LuminosityBlocks should CMSSW use if nThreads > 1 (default is 0 which means 1 for 1 stream and 2 for >= 2 streams)",
                            default=defaultOptions.nConcurrentLumis,
                            type=int,
                            dest='nConcurrentLumis')

expertSettings.add_argument("--nConcurrentIOVs",
                            help="How many concurrent IOVs should CMSSW use if nThreads > 1",
                            default=defaultOptions.nConcurrentIOVs,
                            type=int,
                            dest='nConcurrentIOVs')

expertSettings.add_argument("--accelerators",
                            help="Comma-separated list of accelerators to enable; if 'cpu' is not included, the job will fail if none of the accelerators is available (default is not set, enabling all available accelerators, including the cpu)",
                            default=None,
                            type=str,
                            dest='accelerators')