Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-03-27 03:36:29

0001 #! /usr/bin/env python3
0002 
0003 # A Pyrelval Wrapper
0004 
0005 from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
0006 import sys
0007 import os
0008 import re
0009 import Configuration.Applications
0010 from Configuration.Applications.ConfigBuilder import ConfigBuilder, defaultOptions
0011 import traceback
0012 # Prepare a parser to read the options
0013 usage=\
0014 """%(prog)s <TYPE> [options].
0015 Example:
0016 
0017 %(prog)s reco -s RAW2DIGI,RECO --conditions STARTUP_V4::All --eventcontent RECOSIM
0018 """
0019 parser = ArgumentParser(usage=usage, formatter_class=ArgumentDefaultsHelpFormatter)
0020 
0021 expertSettings = parser.add_argument_group('===============\n  Expert Options', 'Caution: please use only if you know what you are doing.')
0022 
0023 parser.add_argument("evt_type", metavar="TYPE", nargs='?', type=str)
0024 parser.add_argument("-s", "--step",
0025                     help="The desired step. The possible values are: "+\
0026                          "GEN,SIM,DIGI,L1,DIGI2RAW,HLT,RAW2DIGI,RECO,POSTRECO,DQM,ALCA,VALIDATION,HARVESTING, NONE or ALL.",
0027                     default="ALL",
0028                     type=str,
0029                     dest="step")
0030 
0031 parser.add_argument("--conditions",
0032                     help="What conditions to use (required; provide value 'help' to get list of options)",
0033                     required=True,
0034                     type=str,
0035                     dest="conditions")
0036 
0037 parser.add_argument("--eventcontent",
0038                     help="What event content to write out",
0039                     default='RECOSIM',
0040                     type=str,
0041                     dest="eventcontent")
0042 
0043 parser.add_argument("--filein",
0044                     help="The infile name.",
0045                     default="", #to be changed in the default form later
0046                     type=str,
0047                     dest="filein")
0048 
0049 parser.add_argument("--fileout",
0050                     help="The outfile name. If absent a default value is assigned",
0051                     default="", #to be changed in the default form later
0052                     type=str,
0053                     dest="fileout")
0054 
0055 parser.add_argument("--rntuple_out",
0056                     help="If possible, use RNTuple format for output.",
0057                     action="store_true",
0058                     default=defaultOptions.rntuple_out,
0059                     dest="rntuple_out")
0060 
0061 parser.add_argument("--filetype",
0062                     help="The type of the infile",
0063                     default=defaultOptions.filetype,
0064                     type=str,
0065                     dest="filetype",
0066                     choices=['EDM','DAT','LHE','MDCB','DQM','DQMDAQ', 'EDM_RNTUPLE']
0067                   )
0068 
0069 parser.add_argument("-n", "--number",
0070                     help="The number of events.",
0071                     default=1,
0072                     type=int,
0073                     dest="number")
0074 
0075 parser.add_argument("-o", "--number_out",
0076                     help="The number of events in output.",
0077                     default=None,
0078                     type=int,
0079                     dest="number_out")
0080 
0081 parser.add_argument("--mc",
0082                     help="Specify that simulation is to be processed (default = guess based on options)",
0083                     action="store_true",
0084                     default=False,
0085                     dest="isMC")
0086 
0087 parser.add_argument("--data",
0088                     help="Specify that data is to be processed (default = guess based on options)",
0089                     action="store_true",
0090                     default=False,
0091                     dest="isData")
0092 
0093 parser.add_argument("--no_exec",
0094                     help="Do not exec cmsRun. Just prepare the python config file.",
0095                     action="store_true",
0096                     default=False,
0097                     dest="no_exec_flag")
0098 
0099 parser.add_argument("--fast",
0100                     help="Specify that the configuration is for FASTSIM",
0101                     action="store_true",
0102                     default=False)
0103 
0104 parser.add_argument("--runsAndWeightsForMC",
0105                     help="Assign run numbers to MC source according to relative weights. [(run1,weight1),...,(runN,weightN)])",
0106                     default=None,
0107                     dest="runsAndWeightsForMC")
0108 
0109 parser.add_argument("--runsScenarioForMC",
0110                     help="Load a scenario to set run numbers in MC.)",
0111                     default=None,
0112                     dest="runsScenarioForMC")
0113 
0114 parser.add_argument("--runsAndWeightsForMCIntegerWeights",
0115                     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)])",
0116                     default=None,
0117                     dest="runsAndWeightsForMCIntegerWeights")
0118 
0119 parser.add_argument("--runsScenarioForMCIntegerWeights",
0120                     help="Load a scenario to set run numbers in MC with integer IOV weights.",
0121                     default=None,
0122                     dest="runsScenarioForMCIntegerWeights")
0123 
0124 parser.add_argument("--runUnscheduled",
0125                     help="Automatically convert configuration to run unscheduled the EDProducers/EDFilters that were scheduled",
0126                     action="store_true",
0127                     default=False,
0128                     dest="runUnscheduled")
0129 
0130 # expert settings
0131 expertSettings.add_argument("--beamspot",
0132                             help="What beam spot to use (from Configuration/StandardSequences). Default depends on scenario",
0133                             default=None,
0134                             type=str,
0135                             dest="beamspot")
0136 
0137 expertSettings.add_argument("--customise",
0138                             help="Specify the file where the code to modify the process object is stored.",
0139                             default=[],
0140                             action="append",
0141                             type=str,
0142                             dest="customisation_file")
0143 
0144 expertSettings.add_argument("--customise_unsch",
0145                             help="Specify the file where the code to modify the process object is stored.",
0146                             default=[],
0147                             action="append",
0148                             type=str,
0149                             dest="customisation_file_unsch")
0150 
0151 expertSettings.add_argument("--customise_commands",
0152                             help="Specify a string of commands",
0153                             default="",
0154                             type=str,
0155                             dest="customise_commands")
0156 
0157 expertSettings.add_argument("--inline_custom",
0158                             help="inline the customisation file",
0159                             default=False,
0160                             action="store_true",
0161                             dest="inline_custom")
0162 
0163 expertSettings.add_argument("--datatier",
0164                             help="What data tier to use.",
0165                             default='',
0166                             type=str,
0167                             dest="datatier")
0168 
0169 expertSettings.add_argument( "--dirin",
0170                             help="The infile directory.",
0171                             default="",
0172                             type=str,
0173                             dest="dirin")
0174 
0175 expertSettings.add_argument( "--dirout",
0176                             help="The outfile directory.",
0177                             default="",
0178                             type=str,
0179                             dest="dirout")
0180 
0181 expertSettings.add_argument("--filtername",
0182                             help="What filter name to specify in output module",
0183                             default="",
0184                             type=str,
0185                             dest="filtername")
0186 
0187 expertSettings.add_argument("--geometry",
0188                             help="What simulation geometry to use. Comma-separated SimGeometry,RecoGeometry is supported.",
0189                             default=defaultOptions.geometry,
0190                             type=str,
0191                             dest="geometry")
0192 
0193 expertSettings.add_argument("--magField",
0194                             help="What magnetic field to use (from Configuration/StandardSequences).",
0195                             default=defaultOptions.magField,
0196                             type=str,
0197                             dest="magField")
0198 
0199 expertSettings.add_argument("--no_output",
0200                             help="Do not write anything to disk. This is for "+\
0201                             "benchmarking purposes.",
0202                             action="store_true",
0203                             default=False,
0204                             dest="no_output_flag")
0205 
0206 expertSettings.add_argument("--prefix",
0207                             help="Specify a prefix to the cmsRun command.",
0208                             default="",
0209                             type=str,
0210                             dest="prefix")
0211 
0212 expertSettings.add_argument("--suffix",
0213                             help="Specify a suffix to the cmsRun command.",
0214                             default="",
0215                             type=str,
0216                             dest="suffix")
0217 
0218 expertSettings.add_argument("--relval",
0219                             help="Set total number of events and events per job.", #this does not get used but get parsed in the command by DataOps
0220                             default="",
0221                             dest="relval")
0222 
0223 expertSettings.add_argument("--dump_python",
0224                             help="Dump the config file in python "+\
0225                             "and do a full expansion of imports.",
0226                             action="store_true",
0227                             default=False,
0228                             dest="dump_python")
0229 
0230 expertSettings.add_argument("--pileup",
0231                             help="What pileup config to use",
0232                             default=defaultOptions.pileup,
0233                             type=str,
0234                             dest="pileup")
0235     
0236 expertSettings.add_argument("--pileup_input",
0237                             help="define the pile up files to mix with",
0238                             default=None,
0239                             type=str,
0240                             dest="pileup_input")
0241 
0242 expertSettings.add_argument("--pileup_dasoption",
0243                             help="Additional option for DAS query of pile up",
0244                             default="",
0245                             type=str,
0246                             dest="pileup_dasoption")
0247 
0248 expertSettings.add_argument("--datamix",
0249                             help="What datamix config to use",
0250                             default=defaultOptions.datamix,
0251                             type=str,
0252                             dest="datamix")
0253 
0254 expertSettings.add_argument("--gflash",
0255                             help="Run the FULL SIM using the GFlash parameterization.",
0256                             action="store_true",
0257                             default=defaultOptions.gflash,
0258                             dest="gflash")
0259 
0260 expertSettings.add_argument("--python_filename",
0261                             help="Change the name of the created config file",
0262                             default='',
0263                             type=str,
0264                             dest="python_filename")
0265 
0266 expertSettings.add_argument("--secondfilein",
0267                             help="The secondary infile name."+\
0268                                 "for the two-file solution. Default is no file",
0269                             default="", #to be changed in the default form later
0270                             type=str,
0271                             dest="secondfilein")
0272 
0273 expertSettings.add_argument("--processName",
0274                             help="set process name explicitly",
0275                             default = None,
0276                             type=str,
0277                             dest="name")
0278 
0279 expertSettings.add_argument("--triggerResultsProcess",
0280                             help="for splitting jobs specify from which process to take edm::TriggerResults",
0281                             default = None,
0282                             type=str,
0283                             dest="triggerResultsProcess")
0284 
0285 expertSettings.add_argument("--hltProcess",
0286                             help="modify the DQM sequence to look for HLT trigger results with the specified process name",
0287                             default = None,
0288                             type=str,
0289                             dest="hltProcess")
0290 
0291 expertSettings.add_argument("--scenario",
0292                             help="Select scenario overriding standard settings",
0293                             default='pp',
0294                             type=str,
0295                             dest="scenario",
0296                             choices=defaultOptions.scenarioOptions)
0297 
0298 expertSettings.add_argument("--harvesting",
0299                             help="What harvesting to use (from Configuration/StandardSequences)",
0300                             default=defaultOptions.harvesting,
0301                             type=str,
0302                             dest="harvesting")
0303 
0304 expertSettings.add_argument("--particle_table",
0305                             help="Which particle properties table is loaded",
0306                             default=defaultOptions.particleTable,
0307                             type=str,
0308                             dest="particleTable")
0309 
0310 expertSettings.add_argument("--dasquery",
0311                             help="Allow to define the source.fileNames from the das search command",
0312                             default='',
0313                             type=str,
0314                             dest="dasquery")
0315 
0316 expertSettings.add_argument("--dasoption",
0317                             help="Additional option for DAS query",
0318                             default='',
0319                             type=str,
0320                             dest="dasoption")
0321 
0322 expertSettings.add_argument("--dbsquery",
0323                             help="Deprecated. Please use dasquery option. Functions for backward compatibility",
0324                             default='',
0325                             type=str,
0326                             dest="dasquery")
0327 
0328 expertSettings.add_argument("--lazy_download",
0329                             help="Enable lazy downloading of input files",
0330                             action="store_true",
0331                             default=False,
0332                             dest="lazy_download")
0333 
0334 expertSettings.add_argument("--repacked",
0335                             help="When the input file is a file with repacked raw data with label rawDataRepacker",
0336                             action="store_true",
0337                             default=False,
0338                             dest="isRepacked")
0339 
0340 expertSettings.add_argument("--custom_conditions",
0341                             help="Allow to give a few overriding tags for the GT",
0342                             default='',
0343                             type=str,
0344                             dest='custom_conditions')
0345 
0346 expertSettings.add_argument("--inline_eventcontent",
0347                             help="expand event content definitions",
0348                             action="store_true",
0349                             default=False,
0350                             dest="inlineEventContent")
0351 
0352 expertSettings.add_argument("--inline_object",
0353                             help="expand explicitly the definition of a list of objects",
0354                             default='',
0355                             type=str,
0356                             dest="inlineObjects")
0357 
0358 expertSettings.add_argument("--hideGen",
0359                             help="do not inline the generator information, just load it",
0360                             default=False,
0361                             action="store_true")
0362 
0363 expertSettings.add_argument("--output",
0364                             help="specify the list of output modules using dict",
0365                             default='',
0366                             type=str,
0367                             dest="outputDefinition")
0368 
0369 expertSettings.add_argument("--inputCommands",
0370                             help="specify the input commands; i.e dropping products",
0371                             default=None,
0372                             type=str,
0373                             dest="inputCommands")
0374 
0375 expertSettings.add_argument("--outputCommands",
0376                             help="specify the extra output commands;",
0377                             default=None,
0378                             type=str,
0379                             dest="outputCommands")
0380 
0381 expertSettings.add_argument("--inputEventContent",
0382                             help="specify the input event content",
0383                             default=defaultOptions.inputEventContent,
0384                             type=str,
0385                             dest="inputEventContent")
0386 
0387 expertSettings.add_argument("--dropDescendant",
0388                             help="allow to drop descendant on input",
0389                             default=defaultOptions.dropDescendant,
0390                             action="store_true")
0391 
0392 expertSettings.add_argument("--donotDropOnInput",
0393                             help="when using reSTEP, prevent the automatic product dropping on input",
0394                             default=defaultOptions.donotDropOnInput,
0395                             type=str)
0396 
0397 # specifying '--restoreRNDSeeds' results in 'options.restoreRNDSeeds = True'
0398 # specifying '--restoreRNDSeeds arg' results in 'options.restoreRNDSeeds = arg'
0399 expertSettings.add_argument("--restoreRNDSeeds",
0400                             help="restore the random number engine state",
0401                             default=False,
0402                             const=True,
0403                             type=str,
0404                             nargs='?')
0405 
0406 expertSettings.add_argument("--era",
0407                             help="Specify which era to use (e.g. \"run2\")",
0408                             default=None,
0409                             type=str,
0410                             dest="era")
0411 
0412 expertSettings.add_argument("--procModifiers",
0413                             help="Specify any process Modifiers to include (in Configuration/ProcessModiers) - comma separated list",
0414                             default=[],
0415                             action="append",
0416                             type=str,
0417                             dest="procModifiers")
0418 
0419 expertSettings.add_argument("--evt_type",
0420                             help="specify the gen fragment",
0421                             default=None,
0422                             type=str,
0423                             dest="evt_type")
0424 
0425 expertSettings.add_argument("--profile",
0426                             help="add the IgprofService with the parameter provided PROFILER:START:STEP:PEREVENOUTPUTFORMAT:ENDOFJOBOUTPUTFORMAT",
0427                             default=None,
0428                             type=str,
0429                             dest="profile")
0430 
0431 expertSettings.add_argument("--heap_profile",
0432                             help="add the JeProfService with the parameter provided PROFILER:START:STEP:PEREVENOUTPUTFORMAT:ENDOFJOBOUTPUTFORMAT",
0433                             default=False,
0434                             action="store_true",
0435                             dest="heap_profile")
0436 
0437 expertSettings.add_argument("--maxmem_profile",
0438                             help="add the PerfTools/MaxMemoryPreload monitor",
0439                             default=False,
0440                             action="store_true",
0441                             dest="maxmem_profile")
0442 
0443 expertSettings.add_argument("--io",
0444                             help="Create a json file with io informations",
0445                             default=None,
0446                             type=str,
0447                             dest="io")
0448 
0449 expertSettings.add_argument("--lumiToProcess",
0450                             help="specify a certification json file in input to run on certified data",
0451                             default=None,
0452                             type=str,
0453                             dest='lumiToProcess')
0454 
0455 expertSettings.add_argument("--timeoutOutput",
0456                             help="use a TimeoutPoolOutputModule instead of a PoolOutputModule (needed for evt. display)",
0457                             default=False,
0458                             action="store_true",
0459                             dest='timeoutOutput')
0460 
0461 expertSettings.add_argument("--nThreads",
0462                             help="How many threads should CMSSW use",
0463                             default=defaultOptions.nThreads,
0464                             type=int,
0465                             dest='nThreads')
0466 
0467 expertSettings.add_argument("--nStreams",
0468                             help="How many streams should CMSSW use if nThreads > 1 (default is 0 which makes it same as nThreads)",
0469                             default=defaultOptions.nStreams,
0470                             type=int,
0471                             dest='nStreams')
0472 
0473 expertSettings.add_argument("--nConcurrentLumis",
0474                             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)",
0475                             default=defaultOptions.nConcurrentLumis,
0476                             type=int,
0477                             dest='nConcurrentLumis')
0478 
0479 expertSettings.add_argument("--nConcurrentIOVs",
0480                             help="How many concurrent IOVs should CMSSW use if nThreads > 1",
0481                             default=defaultOptions.nConcurrentIOVs,
0482                             type=int,
0483                             dest='nConcurrentIOVs')
0484 
0485 expertSettings.add_argument("--accelerators",
0486                             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)",
0487                             default=None,
0488                             type=str,
0489                             dest='accelerators')