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 from subprocess
import Popen,PIPE
12 import FWCore.ParameterSet.DictTypes
as DictTypes
17 defaultOptions = Options()
18 defaultOptions.datamix =
'DataOnSim'
19 defaultOptions.isMC=
False
20 defaultOptions.isData=
True
21 defaultOptions.step=
''
22 defaultOptions.pileup=
'NoPileUp'
23 defaultOptions.pileup_input =
None
24 defaultOptions.geometry =
'SimDB'
25 defaultOptions.geometryExtendedOptions = [
'ExtendedGFlash',
'Extended',
'NoCastor']
26 defaultOptions.magField =
''
27 defaultOptions.conditions =
None
28 defaultOptions.useCondDBv1 =
False
29 defaultOptions.scenarioOptions=[
'pp',
'cosmics',
'nocoll',
'HeavyIons']
30 defaultOptions.harvesting=
'AtRunEnd'
31 defaultOptions.gflash =
False
32 defaultOptions.number = -1
33 defaultOptions.number_out =
None
34 defaultOptions.arguments =
""
35 defaultOptions.name =
"NO NAME GIVEN"
36 defaultOptions.evt_type =
""
37 defaultOptions.filein =
""
38 defaultOptions.dasquery=
""
39 defaultOptions.secondfilein =
""
40 defaultOptions.customisation_file = []
41 defaultOptions.customisation_file_unsch = []
42 defaultOptions.customise_commands =
""
43 defaultOptions.inline_custom=
False
44 defaultOptions.particleTable =
'pythiapdt'
45 defaultOptions.particleTableList = [
'pythiapdt',
'pdt']
46 defaultOptions.dirin =
''
47 defaultOptions.dirout =
''
48 defaultOptions.filetype =
'EDM'
49 defaultOptions.fileout =
'output.root'
50 defaultOptions.filtername =
''
51 defaultOptions.lazy_download =
False
52 defaultOptions.custom_conditions =
''
53 defaultOptions.hltProcess =
''
54 defaultOptions.eventcontent =
None
55 defaultOptions.datatier =
None
56 defaultOptions.inlineEventContent =
True
57 defaultOptions.inlineObjets =
''
58 defaultOptions.hideGen=
False
59 from Configuration.StandardSequences.VtxSmeared
import VtxSmearedDefaultKey,VtxSmearedHIDefaultKey
60 defaultOptions.beamspot=
None
61 defaultOptions.outputDefinition =
''
62 defaultOptions.inputCommands =
None
63 defaultOptions.outputCommands =
None
64 defaultOptions.inputEventContent =
''
65 defaultOptions.dropDescendant =
False
66 defaultOptions.relval =
None
67 defaultOptions.slhc =
None
68 defaultOptions.profile =
None
69 defaultOptions.isRepacked =
False
70 defaultOptions.restoreRNDSeeds =
False
71 defaultOptions.donotDropOnInput =
''
72 defaultOptions.python_filename =
''
73 defaultOptions.io=
None
74 defaultOptions.lumiToProcess=
None
75 defaultOptions.fast=
False
76 defaultOptions.runsAndWeightsForMC =
None
77 defaultOptions.runsScenarioForMC =
None
78 defaultOptions.runUnscheduled =
False
79 defaultOptions.timeoutOutput =
False
80 defaultOptions.nThreads =
'1'
84 theObject = getattr(process,name)
85 if isinstance(theObject,cms.Path)
or isinstance(theObject,cms.EndPath)
or isinstance(theObject,cms.Sequence):
86 return "process."+name+
" = " + theObject.dumpPython(
"process")
87 elif isinstance(theObject,_Module)
or isinstance(theObject,cms.ESProducer):
88 return "process."+name+
" = " + theObject.dumpPython()+
"\n"
90 return "process."+name+
" = " + theObject.dumpPython()+
"\n"
96 for line
in open(fileName,
'r'):
97 if line.count(
".root")>=2:
99 entries=line.replace(
"\n",
"").
split()
100 if not entries[0]
in prim:
101 prim.append(entries[0])
102 if not entries[1]
in sec:
103 sec.append(entries[1])
104 elif (line.find(
".root")!=-1):
105 entry=line.replace(
"\n",
"")
106 if not entry
in prim:
109 if not hasattr(s,
"fileNames"):
110 s.fileNames=cms.untracked.vstring(prim)
112 s.fileNames.extend(prim)
114 if not hasattr(s,
"secondaryFileNames"):
115 s.secondaryFileNames=cms.untracked.vstring(sec)
117 s.secondaryFileNames.extend(sec)
118 print "found files: ",prim
120 raise Exception(
"There are not files in input from the file list")
122 print "found parent files:",sec
130 print "the query is",query
133 while eC!=0
and count<3:
135 print 'Sleeping, then retrying DAS'
137 p = Popen(
'das_client.py --query "%s"'%(query), stdout=PIPE,shell=
True)
138 tupleP = os.waitpid(p.pid, 0)
143 print "DAS succeeded after",count,
"attempts",eC
145 print "DAS failed 3 times- I give up"
146 for line
in pipe.split(
'\n'):
147 if line.count(
".root")>=2:
149 entries=line.replace(
"\n",
"").
split()
150 if not entries[0]
in prim:
151 prim.append(entries[0])
152 if not entries[1]
in sec:
153 sec.append(entries[1])
154 elif (line.find(
".root")!=-1):
155 entry=line.replace(
"\n",
"")
156 if not entry
in prim:
159 if not hasattr(s,
"fileNames"):
160 s.fileNames=cms.untracked.vstring(prim)
162 s.fileNames.extend(prim)
164 if not hasattr(s,
"secondaryFileNames"):
165 s.secondaryFileNames=cms.untracked.vstring(sec)
167 s.secondaryFileNames.extend(sec)
168 print "found files: ",prim
170 print "found parent files:",sec
175 for s
in aProcess.paths_().
keys():
178 def anyOf(listOfKeys,dict,opt=None):
187 raise Exception(
"any of "+
','.
join(listOfKeys)+
" are mandatory entries of --output options")
190 """The main building routines """
192 def __init__(self, options, process = None, with_output = False, with_input = False ):
193 """options taken from old cmsDriver and optparse """
195 options.outfile_name = options.dirout+options.fileout
199 if self._options.isData
and options.isMC:
200 raise Exception(
"ERROR: You may specify only --data or --mc, not both")
205 if 'ENDJOB' in self._options.step:
206 if (hasattr(self.
_options,
"outputDefinition")
and \
207 self._options.outputDefinition !=
'' and \
208 any(
anyOf([
't',
'tier',
'dataTier'],outdic) ==
'DQMIO' for outdic
in eval(self._options.outputDefinition)))
or \
209 (hasattr(self.
_options,
"datatier")
and \
210 self._options.datatier
and \
211 'DQMIO' in self._options.datatier):
212 print "removing ENDJOB from steps since not compatible with DQMIO dataTier"
213 self._options.step=self._options.step.replace(
',ENDJOB',
'')
218 stepList = [re.sub(
r'^prepare_',
'', methodName)
for methodName
in ConfigBuilder.__dict__
if methodName.startswith(
'prepare_')]
221 for step
in self._options.step.split(
","):
222 if step==
'':
continue
223 stepParts = step.split(
":")
224 stepName = stepParts[0]
225 if stepName
not in stepList
and not stepName.startswith(
're'):
226 raise ValueError(
"Step "+stepName+
" unknown")
227 if len(stepParts)==1:
228 self.stepMap[stepName]=
""
229 elif len(stepParts)==2:
230 self.stepMap[stepName]=stepParts[1].
split(
'+')
231 elif len(stepParts)==3:
232 self.stepMap[stepName]=(stepParts[2].
split(
'+'),stepParts[1])
234 raise ValueError(
"Step definition "+step+
" invalid")
235 self.stepKeys.append(stepName)
239 self.with_output = with_output
240 if hasattr(self.
_options,
"no_output_flag")
and self._options.no_output_flag:
241 self.with_output =
False
242 self.with_input = with_input
244 self.process = cms.Process(self._options.name)
246 self.process = process
248 self.importsUnsch = []
250 self.schedule =
list()
256 self.additionalCommands = []
258 self.blacklist_paths = []
259 self.addedObjects = []
260 self.additionalOutputs = {}
262 self.productionFilterSequence =
None
263 self.nextScheduleIsConditional=
False
264 self.conditionalPaths=[]
265 self.excludedPaths=[]
270 Function to add the igprof profile service so that you can dump in the middle
273 profileOpts = self._options.profile.split(
':')
275 profilerInterval = 100
276 profilerFormat =
None
277 profilerJobFormat =
None
283 startEvent = profileOpts.pop(0)
284 if not startEvent.isdigit():
285 raise Exception(
"%s is not a number" % startEvent)
286 profilerStart = int(startEvent)
288 eventInterval = profileOpts.pop(0)
289 if not eventInterval.isdigit():
290 raise Exception(
"%s is not a number" % eventInterval)
291 profilerInterval = int(eventInterval)
293 profilerFormat = profileOpts.pop(0)
296 if not profilerFormat:
297 profilerFormat =
"%s___%s___%s___%s___%s___%s___%%I.gz" % (self._options.evt_type.replace(
"_cfi",
""),
299 self._options.pileup,
300 self._options.conditions,
301 self._options.datatier,
302 self._options.profileTypeLabel)
303 if not profilerJobFormat
and profilerFormat.endswith(
".gz"):
304 profilerJobFormat = profilerFormat.replace(
".gz",
"_EndOfJob.gz")
305 elif not profilerJobFormat:
306 profilerJobFormat = profilerFormat +
"_EndOfJob.gz"
308 return (profilerStart,profilerInterval,profilerFormat,profilerJobFormat)
311 includeFile = includeFile.replace(
'/',
'.')
312 self.process.load(includeFile)
313 return sys.modules[includeFile]
316 """helper routine to load am memorize imports"""
319 includeFile = includeFile.replace(
'/',
'.')
321 self.imports.append(includeFile)
322 self.process.load(includeFile)
323 return sys.modules[includeFile]
325 self.importsUnsch.append(includeFile)
329 """helper routine to remember replace statements"""
330 self.additionalCommands.append(command)
331 if not command.strip().startswith(
"#"):
334 exec(re.sub(
r"([^a-zA-Z_0-9]|^)(process)([^a-zA-Z_0-9])",
r"\1self.process\3",command))
338 if 'HARVESTING' in self.stepMap.keys()
or 'ALCAHARVEST' in self.stepMap.keys():
339 self.process.options = cms.untracked.PSet( Rethrow = cms.untracked.vstring(
'ProductNotFound'),fileMode = cms.untracked.string(
'FULLMERGE'))
341 self.process.options = cms.untracked.PSet( )
343 if self._options.runUnscheduled:
344 self.process.options.allowUnscheduled=cms.untracked.bool(
True)
346 self.addedObjects.append((
"",
"options"))
348 if self._options.lazy_download:
349 self.process.AdaptorConfig = cms.Service(
"AdaptorConfig",
350 stats = cms.untracked.bool(
True),
351 enable = cms.untracked.bool(
True),
352 cacheHint = cms.untracked.string(
"lazy-download"),
353 readHint = cms.untracked.string(
"read-ahead-buffered")
355 self.addedObjects.append((
"Setup lazy download",
"AdaptorConfig"))
360 if self._options.profile:
362 self.process.IgProfService = cms.Service(
"IgProfService",
363 reportFirstEvent = cms.untracked.int32(start),
364 reportEventInterval = cms.untracked.int32(interval),
365 reportToFileAtPostEvent = cms.untracked.string(
"| gzip -c > %s"%(eventFormat)),
366 reportToFileAtPostEndJob = cms.untracked.string(
"| gzip -c > %s"%(jobFormat)))
367 self.addedObjects.append((
"Setup IGProf Service for profiling",
"IgProfService"))
370 """Here we decide how many evts will be processed"""
371 self.process.maxEvents=cms.untracked.PSet(input=cms.untracked.int32(int(self._options.number)))
372 if self._options.number_out:
373 self.process.maxEvents.output = cms.untracked.int32(int(self._options.number_out))
374 self.addedObjects.append((
"",
"maxEvents"))
377 """Here the source is built. Priority: file, generator"""
378 self.addedObjects.append((
"Input source",
"source"))
381 for entry
in self._options.filein.split(
','):
383 if entry.startswith(
"filelist:"):
385 elif entry.startswith(
"dbs:")
or entry.startswith(
"das:"):
388 self.process.source.fileNames.append(self._options.dirin+entry)
389 if self._options.secondfilein:
390 if not hasattr(self.process.source,
"secondaryFileNames"):
391 raise Exception(
"--secondfilein not compatible with "+self._options.filetype+
"input type")
392 for entry
in self._options.secondfilein.split(
','):
394 if entry.startswith(
"filelist:"):
395 self.process.source.secondaryFileNames.extend((
filesFromList(entry[9:]))[0])
396 elif entry.startswith(
"dbs:")
or entry.startswith(
"das:"):
397 self.process.source.secondaryFileNames.extend((
filesFromDASQuery(
'file dataset = %s'%(entry[4:])))[0])
399 self.process.source.secondaryFileNames.append(self._options.dirin+entry)
401 if self._options.filein
or self._options.dasquery:
402 if self._options.filetype ==
"EDM":
403 self.process.source=cms.Source(
"PoolSource",
404 fileNames = cms.untracked.vstring(),
405 secondaryFileNames= cms.untracked.vstring())
407 elif self._options.filetype ==
"DAT":
408 self.process.source=cms.Source(
"NewEventStreamFileReader",fileNames = cms.untracked.vstring())
410 elif self._options.filetype ==
"LHE":
411 self.process.source=cms.Source(
"LHESource", fileNames = cms.untracked.vstring())
412 if self._options.filein.startswith(
"lhe:"):
414 args=self._options.filein.split(
':')
416 print 'LHE input from article ',article
417 location=
'/store/lhe/'
419 textOfFiles=os.popen(
'cmsLHEtoEOSManager.py -l '+article)
420 for line
in textOfFiles:
421 for fileName
in [x
for x
in line.split()
if '.lhe' in x]:
422 self.process.source.fileNames.append(location+article+
'/'+fileName)
424 self.process.source.skipEvents = cms.untracked.uint32(int(args[2]))
429 elif self._options.filetype ==
"DQM":
430 self.process.source=cms.Source(
"DQMRootSource",
431 fileNames = cms.untracked.vstring())
434 elif self._options.filetype ==
"DQMDAQ":
436 self.process.source=cms.Source(
"DQMStreamerReader")
439 if (
'HARVESTING' in self.stepMap.keys()
or 'ALCAHARVEST' in self.stepMap.keys())
and (
not self._options.filetype ==
"DQM"):
440 self.process.source.processingMode = cms.untracked.string(
"RunsAndLumis")
442 if self._options.dasquery!=
'':
443 self.process.source=cms.Source(
"PoolSource", fileNames = cms.untracked.vstring(),secondaryFileNames = cms.untracked.vstring())
447 if 'GEN' in self.stepMap.keys():
448 if self._options.inputCommands:
449 self._options.inputCommands+=
',drop LHEXMLStringProduct_*_*_*,'
451 self._options.inputCommands=
'keep *, drop LHEXMLStringProduct_*_*_*,'
453 if self.process.source
and self._options.inputCommands:
454 if not hasattr(self.process.source,
'inputCommands'): self.process.source.inputCommands=cms.untracked.vstring()
455 for command
in self._options.inputCommands.split(
','):
457 command = command.strip()
458 if command==
'':
continue
459 self.process.source.inputCommands.append(command)
460 if not self._options.dropDescendant:
461 self.process.source.dropDescendantsOfDroppedBranches = cms.untracked.bool(
False)
463 if self._options.lumiToProcess:
464 import FWCore.PythonUtilities.LumiList
as LumiList
465 self.process.source.lumisToProcess = cms.untracked.VLuminosityBlockRange(
LumiList.LumiList(self._options.lumiToProcess).getCMSSWString().
split(
',') )
467 if 'GEN' in self.stepMap.keys()
or 'LHE' in self.stepMap
or (
not self._options.filein
and hasattr(self.
_options,
"evt_type")):
468 if self.process.source
is None:
469 self.process.source=cms.Source(
"EmptySource")
472 self.runsAndWeights=
None
473 if self._options.runsAndWeightsForMC
or self._options.runsScenarioForMC :
474 if not self._options.isMC :
475 raise Exception(
"options --runsAndWeightsForMC and --runsScenarioForMC are only valid for MC")
476 if self._options.runsAndWeightsForMC:
477 self.runsAndWeights = eval(self._options.runsAndWeightsForMC)
479 from Configuration.StandardSequences.RunsAndWeights
import RunsAndWeights
480 if type(RunsAndWeights[self._options.runsScenarioForMC])==str:
481 __import__(RunsAndWeights[self._options.runsScenarioForMC])
482 self.runsAndWeights = sys.modules[RunsAndWeights[self._options.runsScenarioForMC]].runProbabilityDistribution
484 self.runsAndWeights = RunsAndWeights[self._options.runsScenarioForMC]
486 if self.runsAndWeights:
487 import SimGeneral.Configuration.ThrowAndSetRandomRun
as ThrowAndSetRandomRun
489 self.additionalCommands.append(
'import SimGeneral.Configuration.ThrowAndSetRandomRun as ThrowAndSetRandomRun')
490 self.additionalCommands.append(
'ThrowAndSetRandomRun.throwAndSetRandomRun(process.source,%s)'%(self.runsAndWeights))
495 """ Add output module to the process """
497 if self._options.outputDefinition:
498 if self._options.datatier:
499 print "--datatier & --eventcontent options ignored"
502 outList = eval(self._options.outputDefinition)
503 for (id,outDefDict)
in enumerate(outList):
504 outDefDictStr=outDefDict.__str__()
505 if not isinstance(outDefDict,dict):
506 raise Exception(
"--output needs to be passed a list of dict"+self._options.outputDefinition+
" is invalid")
508 theTier=
anyOf([
't',
'tier',
'dataTier'],outDefDict)
511 theStreamType=
anyOf([
'e',
'ec',
'eventContent',
'streamType'],outDefDict,theTier)
512 theFilterName=
anyOf([
'f',
'ftN',
'filterName'],outDefDict,
'')
513 theSelectEvent=
anyOf([
's',
'sE',
'selectEvents'],outDefDict,
'')
514 theModuleLabel=
anyOf([
'l',
'mL',
'moduleLabel'],outDefDict,
'')
515 theExtraOutputCommands=
anyOf([
'o',
'oC',
'outputCommands'],outDefDict,
'')
517 if not theModuleLabel:
518 tryNames=[theStreamType.replace(theTier.replace(
'-',
''),
'')+theTier.replace(
'-',
'')+
'output',
519 theStreamType.replace(theTier.replace(
'-',
''),
'')+theTier.replace(
'-',
'')+theFilterName+
'output',
520 theStreamType.replace(theTier.replace(
'-',
''),
'')+theTier.replace(
'-',
'')+theFilterName+theSelectEvent.split(
',')[0].
replace(
':',
'for').
replace(
' ',
'')+
'output'
522 for name
in tryNames:
523 if not hasattr(self.process,name):
526 if not theModuleLabel:
527 raise Exception(
"cannot find a module label for specification: "+outDefDictStr)
529 defaultFileName=self._options.outfile_name
531 defaultFileName=self._options.outfile_name.replace(
'.root',
'_in'+theTier+
'.root')
533 theFileName=self._options.dirout+
anyOf([
'fn',
'fileName'],outDefDict,defaultFileName)
534 if not theFileName.endswith(
'.root'):
537 if len(outDefDict.keys()):
538 raise Exception(
"unused keys from --output options: "+
','.
join(outDefDict.keys()))
539 if theStreamType==
'DQMIO': theStreamType=
'DQM'
540 if theStreamType==
'ALL':
541 theEventContent = cms.PSet(outputCommands = cms.untracked.vstring(
'keep *'))
543 theEventContent = getattr(self.process, theStreamType+
"EventContent")
547 if theStreamType==
'ALCARECO' and not theFilterName:
548 theFilterName=
'StreamALCACombined'
551 CppType=
'PoolOutputModule'
552 if self._options.timeoutOutput:
553 CppType=
'TimeoutPoolOutputModule'
554 if theStreamType==
'DQM' and theTier==
'DQMIO': CppType=
'DQMRootOutputModule'
555 output = cms.OutputModule(CppType,
556 theEventContent.clone(),
557 fileName = cms.untracked.string(theFileName),
558 dataset = cms.untracked.PSet(
559 dataTier = cms.untracked.string(theTier),
560 filterName = cms.untracked.string(theFilterName))
562 if not theSelectEvent
and hasattr(self.process,
'generation_step')
and theStreamType!=
'LHE':
563 output.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
'generation_step'))
564 if not theSelectEvent
and hasattr(self.process,
'filtering_step'):
565 output.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
'filtering_step'))
567 output.SelectEvents =cms.untracked.PSet(SelectEvents = cms.vstring(theSelectEvent))
570 if not hasattr(output,
'SelectEvents'):
571 output.SelectEvents=cms.untracked.PSet(SelectEvents=cms.vstring())
572 for alca
in self.AlCaPaths:
573 output.SelectEvents.SelectEvents.extend(getattr(self.process,
'OutALCARECO'+alca).SelectEvents.SelectEvents)
576 if hasattr(self.process,theModuleLabel):
577 raise Exception(
"the current process already has a module "+theModuleLabel+
" defined")
579 setattr(self.process,theModuleLabel,output)
580 outputModule=getattr(self.process,theModuleLabel)
581 setattr(self.process,theModuleLabel+
'_step',cms.EndPath(outputModule))
582 path=getattr(self.process,theModuleLabel+
'_step')
583 self.schedule.append(path)
585 if not self._options.inlineEventContent
and hasattr(self.process,theStreamType+
"EventContent"):
588 outputModule.outputCommands.__dict__[
"dumpPython"] = doNotInlineEventContent
589 if theExtraOutputCommands:
590 if not isinstance(theExtraOutputCommands,list):
591 raise Exception(
"extra ouput command in --option must be a list of strings")
592 if hasattr(self.process,theStreamType+
"EventContent"):
593 self.
executeAndRemember(
'process.%s.outputCommands.extend(%s)'%(theModuleLabel,theExtraOutputCommands))
595 outputModule.outputCommands.extend(theExtraOutputCommands)
597 result+=
"\nprocess."+theModuleLabel+
" = "+outputModule.dumpPython()
602 streamTypes=self._options.eventcontent.split(
',')
603 tiers=self._options.datatier.split(
',')
604 if not self._options.outputDefinition
and len(streamTypes)!=len(tiers):
605 raise Exception(
"number of event content arguments does not match number of datatier arguments")
608 if self._options.step.split(
',')[0].
split(
':')[0] ==
'ALCA':
611 for i,(streamType,tier)
in enumerate(zip(streamTypes,tiers)):
612 if streamType==
'':
continue
613 if streamType==
'DQMIO': streamType=
'DQM'
614 theEventContent = getattr(self.process, streamType+
"EventContent")
616 theFileName=self._options.outfile_name
617 theFilterName=self._options.filtername
619 theFileName=self._options.outfile_name.replace(
'.root',
'_in'+streamType+
'.root')
620 theFilterName=self._options.filtername
621 CppType=
'PoolOutputModule'
622 if self._options.timeoutOutput:
623 CppType=
'TimeoutPoolOutputModule'
624 if streamType==
'DQM' and tier==
'DQMIO': CppType=
'DQMRootOutputModule'
625 output = cms.OutputModule(CppType,
627 fileName = cms.untracked.string(theFileName),
628 dataset = cms.untracked.PSet(dataTier = cms.untracked.string(tier),
629 filterName = cms.untracked.string(theFilterName)
632 if hasattr(self.process,
"generation_step")
and streamType!=
'LHE':
633 output.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
'generation_step'))
634 if hasattr(self.process,
"filtering_step"):
635 output.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
'filtering_step'))
637 if streamType==
'ALCARECO':
638 output.dataset.filterName = cms.untracked.string(
'StreamALCACombined')
640 if "MINIAOD" in streamType:
641 output.dropMetaData = cms.untracked.string(
'ALL')
642 output.fastCloning= cms.untracked.bool(
False)
643 output.overrideInputFileSplitLevels = cms.untracked.bool(
True)
645 outputModuleName=streamType+
'output'
646 setattr(self.process,outputModuleName,output)
647 outputModule=getattr(self.process,outputModuleName)
648 setattr(self.process,outputModuleName+
'_step',cms.EndPath(outputModule))
649 path=getattr(self.process,outputModuleName+
'_step')
650 self.schedule.append(path)
652 if self._options.outputCommands
and streamType!=
'DQM':
653 for evct
in self._options.outputCommands.split(
','):
654 if not evct:
continue
655 self.
executeAndRemember(
"process.%s.outputCommands.append('%s')"%(outputModuleName,evct.strip()))
657 if not self._options.inlineEventContent:
660 outputModule.outputCommands.__dict__[
"dumpPython"] = doNotInlineEventContent
662 result+=
"\nprocess."+outputModuleName+
" = "+outputModule.dumpPython()
668 Add selected standard sequences to the process
671 if self._options.pileup:
672 pileupSpec=self._options.pileup.split(
',')[0]
676 if self._options.fast
and pileupSpec.find(
"GEN_") == 0:
678 pileupSpec = pileupSpec[4:]
681 from Configuration.StandardSequences.Mixing
import Mixing,defineMixing
682 if not pileupSpec
in Mixing
and '.' not in pileupSpec
and 'file:' not in pileupSpec:
683 message = pileupSpec+
' is not a know mixing scenario:\n available are: '+
'\n'.
join(Mixing.keys())
684 if self._options.fast:
685 message +=
"\n-"*20+
"\n additional options for FastSim (gen-mixing):\n" +
"-"*20 +
"\n" +
'\n'.
join([
"GEN_" + x
for x
in Mixing.keys()]) +
"\n"
689 if '.' in pileupSpec:
690 mixingDict={
'file':pileupSpec}
691 elif pileupSpec.startswith(
'file:'):
692 mixingDict={
'file':pileupSpec[5:]}
695 mixingDict=copy.copy(Mixing[pileupSpec])
696 if len(self._options.pileup.split(
','))>1:
697 mixingDict.update(eval(self._options.pileup[self._options.pileup.find(
',')+1:]))
700 if 'file:' in pileupSpec:
702 self.process.load(mixingDict[
'file'])
703 print "inlining mixing module configuration"
704 self._options.inlineObjets+=
',mix'
709 if self._options.fast:
711 self._options.customisation_file.insert(0,
"FastSimulation/Configuration/MixingModule_Full2Fast.prepareGenMixing")
713 self._options.customisation_file.insert(0,
"FastSimulation/Configuration/MixingModule_Full2Fast.prepareDigiRecoMixing")
715 mixingDict.pop(
'file')
716 if not "DATAMIX" in self.stepMap.keys():
717 if self._options.pileup_input:
718 if self._options.pileup_input.startswith(
'dbs:')
or self._options.pileup_input.startswith(
'das:'):
719 mixingDict[
'F']=
filesFromDASQuery(
'file dataset = %s'%(self._options.pileup_input[4:],))[0]
721 mixingDict[
'F']=self._options.pileup_input.split(
',')
723 for command
in specialization:
725 if len(mixingDict)!=0:
726 raise Exception(
'unused mixing specification: '+mixingDict.keys().
__str__())
731 if len(self.stepMap):
733 if (
'SIM' in self.stepMap
or 'reSIM' in self.stepMap)
and not self._options.fast:
735 if self.geometryDBLabel:
736 self.
executeAndRemember(
'process.XMLFromDBSource.label = cms.string("%s")'%(self.geometryDBLabel))
738 print "Geometry option",self._options.geometry,
"unknown."
741 if len(self.stepMap):
744 for stepName
in self.stepKeys:
745 stepSpec = self.stepMap[stepName]
746 print "Step:", stepName,
"Spec:",stepSpec
747 if stepName.startswith(
're'):
749 if stepName[2:]
not in self._options.donotDropOnInput:
750 self._options.inputEventContent=
'%s,%s'%(stepName.upper(),self._options.inputEventContent)
751 stepName=stepName[2:]
753 getattr(self,
"prepare_"+stepName)(sequence = getattr(self,stepName+
"DefaultSeq"))
754 elif type(stepSpec)==list:
755 getattr(self,
"prepare_"+stepName)(sequence =
'+'.
join(stepSpec))
756 elif type(stepSpec)==tuple:
757 getattr(self,
"prepare_"+stepName)(sequence =
','.
join([stepSpec[1],
'+'.
join(stepSpec[0])]))
759 raise ValueError(
"Invalid step definition")
761 if self._options.restoreRNDSeeds!=
False:
763 if self._options.restoreRNDSeeds==
True:
764 self.
executeAndRemember(
'process.RandomNumberGeneratorService.restoreStateLabel=cms.untracked.string("randomEngineStateProducer")')
766 self.
executeAndRemember(
'process.RandomNumberGeneratorService.restoreStateTag=cms.untracked.InputTag("randomEngineStateProducer","","%s")'%(self._options.restoreRNDSeeds))
767 if self._options.inputEventContent
or self._options.inputCommands:
768 if self._options.inputCommands:
769 self._options.inputCommands+=
'keep *_randomEngineStateProducer_*_*,'
771 self._options.inputCommands=
'keep *_randomEngineStateProducer_*_*,'
775 if self._options.inputEventContent:
777 def dropSecondDropStar(iec):
788 if not hasattr(self.process.source,
'inputCommands'): self.process.source.inputCommands=cms.untracked.vstring()
789 for evct
in self._options.inputEventContent.split(
','):
790 if evct==
'':
continue
791 theEventContent = getattr(self.process, evct+
"EventContent")
792 if hasattr(theEventContent,
'outputCommands'):
793 self.process.source.inputCommands.extend(copy.copy(theEventContent.outputCommands))
794 if hasattr(theEventContent,
'inputCommands'):
795 self.process.source.inputCommands.extend(copy.copy(theEventContent.inputCommands))
797 dropSecondDropStar(self.process.source.inputCommands)
799 if not self._options.dropDescendant:
800 self.process.source.dropDescendantsOfDroppedBranches = cms.untracked.bool(
False)
806 """Add conditions to the process"""
807 if not self._options.conditions:
return
809 if 'FrontierConditions_GlobalTag' in self._options.conditions:
810 print 'using FrontierConditions_GlobalTag in --conditions is not necessary anymore and will be deprecated soon. please update your command line'
811 self._options.conditions = self._options.conditions.replace(
"FrontierConditions_GlobalTag,",
'')
813 self.loadAndRemember(self.ConditionsDefaultCFF)
815 if self._options.useCondDBv1:
816 from Configuration.AlCa.GlobalTag_condDBv1
import GlobalTag
820 self.process.GlobalTag =
GlobalTag(self.process.GlobalTag, self._options.conditions, self._options.custom_conditions)
822 if self._options.useCondDBv1:
823 self.additionalCommands.append(
'from Configuration.AlCa.GlobalTag_condDBv1 import GlobalTag')
825 self.additionalCommands.append(
'from Configuration.AlCa.GlobalTag import GlobalTag')
827 self.additionalCommands.append(
'process.GlobalTag = GlobalTag(process.GlobalTag, %s, %s)' % (repr(self._options.conditions), repr(self._options.custom_conditions)))
829 if self._options.slhc:
830 self.loadAndRemember(
"SLHCUpgradeSimulations/Geometry/fakeConditions_%s_cff"%(self._options.slhc,))
834 """Include the customise code """
838 for c
in self._options.customisation_file:
839 custOpt.extend(c.split(
","))
841 for c
in self._options.customisation_file_unsch:
842 custOpt.extend(c.split(
","))
848 raise Exception(
"more than . in the specification:"+opt)
849 fileName=opt.split(
'.')[0]
850 if opt.count(
'.')==0: rest=
'customise'
852 rest=opt.split(
'.')[1]
853 if rest==
'py': rest=
'customise'
855 if fileName
in custMap:
856 custMap[fileName].extend(rest.split(
'+'))
858 custMap[fileName]=rest.split(
'+')
863 final_snippet=
'\n# customisation of the process.\n'
867 allFcn.extend(custMap[opt])
869 if allFcn.count(fcn)!=1:
870 raise Exception(
"cannot specify twice "+fcn+
" as a customisation method")
874 packageName = f.replace(
".py",
"").
replace(
"/",
".")
875 __import__(packageName)
876 package = sys.modules[packageName]
879 customiseFile = re.sub(
r'\.pyc$',
'.py', package.__file__)
881 final_snippet+=
'\n# Automatic addition of the customisation function from '+packageName+
'\n'
882 if self._options.inline_custom:
883 for line
in file(customiseFile,
'r'):
884 if "import FWCore.ParameterSet.Config" in line:
886 final_snippet += line
888 final_snippet +=
'from %s import %s \n'%(packageName,
','.
join(custMap[f]))
889 for fcn
in custMap[f]:
890 print "customising the process with",fcn,
"from",f
891 if not hasattr(package,fcn):
893 raise Exception(
"config "+f+
" has no function "+fcn)
895 self.process=getattr(package,fcn)(self.process)
897 final_snippet +=
"\n#call to customisation function "+fcn+
" imported from "+packageName
898 final_snippet +=
"\nprocess = %s(process)\n"%(fcn,)
901 final_snippet +=
'\n# End of customisation functions\n'
904 if unsch==1
or not self._options.runUnscheduled:
905 if self._options.customise_commands:
907 final_snippet +=
'\n# Customisation from command line'
908 for com
in self._options.customise_commands.split(
'\\n'):
909 com=string.lstrip(com)
911 final_snippet +=
'\n'+com
920 if len(self.stepMap):
922 if self._options.particleTable
not in defaultOptions.particleTableList:
923 print 'Invalid particle table provided. Options are:'
924 print defaultOptions.particleTable
927 if len(self.stepMap):
928 self.
loadAndRemember(
'SimGeneral.HepPDTESSource.'+self._options.particleTable+
'_cfi')
945 self.EIDefaultCFF=
None
946 self.SKIMDefaultCFF=
"Configuration/StandardSequences/Skims_cff"
947 self.POSTRECODefaultCFF=
"Configuration/StandardSequences/PostRecoGenerator_cff"
948 self.VALIDATIONDefaultCFF=
"Configuration/StandardSequences/Validation_cff"
949 self.L1HwValDefaultCFF =
"Configuration/StandardSequences/L1HwVal_cff"
950 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOffline_cff"
951 self.HARVESTINGDefaultCFF=
"Configuration/StandardSequences/Harvesting_cff"
952 self.ALCAHARVESTDefaultCFF=
"Configuration/StandardSequences/AlCaHarvesting_cff"
953 self.ENDJOBDefaultCFF=
"Configuration/StandardSequences/EndOfProcess_cff"
954 if self._options.useCondDBv1:
955 self.ConditionsDefaultCFF =
"Configuration/StandardSequences/FrontierConditions_GlobalTag_condDBv1_cff"
957 self.ConditionsDefaultCFF =
"Configuration/StandardSequences/FrontierConditions_GlobalTag_cff"
958 self.CFWRITERDefaultCFF =
"Configuration/StandardSequences/CrossingFrameWriter_cff"
959 self.REPACKDefaultCFF=
"Configuration/StandardSequences/DigiToRaw_Repack_cff"
961 if "DATAMIX" in self.stepMap.keys():
962 self.DATAMIXDefaultCFF=
"Configuration/StandardSequences/DataMixer"+self._options.datamix+
"_cff"
963 if self._options.datamix ==
'PreMix':
964 self.
DIGIDefaultCFF=
"Configuration/StandardSequences/DigiDMPreMix_cff"
968 self.
L1EMDefaultCFF=
'Configuration/StandardSequences/SimL1EmulatorDM_cff'
970 if "DIGIPREMIX" in self.stepMap.keys():
971 self.
DIGIDefaultCFF=
"Configuration/StandardSequences/Digi_PreMix_cff"
973 self.ALCADefaultSeq=
None
974 self.LHEDefaultSeq=
'externalLHEProducer'
975 self.GENDefaultSeq=
'pgen'
976 self.SIMDefaultSeq=
'psim'
977 self.DIGIDefaultSeq=
'pdigi'
978 self.DIGIPREMIXDefaultSeq=
'pdigi'
979 self.DIGIPREMIX_S2DefaultSeq=
'pdigi'
980 self.DATAMIXDefaultSeq=
None
981 self.DIGI2RAWDefaultSeq=
'DigiToRaw'
982 self.HLTDefaultSeq=
'GRun'
983 self.L1DefaultSeq=
None
984 self.L1REPACKDefaultSeq=
'GT'
985 self.HARVESTINGDefaultSeq=
None
986 self.ALCAHARVESTDefaultSeq=
None
987 self.CFWRITERDefaultSeq=
None
988 self.RAW2DIGIDefaultSeq=
'RawToDigi'
989 self.L1RecoDefaultSeq=
'L1Reco'
990 self.L1TrackTriggerDefaultSeq=
'L1TrackTrigger'
991 if 'RAW2DIGI' in self.stepMap
and 'RECO' in self.stepMap:
992 self.RECODefaultSeq=
'reconstruction'
994 self.RECODefaultSeq=
'reconstruction_fromRECO'
996 self.EIDefaultSeq=
'top'
997 self.POSTRECODefaultSeq=
None
998 self.L1HwValDefaultSeq=
'L1HwVal'
999 self.DQMDefaultSeq=
'DQMOffline'
1000 self.VALIDATIONDefaultSeq=
''
1001 self.ENDJOBDefaultSeq=
'endOfProcess'
1002 self.REPACKDefaultSeq=
'DigiToRawRepack'
1003 self.PATDefaultSeq=
'miniAOD'
1005 self.EVTCONTDefaultCFF=
"Configuration/EventContent/EventContent_cff"
1007 if not self._options.beamspot:
1008 self._options.beamspot=VtxSmearedDefaultKey
1011 if self._options.isMC==
True:
1013 self.
RECODefaultCFF=
"Configuration/StandardSequences/Reconstruction_cff"
1014 self.
PATDefaultCFF=
"Configuration/StandardSequences/PATMC_cff"
1015 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineMC_cff"
1016 self.
ALCADefaultCFF=
"Configuration/StandardSequences/AlCaRecoStreamsMC_cff"
1018 self._options.beamspot =
None
1021 if 'reGEN' in self.stepMap:
1022 self.GENDefaultSeq=
'fixGenInfo'
1024 if self._options.scenario==
'cosmics':
1025 self._options.pileup=
'Cosmics'
1026 self.
DIGIDefaultCFF=
"Configuration/StandardSequences/DigiCosmics_cff"
1027 self.
RECODefaultCFF=
"Configuration/StandardSequences/ReconstructionCosmics_cff"
1028 self.SKIMDefaultCFF=
"Configuration/StandardSequences/SkimsCosmics_cff"
1029 self.EVTCONTDefaultCFF=
"Configuration/EventContent/EventContentCosmics_cff"
1030 self.VALIDATIONDefaultCFF=
"Configuration/StandardSequences/ValidationCosmics_cff"
1031 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineCosmics_cff"
1032 if self._options.isMC==
True:
1033 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineCosmicsMC_cff"
1034 self.HARVESTINGDefaultCFF=
"Configuration/StandardSequences/HarvestingCosmics_cff"
1035 self.RECODefaultSeq=
'reconstructionCosmics'
1036 self.DQMDefaultSeq=
'DQMOfflineCosmics'
1038 if self._options.scenario==
'HeavyIons':
1039 if not self._options.beamspot:
1040 self._options.beamspot=VtxSmearedHIDefaultKey
1041 self.HLTDefaultSeq =
'HIon'
1042 self.VALIDATIONDefaultCFF=
"Configuration/StandardSequences/ValidationHeavyIons_cff"
1043 self.VALIDATIONDefaultSeq=
''
1044 self.EVTCONTDefaultCFF=
"Configuration/EventContent/EventContentHeavyIons_cff"
1045 self.
RECODefaultCFF=
"Configuration/StandardSequences/ReconstructionHeavyIons_cff"
1046 self.RECODefaultSeq=
'reconstructionHeavyIons'
1047 self.
ALCADefaultCFF =
"Configuration/StandardSequences/AlCaRecoStreamsHeavyIons_cff"
1048 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineHeavyIons_cff"
1049 self.DQMDefaultSeq=
'DQMOfflineHeavyIons'
1050 self.SKIMDefaultCFF=
"Configuration/StandardSequences/SkimsHeavyIons_cff"
1051 self.HARVESTINGDefaultCFF=
"Configuration/StandardSequences/HarvestingHeavyIons_cff"
1052 if self._options.isMC==
True:
1053 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineHeavyIonsMC_cff"
1056 self.RAW2RECODefaultSeq=
','.
join([self.RAW2DIGIDefaultSeq,self.RECODefaultSeq])
1058 self.USERDefaultSeq=
'user'
1059 self.USERDefaultCFF=
None
1062 if self._options.isData:
1063 if self._options.magField==defaultOptions.magField:
1064 print "magnetic field option forced to: AutoFromDBCurrent"
1065 self._options.magField=
'AutoFromDBCurrent'
1066 self.magFieldCFF =
'Configuration/StandardSequences/MagneticField_'+self._options.magField.replace(
'.',
'')+
'_cff'
1067 self.magFieldCFF = self.magFieldCFF.replace(
"__",
'_')
1070 self.GeometryCFF=
'Configuration/StandardSequences/GeometryRecoDB_cff'
1071 self.geometryDBLabel=
None
1073 if self._options.fast:
1074 if 'start' in self._options.conditions.lower():
1075 self.GeometryCFF=
'FastSimulation/Configuration/Geometries_START_cff'
1077 self.GeometryCFF=
'FastSimulation/Configuration/Geometries_MC_cff'
1080 from Configuration.StandardSequences.GeometryConf
import GeometryConf
1081 if opt
in GeometryConf:
1082 return GeometryConf[opt]
1086 geoms=self._options.geometry.split(
',')
1090 if '/' in geoms[1]
or '_cff' in geoms[1]:
1091 self.GeometryCFF=geoms[1]
1093 self.GeometryCFF=
'Configuration/Geometry/Geometry'+geoms[1]+
'_cff'
1095 if (geoms[0].startswith(
'DB:')):
1096 self.SimGeometryCFF=
'Configuration/StandardSequences/GeometrySimDB_cff'
1097 self.geometryDBLabel=geoms[0][3:]
1100 if '/' in geoms[0]
or '_cff' in geoms[0]:
1101 self.SimGeometryCFF=geoms[0]
1103 simGeometry=geoms[0]
1104 if self._options.gflash==
True:
1105 self.SimGeometryCFF=
'Configuration/Geometry/Geometry'+geoms[0]+
'GFlash_cff'
1107 self.SimGeometryCFF=
'Configuration/Geometry/Geometry'+geoms[0]+
'_cff'
1110 if simGeometry
not in defaultOptions.geometryExtendedOptions:
1111 self.
SIMDefaultCFF=
"Configuration/StandardSequences/SimIdeal_cff"
1113 if self._options.scenario==
'nocoll' or self._options.scenario==
'cosmics':
1114 self.
SIMDefaultCFF=
"Configuration/StandardSequences/SimNOBEAM_cff"
1115 self._options.beamspot=
'NoSmear'
1118 if self._options.fast:
1119 self.
SIMDefaultCFF =
'FastSimulation.Configuration.SimIdeal_cff'
1120 self.SIMDefaultSeq =
'psim'
1121 self.
RECODefaultCFF=
'FastSimulation.Configuration.Reconstruction_AftMix_cff'
1122 self.RECODefaultSeq=
'reconstruction'
1123 self.EVTCONTDefaultCFF =
"FastSimulation.Configuration.EventContent_cff"
1124 self.VALIDATIONDefaultCFF =
"FastSimulation.Configuration.Validation_cff"
1125 self.RECOBEFMIXDefaultCFF =
'FastSimulation.Configuration.Reconstruction_BefMix_cff'
1126 self.RECOBEFMIXDefaultSeq =
'reconstruction_befmix'
1128 if self._options.datamix ==
'PreMix':
1129 self.
DIGIDefaultCFF=
"FastSimulation.Configuration.DigiDMPreMix_cff"
1130 if "DIGIPREMIX" in self.stepMap.keys():
1131 self.
DIGIDefaultCFF=
"FastSimulation.Configuration.Digi_PreMix_cff"
1132 if "DATAMIX" in self.stepMap.keys():
1133 self.DATAMIXDefaultCFF=
"FastSimulation.Configuration.DataMixer"+self._options.datamix+
"_cff"
1135 self.DIGIDefaultSeq =
'pdigi'
1136 self.
L1EMDefaultCFF=
'FastSimulation.Configuration.SimL1Emulator_cff'
1139 self.DIGI2RAWDefaultSeq =
'DigiToRaw'
1140 self.EVTCONTDefaultCFF =
"FastSimulation.Configuration.EventContent_cff"
1141 self.VALIDATIONDefaultCFF =
"FastSimulation.Configuration.Validation_cff"
1146 if self._options.pileup==
'default':
1147 from Configuration.StandardSequences.Mixing
import MixingDefaultKey
1148 self._options.pileup=MixingDefaultKey
1150 if self._options.fast:
1151 self._options.pileup=
"GEN_" + MixingDefaultKey
1155 if self._options.isData:
1156 self._options.pileup=
None
1158 if self._options.slhc:
1159 self.GeometryCFF=
'SLHCUpgradeSimulations.Geometry.%s_cmsSimIdealGeometryXML_cff'%(self._options.slhc,)
1160 if 'stdgeom' not in self._options.slhc:
1161 self.SimGeometryCFF=
'SLHCUpgradeSimulations.Geometry.%s_cmsSimIdealGeometryXML_cff'%(self._options.slhc,)
1162 self.
DIGIDefaultCFF=
'SLHCUpgradeSimulations/Geometry/Digi_%s_cff'%(self._options.slhc,)
1163 if self._options.pileup!=defaultOptions.pileup:
1164 self._options.pileup=
'SLHC_%s_%s'%(self._options.pileup,self._options.slhc)
1166 self.REDIGIDefaultSeq=self.DIGIDefaultSeq
1171 output = cms.OutputModule(
"PoolOutputModule")
1172 if stream.selectEvents.parameters_().__len__()!=0:
1173 output.SelectEvents = stream.selectEvents
1175 output.SelectEvents = cms.untracked.PSet()
1176 output.SelectEvents.SelectEvents=cms.vstring()
1177 if isinstance(stream.paths,tuple):
1178 for path
in stream.paths:
1179 output.SelectEvents.SelectEvents.append(path.label())
1181 output.SelectEvents.SelectEvents.append(stream.paths.label())
1185 if isinstance(stream.content,str):
1186 evtPset=getattr(self.process,stream.content)
1187 for p
in evtPset.parameters_():
1188 setattr(output,p,getattr(evtPset,p))
1189 if not self._options.inlineEventContent:
1192 output.outputCommands.__dict__[
"dumpPython"] = doNotInlineEventContent
1194 output.outputCommands = stream.content
1197 output.fileName = cms.untracked.string(self._options.dirout+stream.name+
'.root')
1199 output.dataset = cms.untracked.PSet( dataTier = stream.dataTier,
1200 filterName = cms.untracked.string(stream.name))
1202 if self._options.filtername:
1203 output.dataset.filterName= cms.untracked.string(self._options.filtername+
"_"+stream.name)
1206 output.eventAutoFlushCompressedSize=cms.untracked.int32(5*1024*1024)
1208 if workflow
in (
"producers,full"):
1209 if isinstance(stream.paths,tuple):
1210 for path
in stream.paths:
1211 self.schedule.append(path)
1213 self.schedule.append(stream.paths)
1217 if (
not self._options.relval)
and workflow
in (
"full",
"output"):
1218 self.additionalOutputs[name] = output
1219 setattr(self.process,name,output)
1221 if workflow ==
'output':
1223 filterList = output.SelectEvents.SelectEvents
1224 for i, filter
in enumerate(filterList):
1225 filterList[i] = filter+
":"+self._options.triggerResultsProcess
1235 if ( len(sequence.split(
'.'))==1 ):
1237 elif ( len(sequence.split(
'.'))==2 ):
1239 sequence=sequence.split(
'.')[1]
1241 print "sub sequence configuration must be of the form dir/subdir/cff.a+b+c or cff.a"
1242 print sequence,
"not recognized"
1249 for i,s
in enumerate(seq.split(
'*')):
1251 setattr(self.process,prefix,getattr(cms,what)( getattr(self.process, s) ))
1253 p=getattr(self.process,prefix)
1254 p+=getattr(self.process, s)
1255 self.schedule.append(getattr(self.process,prefix))
1260 if self.nextScheduleIsConditional:
1261 self.conditionalPaths.append(prefix)
1262 setattr(self.process,prefix,getattr(cms,what)( getattr(self.process, seq) ))
1263 self.schedule.append(getattr(self.process,prefix))
1265 for i,s
in enumerate(seq.split(
'+')):
1267 setattr(self.process,sn,getattr(cms,what)( getattr(self.process, s) ))
1268 self.schedule.append(getattr(self.process,sn))
1282 """ Enrich the process with alca streams """
1283 print 'DL enriching',workflow,sequence
1285 sequence = sequence.split(
'.')[-1]
1288 alcaList = sequence.split(
"+")
1290 from Configuration.AlCa.autoAlca
import autoAlca
1294 for name
in alcaConfig.__dict__:
1295 alcastream = getattr(alcaConfig,name)
1296 shortName = name.replace(
'ALCARECOStream',
'')
1297 if shortName
in alcaList
and isinstance(alcastream,cms.FilteredStream):
1298 output = self.
addExtraStream(name,alcastream, workflow = workflow)
1299 self.
executeAndRemember(
'process.ALCARECOEventContent.outputCommands.extend(process.OutALCARECO'+shortName+
'_noDrop.outputCommands)')
1300 self.AlCaPaths.append(shortName)
1301 if 'DQM' in alcaList:
1302 if not self._options.inlineEventContent
and hasattr(self.process,name):
1303 self.
executeAndRemember(
'process.' + name +
'.outputCommands.append("keep *_MEtoEDMConverter_*_*")')
1305 output.outputCommands.append(
"keep *_MEtoEDMConverter_*_*")
1308 if self._options.hltProcess
or 'HLT' in self.stepMap:
1309 if isinstance(alcastream.paths,tuple):
1310 for path
in alcastream.paths:
1315 for i
in range(alcaList.count(shortName)):
1316 alcaList.remove(shortName)
1319 elif name ==
'pathALCARECODQM' and 'DQM' in alcaList:
1320 path = getattr(alcaConfig,name)
1321 self.schedule.append(path)
1322 alcaList.remove(
'DQM')
1324 if isinstance(alcastream,cms.Path):
1326 self.blacklist_paths.append(alcastream)
1329 if len(alcaList) != 0:
1331 for name
in alcaConfig.__dict__:
1332 alcastream = getattr(alcaConfig,name)
1333 if isinstance(alcastream,cms.FilteredStream):
1334 available.append(name.replace(
'ALCARECOStream',
''))
1335 print "The following alcas could not be found "+str(alcaList)
1336 print "available ",available
1338 raise Exception(
"The following alcas could not be found "+str(alcaList))
1343 loadFragment = self._options.evt_type.replace(
'.py',
'',).
replace(
'.',
'_').
replace(
'python/',
'').
replace(
'/',
'.')
1344 print "Loading lhe fragment from",loadFragment
1345 __import__(loadFragment)
1346 self.process.load(loadFragment)
1348 self._options.inlineObjets+=
','+sequence
1350 getattr(self.process,sequence).nEvents = int(self._options.number)
1353 self.process.lhe_step = cms.Path( getattr( self.process,sequence) )
1354 self.excludedPaths.append(
"lhe_step")
1355 self.schedule.append( self.process.lhe_step )
1358 """ load the fragment of generator configuration """
1363 loadFragment = self._options.evt_type.replace(
'.py',
'',).
replace(
'.',
'_').
replace(
'python/',
'')
1365 if not '/' in loadFragment:
1366 loadFragment=
'Configuration.Generator.'+loadFragment
1368 loadFragment=loadFragment.replace(
'/',
'.')
1370 print "Loading generator fragment from",loadFragment
1371 __import__(loadFragment)
1375 if not (self._options.filein
or self._options.dasquery):
1376 raise Exception(
"Neither gen fragment of input files provided: this is an inconsistent GEN step configuration")
1379 generatorModule=sys.modules[loadFragment]
1380 genModules=generatorModule.__dict__
1383 if self.LHEDefaultSeq
in genModules:
1384 del genModules[self.LHEDefaultSeq]
1386 if self._options.hideGen:
1389 self.process.load(loadFragment)
1391 import FWCore.ParameterSet.Modules
as cmstypes
1392 for name
in genModules:
1393 theObject = getattr(generatorModule,name)
1394 if isinstance(theObject, cmstypes._Module):
1395 self._options.inlineObjets=name+
','+self._options.inlineObjets
1396 elif isinstance(theObject, cms.Sequence)
or isinstance(theObject, cmstypes.ESProducer):
1397 self._options.inlineObjets+=
','+name
1399 if sequence == self.GENDefaultSeq
or sequence ==
'pgen_genonly':
1400 if 'ProductionFilterSequence' in genModules
and (
'generator' in genModules):
1401 self.productionFilterSequence =
'ProductionFilterSequence'
1402 elif 'generator' in genModules:
1403 self.productionFilterSequence =
'generator'
1405 """ Enrich the schedule with the rest of the generation step """
1407 genSeqName=sequence.split(
'.')[-1]
1411 from Configuration.StandardSequences.VtxSmeared
import VtxSmeared
1412 cffToBeLoaded=VtxSmeared[self._options.beamspot]
1415 raise Exception(
"VertexSmearing type or beamspot "+self._options.beamspot+
" unknown.")
1417 if self._options.scenario ==
'HeavyIons':
1418 if self._options.pileup==
'HiMixGEN':
1419 self.
loadAndRemember(
"Configuration/StandardSequences/GeneratorMix_cff")
1421 self.
loadAndRemember(
"Configuration/StandardSequences/GeneratorHI_cff")
1423 self.process.generation_step = cms.Path( getattr(self.process,genSeqName) )
1424 self.schedule.append(self.process.generation_step)
1427 self.
executeAndRemember(
'process.genstepfilter.triggerConditions=cms.vstring("generation_step")')
1429 if 'reGEN' in self.stepMap:
1433 """ Enrich the schedule with the summary of the filter step """
1440 """ Enrich the schedule with the simulation step"""
1441 self.loadDefaultOrSpecifiedCFF(sequence,self.SIMDefaultCFF)
1442 if not self._options.fast:
1443 if self._options.gflash==
True:
1444 self.loadAndRemember(
"Configuration/StandardSequences/GFlashSIM_cff")
1446 if self._options.magField==
'0T':
1447 self.executeAndRemember(
"process.g4SimHits.UseMagneticField = cms.bool(False)")
1449 if self._options.magField==
'0T':
1450 self.executeAndRemember(
"process.famosSimHits.UseMagneticField = cms.bool(False)")
1452 self.scheduleSequence(sequence.split(
'.')[-1],
'simulation_step')
1456 """ Enrich the schedule with the digitisation step"""
1459 if self._options.gflash==
True:
1460 self.
loadAndRemember(
"Configuration/StandardSequences/GFlashDIGI_cff")
1462 if sequence ==
'pdigi_valid':
1463 self.
executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersValid)")
1465 if sequence !=
'pdigi_nogen' and sequence !=
'pdigi_valid_nogen' and not self.process.source.type_()==
'EmptySource':
1466 if self._options.inputEventContent==
'':
1467 self._options.inputEventContent=
'REGEN'
1469 self._options.inputEventContent=self._options.inputEventContent+
',REGEN'
1476 """ Enrich the schedule with the digitisation step"""
1481 if sequence ==
'pdigi_valid':
1482 self.
executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersNoNoiseValid)")
1484 self.
executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersNoNoise)")
1490 """ Enrich the schedule with the digitisation step"""
1491 self.loadDefaultOrSpecifiedCFF(sequence,self.DIGIDefaultCFF)
1493 self.loadAndRemember(
"SimGeneral/MixingModule/digi_MixPreMix_cfi")
1496 if sequence ==
'pdigi_valid':
1497 self.executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersMixPreMixValid)")
1499 self.executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersMixPreMix)")
1501 self.scheduleSequence(sequence.split(
'.')[-1],
'digitisation_step')
1505 """ Enrich the schedule with the crossing frame writer step"""
1511 """ Enrich the schedule with the digitisation step"""
1515 if self._options.pileup_input:
1517 if self._options.pileup_input.startswith(
'dbs:')
or self._options.pileup_input.startswith(
'das:'):
1518 theFiles=
filesFromDASQuery(
'file dataset = %s'%(self._options.pileup_input[4:],))[0]
1519 elif self._options.pileup_input.startswith(
"filelist:"):
1520 theFiles= (
filesFromList(self._options.pileup_input[9:]))[0]
1522 theFiles=self._options.pileup_input.split(
',')
1524 self.
executeAndRemember(
"process.mixData.input.fileNames = cms.untracked.vstring(%s)"%( theFiles ) )
1531 if "DIGIPREMIX" in self.stepMap.keys():
1533 self.
executeAndRemember(
"process.SiStripDigiToRaw.FedReadoutMode = cms.string('PREMIX_RAW')")
1543 """ Enrich the schedule with the L1 simulation step"""
1550 """ 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"""
1551 supported = [
'GT',
'GT1',
'GT2',
'GCTGT']
1552 if sequence
in supported:
1553 self.loadAndRemember(
'Configuration/StandardSequences/SimL1EmulatorRepack_%s_cff'%sequence)
1554 if self._options.scenario ==
'HeavyIons':
1555 self.renameInputTagsInSequence(
"SimL1Emulator",
"rawDataCollector",
"rawDataRepacker")
1556 self.scheduleSequence(
'SimL1Emulator',
'L1RePack_step')
1558 print "L1REPACK with '",sequence,
"' is not supported! Supported choices are: ",supported
1563 """ Enrich the schedule with the HLT simulation step"""
1565 print "no specification of the hlt menu has been given, should never happen"
1566 raise Exception(
'no HLT sequence provided')
1570 from Configuration.HLT.autoHLT
import autoHLT
1573 sequence = autoHLT[key]
1575 raise ValueError(
'no HLT mapping key "%s" found in autoHLT' % key)
1581 if self._options.scenario ==
'HeavyIons':
1582 optionsForHLT[
'type'] =
'HIon'
1584 optionsForHLT[
'type'] =
'GRun'
1585 optionsForHLTConfig =
', '.
join(
'%s=%s' % (key, repr(val))
for (key, val)
in optionsForHLT.iteritems())
1586 if sequence ==
'run,fromSource':
1587 if hasattr(self.process.source,
'firstRun'):
1588 self.
executeAndRemember(
'process.loadHltConfiguration("run:%%d"%%(process.source.firstRun.value()),%s)'%(optionsForHLTConfig))
1589 elif hasattr(self.process.source,
'setRunNumber'):
1590 self.
executeAndRemember(
'process.loadHltConfiguration("run:%%d"%%(process.source.setRunNumber.value()),%s)'%(optionsForHLTConfig))
1592 raise Exception(
'Cannot replace menu to load %s'%(sequence))
1594 self.
executeAndRemember(
'process.loadHltConfiguration("%s",%s)'%(sequence.replace(
',',
':'),optionsForHLTConfig))
1598 if self._options.isMC:
1599 if self._options.fast:
1600 self._options.customisation_file.append(
"HLTrigger/Configuration/customizeHLTforMC.customizeHLTforFastSim")
1602 self._options.customisation_file.append(
"HLTrigger/Configuration/customizeHLTforMC.customizeHLTforFullSim")
1604 if self._options.name !=
'HLT':
1605 self.additionalCommands.append(
'from HLTrigger.Configuration.CustomConfigs import ProcessName')
1606 self.additionalCommands.append(
'process = ProcessName(process)')
1607 self.additionalCommands.append(
'')
1608 from HLTrigger.Configuration.CustomConfigs
import ProcessName
1611 self.schedule.append(self.process.HLTSchedule)
1612 [self.blacklist_paths.append(path)
for path
in self.process.HLTSchedule
if isinstance(path,(cms.Path,cms.EndPath))]
1615 if self._options.fast:
1616 if not hasattr(self.process,
'HLTEndSequence'):
1617 self.
executeAndRemember(
"process.HLTEndSequence = cms.Sequence( process.dummyModule )")
1622 seqReco=sequence.split(
',')[1]
1623 seqDigi=sequence.split(
',')[0]
1625 print "RAW2RECO requires two specifications",sequence,
"insufficient"
1639 self.
loadAndRemember(
"PhysicsTools/PatAlgos/slimming/metFilterPaths_cff")
1641 for filt
in allMetFilterPaths:
1642 self.schedule.append(getattr(self.process,
'Flag_'+filt))
1645 ''' Enrich the schedule with L1 HW validation '''
1648 print '\n\n\n DEPRECATED this has no action \n\n\n'
1652 ''' Enrich the schedule with L1 reconstruction '''
1658 ''' Enrich the schedule with L1 reconstruction '''
1664 ''' Enrich the schedule with a user defined filter sequence '''
1666 filterConfig=self.
load(sequence.split(
'.')[0])
1667 filterSeq=sequence.split(
'.')[-1]
1675 label=visitee.label()
1683 getattr(self.process,filterSeq).
visit( expander )
1684 self._options.inlineObjets+=
','+expander.inliner
1685 self._options.inlineObjets+=
','+filterSeq
1688 self.scheduleSequence(filterSeq,
'filtering_step')
1689 self.nextScheduleIsConditional=
True
1691 self.productionFilterSequence = filterSeq
1696 ''' Enrich the schedule with reconstruction '''
1702 ''' Enrich the schedule with the part of reconstruction that is done before mixing in FastSim'''
1703 if not self._options.fast:
1704 print "ERROR: this step is only implemented for FastSim"
1707 self.
scheduleSequence(sequence.split(
'.')[-1],
'reconstruction_befmix_step')
1711 ''' Enrich the schedule with PAT '''
1712 self.prepare_PATFILTER(self)
1713 self.loadDefaultOrSpecifiedCFF(sequence,self.PATDefaultCFF,1)
1714 if not self._options.runUnscheduled:
1715 raise Exception(
"MiniAOD production can only run in unscheduled mode, please run cmsDriver with --runUnscheduled")
1716 if self._options.isData:
1717 self._options.customisation_file_unsch.append(
"PhysicsTools/PatAlgos/slimming/miniAOD_tools.miniAOD_customizeAllData")
1719 self._options.customisation_file_unsch.append(
"PhysicsTools/PatAlgos/slimming/miniAOD_tools.miniAOD_customizeAllMC")
1720 if self._options.fast:
1721 self._options.customisation_file_unsch.append(
"PhysicsTools/PatAlgos/slimming/metFilterPaths_cff.miniAOD_customizeMETFiltersFastSim")
1725 ''' Enrich the schedule with event interpretation '''
1726 from Configuration.StandardSequences.EventInterpretation
import EventInterpretation
1727 if sequence
in EventInterpretation:
1728 self.EIDefaultCFF = EventInterpretation[sequence]
1729 sequence =
'EIsequence'
1731 raise Exception(
'Cannot set %s event interpretation'%( sequence) )
1737 ''' Enrich the schedule with skimming fragments'''
1739 sequence = sequence.split(
'.')[-1]
1741 skimlist=sequence.split(
'+')
1743 from Configuration.Skimming.autoSkim
import autoSkim
1747 for skim
in skimConfig.__dict__:
1748 skimstream = getattr(skimConfig,skim)
1749 if isinstance(skimstream,cms.Path):
1751 self.blacklist_paths.append(skimstream)
1752 if (
not isinstance(skimstream,cms.FilteredStream)):
1754 shortname = skim.replace(
'SKIMStream',
'')
1755 if (sequence==
"all"):
1757 elif (shortname
in skimlist):
1760 if self._options.datatier==
'DQM':
1761 self.process.load(self.EVTCONTDefaultCFF)
1762 skimstreamDQM = cms.FilteredStream(
1763 responsible = skimstream.responsible,
1764 name = skimstream.name+
'DQM',
1765 paths = skimstream.paths,
1766 selectEvents = skimstream.selectEvents,
1767 content = self._options.datatier+
'EventContent',
1768 dataTier = cms.untracked.string(self._options.datatier)
1771 for i
in range(skimlist.count(shortname)):
1772 skimlist.remove(shortname)
1776 if (skimlist.__len__()!=0
and sequence!=
"all"):
1777 print 'WARNING, possible typo with SKIM:'+
'+'.
join(skimlist)
1778 raise Exception(
'WARNING, possible typo with SKIM:'+
'+'.
join(skimlist))
1781 ''' Enrich the schedule with a user defined sequence '''
1787 """ Enrich the schedule with the postreco step """
1794 print sequence,
"in preparing validation"
1796 from Validation.Configuration.autoValidation
import autoValidation
1798 sequence=sequence.split(
'.')[-1]
1799 if sequence.find(
',')!=-1:
1800 prevalSeqName=sequence.split(
',')[0].
split(
'+')
1801 valSeqName=sequence.split(
',')[1].
split(
'+')
1806 prevalSeqName=sequence.split(
'+')
1807 valSeqName=sequence.split(
'+')
1813 postfix=
'_'+sequence
1814 prevalSeqName=[
'prevalidation'+postfix]
1815 valSeqName=[
'validation'+postfix]
1816 if not hasattr(self.process,valSeqName[0]):
1818 valSeqName=[sequence]
1827 if not 'DIGI' in self.stepMap
and not self._options.fast
and not any(
map(
lambda s : s.startswith(
'genvalid'), valSeqName)):
1828 if self._options.restoreRNDSeeds==
False and not self._options.restoreRNDSeeds==
True:
1829 self._options.restoreRNDSeeds=
True
1832 if (
'HLT' in self.stepMap
and not self._options.fast)
or self._options.hltProcess:
1833 for s
in valSeqName+prevalSeqName:
1836 for (i,s)
in enumerate(prevalSeqName):
1838 setattr(self.process,
'prevalidation_step%s'%NFI(i), cms.Path( getattr(self.process, s)) )
1839 self.schedule.append(getattr(self.process,
'prevalidation_step%s'%NFI(i)))
1841 for (i,s)
in enumerate(valSeqName):
1842 setattr(self.process,
'validation_step%s'%NFI(i), cms.EndPath( getattr(self.process, s)))
1843 self.schedule.append(getattr(self.process,
'validation_step%s'%NFI(i)))
1845 if not 'DIGI' in self.stepMap
and not self._options.fast:
1849 self._options.customisation_file.append(
"SimGeneral/MixingModule/fullMixCustomize_cff.setCrossingFrameOn")
1851 if hasattr(self.process,
"genstepfilter")
and len(self.process.genstepfilter.triggerConditions):
1853 for (i,s)
in enumerate(valSeqName):
1854 getattr(self.process,
'validation_step%s'%NFI(i))._seq = self.process.genstepfilter * getattr(self.process,
'validation_step%s'%NFI(i))._seq
1860 """Visitor that travels within a cms.Sequence, looks for a parameter and replace its value
1861 It will climb down within PSets, VPSets and VInputTags to find its target"""
1862 def __init__(self, paramSearch, paramReplace, verbose=False, whitelist=()):
1869 if isinstance(pset, cms._Parameterizable):
1870 for name
in pset.parameters_().
keys():
1876 value = getattr(pset,name)
1877 type = value.pythonTypeName()
1878 if type
in (
'cms.PSet',
'cms.untracked.PSet'):
1879 self.
doIt(value,base+
"."+name)
1880 elif type
in (
'cms.VPSet',
'cms.untracked.VPSet'):
1881 for (i,ps)
in enumerate(value): self.
doIt(ps,
"%s.%s[%d]"%(base,name,i) )
1882 elif type
in (
'cms.string',
'cms.untracked.string'):
1884 if self.
_verbose:
print "set string process name %s.%s %s ==> %s"% (base, name, value, self.
_paramReplace)
1886 elif type
in (
'cms.VInputTag',
'cms.untracked.VInputTag'):
1887 for (i,n)
in enumerate(value):
1888 if not isinstance(n, cms.InputTag):
1892 if self.
_verbose:
print "set process name %s.%s[%d] %s ==> %s " % (base, name, i, n, self.
_paramReplace)
1895 elif type
in (
'cms.vstring',
'cms.untracked.vstring'):
1896 for (i,n)
in enumerate(value):
1899 elif type
in (
'cms.InputTag',
'cms.untracked.InputTag'):
1901 if self.
_verbose:
print "set process name %s.%s %s ==> %s " % (base, name, value, self.
_paramReplace)
1902 setattr(getattr(pset, name),
"processName",self.
_paramReplace)
1907 label = visitee.label()
1908 except AttributeError:
1909 label =
'<Module not in a Process>'
1911 label =
'other execption'
1912 self.
doIt(visitee, label)
1919 print "Replacing all InputTag %s => %s"%(oldT,newT)
1922 loadMe=
'from PhysicsTools.PatAlgos.tools.helpers import massSearchReplaceAnyInputTag'
1923 if not loadMe
in self.additionalCommands:
1924 self.additionalCommands.append(loadMe)
1925 self.additionalCommands.append(
'massSearchReplaceAnyInputTag(process.%s,"%s","%s",False,True)'%(sequence,oldT,newT))
1929 if self._options.hltProcess:
1930 proc=self._options.hltProcess
1932 proc=self.process.name_()
1933 if proc==HLTprocess:
return
1935 print "replacing %s process name - sequence %s will use '%s'" % (HLTprocess,sequence, proc)
1937 if 'from Configuration.Applications.ConfigBuilder import ConfigBuilder' not in self.additionalCommands:
1938 self.additionalCommands.append(
'from Configuration.Applications.ConfigBuilder import ConfigBuilder')
1939 self.additionalCommands.append(
'process.%s.visit(ConfigBuilder.MassSearchReplaceProcessNameVisitor("%s", "%s", whitelist = ("subSystemFolder",)))'% (sequence,HLTprocess, proc))
1945 while '@' in repr(seqList)
and level<maxLevel:
1947 for specifiedCommand
in seqList:
1948 if specifiedCommand.startswith(
'@'):
1949 location=specifiedCommand[1:]
1950 if not location
in mapping:
1951 raise Exception(
"Impossible to map "+location+
" from "+repr(mapping))
1952 mappedTo=mapping[location]
1954 mappedTo=mappedTo[index]
1955 seqList.remove(specifiedCommand)
1956 seqList.extend(mappedTo.split(
'+'))
1959 raise Exception(
"Could not fully expand "+repr(seqList)+
" from "+repr(mapping))
1965 sequenceList=sequence.split(
'.')[-1].
split(
'+')
1966 from DQMOffline.Configuration.autoDQM
import autoDQM
1969 if len(set(sequenceList))!=len(sequenceList):
1970 sequenceList=
list(set(sequenceList))
1971 print "Duplicate entries for DQM:, using",sequenceList
1972 pathName=
'dqmoffline_step'
1974 for (i,sequence)
in enumerate(sequenceList):
1976 pathName=
'dqmoffline_%d_step'%(i)
1978 if 'HLT' in self.stepMap.keys()
or self._options.hltProcess:
1982 if 'HLT' in self.stepMap.keys():
1984 setattr(self.process,pathName, cms.EndPath( getattr(self.process, sequence ) ) )
1987 setattr(self.process,pathName, cms.Path( getattr(self.process, sequence) ) )
1988 self.schedule.append(getattr(self.process,pathName))
1992 """ Enrich the process with harvesting step """
1993 self.
DQMSaverCFF=
'Configuration/StandardSequences/DQMSaver'+self._options.harvesting+
'_cff'
1997 sequence = sequence.split(
'.')[-1]
2000 harvestingList = sequence.split(
"+")
2001 from DQMOffline.Configuration.autoDQM
import autoDQM
2002 from Validation.Configuration.autoValidation
import autoValidation
2004 combined_mapping = copy.deepcopy( autoDQM )
2005 combined_mapping.update( autoValidation )
2006 self.
expandMapping(harvestingList,combined_mapping,index=-1)
2008 if len(set(harvestingList))!=len(harvestingList):
2009 harvestingList=
list(set(harvestingList))
2010 print "Duplicate entries for HARVESTING, using",harvestingList
2012 for name
in harvestingList:
2013 if not name
in harvestingConfig.__dict__:
2014 print name,
"is not a possible harvesting type. Available are",harvestingConfig.__dict__.keys()
2016 harvestingstream = getattr(harvestingConfig,name)
2017 if isinstance(harvestingstream,cms.Path):
2018 self.schedule.append(harvestingstream)
2019 self.blacklist_paths.append(harvestingstream)
2020 if isinstance(harvestingstream,cms.Sequence):
2021 setattr(self.process,name+
"_step",cms.Path(harvestingstream))
2022 self.schedule.append(getattr(self.process,name+
"_step"))
2028 """ Enrich the process with AlCaHarvesting step """
2030 sequence=sequence.split(
".")[-1]
2033 harvestingList = sequence.split(
"+")
2037 from Configuration.AlCa.autoPCL
import autoPCL
2040 for name
in harvestingConfig.__dict__:
2041 harvestingstream = getattr(harvestingConfig,name)
2042 if name
in harvestingList
and isinstance(harvestingstream,cms.Path):
2043 self.schedule.append(harvestingstream)
2044 self.
executeAndRemember(
"process.PoolDBOutputService.toPut.append(process.ALCAHARVEST" + name +
"_dbOutput)")
2045 self.
executeAndRemember(
"process.pclMetadataWriter.recordsToMap.append(process.ALCAHARVEST" + name +
"_metadata)")
2046 harvestingList.remove(name)
2048 lastStep = getattr(harvestingConfig,
"ALCAHARVESTDQMSaveAndMetadataWriter")
2049 self.schedule.append(lastStep)
2051 if len(harvestingList) != 0
and 'dummyHarvesting' not in harvestingList :
2052 print "The following harvesting could not be found : ", harvestingList
2053 raise Exception(
"The following harvesting could not be found : "+str(harvestingList))
2063 self.process.reconstruction = cms.Path(self.process.reconstructionWithFamos)
2064 self.schedule.append(self.process.reconstruction)
2068 """ Add useful info for the production. """
2069 self.process.configurationMetadata=cms.untracked.PSet\
2070 (version=cms.untracked.string(
"$Revision: 1.19 $"),
2071 name=cms.untracked.string(
"Applications"),
2072 annotation=cms.untracked.string(evt_type+
" nevts:"+str(evtnumber))
2075 self.addedObjects.append((
"Production Info",
"configurationMetadata"))
2079 """ Prepare the configuration string and add missing pieces."""
2091 outputModuleCfgCode=
""
2092 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:
2097 self.pythonCfgCode =
"# Auto generated configuration file\n"
2098 self.pythonCfgCode +=
"# using: \n# "+__version__[1:-1]+
"\n# "+__source__[1:-1]+
'\n'
2099 self.pythonCfgCode +=
"# with command line options: "+self._options.arguments+
'\n'
2100 self.pythonCfgCode +=
"import FWCore.ParameterSet.Config as cms\n\n"
2101 if hasattr(self.
_options,
"era")
and self._options.era :
2102 self.pythonCfgCode +=
"from Configuration.StandardSequences.Eras import eras\n\n"
2103 self.pythonCfgCode +=
"process = cms.Process('"+self.process.name_()+
"'"
2105 for requestedEra
in self._options.era.split(
",") :
2106 self.pythonCfgCode +=
",eras."+requestedEra
2107 self.pythonCfgCode +=
")\n\n"
2109 self.pythonCfgCode +=
"process = cms.Process('"+self.process.name_()+
"')\n\n"
2111 self.pythonCfgCode +=
"# import of standard configurations\n"
2112 for module
in self.imports:
2113 self.pythonCfgCode += (
"process.load('"+module+
"')\n")
2116 if not hasattr(self.process,
"configurationMetadata"):
2120 self.addedObjects.append((
"Production Info",
"configurationMetadata"))
2122 self.pythonCfgCode +=
"\n"
2123 for comment,object
in self.addedObjects:
2125 self.pythonCfgCode +=
"\n# "+comment+
"\n"
2126 self.pythonCfgCode +=
dumpPython(self.process,object)
2129 self.pythonCfgCode +=
"\n# Output definition\n"
2130 self.pythonCfgCode += outputModuleCfgCode
2133 self.pythonCfgCode +=
"\n# Additional output definition\n"
2135 nl=self.additionalOutputs.keys()
2138 output = self.additionalOutputs[name]
2139 self.pythonCfgCode +=
"process.%s = %s" %(name, output.dumpPython())
2140 tmpOut = cms.EndPath(output)
2141 setattr(self.process,name+
'OutPath',tmpOut)
2142 self.schedule.append(tmpOut)
2145 self.pythonCfgCode +=
"\n# Other statements\n"
2146 for command
in self.additionalCommands:
2147 self.pythonCfgCode += command +
"\n"
2150 for object
in self._options.inlineObjets.split(
','):
2153 if not hasattr(self.process,object):
2154 print 'cannot inline -'+object+
'- : not known'
2156 self.pythonCfgCode +=
'\n'
2157 self.pythonCfgCode +=
dumpPython(self.process,object)
2160 self.pythonCfgCode +=
"\n# Path and EndPath definitions\n"
2161 for path
in self.process.paths:
2162 if getattr(self.process,path)
not in self.blacklist_paths:
2163 self.pythonCfgCode +=
dumpPython(self.process,path)
2165 for endpath
in self.process.endpaths:
2166 if getattr(self.process,endpath)
not in self.blacklist_paths:
2167 self.pythonCfgCode +=
dumpPython(self.process,endpath)
2170 self.pythonCfgCode +=
"\n# Schedule definition\n"
2171 result =
"process.schedule = cms.Schedule("
2174 self.process.schedule = cms.Schedule()
2175 for item
in self.schedule:
2176 if not isinstance(item, cms.Schedule):
2177 self.process.schedule.append(item)
2179 self.process.schedule.extend(item)
2181 if hasattr(self.process,
"HLTSchedule"):
2182 beforeHLT = self.schedule[:self.schedule.index(self.process.HLTSchedule)]
2183 afterHLT = self.schedule[self.schedule.index(self.process.HLTSchedule)+1:]
2184 pathNames = [
'process.'+p.label_()
for p
in beforeHLT]
2185 result +=
','.
join(pathNames)+
')\n'
2186 result +=
'process.schedule.extend(process.HLTSchedule)\n'
2187 pathNames = [
'process.'+p.label_()
for p
in afterHLT]
2188 result +=
'process.schedule.extend(['+
','.
join(pathNames)+
'])\n'
2190 pathNames = [
'process.'+p.label_()
for p
in self.schedule]
2191 result =
'process.schedule = cms.Schedule('+
','.
join(pathNames)+
')\n'
2193 self.pythonCfgCode += result
2195 if self._options.nThreads
is not "1":
2196 self.pythonCfgCode +=
"\n"
2197 self.pythonCfgCode +=
"#Setup FWK for multithreaded\n"
2198 self.pythonCfgCode +=
"process.options.numberOfThreads=cms.untracked.uint32("+self._options.nThreads+
")\n"
2199 self.pythonCfgCode +=
"process.options.numberOfStreams=cms.untracked.uint32(0)\n"
2201 if self._options.isRepacked:
2202 self.pythonCfgCode +=
"\n"
2203 self.pythonCfgCode +=
"from Configuration.Applications.ConfigBuilder import MassReplaceInputTag\n"
2204 self.pythonCfgCode +=
"MassReplaceInputTag(process)\n"
2208 if self.productionFilterSequence:
2209 self.pythonCfgCode +=
'# filter all path with the production filter sequence\n'
2210 self.pythonCfgCode +=
'for path in process.paths:\n'
2211 if len(self.conditionalPaths):
2212 self.pythonCfgCode +=
'\tif not path in %s: continue\n'%str(self.conditionalPaths)
2213 if len(self.excludedPaths):
2214 self.pythonCfgCode +=
'\tif path in %s: continue\n'%str(self.excludedPaths)
2215 self.pythonCfgCode +=
'\tgetattr(process,path)._seq = process.%s * getattr(process,path)._seq \n'%(self.productionFilterSequence,)
2216 pfs = getattr(self.process,self.productionFilterSequence)
2217 for path
in self.process.paths:
2218 if not path
in self.conditionalPaths:
continue
2219 if path
in self.excludedPaths:
continue
2220 getattr(self.process,path)._seq = pfs * getattr(self.process,path)._seq
2226 if self._options.runUnscheduled:
2229 self.pythonCfgCode+=
"#do not add changes to your config after this point (unless you know what you are doing)\n"
2230 self.pythonCfgCode+=
"from FWCore.ParameterSet.Utilities import convertToUnscheduled\n"
2231 self.pythonCfgCode+=
"process=convertToUnscheduled(process)\n"
2233 from FWCore.ParameterSet.Utilities
import convertToUnscheduled
2237 for module
in self.importsUnsch:
2238 self.process.load(module)
2239 self.pythonCfgCode += (
"process.load('"+module+
"')\n")
2242 self.pythonCfgCode+=
"from FWCore.ParameterSet.Utilities import cleanUnscheduled\n"
2243 self.pythonCfgCode+=
"process=cleanUnscheduled(process)\n"
2245 from FWCore.ParameterSet.Utilities
import cleanUnscheduled
2254 if self._options.io:
2256 if not self._options.io.endswith(
'.io'): self._option.io+=
'.io'
2257 io=open(self._options.io,
'w')
2259 if hasattr(self.process.source,
"fileNames"):
2260 if len(self.process.source.fileNames.value()):
2261 ioJson[
'primary']=self.process.source.fileNames.value()
2262 if hasattr(self.process.source,
"secondaryFileNames"):
2263 if len(self.process.source.secondaryFileNames.value()):
2264 ioJson[
'secondary']=self.process.source.secondaryFileNames.value()
2265 if self._options.pileup_input
and (self._options.pileup_input.startswith(
'dbs:')
or self._options.pileup_input.startswith(
'das:')):
2266 ioJson[
'pileup']=self._options.pileup_input[4:]
2267 for (o,om)
in self.process.outputModules_().items():
2268 ioJson[o]=om.fileName.value()
2269 ioJson[
'GT']=self.process.GlobalTag.globaltag.value()
2270 if self.productionFilterSequence:
2271 ioJson[
'filter']=self.productionFilterSequence
2273 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