3 __version__ =
"$Revision: 1.19 $"
4 __source__ =
"$Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v $"
7 from FWCore.ParameterSet.Modules
import _Module
15 defaultOptions = Options()
16 defaultOptions.datamix =
'DataOnSim'
17 defaultOptions.isMC=
False
18 defaultOptions.isData=
True
19 defaultOptions.step=
''
20 defaultOptions.pileup=
'NoPileUp'
21 defaultOptions.pileup_input =
None
22 defaultOptions.geometry =
'SimDB'
23 defaultOptions.geometryExtendedOptions = [
'ExtendedGFlash',
'Extended',
'NoCastor']
24 defaultOptions.magField =
'38T'
25 defaultOptions.conditions =
None
26 defaultOptions.useCondDBv1 =
False
27 defaultOptions.scenarioOptions=[
'pp',
'cosmics',
'nocoll',
'HeavyIons']
28 defaultOptions.harvesting=
'AtRunEnd'
29 defaultOptions.gflash =
False
30 defaultOptions.himix =
False
31 defaultOptions.number = -1
32 defaultOptions.number_out =
None
33 defaultOptions.arguments =
""
34 defaultOptions.name =
"NO NAME GIVEN"
35 defaultOptions.evt_type =
""
36 defaultOptions.filein =
""
37 defaultOptions.dasquery=
""
38 defaultOptions.secondfilein =
""
39 defaultOptions.customisation_file = []
40 defaultOptions.customisation_file_unsch = []
41 defaultOptions.customise_commands =
""
42 defaultOptions.inline_custom=
False
43 defaultOptions.particleTable =
'pythiapdt'
44 defaultOptions.particleTableList = [
'pythiapdt',
'pdt']
45 defaultOptions.dirin =
''
46 defaultOptions.dirout =
''
47 defaultOptions.filetype =
'EDM'
48 defaultOptions.fileout =
'output.root'
49 defaultOptions.filtername =
''
50 defaultOptions.lazy_download =
False
51 defaultOptions.custom_conditions =
''
52 defaultOptions.hltProcess =
''
53 defaultOptions.eventcontent =
None
54 defaultOptions.datatier =
None
55 defaultOptions.inlineEventContent =
True
56 defaultOptions.inlineObjets =
''
57 defaultOptions.hideGen=
False
58 from Configuration.StandardSequences.VtxSmeared
import VtxSmearedDefaultKey,VtxSmearedHIDefaultKey
59 defaultOptions.beamspot=
None
60 defaultOptions.outputDefinition =
''
61 defaultOptions.inputCommands =
None
62 defaultOptions.outputCommands =
None
63 defaultOptions.inputEventContent =
''
64 defaultOptions.dropDescendant =
False
65 defaultOptions.relval =
None
66 defaultOptions.slhc =
None
67 defaultOptions.profile =
None
68 defaultOptions.isRepacked =
False
69 defaultOptions.restoreRNDSeeds =
False
70 defaultOptions.donotDropOnInput =
''
71 defaultOptions.python_filename =
''
72 defaultOptions.io=
None
73 defaultOptions.lumiToProcess=
None
74 defaultOptions.fast=
False
75 defaultOptions.runsAndWeightsForMC =
None
76 defaultOptions.runsScenarioForMC =
None
77 defaultOptions.runUnscheduled =
False
78 defaultOptions.timeoutOutput =
False
82 theObject = getattr(process,name)
83 if isinstance(theObject,cms.Path)
or isinstance(theObject,cms.EndPath)
or isinstance(theObject,cms.Sequence):
84 return "process."+name+
" = " + theObject.dumpPython(
"process")
85 elif isinstance(theObject,_Module)
or isinstance(theObject,cms.ESProducer):
86 return "process."+name+
" = " + theObject.dumpPython()+
"\n"
88 return "process."+name+
" = " + theObject.dumpPython()+
"\n"
94 for line
in open(fileName,
'r'):
95 if line.count(
".root")>=2:
97 entries=line.replace(
"\n",
"").
split()
98 if not entries[0]
in prim:
99 prim.append(entries[0])
100 if not entries[1]
in sec:
101 sec.append(entries[1])
102 elif (line.find(
".root")!=-1):
103 entry=line.replace(
"\n",
"")
104 if not entry
in prim:
107 if not hasattr(s,
"fileNames"):
108 s.fileNames=cms.untracked.vstring(prim)
110 s.fileNames.extend(prim)
112 if not hasattr(s,
"secondaryFileNames"):
113 s.secondaryFileNames=cms.untracked.vstring(sec)
115 s.secondaryFileNames.extend(sec)
116 print "found files: ",prim
118 raise Exception(
"There are not files in input from the file list")
120 print "found parent files:",sec
128 print "the query is",query
129 for line
in os.popen(
'das_client.py --query "%s"'%(query)):
130 if line.count(
".root")>=2:
132 entries=line.replace(
"\n",
"").
split()
133 if not entries[0]
in prim:
134 prim.append(entries[0])
135 if not entries[1]
in sec:
136 sec.append(entries[1])
137 elif (line.find(
".root")!=-1):
138 entry=line.replace(
"\n",
"")
139 if not entry
in prim:
142 if not hasattr(s,
"fileNames"):
143 s.fileNames=cms.untracked.vstring(prim)
145 s.fileNames.extend(prim)
147 if not hasattr(s,
"secondaryFileNames"):
148 s.secondaryFileNames=cms.untracked.vstring(sec)
150 s.secondaryFileNames.extend(sec)
151 print "found files: ",prim
153 print "found parent files:",sec
158 for s
in aProcess.paths_().
keys():
163 """The main building routines """
165 def __init__(self, options, process = None, with_output = False, with_input = False ):
166 """options taken from old cmsDriver and optparse """
168 options.outfile_name = options.dirout+options.fileout
172 if self._options.isData
and options.isMC:
173 raise Exception(
"ERROR: You may specify only --data or --mc, not both")
177 if hasattr(self.
_options,
"datatier")
and self._options.datatier
and 'DQMIO' in self._options.datatier
and 'ENDJOB' in self._options.step:
178 self._options.step=self._options.step.replace(
',ENDJOB',
'')
181 stepList = [re.sub(
r'^prepare_',
'', methodName)
for methodName
in ConfigBuilder.__dict__
if methodName.startswith(
'prepare_')]
184 for step
in self._options.step.split(
","):
185 if step==
'':
continue
186 stepParts = step.split(
":")
187 stepName = stepParts[0]
188 if stepName
not in stepList
and not stepName.startswith(
're'):
189 raise ValueError(
"Step "+stepName+
" unknown")
190 if len(stepParts)==1:
191 self.stepMap[stepName]=
""
192 elif len(stepParts)==2:
193 self.stepMap[stepName]=stepParts[1].
split(
'+')
194 elif len(stepParts)==3:
195 self.stepMap[stepName]=(stepParts[2].
split(
'+'),stepParts[1])
197 raise ValueError(
"Step definition "+step+
" invalid")
198 self.stepKeys.append(stepName)
202 if 'FASTSIM' in self.stepMap:
204 self._options.fast=
True
206 self.with_output = with_output
207 if hasattr(self.
_options,
"no_output_flag")
and self._options.no_output_flag:
208 self.with_output =
False
209 self.with_input = with_input
211 self.process = cms.Process(self._options.name)
213 self.process = process
215 self.importsUnsch = []
217 self.schedule =
list()
223 self.additionalCommands = []
225 self.blacklist_paths = []
226 self.addedObjects = []
227 self.additionalOutputs = {}
229 self.productionFilterSequence =
None
230 self.nextScheduleIsConditional=
False
231 self.conditionalPaths=[]
232 self.excludedPaths=[]
237 Function to add the igprof profile service so that you can dump in the middle
240 profileOpts = self._options.profile.split(
':')
242 profilerInterval = 100
243 profilerFormat =
None
244 profilerJobFormat =
None
250 startEvent = profileOpts.pop(0)
251 if not startEvent.isdigit():
252 raise Exception(
"%s is not a number" % startEvent)
253 profilerStart = int(startEvent)
255 eventInterval = profileOpts.pop(0)
256 if not eventInterval.isdigit():
257 raise Exception(
"%s is not a number" % eventInterval)
258 profilerInterval = int(eventInterval)
260 profilerFormat = profileOpts.pop(0)
263 if not profilerFormat:
264 profilerFormat =
"%s___%s___%s___%s___%s___%s___%%I.gz" % (self._options.evt_type.replace(
"_cfi",
""),
266 self._options.pileup,
267 self._options.conditions,
268 self._options.datatier,
269 self._options.profileTypeLabel)
270 if not profilerJobFormat
and profilerFormat.endswith(
".gz"):
271 profilerJobFormat = profilerFormat.replace(
".gz",
"_EndOfJob.gz")
272 elif not profilerJobFormat:
273 profilerJobFormat = profilerFormat +
"_EndOfJob.gz"
275 return (profilerStart,profilerInterval,profilerFormat,profilerJobFormat)
278 includeFile = includeFile.replace(
'/',
'.')
279 self.process.load(includeFile)
280 return sys.modules[includeFile]
283 """helper routine to load am memorize imports"""
286 includeFile = includeFile.replace(
'/',
'.')
288 self.imports.append(includeFile)
289 self.process.load(includeFile)
290 return sys.modules[includeFile]
292 self.importsUnsch.append(includeFile)
296 """helper routine to remember replace statements"""
297 self.additionalCommands.append(command)
298 if not command.strip().startswith(
"#"):
301 exec(re.sub(
r"([^a-zA-Z_0-9]|^)(process)([^a-zA-Z_0-9])",
r"\1self.process\3",command))
305 if 'HARVESTING' in self.stepMap.keys()
or 'ALCAHARVEST' in self.stepMap.keys():
306 self.process.options = cms.untracked.PSet( Rethrow = cms.untracked.vstring(
'ProductNotFound'),fileMode = cms.untracked.string(
'FULLMERGE'))
308 self.process.options = cms.untracked.PSet( )
310 if self._options.runUnscheduled:
311 self.process.options.allowUnscheduled=cms.untracked.bool(
True)
313 self.addedObjects.append((
"",
"options"))
315 if self._options.lazy_download:
316 self.process.AdaptorConfig = cms.Service(
"AdaptorConfig",
317 stats = cms.untracked.bool(
True),
318 enable = cms.untracked.bool(
True),
319 cacheHint = cms.untracked.string(
"lazy-download"),
320 readHint = cms.untracked.string(
"read-ahead-buffered")
322 self.addedObjects.append((
"Setup lazy download",
"AdaptorConfig"))
327 if self._options.profile:
329 self.process.IgProfService = cms.Service(
"IgProfService",
330 reportFirstEvent = cms.untracked.int32(start),
331 reportEventInterval = cms.untracked.int32(interval),
332 reportToFileAtPostEvent = cms.untracked.string(
"| gzip -c > %s"%(eventFormat)),
333 reportToFileAtPostEndJob = cms.untracked.string(
"| gzip -c > %s"%(jobFormat)))
334 self.addedObjects.append((
"Setup IGProf Service for profiling",
"IgProfService"))
337 """Here we decide how many evts will be processed"""
338 self.process.maxEvents=cms.untracked.PSet(input=cms.untracked.int32(int(self._options.number)))
339 if self._options.number_out:
340 self.process.maxEvents.output = cms.untracked.int32(int(self._options.number_out))
341 self.addedObjects.append((
"",
"maxEvents"))
344 """Here the source is built. Priority: file, generator"""
345 self.addedObjects.append((
"Input source",
"source"))
348 for entry
in self._options.filein.split(
','):
350 if entry.startswith(
"filelist:"):
352 elif entry.startswith(
"dbs:")
or entry.startswith(
"das:"):
355 self.process.source.fileNames.append(self._options.dirin+entry)
356 if self._options.secondfilein:
357 if not hasattr(self.process.source,
"secondaryFileNames"):
358 raise Exception(
"--secondfilein not compatible with "+self._options.filetype+
"input type")
359 for entry
in self._options.secondfilein.split(
','):
361 if entry.startswith(
"filelist:"):
362 self.process.source.secondaryFileNames.extend((
filesFromList(entry[9:]))[0])
363 elif entry.startswith(
"dbs:")
or entry.startswith(
"das:"):
364 self.process.source.secondaryFileNames.extend((
filesFromDASQuery(
'file dataset = %s'%(entry[4:])))[0])
366 self.process.source.secondaryFileNames.append(self._options.dirin+entry)
368 if self._options.filein
or self._options.dasquery:
369 if self._options.filetype ==
"EDM":
370 self.process.source=cms.Source(
"PoolSource",
371 fileNames = cms.untracked.vstring(),
372 secondaryFileNames= cms.untracked.vstring())
374 elif self._options.filetype ==
"DAT":
375 self.process.source=cms.Source(
"NewEventStreamFileReader",fileNames = cms.untracked.vstring())
377 elif self._options.filetype ==
"LHE":
378 self.process.source=cms.Source(
"LHESource", fileNames = cms.untracked.vstring())
379 if self._options.filein.startswith(
"lhe:"):
381 args=self._options.filein.split(
':')
383 print 'LHE input from article ',article
384 location=
'/store/lhe/'
386 textOfFiles=os.popen(
'cmsLHEtoEOSManager.py -l '+article)
387 for line
in textOfFiles:
388 for fileName
in [x
for x
in line.split()
if '.lhe' in x]:
389 self.process.source.fileNames.append(location+article+
'/'+fileName)
391 self.process.source.skipEvents = cms.untracked.uint32(int(args[2]))
396 elif self._options.filetype ==
"DQM":
397 self.process.source=cms.Source(
"DQMRootSource",
398 fileNames = cms.untracked.vstring())
401 elif self._options.filetype ==
"DQMDAQ":
403 self.process.source=cms.Source(
"DQMStreamerReader")
406 if (
'HARVESTING' in self.stepMap.keys()
or 'ALCAHARVEST' in self.stepMap.keys())
and (
not self._options.filetype ==
"DQM"):
407 self.process.source.processingMode = cms.untracked.string(
"RunsAndLumis")
409 if self._options.dasquery!=
'':
410 self.process.source=cms.Source(
"PoolSource", fileNames = cms.untracked.vstring(),secondaryFileNames = cms.untracked.vstring())
413 if self._options.inputCommands:
414 if not hasattr(self.process.source,
'inputCommands'): self.process.source.inputCommands=cms.untracked.vstring()
415 for command
in self._options.inputCommands.split(
','):
417 command = command.strip()
418 if command==
'':
continue
419 self.process.source.inputCommands.append(command)
420 if not self._options.dropDescendant:
421 self.process.source.dropDescendantsOfDroppedBranches = cms.untracked.bool(
False)
423 if self._options.lumiToProcess:
424 import FWCore.PythonUtilities.LumiList
as LumiList
425 self.process.source.lumisToProcess = cms.untracked.VLuminosityBlockRange(
LumiList.LumiList(self._options.lumiToProcess).getCMSSWString().
split(
',') )
427 if 'GEN' in self.stepMap.keys()
or 'LHE' in self.stepMap
or (
not self._options.filein
and hasattr(self.
_options,
"evt_type")):
428 if self.process.source
is None:
429 self.process.source=cms.Source(
"EmptySource")
431 if self._options.himix==
True:
432 self.process.source.inputCommands = cms.untracked.vstring(
'drop *',
'keep *_generator_*_*',
'keep *_g4SimHits_*_*')
433 self.process.source.dropDescendantsOfDroppedBranches=cms.untracked.bool(
False)
436 self.runsAndWeights=
None
437 if self._options.runsAndWeightsForMC
or self._options.runsScenarioForMC :
438 if not self._options.isMC :
439 raise Exception(
"options --runsAndWeightsForMC and --runsScenarioForMC are only valid for MC")
440 if self._options.runsAndWeightsForMC:
441 self.runsAndWeights = eval(self._options.runsAndWeightsForMC)
443 from Configuration.StandardSequences.RunsAndWeights
import RunsAndWeights
444 if type(RunsAndWeights[self._options.runsScenarioForMC])==str:
445 __import__(RunsAndWeights[self._options.runsScenarioForMC])
446 self.runsAndWeights = sys.modules[RunsAndWeights[self._options.runsScenarioForMC]].runProbabilityDistribution
448 self.runsAndWeights = RunsAndWeights[self._options.runsScenarioForMC]
450 if self.runsAndWeights:
451 import SimGeneral.Configuration.ThrowAndSetRandomRun
as ThrowAndSetRandomRun
453 self.additionalCommands.append(
'import SimGeneral.Configuration.ThrowAndSetRandomRun as ThrowAndSetRandomRun')
454 self.additionalCommands.append(
'ThrowAndSetRandomRun.throwAndSetRandomRun(process.source,%s)'%(self.runsAndWeights))
459 """ Add output module to the process """
461 if self._options.outputDefinition:
462 if self._options.datatier:
463 print "--datatier & --eventcontent options ignored"
465 def anyOf(listOfKeys,dict,opt=None):
474 raise Exception(
"any of "+
','.
join(listOfKeys)+
" are mandatory entries of --output options")
477 outList = eval(self._options.outputDefinition)
478 for (id,outDefDict)
in enumerate(outList):
479 outDefDictStr=outDefDict.__str__()
480 if not isinstance(outDefDict,dict):
481 raise Exception(
"--output needs to be passed a list of dict"+self._options.outputDefinition+
" is invalid")
483 theTier=
anyOf([
't',
'tier',
'dataTier'],outDefDict)
486 theStreamType=
anyOf([
'e',
'ec',
'eventContent',
'streamType'],outDefDict,theTier)
487 theFilterName=
anyOf([
'f',
'ftN',
'filterName'],outDefDict,
'')
488 theSelectEvent=
anyOf([
's',
'sE',
'selectEvents'],outDefDict,
'')
489 theModuleLabel=
anyOf([
'l',
'mL',
'moduleLabel'],outDefDict,
'')
490 theExtraOutputCommands=
anyOf([
'o',
'oC',
'outputCommands'],outDefDict,
'')
492 if not theModuleLabel:
493 tryNames=[theStreamType.replace(theTier.replace(
'-',
''),
'')+theTier.replace(
'-',
'')+
'output',
494 theStreamType.replace(theTier.replace(
'-',
''),
'')+theTier.replace(
'-',
'')+theFilterName+
'output',
495 theStreamType.replace(theTier.replace(
'-',
''),
'')+theTier.replace(
'-',
'')+theFilterName+theSelectEvent.split(
',')[0].
replace(
':',
'for').
replace(
' ',
'')+
'output'
497 for name
in tryNames:
498 if not hasattr(self.process,name):
501 if not theModuleLabel:
502 raise Exception(
"cannot find a module label for specification: "+outDefDictStr)
504 defaultFileName=self._options.outfile_name
506 defaultFileName=self._options.outfile_name.replace(
'.root',
'_in'+theTier+
'.root')
508 theFileName=self._options.dirout+
anyOf([
'fn',
'fileName'],outDefDict,defaultFileName)
509 if not theFileName.endswith(
'.root'):
512 if len(outDefDict.keys()):
513 raise Exception(
"unused keys from --output options: "+
','.
join(outDefDict.keys()))
514 if theStreamType==
'DQMIO': theStreamType=
'DQM'
515 if theStreamType==
'ALL':
516 theEventContent = cms.PSet(outputCommands = cms.untracked.vstring(
'keep *'))
518 theEventContent = getattr(self.process, theStreamType+
"EventContent")
520 if theStreamType==
'ALCARECO' and not theFilterName:
521 theFilterName=
'StreamALCACombined'
523 CppType=
'PoolOutputModule'
524 if self._options.timeoutOutput:
525 CppType=
'TimeoutPoolOutputModule'
526 if theStreamType==
'DQM' and theTier==
'DQMIO': CppType=
'DQMRootOutputModule'
527 output = cms.OutputModule(CppType,
528 theEventContent.clone(),
529 fileName = cms.untracked.string(theFileName),
530 dataset = cms.untracked.PSet(
531 dataTier = cms.untracked.string(theTier),
532 filterName = cms.untracked.string(theFilterName))
534 if not theSelectEvent
and hasattr(self.process,
'generation_step')
and theStreamType!=
'LHE':
535 output.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
'generation_step'))
536 if not theSelectEvent
and hasattr(self.process,
'filtering_step'):
537 output.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
'filtering_step'))
539 output.SelectEvents =cms.untracked.PSet(SelectEvents = cms.vstring(theSelectEvent))
541 if hasattr(self.process,theModuleLabel):
542 raise Exception(
"the current process already has a module "+theModuleLabel+
" defined")
544 setattr(self.process,theModuleLabel,output)
545 outputModule=getattr(self.process,theModuleLabel)
546 setattr(self.process,theModuleLabel+
'_step',cms.EndPath(outputModule))
547 path=getattr(self.process,theModuleLabel+
'_step')
548 self.schedule.append(path)
550 if not self._options.inlineEventContent
and hasattr(self.process,theStreamType+
"EventContent"):
553 outputModule.outputCommands.__dict__[
"dumpPython"] = doNotInlineEventContent
554 if theExtraOutputCommands:
555 if not isinstance(theExtraOutputCommands,list):
556 raise Exception(
"extra ouput command in --option must be a list of strings")
557 if hasattr(self.process,theStreamType+
"EventContent"):
558 self.
executeAndRemember(
'process.%s.outputCommands.extend(%s)'%(theModuleLabel,theExtraOutputCommands))
560 outputModule.outputCommands.extend(theExtraOutputCommands)
562 result+=
"\nprocess."+theModuleLabel+
" = "+outputModule.dumpPython()
567 streamTypes=self._options.eventcontent.split(
',')
568 tiers=self._options.datatier.split(
',')
569 if not self._options.outputDefinition
and len(streamTypes)!=len(tiers):
570 raise Exception(
"number of event content arguments does not match number of datatier arguments")
573 if self._options.step.split(
',')[0].
split(
':')[0] ==
'ALCA':
576 for i,(streamType,tier)
in enumerate(
zip(streamTypes,tiers)):
577 if streamType==
'':
continue
578 if streamType==
'DQMIO': streamType=
'DQM'
579 theEventContent = getattr(self.process, streamType+
"EventContent")
581 theFileName=self._options.outfile_name
582 theFilterName=self._options.filtername
584 theFileName=self._options.outfile_name.replace(
'.root',
'_in'+streamType+
'.root')
585 theFilterName=self._options.filtername
586 CppType=
'PoolOutputModule'
587 if self._options.timeoutOutput:
588 CppType=
'TimeoutPoolOutputModule'
589 if streamType==
'DQM' and tier==
'DQMIO': CppType=
'DQMRootOutputModule'
590 output = cms.OutputModule(CppType,
592 fileName = cms.untracked.string(theFileName),
593 dataset = cms.untracked.PSet(dataTier = cms.untracked.string(tier),
594 filterName = cms.untracked.string(theFilterName)
597 if hasattr(self.process,
"generation_step")
and streamType!=
'LHE':
598 output.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
'generation_step'))
599 if hasattr(self.process,
"filtering_step"):
600 output.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
'filtering_step'))
602 if streamType==
'ALCARECO':
603 output.dataset.filterName = cms.untracked.string(
'StreamALCACombined')
605 if "MINIAOD" in streamType:
606 output.dropMetaData = cms.untracked.string(
'ALL')
607 output.fastCloning= cms.untracked.bool(
False)
608 output.overrideInputFileSplitLevels = cms.untracked.bool(
True)
610 outputModuleName=streamType+
'output'
611 setattr(self.process,outputModuleName,output)
612 outputModule=getattr(self.process,outputModuleName)
613 setattr(self.process,outputModuleName+
'_step',cms.EndPath(outputModule))
614 path=getattr(self.process,outputModuleName+
'_step')
615 self.schedule.append(path)
617 if self._options.outputCommands
and streamType!=
'DQM':
618 for evct
in self._options.outputCommands.split(
','):
619 if not evct:
continue
620 self.
executeAndRemember(
"process.%s.outputCommands.append('%s')"%(outputModuleName,evct.strip()))
622 if not self._options.inlineEventContent:
625 outputModule.outputCommands.__dict__[
"dumpPython"] = doNotInlineEventContent
627 result+=
"\nprocess."+outputModuleName+
" = "+outputModule.dumpPython()
633 Add selected standard sequences to the process
636 if self._options.pileup:
637 pileupSpec=self._options.pileup.split(
',')[0]
638 from Configuration.StandardSequences.Mixing
import Mixing,defineMixing
639 if not pileupSpec
in Mixing
and '.' not in pileupSpec
and 'file:' not in pileupSpec:
640 raise Exception(pileupSpec+
' is not a know mixing scenario:\n available are: '+
'\n'.
join(Mixing.keys()))
641 if '.' in pileupSpec:
642 mixingDict={
'file':pileupSpec}
643 elif pileupSpec.startswith(
'file:'):
644 mixingDict={
'file':pileupSpec[5:]}
647 mixingDict=copy.copy(Mixing[pileupSpec])
648 if len(self._options.pileup.split(
','))>1:
649 mixingDict.update(eval(self._options.pileup[self._options.pileup.find(
',')+1:]))
650 if 'file:' in pileupSpec:
652 self.process.load(mixingDict[
'file'])
653 print "inlining mixing module configuration"
654 self._options.inlineObjets+=
',mix'
656 self.loadAndRemember(mixingDict[
'file'])
657 if self._options.fast:
658 self._options.customisation_file.append(
"FastSimulation/Configuration/MixingModule_Full2Fast.setVertexGeneratorPileUpProducer")
660 mixingDict.pop(
'file')
661 if not "DATAMIX" in self.stepMap.keys():
662 if self._options.pileup_input:
663 if self._options.pileup_input.startswith(
'dbs:')
or self._options.pileup_input.startswith(
'das:'):
664 mixingDict[
'F']=
filesFromDASQuery(
'file dataset = %s'%(self._options.pileup_input[4:],))[0]
666 mixingDict[
'F']=self._options.pileup_input.split(
',')
667 specialization=
defineMixing(mixingDict,self._options.fast)
668 for command
in specialization:
669 self.executeAndRemember(command)
670 if len(mixingDict)!=0:
671 raise Exception(
'unused mixing specification: '+mixingDict.keys().
__str__())
673 if self._options.fast
and not 'SIM' in self.stepMap
and not 'FASTSIM' in self.stepMap:
674 self.executeAndRemember(
'process.mix.playback= True')
679 if len(self.stepMap):
680 self.loadAndRemember(self.GeometryCFF)
681 if (
'SIM' in self.stepMap
or 'reSIM' in self.stepMap)
and not self._options.fast:
682 self.loadAndRemember(self.SimGeometryCFF)
683 if self.geometryDBLabel:
684 self.executeAndRemember(
'process.XMLFromDBSource.label = cms.string("%s")'%(self.geometryDBLabel))
686 print "Geometry option",self._options.geometry,
"unknown."
689 if len(self.stepMap):
690 self.loadAndRemember(self.magFieldCFF)
692 for stepName
in self.stepKeys:
693 stepSpec = self.stepMap[stepName]
694 print "Step:", stepName,
"Spec:",stepSpec
695 if stepName.startswith(
're'):
697 if stepName[2:]
not in self._options.donotDropOnInput:
698 self._options.inputEventContent=
'%s,%s'%(stepName.upper(),self._options.inputEventContent)
699 stepName=stepName[2:]
701 getattr(self,
"prepare_"+stepName)(sequence = getattr(self,stepName+
"DefaultSeq"))
702 elif type(stepSpec)==list:
703 getattr(self,
"prepare_"+stepName)(sequence =
'+'.
join(stepSpec))
704 elif type(stepSpec)==tuple:
705 getattr(self,
"prepare_"+stepName)(sequence =
','.
join([stepSpec[1],
'+'.
join(stepSpec[0])]))
707 raise ValueError(
"Invalid step definition")
709 if self._options.restoreRNDSeeds!=
False:
711 if self._options.restoreRNDSeeds==
True:
712 self.executeAndRemember(
'process.RandomNumberGeneratorService.restoreStateLabel=cms.untracked.string("randomEngineStateProducer")')
714 self.executeAndRemember(
'process.RandomNumberGeneratorService.restoreStateTag=cms.untracked.InputTag("randomEngineStateProducer","","%s")'%(self._options.restoreRNDSeeds))
715 if self._options.inputEventContent
or self._options.inputCommands:
716 if self._options.inputCommands:
717 self._options.inputCommands+=
'keep *_randomEngineStateProducer_*_*,'
719 self._options.inputCommands=
'keep *_randomEngineStateProducer_*_*,'
723 if self._options.inputEventContent:
725 def dropSecondDropStar(iec):
736 if not hasattr(self.process.source,
'inputCommands'): self.process.source.inputCommands=cms.untracked.vstring()
737 for evct
in self._options.inputEventContent.split(
','):
738 if evct==
'':
continue
739 theEventContent = getattr(self.process, evct+
"EventContent")
740 if hasattr(theEventContent,
'outputCommands'):
741 self.process.source.inputCommands.extend(copy.copy(theEventContent.outputCommands))
742 if hasattr(theEventContent,
'inputCommands'):
743 self.process.source.inputCommands.extend(copy.copy(theEventContent.inputCommands))
745 dropSecondDropStar(self.process.source.inputCommands)
747 if not self._options.dropDescendant:
748 self.process.source.dropDescendantsOfDroppedBranches = cms.untracked.bool(
False)
754 """Add conditions to the process"""
755 if not self._options.conditions:
return
757 if 'FrontierConditions_GlobalTag' in self._options.conditions:
758 print 'using FrontierConditions_GlobalTag in --conditions is not necessary anymore and will be deprecated soon. please update your command line'
759 self._options.conditions = self._options.conditions.replace(
"FrontierConditions_GlobalTag,",
'')
761 self.loadAndRemember(self.ConditionsDefaultCFF)
763 if self._options.useCondDBv1:
764 from Configuration.AlCa.GlobalTag
import GlobalTag
766 from Configuration.AlCa.GlobalTag_condDBv2
import GlobalTag
768 self.process.GlobalTag =
GlobalTag(self.process.GlobalTag, self._options.conditions, self._options.custom_conditions)
770 if self._options.useCondDBv1:
771 self.additionalCommands.append(
'from Configuration.AlCa.GlobalTag import GlobalTag')
773 self.additionalCommands.append(
'from Configuration.AlCa.GlobalTag_condDBv2 import GlobalTag')
775 self.additionalCommands.append(
'process.GlobalTag = GlobalTag(process.GlobalTag, %s, %s)' % (repr(self._options.conditions), repr(self._options.custom_conditions)))
777 if self._options.slhc:
778 self.loadAndRemember(
"SLHCUpgradeSimulations/Geometry/fakeConditions_%s_cff"%(self._options.slhc,))
782 """Include the customise code """
786 for c
in self._options.customisation_file:
787 custOpt.extend(c.split(
","))
789 for c
in self._options.customisation_file_unsch:
790 custOpt.extend(c.split(
","))
796 raise Exception(
"more than . in the specification:"+opt)
797 fileName=opt.split(
'.')[0]
798 if opt.count(
'.')==0: rest=
'customise'
800 rest=opt.split(
'.')[1]
801 if rest==
'py': rest=
'customise'
803 if fileName
in custMap:
804 custMap[fileName].extend(rest.split(
'+'))
806 custMap[fileName]=rest.split(
'+')
811 final_snippet=
'\n# customisation of the process.\n'
815 allFcn.extend(custMap[opt])
817 if allFcn.count(fcn)!=1:
818 raise Exception(
"cannot specify twice "+fcn+
" as a customisation method")
822 packageName = f.replace(
".py",
"").
replace(
"/",
".")
823 __import__(packageName)
824 package = sys.modules[packageName]
827 customiseFile = re.sub(
r'\.pyc$',
'.py', package.__file__)
829 final_snippet+=
'\n# Automatic addition of the customisation function from '+packageName+
'\n'
830 if self._options.inline_custom:
831 for line
in file(customiseFile,
'r'):
832 if "import FWCore.ParameterSet.Config" in line:
834 final_snippet += line
836 final_snippet +=
'from %s import %s \n'%(packageName,
','.
join(custMap[f]))
837 for fcn
in custMap[f]:
838 print "customising the process with",fcn,
"from",f
839 if not hasattr(package,fcn):
841 raise Exception(
"config "+f+
" has no function "+fcn)
843 self.process=getattr(package,fcn)(self.process)
845 final_snippet +=
"\n#call to customisation function "+fcn+
" imported from "+packageName
846 final_snippet +=
"\nprocess = %s(process)\n"%(fcn,)
849 final_snippet +=
'\n# End of customisation functions\n'
852 if self._options.customise_commands:
854 final_snippet +=
'\n# Customisation from command line'
855 for com
in self._options.customise_commands.split(
'\\n'):
856 com=string.lstrip(com)
858 final_snippet +=
'\n'+com
867 if len(self.stepMap):
869 if self._options.particleTable
not in defaultOptions.particleTableList:
870 print 'Invalid particle table provided. Options are:'
871 print defaultOptions.particleTable
874 if len(self.stepMap):
875 self.
loadAndRemember(
'SimGeneral.HepPDTESSource.'+self._options.particleTable+
'_cfi')
879 self.
ALCADefaultCFF=
"Configuration/StandardSequences/AlCaRecoStreams_cff"
880 self.
GENDefaultCFF=
"Configuration/StandardSequences/Generator_cff"
884 self.
L1EMDefaultCFF=
'Configuration/StandardSequences/SimL1Emulator_cff'
885 self.
L1MENUDefaultCFF=
"Configuration/StandardSequences/L1TriggerDefaultMenu_cff"
886 self.
HLTDefaultCFF=
"Configuration/StandardSequences/HLTtable_cff"
890 self.
RECODefaultCFF=
"Configuration/StandardSequences/Reconstruction_Data_cff"
892 self.EIDefaultCFF=
None
893 self.SKIMDefaultCFF=
"Configuration/StandardSequences/Skims_cff"
894 self.POSTRECODefaultCFF=
"Configuration/StandardSequences/PostRecoGenerator_cff"
895 self.VALIDATIONDefaultCFF=
"Configuration/StandardSequences/Validation_cff"
896 self.L1HwValDefaultCFF =
"Configuration/StandardSequences/L1HwVal_cff"
897 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOffline_cff"
898 self.HARVESTINGDefaultCFF=
"Configuration/StandardSequences/Harvesting_cff"
899 self.ALCAHARVESTDefaultCFF=
"Configuration/StandardSequences/AlCaHarvesting_cff"
900 self.ENDJOBDefaultCFF=
"Configuration/StandardSequences/EndOfProcess_cff"
901 if self._options.useCondDBv1:
902 self.ConditionsDefaultCFF =
"Configuration/StandardSequences/FrontierConditions_GlobalTag_cff"
904 self.ConditionsDefaultCFF =
"Configuration/StandardSequences/FrontierConditions_GlobalTag_condDBv2_cff"
905 self.CFWRITERDefaultCFF =
"Configuration/StandardSequences/CrossingFrameWriter_cff"
906 self.REPACKDefaultCFF=
"Configuration/StandardSequences/DigiToRaw_Repack_cff"
908 if "DATAMIX" in self.stepMap.keys():
909 self.DATAMIXDefaultCFF=
"Configuration/StandardSequences/DataMixer"+self._options.datamix+
"_cff"
910 if self._options.datamix ==
'PreMix':
911 self.
DIGIDefaultCFF=
"Configuration/StandardSequences/DigiDMPreMix_cff"
915 self.
L1EMDefaultCFF=
'Configuration/StandardSequences/SimL1EmulatorDM_cff'
917 if "DIGIPREMIX" in self.stepMap.keys():
918 self.
DIGIDefaultCFF=
"Configuration/StandardSequences/Digi_PreMix_cff"
920 self.ALCADefaultSeq=
None
921 self.LHEDefaultSeq=
'externalLHEProducer'
922 self.GENDefaultSeq=
'pgen'
923 self.SIMDefaultSeq=
'psim'
924 self.DIGIDefaultSeq=
'pdigi'
925 self.DIGIPREMIXDefaultSeq=
'pdigi'
926 self.DIGIPREMIX_S2DefaultSeq=
'pdigi'
927 self.DATAMIXDefaultSeq=
None
928 self.DIGI2RAWDefaultSeq=
'DigiToRaw'
929 self.HLTDefaultSeq=
'GRun'
930 self.L1DefaultSeq=
None
931 self.L1REPACKDefaultSeq=
'GT'
932 self.HARVESTINGDefaultSeq=
None
933 self.ALCAHARVESTDefaultSeq=
None
934 self.CFWRITERDefaultSeq=
None
935 self.RAW2DIGIDefaultSeq=
'RawToDigi'
936 self.L1RecoDefaultSeq=
'L1Reco'
937 self.L1TrackTriggerDefaultSeq=
'L1TrackTrigger'
938 if 'RAW2DIGI' in self.stepMap
and 'RECO' in self.stepMap:
939 self.RECODefaultSeq=
'reconstruction'
941 self.RECODefaultSeq=
'reconstruction_fromRECO'
943 self.EIDefaultSeq=
'top'
944 self.POSTRECODefaultSeq=
None
945 self.L1HwValDefaultSeq=
'L1HwVal'
946 self.DQMDefaultSeq=
'DQMOffline'
947 self.FASTSIMDefaultSeq=
'all'
948 self.VALIDATIONDefaultSeq=
''
949 self.ENDJOBDefaultSeq=
'endOfProcess'
950 self.REPACKDefaultSeq=
'DigiToRawRepack'
951 self.PATDefaultSeq=
'miniAOD'
953 self.EVTCONTDefaultCFF=
"Configuration/EventContent/EventContent_cff"
955 if not self._options.beamspot:
956 self._options.beamspot=VtxSmearedDefaultKey
959 if self._options.isMC==
True:
961 self.
RECODefaultCFF=
"Configuration/StandardSequences/Reconstruction_cff"
962 self.
PATDefaultCFF=
"Configuration/StandardSequences/PATMC_cff"
963 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineMC_cff"
964 self.
ALCADefaultCFF=
"Configuration/StandardSequences/AlCaRecoStreamsMC_cff"
966 self._options.beamspot =
None
969 if 'reGEN' in self.stepMap:
970 self.GENDefaultSeq=
'fixGenInfo'
972 if self._options.scenario==
'cosmics':
973 self._options.pileup=
'Cosmics'
974 self.
DIGIDefaultCFF=
"Configuration/StandardSequences/DigiCosmics_cff"
975 self.
RECODefaultCFF=
"Configuration/StandardSequences/ReconstructionCosmics_cff"
976 self.SKIMDefaultCFF=
"Configuration/StandardSequences/SkimsCosmics_cff"
977 self.EVTCONTDefaultCFF=
"Configuration/EventContent/EventContentCosmics_cff"
978 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineCosmics_cff"
979 if self._options.isMC==
True:
980 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineCosmicsMC_cff"
981 self.HARVESTINGDefaultCFF=
"Configuration/StandardSequences/HarvestingCosmics_cff"
982 self.RECODefaultSeq=
'reconstructionCosmics'
983 self.DQMDefaultSeq=
'DQMOfflineCosmics'
985 if self._options.himix:
986 print "From the presence of the himix option, we have determined that this is heavy ions and will use '--scenario HeavyIons'."
987 self._options.scenario=
'HeavyIons'
989 if self._options.scenario==
'HeavyIons':
990 if not self._options.beamspot:
991 self._options.beamspot=VtxSmearedHIDefaultKey
992 self.HLTDefaultSeq =
'HIon'
993 if not self._options.himix:
994 self.GENDefaultSeq=
'pgen_hi'
996 self.GENDefaultSeq=
'pgen_himix'
997 self.VALIDATIONDefaultCFF=
"Configuration/StandardSequences/ValidationHeavyIons_cff"
998 self.VALIDATIONDefaultSeq=
''
999 self.EVTCONTDefaultCFF=
"Configuration/EventContent/EventContentHeavyIons_cff"
1000 self.
RECODefaultCFF=
"Configuration/StandardSequences/ReconstructionHeavyIons_cff"
1001 self.RECODefaultSeq=
'reconstructionHeavyIons'
1002 self.
ALCADefaultCFF =
"Configuration/StandardSequences/AlCaRecoStreamsHeavyIons_cff"
1003 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineHeavyIons_cff"
1004 self.DQMDefaultSeq=
'DQMOfflineHeavyIons'
1005 self.SKIMDefaultCFF=
"Configuration/StandardSequences/SkimsHeavyIons_cff"
1006 self.HARVESTINGDefaultCFF=
"Configuration/StandardSequences/HarvestingHeavyIons_cff"
1007 if self._options.isMC==
True:
1008 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineHeavyIonsMC_cff"
1011 self.RAW2RECODefaultSeq=
','.
join([self.RAW2DIGIDefaultSeq,self.RECODefaultSeq])
1013 self.USERDefaultSeq=
'user'
1014 self.USERDefaultCFF=
None
1017 if self._options.isData:
1018 if self._options.magField==defaultOptions.magField:
1019 print "magnetic field option forced to: AutoFromDBCurrent"
1020 self._options.magField=
'AutoFromDBCurrent'
1021 self.magFieldCFF =
'Configuration/StandardSequences/MagneticField_'+self._options.magField.replace(
'.',
'')+
'_cff'
1022 self.magFieldCFF = self.magFieldCFF.replace(
"__",
'_')
1025 self.GeometryCFF=
'Configuration/StandardSequences/GeometryRecoDB_cff'
1026 self.geometryDBLabel=
None
1028 if self._options.fast:
1029 if 'start' in self._options.conditions.lower():
1030 self.GeometryCFF=
'FastSimulation/Configuration/Geometries_START_cff'
1032 self.GeometryCFF=
'FastSimulation/Configuration/Geometries_MC_cff'
1035 from Configuration.StandardSequences.GeometryConf
import GeometryConf
1036 if opt
in GeometryConf:
1037 return GeometryConf[opt]
1041 geoms=self._options.geometry.split(
',')
1045 if '/' in geoms[1]
or '_cff' in geoms[1]:
1046 self.GeometryCFF=geoms[1]
1048 self.GeometryCFF=
'Configuration/Geometry/Geometry'+geoms[1]+
'_cff'
1050 if (geoms[0].startswith(
'DB:')):
1051 self.SimGeometryCFF=
'Configuration/StandardSequences/GeometrySimDB_cff'
1052 self.geometryDBLabel=geoms[0][3:]
1055 if '/' in geoms[0]
or '_cff' in geoms[0]:
1056 self.SimGeometryCFF=geoms[0]
1058 simGeometry=geoms[0]
1059 if self._options.gflash==
True:
1060 self.SimGeometryCFF=
'Configuration/Geometry/Geometry'+geoms[0]+
'GFlash_cff'
1062 self.SimGeometryCFF=
'Configuration/Geometry/Geometry'+geoms[0]+
'_cff'
1065 if simGeometry
not in defaultOptions.geometryExtendedOptions:
1066 self.
SIMDefaultCFF=
"Configuration/StandardSequences/SimIdeal_cff"
1068 if self._options.scenario==
'nocoll' or self._options.scenario==
'cosmics':
1069 self.
SIMDefaultCFF=
"Configuration/StandardSequences/SimNOBEAM_cff"
1070 self._options.beamspot=
'NoSmear'
1073 if self._options.fast:
1074 self.
SIMDefaultCFF =
'FastSimulation.Configuration.FamosSequences_cff'
1075 self.SIMDefaultSeq=
'simulationWithFamos'
1076 self.
RECODefaultCFF=
'FastSimulation.Configuration.FamosSequences_cff'
1077 self.RECODefaultSeq=
'reconstructionWithFamos'
1078 self.EVTCONTDefaultCFF =
"FastSimulation.Configuration.EventContent_cff"
1079 self.VALIDATIONDefaultCFF =
"FastSimulation.Configuration.Validation_cff"
1084 if self._options.pileup==
'default':
1085 from Configuration.StandardSequences.Mixing
import MixingDefaultKey,MixingFSDefaultKey
1086 if self._options.fast:
1087 self._options.pileup=MixingFSDefaultKey
1089 self._options.pileup=MixingDefaultKey
1092 if self._options.isData:
1093 self._options.pileup=
None
1094 if self._options.isMC==
True and self._options.himix==
False:
1095 if self._options.fast:
1096 self._options.pileup=
'FS_'+self._options.pileup
1097 elif self._options.isMC==
True and self._options.himix==
True:
1098 self._options.pileup=
'HiMix'
1101 if self._options.slhc:
1102 self.GeometryCFF=
'SLHCUpgradeSimulations.Geometry.%s_cmsSimIdealGeometryXML_cff'%(self._options.slhc,)
1103 if 'stdgeom' not in self._options.slhc:
1104 self.SimGeometryCFF=
'SLHCUpgradeSimulations.Geometry.%s_cmsSimIdealGeometryXML_cff'%(self._options.slhc,)
1105 self.
DIGIDefaultCFF=
'SLHCUpgradeSimulations/Geometry/Digi_%s_cff'%(self._options.slhc,)
1106 if self._options.pileup!=defaultOptions.pileup:
1107 self._options.pileup=
'SLHC_%s_%s'%(self._options.pileup,self._options.slhc)
1109 self.REDIGIDefaultSeq=self.DIGIDefaultSeq
1114 output = cms.OutputModule(
"PoolOutputModule")
1115 if stream.selectEvents.parameters_().__len__()!=0:
1116 output.SelectEvents = stream.selectEvents
1118 output.SelectEvents = cms.untracked.PSet()
1119 output.SelectEvents.SelectEvents=cms.vstring()
1120 if isinstance(stream.paths,tuple):
1121 for path
in stream.paths:
1122 output.SelectEvents.SelectEvents.append(path.label())
1124 output.SelectEvents.SelectEvents.append(stream.paths.label())
1128 if isinstance(stream.content,str):
1129 evtPset=getattr(self.process,stream.content)
1130 for p
in evtPset.parameters_():
1131 setattr(output,p,getattr(evtPset,p))
1132 if not self._options.inlineEventContent:
1135 output.outputCommands.__dict__[
"dumpPython"] = doNotInlineEventContent
1137 output.outputCommands = stream.content
1140 output.fileName = cms.untracked.string(self._options.dirout+stream.name+
'.root')
1142 output.dataset = cms.untracked.PSet( dataTier = stream.dataTier,
1143 filterName = cms.untracked.string(stream.name))
1145 if self._options.filtername:
1146 output.dataset.filterName= cms.untracked.string(self._options.filtername+
"_"+stream.name)
1149 output.eventAutoFlushCompressedSize=cms.untracked.int32(5*1024*1024)
1151 if workflow
in (
"producers,full"):
1152 if isinstance(stream.paths,tuple):
1153 for path
in stream.paths:
1154 self.schedule.append(path)
1156 self.schedule.append(stream.paths)
1160 if (
not self._options.relval)
and workflow
in (
"full",
"output"):
1161 self.additionalOutputs[name] = output
1162 setattr(self.process,name,output)
1164 if workflow ==
'output':
1166 filterList = output.SelectEvents.SelectEvents
1167 for i, filter
in enumerate(filterList):
1168 filterList[i] = filter+
":"+self._options.triggerResultsProcess
1178 if ( len(sequence.split(
'.'))==1 ):
1180 elif ( len(sequence.split(
'.'))==2 ):
1182 sequence=sequence.split(
'.')[1]
1184 print "sub sequence configuration must be of the form dir/subdir/cff.a+b+c or cff.a"
1185 print sequence,
"not recognized"
1192 for i,s
in enumerate(seq.split(
'*')):
1194 setattr(self.process,prefix,getattr(cms,what)( getattr(self.process, s) ))
1196 p=getattr(self.process,prefix)
1197 p+=getattr(self.process, s)
1198 self.schedule.append(getattr(self.process,prefix))
1203 if self.nextScheduleIsConditional:
1204 self.conditionalPaths.append(prefix)
1205 setattr(self.process,prefix,getattr(cms,what)( getattr(self.process, seq) ))
1206 self.schedule.append(getattr(self.process,prefix))
1208 for i,s
in enumerate(seq.split(
'+')):
1210 setattr(self.process,sn,getattr(cms,what)( getattr(self.process, s) ))
1211 self.schedule.append(getattr(self.process,sn))
1225 """ Enrich the process with alca streams """
1227 sequence = sequence.split(
'.')[-1]
1230 alcaList = sequence.split(
"+")
1232 from Configuration.AlCa.autoAlca
import autoAlca
1236 for name
in alcaConfig.__dict__:
1237 alcastream = getattr(alcaConfig,name)
1238 shortName = name.replace(
'ALCARECOStream',
'')
1239 if shortName
in alcaList
and isinstance(alcastream,cms.FilteredStream):
1240 output = self.
addExtraStream(name,alcastream, workflow = workflow)
1241 if 'DQM' in alcaList:
1242 if not self._options.inlineEventContent
and hasattr(self.process,name):
1243 self.
executeAndRemember(
'process.' + name +
'.outputCommands.append("keep *_MEtoEDMConverter_*_*")')
1245 output.outputCommands.append(
"keep *_MEtoEDMConverter_*_*")
1248 if self._options.hltProcess
or 'HLT' in self.stepMap:
1249 if isinstance(alcastream.paths,tuple):
1250 for path
in alcastream.paths:
1255 for i
in range(alcaList.count(shortName)):
1256 alcaList.remove(shortName)
1259 elif name ==
'pathALCARECODQM' and 'DQM' in alcaList:
1260 path = getattr(alcaConfig,name)
1261 self.schedule.append(path)
1262 alcaList.remove(
'DQM')
1264 if isinstance(alcastream,cms.Path):
1266 self.blacklist_paths.append(alcastream)
1269 if len(alcaList) != 0:
1271 for name
in alcaConfig.__dict__:
1272 alcastream = getattr(alcaConfig,name)
1273 if isinstance(alcastream,cms.FilteredStream):
1274 available.append(name.replace(
'ALCARECOStream',
''))
1275 print "The following alcas could not be found "+str(alcaList)
1276 print "available ",available
1278 raise Exception(
"The following alcas could not be found "+str(alcaList))
1283 loadFragment = self._options.evt_type.replace(
'.py',
'',).
replace(
'.',
'_').
replace(
'python/',
'').
replace(
'/',
'.')
1284 print "Loading lhe fragment from",loadFragment
1285 __import__(loadFragment)
1286 self.process.load(loadFragment)
1288 self._options.inlineObjets+=
','+sequence
1290 getattr(self.process,sequence).nEvents = int(self._options.number)
1293 self.process.lhe_step = cms.Path( getattr( self.process,sequence) )
1294 self.excludedPaths.append(
"lhe_step")
1295 self.schedule.append( self.process.lhe_step )
1298 """ load the fragment of generator configuration """
1303 loadFragment = self._options.evt_type.replace(
'.py',
'',).
replace(
'.',
'_').
replace(
'python/',
'')
1305 if not '/' in loadFragment:
1306 loadFragment=
'Configuration.Generator.'+loadFragment
1308 loadFragment=loadFragment.replace(
'/',
'.')
1310 print "Loading generator fragment from",loadFragment
1311 __import__(loadFragment)
1315 if not (self._options.filein
or self._options.dasquery):
1316 raise Exception(
"Neither gen fragment of input files provided: this is an inconsistent GEN step configuration")
1319 generatorModule=sys.modules[loadFragment]
1320 genModules=generatorModule.__dict__
1323 if self.LHEDefaultSeq
in genModules:
1324 del genModules[self.LHEDefaultSeq]
1326 if self._options.hideGen:
1327 self.loadAndRemember(loadFragment)
1329 self.process.load(loadFragment)
1331 import FWCore.ParameterSet.Modules
as cmstypes
1332 for name
in genModules:
1333 theObject = getattr(generatorModule,name)
1334 if isinstance(theObject, cmstypes._Module):
1335 self._options.inlineObjets=name+
','+self._options.inlineObjets
1336 elif isinstance(theObject, cms.Sequence)
or isinstance(theObject, cmstypes.ESProducer):
1337 self._options.inlineObjets+=
','+name
1339 if sequence == self.GENDefaultSeq
or sequence ==
'pgen_genonly' or ( sequence ==
'pgen_himix' or sequence ==
'pgen_hi'):
1340 if 'ProductionFilterSequence' in genModules
and (
'generator' in genModules
or 'hiSignal' in genModules):
1341 self.productionFilterSequence =
'ProductionFilterSequence'
1342 elif 'generator' in genModules:
1343 self.productionFilterSequence =
'generator'
1345 """ Enrich the schedule with the rest of the generation step """
1346 self.loadDefaultOrSpecifiedCFF(sequence,self.GENDefaultCFF)
1347 genSeqName=sequence.split(
'.')[-1]
1351 from Configuration.StandardSequences.VtxSmeared
import VtxSmeared
1352 cffToBeLoaded=VtxSmeared[self._options.beamspot]
1353 self.loadAndRemember(cffToBeLoaded)
1355 raise Exception(
"VertexSmearing type or beamspot "+self._options.beamspot+
" unknown.")
1357 if self._options.scenario ==
'HeavyIons' and self._options.himix:
1358 self.loadAndRemember(
"SimGeneral/MixingModule/himixGEN_cff")
1360 self.process.generation_step = cms.Path( getattr(self.process,genSeqName) )
1361 self.schedule.append(self.process.generation_step)
1364 self.executeAndRemember(
'process.genstepfilter.triggerConditions=cms.vstring("generation_step")')
1366 if 'reGEN' in self.stepMap:
1370 """ Enrich the schedule with the summary of the filter step """
1372 self.loadAndRemember(
"GeneratorInterface/Core/genFilterSummary_cff")
1373 self.scheduleSequenceAtEnd(
'genFilterSummary',
'genfiltersummary_step')
1377 """ Enrich the schedule with the simulation step"""
1378 self.loadDefaultOrSpecifiedCFF(sequence,self.SIMDefaultCFF)
1379 if not self._options.fast:
1380 if self._options.gflash==
True:
1381 self.loadAndRemember(
"Configuration/StandardSequences/GFlashSIM_cff")
1383 if self._options.magField==
'0T':
1384 self.executeAndRemember(
"process.g4SimHits.UseMagneticField = cms.bool(False)")
1386 if self._options.himix==
True:
1387 if self._options.geometry
in defaultOptions.geometryExtendedOptions:
1388 self.loadAndRemember(
"SimGeneral/MixingModule/himixSIMExtended_cff")
1390 self.loadAndRemember(
"SimGeneral/MixingModule/himixSIMIdeal_cff")
1392 if self._options.magField==
'0T':
1393 self.executeAndRemember(
"process.famosSimHits.UseMagneticField = cms.bool(False)")
1395 self.scheduleSequence(sequence.split(
'.')[-1],
'simulation_step')
1399 """ Enrich the schedule with the digitisation step"""
1402 if self._options.gflash==
True:
1403 self.
loadAndRemember(
"Configuration/StandardSequences/GFlashDIGI_cff")
1405 if self._options.himix==
True:
1408 if sequence ==
'pdigi_valid':
1409 self.
executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersValid)")
1415 """ Enrich the schedule with the digitisation step"""
1419 self.
executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersNoNoise)")
1425 """ Enrich the schedule with the digitisation step"""
1431 if sequence ==
'pdigi_valid':
1432 self.
executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersMixPreMixValid)")
1434 self.
executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersMixPreMix)")
1440 """ Enrich the schedule with the crossing frame writer step"""
1446 """ Enrich the schedule with the digitisation step"""
1450 if self._options.pileup_input:
1452 if self._options.pileup_input.startswith(
'dbs:')
or self._options.pileup_input.startswith(
'das:'):
1453 theFiles=
filesFromDASQuery(
'file dataset = %s'%(self._options.pileup_input[4:],))[0]
1454 elif self._options.pileup_input.startswith(
"filelist:"):
1455 theFiles= (
filesFromList(self._options.pileup_input[9:]))[0]
1457 theFiles=self._options.pileup_input.split(
',')
1459 self.
executeAndRemember(
"process.mixData.input.fileNames = cms.untracked.vstring(%s)"%( theFiles ) )
1466 if "DIGIPREMIX" in self.stepMap.keys():
1468 self.
executeAndRemember(
"process.SiStripDigiToRaw.FedReadoutMode = cms.string('PREMIX_RAW')")
1478 """ Enrich the schedule with the L1 simulation step"""
1483 from L1Trigger.Configuration.ConfigBuilder
import getConfigsForScenario
1484 listOfImports = getConfigsForScenario(sequence)
1485 for file
in listOfImports:
1491 """ Enrich the schedule with the L1 simulation step, running the L1 emulator on data unpacked from the RAW collection, and repacking the result in a new RAW collection"""
1492 if sequence
is not 'GT':
1493 print 'Running the full L1 emulator is not supported yet'
1495 if sequence
is 'GT':
1496 self.
loadAndRemember(
'Configuration/StandardSequences/SimL1EmulatorRepack_GT_cff')
1497 if self._options.scenario ==
'HeavyIons':
1503 """ Enrich the schedule with the HLT simulation step"""
1505 print "no specification of the hlt menu has been given, should never happen"
1506 raise Exception(
'no HLT sequence provided')
1510 from Configuration.HLT.autoHLT
import autoHLT
1513 sequence = autoHLT[key]
1515 raise ValueError(
'no HLT mapping key "%s" found in autoHLT' % key)
1521 if self._options.scenario ==
'HeavyIons':
1522 optionsForHLT[
'type'] =
'HIon'
1524 optionsForHLT[
'type'] =
'GRun'
1525 optionsForHLTConfig =
', '.
join(
'%s=%s' % (key, repr(val))
for (key, val)
in optionsForHLT.iteritems())
1526 if sequence ==
'run,fromSource':
1527 if hasattr(self.process.source,
'firstRun'):
1528 self.
executeAndRemember(
'process.loadHltConfiguration("run:%%d"%%(process.source.firstRun.value()),%s)'%(optionsForHLTConfig))
1529 elif hasattr(self.process.source,
'setRunNumber'):
1530 self.
executeAndRemember(
'process.loadHltConfiguration("run:%%d"%%(process.source.setRunNumber.value()),%s)'%(optionsForHLTConfig))
1532 raise Exception(
'Cannot replace menu to load %s'%(sequence))
1534 self.
executeAndRemember(
'process.loadHltConfiguration("%s",%s)'%(sequence.replace(
',',
':'),optionsForHLTConfig))
1536 if self._options.fast:
1537 self.
loadAndRemember(
'HLTrigger/Configuration/HLT_%s_Famos_cff' % sequence)
1541 if self._options.isMC:
1542 self._options.customisation_file.append(
"HLTrigger/Configuration/customizeHLTforMC.customizeHLTforMC")
1544 if self._options.name !=
'HLT':
1545 self.additionalCommands.append(
'from HLTrigger.Configuration.CustomConfigs import ProcessName')
1546 self.additionalCommands.append(
'process = ProcessName(process)')
1547 self.additionalCommands.append(
'')
1548 from HLTrigger.Configuration.CustomConfigs
import ProcessName
1551 self.schedule.append(self.process.HLTSchedule)
1552 [self.blacklist_paths.append(path)
for path
in self.process.HLTSchedule
if isinstance(path,(cms.Path,cms.EndPath))]
1553 if (self._options.fast
and 'HLT' in self.stepMap
and 'FASTSIM' in self.stepMap):
1557 if self._options.fast
and not 'FASTSIM' in self.stepMap:
1558 if not hasattr(self.process,
'HLTEndSequence'):
1559 self.
executeAndRemember(
"process.HLTEndSequence = cms.Sequence( process.dummyModule )")
1560 if not hasattr(self.process,
'simulation'):
1566 seqReco=sequence.split(
',')[1]
1567 seqDigi=sequence.split(
',')[0]
1569 print "RAW2RECO requires two specifications",sequence,
"insufficient"
1583 ''' Enrich the schedule with L1 HW validation '''
1586 print '\n\n\n DEPRECATED this has no action \n\n\n'
1590 ''' Enrich the schedule with L1 reconstruction '''
1596 ''' Enrich the schedule with L1 reconstruction '''
1602 ''' Enrich the schedule with a user defined filter sequence '''
1604 filterConfig=self.load(sequence.split(
'.')[0])
1605 filterSeq=sequence.split(
'.')[-1]
1607 class PrintAllModules(
object):
1613 label=visitee.label()
1621 getattr(self.process,filterSeq).
visit( expander )
1622 self._options.inlineObjets+=
','+expander.inliner
1623 self._options.inlineObjets+=
','+filterSeq
1626 self.scheduleSequence(filterSeq,
'filtering_step')
1627 self.nextScheduleIsConditional=
True
1629 self.productionFilterSequence = filterSeq
1634 ''' Enrich the schedule with reconstruction '''
1640 ''' Enrich the schedule with PAT '''
1642 if not self._options.runUnscheduled:
1643 raise Exception(
"MiniAOD production can only run in unscheduled mode, please run cmsDriver with --runUnscheduled")
1644 if self._options.isData:
1645 self._options.customisation_file_unsch.append(
"PhysicsTools/PatAlgos/slimming/miniAOD_tools.miniAOD_customizeAllData")
1647 self._options.customisation_file_unsch.append(
"PhysicsTools/PatAlgos/slimming/miniAOD_tools.miniAOD_customizeAllMC")
1648 if self._options.fast:
1649 self._options.customisation_file_unsch.append(
"PhysicsTools/PatAlgos/slimming/metFilterPaths_cff.miniAOD_customizeMETFiltersFastSim")
1653 ''' Enrich the schedule with event interpretation '''
1654 from Configuration.StandardSequences.EventInterpretation
import EventInterpretation
1655 if sequence
in EventInterpretation:
1656 self.EIDefaultCFF = EventInterpretation[sequence]
1657 sequence =
'EIsequence'
1659 raise Exception(
'Cannot set %s event interpretation'%( sequence) )
1660 self.loadDefaultOrSpecifiedCFF(sequence,self.EIDefaultCFF)
1661 self.scheduleSequence(sequence.split(
'.')[-1],
'eventinterpretaion_step')
1665 ''' Enrich the schedule with skimming fragments'''
1667 sequence = sequence.split(
'.')[-1]
1669 skimlist=sequence.split(
'+')
1671 from Configuration.Skimming.autoSkim
import autoSkim
1675 for skim
in skimConfig.__dict__:
1676 skimstream = getattr(skimConfig,skim)
1677 if isinstance(skimstream,cms.Path):
1679 self.blacklist_paths.append(skimstream)
1680 if (
not isinstance(skimstream,cms.FilteredStream)):
1682 shortname = skim.replace(
'SKIMStream',
'')
1683 if (sequence==
"all"):
1685 elif (shortname
in skimlist):
1688 if self._options.datatier==
'DQM':
1689 self.process.load(self.EVTCONTDefaultCFF)
1690 skimstreamDQM = cms.FilteredStream(
1691 responsible = skimstream.responsible,
1692 name = skimstream.name+
'DQM',
1693 paths = skimstream.paths,
1694 selectEvents = skimstream.selectEvents,
1695 content = self._options.datatier+
'EventContent',
1696 dataTier = cms.untracked.string(self._options.datatier)
1699 for i
in range(skimlist.count(shortname)):
1700 skimlist.remove(shortname)
1704 if (skimlist.__len__()!=0
and sequence!=
"all"):
1705 print 'WARNING, possible typo with SKIM:'+
'+'.
join(skimlist)
1706 raise Exception(
'WARNING, possible typo with SKIM:'+
'+'.
join(skimlist))
1709 ''' Enrich the schedule with a user defined sequence '''
1715 """ Enrich the schedule with the postreco step """
1722 print sequence,
"in preparing validation"
1724 from Validation.Configuration.autoValidation
import autoValidation
1726 sequence=sequence.split(
'.')[-1]
1727 if sequence.find(
',')!=-1:
1728 prevalSeqName=sequence.split(
',')[0].
split(
'+')
1729 valSeqName=sequence.split(
',')[1].
split(
'+')
1734 prevalSeqName=sequence.split(
'+')
1735 valSeqName=sequence.split(
'+')
1741 postfix=
'_'+sequence
1742 prevalSeqName=[
'prevalidation'+postfix]
1743 valSeqName=[
'validation'+postfix]
1744 if not hasattr(self.process,valSeqName[0]):
1746 valSeqName=[sequence]
1755 if not 'DIGI' in self.stepMap
and not self._options.fast
and not any(
map(
lambda s : s.startswith(
'genvalid'), valSeqName)):
1756 if self._options.restoreRNDSeeds==
False and not self._options.restoreRNDSeeds==
True:
1757 self._options.restoreRNDSeeds=
True
1760 if (
'HLT' in self.stepMap
and not self._options.fast)
or self._options.hltProcess:
1761 for s
in valSeqName+prevalSeqName:
1764 for (i,s)
in enumerate(prevalSeqName):
1766 setattr(self.process,
'prevalidation_step%s'%NFI(i), cms.Path( getattr(self.process, s)) )
1767 self.schedule.append(getattr(self.process,
'prevalidation_step%s'%NFI(i)))
1769 for (i,s)
in enumerate(valSeqName):
1770 setattr(self.process,
'validation_step%s'%NFI(i), cms.EndPath( getattr(self.process, s)))
1771 self.schedule.append(getattr(self.process,
'validation_step%s'%NFI(i)))
1773 if not 'DIGI' in self.stepMap
and not self._options.fast:
1777 self._options.customisation_file.append(
"SimGeneral/MixingModule/fullMixCustomize_cff.setCrossingFrameOn")
1779 if hasattr(self.process,
"genstepfilter")
and len(self.process.genstepfilter.triggerConditions):
1781 for (i,s)
in enumerate(valSeqName):
1782 getattr(self.process,
'validation_step%s'%NFI(i))._seq = self.process.genstepfilter * getattr(self.process,
'validation_step%s'%NFI(i))._seq
1788 """Visitor that travels within a cms.Sequence, looks for a parameter and replace its value
1789 It will climb down within PSets, VPSets and VInputTags to find its target"""
1790 def __init__(self, paramSearch, paramReplace, verbose=False, whitelist=()):
1797 if isinstance(pset, cms._Parameterizable):
1798 for name
in pset.parameters_().
keys():
1804 value = getattr(pset,name)
1805 type = value.pythonTypeName()
1806 if type
in (
'cms.PSet',
'cms.untracked.PSet'):
1807 self.
doIt(value,base+
"."+name)
1808 elif type
in (
'cms.VPSet',
'cms.untracked.VPSet'):
1809 for (i,ps)
in enumerate(value): self.
doIt(ps,
"%s.%s[%d]"%(base,name,i) )
1810 elif type
in (
'cms.string',
'cms.untracked.string'):
1812 if self.
_verbose:
print "set string process name %s.%s %s ==> %s"% (base, name, value, self.
_paramReplace)
1814 elif type
in (
'cms.VInputTag',
'cms.untracked.VInputTag'):
1815 for (i,n)
in enumerate(value):
1816 if not isinstance(n, cms.InputTag):
1820 if self.
_verbose:
print "set process name %s.%s[%d] %s ==> %s " % (base, name, i, n, self.
_paramReplace)
1823 elif type
in (
'cms.vstring',
'cms.untracked.vstring'):
1824 for (i,n)
in enumerate(value):
1827 elif type
in (
'cms.InputTag',
'cms.untracked.InputTag'):
1829 if self.
_verbose:
print "set process name %s.%s %s ==> %s " % (base, name, value, self.
_paramReplace)
1830 setattr(getattr(pset, name),
"processName",self.
_paramReplace)
1835 label = visitee.label()
1836 except AttributeError:
1837 label =
'<Module not in a Process>'
1839 label =
'other execption'
1840 self.
doIt(visitee, label)
1847 print "Replacing all InputTag %s => %s"%(oldT,newT)
1850 loadMe=
'from PhysicsTools.PatAlgos.tools.helpers import massSearchReplaceAnyInputTag'
1851 if not loadMe
in self.additionalCommands:
1852 self.additionalCommands.append(loadMe)
1853 self.additionalCommands.append(
'massSearchReplaceAnyInputTag(process.%s,"%s","%s",False,True)'%(sequence,oldT,newT))
1857 if self._options.hltProcess:
1858 proc=self._options.hltProcess
1860 proc=self.process.name_()
1861 if proc==HLTprocess:
return
1863 print "replacing %s process name - sequence %s will use '%s'" % (HLTprocess,sequence, proc)
1865 if 'from Configuration.Applications.ConfigBuilder import ConfigBuilder' not in self.additionalCommands:
1866 self.additionalCommands.append(
'from Configuration.Applications.ConfigBuilder import ConfigBuilder')
1867 self.additionalCommands.append(
'process.%s.visit(ConfigBuilder.MassSearchReplaceProcessNameVisitor("%s", "%s", whitelist = ("subSystemFolder",)))'% (sequence,HLTprocess, proc))
1873 while '@' in repr(seqList)
and level<maxLevel:
1875 for specifiedCommand
in seqList:
1876 if specifiedCommand.startswith(
'@'):
1877 location=specifiedCommand[1:]
1878 if not location
in mapping:
1879 raise Exception(
"Impossible to map "+location+
" from "+repr(mapping))
1880 mappedTo=mapping[location]
1882 mappedTo=mappedTo[index]
1883 seqList.remove(specifiedCommand)
1884 seqList.extend(mappedTo.split(
'+'))
1887 raise Exception(
"Could not fully expand "+repr(seqList)+
" from "+repr(mapping))
1893 sequenceList=sequence.split(
'.')[-1].
split(
'+')
1894 from DQMOffline.Configuration.autoDQM
import autoDQM
1897 if len(set(sequenceList))!=len(sequenceList):
1898 sequenceList=
list(set(sequenceList))
1899 print "Duplicate entries for DQM:, using",sequenceList
1900 pathName=
'dqmoffline_step'
1902 for (i,sequence)
in enumerate(sequenceList):
1904 pathName=
'dqmoffline_%d_step'%(i)
1906 if 'HLT' in self.stepMap.keys()
or self._options.hltProcess:
1910 if 'HLT' in self.stepMap.keys():
1912 setattr(self.process,pathName, cms.EndPath( getattr(self.process, sequence ) ) )
1915 setattr(self.process,pathName, cms.Path( getattr(self.process, sequence) ) )
1916 self.schedule.append(getattr(self.process,pathName))
1920 """ Enrich the process with harvesting step """
1921 self.
EDMtoMECFF=
'Configuration/StandardSequences/EDMtoME'+self._options.harvesting+
'_cff'
1926 sequence = sequence.split(
'.')[-1]
1929 harvestingList = sequence.split(
"+")
1930 from DQMOffline.Configuration.autoDQM
import autoDQM
1931 from Validation.Configuration.autoValidation
import autoValidation
1933 combined_mapping = copy.deepcopy( autoDQM )
1934 combined_mapping.update( autoValidation )
1935 self.
expandMapping(harvestingList,combined_mapping,index=-1)
1937 if len(set(harvestingList))!=len(harvestingList):
1938 harvestingList=
list(set(harvestingList))
1939 print "Duplicate entries for HARVESTING, using",harvestingList
1941 for name
in harvestingList:
1942 if not name
in harvestingConfig.__dict__:
1943 print name,
"is not a possible harvesting type. Available are",harvestingConfig.__dict__.keys()
1945 harvestingstream = getattr(harvestingConfig,name)
1946 if isinstance(harvestingstream,cms.Path):
1947 self.schedule.append(harvestingstream)
1948 self.blacklist_paths.append(harvestingstream)
1949 if isinstance(harvestingstream,cms.Sequence):
1950 setattr(self.process,name+
"_step",cms.Path(harvestingstream))
1951 self.schedule.append(getattr(self.process,name+
"_step"))
1957 """ Enrich the process with AlCaHarvesting step """
1959 sequence=sequence.split(
".")[-1]
1962 harvestingList = sequence.split(
"+")
1963 for name
in harvestingConfig.__dict__:
1964 harvestingstream = getattr(harvestingConfig,name)
1965 if name
in harvestingList
and isinstance(harvestingstream,cms.Path):
1966 self.schedule.append(harvestingstream)
1967 self.
executeAndRemember(
"process.PoolDBOutputService.toPut.append(process.ALCAHARVEST" + name +
"_dbOutput)")
1968 self.
executeAndRemember(
"process.pclMetadataWriter.recordsToMap.append(process.ALCAHARVEST" + name +
"_metadata)")
1969 harvestingList.remove(name)
1971 lastStep = getattr(harvestingConfig,
"ALCAHARVESTDQMSaveAndMetadataWriter")
1972 self.schedule.append(lastStep)
1974 if len(harvestingList) != 0
and 'dummyHarvesting' not in harvestingList :
1975 print "The following harvesting could not be found : ", harvestingList
1976 raise Exception(
"The following harvesting could not be found : "+str(harvestingList))
1986 self.process.reconstruction = cms.Path(self.process.reconstructionWithFamos)
1987 self.schedule.append(self.process.reconstruction)
1990 """Enrich the schedule with fastsim"""
1991 self.
loadAndRemember(
"FastSimulation/Configuration/FamosSequences_cff")
1993 if sequence
in (
'all',
'allWithHLTFiltering',
''):
1994 if not 'HLT' in self.stepMap.keys():
2000 self.
executeAndRemember(
"process.simulation = cms.Sequence(process.simulationWithFamos)")
2001 self.
executeAndRemember(
"process.HLTEndSequence = cms.Sequence(process.reconstructionWithFamos)")
2004 self._options.name =
"HLT"
2007 if sequence ==
'all' and not 'HLT' in self.stepMap.keys():
2009 elif sequence ==
'sim':
2013 self.
executeAndRemember(
"process.simulation = cms.Sequence(process.simulationWithFamos)")
2015 self.process.fastsim_step = cms.Path( getattr(self.process,
"simulationWithFamos") )
2016 self.schedule.append(self.process.fastsim_step)
2017 elif sequence ==
'reco':
2019 self.
executeAndRemember(
"process.reconstruction = cms.Sequence(process.reconstructionWithFamos)")
2021 self.process.fastsim_step = cms.Path( getattr(self.process,
"reconstructionWithFamos") )
2022 self.schedule.append(self.process.fastsim_step)
2023 elif sequence ==
'simExtended':
2027 self.
executeAndRemember(
"process.simulation = cms.Sequence(process.simulationWithSomeReconstruction)")
2029 self.process.fastsim_step = cms.Path( getattr(self.process,
"simulationWithSomeReconstruction") )
2030 self.schedule.append(self.process.fastsim_step)
2031 elif sequence ==
'recoHighLevel':
2033 self.
executeAndRemember(
"process.reconstruction = cms.Sequence(process.reconstructionHighLevel)")
2035 self.process.fastsim_step = cms.Path( getattr(self.process,
"reconstructionHighLevel") )
2036 self.schedule.append(self.process.fastsim_step)
2037 elif sequence ==
'famosWithEverything':
2038 self.process.fastsim_step = cms.Path( getattr(self.process,
"famosWithEverything") )
2039 self.schedule.append(self.process.fastsim_step)
2042 self.
executeAndRemember(
"process.VolumeBasedMagneticFieldESProducer.useParametrizedTrackerField = True")
2044 print "FastSim setting", sequence,
"unknown."
2047 if 'Flat' in self._options.beamspot:
2048 beamspotType =
'Flat'
2049 elif 'Gauss' in self._options.beamspot:
2050 beamspotType =
'Gaussian'
2052 beamspotType =
'BetaFunc'
2053 self.
loadAndRemember(
'IOMC.EventVertexGenerators.VtxSmearedParameters_cfi')
2054 beamspotName =
'process.%sVtxSmearingParameters' %(self._options.beamspot)
2057 if hasattr(self.process,
'famosPileUp'):
2063 """ Add useful info for the production. """
2064 self.process.configurationMetadata=cms.untracked.PSet\
2065 (version=cms.untracked.string(
"$Revision: 1.19 $"),
2066 name=cms.untracked.string(
"Applications"),
2067 annotation=cms.untracked.string(evt_type+
" nevts:"+str(evtnumber))
2070 self.addedObjects.append((
"Production Info",
"configurationMetadata"))
2074 """ Prepare the configuration string and add missing pieces."""
2086 outputModuleCfgCode=
""
2087 if not 'HARVESTING' in self.stepMap.keys()
and not 'SKIM' in self.stepMap.keys()
and not 'ALCAHARVEST' in self.stepMap.keys()
and not 'ALCAOUTPUT' in self.stepMap.keys()
and self.with_output:
2092 self.pythonCfgCode =
"# Auto generated configuration file\n"
2093 self.pythonCfgCode +=
"# using: \n# "+__version__[1:-1]+
"\n# "+__source__[1:-1]+
'\n'
2094 self.pythonCfgCode +=
"# with command line options: "+self._options.arguments+
'\n'
2095 self.pythonCfgCode +=
"import FWCore.ParameterSet.Config as cms\n\n"
2096 self.pythonCfgCode +=
"process = cms.Process('"+self.process.name_()+
"')\n\n"
2098 self.pythonCfgCode +=
"# import of standard configurations\n"
2099 for module
in self.imports:
2100 self.pythonCfgCode += (
"process.load('"+module+
"')\n")
2103 if not hasattr(self.process,
"configurationMetadata"):
2107 self.addedObjects.append((
"Production Info",
"configurationMetadata"))
2109 self.pythonCfgCode +=
"\n"
2110 for comment,object
in self.addedObjects:
2112 self.pythonCfgCode +=
"\n# "+comment+
"\n"
2113 self.pythonCfgCode +=
dumpPython(self.process,object)
2116 self.pythonCfgCode +=
"\n# Output definition\n"
2117 self.pythonCfgCode += outputModuleCfgCode
2120 self.pythonCfgCode +=
"\n# Additional output definition\n"
2122 nl=self.additionalOutputs.keys()
2125 output = self.additionalOutputs[name]
2126 self.pythonCfgCode +=
"process.%s = %s" %(name, output.dumpPython())
2127 tmpOut = cms.EndPath(output)
2128 setattr(self.process,name+
'OutPath',tmpOut)
2129 self.schedule.append(tmpOut)
2132 self.pythonCfgCode +=
"\n# Other statements\n"
2133 for command
in self.additionalCommands:
2134 self.pythonCfgCode += command +
"\n"
2137 for object
in self._options.inlineObjets.split(
','):
2140 if not hasattr(self.process,object):
2141 print 'cannot inline -'+object+
'- : not known'
2143 self.pythonCfgCode +=
'\n'
2144 self.pythonCfgCode +=
dumpPython(self.process,object)
2147 self.pythonCfgCode +=
"\n# Path and EndPath definitions\n"
2148 for path
in self.process.paths:
2149 if getattr(self.process,path)
not in self.blacklist_paths:
2150 self.pythonCfgCode +=
dumpPython(self.process,path)
2152 for endpath
in self.process.endpaths:
2153 if getattr(self.process,endpath)
not in self.blacklist_paths:
2154 self.pythonCfgCode +=
dumpPython(self.process,endpath)
2157 if not self._options.runUnscheduled:
2158 self.pythonCfgCode +=
"\n# Schedule definition\n"
2159 result =
"process.schedule = cms.Schedule("
2162 self.process.schedule = cms.Schedule()
2163 for item
in self.schedule:
2164 if not isinstance(item, cms.Schedule):
2165 self.process.schedule.append(item)
2167 self.process.schedule.extend(item)
2169 if hasattr(self.process,
"HLTSchedule"):
2170 beforeHLT = self.schedule[:self.schedule.index(self.process.HLTSchedule)]
2171 afterHLT = self.schedule[self.schedule.index(self.process.HLTSchedule)+1:]
2172 pathNames = [
'process.'+p.label_()
for p
in beforeHLT]
2173 result +=
','.
join(pathNames)+
')\n'
2174 result +=
'process.schedule.extend(process.HLTSchedule)\n'
2175 pathNames = [
'process.'+p.label_()
for p
in afterHLT]
2176 result +=
'process.schedule.extend(['+
','.
join(pathNames)+
'])\n'
2178 pathNames = [
'process.'+p.label_()
for p
in self.schedule]
2179 result =
'process.schedule = cms.Schedule('+
','.
join(pathNames)+
')\n'
2181 self.pythonCfgCode += result
2184 if self._options.isRepacked:
2185 self.pythonCfgCode +=
"\n"
2186 self.pythonCfgCode +=
"from Configuration.Applications.ConfigBuilder import MassReplaceInputTag\n"
2187 self.pythonCfgCode +=
"MassReplaceInputTag(process)\n"
2191 if self.productionFilterSequence:
2192 self.pythonCfgCode +=
'# filter all path with the production filter sequence\n'
2193 self.pythonCfgCode +=
'for path in process.paths:\n'
2194 if len(self.conditionalPaths):
2195 self.pythonCfgCode +=
'\tif not path in %s: continue\n'%str(self.conditionalPaths)
2196 if len(self.excludedPaths):
2197 self.pythonCfgCode +=
'\tif path in %s: continue\n'%str(self.excludedPaths)
2198 self.pythonCfgCode +=
'\tgetattr(process,path)._seq = process.%s * getattr(process,path)._seq \n'%(self.productionFilterSequence,)
2199 pfs = getattr(self.process,self.productionFilterSequence)
2200 for path
in self.process.paths:
2201 if not path
in self.conditionalPaths:
continue
2202 if path
in self.excludedPaths:
continue
2203 getattr(self.process,path)._seq = pfs * getattr(self.process,path)._seq
2209 if self._options.runUnscheduled:
2212 self.pythonCfgCode+=
"#do not add changes to your config after this point (unless you know what you are doing)\n"
2213 self.pythonCfgCode+=
"from FWCore.ParameterSet.Utilities import convertToUnscheduled\n"
2215 self.pythonCfgCode+=
"process=convertToUnscheduled(process)\n"
2218 for module
in self.importsUnsch:
2219 self.process.load(module)
2220 self.pythonCfgCode += (
"process.load('"+module+
"')\n")
2227 if self._options.io:
2229 if not self._options.io.endswith(
'.io'): self._option.io+=
'.io'
2230 io=open(self._options.io,
'w')
2232 if hasattr(self.process.source,
"fileNames"):
2233 if len(self.process.source.fileNames.value()):
2234 ioJson[
'primary']=self.process.source.fileNames.value()
2235 if hasattr(self.process.source,
"secondaryFileNames"):
2236 if len(self.process.source.secondaryFileNames.value()):
2237 ioJson[
'secondary']=self.process.source.secondaryFileNames.value()
2238 if self._options.pileup_input
and (self._options.pileup_input.startswith(
'dbs:')
or self._options.pileup_input.startswith(
'das:')):
2239 ioJson[
'pileup']=self._options.pileup_input[4:]
2240 for (o,om)
in self.process.outputModules_().items():
2241 ioJson[o]=om.fileName.value()
2242 ioJson[
'GT']=self.process.GlobalTag.globaltag.value()
2243 if self.productionFilterSequence:
2244 ioJson[
'filter']=self.productionFilterSequence
2246 io.write(json.dumps(ioJson))
def renameInputTagsInSequence
bool any(const std::vector< T > &v, const T &what)
def scheduleSequenceAtEnd
def visit
Retrieve data from a perf suite output (sub) directory, only examines TimeSize at the moment...
def prepare_RECO
put the filtering path in the schedule
def doNotInlineEventContent
def massSearchReplaceAnyInputTag
def build_production_info
def prepare_L1TrackTrigger
print it in the configuration
inliner
needs to be in reverse order
static std::string join(char **cmd)
def loadDefaultOrSpecifiedCFF
def prepare_DIGIPREMIX_S2
def renameHLTprocessInSequence
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run