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
11 import FWCore.ParameterSet.DictTypes
as DictTypes
16 defaultOptions = Options()
17 defaultOptions.datamix =
'DataOnSim'
18 defaultOptions.isMC=
False
19 defaultOptions.isData=
True
20 defaultOptions.step=
''
21 defaultOptions.pileup=
'NoPileUp'
22 defaultOptions.pileup_input =
None
23 defaultOptions.geometry =
'SimDB'
24 defaultOptions.geometryExtendedOptions = [
'ExtendedGFlash',
'Extended',
'NoCastor']
25 defaultOptions.magField =
''
26 defaultOptions.conditions =
None
27 defaultOptions.useCondDBv1 =
False
28 defaultOptions.scenarioOptions=[
'pp',
'cosmics',
'nocoll',
'HeavyIons']
29 defaultOptions.harvesting=
'AtRunEnd'
30 defaultOptions.gflash =
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
79 defaultOptions.nThreads =
'1'
83 theObject = getattr(process,name)
84 if isinstance(theObject,cms.Path)
or isinstance(theObject,cms.EndPath)
or isinstance(theObject,cms.Sequence):
85 return "process."+name+
" = " + theObject.dumpPython(
"process")
86 elif isinstance(theObject,_Module)
or isinstance(theObject,cms.ESProducer):
87 return "process."+name+
" = " + theObject.dumpPython()+
"\n"
89 return "process."+name+
" = " + theObject.dumpPython()+
"\n"
95 for line
in open(fileName,
'r'):
96 if line.count(
".root")>=2:
98 entries=line.replace(
"\n",
"").
split()
99 if not entries[0]
in prim:
100 prim.append(entries[0])
101 if not entries[1]
in sec:
102 sec.append(entries[1])
103 elif (line.find(
".root")!=-1):
104 entry=line.replace(
"\n",
"")
105 if not entry
in prim:
108 if not hasattr(s,
"fileNames"):
109 s.fileNames=cms.untracked.vstring(prim)
111 s.fileNames.extend(prim)
113 if not hasattr(s,
"secondaryFileNames"):
114 s.secondaryFileNames=cms.untracked.vstring(sec)
116 s.secondaryFileNames.extend(sec)
117 print "found files: ",prim
119 raise Exception(
"There are not files in input from the file list")
121 print "found parent files:",sec
129 print "the query is",query
130 for line
in os.popen(
'das_client.py --query "%s"'%(query)):
131 if line.count(
".root")>=2:
133 entries=line.replace(
"\n",
"").
split()
134 if not entries[0]
in prim:
135 prim.append(entries[0])
136 if not entries[1]
in sec:
137 sec.append(entries[1])
138 elif (line.find(
".root")!=-1):
139 entry=line.replace(
"\n",
"")
140 if not entry
in prim:
143 if not hasattr(s,
"fileNames"):
144 s.fileNames=cms.untracked.vstring(prim)
146 s.fileNames.extend(prim)
148 if not hasattr(s,
"secondaryFileNames"):
149 s.secondaryFileNames=cms.untracked.vstring(sec)
151 s.secondaryFileNames.extend(sec)
152 print "found files: ",prim
154 print "found parent files:",sec
159 for s
in aProcess.paths_().
keys():
162 def anyOf(listOfKeys,dict,opt=None):
171 raise Exception(
"any of "+
','.
join(listOfKeys)+
" are mandatory entries of --output options")
174 """The main building routines """
176 def __init__(self, options, process = None, with_output = False, with_input = False ):
177 """options taken from old cmsDriver and optparse """
179 options.outfile_name = options.dirout+options.fileout
183 if self._options.isData
and options.isMC:
184 raise Exception(
"ERROR: You may specify only --data or --mc, not both")
189 if 'ENDJOB' in self._options.step:
190 if (hasattr(self.
_options,
"outputDefinition")
and \
191 self._options.outputDefinition !=
'' and \
192 any(
anyOf([
't',
'tier',
'dataTier'],outdic) ==
'DQMIO' for outdic
in eval(self._options.outputDefinition)))
or \
193 (hasattr(self.
_options,
"datatier")
and \
194 self._options.datatier
and \
195 'DQMIO' in self._options.datatier):
196 print "removing ENDJOB from steps since not compatible with DQMIO dataTier"
197 self._options.step=self._options.step.replace(
',ENDJOB',
'')
202 stepList = [re.sub(
r'^prepare_',
'', methodName)
for methodName
in ConfigBuilder.__dict__
if methodName.startswith(
'prepare_')]
205 for step
in self._options.step.split(
","):
206 if step==
'':
continue
207 stepParts = step.split(
":")
208 stepName = stepParts[0]
209 if stepName
not in stepList
and not stepName.startswith(
're'):
210 raise ValueError(
"Step "+stepName+
" unknown")
211 if len(stepParts)==1:
212 self.stepMap[stepName]=
""
213 elif len(stepParts)==2:
214 self.stepMap[stepName]=stepParts[1].
split(
'+')
215 elif len(stepParts)==3:
216 self.stepMap[stepName]=(stepParts[2].
split(
'+'),stepParts[1])
218 raise ValueError(
"Step definition "+step+
" invalid")
219 self.stepKeys.append(stepName)
223 self.with_output = with_output
224 if hasattr(self.
_options,
"no_output_flag")
and self._options.no_output_flag:
225 self.with_output =
False
226 self.with_input = with_input
228 self.process = cms.Process(self._options.name)
230 self.process = process
232 self.importsUnsch = []
234 self.schedule =
list()
240 self.additionalCommands = []
242 self.blacklist_paths = []
243 self.addedObjects = []
244 self.additionalOutputs = {}
246 self.productionFilterSequence =
None
247 self.nextScheduleIsConditional=
False
248 self.conditionalPaths=[]
249 self.excludedPaths=[]
254 Function to add the igprof profile service so that you can dump in the middle
257 profileOpts = self._options.profile.split(
':')
259 profilerInterval = 100
260 profilerFormat =
None
261 profilerJobFormat =
None
267 startEvent = profileOpts.pop(0)
268 if not startEvent.isdigit():
269 raise Exception(
"%s is not a number" % startEvent)
270 profilerStart = int(startEvent)
272 eventInterval = profileOpts.pop(0)
273 if not eventInterval.isdigit():
274 raise Exception(
"%s is not a number" % eventInterval)
275 profilerInterval = int(eventInterval)
277 profilerFormat = profileOpts.pop(0)
280 if not profilerFormat:
281 profilerFormat =
"%s___%s___%s___%s___%s___%s___%%I.gz" % (self._options.evt_type.replace(
"_cfi",
""),
283 self._options.pileup,
284 self._options.conditions,
285 self._options.datatier,
286 self._options.profileTypeLabel)
287 if not profilerJobFormat
and profilerFormat.endswith(
".gz"):
288 profilerJobFormat = profilerFormat.replace(
".gz",
"_EndOfJob.gz")
289 elif not profilerJobFormat:
290 profilerJobFormat = profilerFormat +
"_EndOfJob.gz"
292 return (profilerStart,profilerInterval,profilerFormat,profilerJobFormat)
295 includeFile = includeFile.replace(
'/',
'.')
296 self.process.load(includeFile)
297 return sys.modules[includeFile]
300 """helper routine to load am memorize imports"""
303 includeFile = includeFile.replace(
'/',
'.')
305 self.imports.append(includeFile)
306 self.process.load(includeFile)
307 return sys.modules[includeFile]
309 self.importsUnsch.append(includeFile)
313 """helper routine to remember replace statements"""
314 self.additionalCommands.append(command)
315 if not command.strip().startswith(
"#"):
318 exec(re.sub(
r"([^a-zA-Z_0-9]|^)(process)([^a-zA-Z_0-9])",
r"\1self.process\3",command))
322 if 'HARVESTING' in self.stepMap.keys()
or 'ALCAHARVEST' in self.stepMap.keys():
323 self.process.options = cms.untracked.PSet( Rethrow = cms.untracked.vstring(
'ProductNotFound'),fileMode = cms.untracked.string(
'FULLMERGE'))
325 self.process.options = cms.untracked.PSet( )
327 if self._options.runUnscheduled:
328 self.process.options.allowUnscheduled=cms.untracked.bool(
True)
330 self.addedObjects.append((
"",
"options"))
332 if self._options.lazy_download:
333 self.process.AdaptorConfig = cms.Service(
"AdaptorConfig",
334 stats = cms.untracked.bool(
True),
335 enable = cms.untracked.bool(
True),
336 cacheHint = cms.untracked.string(
"lazy-download"),
337 readHint = cms.untracked.string(
"read-ahead-buffered")
339 self.addedObjects.append((
"Setup lazy download",
"AdaptorConfig"))
344 if self._options.profile:
346 self.process.IgProfService = cms.Service(
"IgProfService",
347 reportFirstEvent = cms.untracked.int32(start),
348 reportEventInterval = cms.untracked.int32(interval),
349 reportToFileAtPostEvent = cms.untracked.string(
"| gzip -c > %s"%(eventFormat)),
350 reportToFileAtPostEndJob = cms.untracked.string(
"| gzip -c > %s"%(jobFormat)))
351 self.addedObjects.append((
"Setup IGProf Service for profiling",
"IgProfService"))
354 """Here we decide how many evts will be processed"""
355 self.process.maxEvents=cms.untracked.PSet(input=cms.untracked.int32(int(self._options.number)))
356 if self._options.number_out:
357 self.process.maxEvents.output = cms.untracked.int32(int(self._options.number_out))
358 self.addedObjects.append((
"",
"maxEvents"))
361 """Here the source is built. Priority: file, generator"""
362 self.addedObjects.append((
"Input source",
"source"))
365 for entry
in self._options.filein.split(
','):
367 if entry.startswith(
"filelist:"):
369 elif entry.startswith(
"dbs:")
or entry.startswith(
"das:"):
372 self.process.source.fileNames.append(self._options.dirin+entry)
373 if self._options.secondfilein:
374 if not hasattr(self.process.source,
"secondaryFileNames"):
375 raise Exception(
"--secondfilein not compatible with "+self._options.filetype+
"input type")
376 for entry
in self._options.secondfilein.split(
','):
378 if entry.startswith(
"filelist:"):
379 self.process.source.secondaryFileNames.extend((
filesFromList(entry[9:]))[0])
380 elif entry.startswith(
"dbs:")
or entry.startswith(
"das:"):
381 self.process.source.secondaryFileNames.extend((
filesFromDASQuery(
'file dataset = %s'%(entry[4:])))[0])
383 self.process.source.secondaryFileNames.append(self._options.dirin+entry)
385 if self._options.filein
or self._options.dasquery:
386 if self._options.filetype ==
"EDM":
387 self.process.source=cms.Source(
"PoolSource",
388 fileNames = cms.untracked.vstring(),
389 secondaryFileNames= cms.untracked.vstring())
391 elif self._options.filetype ==
"DAT":
392 self.process.source=cms.Source(
"NewEventStreamFileReader",fileNames = cms.untracked.vstring())
394 elif self._options.filetype ==
"LHE":
395 self.process.source=cms.Source(
"LHESource", fileNames = cms.untracked.vstring())
396 if self._options.filein.startswith(
"lhe:"):
398 args=self._options.filein.split(
':')
400 print 'LHE input from article ',article
401 location=
'/store/lhe/'
403 textOfFiles=os.popen(
'cmsLHEtoEOSManager.py -l '+article)
404 for line
in textOfFiles:
405 for fileName
in [x
for x
in line.split()
if '.lhe' in x]:
406 self.process.source.fileNames.append(location+article+
'/'+fileName)
408 self.process.source.skipEvents = cms.untracked.uint32(int(args[2]))
413 elif self._options.filetype ==
"DQM":
414 self.process.source=cms.Source(
"DQMRootSource",
415 fileNames = cms.untracked.vstring())
418 elif self._options.filetype ==
"DQMDAQ":
420 self.process.source=cms.Source(
"DQMStreamerReader")
423 if (
'HARVESTING' in self.stepMap.keys()
or 'ALCAHARVEST' in self.stepMap.keys())
and (
not self._options.filetype ==
"DQM"):
424 self.process.source.processingMode = cms.untracked.string(
"RunsAndLumis")
426 if self._options.dasquery!=
'':
427 self.process.source=cms.Source(
"PoolSource", fileNames = cms.untracked.vstring(),secondaryFileNames = cms.untracked.vstring())
431 if 'GEN' in self.stepMap.keys():
432 if self._options.inputCommands:
433 self._options.inputCommands+=
',drop LHEXMLStringProduct_*_*_*,'
435 self._options.inputCommands=
'keep *, drop LHEXMLStringProduct_*_*_*,'
437 if self.process.source
and self._options.inputCommands:
438 if not hasattr(self.process.source,
'inputCommands'): self.process.source.inputCommands=cms.untracked.vstring()
439 for command
in self._options.inputCommands.split(
','):
441 command = command.strip()
442 if command==
'':
continue
443 self.process.source.inputCommands.append(command)
444 if not self._options.dropDescendant:
445 self.process.source.dropDescendantsOfDroppedBranches = cms.untracked.bool(
False)
447 if self._options.lumiToProcess:
448 import FWCore.PythonUtilities.LumiList
as LumiList
449 self.process.source.lumisToProcess = cms.untracked.VLuminosityBlockRange(
LumiList.LumiList(self._options.lumiToProcess).getCMSSWString().
split(
',') )
451 if 'GEN' in self.stepMap.keys()
or 'LHE' in self.stepMap
or (
not self._options.filein
and hasattr(self.
_options,
"evt_type")):
452 if self.process.source
is None:
453 self.process.source=cms.Source(
"EmptySource")
456 self.runsAndWeights=
None
457 if self._options.runsAndWeightsForMC
or self._options.runsScenarioForMC :
458 if not self._options.isMC :
459 raise Exception(
"options --runsAndWeightsForMC and --runsScenarioForMC are only valid for MC")
460 if self._options.runsAndWeightsForMC:
461 self.runsAndWeights = eval(self._options.runsAndWeightsForMC)
463 from Configuration.StandardSequences.RunsAndWeights
import RunsAndWeights
464 if type(RunsAndWeights[self._options.runsScenarioForMC])==str:
465 __import__(RunsAndWeights[self._options.runsScenarioForMC])
466 self.runsAndWeights = sys.modules[RunsAndWeights[self._options.runsScenarioForMC]].runProbabilityDistribution
468 self.runsAndWeights = RunsAndWeights[self._options.runsScenarioForMC]
470 if self.runsAndWeights:
471 import SimGeneral.Configuration.ThrowAndSetRandomRun
as ThrowAndSetRandomRun
473 self.additionalCommands.append(
'import SimGeneral.Configuration.ThrowAndSetRandomRun as ThrowAndSetRandomRun')
474 self.additionalCommands.append(
'ThrowAndSetRandomRun.throwAndSetRandomRun(process.source,%s)'%(self.runsAndWeights))
479 """ Add output module to the process """
481 if self._options.outputDefinition:
482 if self._options.datatier:
483 print "--datatier & --eventcontent options ignored"
486 outList = eval(self._options.outputDefinition)
487 for (id,outDefDict)
in enumerate(outList):
488 outDefDictStr=outDefDict.__str__()
489 if not isinstance(outDefDict,dict):
490 raise Exception(
"--output needs to be passed a list of dict"+self._options.outputDefinition+
" is invalid")
492 theTier=
anyOf([
't',
'tier',
'dataTier'],outDefDict)
495 theStreamType=
anyOf([
'e',
'ec',
'eventContent',
'streamType'],outDefDict,theTier)
496 theFilterName=
anyOf([
'f',
'ftN',
'filterName'],outDefDict,
'')
497 theSelectEvent=
anyOf([
's',
'sE',
'selectEvents'],outDefDict,
'')
498 theModuleLabel=
anyOf([
'l',
'mL',
'moduleLabel'],outDefDict,
'')
499 theExtraOutputCommands=
anyOf([
'o',
'oC',
'outputCommands'],outDefDict,
'')
501 if not theModuleLabel:
502 tryNames=[theStreamType.replace(theTier.replace(
'-',
''),
'')+theTier.replace(
'-',
'')+
'output',
503 theStreamType.replace(theTier.replace(
'-',
''),
'')+theTier.replace(
'-',
'')+theFilterName+
'output',
504 theStreamType.replace(theTier.replace(
'-',
''),
'')+theTier.replace(
'-',
'')+theFilterName+theSelectEvent.split(
',')[0].
replace(
':',
'for').
replace(
' ',
'')+
'output'
506 for name
in tryNames:
507 if not hasattr(self.process,name):
510 if not theModuleLabel:
511 raise Exception(
"cannot find a module label for specification: "+outDefDictStr)
513 defaultFileName=self._options.outfile_name
515 defaultFileName=self._options.outfile_name.replace(
'.root',
'_in'+theTier+
'.root')
517 theFileName=self._options.dirout+
anyOf([
'fn',
'fileName'],outDefDict,defaultFileName)
518 if not theFileName.endswith(
'.root'):
521 if len(outDefDict.keys()):
522 raise Exception(
"unused keys from --output options: "+
','.
join(outDefDict.keys()))
523 if theStreamType==
'DQMIO': theStreamType=
'DQM'
524 if theStreamType==
'ALL':
525 theEventContent = cms.PSet(outputCommands = cms.untracked.vstring(
'keep *'))
527 theEventContent = getattr(self.process, theStreamType+
"EventContent")
531 if theStreamType==
'ALCARECO' and not theFilterName:
532 theFilterName=
'StreamALCACombined'
535 CppType=
'PoolOutputModule'
536 if self._options.timeoutOutput:
537 CppType=
'TimeoutPoolOutputModule'
538 if theStreamType==
'DQM' and theTier==
'DQMIO': CppType=
'DQMRootOutputModule'
539 output = cms.OutputModule(CppType,
540 theEventContent.clone(),
541 fileName = cms.untracked.string(theFileName),
542 dataset = cms.untracked.PSet(
543 dataTier = cms.untracked.string(theTier),
544 filterName = cms.untracked.string(theFilterName))
546 if not theSelectEvent
and hasattr(self.process,
'generation_step')
and theStreamType!=
'LHE':
547 output.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
'generation_step'))
548 if not theSelectEvent
and hasattr(self.process,
'filtering_step'):
549 output.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
'filtering_step'))
551 output.SelectEvents =cms.untracked.PSet(SelectEvents = cms.vstring(theSelectEvent))
554 if not hasattr(output,
'SelectEvents'):
555 output.SelectEvents=cms.untracked.PSet(SelectEvents=cms.vstring())
556 for alca
in self.AlCaPaths:
557 output.SelectEvents.SelectEvents.extend(getattr(self.process,
'OutALCARECO'+alca).SelectEvents.SelectEvents)
560 if hasattr(self.process,theModuleLabel):
561 raise Exception(
"the current process already has a module "+theModuleLabel+
" defined")
563 setattr(self.process,theModuleLabel,output)
564 outputModule=getattr(self.process,theModuleLabel)
565 setattr(self.process,theModuleLabel+
'_step',cms.EndPath(outputModule))
566 path=getattr(self.process,theModuleLabel+
'_step')
567 self.schedule.append(path)
569 if not self._options.inlineEventContent
and hasattr(self.process,theStreamType+
"EventContent"):
572 outputModule.outputCommands.__dict__[
"dumpPython"] = doNotInlineEventContent
573 if theExtraOutputCommands:
574 if not isinstance(theExtraOutputCommands,list):
575 raise Exception(
"extra ouput command in --option must be a list of strings")
576 if hasattr(self.process,theStreamType+
"EventContent"):
577 self.
executeAndRemember(
'process.%s.outputCommands.extend(%s)'%(theModuleLabel,theExtraOutputCommands))
579 outputModule.outputCommands.extend(theExtraOutputCommands)
581 result+=
"\nprocess."+theModuleLabel+
" = "+outputModule.dumpPython()
586 streamTypes=self._options.eventcontent.split(
',')
587 tiers=self._options.datatier.split(
',')
588 if not self._options.outputDefinition
and len(streamTypes)!=len(tiers):
589 raise Exception(
"number of event content arguments does not match number of datatier arguments")
592 if self._options.step.split(
',')[0].
split(
':')[0] ==
'ALCA':
595 for i,(streamType,tier)
in enumerate(zip(streamTypes,tiers)):
596 if streamType==
'':
continue
597 if streamType==
'DQMIO': streamType=
'DQM'
598 theEventContent = getattr(self.process, streamType+
"EventContent")
600 theFileName=self._options.outfile_name
601 theFilterName=self._options.filtername
603 theFileName=self._options.outfile_name.replace(
'.root',
'_in'+streamType+
'.root')
604 theFilterName=self._options.filtername
605 CppType=
'PoolOutputModule'
606 if self._options.timeoutOutput:
607 CppType=
'TimeoutPoolOutputModule'
608 if streamType==
'DQM' and tier==
'DQMIO': CppType=
'DQMRootOutputModule'
609 output = cms.OutputModule(CppType,
611 fileName = cms.untracked.string(theFileName),
612 dataset = cms.untracked.PSet(dataTier = cms.untracked.string(tier),
613 filterName = cms.untracked.string(theFilterName)
616 if hasattr(self.process,
"generation_step")
and streamType!=
'LHE':
617 output.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
'generation_step'))
618 if hasattr(self.process,
"filtering_step"):
619 output.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
'filtering_step'))
621 if streamType==
'ALCARECO':
622 output.dataset.filterName = cms.untracked.string(
'StreamALCACombined')
624 if "MINIAOD" in streamType:
625 output.dropMetaData = cms.untracked.string(
'ALL')
626 output.fastCloning= cms.untracked.bool(
False)
627 output.overrideInputFileSplitLevels = cms.untracked.bool(
True)
629 outputModuleName=streamType+
'output'
630 setattr(self.process,outputModuleName,output)
631 outputModule=getattr(self.process,outputModuleName)
632 setattr(self.process,outputModuleName+
'_step',cms.EndPath(outputModule))
633 path=getattr(self.process,outputModuleName+
'_step')
634 self.schedule.append(path)
636 if self._options.outputCommands
and streamType!=
'DQM':
637 for evct
in self._options.outputCommands.split(
','):
638 if not evct:
continue
639 self.
executeAndRemember(
"process.%s.outputCommands.append('%s')"%(outputModuleName,evct.strip()))
641 if not self._options.inlineEventContent:
644 outputModule.outputCommands.__dict__[
"dumpPython"] = doNotInlineEventContent
646 result+=
"\nprocess."+outputModuleName+
" = "+outputModule.dumpPython()
652 Add selected standard sequences to the process
655 if self._options.pileup:
656 pileupSpec=self._options.pileup.split(
',')[0]
660 if self._options.fast
and pileupSpec.find(
"GEN_") == 0:
662 pileupSpec = pileupSpec[4:]
665 from Configuration.StandardSequences.Mixing
import Mixing,defineMixing
666 if not pileupSpec
in Mixing
and '.' not in pileupSpec
and 'file:' not in pileupSpec:
667 message = pileupSpec+
' is not a know mixing scenario:\n available are: '+
'\n'.
join(Mixing.keys())
668 if self._options.fast:
669 message +=
"\n-"*20+
"\n additional options for FastSim (gen-mixing):\n" +
"-"*20 +
"\n" +
'\n'.
join([
"GEN_" + x
for x
in Mixing.keys()]) +
"\n"
673 if '.' in pileupSpec:
674 mixingDict={
'file':pileupSpec}
675 elif pileupSpec.startswith(
'file:'):
676 mixingDict={
'file':pileupSpec[5:]}
679 mixingDict=copy.copy(Mixing[pileupSpec])
680 if len(self._options.pileup.split(
','))>1:
681 mixingDict.update(eval(self._options.pileup[self._options.pileup.find(
',')+1:]))
684 if 'file:' in pileupSpec:
686 self.process.load(mixingDict[
'file'])
687 print "inlining mixing module configuration"
688 self._options.inlineObjets+=
',mix'
693 if self._options.fast:
695 self._options.customisation_file.insert(0,
"FastSimulation/Configuration/MixingModule_Full2Fast.prepareGenMixing")
697 self._options.customisation_file.insert(0,
"FastSimulation/Configuration/MixingModule_Full2Fast.prepareDigiRecoMixing")
699 mixingDict.pop(
'file')
700 if not "DATAMIX" in self.stepMap.keys():
701 if self._options.pileup_input:
702 if self._options.pileup_input.startswith(
'dbs:')
or self._options.pileup_input.startswith(
'das:'):
703 mixingDict[
'F']=
filesFromDASQuery(
'file dataset = %s'%(self._options.pileup_input[4:],))[0]
705 mixingDict[
'F']=self._options.pileup_input.split(
',')
707 for command
in specialization:
709 if len(mixingDict)!=0:
710 raise Exception(
'unused mixing specification: '+mixingDict.keys().
__str__())
715 if len(self.stepMap):
717 if (
'SIM' in self.stepMap
or 'reSIM' in self.stepMap)
and not self._options.fast:
719 if self.geometryDBLabel:
720 self.
executeAndRemember(
'process.XMLFromDBSource.label = cms.string("%s")'%(self.geometryDBLabel))
722 print "Geometry option",self._options.geometry,
"unknown."
725 if len(self.stepMap):
728 for stepName
in self.stepKeys:
729 stepSpec = self.stepMap[stepName]
730 print "Step:", stepName,
"Spec:",stepSpec
731 if stepName.startswith(
're'):
733 if stepName[2:]
not in self._options.donotDropOnInput:
734 self._options.inputEventContent=
'%s,%s'%(stepName.upper(),self._options.inputEventContent)
735 stepName=stepName[2:]
737 getattr(self,
"prepare_"+stepName)(sequence = getattr(self,stepName+
"DefaultSeq"))
738 elif type(stepSpec)==list:
739 getattr(self,
"prepare_"+stepName)(sequence =
'+'.
join(stepSpec))
740 elif type(stepSpec)==tuple:
741 getattr(self,
"prepare_"+stepName)(sequence =
','.
join([stepSpec[1],
'+'.
join(stepSpec[0])]))
743 raise ValueError(
"Invalid step definition")
745 if self._options.restoreRNDSeeds!=
False:
747 if self._options.restoreRNDSeeds==
True:
748 self.
executeAndRemember(
'process.RandomNumberGeneratorService.restoreStateLabel=cms.untracked.string("randomEngineStateProducer")')
750 self.
executeAndRemember(
'process.RandomNumberGeneratorService.restoreStateTag=cms.untracked.InputTag("randomEngineStateProducer","","%s")'%(self._options.restoreRNDSeeds))
751 if self._options.inputEventContent
or self._options.inputCommands:
752 if self._options.inputCommands:
753 self._options.inputCommands+=
'keep *_randomEngineStateProducer_*_*,'
755 self._options.inputCommands=
'keep *_randomEngineStateProducer_*_*,'
759 if self._options.inputEventContent:
761 def dropSecondDropStar(iec):
772 if not hasattr(self.process.source,
'inputCommands'): self.process.source.inputCommands=cms.untracked.vstring()
773 for evct
in self._options.inputEventContent.split(
','):
774 if evct==
'':
continue
775 theEventContent = getattr(self.process, evct+
"EventContent")
776 if hasattr(theEventContent,
'outputCommands'):
777 self.process.source.inputCommands.extend(copy.copy(theEventContent.outputCommands))
778 if hasattr(theEventContent,
'inputCommands'):
779 self.process.source.inputCommands.extend(copy.copy(theEventContent.inputCommands))
781 dropSecondDropStar(self.process.source.inputCommands)
783 if not self._options.dropDescendant:
784 self.process.source.dropDescendantsOfDroppedBranches = cms.untracked.bool(
False)
790 """Add conditions to the process"""
791 if not self._options.conditions:
return
793 if 'FrontierConditions_GlobalTag' in self._options.conditions:
794 print 'using FrontierConditions_GlobalTag in --conditions is not necessary anymore and will be deprecated soon. please update your command line'
795 self._options.conditions = self._options.conditions.replace(
"FrontierConditions_GlobalTag,",
'')
797 self.loadAndRemember(self.ConditionsDefaultCFF)
799 if self._options.useCondDBv1:
800 from Configuration.AlCa.GlobalTag_condDBv1
import GlobalTag
804 self.process.GlobalTag =
GlobalTag(self.process.GlobalTag, self._options.conditions, self._options.custom_conditions)
806 if self._options.useCondDBv1:
807 self.additionalCommands.append(
'from Configuration.AlCa.GlobalTag_condDBv1 import GlobalTag')
809 self.additionalCommands.append(
'from Configuration.AlCa.GlobalTag import GlobalTag')
811 self.additionalCommands.append(
'process.GlobalTag = GlobalTag(process.GlobalTag, %s, %s)' % (repr(self._options.conditions), repr(self._options.custom_conditions)))
813 if self._options.slhc:
814 self.loadAndRemember(
"SLHCUpgradeSimulations/Geometry/fakeConditions_%s_cff"%(self._options.slhc,))
818 """Include the customise code """
822 for c
in self._options.customisation_file:
823 custOpt.extend(c.split(
","))
825 for c
in self._options.customisation_file_unsch:
826 custOpt.extend(c.split(
","))
832 raise Exception(
"more than . in the specification:"+opt)
833 fileName=opt.split(
'.')[0]
834 if opt.count(
'.')==0: rest=
'customise'
836 rest=opt.split(
'.')[1]
837 if rest==
'py': rest=
'customise'
839 if fileName
in custMap:
840 custMap[fileName].extend(rest.split(
'+'))
842 custMap[fileName]=rest.split(
'+')
847 final_snippet=
'\n# customisation of the process.\n'
851 allFcn.extend(custMap[opt])
853 if allFcn.count(fcn)!=1:
854 raise Exception(
"cannot specify twice "+fcn+
" as a customisation method")
858 packageName = f.replace(
".py",
"").
replace(
"/",
".")
859 __import__(packageName)
860 package = sys.modules[packageName]
863 customiseFile = re.sub(
r'\.pyc$',
'.py', package.__file__)
865 final_snippet+=
'\n# Automatic addition of the customisation function from '+packageName+
'\n'
866 if self._options.inline_custom:
867 for line
in file(customiseFile,
'r'):
868 if "import FWCore.ParameterSet.Config" in line:
870 final_snippet += line
872 final_snippet +=
'from %s import %s \n'%(packageName,
','.
join(custMap[f]))
873 for fcn
in custMap[f]:
874 print "customising the process with",fcn,
"from",f
875 if not hasattr(package,fcn):
877 raise Exception(
"config "+f+
" has no function "+fcn)
879 self.process=getattr(package,fcn)(self.process)
881 final_snippet +=
"\n#call to customisation function "+fcn+
" imported from "+packageName
882 final_snippet +=
"\nprocess = %s(process)\n"%(fcn,)
885 final_snippet +=
'\n# End of customisation functions\n'
888 if unsch==1
or not self._options.runUnscheduled:
889 if self._options.customise_commands:
891 final_snippet +=
'\n# Customisation from command line'
892 for com
in self._options.customise_commands.split(
'\\n'):
893 com=string.lstrip(com)
895 final_snippet +=
'\n'+com
904 if len(self.stepMap):
906 if self._options.particleTable
not in defaultOptions.particleTableList:
907 print 'Invalid particle table provided. Options are:'
908 print defaultOptions.particleTable
911 if len(self.stepMap):
912 self.
loadAndRemember(
'SimGeneral.HepPDTESSource.'+self._options.particleTable+
'_cfi')
929 self.EIDefaultCFF=
None
930 self.SKIMDefaultCFF=
"Configuration/StandardSequences/Skims_cff"
931 self.POSTRECODefaultCFF=
"Configuration/StandardSequences/PostRecoGenerator_cff"
932 self.VALIDATIONDefaultCFF=
"Configuration/StandardSequences/Validation_cff"
933 self.L1HwValDefaultCFF =
"Configuration/StandardSequences/L1HwVal_cff"
934 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOffline_cff"
935 self.HARVESTINGDefaultCFF=
"Configuration/StandardSequences/Harvesting_cff"
936 self.ALCAHARVESTDefaultCFF=
"Configuration/StandardSequences/AlCaHarvesting_cff"
937 self.ENDJOBDefaultCFF=
"Configuration/StandardSequences/EndOfProcess_cff"
938 if self._options.useCondDBv1:
939 self.ConditionsDefaultCFF =
"Configuration/StandardSequences/FrontierConditions_GlobalTag_condDBv1_cff"
941 self.ConditionsDefaultCFF =
"Configuration/StandardSequences/FrontierConditions_GlobalTag_cff"
942 self.CFWRITERDefaultCFF =
"Configuration/StandardSequences/CrossingFrameWriter_cff"
943 self.REPACKDefaultCFF=
"Configuration/StandardSequences/DigiToRaw_Repack_cff"
945 if "DATAMIX" in self.stepMap.keys():
946 self.DATAMIXDefaultCFF=
"Configuration/StandardSequences/DataMixer"+self._options.datamix+
"_cff"
947 if self._options.datamix ==
'PreMix':
948 self.
DIGIDefaultCFF=
"Configuration/StandardSequences/DigiDMPreMix_cff"
952 self.
L1EMDefaultCFF=
'Configuration/StandardSequences/SimL1EmulatorDM_cff'
954 if "DIGIPREMIX" in self.stepMap.keys():
955 self.
DIGIDefaultCFF=
"Configuration/StandardSequences/Digi_PreMix_cff"
957 self.ALCADefaultSeq=
None
958 self.LHEDefaultSeq=
'externalLHEProducer'
959 self.GENDefaultSeq=
'pgen'
960 self.SIMDefaultSeq=
'psim'
961 self.DIGIDefaultSeq=
'pdigi'
962 self.DIGIPREMIXDefaultSeq=
'pdigi'
963 self.DIGIPREMIX_S2DefaultSeq=
'pdigi'
964 self.DATAMIXDefaultSeq=
None
965 self.DIGI2RAWDefaultSeq=
'DigiToRaw'
966 self.HLTDefaultSeq=
'GRun'
967 self.L1DefaultSeq=
None
968 self.L1REPACKDefaultSeq=
'GT'
969 self.HARVESTINGDefaultSeq=
None
970 self.ALCAHARVESTDefaultSeq=
None
971 self.CFWRITERDefaultSeq=
None
972 self.RAW2DIGIDefaultSeq=
'RawToDigi'
973 self.L1RecoDefaultSeq=
'L1Reco'
974 self.L1TrackTriggerDefaultSeq=
'L1TrackTrigger'
975 if 'RAW2DIGI' in self.stepMap
and 'RECO' in self.stepMap:
976 self.RECODefaultSeq=
'reconstruction'
978 self.RECODefaultSeq=
'reconstruction_fromRECO'
980 self.EIDefaultSeq=
'top'
981 self.POSTRECODefaultSeq=
None
982 self.L1HwValDefaultSeq=
'L1HwVal'
983 self.DQMDefaultSeq=
'DQMOffline'
984 self.VALIDATIONDefaultSeq=
''
985 self.ENDJOBDefaultSeq=
'endOfProcess'
986 self.REPACKDefaultSeq=
'DigiToRawRepack'
987 self.PATDefaultSeq=
'miniAOD'
989 self.EVTCONTDefaultCFF=
"Configuration/EventContent/EventContent_cff"
991 if not self._options.beamspot:
992 self._options.beamspot=VtxSmearedDefaultKey
995 if self._options.isMC==
True:
997 self.
RECODefaultCFF=
"Configuration/StandardSequences/Reconstruction_cff"
998 self.
PATDefaultCFF=
"Configuration/StandardSequences/PATMC_cff"
999 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineMC_cff"
1000 self.
ALCADefaultCFF=
"Configuration/StandardSequences/AlCaRecoStreamsMC_cff"
1002 self._options.beamspot =
None
1005 if 'reGEN' in self.stepMap:
1006 self.GENDefaultSeq=
'fixGenInfo'
1008 if self._options.scenario==
'cosmics':
1009 self._options.pileup=
'Cosmics'
1010 self.
DIGIDefaultCFF=
"Configuration/StandardSequences/DigiCosmics_cff"
1011 self.
RECODefaultCFF=
"Configuration/StandardSequences/ReconstructionCosmics_cff"
1012 self.SKIMDefaultCFF=
"Configuration/StandardSequences/SkimsCosmics_cff"
1013 self.EVTCONTDefaultCFF=
"Configuration/EventContent/EventContentCosmics_cff"
1014 self.VALIDATIONDefaultCFF=
"Configuration/StandardSequences/ValidationCosmics_cff"
1015 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineCosmics_cff"
1016 if self._options.isMC==
True:
1017 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineCosmicsMC_cff"
1018 self.HARVESTINGDefaultCFF=
"Configuration/StandardSequences/HarvestingCosmics_cff"
1019 self.RECODefaultSeq=
'reconstructionCosmics'
1020 self.DQMDefaultSeq=
'DQMOfflineCosmics'
1022 if self._options.scenario==
'HeavyIons':
1023 if not self._options.beamspot:
1024 self._options.beamspot=VtxSmearedHIDefaultKey
1025 self.HLTDefaultSeq =
'HIon'
1026 self.VALIDATIONDefaultCFF=
"Configuration/StandardSequences/ValidationHeavyIons_cff"
1027 self.VALIDATIONDefaultSeq=
''
1028 self.EVTCONTDefaultCFF=
"Configuration/EventContent/EventContentHeavyIons_cff"
1029 self.
RECODefaultCFF=
"Configuration/StandardSequences/ReconstructionHeavyIons_cff"
1030 self.RECODefaultSeq=
'reconstructionHeavyIons'
1031 self.
ALCADefaultCFF =
"Configuration/StandardSequences/AlCaRecoStreamsHeavyIons_cff"
1032 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineHeavyIons_cff"
1033 self.DQMDefaultSeq=
'DQMOfflineHeavyIons'
1034 self.SKIMDefaultCFF=
"Configuration/StandardSequences/SkimsHeavyIons_cff"
1035 self.HARVESTINGDefaultCFF=
"Configuration/StandardSequences/HarvestingHeavyIons_cff"
1036 if self._options.isMC==
True:
1037 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineHeavyIonsMC_cff"
1040 self.RAW2RECODefaultSeq=
','.
join([self.RAW2DIGIDefaultSeq,self.RECODefaultSeq])
1042 self.USERDefaultSeq=
'user'
1043 self.USERDefaultCFF=
None
1046 if self._options.isData:
1047 if self._options.magField==defaultOptions.magField:
1048 print "magnetic field option forced to: AutoFromDBCurrent"
1049 self._options.magField=
'AutoFromDBCurrent'
1050 self.magFieldCFF =
'Configuration/StandardSequences/MagneticField_'+self._options.magField.replace(
'.',
'')+
'_cff'
1051 self.magFieldCFF = self.magFieldCFF.replace(
"__",
'_')
1054 self.GeometryCFF=
'Configuration/StandardSequences/GeometryRecoDB_cff'
1055 self.geometryDBLabel=
None
1057 if self._options.fast:
1058 if 'start' in self._options.conditions.lower():
1059 self.GeometryCFF=
'FastSimulation/Configuration/Geometries_START_cff'
1061 self.GeometryCFF=
'FastSimulation/Configuration/Geometries_MC_cff'
1064 from Configuration.StandardSequences.GeometryConf
import GeometryConf
1065 if opt
in GeometryConf:
1066 return GeometryConf[opt]
1070 geoms=self._options.geometry.split(
',')
1074 if '/' in geoms[1]
or '_cff' in geoms[1]:
1075 self.GeometryCFF=geoms[1]
1077 self.GeometryCFF=
'Configuration/Geometry/Geometry'+geoms[1]+
'_cff'
1079 if (geoms[0].startswith(
'DB:')):
1080 self.SimGeometryCFF=
'Configuration/StandardSequences/GeometrySimDB_cff'
1081 self.geometryDBLabel=geoms[0][3:]
1084 if '/' in geoms[0]
or '_cff' in geoms[0]:
1085 self.SimGeometryCFF=geoms[0]
1087 simGeometry=geoms[0]
1088 if self._options.gflash==
True:
1089 self.SimGeometryCFF=
'Configuration/Geometry/Geometry'+geoms[0]+
'GFlash_cff'
1091 self.SimGeometryCFF=
'Configuration/Geometry/Geometry'+geoms[0]+
'_cff'
1094 if simGeometry
not in defaultOptions.geometryExtendedOptions:
1095 self.
SIMDefaultCFF=
"Configuration/StandardSequences/SimIdeal_cff"
1097 if self._options.scenario==
'nocoll' or self._options.scenario==
'cosmics':
1098 self.
SIMDefaultCFF=
"Configuration/StandardSequences/SimNOBEAM_cff"
1099 self._options.beamspot=
'NoSmear'
1102 if self._options.fast:
1103 self.
SIMDefaultCFF =
'FastSimulation.Configuration.SimIdeal_cff'
1104 self.SIMDefaultSeq =
'psim'
1105 self.
RECODefaultCFF=
'FastSimulation.Configuration.Reconstruction_AftMix_cff'
1106 self.RECODefaultSeq=
'reconstruction'
1107 self.EVTCONTDefaultCFF =
"FastSimulation.Configuration.EventContent_cff"
1108 self.VALIDATIONDefaultCFF =
"FastSimulation.Configuration.Validation_cff"
1109 self.RECOBEFMIXDefaultCFF =
'FastSimulation.Configuration.Reconstruction_BefMix_cff'
1110 self.RECOBEFMIXDefaultSeq =
'reconstruction_befmix'
1112 if self._options.datamix ==
'PreMix':
1113 self.
DIGIDefaultCFF=
"FastSimulation.Configuration.DigiDMPreMix_cff"
1114 if "DIGIPREMIX" in self.stepMap.keys():
1115 self.
DIGIDefaultCFF=
"FastSimulation.Configuration.Digi_PreMix_cff"
1116 if "DATAMIX" in self.stepMap.keys():
1117 self.DATAMIXDefaultCFF=
"FastSimulation.Configuration.DataMixer"+self._options.datamix+
"_cff"
1119 self.DIGIDefaultSeq =
'pdigi'
1120 self.
L1EMDefaultCFF=
'FastSimulation.Configuration.SimL1Emulator_cff'
1123 self.DIGI2RAWDefaultSeq =
'DigiToRaw'
1124 self.EVTCONTDefaultCFF =
"FastSimulation.Configuration.EventContent_cff"
1125 self.VALIDATIONDefaultCFF =
"FastSimulation.Configuration.Validation_cff"
1130 if self._options.pileup==
'default':
1131 from Configuration.StandardSequences.Mixing
import MixingDefaultKey
1132 self._options.pileup=MixingDefaultKey
1134 if self._options.fast:
1135 self._options.pileup=
"GEN_" + MixingDefaultKey
1139 if self._options.isData:
1140 self._options.pileup=
None
1142 if self._options.slhc:
1143 self.GeometryCFF=
'SLHCUpgradeSimulations.Geometry.%s_cmsSimIdealGeometryXML_cff'%(self._options.slhc,)
1144 if 'stdgeom' not in self._options.slhc:
1145 self.SimGeometryCFF=
'SLHCUpgradeSimulations.Geometry.%s_cmsSimIdealGeometryXML_cff'%(self._options.slhc,)
1146 self.
DIGIDefaultCFF=
'SLHCUpgradeSimulations/Geometry/Digi_%s_cff'%(self._options.slhc,)
1147 if self._options.pileup!=defaultOptions.pileup:
1148 self._options.pileup=
'SLHC_%s_%s'%(self._options.pileup,self._options.slhc)
1150 self.REDIGIDefaultSeq=self.DIGIDefaultSeq
1155 output = cms.OutputModule(
"PoolOutputModule")
1156 if stream.selectEvents.parameters_().__len__()!=0:
1157 output.SelectEvents = stream.selectEvents
1159 output.SelectEvents = cms.untracked.PSet()
1160 output.SelectEvents.SelectEvents=cms.vstring()
1161 if isinstance(stream.paths,tuple):
1162 for path
in stream.paths:
1163 output.SelectEvents.SelectEvents.append(path.label())
1165 output.SelectEvents.SelectEvents.append(stream.paths.label())
1169 if isinstance(stream.content,str):
1170 evtPset=getattr(self.process,stream.content)
1171 for p
in evtPset.parameters_():
1172 setattr(output,p,getattr(evtPset,p))
1173 if not self._options.inlineEventContent:
1176 output.outputCommands.__dict__[
"dumpPython"] = doNotInlineEventContent
1178 output.outputCommands = stream.content
1181 output.fileName = cms.untracked.string(self._options.dirout+stream.name+
'.root')
1183 output.dataset = cms.untracked.PSet( dataTier = stream.dataTier,
1184 filterName = cms.untracked.string(stream.name))
1186 if self._options.filtername:
1187 output.dataset.filterName= cms.untracked.string(self._options.filtername+
"_"+stream.name)
1190 output.eventAutoFlushCompressedSize=cms.untracked.int32(5*1024*1024)
1192 if workflow
in (
"producers,full"):
1193 if isinstance(stream.paths,tuple):
1194 for path
in stream.paths:
1195 self.schedule.append(path)
1197 self.schedule.append(stream.paths)
1201 if (
not self._options.relval)
and workflow
in (
"full",
"output"):
1202 self.additionalOutputs[name] = output
1203 setattr(self.process,name,output)
1205 if workflow ==
'output':
1207 filterList = output.SelectEvents.SelectEvents
1208 for i, filter
in enumerate(filterList):
1209 filterList[i] = filter+
":"+self._options.triggerResultsProcess
1219 if ( len(sequence.split(
'.'))==1 ):
1221 elif ( len(sequence.split(
'.'))==2 ):
1223 sequence=sequence.split(
'.')[1]
1225 print "sub sequence configuration must be of the form dir/subdir/cff.a+b+c or cff.a"
1226 print sequence,
"not recognized"
1233 for i,s
in enumerate(seq.split(
'*')):
1235 setattr(self.process,prefix,getattr(cms,what)( getattr(self.process, s) ))
1237 p=getattr(self.process,prefix)
1238 p+=getattr(self.process, s)
1239 self.schedule.append(getattr(self.process,prefix))
1244 if self.nextScheduleIsConditional:
1245 self.conditionalPaths.append(prefix)
1246 setattr(self.process,prefix,getattr(cms,what)( getattr(self.process, seq) ))
1247 self.schedule.append(getattr(self.process,prefix))
1249 for i,s
in enumerate(seq.split(
'+')):
1251 setattr(self.process,sn,getattr(cms,what)( getattr(self.process, s) ))
1252 self.schedule.append(getattr(self.process,sn))
1266 """ Enrich the process with alca streams """
1267 print 'DL enriching',workflow,sequence
1269 sequence = sequence.split(
'.')[-1]
1272 alcaList = sequence.split(
"+")
1274 from Configuration.AlCa.autoAlca
import autoAlca
1278 for name
in alcaConfig.__dict__:
1279 alcastream = getattr(alcaConfig,name)
1280 shortName = name.replace(
'ALCARECOStream',
'')
1281 if shortName
in alcaList
and isinstance(alcastream,cms.FilteredStream):
1282 output = self.
addExtraStream(name,alcastream, workflow = workflow)
1283 self.
executeAndRemember(
'process.ALCARECOEventContent.outputCommands.extend(process.OutALCARECO'+shortName+
'_noDrop.outputCommands)')
1284 self.AlCaPaths.append(shortName)
1285 if 'DQM' in alcaList:
1286 if not self._options.inlineEventContent
and hasattr(self.process,name):
1287 self.
executeAndRemember(
'process.' + name +
'.outputCommands.append("keep *_MEtoEDMConverter_*_*")')
1289 output.outputCommands.append(
"keep *_MEtoEDMConverter_*_*")
1292 if self._options.hltProcess
or 'HLT' in self.stepMap:
1293 if isinstance(alcastream.paths,tuple):
1294 for path
in alcastream.paths:
1299 for i
in range(alcaList.count(shortName)):
1300 alcaList.remove(shortName)
1303 elif name ==
'pathALCARECODQM' and 'DQM' in alcaList:
1304 path = getattr(alcaConfig,name)
1305 self.schedule.append(path)
1306 alcaList.remove(
'DQM')
1308 if isinstance(alcastream,cms.Path):
1310 self.blacklist_paths.append(alcastream)
1313 if len(alcaList) != 0:
1315 for name
in alcaConfig.__dict__:
1316 alcastream = getattr(alcaConfig,name)
1317 if isinstance(alcastream,cms.FilteredStream):
1318 available.append(name.replace(
'ALCARECOStream',
''))
1319 print "The following alcas could not be found "+str(alcaList)
1320 print "available ",available
1322 raise Exception(
"The following alcas could not be found "+str(alcaList))
1327 loadFragment = self._options.evt_type.replace(
'.py',
'',).
replace(
'.',
'_').
replace(
'python/',
'').
replace(
'/',
'.')
1328 print "Loading lhe fragment from",loadFragment
1329 __import__(loadFragment)
1330 self.process.load(loadFragment)
1332 self._options.inlineObjets+=
','+sequence
1334 getattr(self.process,sequence).nEvents = int(self._options.number)
1337 self.process.lhe_step = cms.Path( getattr( self.process,sequence) )
1338 self.excludedPaths.append(
"lhe_step")
1339 self.schedule.append( self.process.lhe_step )
1342 """ load the fragment of generator configuration """
1347 loadFragment = self._options.evt_type.replace(
'.py',
'',).
replace(
'.',
'_').
replace(
'python/',
'')
1349 if not '/' in loadFragment:
1350 loadFragment=
'Configuration.Generator.'+loadFragment
1352 loadFragment=loadFragment.replace(
'/',
'.')
1354 print "Loading generator fragment from",loadFragment
1355 __import__(loadFragment)
1359 if not (self._options.filein
or self._options.dasquery):
1360 raise Exception(
"Neither gen fragment of input files provided: this is an inconsistent GEN step configuration")
1363 generatorModule=sys.modules[loadFragment]
1364 genModules=generatorModule.__dict__
1367 if self.LHEDefaultSeq
in genModules:
1368 del genModules[self.LHEDefaultSeq]
1370 if self._options.hideGen:
1373 self.process.load(loadFragment)
1375 import FWCore.ParameterSet.Modules
as cmstypes
1376 for name
in genModules:
1377 theObject = getattr(generatorModule,name)
1378 if isinstance(theObject, cmstypes._Module):
1379 self._options.inlineObjets=name+
','+self._options.inlineObjets
1380 elif isinstance(theObject, cms.Sequence)
or isinstance(theObject, cmstypes.ESProducer):
1381 self._options.inlineObjets+=
','+name
1383 if sequence == self.GENDefaultSeq
or sequence ==
'pgen_genonly':
1384 if 'ProductionFilterSequence' in genModules
and (
'generator' in genModules):
1385 self.productionFilterSequence =
'ProductionFilterSequence'
1386 elif 'generator' in genModules:
1387 self.productionFilterSequence =
'generator'
1389 """ Enrich the schedule with the rest of the generation step """
1391 genSeqName=sequence.split(
'.')[-1]
1395 from Configuration.StandardSequences.VtxSmeared
import VtxSmeared
1396 cffToBeLoaded=VtxSmeared[self._options.beamspot]
1399 raise Exception(
"VertexSmearing type or beamspot "+self._options.beamspot+
" unknown.")
1401 if self._options.scenario ==
'HeavyIons':
1402 if self._options.pileup==
'HiMixGEN':
1403 self.
loadAndRemember(
"Configuration/StandardSequences/GeneratorMix_cff")
1405 self.
loadAndRemember(
"Configuration/StandardSequences/GeneratorHI_cff")
1407 self.process.generation_step = cms.Path( getattr(self.process,genSeqName) )
1408 self.schedule.append(self.process.generation_step)
1411 self.
executeAndRemember(
'process.genstepfilter.triggerConditions=cms.vstring("generation_step")')
1413 if 'reGEN' in self.stepMap:
1417 """ Enrich the schedule with the summary of the filter step """
1424 """ Enrich the schedule with the simulation step"""
1425 self.loadDefaultOrSpecifiedCFF(sequence,self.SIMDefaultCFF)
1426 if not self._options.fast:
1427 if self._options.gflash==
True:
1428 self.loadAndRemember(
"Configuration/StandardSequences/GFlashSIM_cff")
1430 if self._options.magField==
'0T':
1431 self.executeAndRemember(
"process.g4SimHits.UseMagneticField = cms.bool(False)")
1433 if self._options.magField==
'0T':
1434 self.executeAndRemember(
"process.famosSimHits.UseMagneticField = cms.bool(False)")
1436 self.scheduleSequence(sequence.split(
'.')[-1],
'simulation_step')
1440 """ Enrich the schedule with the digitisation step"""
1443 if self._options.gflash==
True:
1444 self.
loadAndRemember(
"Configuration/StandardSequences/GFlashDIGI_cff")
1446 if sequence ==
'pdigi_valid':
1447 self.
executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersValid)")
1449 if sequence !=
'pdigi_nogen' and sequence !=
'pdigi_valid_nogen' and not self.process.source.type_()==
'EmptySource':
1450 if self._options.inputEventContent==
'':
1451 self._options.inputEventContent=
'REGEN'
1453 self._options.inputEventContent=self._options.inputEventContent+
',REGEN'
1460 """ Enrich the schedule with the digitisation step"""
1465 if sequence ==
'pdigi_valid':
1466 self.
executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersNoNoiseValid)")
1468 self.
executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersNoNoise)")
1474 """ Enrich the schedule with the digitisation step"""
1475 self.loadDefaultOrSpecifiedCFF(sequence,self.DIGIDefaultCFF)
1477 self.loadAndRemember(
"SimGeneral/MixingModule/digi_MixPreMix_cfi")
1480 if sequence ==
'pdigi_valid':
1481 self.executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersMixPreMixValid)")
1483 self.executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersMixPreMix)")
1485 self.scheduleSequence(sequence.split(
'.')[-1],
'digitisation_step')
1489 """ Enrich the schedule with the crossing frame writer step"""
1495 """ Enrich the schedule with the digitisation step"""
1499 if self._options.pileup_input:
1501 if self._options.pileup_input.startswith(
'dbs:')
or self._options.pileup_input.startswith(
'das:'):
1502 theFiles=
filesFromDASQuery(
'file dataset = %s'%(self._options.pileup_input[4:],))[0]
1503 elif self._options.pileup_input.startswith(
"filelist:"):
1504 theFiles= (
filesFromList(self._options.pileup_input[9:]))[0]
1506 theFiles=self._options.pileup_input.split(
',')
1508 self.
executeAndRemember(
"process.mixData.input.fileNames = cms.untracked.vstring(%s)"%( theFiles ) )
1515 if "DIGIPREMIX" in self.stepMap.keys():
1517 self.
executeAndRemember(
"process.SiStripDigiToRaw.FedReadoutMode = cms.string('PREMIX_RAW')")
1527 """ Enrich the schedule with the L1 simulation step"""
1534 """ 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"""
1535 supported = [
'GT',
'GT1',
'GT2',
'GCTGT']
1536 if sequence
in supported:
1537 self.loadAndRemember(
'Configuration/StandardSequences/SimL1EmulatorRepack_%s_cff'%sequence)
1538 if self._options.scenario ==
'HeavyIons':
1539 self.renameInputTagsInSequence(
"SimL1Emulator",
"rawDataCollector",
"rawDataRepacker")
1540 self.scheduleSequence(
'SimL1Emulator',
'L1RePack_step')
1542 print "L1REPACK with '",sequence,
"' is not supported! Supported choices are: ",supported
1547 """ Enrich the schedule with the HLT simulation step"""
1549 print "no specification of the hlt menu has been given, should never happen"
1550 raise Exception(
'no HLT sequence provided')
1554 from Configuration.HLT.autoHLT
import autoHLT
1557 sequence = autoHLT[key]
1559 raise ValueError(
'no HLT mapping key "%s" found in autoHLT' % key)
1565 if self._options.scenario ==
'HeavyIons':
1566 optionsForHLT[
'type'] =
'HIon'
1568 optionsForHLT[
'type'] =
'GRun'
1569 optionsForHLTConfig =
', '.
join(
'%s=%s' % (key, repr(val))
for (key, val)
in optionsForHLT.iteritems())
1570 if sequence ==
'run,fromSource':
1571 if hasattr(self.process.source,
'firstRun'):
1572 self.
executeAndRemember(
'process.loadHltConfiguration("run:%%d"%%(process.source.firstRun.value()),%s)'%(optionsForHLTConfig))
1573 elif hasattr(self.process.source,
'setRunNumber'):
1574 self.
executeAndRemember(
'process.loadHltConfiguration("run:%%d"%%(process.source.setRunNumber.value()),%s)'%(optionsForHLTConfig))
1576 raise Exception(
'Cannot replace menu to load %s'%(sequence))
1578 self.
executeAndRemember(
'process.loadHltConfiguration("%s",%s)'%(sequence.replace(
',',
':'),optionsForHLTConfig))
1582 if self._options.isMC:
1583 if self._options.fast:
1584 self._options.customisation_file.append(
"HLTrigger/Configuration/customizeHLTforMC.customizeHLTforFastSim")
1586 self._options.customisation_file.append(
"HLTrigger/Configuration/customizeHLTforMC.customizeHLTforFullSim")
1588 if self._options.name !=
'HLT':
1589 self.additionalCommands.append(
'from HLTrigger.Configuration.CustomConfigs import ProcessName')
1590 self.additionalCommands.append(
'process = ProcessName(process)')
1591 self.additionalCommands.append(
'')
1592 from HLTrigger.Configuration.CustomConfigs
import ProcessName
1595 self.schedule.append(self.process.HLTSchedule)
1596 [self.blacklist_paths.append(path)
for path
in self.process.HLTSchedule
if isinstance(path,(cms.Path,cms.EndPath))]
1599 if self._options.fast:
1600 if not hasattr(self.process,
'HLTEndSequence'):
1601 self.
executeAndRemember(
"process.HLTEndSequence = cms.Sequence( process.dummyModule )")
1606 seqReco=sequence.split(
',')[1]
1607 seqDigi=sequence.split(
',')[0]
1609 print "RAW2RECO requires two specifications",sequence,
"insufficient"
1623 ''' Enrich the schedule with L1 HW validation '''
1626 print '\n\n\n DEPRECATED this has no action \n\n\n'
1630 ''' Enrich the schedule with L1 reconstruction '''
1636 ''' Enrich the schedule with L1 reconstruction '''
1642 ''' Enrich the schedule with a user defined filter sequence '''
1644 filterConfig=self.
load(sequence.split(
'.')[0])
1645 filterSeq=sequence.split(
'.')[-1]
1653 label=visitee.label()
1661 getattr(self.process,filterSeq).
visit( expander )
1662 self._options.inlineObjets+=
','+expander.inliner
1663 self._options.inlineObjets+=
','+filterSeq
1666 self.scheduleSequence(filterSeq,
'filtering_step')
1667 self.nextScheduleIsConditional=
True
1669 self.productionFilterSequence = filterSeq
1674 ''' Enrich the schedule with reconstruction '''
1680 ''' Enrich the schedule with the part of reconstruction that is done before mixing in FastSim'''
1681 if not self._options.fast:
1682 print "ERROR: this step is only implemented for FastSim"
1685 self.
scheduleSequence(sequence.split(
'.')[-1],
'reconstruction_befmix_step')
1689 ''' Enrich the schedule with PAT '''
1691 if not self._options.runUnscheduled:
1692 raise Exception(
"MiniAOD production can only run in unscheduled mode, please run cmsDriver with --runUnscheduled")
1693 if self._options.isData:
1694 self._options.customisation_file_unsch.append(
"PhysicsTools/PatAlgos/slimming/miniAOD_tools.miniAOD_customizeAllData")
1696 self._options.customisation_file_unsch.append(
"PhysicsTools/PatAlgos/slimming/miniAOD_tools.miniAOD_customizeAllMC")
1697 if self._options.fast:
1698 self._options.customisation_file_unsch.append(
"PhysicsTools/PatAlgos/slimming/metFilterPaths_cff.miniAOD_customizeMETFiltersFastSim")
1702 ''' Enrich the schedule with event interpretation '''
1703 from Configuration.StandardSequences.EventInterpretation
import EventInterpretation
1704 if sequence
in EventInterpretation:
1705 self.EIDefaultCFF = EventInterpretation[sequence]
1706 sequence =
'EIsequence'
1708 raise Exception(
'Cannot set %s event interpretation'%( sequence) )
1714 ''' Enrich the schedule with skimming fragments'''
1716 sequence = sequence.split(
'.')[-1]
1718 skimlist=sequence.split(
'+')
1720 from Configuration.Skimming.autoSkim
import autoSkim
1724 for skim
in skimConfig.__dict__:
1725 skimstream = getattr(skimConfig,skim)
1726 if isinstance(skimstream,cms.Path):
1728 self.blacklist_paths.append(skimstream)
1729 if (
not isinstance(skimstream,cms.FilteredStream)):
1731 shortname = skim.replace(
'SKIMStream',
'')
1732 if (sequence==
"all"):
1734 elif (shortname
in skimlist):
1737 if self._options.datatier==
'DQM':
1738 self.process.load(self.EVTCONTDefaultCFF)
1739 skimstreamDQM = cms.FilteredStream(
1740 responsible = skimstream.responsible,
1741 name = skimstream.name+
'DQM',
1742 paths = skimstream.paths,
1743 selectEvents = skimstream.selectEvents,
1744 content = self._options.datatier+
'EventContent',
1745 dataTier = cms.untracked.string(self._options.datatier)
1748 for i
in range(skimlist.count(shortname)):
1749 skimlist.remove(shortname)
1753 if (skimlist.__len__()!=0
and sequence!=
"all"):
1754 print 'WARNING, possible typo with SKIM:'+
'+'.
join(skimlist)
1755 raise Exception(
'WARNING, possible typo with SKIM:'+
'+'.
join(skimlist))
1758 ''' Enrich the schedule with a user defined sequence '''
1764 """ Enrich the schedule with the postreco step """
1771 print sequence,
"in preparing validation"
1773 from Validation.Configuration.autoValidation
import autoValidation
1775 sequence=sequence.split(
'.')[-1]
1776 if sequence.find(
',')!=-1:
1777 prevalSeqName=sequence.split(
',')[0].
split(
'+')
1778 valSeqName=sequence.split(
',')[1].
split(
'+')
1783 prevalSeqName=sequence.split(
'+')
1784 valSeqName=sequence.split(
'+')
1790 postfix=
'_'+sequence
1791 prevalSeqName=[
'prevalidation'+postfix]
1792 valSeqName=[
'validation'+postfix]
1793 if not hasattr(self.process,valSeqName[0]):
1795 valSeqName=[sequence]
1804 if not 'DIGI' in self.stepMap
and not self._options.fast
and not any(
map(
lambda s : s.startswith(
'genvalid'), valSeqName)):
1805 if self._options.restoreRNDSeeds==
False and not self._options.restoreRNDSeeds==
True:
1806 self._options.restoreRNDSeeds=
True
1809 if (
'HLT' in self.stepMap
and not self._options.fast)
or self._options.hltProcess:
1810 for s
in valSeqName+prevalSeqName:
1813 for (i,s)
in enumerate(prevalSeqName):
1815 setattr(self.process,
'prevalidation_step%s'%NFI(i), cms.Path( getattr(self.process, s)) )
1816 self.schedule.append(getattr(self.process,
'prevalidation_step%s'%NFI(i)))
1818 for (i,s)
in enumerate(valSeqName):
1819 setattr(self.process,
'validation_step%s'%NFI(i), cms.EndPath( getattr(self.process, s)))
1820 self.schedule.append(getattr(self.process,
'validation_step%s'%NFI(i)))
1822 if not 'DIGI' in self.stepMap
and not self._options.fast:
1826 self._options.customisation_file.append(
"SimGeneral/MixingModule/fullMixCustomize_cff.setCrossingFrameOn")
1828 if hasattr(self.process,
"genstepfilter")
and len(self.process.genstepfilter.triggerConditions):
1830 for (i,s)
in enumerate(valSeqName):
1831 getattr(self.process,
'validation_step%s'%NFI(i))._seq = self.process.genstepfilter * getattr(self.process,
'validation_step%s'%NFI(i))._seq
1837 """Visitor that travels within a cms.Sequence, looks for a parameter and replace its value
1838 It will climb down within PSets, VPSets and VInputTags to find its target"""
1839 def __init__(self, paramSearch, paramReplace, verbose=False, whitelist=()):
1846 if isinstance(pset, cms._Parameterizable):
1847 for name
in pset.parameters_().
keys():
1853 value = getattr(pset,name)
1854 type = value.pythonTypeName()
1855 if type
in (
'cms.PSet',
'cms.untracked.PSet'):
1856 self.
doIt(value,base+
"."+name)
1857 elif type
in (
'cms.VPSet',
'cms.untracked.VPSet'):
1858 for (i,ps)
in enumerate(value): self.
doIt(ps,
"%s.%s[%d]"%(base,name,i) )
1859 elif type
in (
'cms.string',
'cms.untracked.string'):
1861 if self.
_verbose:
print "set string process name %s.%s %s ==> %s"% (base, name, value, self.
_paramReplace)
1863 elif type
in (
'cms.VInputTag',
'cms.untracked.VInputTag'):
1864 for (i,n)
in enumerate(value):
1865 if not isinstance(n, cms.InputTag):
1869 if self.
_verbose:
print "set process name %s.%s[%d] %s ==> %s " % (base, name, i, n, self.
_paramReplace)
1872 elif type
in (
'cms.vstring',
'cms.untracked.vstring'):
1873 for (i,n)
in enumerate(value):
1876 elif type
in (
'cms.InputTag',
'cms.untracked.InputTag'):
1878 if self.
_verbose:
print "set process name %s.%s %s ==> %s " % (base, name, value, self.
_paramReplace)
1879 setattr(getattr(pset, name),
"processName",self.
_paramReplace)
1884 label = visitee.label()
1885 except AttributeError:
1886 label =
'<Module not in a Process>'
1888 label =
'other execption'
1889 self.
doIt(visitee, label)
1896 print "Replacing all InputTag %s => %s"%(oldT,newT)
1899 loadMe=
'from PhysicsTools.PatAlgos.tools.helpers import massSearchReplaceAnyInputTag'
1900 if not loadMe
in self.additionalCommands:
1901 self.additionalCommands.append(loadMe)
1902 self.additionalCommands.append(
'massSearchReplaceAnyInputTag(process.%s,"%s","%s",False,True)'%(sequence,oldT,newT))
1906 if self._options.hltProcess:
1907 proc=self._options.hltProcess
1909 proc=self.process.name_()
1910 if proc==HLTprocess:
return
1912 print "replacing %s process name - sequence %s will use '%s'" % (HLTprocess,sequence, proc)
1914 if 'from Configuration.Applications.ConfigBuilder import ConfigBuilder' not in self.additionalCommands:
1915 self.additionalCommands.append(
'from Configuration.Applications.ConfigBuilder import ConfigBuilder')
1916 self.additionalCommands.append(
'process.%s.visit(ConfigBuilder.MassSearchReplaceProcessNameVisitor("%s", "%s", whitelist = ("subSystemFolder",)))'% (sequence,HLTprocess, proc))
1922 while '@' in repr(seqList)
and level<maxLevel:
1924 for specifiedCommand
in seqList:
1925 if specifiedCommand.startswith(
'@'):
1926 location=specifiedCommand[1:]
1927 if not location
in mapping:
1928 raise Exception(
"Impossible to map "+location+
" from "+repr(mapping))
1929 mappedTo=mapping[location]
1931 mappedTo=mappedTo[index]
1932 seqList.remove(specifiedCommand)
1933 seqList.extend(mappedTo.split(
'+'))
1936 raise Exception(
"Could not fully expand "+repr(seqList)+
" from "+repr(mapping))
1942 sequenceList=sequence.split(
'.')[-1].
split(
'+')
1943 from DQMOffline.Configuration.autoDQM
import autoDQM
1946 if len(set(sequenceList))!=len(sequenceList):
1947 sequenceList=
list(set(sequenceList))
1948 print "Duplicate entries for DQM:, using",sequenceList
1949 pathName=
'dqmoffline_step'
1951 for (i,sequence)
in enumerate(sequenceList):
1953 pathName=
'dqmoffline_%d_step'%(i)
1955 if 'HLT' in self.stepMap.keys()
or self._options.hltProcess:
1959 if 'HLT' in self.stepMap.keys():
1961 setattr(self.process,pathName, cms.EndPath( getattr(self.process, sequence ) ) )
1964 setattr(self.process,pathName, cms.Path( getattr(self.process, sequence) ) )
1965 self.schedule.append(getattr(self.process,pathName))
1969 """ Enrich the process with harvesting step """
1970 self.
DQMSaverCFF=
'Configuration/StandardSequences/DQMSaver'+self._options.harvesting+
'_cff'
1974 sequence = sequence.split(
'.')[-1]
1977 harvestingList = sequence.split(
"+")
1978 from DQMOffline.Configuration.autoDQM
import autoDQM
1979 from Validation.Configuration.autoValidation
import autoValidation
1981 combined_mapping = copy.deepcopy( autoDQM )
1982 combined_mapping.update( autoValidation )
1983 self.
expandMapping(harvestingList,combined_mapping,index=-1)
1985 if len(set(harvestingList))!=len(harvestingList):
1986 harvestingList=
list(set(harvestingList))
1987 print "Duplicate entries for HARVESTING, using",harvestingList
1989 for name
in harvestingList:
1990 if not name
in harvestingConfig.__dict__:
1991 print name,
"is not a possible harvesting type. Available are",harvestingConfig.__dict__.keys()
1993 harvestingstream = getattr(harvestingConfig,name)
1994 if isinstance(harvestingstream,cms.Path):
1995 self.schedule.append(harvestingstream)
1996 self.blacklist_paths.append(harvestingstream)
1997 if isinstance(harvestingstream,cms.Sequence):
1998 setattr(self.process,name+
"_step",cms.Path(harvestingstream))
1999 self.schedule.append(getattr(self.process,name+
"_step"))
2005 """ Enrich the process with AlCaHarvesting step """
2007 sequence=sequence.split(
".")[-1]
2010 harvestingList = sequence.split(
"+")
2014 from Configuration.AlCa.autoPCL
import autoPCL
2017 for name
in harvestingConfig.__dict__:
2018 harvestingstream = getattr(harvestingConfig,name)
2019 if name
in harvestingList
and isinstance(harvestingstream,cms.Path):
2020 self.schedule.append(harvestingstream)
2021 self.
executeAndRemember(
"process.PoolDBOutputService.toPut.append(process.ALCAHARVEST" + name +
"_dbOutput)")
2022 self.
executeAndRemember(
"process.pclMetadataWriter.recordsToMap.append(process.ALCAHARVEST" + name +
"_metadata)")
2023 harvestingList.remove(name)
2025 lastStep = getattr(harvestingConfig,
"ALCAHARVESTDQMSaveAndMetadataWriter")
2026 self.schedule.append(lastStep)
2028 if len(harvestingList) != 0
and 'dummyHarvesting' not in harvestingList :
2029 print "The following harvesting could not be found : ", harvestingList
2030 raise Exception(
"The following harvesting could not be found : "+str(harvestingList))
2040 self.process.reconstruction = cms.Path(self.process.reconstructionWithFamos)
2041 self.schedule.append(self.process.reconstruction)
2045 """ Add useful info for the production. """
2046 self.process.configurationMetadata=cms.untracked.PSet\
2047 (version=cms.untracked.string(
"$Revision: 1.19 $"),
2048 name=cms.untracked.string(
"Applications"),
2049 annotation=cms.untracked.string(evt_type+
" nevts:"+str(evtnumber))
2052 self.addedObjects.append((
"Production Info",
"configurationMetadata"))
2056 """ Prepare the configuration string and add missing pieces."""
2068 outputModuleCfgCode=
""
2069 if not 'HARVESTING' in self.stepMap.keys()
and not 'ALCAHARVEST' in self.stepMap.keys()
and not 'ALCAOUTPUT' in self.stepMap.keys()
and self.with_output:
2074 self.pythonCfgCode =
"# Auto generated configuration file\n"
2075 self.pythonCfgCode +=
"# using: \n# "+__version__[1:-1]+
"\n# "+__source__[1:-1]+
'\n'
2076 self.pythonCfgCode +=
"# with command line options: "+self._options.arguments+
'\n'
2077 self.pythonCfgCode +=
"import FWCore.ParameterSet.Config as cms\n\n"
2078 if hasattr(self.
_options,
"era")
and self._options.era :
2079 self.pythonCfgCode +=
"from Configuration.StandardSequences.Eras import eras\n\n"
2080 self.pythonCfgCode +=
"process = cms.Process('"+self.process.name_()+
"'"
2082 for requestedEra
in self._options.era.split(
",") :
2083 self.pythonCfgCode +=
",eras."+requestedEra
2084 self.pythonCfgCode +=
")\n\n"
2086 self.pythonCfgCode +=
"process = cms.Process('"+self.process.name_()+
"')\n\n"
2088 self.pythonCfgCode +=
"# import of standard configurations\n"
2089 for module
in self.imports:
2090 self.pythonCfgCode += (
"process.load('"+module+
"')\n")
2093 if not hasattr(self.process,
"configurationMetadata"):
2097 self.addedObjects.append((
"Production Info",
"configurationMetadata"))
2099 self.pythonCfgCode +=
"\n"
2100 for comment,object
in self.addedObjects:
2102 self.pythonCfgCode +=
"\n# "+comment+
"\n"
2103 self.pythonCfgCode +=
dumpPython(self.process,object)
2106 self.pythonCfgCode +=
"\n# Output definition\n"
2107 self.pythonCfgCode += outputModuleCfgCode
2110 self.pythonCfgCode +=
"\n# Additional output definition\n"
2112 nl=self.additionalOutputs.keys()
2115 output = self.additionalOutputs[name]
2116 self.pythonCfgCode +=
"process.%s = %s" %(name, output.dumpPython())
2117 tmpOut = cms.EndPath(output)
2118 setattr(self.process,name+
'OutPath',tmpOut)
2119 self.schedule.append(tmpOut)
2122 self.pythonCfgCode +=
"\n# Other statements\n"
2123 for command
in self.additionalCommands:
2124 self.pythonCfgCode += command +
"\n"
2127 for object
in self._options.inlineObjets.split(
','):
2130 if not hasattr(self.process,object):
2131 print 'cannot inline -'+object+
'- : not known'
2133 self.pythonCfgCode +=
'\n'
2134 self.pythonCfgCode +=
dumpPython(self.process,object)
2137 self.pythonCfgCode +=
"\n# Path and EndPath definitions\n"
2138 for path
in self.process.paths:
2139 if getattr(self.process,path)
not in self.blacklist_paths:
2140 self.pythonCfgCode +=
dumpPython(self.process,path)
2142 for endpath
in self.process.endpaths:
2143 if getattr(self.process,endpath)
not in self.blacklist_paths:
2144 self.pythonCfgCode +=
dumpPython(self.process,endpath)
2147 self.pythonCfgCode +=
"\n# Schedule definition\n"
2148 result =
"process.schedule = cms.Schedule("
2151 self.process.schedule = cms.Schedule()
2152 for item
in self.schedule:
2153 if not isinstance(item, cms.Schedule):
2154 self.process.schedule.append(item)
2156 self.process.schedule.extend(item)
2158 if hasattr(self.process,
"HLTSchedule"):
2159 beforeHLT = self.schedule[:self.schedule.index(self.process.HLTSchedule)]
2160 afterHLT = self.schedule[self.schedule.index(self.process.HLTSchedule)+1:]
2161 pathNames = [
'process.'+p.label_()
for p
in beforeHLT]
2162 result +=
','.
join(pathNames)+
')\n'
2163 result +=
'process.schedule.extend(process.HLTSchedule)\n'
2164 pathNames = [
'process.'+p.label_()
for p
in afterHLT]
2165 result +=
'process.schedule.extend(['+
','.
join(pathNames)+
'])\n'
2167 pathNames = [
'process.'+p.label_()
for p
in self.schedule]
2168 result =
'process.schedule = cms.Schedule('+
','.
join(pathNames)+
')\n'
2170 self.pythonCfgCode += result
2172 if self._options.nThreads
is not "1":
2173 self.pythonCfgCode +=
"\n"
2174 self.pythonCfgCode +=
"#Setup FWK for multithreaded\n"
2175 self.pythonCfgCode +=
"process.options.numberOfThreads=cms.untracked.uint32("+self._options.nThreads+
")\n"
2176 self.pythonCfgCode +=
"process.options.numberOfStreams=cms.untracked.uint32(0)\n"
2178 if self._options.isRepacked:
2179 self.pythonCfgCode +=
"\n"
2180 self.pythonCfgCode +=
"from Configuration.Applications.ConfigBuilder import MassReplaceInputTag\n"
2181 self.pythonCfgCode +=
"MassReplaceInputTag(process)\n"
2185 if self.productionFilterSequence:
2186 self.pythonCfgCode +=
'# filter all path with the production filter sequence\n'
2187 self.pythonCfgCode +=
'for path in process.paths:\n'
2188 if len(self.conditionalPaths):
2189 self.pythonCfgCode +=
'\tif not path in %s: continue\n'%str(self.conditionalPaths)
2190 if len(self.excludedPaths):
2191 self.pythonCfgCode +=
'\tif path in %s: continue\n'%str(self.excludedPaths)
2192 self.pythonCfgCode +=
'\tgetattr(process,path)._seq = process.%s * getattr(process,path)._seq \n'%(self.productionFilterSequence,)
2193 pfs = getattr(self.process,self.productionFilterSequence)
2194 for path
in self.process.paths:
2195 if not path
in self.conditionalPaths:
continue
2196 if path
in self.excludedPaths:
continue
2197 getattr(self.process,path)._seq = pfs * getattr(self.process,path)._seq
2203 if self._options.runUnscheduled:
2206 self.pythonCfgCode+=
"#do not add changes to your config after this point (unless you know what you are doing)\n"
2207 self.pythonCfgCode+=
"from FWCore.ParameterSet.Utilities import convertToUnscheduled\n"
2208 self.pythonCfgCode+=
"process=convertToUnscheduled(process)\n"
2210 from FWCore.ParameterSet.Utilities
import convertToUnscheduled
2214 for module
in self.importsUnsch:
2215 self.process.load(module)
2216 self.pythonCfgCode += (
"process.load('"+module+
"')\n")
2219 self.pythonCfgCode+=
"from FWCore.ParameterSet.Utilities import cleanUnscheduled\n"
2220 self.pythonCfgCode+=
"process=cleanUnscheduled(process)\n"
2222 from FWCore.ParameterSet.Utilities
import cleanUnscheduled
2231 if self._options.io:
2233 if not self._options.io.endswith(
'.io'): self._option.io+=
'.io'
2234 io=open(self._options.io,
'w')
2236 if hasattr(self.process.source,
"fileNames"):
2237 if len(self.process.source.fileNames.value()):
2238 ioJson[
'primary']=self.process.source.fileNames.value()
2239 if hasattr(self.process.source,
"secondaryFileNames"):
2240 if len(self.process.source.secondaryFileNames.value()):
2241 ioJson[
'secondary']=self.process.source.secondaryFileNames.value()
2242 if self._options.pileup_input
and (self._options.pileup_input.startswith(
'dbs:')
or self._options.pileup_input.startswith(
'das:')):
2243 ioJson[
'pileup']=self._options.pileup_input[4:]
2244 for (o,om)
in self.process.outputModules_().items():
2245 ioJson[o]=om.fileName.value()
2246 ioJson[
'GT']=self.process.GlobalTag.globaltag.value()
2247 if self.productionFilterSequence:
2248 ioJson[
'filter']=self.productionFilterSequence
2250 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