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 =
'38T'
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())
430 if self._options.inputCommands:
431 if not hasattr(self.process.source,
'inputCommands'): self.process.source.inputCommands=cms.untracked.vstring()
432 for command
in self._options.inputCommands.split(
','):
434 command = command.strip()
435 if command==
'':
continue
436 self.process.source.inputCommands.append(command)
437 if not self._options.dropDescendant:
438 self.process.source.dropDescendantsOfDroppedBranches = cms.untracked.bool(
False)
440 if self._options.lumiToProcess:
441 import FWCore.PythonUtilities.LumiList
as LumiList
442 self.process.source.lumisToProcess = cms.untracked.VLuminosityBlockRange(
LumiList.LumiList(self._options.lumiToProcess).getCMSSWString().
split(
',') )
444 if 'GEN' in self.stepMap.keys()
or 'LHE' in self.stepMap
or (
not self._options.filein
and hasattr(self.
_options,
"evt_type")):
445 if self.process.source
is None:
446 self.process.source=cms.Source(
"EmptySource")
449 self.runsAndWeights=
None
450 if self._options.runsAndWeightsForMC
or self._options.runsScenarioForMC :
451 if not self._options.isMC :
452 raise Exception(
"options --runsAndWeightsForMC and --runsScenarioForMC are only valid for MC")
453 if self._options.runsAndWeightsForMC:
454 self.runsAndWeights = eval(self._options.runsAndWeightsForMC)
456 from Configuration.StandardSequences.RunsAndWeights
import RunsAndWeights
457 if type(RunsAndWeights[self._options.runsScenarioForMC])==str:
458 __import__(RunsAndWeights[self._options.runsScenarioForMC])
459 self.runsAndWeights = sys.modules[RunsAndWeights[self._options.runsScenarioForMC]].runProbabilityDistribution
461 self.runsAndWeights = RunsAndWeights[self._options.runsScenarioForMC]
463 if self.runsAndWeights:
464 import SimGeneral.Configuration.ThrowAndSetRandomRun
as ThrowAndSetRandomRun
466 self.additionalCommands.append(
'import SimGeneral.Configuration.ThrowAndSetRandomRun as ThrowAndSetRandomRun')
467 self.additionalCommands.append(
'ThrowAndSetRandomRun.throwAndSetRandomRun(process.source,%s)'%(self.runsAndWeights))
472 """ Add output module to the process """
474 if self._options.outputDefinition:
475 if self._options.datatier:
476 print "--datatier & --eventcontent options ignored"
479 outList = eval(self._options.outputDefinition)
480 for (id,outDefDict)
in enumerate(outList):
481 outDefDictStr=outDefDict.__str__()
482 if not isinstance(outDefDict,dict):
483 raise Exception(
"--output needs to be passed a list of dict"+self._options.outputDefinition+
" is invalid")
485 theTier=
anyOf([
't',
'tier',
'dataTier'],outDefDict)
488 theStreamType=
anyOf([
'e',
'ec',
'eventContent',
'streamType'],outDefDict,theTier)
489 theFilterName=
anyOf([
'f',
'ftN',
'filterName'],outDefDict,
'')
490 theSelectEvent=
anyOf([
's',
'sE',
'selectEvents'],outDefDict,
'')
491 theModuleLabel=
anyOf([
'l',
'mL',
'moduleLabel'],outDefDict,
'')
492 theExtraOutputCommands=
anyOf([
'o',
'oC',
'outputCommands'],outDefDict,
'')
494 if not theModuleLabel:
495 tryNames=[theStreamType.replace(theTier.replace(
'-',
''),
'')+theTier.replace(
'-',
'')+
'output',
496 theStreamType.replace(theTier.replace(
'-',
''),
'')+theTier.replace(
'-',
'')+theFilterName+
'output',
497 theStreamType.replace(theTier.replace(
'-',
''),
'')+theTier.replace(
'-',
'')+theFilterName+theSelectEvent.split(
',')[0].
replace(
':',
'for').
replace(
' ',
'')+
'output'
499 for name
in tryNames:
500 if not hasattr(self.process,name):
503 if not theModuleLabel:
504 raise Exception(
"cannot find a module label for specification: "+outDefDictStr)
506 defaultFileName=self._options.outfile_name
508 defaultFileName=self._options.outfile_name.replace(
'.root',
'_in'+theTier+
'.root')
510 theFileName=self._options.dirout+
anyOf([
'fn',
'fileName'],outDefDict,defaultFileName)
511 if not theFileName.endswith(
'.root'):
514 if len(outDefDict.keys()):
515 raise Exception(
"unused keys from --output options: "+
','.
join(outDefDict.keys()))
516 if theStreamType==
'DQMIO': theStreamType=
'DQM'
517 if theStreamType==
'ALL':
518 theEventContent = cms.PSet(outputCommands = cms.untracked.vstring(
'keep *'))
520 theEventContent = getattr(self.process, theStreamType+
"EventContent")
524 if theStreamType==
'ALCARECO' and not theFilterName:
525 theFilterName=
'StreamALCACombined'
528 CppType=
'PoolOutputModule'
529 if self._options.timeoutOutput:
530 CppType=
'TimeoutPoolOutputModule'
531 if theStreamType==
'DQM' and theTier==
'DQMIO': CppType=
'DQMRootOutputModule'
532 output = cms.OutputModule(CppType,
533 theEventContent.clone(),
534 fileName = cms.untracked.string(theFileName),
535 dataset = cms.untracked.PSet(
536 dataTier = cms.untracked.string(theTier),
537 filterName = cms.untracked.string(theFilterName))
539 if not theSelectEvent
and hasattr(self.process,
'generation_step')
and theStreamType!=
'LHE':
540 output.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
'generation_step'))
541 if not theSelectEvent
and hasattr(self.process,
'filtering_step'):
542 output.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
'filtering_step'))
544 output.SelectEvents =cms.untracked.PSet(SelectEvents = cms.vstring(theSelectEvent))
547 if not hasattr(output,
'SelectEvents'):
548 output.SelectEvents=cms.untracked.PSet(SelectEvents=cms.vstring())
549 for alca
in self.AlCaPaths:
550 output.SelectEvents.SelectEvents.extend(getattr(self.process,
'OutALCARECO'+alca).SelectEvents.SelectEvents)
553 if hasattr(self.process,theModuleLabel):
554 raise Exception(
"the current process already has a module "+theModuleLabel+
" defined")
556 setattr(self.process,theModuleLabel,output)
557 outputModule=getattr(self.process,theModuleLabel)
558 setattr(self.process,theModuleLabel+
'_step',cms.EndPath(outputModule))
559 path=getattr(self.process,theModuleLabel+
'_step')
560 self.schedule.append(path)
562 if not self._options.inlineEventContent
and hasattr(self.process,theStreamType+
"EventContent"):
565 outputModule.outputCommands.__dict__[
"dumpPython"] = doNotInlineEventContent
566 if theExtraOutputCommands:
567 if not isinstance(theExtraOutputCommands,list):
568 raise Exception(
"extra ouput command in --option must be a list of strings")
569 if hasattr(self.process,theStreamType+
"EventContent"):
570 self.
executeAndRemember(
'process.%s.outputCommands.extend(%s)'%(theModuleLabel,theExtraOutputCommands))
572 outputModule.outputCommands.extend(theExtraOutputCommands)
574 result+=
"\nprocess."+theModuleLabel+
" = "+outputModule.dumpPython()
579 streamTypes=self._options.eventcontent.split(
',')
580 tiers=self._options.datatier.split(
',')
581 if not self._options.outputDefinition
and len(streamTypes)!=len(tiers):
582 raise Exception(
"number of event content arguments does not match number of datatier arguments")
585 if self._options.step.split(
',')[0].
split(
':')[0] ==
'ALCA':
588 for i,(streamType,tier)
in enumerate(
zip(streamTypes,tiers)):
589 if streamType==
'':
continue
590 if streamType==
'DQMIO': streamType=
'DQM'
591 theEventContent = getattr(self.process, streamType+
"EventContent")
593 theFileName=self._options.outfile_name
594 theFilterName=self._options.filtername
596 theFileName=self._options.outfile_name.replace(
'.root',
'_in'+streamType+
'.root')
597 theFilterName=self._options.filtername
598 CppType=
'PoolOutputModule'
599 if self._options.timeoutOutput:
600 CppType=
'TimeoutPoolOutputModule'
601 if streamType==
'DQM' and tier==
'DQMIO': CppType=
'DQMRootOutputModule'
602 output = cms.OutputModule(CppType,
604 fileName = cms.untracked.string(theFileName),
605 dataset = cms.untracked.PSet(dataTier = cms.untracked.string(tier),
606 filterName = cms.untracked.string(theFilterName)
609 if hasattr(self.process,
"generation_step")
and streamType!=
'LHE':
610 output.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
'generation_step'))
611 if hasattr(self.process,
"filtering_step"):
612 output.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
'filtering_step'))
614 if streamType==
'ALCARECO':
615 output.dataset.filterName = cms.untracked.string(
'StreamALCACombined')
617 if "MINIAOD" in streamType:
618 output.dropMetaData = cms.untracked.string(
'ALL')
619 output.fastCloning= cms.untracked.bool(
False)
620 output.overrideInputFileSplitLevels = cms.untracked.bool(
True)
622 outputModuleName=streamType+
'output'
623 setattr(self.process,outputModuleName,output)
624 outputModule=getattr(self.process,outputModuleName)
625 setattr(self.process,outputModuleName+
'_step',cms.EndPath(outputModule))
626 path=getattr(self.process,outputModuleName+
'_step')
627 self.schedule.append(path)
629 if self._options.outputCommands
and streamType!=
'DQM':
630 for evct
in self._options.outputCommands.split(
','):
631 if not evct:
continue
632 self.
executeAndRemember(
"process.%s.outputCommands.append('%s')"%(outputModuleName,evct.strip()))
634 if not self._options.inlineEventContent:
637 outputModule.outputCommands.__dict__[
"dumpPython"] = doNotInlineEventContent
639 result+=
"\nprocess."+outputModuleName+
" = "+outputModule.dumpPython()
645 Add selected standard sequences to the process
648 if self._options.pileup:
649 pileupSpec=self._options.pileup.split(
',')[0]
653 if self._options.fast
and pileupSpec.find(
"GEN_") == 0:
655 pileupSpec = pileupSpec[4:]
658 from Configuration.StandardSequences.Mixing
import Mixing,defineMixing
659 if not pileupSpec
in Mixing
and '.' not in pileupSpec
and 'file:' not in pileupSpec:
660 message = pileupSpec+
' is not a know mixing scenario:\n available are: '+
'\n'.
join(Mixing.keys())
661 if self._options.fast:
662 message +=
"\n-"*20+
"\n additional options for FastSim (gen-mixing):\n" +
"-"*20 +
"\n" +
'\n'.
join([
"GEN_" + x
for x
in Mixing.keys()]) +
"\n"
666 if '.' in pileupSpec:
667 mixingDict={
'file':pileupSpec}
668 elif pileupSpec.startswith(
'file:'):
669 mixingDict={
'file':pileupSpec[5:]}
672 mixingDict=copy.copy(Mixing[pileupSpec])
673 if len(self._options.pileup.split(
','))>1:
674 mixingDict.update(eval(self._options.pileup[self._options.pileup.find(
',')+1:]))
677 if 'file:' in pileupSpec:
679 self.process.load(mixingDict[
'file'])
680 print "inlining mixing module configuration"
681 self._options.inlineObjets+=
',mix'
686 if self._options.fast:
688 self._options.customisation_file.insert(0,
"FastSimulation/Configuration/MixingModule_Full2Fast.prepareGenMixing")
690 self._options.customisation_file.insert(0,
"FastSimulation/Configuration/MixingModule_Full2Fast.prepareDigiRecoMixing")
692 mixingDict.pop(
'file')
693 if not "DATAMIX" in self.stepMap.keys():
694 if self._options.pileup_input:
695 if self._options.pileup_input.startswith(
'dbs:')
or self._options.pileup_input.startswith(
'das:'):
696 mixingDict[
'F']=
filesFromDASQuery(
'file dataset = %s'%(self._options.pileup_input[4:],))[0]
698 mixingDict[
'F']=self._options.pileup_input.split(
',')
700 for command
in specialization:
702 if len(mixingDict)!=0:
703 raise Exception(
'unused mixing specification: '+mixingDict.keys().
__str__())
708 if len(self.stepMap):
710 if (
'SIM' in self.stepMap
or 'reSIM' in self.stepMap)
and not self._options.fast:
712 if self.geometryDBLabel:
713 self.
executeAndRemember(
'process.XMLFromDBSource.label = cms.string("%s")'%(self.geometryDBLabel))
715 print "Geometry option",self._options.geometry,
"unknown."
718 if len(self.stepMap):
721 for stepName
in self.stepKeys:
722 stepSpec = self.stepMap[stepName]
723 print "Step:", stepName,
"Spec:",stepSpec
724 if stepName.startswith(
're'):
726 if stepName[2:]
not in self._options.donotDropOnInput:
727 self._options.inputEventContent=
'%s,%s'%(stepName.upper(),self._options.inputEventContent)
728 stepName=stepName[2:]
730 getattr(self,
"prepare_"+stepName)(sequence = getattr(self,stepName+
"DefaultSeq"))
731 elif type(stepSpec)==list:
732 getattr(self,
"prepare_"+stepName)(sequence =
'+'.
join(stepSpec))
733 elif type(stepSpec)==tuple:
734 getattr(self,
"prepare_"+stepName)(sequence =
','.
join([stepSpec[1],
'+'.
join(stepSpec[0])]))
736 raise ValueError(
"Invalid step definition")
738 if self._options.restoreRNDSeeds!=
False:
740 if self._options.restoreRNDSeeds==
True:
741 self.
executeAndRemember(
'process.RandomNumberGeneratorService.restoreStateLabel=cms.untracked.string("randomEngineStateProducer")')
743 self.
executeAndRemember(
'process.RandomNumberGeneratorService.restoreStateTag=cms.untracked.InputTag("randomEngineStateProducer","","%s")'%(self._options.restoreRNDSeeds))
744 if self._options.inputEventContent
or self._options.inputCommands:
745 if self._options.inputCommands:
746 self._options.inputCommands+=
'keep *_randomEngineStateProducer_*_*,'
748 self._options.inputCommands=
'keep *_randomEngineStateProducer_*_*,'
752 if self._options.inputEventContent:
754 def dropSecondDropStar(iec):
765 if not hasattr(self.process.source,
'inputCommands'): self.process.source.inputCommands=cms.untracked.vstring()
766 for evct
in self._options.inputEventContent.split(
','):
767 if evct==
'':
continue
768 theEventContent = getattr(self.process, evct+
"EventContent")
769 if hasattr(theEventContent,
'outputCommands'):
770 self.process.source.inputCommands.extend(copy.copy(theEventContent.outputCommands))
771 if hasattr(theEventContent,
'inputCommands'):
772 self.process.source.inputCommands.extend(copy.copy(theEventContent.inputCommands))
774 dropSecondDropStar(self.process.source.inputCommands)
776 if not self._options.dropDescendant:
777 self.process.source.dropDescendantsOfDroppedBranches = cms.untracked.bool(
False)
783 """Add conditions to the process"""
784 if not self._options.conditions:
return
786 if 'FrontierConditions_GlobalTag' in self._options.conditions:
787 print 'using FrontierConditions_GlobalTag in --conditions is not necessary anymore and will be deprecated soon. please update your command line'
788 self._options.conditions = self._options.conditions.replace(
"FrontierConditions_GlobalTag,",
'')
790 self.loadAndRemember(self.ConditionsDefaultCFF)
792 if self._options.useCondDBv1:
793 from Configuration.AlCa.GlobalTag
import GlobalTag
795 from Configuration.AlCa.GlobalTag_condDBv2
import GlobalTag
797 self.process.GlobalTag =
GlobalTag(self.process.GlobalTag, self._options.conditions, self._options.custom_conditions)
799 if self._options.useCondDBv1:
800 self.additionalCommands.append(
'from Configuration.AlCa.GlobalTag import GlobalTag')
802 self.additionalCommands.append(
'from Configuration.AlCa.GlobalTag_condDBv2 import GlobalTag')
804 self.additionalCommands.append(
'process.GlobalTag = GlobalTag(process.GlobalTag, %s, %s)' % (repr(self._options.conditions), repr(self._options.custom_conditions)))
806 if self._options.slhc:
807 self.loadAndRemember(
"SLHCUpgradeSimulations/Geometry/fakeConditions_%s_cff"%(self._options.slhc,))
811 """Include the customise code """
815 for c
in self._options.customisation_file:
816 custOpt.extend(c.split(
","))
818 for c
in self._options.customisation_file_unsch:
819 custOpt.extend(c.split(
","))
825 raise Exception(
"more than . in the specification:"+opt)
826 fileName=opt.split(
'.')[0]
827 if opt.count(
'.')==0: rest=
'customise'
829 rest=opt.split(
'.')[1]
830 if rest==
'py': rest=
'customise'
832 if fileName
in custMap:
833 custMap[fileName].extend(rest.split(
'+'))
835 custMap[fileName]=rest.split(
'+')
840 final_snippet=
'\n# customisation of the process.\n'
844 allFcn.extend(custMap[opt])
846 if allFcn.count(fcn)!=1:
847 raise Exception(
"cannot specify twice "+fcn+
" as a customisation method")
851 packageName = f.replace(
".py",
"").
replace(
"/",
".")
852 __import__(packageName)
853 package = sys.modules[packageName]
856 customiseFile = re.sub(
r'\.pyc$',
'.py', package.__file__)
858 final_snippet+=
'\n# Automatic addition of the customisation function from '+packageName+
'\n'
859 if self._options.inline_custom:
860 for line
in file(customiseFile,
'r'):
861 if "import FWCore.ParameterSet.Config" in line:
863 final_snippet += line
865 final_snippet +=
'from %s import %s \n'%(packageName,
','.
join(custMap[f]))
866 for fcn
in custMap[f]:
867 print "customising the process with",fcn,
"from",f
868 if not hasattr(package,fcn):
870 raise Exception(
"config "+f+
" has no function "+fcn)
872 self.process=getattr(package,fcn)(self.process)
874 final_snippet +=
"\n#call to customisation function "+fcn+
" imported from "+packageName
875 final_snippet +=
"\nprocess = %s(process)\n"%(fcn,)
878 final_snippet +=
'\n# End of customisation functions\n'
881 if unsch==1
or not self._options.runUnscheduled:
882 if self._options.customise_commands:
884 final_snippet +=
'\n# Customisation from command line'
885 for com
in self._options.customise_commands.split(
'\\n'):
886 com=string.lstrip(com)
888 final_snippet +=
'\n'+com
897 if len(self.stepMap):
899 if self._options.particleTable
not in defaultOptions.particleTableList:
900 print 'Invalid particle table provided. Options are:'
901 print defaultOptions.particleTable
904 if len(self.stepMap):
905 self.
loadAndRemember(
'SimGeneral.HepPDTESSource.'+self._options.particleTable+
'_cfi')
922 self.EIDefaultCFF=
None
923 self.SKIMDefaultCFF=
"Configuration/StandardSequences/Skims_cff"
924 self.POSTRECODefaultCFF=
"Configuration/StandardSequences/PostRecoGenerator_cff"
925 self.VALIDATIONDefaultCFF=
"Configuration/StandardSequences/Validation_cff"
926 self.L1HwValDefaultCFF =
"Configuration/StandardSequences/L1HwVal_cff"
927 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOffline_cff"
928 self.HARVESTINGDefaultCFF=
"Configuration/StandardSequences/Harvesting_cff"
929 self.ALCAHARVESTDefaultCFF=
"Configuration/StandardSequences/AlCaHarvesting_cff"
930 self.ENDJOBDefaultCFF=
"Configuration/StandardSequences/EndOfProcess_cff"
931 if self._options.useCondDBv1:
932 self.ConditionsDefaultCFF =
"Configuration/StandardSequences/FrontierConditions_GlobalTag_cff"
934 self.ConditionsDefaultCFF =
"Configuration/StandardSequences/FrontierConditions_GlobalTag_condDBv2_cff"
935 self.CFWRITERDefaultCFF =
"Configuration/StandardSequences/CrossingFrameWriter_cff"
936 self.REPACKDefaultCFF=
"Configuration/StandardSequences/DigiToRaw_Repack_cff"
938 if "DATAMIX" in self.stepMap.keys():
939 self.DATAMIXDefaultCFF=
"Configuration/StandardSequences/DataMixer"+self._options.datamix+
"_cff"
940 if self._options.datamix ==
'PreMix':
941 self.
DIGIDefaultCFF=
"Configuration/StandardSequences/DigiDMPreMix_cff"
945 self.
L1EMDefaultCFF=
'Configuration/StandardSequences/SimL1EmulatorDM_cff'
947 if "DIGIPREMIX" in self.stepMap.keys():
948 self.
DIGIDefaultCFF=
"Configuration/StandardSequences/Digi_PreMix_cff"
950 self.ALCADefaultSeq=
None
951 self.LHEDefaultSeq=
'externalLHEProducer'
952 self.GENDefaultSeq=
'pgen'
953 self.SIMDefaultSeq=
'psim'
954 self.DIGIDefaultSeq=
'pdigi'
955 self.DIGIPREMIXDefaultSeq=
'pdigi'
956 self.DIGIPREMIX_S2DefaultSeq=
'pdigi'
957 self.DATAMIXDefaultSeq=
None
958 self.DIGI2RAWDefaultSeq=
'DigiToRaw'
959 self.HLTDefaultSeq=
'GRun'
960 self.L1DefaultSeq=
None
961 self.L1REPACKDefaultSeq=
'GT'
962 self.HARVESTINGDefaultSeq=
None
963 self.ALCAHARVESTDefaultSeq=
None
964 self.CFWRITERDefaultSeq=
None
965 self.RAW2DIGIDefaultSeq=
'RawToDigi'
966 self.L1RecoDefaultSeq=
'L1Reco'
967 self.L1TrackTriggerDefaultSeq=
'L1TrackTrigger'
968 if 'RAW2DIGI' in self.stepMap
and 'RECO' in self.stepMap:
969 self.RECODefaultSeq=
'reconstruction'
971 self.RECODefaultSeq=
'reconstruction_fromRECO'
973 self.EIDefaultSeq=
'top'
974 self.POSTRECODefaultSeq=
None
975 self.L1HwValDefaultSeq=
'L1HwVal'
976 self.DQMDefaultSeq=
'DQMOffline'
977 self.VALIDATIONDefaultSeq=
''
978 self.ENDJOBDefaultSeq=
'endOfProcess'
979 self.REPACKDefaultSeq=
'DigiToRawRepack'
980 self.PATDefaultSeq=
'miniAOD'
982 self.EVTCONTDefaultCFF=
"Configuration/EventContent/EventContent_cff"
984 if not self._options.beamspot:
985 self._options.beamspot=VtxSmearedDefaultKey
988 if self._options.isMC==
True:
990 self.
RECODefaultCFF=
"Configuration/StandardSequences/Reconstruction_cff"
991 self.
PATDefaultCFF=
"Configuration/StandardSequences/PATMC_cff"
992 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineMC_cff"
993 self.
ALCADefaultCFF=
"Configuration/StandardSequences/AlCaRecoStreamsMC_cff"
995 self._options.beamspot =
None
998 if 'reGEN' in self.stepMap:
999 self.GENDefaultSeq=
'fixGenInfo'
1001 if self._options.scenario==
'cosmics':
1002 self._options.pileup=
'Cosmics'
1003 self.
DIGIDefaultCFF=
"Configuration/StandardSequences/DigiCosmics_cff"
1004 self.
RECODefaultCFF=
"Configuration/StandardSequences/ReconstructionCosmics_cff"
1005 self.SKIMDefaultCFF=
"Configuration/StandardSequences/SkimsCosmics_cff"
1006 self.EVTCONTDefaultCFF=
"Configuration/EventContent/EventContentCosmics_cff"
1007 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineCosmics_cff"
1008 if self._options.isMC==
True:
1009 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineCosmicsMC_cff"
1010 self.HARVESTINGDefaultCFF=
"Configuration/StandardSequences/HarvestingCosmics_cff"
1011 self.RECODefaultSeq=
'reconstructionCosmics'
1012 self.DQMDefaultSeq=
'DQMOfflineCosmics'
1014 if self._options.scenario==
'HeavyIons':
1015 if not self._options.beamspot:
1016 self._options.beamspot=VtxSmearedHIDefaultKey
1017 self.HLTDefaultSeq =
'HIon'
1018 self.VALIDATIONDefaultCFF=
"Configuration/StandardSequences/ValidationHeavyIons_cff"
1019 self.VALIDATIONDefaultSeq=
''
1020 self.EVTCONTDefaultCFF=
"Configuration/EventContent/EventContentHeavyIons_cff"
1021 self.
RECODefaultCFF=
"Configuration/StandardSequences/ReconstructionHeavyIons_cff"
1022 self.RECODefaultSeq=
'reconstructionHeavyIons'
1023 self.
ALCADefaultCFF =
"Configuration/StandardSequences/AlCaRecoStreamsHeavyIons_cff"
1024 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineHeavyIons_cff"
1025 self.DQMDefaultSeq=
'DQMOfflineHeavyIons'
1026 self.SKIMDefaultCFF=
"Configuration/StandardSequences/SkimsHeavyIons_cff"
1027 self.HARVESTINGDefaultCFF=
"Configuration/StandardSequences/HarvestingHeavyIons_cff"
1028 if self._options.isMC==
True:
1029 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineHeavyIonsMC_cff"
1032 self.RAW2RECODefaultSeq=
','.
join([self.RAW2DIGIDefaultSeq,self.RECODefaultSeq])
1034 self.USERDefaultSeq=
'user'
1035 self.USERDefaultCFF=
None
1038 if self._options.isData:
1039 if self._options.magField==defaultOptions.magField:
1040 print "magnetic field option forced to: AutoFromDBCurrent"
1041 self._options.magField=
'AutoFromDBCurrent'
1042 self.magFieldCFF =
'Configuration/StandardSequences/MagneticField_'+self._options.magField.replace(
'.',
'')+
'_cff'
1043 self.magFieldCFF = self.magFieldCFF.replace(
"__",
'_')
1046 self.GeometryCFF=
'Configuration/StandardSequences/GeometryRecoDB_cff'
1047 self.geometryDBLabel=
None
1049 if self._options.fast:
1050 if 'start' in self._options.conditions.lower():
1051 self.GeometryCFF=
'FastSimulation/Configuration/Geometries_START_cff'
1053 self.GeometryCFF=
'FastSimulation/Configuration/Geometries_MC_cff'
1056 from Configuration.StandardSequences.GeometryConf
import GeometryConf
1057 if opt
in GeometryConf:
1058 return GeometryConf[opt]
1062 geoms=self._options.geometry.split(
',')
1066 if '/' in geoms[1]
or '_cff' in geoms[1]:
1067 self.GeometryCFF=geoms[1]
1069 self.GeometryCFF=
'Configuration/Geometry/Geometry'+geoms[1]+
'_cff'
1071 if (geoms[0].startswith(
'DB:')):
1072 self.SimGeometryCFF=
'Configuration/StandardSequences/GeometrySimDB_cff'
1073 self.geometryDBLabel=geoms[0][3:]
1076 if '/' in geoms[0]
or '_cff' in geoms[0]:
1077 self.SimGeometryCFF=geoms[0]
1079 simGeometry=geoms[0]
1080 if self._options.gflash==
True:
1081 self.SimGeometryCFF=
'Configuration/Geometry/Geometry'+geoms[0]+
'GFlash_cff'
1083 self.SimGeometryCFF=
'Configuration/Geometry/Geometry'+geoms[0]+
'_cff'
1086 if simGeometry
not in defaultOptions.geometryExtendedOptions:
1087 self.
SIMDefaultCFF=
"Configuration/StandardSequences/SimIdeal_cff"
1089 if self._options.scenario==
'nocoll' or self._options.scenario==
'cosmics':
1090 self.
SIMDefaultCFF=
"Configuration/StandardSequences/SimNOBEAM_cff"
1091 self._options.beamspot=
'NoSmear'
1094 if self._options.fast:
1095 self.
SIMDefaultCFF =
'FastSimulation.Configuration.SimIdeal_cff'
1096 self.SIMDefaultSeq =
'psim'
1097 self.
RECODefaultCFF=
'FastSimulation.Configuration.Reconstruction_AftMix_cff'
1098 self.RECODefaultSeq=
'reconstruction'
1099 self.EVTCONTDefaultCFF =
"FastSimulation.Configuration.EventContent_cff"
1100 self.VALIDATIONDefaultCFF =
"FastSimulation.Configuration.Validation_cff"
1101 self.RECOBEFMIXDefaultCFF =
'FastSimulation.Configuration.Reconstruction_BefMix_cff'
1102 self.RECOBEFMIXDefaultSeq =
'reconstruction_befmix'
1104 if self._options.datamix ==
'PreMix':
1105 self.
DIGIDefaultCFF=
"FastSimulation.Configuration.DigiDMPreMix_cff"
1106 if "DIGIPREMIX" in self.stepMap.keys():
1107 self.
DIGIDefaultCFF=
"FastSimulation.Configuration.Digi_PreMix_cff"
1108 if "DATAMIX" in self.stepMap.keys():
1109 self.DATAMIXDefaultCFF=
"FastSimulation.Configuration.DataMixer"+self._options.datamix+
"_cff"
1111 self.DIGIDefaultSeq =
'pdigi'
1112 self.
L1EMDefaultCFF=
'FastSimulation.Configuration.SimL1Emulator_cff'
1115 self.DIGI2RAWDefaultSeq =
'DigiToRaw'
1116 self.EVTCONTDefaultCFF =
"FastSimulation.Configuration.EventContent_cff"
1117 self.VALIDATIONDefaultCFF =
"FastSimulation.Configuration.Validation_cff"
1122 if self._options.pileup==
'default':
1123 from Configuration.StandardSequences.Mixing
import MixingDefaultKey
1124 self._options.pileup=MixingDefaultKey
1126 if self._options.fast:
1127 self._options.pileup=
"GEN_" + MixingDefaultKey
1131 if self._options.isData:
1132 self._options.pileup=
None
1134 if self._options.slhc:
1135 self.GeometryCFF=
'SLHCUpgradeSimulations.Geometry.%s_cmsSimIdealGeometryXML_cff'%(self._options.slhc,)
1136 if 'stdgeom' not in self._options.slhc:
1137 self.SimGeometryCFF=
'SLHCUpgradeSimulations.Geometry.%s_cmsSimIdealGeometryXML_cff'%(self._options.slhc,)
1138 self.
DIGIDefaultCFF=
'SLHCUpgradeSimulations/Geometry/Digi_%s_cff'%(self._options.slhc,)
1139 if self._options.pileup!=defaultOptions.pileup:
1140 self._options.pileup=
'SLHC_%s_%s'%(self._options.pileup,self._options.slhc)
1142 self.REDIGIDefaultSeq=self.DIGIDefaultSeq
1147 output = cms.OutputModule(
"PoolOutputModule")
1148 if stream.selectEvents.parameters_().__len__()!=0:
1149 output.SelectEvents = stream.selectEvents
1151 output.SelectEvents = cms.untracked.PSet()
1152 output.SelectEvents.SelectEvents=cms.vstring()
1153 if isinstance(stream.paths,tuple):
1154 for path
in stream.paths:
1155 output.SelectEvents.SelectEvents.append(path.label())
1157 output.SelectEvents.SelectEvents.append(stream.paths.label())
1161 if isinstance(stream.content,str):
1162 evtPset=getattr(self.process,stream.content)
1163 for p
in evtPset.parameters_():
1164 setattr(output,p,getattr(evtPset,p))
1165 if not self._options.inlineEventContent:
1168 output.outputCommands.__dict__[
"dumpPython"] = doNotInlineEventContent
1170 output.outputCommands = stream.content
1173 output.fileName = cms.untracked.string(self._options.dirout+stream.name+
'.root')
1175 output.dataset = cms.untracked.PSet( dataTier = stream.dataTier,
1176 filterName = cms.untracked.string(stream.name))
1178 if self._options.filtername:
1179 output.dataset.filterName= cms.untracked.string(self._options.filtername+
"_"+stream.name)
1182 output.eventAutoFlushCompressedSize=cms.untracked.int32(5*1024*1024)
1184 if workflow
in (
"producers,full"):
1185 if isinstance(stream.paths,tuple):
1186 for path
in stream.paths:
1187 self.schedule.append(path)
1189 self.schedule.append(stream.paths)
1193 if (
not self._options.relval)
and workflow
in (
"full",
"output"):
1194 self.additionalOutputs[name] = output
1195 setattr(self.process,name,output)
1197 if workflow ==
'output':
1199 filterList = output.SelectEvents.SelectEvents
1200 for i, filter
in enumerate(filterList):
1201 filterList[i] = filter+
":"+self._options.triggerResultsProcess
1211 if ( len(sequence.split(
'.'))==1 ):
1213 elif ( len(sequence.split(
'.'))==2 ):
1215 sequence=sequence.split(
'.')[1]
1217 print "sub sequence configuration must be of the form dir/subdir/cff.a+b+c or cff.a"
1218 print sequence,
"not recognized"
1225 for i,s
in enumerate(seq.split(
'*')):
1227 setattr(self.process,prefix,getattr(cms,what)( getattr(self.process, s) ))
1229 p=getattr(self.process,prefix)
1230 p+=getattr(self.process, s)
1231 self.schedule.append(getattr(self.process,prefix))
1236 if self.nextScheduleIsConditional:
1237 self.conditionalPaths.append(prefix)
1238 setattr(self.process,prefix,getattr(cms,what)( getattr(self.process, seq) ))
1239 self.schedule.append(getattr(self.process,prefix))
1241 for i,s
in enumerate(seq.split(
'+')):
1243 setattr(self.process,sn,getattr(cms,what)( getattr(self.process, s) ))
1244 self.schedule.append(getattr(self.process,sn))
1258 """ Enrich the process with alca streams """
1260 sequence = sequence.split(
'.')[-1]
1263 alcaList = sequence.split(
"+")
1265 from Configuration.AlCa.autoAlca
import autoAlca
1269 for name
in alcaConfig.__dict__:
1270 alcastream = getattr(alcaConfig,name)
1271 shortName = name.replace(
'ALCARECOStream',
'')
1272 if shortName
in alcaList
and isinstance(alcastream,cms.FilteredStream):
1273 output = self.
addExtraStream(name,alcastream, workflow = workflow)
1274 self.
executeAndRemember(
'process.ALCARECOEventContent.outputCommands.extend(process.OutALCARECO'+shortName+
'_noDrop.outputCommands)')
1275 self.AlCaPaths.append(shortName)
1276 if 'DQM' in alcaList:
1277 if not self._options.inlineEventContent
and hasattr(self.process,name):
1278 self.
executeAndRemember(
'process.' + name +
'.outputCommands.append("keep *_MEtoEDMConverter_*_*")')
1280 output.outputCommands.append(
"keep *_MEtoEDMConverter_*_*")
1283 if self._options.hltProcess
or 'HLT' in self.stepMap:
1284 if isinstance(alcastream.paths,tuple):
1285 for path
in alcastream.paths:
1290 for i
in range(alcaList.count(shortName)):
1291 alcaList.remove(shortName)
1294 elif name ==
'pathALCARECODQM' and 'DQM' in alcaList:
1295 path = getattr(alcaConfig,name)
1296 self.schedule.append(path)
1297 alcaList.remove(
'DQM')
1299 if isinstance(alcastream,cms.Path):
1301 self.blacklist_paths.append(alcastream)
1304 if len(alcaList) != 0:
1306 for name
in alcaConfig.__dict__:
1307 alcastream = getattr(alcaConfig,name)
1308 if isinstance(alcastream,cms.FilteredStream):
1309 available.append(name.replace(
'ALCARECOStream',
''))
1310 print "The following alcas could not be found "+str(alcaList)
1311 print "available ",available
1313 raise Exception(
"The following alcas could not be found "+str(alcaList))
1318 loadFragment = self._options.evt_type.replace(
'.py',
'',).
replace(
'.',
'_').
replace(
'python/',
'').
replace(
'/',
'.')
1319 print "Loading lhe fragment from",loadFragment
1320 __import__(loadFragment)
1321 self.process.load(loadFragment)
1323 self._options.inlineObjets+=
','+sequence
1325 getattr(self.process,sequence).nEvents = int(self._options.number)
1328 self.process.lhe_step = cms.Path( getattr( self.process,sequence) )
1329 self.excludedPaths.append(
"lhe_step")
1330 self.schedule.append( self.process.lhe_step )
1333 """ load the fragment of generator configuration """
1338 loadFragment = self._options.evt_type.replace(
'.py',
'',).
replace(
'.',
'_').
replace(
'python/',
'')
1340 if not '/' in loadFragment:
1341 loadFragment=
'Configuration.Generator.'+loadFragment
1343 loadFragment=loadFragment.replace(
'/',
'.')
1345 print "Loading generator fragment from",loadFragment
1346 __import__(loadFragment)
1350 if not (self._options.filein
or self._options.dasquery):
1351 raise Exception(
"Neither gen fragment of input files provided: this is an inconsistent GEN step configuration")
1354 generatorModule=sys.modules[loadFragment]
1355 genModules=generatorModule.__dict__
1358 if self.LHEDefaultSeq
in genModules:
1359 del genModules[self.LHEDefaultSeq]
1361 if self._options.hideGen:
1364 self.process.load(loadFragment)
1366 import FWCore.ParameterSet.Modules
as cmstypes
1367 for name
in genModules:
1368 theObject = getattr(generatorModule,name)
1369 if isinstance(theObject, cmstypes._Module):
1370 self._options.inlineObjets=name+
','+self._options.inlineObjets
1371 elif isinstance(theObject, cms.Sequence)
or isinstance(theObject, cmstypes.ESProducer):
1372 self._options.inlineObjets+=
','+name
1374 if sequence == self.GENDefaultSeq
or sequence ==
'pgen_genonly':
1375 if 'ProductionFilterSequence' in genModules
and (
'generator' in genModules):
1376 self.productionFilterSequence =
'ProductionFilterSequence'
1377 elif 'generator' in genModules:
1378 self.productionFilterSequence =
'generator'
1380 """ Enrich the schedule with the rest of the generation step """
1382 genSeqName=sequence.split(
'.')[-1]
1386 from Configuration.StandardSequences.VtxSmeared
import VtxSmeared
1387 cffToBeLoaded=VtxSmeared[self._options.beamspot]
1390 raise Exception(
"VertexSmearing type or beamspot "+self._options.beamspot+
" unknown.")
1392 if self._options.scenario ==
'HeavyIons':
1393 if self._options.pileup==
'HiMixGEN':
1394 self.
loadAndRemember(
"Configuration/StandardSequences/GeneratorMix_cff")
1396 self.
loadAndRemember(
"Configuration/StandardSequences/GeneratorHI_cff")
1398 self.process.generation_step = cms.Path( getattr(self.process,genSeqName) )
1399 self.schedule.append(self.process.generation_step)
1402 self.
executeAndRemember(
'process.genstepfilter.triggerConditions=cms.vstring("generation_step")')
1404 if 'reGEN' in self.stepMap:
1408 """ Enrich the schedule with the summary of the filter step """
1415 """ Enrich the schedule with the simulation step"""
1416 self.loadDefaultOrSpecifiedCFF(sequence,self.SIMDefaultCFF)
1417 if not self._options.fast:
1418 if self._options.gflash==
True:
1419 self.loadAndRemember(
"Configuration/StandardSequences/GFlashSIM_cff")
1421 if self._options.magField==
'0T':
1422 self.executeAndRemember(
"process.g4SimHits.UseMagneticField = cms.bool(False)")
1424 if self._options.magField==
'0T':
1425 self.executeAndRemember(
"process.famosSimHits.UseMagneticField = cms.bool(False)")
1427 self.scheduleSequence(sequence.split(
'.')[-1],
'simulation_step')
1431 """ Enrich the schedule with the digitisation step"""
1434 if self._options.gflash==
True:
1435 self.
loadAndRemember(
"Configuration/StandardSequences/GFlashDIGI_cff")
1437 if sequence ==
'pdigi_valid':
1438 self.
executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersValid)")
1440 if sequence !=
'pdigi_nogen' and sequence !=
'pdigi_valid_nogen' and not self.process.source.type_()==
'EmptySource':
1441 if self._options.inputEventContent==
'':
1442 self._options.inputEventContent=
'REGEN'
1444 self._options.inputEventContent=self._options.inputEventContent+
',REGEN'
1451 """ Enrich the schedule with the digitisation step"""
1455 self.
executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersNoNoise)")
1461 """ Enrich the schedule with the digitisation step"""
1462 self.loadDefaultOrSpecifiedCFF(sequence,self.DIGIDefaultCFF)
1464 self.loadAndRemember(
"SimGeneral/MixingModule/digi_MixPreMix_cfi")
1467 if sequence ==
'pdigi_valid':
1468 self.executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersMixPreMixValid)")
1470 self.executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersMixPreMix)")
1472 self.scheduleSequence(sequence.split(
'.')[-1],
'digitisation_step')
1476 """ Enrich the schedule with the crossing frame writer step"""
1482 """ Enrich the schedule with the digitisation step"""
1486 if self._options.pileup_input:
1488 if self._options.pileup_input.startswith(
'dbs:')
or self._options.pileup_input.startswith(
'das:'):
1489 theFiles=
filesFromDASQuery(
'file dataset = %s'%(self._options.pileup_input[4:],))[0]
1490 elif self._options.pileup_input.startswith(
"filelist:"):
1491 theFiles= (
filesFromList(self._options.pileup_input[9:]))[0]
1493 theFiles=self._options.pileup_input.split(
',')
1495 self.
executeAndRemember(
"process.mixData.input.fileNames = cms.untracked.vstring(%s)"%( theFiles ) )
1502 if "DIGIPREMIX" in self.stepMap.keys():
1504 self.
executeAndRemember(
"process.SiStripDigiToRaw.FedReadoutMode = cms.string('PREMIX_RAW')")
1514 """ Enrich the schedule with the L1 simulation step"""
1521 """ 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"""
1522 supported = [
'GT',
'GT1',
'GT2',
'GCTGT']
1523 if sequence
in supported:
1524 self.loadAndRemember(
'Configuration/StandardSequences/SimL1EmulatorRepack_%s_cff'%sequence)
1525 if self._options.scenario ==
'HeavyIons':
1526 self.renameInputTagsInSequence(
"SimL1Emulator",
"rawDataCollector",
"rawDataRepacker")
1527 self.scheduleSequence(
'SimL1Emulator',
'L1RePack_step')
1529 print "L1REPACK with '",sequence,
"' is not supported! Supported choices are: ",supported
1534 """ Enrich the schedule with the HLT simulation step"""
1536 print "no specification of the hlt menu has been given, should never happen"
1537 raise Exception(
'no HLT sequence provided')
1541 from Configuration.HLT.autoHLT
import autoHLT
1544 sequence = autoHLT[key]
1546 raise ValueError(
'no HLT mapping key "%s" found in autoHLT' % key)
1552 if self._options.scenario ==
'HeavyIons':
1553 optionsForHLT[
'type'] =
'HIon'
1555 optionsForHLT[
'type'] =
'GRun'
1556 optionsForHLTConfig =
', '.
join(
'%s=%s' % (key, repr(val))
for (key, val)
in optionsForHLT.iteritems())
1557 if sequence ==
'run,fromSource':
1558 if hasattr(self.process.source,
'firstRun'):
1559 self.
executeAndRemember(
'process.loadHltConfiguration("run:%%d"%%(process.source.firstRun.value()),%s)'%(optionsForHLTConfig))
1560 elif hasattr(self.process.source,
'setRunNumber'):
1561 self.
executeAndRemember(
'process.loadHltConfiguration("run:%%d"%%(process.source.setRunNumber.value()),%s)'%(optionsForHLTConfig))
1563 raise Exception(
'Cannot replace menu to load %s'%(sequence))
1565 self.
executeAndRemember(
'process.loadHltConfiguration("%s",%s)'%(sequence.replace(
',',
':'),optionsForHLTConfig))
1569 if self._options.isMC:
1570 if self._options.fast:
1571 self._options.customisation_file.append(
"HLTrigger/Configuration/customizeHLTforMC.customizeHLTforFastSim")
1573 self._options.customisation_file.append(
"HLTrigger/Configuration/customizeHLTforMC.customizeHLTforFullSim")
1575 if self._options.name !=
'HLT':
1576 self.additionalCommands.append(
'from HLTrigger.Configuration.CustomConfigs import ProcessName')
1577 self.additionalCommands.append(
'process = ProcessName(process)')
1578 self.additionalCommands.append(
'')
1579 from HLTrigger.Configuration.CustomConfigs
import ProcessName
1582 self.schedule.append(self.process.HLTSchedule)
1583 [self.blacklist_paths.append(path)
for path
in self.process.HLTSchedule
if isinstance(path,(cms.Path,cms.EndPath))]
1586 if self._options.fast:
1587 if not hasattr(self.process,
'HLTEndSequence'):
1588 self.
executeAndRemember(
"process.HLTEndSequence = cms.Sequence( process.dummyModule )")
1593 seqReco=sequence.split(
',')[1]
1594 seqDigi=sequence.split(
',')[0]
1596 print "RAW2RECO requires two specifications",sequence,
"insufficient"
1610 self.
loadAndRemember(
"PhysicsTools/PatAlgos/slimming/metFilterPaths_cff")
1612 for filt
in allMetFilterPaths:
1613 self.schedule.append(getattr(self.process,
'Flag_'+filt))
1616 ''' Enrich the schedule with L1 HW validation '''
1619 print '\n\n\n DEPRECATED this has no action \n\n\n'
1623 ''' Enrich the schedule with L1 reconstruction '''
1629 ''' Enrich the schedule with L1 reconstruction '''
1635 ''' Enrich the schedule with a user defined filter sequence '''
1637 filterConfig=self.
load(sequence.split(
'.')[0])
1638 filterSeq=sequence.split(
'.')[-1]
1646 label=visitee.label()
1654 getattr(self.process,filterSeq).
visit( expander )
1655 self._options.inlineObjets+=
','+expander.inliner
1656 self._options.inlineObjets+=
','+filterSeq
1659 self.scheduleSequence(filterSeq,
'filtering_step')
1660 self.nextScheduleIsConditional=
True
1662 self.productionFilterSequence = filterSeq
1667 ''' Enrich the schedule with reconstruction '''
1673 ''' Enrich the schedule with the part of reconstruction that is done before mixing in FastSim'''
1674 if not self._options.fast:
1675 print "ERROR: this step is only implemented for FastSim"
1678 self.
scheduleSequence(sequence.split(
'.')[-1],
'reconstruction_befmix_step')
1682 ''' Enrich the schedule with PAT '''
1683 self.prepare_PATFILTER(self)
1684 self.loadDefaultOrSpecifiedCFF(sequence,self.PATDefaultCFF,1)
1685 if not self._options.runUnscheduled:
1686 raise Exception(
"MiniAOD production can only run in unscheduled mode, please run cmsDriver with --runUnscheduled")
1687 if self._options.isData:
1688 self._options.customisation_file_unsch.append(
"PhysicsTools/PatAlgos/slimming/miniAOD_tools.miniAOD_customizeAllData")
1690 self._options.customisation_file_unsch.append(
"PhysicsTools/PatAlgos/slimming/miniAOD_tools.miniAOD_customizeAllMC")
1691 if self._options.fast:
1692 self._options.customisation_file_unsch.append(
"PhysicsTools/PatAlgos/slimming/metFilterPaths_cff.miniAOD_customizeMETFiltersFastSim")
1696 ''' Enrich the schedule with event interpretation '''
1697 from Configuration.StandardSequences.EventInterpretation
import EventInterpretation
1698 if sequence
in EventInterpretation:
1699 self.EIDefaultCFF = EventInterpretation[sequence]
1700 sequence =
'EIsequence'
1702 raise Exception(
'Cannot set %s event interpretation'%( sequence) )
1708 ''' Enrich the schedule with skimming fragments'''
1710 sequence = sequence.split(
'.')[-1]
1712 skimlist=sequence.split(
'+')
1714 from Configuration.Skimming.autoSkim
import autoSkim
1718 for skim
in skimConfig.__dict__:
1719 skimstream = getattr(skimConfig,skim)
1720 if isinstance(skimstream,cms.Path):
1722 self.blacklist_paths.append(skimstream)
1723 if (
not isinstance(skimstream,cms.FilteredStream)):
1725 shortname = skim.replace(
'SKIMStream',
'')
1726 if (sequence==
"all"):
1728 elif (shortname
in skimlist):
1731 if self._options.datatier==
'DQM':
1732 self.process.load(self.EVTCONTDefaultCFF)
1733 skimstreamDQM = cms.FilteredStream(
1734 responsible = skimstream.responsible,
1735 name = skimstream.name+
'DQM',
1736 paths = skimstream.paths,
1737 selectEvents = skimstream.selectEvents,
1738 content = self._options.datatier+
'EventContent',
1739 dataTier = cms.untracked.string(self._options.datatier)
1742 for i
in range(skimlist.count(shortname)):
1743 skimlist.remove(shortname)
1747 if (skimlist.__len__()!=0
and sequence!=
"all"):
1748 print 'WARNING, possible typo with SKIM:'+
'+'.
join(skimlist)
1749 raise Exception(
'WARNING, possible typo with SKIM:'+
'+'.
join(skimlist))
1752 ''' Enrich the schedule with a user defined sequence '''
1758 """ Enrich the schedule with the postreco step """
1765 print sequence,
"in preparing validation"
1767 from Validation.Configuration.autoValidation
import autoValidation
1769 sequence=sequence.split(
'.')[-1]
1770 if sequence.find(
',')!=-1:
1771 prevalSeqName=sequence.split(
',')[0].
split(
'+')
1772 valSeqName=sequence.split(
',')[1].
split(
'+')
1777 prevalSeqName=sequence.split(
'+')
1778 valSeqName=sequence.split(
'+')
1784 postfix=
'_'+sequence
1785 prevalSeqName=[
'prevalidation'+postfix]
1786 valSeqName=[
'validation'+postfix]
1787 if not hasattr(self.process,valSeqName[0]):
1789 valSeqName=[sequence]
1798 if not 'DIGI' in self.stepMap
and not self._options.fast
and not any(
map(
lambda s : s.startswith(
'genvalid'), valSeqName)):
1799 if self._options.restoreRNDSeeds==
False and not self._options.restoreRNDSeeds==
True:
1800 self._options.restoreRNDSeeds=
True
1803 if (
'HLT' in self.stepMap
and not self._options.fast)
or self._options.hltProcess:
1804 for s
in valSeqName+prevalSeqName:
1807 for (i,s)
in enumerate(prevalSeqName):
1809 setattr(self.process,
'prevalidation_step%s'%NFI(i), cms.Path( getattr(self.process, s)) )
1810 self.schedule.append(getattr(self.process,
'prevalidation_step%s'%NFI(i)))
1812 for (i,s)
in enumerate(valSeqName):
1813 setattr(self.process,
'validation_step%s'%NFI(i), cms.EndPath( getattr(self.process, s)))
1814 self.schedule.append(getattr(self.process,
'validation_step%s'%NFI(i)))
1816 if not 'DIGI' in self.stepMap
and not self._options.fast:
1820 self._options.customisation_file.append(
"SimGeneral/MixingModule/fullMixCustomize_cff.setCrossingFrameOn")
1822 if hasattr(self.process,
"genstepfilter")
and len(self.process.genstepfilter.triggerConditions):
1824 for (i,s)
in enumerate(valSeqName):
1825 getattr(self.process,
'validation_step%s'%NFI(i))._seq = self.process.genstepfilter * getattr(self.process,
'validation_step%s'%NFI(i))._seq
1831 """Visitor that travels within a cms.Sequence, looks for a parameter and replace its value
1832 It will climb down within PSets, VPSets and VInputTags to find its target"""
1833 def __init__(self, paramSearch, paramReplace, verbose=False, whitelist=()):
1840 if isinstance(pset, cms._Parameterizable):
1841 for name
in pset.parameters_().
keys():
1847 value = getattr(pset,name)
1848 type = value.pythonTypeName()
1849 if type
in (
'cms.PSet',
'cms.untracked.PSet'):
1850 self.
doIt(value,base+
"."+name)
1851 elif type
in (
'cms.VPSet',
'cms.untracked.VPSet'):
1852 for (i,ps)
in enumerate(value): self.
doIt(ps,
"%s.%s[%d]"%(base,name,i) )
1853 elif type
in (
'cms.string',
'cms.untracked.string'):
1855 if self.
_verbose:
print "set string process name %s.%s %s ==> %s"% (base, name, value, self.
_paramReplace)
1857 elif type
in (
'cms.VInputTag',
'cms.untracked.VInputTag'):
1858 for (i,n)
in enumerate(value):
1859 if not isinstance(n, cms.InputTag):
1863 if self.
_verbose:
print "set process name %s.%s[%d] %s ==> %s " % (base, name, i, n, self.
_paramReplace)
1866 elif type
in (
'cms.vstring',
'cms.untracked.vstring'):
1867 for (i,n)
in enumerate(value):
1870 elif type
in (
'cms.InputTag',
'cms.untracked.InputTag'):
1872 if self.
_verbose:
print "set process name %s.%s %s ==> %s " % (base, name, value, self.
_paramReplace)
1873 setattr(getattr(pset, name),
"processName",self.
_paramReplace)
1878 label = visitee.label()
1879 except AttributeError:
1880 label =
'<Module not in a Process>'
1882 label =
'other execption'
1883 self.
doIt(visitee, label)
1890 print "Replacing all InputTag %s => %s"%(oldT,newT)
1893 loadMe=
'from PhysicsTools.PatAlgos.tools.helpers import massSearchReplaceAnyInputTag'
1894 if not loadMe
in self.additionalCommands:
1895 self.additionalCommands.append(loadMe)
1896 self.additionalCommands.append(
'massSearchReplaceAnyInputTag(process.%s,"%s","%s",False,True)'%(sequence,oldT,newT))
1900 if self._options.hltProcess:
1901 proc=self._options.hltProcess
1903 proc=self.process.name_()
1904 if proc==HLTprocess:
return
1906 print "replacing %s process name - sequence %s will use '%s'" % (HLTprocess,sequence, proc)
1908 if 'from Configuration.Applications.ConfigBuilder import ConfigBuilder' not in self.additionalCommands:
1909 self.additionalCommands.append(
'from Configuration.Applications.ConfigBuilder import ConfigBuilder')
1910 self.additionalCommands.append(
'process.%s.visit(ConfigBuilder.MassSearchReplaceProcessNameVisitor("%s", "%s", whitelist = ("subSystemFolder",)))'% (sequence,HLTprocess, proc))
1916 while '@' in repr(seqList)
and level<maxLevel:
1918 for specifiedCommand
in seqList:
1919 if specifiedCommand.startswith(
'@'):
1920 location=specifiedCommand[1:]
1921 if not location
in mapping:
1922 raise Exception(
"Impossible to map "+location+
" from "+repr(mapping))
1923 mappedTo=mapping[location]
1925 mappedTo=mappedTo[index]
1926 seqList.remove(specifiedCommand)
1927 seqList.extend(mappedTo.split(
'+'))
1930 raise Exception(
"Could not fully expand "+repr(seqList)+
" from "+repr(mapping))
1936 sequenceList=sequence.split(
'.')[-1].
split(
'+')
1937 from DQMOffline.Configuration.autoDQM
import autoDQM
1940 if len(set(sequenceList))!=len(sequenceList):
1941 sequenceList=
list(set(sequenceList))
1942 print "Duplicate entries for DQM:, using",sequenceList
1943 pathName=
'dqmoffline_step'
1945 for (i,sequence)
in enumerate(sequenceList):
1947 pathName=
'dqmoffline_%d_step'%(i)
1949 if 'HLT' in self.stepMap.keys()
or self._options.hltProcess:
1953 if 'HLT' in self.stepMap.keys():
1955 setattr(self.process,pathName, cms.EndPath( getattr(self.process, sequence ) ) )
1958 setattr(self.process,pathName, cms.Path( getattr(self.process, sequence) ) )
1959 self.schedule.append(getattr(self.process,pathName))
1963 """ Enrich the process with harvesting step """
1964 self.
EDMtoMECFF=
'Configuration/StandardSequences/EDMtoME'+self._options.harvesting+
'_cff'
1969 sequence = sequence.split(
'.')[-1]
1972 harvestingList = sequence.split(
"+")
1973 from DQMOffline.Configuration.autoDQM
import autoDQM
1974 from Validation.Configuration.autoValidation
import autoValidation
1976 combined_mapping = copy.deepcopy( autoDQM )
1977 combined_mapping.update( autoValidation )
1978 self.
expandMapping(harvestingList,combined_mapping,index=-1)
1980 if len(set(harvestingList))!=len(harvestingList):
1981 harvestingList=
list(set(harvestingList))
1982 print "Duplicate entries for HARVESTING, using",harvestingList
1984 for name
in harvestingList:
1985 if not name
in harvestingConfig.__dict__:
1986 print name,
"is not a possible harvesting type. Available are",harvestingConfig.__dict__.keys()
1988 harvestingstream = getattr(harvestingConfig,name)
1989 if isinstance(harvestingstream,cms.Path):
1990 self.schedule.append(harvestingstream)
1991 self.blacklist_paths.append(harvestingstream)
1992 if isinstance(harvestingstream,cms.Sequence):
1993 setattr(self.process,name+
"_step",cms.Path(harvestingstream))
1994 self.schedule.append(getattr(self.process,name+
"_step"))
2000 """ Enrich the process with AlCaHarvesting step """
2002 sequence=sequence.split(
".")[-1]
2005 harvestingList = sequence.split(
"+")
2009 from Configuration.AlCa.autoPCL
import autoPCL
2012 for name
in harvestingConfig.__dict__:
2013 harvestingstream = getattr(harvestingConfig,name)
2014 if name
in harvestingList
and isinstance(harvestingstream,cms.Path):
2015 self.schedule.append(harvestingstream)
2016 self.
executeAndRemember(
"process.PoolDBOutputService.toPut.append(process.ALCAHARVEST" + name +
"_dbOutput)")
2017 self.
executeAndRemember(
"process.pclMetadataWriter.recordsToMap.append(process.ALCAHARVEST" + name +
"_metadata)")
2018 harvestingList.remove(name)
2020 lastStep = getattr(harvestingConfig,
"ALCAHARVESTDQMSaveAndMetadataWriter")
2021 self.schedule.append(lastStep)
2023 if len(harvestingList) != 0
and 'dummyHarvesting' not in harvestingList :
2024 print "The following harvesting could not be found : ", harvestingList
2025 raise Exception(
"The following harvesting could not be found : "+str(harvestingList))
2035 self.process.reconstruction = cms.Path(self.process.reconstructionWithFamos)
2036 self.schedule.append(self.process.reconstruction)
2040 """ Add useful info for the production. """
2041 self.process.configurationMetadata=cms.untracked.PSet\
2042 (version=cms.untracked.string(
"$Revision: 1.19 $"),
2043 name=cms.untracked.string(
"Applications"),
2044 annotation=cms.untracked.string(evt_type+
" nevts:"+str(evtnumber))
2047 self.addedObjects.append((
"Production Info",
"configurationMetadata"))
2051 """ Prepare the configuration string and add missing pieces."""
2063 outputModuleCfgCode=
""
2064 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:
2069 self.pythonCfgCode =
"# Auto generated configuration file\n"
2070 self.pythonCfgCode +=
"# using: \n# "+__version__[1:-1]+
"\n# "+__source__[1:-1]+
'\n'
2071 self.pythonCfgCode +=
"# with command line options: "+self._options.arguments+
'\n'
2072 self.pythonCfgCode +=
"import FWCore.ParameterSet.Config as cms\n\n"
2073 if hasattr(self.
_options,
"era")
and self._options.era :
2074 self.pythonCfgCode +=
"from Configuration.StandardSequences.Eras import eras\n\n"
2075 self.pythonCfgCode +=
"process = cms.Process('"+self.process.name_()+
"'"
2077 for requestedEra
in self._options.era.split(
",") :
2078 self.pythonCfgCode +=
",eras."+requestedEra
2079 self.pythonCfgCode +=
")\n\n"
2081 self.pythonCfgCode +=
"process = cms.Process('"+self.process.name_()+
"')\n\n"
2083 self.pythonCfgCode +=
"# import of standard configurations\n"
2084 for module
in self.imports:
2085 self.pythonCfgCode += (
"process.load('"+module+
"')\n")
2088 if not hasattr(self.process,
"configurationMetadata"):
2092 self.addedObjects.append((
"Production Info",
"configurationMetadata"))
2094 self.pythonCfgCode +=
"\n"
2095 for comment,object
in self.addedObjects:
2097 self.pythonCfgCode +=
"\n# "+comment+
"\n"
2098 self.pythonCfgCode +=
dumpPython(self.process,object)
2101 self.pythonCfgCode +=
"\n# Output definition\n"
2102 self.pythonCfgCode += outputModuleCfgCode
2105 self.pythonCfgCode +=
"\n# Additional output definition\n"
2107 nl=self.additionalOutputs.keys()
2110 output = self.additionalOutputs[name]
2111 self.pythonCfgCode +=
"process.%s = %s" %(name, output.dumpPython())
2112 tmpOut = cms.EndPath(output)
2113 setattr(self.process,name+
'OutPath',tmpOut)
2114 self.schedule.append(tmpOut)
2117 self.pythonCfgCode +=
"\n# Other statements\n"
2118 for command
in self.additionalCommands:
2119 self.pythonCfgCode += command +
"\n"
2122 for object
in self._options.inlineObjets.split(
','):
2125 if not hasattr(self.process,object):
2126 print 'cannot inline -'+object+
'- : not known'
2128 self.pythonCfgCode +=
'\n'
2129 self.pythonCfgCode +=
dumpPython(self.process,object)
2132 self.pythonCfgCode +=
"\n# Path and EndPath definitions\n"
2133 for path
in self.process.paths:
2134 if getattr(self.process,path)
not in self.blacklist_paths:
2135 self.pythonCfgCode +=
dumpPython(self.process,path)
2137 for endpath
in self.process.endpaths:
2138 if getattr(self.process,endpath)
not in self.blacklist_paths:
2139 self.pythonCfgCode +=
dumpPython(self.process,endpath)
2142 self.pythonCfgCode +=
"\n# Schedule definition\n"
2143 result =
"process.schedule = cms.Schedule("
2146 self.process.schedule = cms.Schedule()
2147 for item
in self.schedule:
2148 if not isinstance(item, cms.Schedule):
2149 self.process.schedule.append(item)
2151 self.process.schedule.extend(item)
2153 if hasattr(self.process,
"HLTSchedule"):
2154 beforeHLT = self.schedule[:self.schedule.index(self.process.HLTSchedule)]
2155 afterHLT = self.schedule[self.schedule.index(self.process.HLTSchedule)+1:]
2156 pathNames = [
'process.'+p.label_()
for p
in beforeHLT]
2157 result +=
','.
join(pathNames)+
')\n'
2158 result +=
'process.schedule.extend(process.HLTSchedule)\n'
2159 pathNames = [
'process.'+p.label_()
for p
in afterHLT]
2160 result +=
'process.schedule.extend(['+
','.
join(pathNames)+
'])\n'
2162 pathNames = [
'process.'+p.label_()
for p
in self.schedule]
2163 result =
'process.schedule = cms.Schedule('+
','.
join(pathNames)+
')\n'
2165 self.pythonCfgCode += result
2167 if self._options.nThreads
is not "1":
2168 self.pythonCfgCode +=
"\n"
2169 self.pythonCfgCode +=
"#Setup FWK for multithreaded\n"
2170 self.pythonCfgCode +=
"process.options.numberOfThreads=cms.untracked.uint32("+self._options.nThreads+
")\n"
2171 self.pythonCfgCode +=
"process.options.numberOfStreams=cms.untracked.uint32(0)\n"
2173 if self._options.isRepacked:
2174 self.pythonCfgCode +=
"\n"
2175 self.pythonCfgCode +=
"from Configuration.Applications.ConfigBuilder import MassReplaceInputTag\n"
2176 self.pythonCfgCode +=
"MassReplaceInputTag(process)\n"
2180 if self.productionFilterSequence:
2181 self.pythonCfgCode +=
'# filter all path with the production filter sequence\n'
2182 self.pythonCfgCode +=
'for path in process.paths:\n'
2183 if len(self.conditionalPaths):
2184 self.pythonCfgCode +=
'\tif not path in %s: continue\n'%str(self.conditionalPaths)
2185 if len(self.excludedPaths):
2186 self.pythonCfgCode +=
'\tif path in %s: continue\n'%str(self.excludedPaths)
2187 self.pythonCfgCode +=
'\tgetattr(process,path)._seq = process.%s * getattr(process,path)._seq \n'%(self.productionFilterSequence,)
2188 pfs = getattr(self.process,self.productionFilterSequence)
2189 for path
in self.process.paths:
2190 if not path
in self.conditionalPaths:
continue
2191 if path
in self.excludedPaths:
continue
2192 getattr(self.process,path)._seq = pfs * getattr(self.process,path)._seq
2198 if self._options.runUnscheduled:
2201 self.pythonCfgCode+=
"#do not add changes to your config after this point (unless you know what you are doing)\n"
2202 self.pythonCfgCode+=
"from FWCore.ParameterSet.Utilities import convertToUnscheduled\n"
2203 self.pythonCfgCode+=
"process=convertToUnscheduled(process)\n"
2205 from FWCore.ParameterSet.Utilities
import convertToUnscheduled
2209 for module
in self.importsUnsch:
2210 self.process.load(module)
2211 self.pythonCfgCode += (
"process.load('"+module+
"')\n")
2214 self.pythonCfgCode+=
"from FWCore.ParameterSet.Utilities import cleanUnscheduled\n"
2215 self.pythonCfgCode+=
"process=cleanUnscheduled(process)\n"
2217 from FWCore.ParameterSet.Utilities
import cleanUnscheduled
2226 if self._options.io:
2228 if not self._options.io.endswith(
'.io'): self._option.io+=
'.io'
2229 io=open(self._options.io,
'w')
2231 if hasattr(self.process.source,
"fileNames"):
2232 if len(self.process.source.fileNames.value()):
2233 ioJson[
'primary']=self.process.source.fileNames.value()
2234 if hasattr(self.process.source,
"secondaryFileNames"):
2235 if len(self.process.source.secondaryFileNames.value()):
2236 ioJson[
'secondary']=self.process.source.secondaryFileNames.value()
2237 if self._options.pileup_input
and (self._options.pileup_input.startswith(
'dbs:')
or self._options.pileup_input.startswith(
'das:')):
2238 ioJson[
'pileup']=self._options.pileup_input[4:]
2239 for (o,om)
in self.process.outputModules_().items():
2240 ioJson[o]=om.fileName.value()
2241 ioJson[
'GT']=self.process.GlobalTag.globaltag.value()
2242 if self.productionFilterSequence:
2243 ioJson[
'filter']=self.productionFilterSequence
2245 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