00001
00002
00003
00004
00005 import optparse
00006 import sys
00007 import os
00008 import re
00009 import Configuration.PyReleaseValidation
00010 from Configuration.PyReleaseValidation.ConfigBuilder import ConfigBuilder, defaultOptions
00011 import traceback
00012
00013 usage=\
00014 """%prog <TYPE> [options].
00015 Example:
00016
00017 %prog reco -s RAW2DIGI,RECO --conditions STARTUP_V4::All --eventcontent RECOSIM
00018 """
00019 parser = optparse.OptionParser(usage)
00020
00021 expertSettings = optparse.OptionGroup(parser, '===============\n Expert Options', 'Caution: please use only if you know what you are doing.')
00022 famosSettings = optparse.OptionGroup(parser, '===============\n FastSimulation options', '')
00023 parser.add_option_group(expertSettings)
00024
00025 parser.add_option("-s", "--step",
00026 help="The desired step. The possible values are: "+\
00027 "GEN,SIM,DIGI,L1,DIGI2RAW,HLT,RAW2DIGI,RECO,POSTRECO,DQM,ALCA,VALIDATION,HARVESTING, NONE or ALL.",
00028 default="ALL",
00029 dest="step")
00030
00031 parser.add_option("--conditions",
00032 help="What conditions to use. This has to be specified",
00033 default=None,
00034 dest="conditions")
00035
00036 parser.add_option("--eventcontent",
00037 help="What event content to write out. Default=FEVTDEBUG, or FEVT (for cosmics)",
00038 default='RECOSIM',
00039 dest="eventcontent")
00040
00041 parser.add_option("--filein",
00042 help="The infile name.",
00043 default="",
00044 dest="filein")
00045
00046 parser.add_option("--fileout",
00047 help="The outfile name. If absent a default value is assigned",
00048 default="",
00049 dest="fileout")
00050
00051 parser.add_option("--filetype",
00052 help="The type of the infile (EDM, LHE or MCDB).",
00053 default="",
00054 dest="filetype")
00055
00056 parser.add_option("-n", "--number",
00057 help="The number of events. The default is 1.",
00058 default="1",
00059 dest="number")
00060
00061 parser.add_option("--mc",
00062 help="Specify that simulation is to be processed (default = guess based on options",
00063 action="store_true",
00064 default=False,
00065 dest="isMC")
00066
00067 parser.add_option("--data",
00068 help="Specify that data is to be processed (default = guess based on options",
00069 action="store_true",
00070 default=False,
00071 dest="isData")
00072
00073
00074 parser.add_option("--no_exec",
00075 help="Do not exec cmsRun. Just prepare the python config file.",
00076 action="store_true",
00077 default=False,
00078 dest="no_exec_flag")
00079
00080
00081 expertSettings.add_option("--beamspot",
00082 help="What beam spot to use (from Configuration/StandardSequences). Default depends on scenario",
00083 default=defaultOptions.beamspot,
00084 dest="beamspot")
00085
00086 expertSettings.add_option("--customise",
00087 help="Specify the file where the code to modify the process object is stored.",
00088 default="",
00089 dest="customisation_file")
00090
00091 expertSettings.add_option("--inline_custom",
00092 help="inline the customisation file",
00093 default=False,
00094 dest="inline_custom")
00095
00096 expertSettings.add_option("--datatier",
00097 help="What data tier to use.",
00098 default='',
00099 dest="datatier")
00100
00101 expertSettings.add_option( "--dirin",
00102 help="The infile directory.",
00103 default="",
00104 dest="dirin")
00105
00106 expertSettings.add_option( "--dirout",
00107 help="The outfile directory.",
00108 default="",
00109 dest="dirout")
00110
00111 expertSettings.add_option("--filtername",
00112 help="What filter name to specify in output module",
00113 default="",
00114 dest="filtername")
00115
00116 expertSettings.add_option("--geometry",
00117 help="What geometry to use (from Configuration/StandardSequences). Default=Ideal",
00118 default=defaultOptions.geometry,
00119 dest="geometry")
00120
00121 expertSettings.add_option("--magField",
00122 help="What magnetic field to use (from Configuration/StandardSequences).",
00123 default=defaultOptions.magField,
00124 dest="magField")
00125
00126 expertSettings.add_option("--no_output",
00127 help="Do not write anything to disk. This is for "+\
00128 "benchmarking purposes.",
00129 action="store_true",
00130 default=False,
00131 dest="no_output_flag")
00132
00133 expertSettings.add_option("--oneoutput",
00134 help="use only one output module",
00135 action="store_true",
00136 default="False",
00137 dest="oneoutput")
00138
00139 expertSettings.add_option("--prefix",
00140 help="Specify a prefix to the cmsRun command.",
00141 default="",
00142 dest="prefix")
00143
00144 expertSettings.add_option("--relval",
00145 help="Set total number of events and events per job.",
00146 default="",
00147 dest="relval")
00148
00149 expertSettings.add_option("--dump_python",
00150 help="Dump the config file in python "+\
00151 "and do a full expansion of imports.",
00152 action="store_true",
00153 default=False,
00154 dest="dump_python")
00155
00156 expertSettings.add_option("--dump_DSetName",
00157 help="Dump the primary datasetname.",
00158 action="store_true",
00159 default=False,
00160 dest="dump_dsetname_flag")
00161
00162 expertSettings.add_option("--pileup",
00163 help="What pileup config to use. Default=NoPileUp.",
00164 default=defaultOptions.pileup,
00165 dest="pileup")
00166
00167 expertSettings.add_option("--pileup_input",
00168 help="define the pile up files to mix with",
00169 default=None,
00170 dest="pileup_input")
00171
00172 expertSettings.add_option("--datamix",
00173 help="What datamix config to use. Default=DataOnSim.",
00174 default=defaultOptions.datamix,
00175 dest="datamix")
00176
00177 expertSettings.add_option("--gflash",
00178 help="Run the FULL SIM using the GFlash parameterization.",
00179 action="store_true",
00180 default=defaultOptions.gflash,
00181 dest="gflash")
00182
00183 expertSettings.add_option("--himix",
00184 help="Run the Heavy Ions signal mixing.",
00185 action="store_true",
00186 default=defaultOptions.himix,
00187 dest="himix")
00188
00189 expertSettings.add_option("--python_filename",
00190 help="Change the name of the created config file ",
00191 default='',
00192 dest="python_filename")
00193
00194 expertSettings.add_option("--secondfilein",
00195 help="The secondary infile name."+\
00196 "for the two-file solution. Default is no file",
00197 default="",
00198 dest="secondfilein")
00199
00200 expertSettings.add_option("--writeraw",
00201 help="In addition to the nominal output, write a file with just raw",
00202 action="store_true",
00203 default=False,
00204 dest="writeraw")
00205
00206 expertSettings.add_option("--processName",
00207 help="set process name explicitly",
00208 default = None,
00209 dest="name"
00210 )
00211
00212 expertSettings.add_option("--triggerResultsProcess",
00213 help="for splitting jobs specify from which process to take edm::TriggerResults",
00214 default = None,
00215 dest="triggerResultsProcess"
00216 )
00217
00218 expertSettings.add_option("--hltProcess",
00219 help="modify the DQM sequence to look for HLT trigger results with the specified process name",
00220 default = None,
00221 dest="hltProcess"
00222 )
00223
00224 expertSettings.add_option("--scenario",
00225 help="Select scenario overriding standard settings (available:"+str(defaultOptions.scenarioOptions)+")",
00226 default='pp',
00227 dest="scenario")
00228
00229 expertSettings.add_option("--harvesting",
00230 help="What harvesting to use (from Configuration/StandardSequences). Default=AtRunEnd",
00231 default=defaultOptions.harvesting,
00232 dest="harvesting")
00233
00234 expertSettings.add_option("--particle_table",
00235 help="Which particle properties table is loaded. Default=pythia",
00236 default=defaultOptions.particleTable,
00237 dest="particleTable")
00238
00239 expertSettings.add_option("--dbsquery",
00240 help="Allow to define the source.fileNames from the dbs search command",
00241 default='',
00242 dest="dbsquery")
00243
00244 expertSettings.add_option("--lazy_download",
00245 help="Enable lazy downloading of input files",
00246 action="store_true",
00247 default=False,
00248 dest="lazy_download")
00249
00250 expertSettings.add_option("--repacked",
00251 help="When the input file is a file with repacked raw data with label rawDataRepacker",
00252 action="store_true",
00253 default=False,
00254 dest="isRepacked"
00255 )
00256
00257 expertSettings.add_option("--custom_conditions",
00258 help="Allow to give a few overriding tags for the GT",
00259 default='',
00260 dest='custom_conditions')
00261
00262 expertSettings.add_option("--inline_eventcontent",
00263 help="expand event content definitions",
00264 action="store_true",
00265 default=False,
00266 dest="inlineEventContent")
00267
00268
00269 expertSettings.add_option("--inline_object",
00270 help="expand explicitely the definition of a list of objects",
00271 default='',
00272 dest="inlineObjets")
00273
00274 expertSettings.add_option("--hideGen",
00275 help="do not inline the generator information, just load it",
00276 default=False,
00277 action="store_true")
00278 expertSettings.add_option("--output",
00279 help="specify the list of output modules using dict",
00280 default='',
00281 dest="outputDefinition")
00282
00283 expertSettings.add_option("--inputCommands",
00284 help="specify the input commands; i.e dropping products",
00285 default=None,
00286 dest="inputCommands")
00287
00288 expertSettings.add_option("--inputEventContent",
00289 help="specify the input event content",
00290 default=None,
00291 dest="inputEventContent")
00292 expertSettings.add_option("--slhc",
00293 help="Specify the SLHC scenario version",
00294 default=None,
00295 dest="slhc")
00296
00297 (options,args) = parser.parse_args()
00298
00299
00300
00301
00302
00303
00304 if len(sys.argv)==1:
00305 raise "Event Type: ", "No event type specified!"
00306
00307
00308 if options.triggerResultsProcess == None and "ALCAOUTPUT" in options.step:
00309 print "ERROR: If ALCA splitting is requested, the name of the process in which the alca producers ran needs to be specified. E.g. via --triggerResultsProcess RECO"
00310 sys.exit(1)
00311
00312
00313 options.evt_type=sys.argv[1]
00314
00315
00316 options.arguments = reduce(lambda x, y: x+' '+y, sys.argv[1:])
00317
00318
00319
00320
00321
00322
00323
00324
00325 prec_step = {"NONE":"",
00326 "ALL":"",
00327 "GEN":"",
00328 "SIM":"GEN",
00329 "DIGI":"SIM",
00330 "HLT":"RAW",
00331 "RECO":"DIGI",
00332 "ALCA":"RECO",
00333 "ANA":"RECO",
00334 "SKIM":"RECO",
00335 "DIGI2RAW":"DIGI",
00336 "RAW2DIGI":"DIGI2RAW",
00337 "RAW2RECO":"DIGI2RAW",
00338 "DATAMIX":"DIGI",
00339 "DIGI2RAW":"DATAMIX",
00340 "HARVESTING":"RECO",
00341 "ALCAHARVEST":"RECO"}
00342
00343 trimmedEvtType=options.evt_type.split('/')[-1]
00344
00345 trimmedStep=''
00346 isFirst=0
00347 step_list=options.step.split(',')
00348 for s in step_list:
00349 stepSP=s.split(':')
00350 step=stepSP[0]
00351 if ( isFirst==0 ):
00352 trimmedStep=step
00353 isFirst=1
00354 else:
00355 trimmedStep=trimmedStep+','+step
00356
00357
00358 if options.filetype=="":
00359 if options.filein.lower().endswith(".lhe") or options.filein.lower().endswith(".lhef"):
00360 options.filetype="LHE"
00361 elif options.filein.startswith("mcdb:"):
00362 options.filetype="MCDB"
00363 else:
00364 options.filetype="EDM"
00365 if options.filetype=="MCDB" and options.filein.startswith("mcdb:"):
00366 options.filein = options.filein[5:]
00367
00368 filesuffix = {"LHE": "lhe", "EDM": "root", "MCDB": ""}[options.filetype]
00369
00370 first_step=trimmedStep.split(',')[0]
00371 if options.filein=="" and not (first_step in ("ALL","GEN","SIM_CHAIN") and options.dirin == ""):
00372 if options.dirin=="":
00373 options.dirin="file:"
00374 options.filein=trimmedEvtType+"_"+prec_step[first_step]+"."+filesuffix
00375
00376
00377
00378
00379 standardFileName = ""
00380 standardFileName = trimmedEvtType+"_"+trimmedStep
00381 standardFileName = standardFileName.replace(",","_").replace(".","_")
00382 if options.pileup != "NoPileUp":
00383 standardFileName += "_PU"
00384
00385
00386
00387 if options.fileout=="" and not first_step in ("HARVESTING", "ALCAHARVEST"):
00388 options.fileout = standardFileName+".root"
00389
00390
00391
00392 python_config_filename = standardFileName
00393
00394
00395 conditionsSP = options.conditions.split(',')
00396 if len(conditionsSP) > 1:
00397
00398 conditionsType = conditionsSP[1].split("_")[0]
00399 python_config_filename += "_"+str(conditionsType)
00400
00401 python_config_filename+=".py"
00402
00403
00404
00405 fileraw=''
00406 if options.writeraw:
00407 fileraw=options.dirout
00408 wrSP=options.fileout.split('.')
00409 wrSPLen=len(wrSP)
00410 counter=0
00411 for w in wrSP:
00412 counter=counter+1
00413 if ( counter < wrSPLen ):
00414 if ( counter == 1):
00415 fileraw=fileraw+w
00416 else:
00417 fileraw=fileraw+'.'+w
00418 else:
00419 fileraw=fileraw+'_rawonly.'+w
00420
00421
00422
00423 secondfilestr=''
00424 if options.secondfilein!='':
00425 secondfilestr=options.dirin+options.secondfilein
00426
00427
00428
00429 if options.step=='NONE':
00430 options.step=''
00431 elif options.step=='ALL':
00432 options.step='GEN,SIM,DIGI,L1,DIGI2RAW,RAW2DIGI,RECO,POSTRECO,VALIDATION,DQM'
00433 elif options.step=='DATA_CHAIN':
00434 options.step='RAW2DIGI,RECO,POSTRECO,DQM'
00435 options.step = options.step.replace("SIM_CHAIN","GEN,SIM,DIGI,L1,DIGI2RAW")
00436
00437
00438
00439
00440 addEndJob = True
00441 if ("FASTSIM" in options.step and not "VALIDATION" in options.step) or "HARVESTING" in options.step or "ALCAHARVEST" in options.step or "ALCAOUTPUT" in options.step or options.step == "":
00442 addEndJob = False
00443 if ("SKIM" in options.step and not "RECO" in options.step):
00444 addEndJob = False
00445 if ("ENDJOB" in options.step):
00446 addEndJob = False
00447 if addEndJob:
00448 options.step=options.step+',ENDJOB'
00449 print options.step
00450
00451
00452
00453
00454 if not options.name:
00455 if 'HLT' in trimmedStep:
00456 options.name = 'HLT'
00457 elif 'RECO' in trimmedStep:
00458 options.name = 'RECO'
00459 elif trimmedStep == 'NONE' and options.filetype in ('LHE', 'MCDB'):
00460 options.name = 'LHE'
00461 else:
00462 options.name = trimmedStep.split(',')[-1]
00463
00464
00465 isHarvesting = False
00466 isOther = False
00467
00468 s_list=options.step.split(',')
00469 if "HARVESTING" in options.step and len(s_list) > 1:
00470 print "The Harvesting step must be run alone"
00471 sys.exit(1)
00472
00473
00474 if not options.isData and not options.isMC:
00475 if 'SIM' in trimmedStep:
00476 options.isMC=True
00477 if 'CFWRITER' in trimmedStep:
00478 options.isMC=True
00479 if 'DIGI' in trimmedStep:
00480 options.isMC=True
00481 if (not (options.eventcontent == None)) and 'SIM' in options.eventcontent:
00482 options.isMC=True
00483 if 'SIM' in options.datatier:
00484 options.isMC=True
00485 if options.isMC:
00486 print 'We have determined that this is simulation (if not, rerun cmsDriver.py with --data)'
00487 else:
00488 print 'We have determined that this is real data (if not, rerun cmsDriver.py with --mc)'
00489
00490