5 from __future__
import print_function
10 import Configuration.Applications
11 from Configuration.Applications.ConfigBuilder
import ConfigBuilder, defaultOptions
13 from functools
import reduce
16 from FWCore.ParameterSet.Config
import Modifier, ModifierChain
17 return isinstance( era, Modifier )
or isinstance( era, ModifierChain )
27 if items[0] !=
'cmsDriver.py':
29 items.append(
'--evt_type')
30 items.append(items[1])
32 options.arguments = command
39 options.arguments = reduce(
lambda x, y: x+
' '+y, sys.argv[1:])
46 for (index,item)
in enumerate(items):
47 for (opt,value)
in threeValued:
48 if (
str(item)
in opt)
and (index==len(items)-1
or items[index+1].startswith(
'-')):
49 items.insert(index+1,value)
51 (options,args) = parser.parse_args(items)
53 if not options.conditions
or options.conditions==
"help":
54 from Configuration.AlCa
import autoCond
56 for k
in autoCond.autoCond:
57 possible+=
"\nauto:"+k+
" -> "+
str(autoCond.autoCond[k])
58 raise Exception(
"the --conditions option is mandatory. Possibilities are: "+possible)
66 if options.triggerResultsProcess ==
None and "ALCAOUTPUT" in options.step:
67 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")
70 if not options.evt_type:
71 options.evt_type=sys.argv[1]
76 if options.dirin!=
'' and (
not options.dirin.endswith(
'/')): options.dirin+=
'/' 77 if options.dirout!=
'' and (
not options.dirout.endswith(
'/')): options.dirout+=
'/' 82 prec_step = {
"NONE":
"",
99 "RAW2DIGI":
"DIGI2RAW",
100 "RAW2RECO":
"DIGI2RAW",
102 "DIGI2RAW":
"DATAMIX",
104 "ALCAHARVEST":
"RECO",
109 trimmedEvtType=options.evt_type.split(
'/')[-1]
112 options.trimmedStep=[]
113 for s
in options.step.split(
','):
115 options.trimmedStep.append(step)
116 first_step=options.trimmedStep[0]
122 'ALL':
'GEN,SIM,DIGI,L1,DIGI2RAW,HLT:GRun,RAW2DIGI,RECO,POSTRECO,VALIDATION,DQM',
123 'DATA_CHAIN':
'RAW2DIGI,RECO,POSTRECO,DQM' 125 if options.step
in stepsAliases:
126 options.step=stepsAliases[options.step]
128 options.step = options.step.replace(
"SIM_CHAIN",
"GEN,SIM,DIGI,L1,DIGI2RAW")
132 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 ==
"":
134 if (
"SKIM" in options.step
and not "RECO" in options.step):
136 if (
"ENDJOB" in options.step):
138 if (
'DQMIO' in options.datatier):
141 options.step=options.step+
',ENDJOB' 145 if options.filetype==defaultOptions.filetype:
146 if options.filein.lower().endswith(
".lhe")
or options.filein.lower().endswith(
".lhef")
or options.filein.startswith(
"lhe:"):
147 options.filetype=
"LHE" 148 elif options.filein.startswith(
"mcdb:"):
149 print(
"This is a deprecated way of selecting lhe files from article number. Please use lhe:article argument to --filein")
150 options.filein=options.filein.replace(
'mcdb:',
'lhe:')
151 options.filetype=
"LHE" 153 options.filetype=
"EDM" 155 filesuffix = {
"LHE":
"lhe",
"EDM":
"root",
"MCDB":
"",
"DQM":
"root"}[options.filetype]
157 if options.filein==
"" and not (first_step
in (
"ALL",
"GEN",
"LHE",
"SIM_CHAIN")):
158 options.dirin=
"file:"+options.dirin.replace(
'file:',
'')
159 options.filein=trimmedEvtType+
"_"+prec_step[first_step]+
"."+filesuffix
164 standardFileName =
"" 165 standardFileName = trimmedEvtType+
"_"+
"_".
join(options.trimmedStep)
166 standardFileName = standardFileName.replace(
",",
"_").
replace(
".",
"_")
167 if options.pileup !=
"NoPileUp":
168 standardFileName +=
"_PU" 172 if options.fileout==
"" and not first_step
in (
"HARVESTING",
"ALCAHARVEST"):
173 options.fileout = standardFileName+
".root" 176 if not options.python_filename:
177 options.python_filename = standardFileName+
'.py' 185 if 'reSIM' in options.trimmedStep:
186 options.name =
'RESIM' 187 elif 'reDIGI' in options.trimmedStep:
188 options.name =
'REDIGI' 189 elif 'HLT' in options.trimmedStep:
191 elif 'RECO' in options.trimmedStep:
192 options.name =
'RECO' 193 elif options.trimmedStep == [
'NONE']
and options.filetype
in (
'LHE',
'MCDB'):
195 elif len(options.trimmedStep)==0:
196 options.name =
'PROCESS' 198 options.name = options.trimmedStep[-1]
204 if "HARVESTING" in options.trimmedStep
and len(options.trimmedStep) > 1:
205 raise Exception(
"The Harvesting step must be run alone")
208 if not options.isData
and not options.isMC:
209 if 'LHE' in options.trimmedStep
or 'LHE' in options.datatier:
211 if 'GEN' in options.trimmedStep
or 'GEN' in options.datatier:
213 if 'SIM' in options.trimmedStep:
215 if 'CFWRITER' in options.trimmedStep:
217 if 'DIGI' in options.trimmedStep:
219 if 'DIGI2RAW' in options.trimmedStep:
221 if (
not (options.eventcontent ==
None))
and 'SIM' in options.eventcontent:
223 if 'SIM' in options.datatier:
225 if 'VALIDATION' in options.trimmedStep:
227 if options.era
and 'Phase2' in options.era:
230 print(
'We have determined that this is simulation (if not, rerun cmsDriver.py with --data)')
232 print(
'We have determined that this is real data (if not, rerun cmsDriver.py with --mc)')
236 if options.profile
and options.prefix:
237 raise Exception(
"--profile and --prefix are incompatible")
239 profileOpts = options.profile.split(
':')
241 profilerType = profileOpts[0].
replace(
"=",
" ")
243 if profilerType ==
"pp":
244 options.profileTypeLabel =
"performance" 245 elif profilerType ==
"mp":
246 options.profileTypeLabel =
"memory" 247 elif profilerType.startswith(
"fp "):
248 options.profileTypeLabel = profilerType.replace(
"fp ",
"")
250 raise Exception(
"Not a valid profiler type %s. Alternatives are pp, mp, fp=<function>."%(profilerType))
252 options.prefix =
"igprof -t cmsRun -%s" % profilerType
256 from Configuration.StandardSequences.Eras
import eras
258 requestedEras = options.era.split(
",")
260 for eraName
in requestedEras :
261 if not hasattr( eras, eraName )
or not checkModifier(getattr(eras,eraName)):
263 for key
in eras.__dict__ :
265 if validOptions!=
"" : validOptions+=
", " 266 validOptions+=
"'"+key+
"'" 267 raise Exception(
"'%s' is not a valid option for '--era'. Valid options are %s." % (eraName, validOptions) )
271 options.era+=
",fastSim" 273 options.era=
"fastSim" 276 if options.fast
and not options.scenario ==
"pp":
277 raise Exception(
"ERROR: the --option fast is only compatible with the default scenario (--scenario=pp)")
278 if options.fast
and 'HLT' in options.trimmedStep:
279 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)