9 import Configuration.Applications
10 from Configuration.Applications.ConfigBuilder
import ConfigBuilder, defaultOptions
12 from functools
import reduce
15 from FWCore.ParameterSet.Config
import Modifier, ModifierChain
16 return isinstance( era, Modifier )
or isinstance( era, ModifierChain )
26 if items[0] !=
'cmsDriver.py':
28 items.append(
'--evt_type')
29 items.append(items[1])
31 options.arguments = command
38 options.arguments = reduce(
lambda x, y: x+
' '+y, sys.argv[1:])
45 options = parser.parse_args(items)
47 if options.conditions==
"help":
48 from Configuration.AlCa
import autoCond
50 for k
in autoCond.autoCond:
51 possible+=
"\nauto:"+k+
" -> "+
str(autoCond.autoCond[k])
52 parser.error(
"Possibilities for the --conditions option: "+possible)
60 if options.triggerResultsProcess ==
None and "ALCAOUTPUT" in options.step:
61 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")
64 if not options.evt_type:
65 options.evt_type=sys.argv[1]
70 if options.dirin!=
'' and (
not options.dirin.endswith(
'/')): options.dirin+=
'/' 71 if options.dirout!=
'' and (
not options.dirout.endswith(
'/')): options.dirout+=
'/' 76 prec_step = {
"NONE":
"",
93 "RAW2DIGI":
"DIGI2RAW",
94 "RAW2RECO":
"DIGI2RAW",
103 trimmedEvtType=options.evt_type.split(
'/')[-1]
106 options.trimmedStep=[]
107 for s
in options.step.split(
','):
109 options.trimmedStep.append(step)
110 first_step=options.trimmedStep[0]
116 'ALL':
'GEN,SIM,DIGI,L1,DIGI2RAW,HLT:GRun,RAW2DIGI,RECO,POSTRECO,VALIDATION,DQM',
117 'DATA_CHAIN':
'RAW2DIGI,RECO,POSTRECO,DQM' 119 if options.step
in stepsAliases:
120 options.step=stepsAliases[options.step]
122 options.step = options.step.replace(
"SIM_CHAIN",
"GEN,SIM,DIGI,L1,DIGI2RAW")
126 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 ==
"":
128 if (
"SKIM" in options.step
and not "RECO" in options.step):
130 if (
"ENDJOB" in options.step):
132 if (
'DQMIO' in options.datatier):
135 options.step=options.step+
',ENDJOB' 139 if options.filetype==defaultOptions.filetype:
140 if options.filein.lower().endswith(
".lhe")
or options.filein.lower().endswith(
".lhef")
or options.filein.startswith(
"lhe:"):
141 options.filetype=
"LHE" 142 elif options.filein.startswith(
"mcdb:"):
143 print(
"This is a deprecated way of selecting lhe files from article number. Please use lhe:article argument to --filein")
144 options.filein=options.filein.replace(
'mcdb:',
'lhe:')
145 options.filetype=
"LHE" 147 options.filetype=
"EDM" 149 filesuffix = {
"LHE":
"lhe",
"EDM":
"root",
"MCDB":
"",
"DQM":
"root"}[options.filetype]
151 if options.filein==
"" and not (first_step
in (
"ALL",
"GEN",
"LHE",
"SIM_CHAIN")):
152 options.dirin=
"file:"+options.dirin.replace(
'file:',
'')
153 options.filein=trimmedEvtType+
"_"+prec_step[first_step]+
"."+filesuffix
158 standardFileName =
"" 159 standardFileName = trimmedEvtType+
"_"+
"_".
join(options.trimmedStep)
160 standardFileName = standardFileName.replace(
",",
"_").
replace(
".",
"_")
161 if options.pileup !=
"NoPileUp":
162 standardFileName +=
"_PU" 166 if options.fileout==
"" and not first_step
in (
"HARVESTING",
"ALCAHARVEST"):
167 options.fileout = standardFileName+
".root" 170 if not options.python_filename:
171 options.python_filename = standardFileName+
'.py' 179 if 'reSIM' in options.trimmedStep:
180 options.name =
'RESIM' 181 elif 'reDIGI' in options.trimmedStep:
182 options.name =
'REDIGI' 183 elif 'HLT' in options.trimmedStep:
185 elif 'RECO' in options.trimmedStep:
186 options.name =
'RECO' 187 elif options.trimmedStep == [
'NONE']
and options.filetype
in (
'LHE',
'MCDB'):
189 elif len(options.trimmedStep)==0:
190 options.name =
'PROCESS' 192 options.name = options.trimmedStep[-1]
198 if "HARVESTING" in options.trimmedStep
and len(options.trimmedStep) > 1:
199 raise Exception(
"The Harvesting step must be run alone")
202 if not options.isData
and not options.isMC:
203 if 'LHE' in options.trimmedStep
or 'LHE' in options.datatier:
205 if 'GEN' in options.trimmedStep
or 'GEN' in options.datatier:
207 if 'SIM' in options.trimmedStep:
209 if 'CFWRITER' in options.trimmedStep:
211 if 'DIGI' in options.trimmedStep:
213 if 'DIGI2RAW' in options.trimmedStep:
215 if (
not (options.eventcontent ==
None))
and 'SIM' in options.eventcontent:
217 if 'SIM' in options.datatier:
219 if 'VALIDATION' in options.trimmedStep:
221 if options.era
and 'Phase2' in options.era:
224 print(
'We have determined that this is simulation (if not, rerun cmsDriver.py with --data)')
226 print(
'We have determined that this is real data (if not, rerun cmsDriver.py with --mc)')
230 if options.profile
and options.prefix:
231 raise Exception(
"--profile and --prefix are incompatible")
233 profileOpts = options.profile.split(
':')
235 profilerType = profileOpts[0].
replace(
"=",
" ")
237 if profilerType ==
"pp":
238 options.profileTypeLabel =
"performance" 239 elif profilerType ==
"mp":
240 options.profileTypeLabel =
"memory" 241 elif profilerType.startswith(
"fp "):
242 options.profileTypeLabel = profilerType.replace(
"fp ",
"")
244 raise Exception(
"Not a valid profiler type %s. Alternatives are pp, mp, fp=<function>."%(profilerType))
246 options.prefix =
"igprof -t cmsRun -%s" % profilerType
248 if options.heap_profile:
250 raise Exception(
"--heap_profile and --prefix are incompatible")
251 options.prefix =
"env MALLOC_CONF=prof:true,prof_accum:true,prof_prefix:jeprof.out LD_PRELOAD=libjemalloc-prof.so " 253 if options.maxmem_profile:
255 raise Exception(
"--maxmem_profile and --prefix are incompatible")
256 options.prefix =
"env LD_PRELOAD=libPerfToolsAllocMonitorPreload.so:libPerfToolsMaxMemoryPreload.so " 260 from Configuration.StandardSequences.Eras
import eras
262 requestedEras = options.era.split(
",")
264 for eraName
in requestedEras :
265 if not hasattr( eras, eraName )
or not checkModifier(getattr(eras,eraName)):
267 for key
in eras.__dict__ :
269 if validOptions!=
"" : validOptions+=
", " 270 validOptions+=
"'"+key+
"'" 271 raise Exception(
"'%s' is not a valid option for '--era'. Valid options are %s." % (eraName, validOptions) )
275 options.era+=
",fastSim" 277 options.era=
"fastSim" 280 if options.fast
and not options.scenario ==
"pp":
281 raise Exception(
"ERROR: the --option fast is only compatible with the default scenario (--scenario=pp)")
282 if options.fast
and 'HLT' in options.trimmedStep:
283 raise Exception(
"ERROR: the --option fast is incompatible with HLT (HLT is no longer available in FastSim)")
def OptionsFromCommandLine()
def OptionsFromItems(items)
def replace(string, replacements)
def OptionsFromCommand(command)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
static std::string join(char **cmd)