3 __version__ =
"$Revision: 1.19 $"
4 __source__ =
"$Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v $"
6 import FWCore.ParameterSet.Config
as cms
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.pileup_dasoption =
''
25 defaultOptions.geometry =
'SimDB'
26 defaultOptions.geometryExtendedOptions = [
'ExtendedGFlash',
'Extended',
'NoCastor']
27 defaultOptions.magField =
''
28 defaultOptions.conditions =
None
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.dasoption=
""
40 defaultOptions.secondfilein =
""
41 defaultOptions.customisation_file = []
42 defaultOptions.customisation_file_unsch = []
43 defaultOptions.customise_commands =
""
44 defaultOptions.inline_custom=
False
45 defaultOptions.particleTable =
'pythiapdt'
46 defaultOptions.particleTableList = [
'pythiapdt',
'pdt']
47 defaultOptions.dirin =
''
48 defaultOptions.dirout =
''
49 defaultOptions.filetype =
'EDM'
50 defaultOptions.fileout =
'output.root'
51 defaultOptions.filtername =
''
52 defaultOptions.lazy_download =
False
53 defaultOptions.custom_conditions =
''
54 defaultOptions.hltProcess =
''
55 defaultOptions.eventcontent =
None
56 defaultOptions.datatier =
None
57 defaultOptions.inlineEventContent =
True
58 defaultOptions.inlineObjets =
''
59 defaultOptions.hideGen=
False
60 from Configuration.StandardSequences.VtxSmeared
import VtxSmearedDefaultKey,VtxSmearedHIDefaultKey
61 defaultOptions.beamspot=
None
62 defaultOptions.outputDefinition =
''
63 defaultOptions.inputCommands =
None
64 defaultOptions.outputCommands =
None
65 defaultOptions.inputEventContent =
''
66 defaultOptions.dropDescendant =
False
67 defaultOptions.relval =
None
68 defaultOptions.slhc =
None
69 defaultOptions.profile =
None
70 defaultOptions.isRepacked =
False
71 defaultOptions.restoreRNDSeeds =
False
72 defaultOptions.donotDropOnInput =
''
73 defaultOptions.python_filename =
''
74 defaultOptions.io=
None
75 defaultOptions.lumiToProcess=
None
76 defaultOptions.fast=
False
77 defaultOptions.runsAndWeightsForMC =
None
78 defaultOptions.runsScenarioForMC =
None
79 defaultOptions.runUnscheduled =
False
80 defaultOptions.timeoutOutput =
False
81 defaultOptions.nThreads =
'1'
85 theObject = getattr(process,name)
86 if isinstance(theObject,cms.Path)
or isinstance(theObject,cms.EndPath)
or isinstance(theObject,cms.Sequence):
87 return "process."+name+
" = " + theObject.dumpPython(
"process")
88 elif isinstance(theObject,_Module)
or isinstance(theObject,cms.ESProducer):
89 return "process."+name+
" = " + theObject.dumpPython()+
"\n"
91 return "process."+name+
" = " + theObject.dumpPython()+
"\n"
94 import FWCore.ParameterSet.Config
as cms
97 for line
in open(fileName,
'r'):
98 if line.count(
".root")>=2:
100 entries=line.replace(
"\n",
"").
split()
101 if not entries[0]
in prim:
102 prim.append(entries[0])
103 if not entries[1]
in sec:
104 sec.append(entries[1])
105 elif (line.find(
".root")!=-1):
106 entry=line.replace(
"\n",
"")
107 if not entry
in prim:
110 if not hasattr(s,
"fileNames"):
111 s.fileNames=cms.untracked.vstring(prim)
113 s.fileNames.extend(prim)
115 if not hasattr(s,
"secondaryFileNames"):
116 s.secondaryFileNames=cms.untracked.vstring(sec)
118 s.secondaryFileNames.extend(sec)
119 print "found files: ",prim
121 raise Exception(
"There are not files in input from the file list")
123 print "found parent files:",sec
128 import FWCore.ParameterSet.Config
as cms
131 print "the query is",query
134 while eC!=0
and count<3:
136 print 'Sleeping, then retrying DAS'
138 p = Popen(
'das_client %s --query "%s"'%(option,query), stdout=PIPE,shell=
True)
140 tupleP = os.waitpid(p.pid, 0)
144 print "DAS succeeded after",count,
"attempts",eC
146 print "DAS failed 3 times- I give up"
147 for line
in pipe.split(
'\n'):
148 if line.count(
".root")>=2:
150 entries=line.replace(
"\n",
"").
split()
151 if not entries[0]
in prim:
152 prim.append(entries[0])
153 if not entries[1]
in sec:
154 sec.append(entries[1])
155 elif (line.find(
".root")!=-1):
156 entry=line.replace(
"\n",
"")
157 if not entry
in prim:
160 if not hasattr(s,
"fileNames"):
161 s.fileNames=cms.untracked.vstring(prim)
163 s.fileNames.extend(prim)
165 if not hasattr(s,
"secondaryFileNames"):
166 s.secondaryFileNames=cms.untracked.vstring(sec)
168 s.secondaryFileNames.extend(sec)
169 print "found files: ",prim
171 print "found parent files:",sec
176 for s
in aProcess.paths_().
keys():
179 def anyOf(listOfKeys,dict,opt=None):
188 raise Exception(
"any of "+
','.
join(listOfKeys)+
" are mandatory entries of --output options")
191 """The main building routines """
193 def __init__(self, options, process = None, with_output = False, with_input = False ):
194 """options taken from old cmsDriver and optparse """
196 options.outfile_name = options.dirout+options.fileout
200 if self._options.isData
and options.isMC:
201 raise Exception(
"ERROR: You may specify only --data or --mc, not both")
206 if 'ENDJOB' in self._options.step:
207 if (hasattr(self.
_options,
"outputDefinition")
and \
208 self._options.outputDefinition !=
'' and \
209 any(
anyOf([
't',
'tier',
'dataTier'],outdic) ==
'DQMIO' for outdic
in eval(self._options.outputDefinition)))
or \
210 (hasattr(self.
_options,
"datatier")
and \
211 self._options.datatier
and \
212 'DQMIO' in self._options.datatier):
213 print "removing ENDJOB from steps since not compatible with DQMIO dataTier"
214 self._options.step=self._options.step.replace(
',ENDJOB',
'')
219 stepList = [re.sub(
r'^prepare_',
'', methodName)
for methodName
in ConfigBuilder.__dict__
if methodName.startswith(
'prepare_')]
222 for step
in self._options.step.split(
","):
223 if step==
'':
continue
224 stepParts = step.split(
":")
225 stepName = stepParts[0]
226 if stepName
not in stepList
and not stepName.startswith(
're'):
227 raise ValueError(
"Step "+stepName+
" unknown")
228 if len(stepParts)==1:
229 self.stepMap[stepName]=
""
230 elif len(stepParts)==2:
231 self.stepMap[stepName]=stepParts[1].
split(
'+')
232 elif len(stepParts)==3:
233 self.stepMap[stepName]=(stepParts[2].
split(
'+'),stepParts[1])
235 raise ValueError(
"Step definition "+step+
" invalid")
236 self.stepKeys.append(stepName)
240 self.with_output = with_output
241 if hasattr(self.
_options,
"no_output_flag")
and self._options.no_output_flag:
242 self.with_output =
False
243 self.with_input = with_input
245 self.process = cms.Process(self._options.name)
247 self.process = process
249 self.importsUnsch = []
251 self.schedule =
list()
257 self.additionalCommands = []
259 self.blacklist_paths = []
260 self.addedObjects = []
261 self.additionalOutputs = {}
263 self.productionFilterSequence =
None
264 self.nextScheduleIsConditional=
False
265 self.conditionalPaths=[]
266 self.excludedPaths=[]
271 Function to add the igprof profile service so that you can dump in the middle
274 profileOpts = self._options.profile.split(
':')
276 profilerInterval = 100
277 profilerFormat =
None
278 profilerJobFormat =
None
284 startEvent = profileOpts.pop(0)
285 if not startEvent.isdigit():
286 raise Exception(
"%s is not a number" % startEvent)
287 profilerStart = int(startEvent)
289 eventInterval = profileOpts.pop(0)
290 if not eventInterval.isdigit():
291 raise Exception(
"%s is not a number" % eventInterval)
292 profilerInterval = int(eventInterval)
294 profilerFormat = profileOpts.pop(0)
297 if not profilerFormat:
298 profilerFormat =
"%s___%s___%s___%s___%s___%s___%%I.gz" % (self._options.evt_type.replace(
"_cfi",
""),
300 self._options.pileup,
301 self._options.conditions,
302 self._options.datatier,
303 self._options.profileTypeLabel)
304 if not profilerJobFormat
and profilerFormat.endswith(
".gz"):
305 profilerJobFormat = profilerFormat.replace(
".gz",
"_EndOfJob.gz")
306 elif not profilerJobFormat:
307 profilerJobFormat = profilerFormat +
"_EndOfJob.gz"
309 return (profilerStart,profilerInterval,profilerFormat,profilerJobFormat)
312 includeFile = includeFile.replace(
'/',
'.')
313 self.process.load(includeFile)
314 return sys.modules[includeFile]
317 """helper routine to load am memorize imports"""
320 includeFile = includeFile.replace(
'/',
'.')
322 self.imports.append(includeFile)
323 self.process.load(includeFile)
324 return sys.modules[includeFile]
326 self.importsUnsch.append(includeFile)
330 """helper routine to remember replace statements"""
331 self.additionalCommands.append(command)
332 if not command.strip().startswith(
"#"):
335 exec(re.sub(
r"([^a-zA-Z_0-9]|^)(process)([^a-zA-Z_0-9])",
r"\1self.process\3",command))
339 if 'HARVESTING' in self.stepMap.keys()
or 'ALCAHARVEST' in self.stepMap.keys():
340 self.process.options = cms.untracked.PSet( Rethrow = cms.untracked.vstring(
'ProductNotFound'),fileMode = cms.untracked.string(
'FULLMERGE'))
342 self.process.options = cms.untracked.PSet( )
344 if self._options.runUnscheduled:
345 self.process.options.allowUnscheduled=cms.untracked.bool(
True)
347 self.addedObjects.append((
"",
"options"))
349 if self._options.lazy_download:
350 self.process.AdaptorConfig = cms.Service(
"AdaptorConfig",
351 stats = cms.untracked.bool(
True),
352 enable = cms.untracked.bool(
True),
353 cacheHint = cms.untracked.string(
"lazy-download"),
354 readHint = cms.untracked.string(
"read-ahead-buffered")
356 self.addedObjects.append((
"Setup lazy download",
"AdaptorConfig"))
361 if self._options.profile:
363 self.process.IgProfService = cms.Service(
"IgProfService",
364 reportFirstEvent = cms.untracked.int32(start),
365 reportEventInterval = cms.untracked.int32(interval),
366 reportToFileAtPostEvent = cms.untracked.string(
"| gzip -c > %s"%(eventFormat)),
367 reportToFileAtPostEndJob = cms.untracked.string(
"| gzip -c > %s"%(jobFormat)))
368 self.addedObjects.append((
"Setup IGProf Service for profiling",
"IgProfService"))
371 """Here we decide how many evts will be processed"""
372 self.process.maxEvents=cms.untracked.PSet(input=cms.untracked.int32(int(self._options.number)))
373 if self._options.number_out:
374 self.process.maxEvents.output = cms.untracked.int32(int(self._options.number_out))
375 self.addedObjects.append((
"",
"maxEvents"))
378 """Here the source is built. Priority: file, generator"""
379 self.addedObjects.append((
"Input source",
"source"))
382 for entry
in self._options.filein.split(
','):
384 if entry.startswith(
"filelist:"):
386 elif entry.startswith(
"dbs:")
or entry.startswith(
"das:"):
387 filesFromDASQuery(
'file dataset = %s'%(entry[4:]),self._options.dasoption,self.process.source)
389 self.process.source.fileNames.append(self._options.dirin+entry)
390 if self._options.secondfilein:
391 if not hasattr(self.process.source,
"secondaryFileNames"):
392 raise Exception(
"--secondfilein not compatible with "+self._options.filetype+
"input type")
393 for entry
in self._options.secondfilein.split(
','):
395 if entry.startswith(
"filelist:"):
396 self.process.source.secondaryFileNames.extend((
filesFromList(entry[9:]))[0])
397 elif entry.startswith(
"dbs:")
or entry.startswith(
"das:"):
398 self.process.source.secondaryFileNames.extend((
filesFromDASQuery(
'file dataset = %s'%(entry[4:]),self._options.dasoption))[0])
400 self.process.source.secondaryFileNames.append(self._options.dirin+entry)
402 if self._options.filein
or self._options.dasquery:
403 if self._options.filetype ==
"EDM":
404 self.process.source=cms.Source(
"PoolSource",
405 fileNames = cms.untracked.vstring(),
406 secondaryFileNames= cms.untracked.vstring())
408 elif self._options.filetype ==
"DAT":
409 self.process.source=cms.Source(
"NewEventStreamFileReader",fileNames = cms.untracked.vstring())
411 elif self._options.filetype ==
"LHE":
412 self.process.source=cms.Source(
"LHESource", fileNames = cms.untracked.vstring())
413 if self._options.filein.startswith(
"lhe:"):
415 args=self._options.filein.split(
':')
417 print 'LHE input from article ',article
418 location=
'/store/lhe/'
420 textOfFiles=os.popen(
'cmsLHEtoEOSManager.py -l '+article)
421 for line
in textOfFiles:
422 for fileName
in [x
for x
in line.split()
if '.lhe' in x]:
423 self.process.source.fileNames.append(location+article+
'/'+fileName)
425 self.process.source.skipEvents = cms.untracked.uint32(int(args[2]))
430 elif self._options.filetype ==
"DQM":
431 self.process.source=cms.Source(
"DQMRootSource",
432 fileNames = cms.untracked.vstring())
435 elif self._options.filetype ==
"DQMDAQ":
437 self.process.source=cms.Source(
"DQMStreamerReader")
440 if (
'HARVESTING' in self.stepMap.keys()
or 'ALCAHARVEST' in self.stepMap.keys())
and (
not self._options.filetype ==
"DQM"):
441 self.process.source.processingMode = cms.untracked.string(
"RunsAndLumis")
443 if self._options.dasquery!=
'':
444 self.process.source=cms.Source(
"PoolSource", fileNames = cms.untracked.vstring(),secondaryFileNames = cms.untracked.vstring())
445 filesFromDASQuery(self._options.dasquery,self._options.dasoption,self.process.source)
448 if 'GEN' in self.stepMap.keys():
449 if self._options.inputCommands:
450 self._options.inputCommands+=
',drop LHEXMLStringProduct_*_*_*,'
452 self._options.inputCommands=
'keep *, drop LHEXMLStringProduct_*_*_*,'
454 if self.process.source
and self._options.inputCommands:
455 if not hasattr(self.process.source,
'inputCommands'): self.process.source.inputCommands=cms.untracked.vstring()
456 for command
in self._options.inputCommands.split(
','):
458 command = command.strip()
459 if command==
'':
continue
460 self.process.source.inputCommands.append(command)
461 if not self._options.dropDescendant:
462 self.process.source.dropDescendantsOfDroppedBranches = cms.untracked.bool(
False)
464 if self._options.lumiToProcess:
465 import FWCore.PythonUtilities.LumiList
as LumiList
466 self.process.source.lumisToProcess = cms.untracked.VLuminosityBlockRange(
LumiList.LumiList(self._options.lumiToProcess).getCMSSWString().
split(
',') )
468 if 'GEN' in self.stepMap.keys()
or 'LHE' in self.stepMap
or (
not self._options.filein
and hasattr(self.
_options,
"evt_type")):
469 if self.process.source
is None:
470 self.process.source=cms.Source(
"EmptySource")
473 self.runsAndWeights=
None
474 if self._options.runsAndWeightsForMC
or self._options.runsScenarioForMC :
475 if not self._options.isMC :
476 raise Exception(
"options --runsAndWeightsForMC and --runsScenarioForMC are only valid for MC")
477 if self._options.runsAndWeightsForMC:
478 self.runsAndWeights = eval(self._options.runsAndWeightsForMC)
480 from Configuration.StandardSequences.RunsAndWeights
import RunsAndWeights
481 if type(RunsAndWeights[self._options.runsScenarioForMC])==str:
482 __import__(RunsAndWeights[self._options.runsScenarioForMC])
483 self.runsAndWeights = sys.modules[RunsAndWeights[self._options.runsScenarioForMC]].runProbabilityDistribution
485 self.runsAndWeights = RunsAndWeights[self._options.runsScenarioForMC]
487 if self.runsAndWeights:
488 import SimGeneral.Configuration.ThrowAndSetRandomRun
as ThrowAndSetRandomRun
490 self.additionalCommands.append(
'import SimGeneral.Configuration.ThrowAndSetRandomRun as ThrowAndSetRandomRun')
491 self.additionalCommands.append(
'ThrowAndSetRandomRun.throwAndSetRandomRun(process.source,%s)'%(self.runsAndWeights))
496 """ Add output module to the process """
498 if self._options.outputDefinition:
499 if self._options.datatier:
500 print "--datatier & --eventcontent options ignored"
503 outList = eval(self._options.outputDefinition)
504 for (id,outDefDict)
in enumerate(outList):
505 outDefDictStr=outDefDict.__str__()
506 if not isinstance(outDefDict,dict):
507 raise Exception(
"--output needs to be passed a list of dict"+self._options.outputDefinition+
" is invalid")
509 theTier=
anyOf([
't',
'tier',
'dataTier'],outDefDict)
512 theStreamType=
anyOf([
'e',
'ec',
'eventContent',
'streamType'],outDefDict,theTier)
513 theFilterName=
anyOf([
'f',
'ftN',
'filterName'],outDefDict,
'')
514 theSelectEvent=
anyOf([
's',
'sE',
'selectEvents'],outDefDict,
'')
515 theModuleLabel=
anyOf([
'l',
'mL',
'moduleLabel'],outDefDict,
'')
516 theExtraOutputCommands=
anyOf([
'o',
'oC',
'outputCommands'],outDefDict,
'')
518 if not theModuleLabel:
519 tryNames=[theStreamType.replace(theTier.replace(
'-',
''),
'')+theTier.replace(
'-',
'')+
'output',
520 theStreamType.replace(theTier.replace(
'-',
''),
'')+theTier.replace(
'-',
'')+theFilterName+
'output',
521 theStreamType.replace(theTier.replace(
'-',
''),
'')+theTier.replace(
'-',
'')+theFilterName+theSelectEvent.split(
',')[0].
replace(
':',
'for').
replace(
' ',
'')+
'output'
523 for name
in tryNames:
524 if not hasattr(self.process,name):
527 if not theModuleLabel:
528 raise Exception(
"cannot find a module label for specification: "+outDefDictStr)
530 defaultFileName=self._options.outfile_name
532 defaultFileName=self._options.outfile_name.replace(
'.root',
'_in'+theTier+
'.root')
534 theFileName=self._options.dirout+
anyOf([
'fn',
'fileName'],outDefDict,defaultFileName)
535 if not theFileName.endswith(
'.root'):
538 if len(outDefDict.keys()):
539 raise Exception(
"unused keys from --output options: "+
','.
join(outDefDict.keys()))
540 if theStreamType==
'DQMIO': theStreamType=
'DQM'
541 if theStreamType==
'ALL':
542 theEventContent = cms.PSet(outputCommands = cms.untracked.vstring(
'keep *'))
544 theEventContent = getattr(self.process, theStreamType+
"EventContent")
548 if theStreamType==
'ALCARECO' and not theFilterName:
549 theFilterName=
'StreamALCACombined'
552 CppType=
'PoolOutputModule'
553 if self._options.timeoutOutput:
554 CppType=
'TimeoutPoolOutputModule'
555 if theStreamType==
'DQM' and theTier==
'DQMIO': CppType=
'DQMRootOutputModule'
556 output = cms.OutputModule(CppType,
557 theEventContent.clone(),
558 fileName = cms.untracked.string(theFileName),
559 dataset = cms.untracked.PSet(
560 dataTier = cms.untracked.string(theTier),
561 filterName = cms.untracked.string(theFilterName))
563 if not theSelectEvent
and hasattr(self.process,
'generation_step')
and theStreamType!=
'LHE':
564 output.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
'generation_step'))
565 if not theSelectEvent
and hasattr(self.process,
'filtering_step'):
566 output.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
'filtering_step'))
568 output.SelectEvents =cms.untracked.PSet(SelectEvents = cms.vstring(theSelectEvent))
571 if not hasattr(output,
'SelectEvents'):
572 output.SelectEvents=cms.untracked.PSet(SelectEvents=cms.vstring())
573 for alca
in self.AlCaPaths:
574 output.SelectEvents.SelectEvents.extend(getattr(self.process,
'OutALCARECO'+alca).SelectEvents.SelectEvents)
577 if hasattr(self.process,theModuleLabel):
578 raise Exception(
"the current process already has a module "+theModuleLabel+
" defined")
580 setattr(self.process,theModuleLabel,output)
581 outputModule=getattr(self.process,theModuleLabel)
582 setattr(self.process,theModuleLabel+
'_step',cms.EndPath(outputModule))
583 path=getattr(self.process,theModuleLabel+
'_step')
584 self.schedule.append(path)
586 if not self._options.inlineEventContent
and hasattr(self.process,theStreamType+
"EventContent"):
589 outputModule.outputCommands.__dict__[
"dumpPython"] = doNotInlineEventContent
590 if theExtraOutputCommands:
591 if not isinstance(theExtraOutputCommands,list):
592 raise Exception(
"extra ouput command in --option must be a list of strings")
593 if hasattr(self.process,theStreamType+
"EventContent"):
594 self.
executeAndRemember(
'process.%s.outputCommands.extend(%s)'%(theModuleLabel,theExtraOutputCommands))
596 outputModule.outputCommands.extend(theExtraOutputCommands)
598 result+=
"\nprocess."+theModuleLabel+
" = "+outputModule.dumpPython()
603 streamTypes=self._options.eventcontent.split(
',')
604 tiers=self._options.datatier.split(
',')
605 if not self._options.outputDefinition
and len(streamTypes)!=len(tiers):
606 raise Exception(
"number of event content arguments does not match number of datatier arguments")
609 if self._options.step.split(
',')[0].
split(
':')[0] ==
'ALCA':
612 for i,(streamType,tier)
in enumerate(
zip(streamTypes,tiers)):
613 if streamType==
'':
continue
614 if streamType==
'DQMIO': streamType=
'DQM'
615 theEventContent = getattr(self.process, streamType+
"EventContent")
617 theFileName=self._options.outfile_name
618 theFilterName=self._options.filtername
620 theFileName=self._options.outfile_name.replace(
'.root',
'_in'+streamType+
'.root')
621 theFilterName=self._options.filtername
622 CppType=
'PoolOutputModule'
623 if self._options.timeoutOutput:
624 CppType=
'TimeoutPoolOutputModule'
625 if streamType==
'DQM' and tier==
'DQMIO': CppType=
'DQMRootOutputModule'
626 output = cms.OutputModule(CppType,
628 fileName = cms.untracked.string(theFileName),
629 dataset = cms.untracked.PSet(dataTier = cms.untracked.string(tier),
630 filterName = cms.untracked.string(theFilterName)
633 if hasattr(self.process,
"generation_step")
and streamType!=
'LHE':
634 output.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
'generation_step'))
635 if hasattr(self.process,
"filtering_step"):
636 output.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring(
'filtering_step'))
638 if streamType==
'ALCARECO':
639 output.dataset.filterName = cms.untracked.string(
'StreamALCACombined')
641 if "MINIAOD" in streamType:
642 output.dropMetaData = cms.untracked.string(
'ALL')
643 output.fastCloning= cms.untracked.bool(
False)
644 output.overrideInputFileSplitLevels = cms.untracked.bool(
True)
646 outputModuleName=streamType+
'output'
647 setattr(self.process,outputModuleName,output)
648 outputModule=getattr(self.process,outputModuleName)
649 setattr(self.process,outputModuleName+
'_step',cms.EndPath(outputModule))
650 path=getattr(self.process,outputModuleName+
'_step')
651 self.schedule.append(path)
653 if self._options.outputCommands
and streamType!=
'DQM':
654 for evct
in self._options.outputCommands.split(
','):
655 if not evct:
continue
656 self.
executeAndRemember(
"process.%s.outputCommands.append('%s')"%(outputModuleName,evct.strip()))
658 if not self._options.inlineEventContent:
661 outputModule.outputCommands.__dict__[
"dumpPython"] = doNotInlineEventContent
663 result+=
"\nprocess."+outputModuleName+
" = "+outputModule.dumpPython()
669 Add selected standard sequences to the process
672 if self._options.pileup:
673 pileupSpec=self._options.pileup.split(
',')[0]
676 from Configuration.StandardSequences.Mixing
import Mixing,defineMixing
677 if not pileupSpec
in Mixing
and '.' not in pileupSpec
and 'file:' not in pileupSpec:
678 message = pileupSpec+
' is not a know mixing scenario:\n available are: '+
'\n'.
join(Mixing.keys())
682 if '.' in pileupSpec:
683 mixingDict={
'file':pileupSpec}
684 elif pileupSpec.startswith(
'file:'):
685 mixingDict={
'file':pileupSpec[5:]}
688 mixingDict=copy.copy(Mixing[pileupSpec])
689 if len(self._options.pileup.split(
','))>1:
690 mixingDict.update(eval(self._options.pileup[self._options.pileup.find(
',')+1:]))
693 if 'file:' in pileupSpec:
695 self.process.load(mixingDict[
'file'])
696 print "inlining mixing module configuration"
697 self._options.inlineObjets+=
',mix'
701 mixingDict.pop(
'file')
702 if not "DATAMIX" in self.stepMap.keys():
703 if self._options.pileup_input:
704 if self._options.pileup_input.startswith(
'dbs:')
or self._options.pileup_input.startswith(
'das:'):
705 mixingDict[
'F']=
filesFromDASQuery(
'file dataset = %s'%(self._options.pileup_input[4:],),self._options.pileup_dasoption)[0]
707 mixingDict[
'F']=self._options.pileup_input.split(
',')
709 for command
in specialization:
711 if len(mixingDict)!=0:
712 raise Exception(
'unused mixing specification: '+mixingDict.keys().
__str__())
717 if len(self.stepMap):
719 if (
'SIM' in self.stepMap
or 'reSIM' in self.stepMap)
and not self._options.fast:
721 if self.geometryDBLabel:
722 self.
executeAndRemember(
'process.XMLFromDBSource.label = cms.string("%s")'%(self.geometryDBLabel))
724 print "Geometry option",self._options.geometry,
"unknown."
727 if len(self.stepMap):
730 for stepName
in self.stepKeys:
731 stepSpec = self.stepMap[stepName]
732 print "Step:", stepName,
"Spec:",stepSpec
733 if stepName.startswith(
're'):
735 if stepName[2:]
not in self._options.donotDropOnInput:
736 self._options.inputEventContent=
'%s,%s'%(stepName.upper(),self._options.inputEventContent)
737 stepName=stepName[2:]
739 getattr(self,
"prepare_"+stepName)(sequence = getattr(self,stepName+
"DefaultSeq"))
740 elif type(stepSpec)==list:
741 getattr(self,
"prepare_"+stepName)(sequence =
'+'.
join(stepSpec))
742 elif type(stepSpec)==tuple:
743 getattr(self,
"prepare_"+stepName)(sequence =
','.
join([stepSpec[1],
'+'.
join(stepSpec[0])]))
745 raise ValueError(
"Invalid step definition")
747 if self._options.restoreRNDSeeds!=
False:
749 if self._options.restoreRNDSeeds==
True:
750 self.
executeAndRemember(
'process.RandomNumberGeneratorService.restoreStateLabel=cms.untracked.string("randomEngineStateProducer")')
752 self.
executeAndRemember(
'process.RandomNumberGeneratorService.restoreStateTag=cms.untracked.InputTag("randomEngineStateProducer","","%s")'%(self._options.restoreRNDSeeds))
753 if self._options.inputEventContent
or self._options.inputCommands:
754 if self._options.inputCommands:
755 self._options.inputCommands+=
'keep *_randomEngineStateProducer_*_*,'
757 self._options.inputCommands=
'keep *_randomEngineStateProducer_*_*,'
761 if self._options.inputEventContent:
763 def dropSecondDropStar(iec):
774 if not hasattr(self.process.source,
'inputCommands'): self.process.source.inputCommands=cms.untracked.vstring()
775 for evct
in self._options.inputEventContent.split(
','):
776 if evct==
'':
continue
777 theEventContent = getattr(self.process, evct+
"EventContent")
778 if hasattr(theEventContent,
'outputCommands'):
779 self.process.source.inputCommands.extend(copy.copy(theEventContent.outputCommands))
780 if hasattr(theEventContent,
'inputCommands'):
781 self.process.source.inputCommands.extend(copy.copy(theEventContent.inputCommands))
783 dropSecondDropStar(self.process.source.inputCommands)
785 if not self._options.dropDescendant:
786 self.process.source.dropDescendantsOfDroppedBranches = cms.untracked.bool(
False)
792 """Add conditions to the process"""
793 if not self._options.conditions:
return
795 if 'FrontierConditions_GlobalTag' in self._options.conditions:
796 print 'using FrontierConditions_GlobalTag in --conditions is not necessary anymore and will be deprecated soon. please update your command line'
797 self._options.conditions = self._options.conditions.replace(
"FrontierConditions_GlobalTag,",
'')
799 self.loadAndRemember(self.ConditionsDefaultCFF)
801 self.process.GlobalTag =
GlobalTag(self.process.GlobalTag, self._options.conditions, self._options.custom_conditions)
802 self.additionalCommands.append(
'from Configuration.AlCa.GlobalTag import GlobalTag')
803 self.additionalCommands.append(
'process.GlobalTag = GlobalTag(process.GlobalTag, %s, %s)' % (repr(self._options.conditions), repr(self._options.custom_conditions)))
805 if self._options.slhc:
806 self.loadAndRemember(
"SLHCUpgradeSimulations/Geometry/fakeConditions_%s_cff"%(self._options.slhc,))
810 """Include the customise code """
814 for c
in self._options.customisation_file:
815 custOpt.extend(c.split(
","))
817 for c
in self._options.customisation_file_unsch:
818 custOpt.extend(c.split(
","))
824 raise Exception(
"more than . in the specification:"+opt)
825 fileName=opt.split(
'.')[0]
826 if opt.count(
'.')==0: rest=
'customise'
828 rest=opt.split(
'.')[1]
829 if rest==
'py': rest=
'customise'
831 if fileName
in custMap:
832 custMap[fileName].extend(rest.split(
'+'))
834 custMap[fileName]=rest.split(
'+')
839 final_snippet=
'\n# customisation of the process.\n'
843 allFcn.extend(custMap[opt])
845 if allFcn.count(fcn)!=1:
846 raise Exception(
"cannot specify twice "+fcn+
" as a customisation method")
850 packageName = f.replace(
".py",
"").
replace(
"/",
".")
851 __import__(packageName)
852 package = sys.modules[packageName]
855 customiseFile = re.sub(
r'\.pyc$',
'.py', package.__file__)
857 final_snippet+=
'\n# Automatic addition of the customisation function from '+packageName+
'\n'
858 if self._options.inline_custom:
859 for line
in file(customiseFile,
'r'):
860 if "import FWCore.ParameterSet.Config" in line:
862 final_snippet += line
864 final_snippet +=
'from %s import %s \n'%(packageName,
','.
join(custMap[f]))
865 for fcn
in custMap[f]:
866 print "customising the process with",fcn,
"from",f
867 if not hasattr(package,fcn):
869 raise Exception(
"config "+f+
" has no function "+fcn)
871 self.process=getattr(package,fcn)(self.process)
873 final_snippet +=
"\n#call to customisation function "+fcn+
" imported from "+packageName
874 final_snippet +=
"\nprocess = %s(process)\n"%(fcn,)
877 final_snippet +=
'\n# End of customisation functions\n'
880 if unsch==1
or not self._options.runUnscheduled:
881 if self._options.customise_commands:
883 final_snippet +=
'\n# Customisation from command line'
884 for com
in self._options.customise_commands.split(
'\\n'):
885 com=string.lstrip(com)
887 final_snippet +=
'\n'+com
896 if len(self.stepMap):
898 if self._options.particleTable
not in defaultOptions.particleTableList:
899 print 'Invalid particle table provided. Options are:'
900 print defaultOptions.particleTable
903 if len(self.stepMap):
904 self.
loadAndRemember(
'SimGeneral.HepPDTESSource.'+self._options.particleTable+
'_cfi')
921 self.EIDefaultCFF=
None
922 self.SKIMDefaultCFF=
"Configuration/StandardSequences/Skims_cff"
923 self.POSTRECODefaultCFF=
"Configuration/StandardSequences/PostRecoGenerator_cff"
924 self.VALIDATIONDefaultCFF=
"Configuration/StandardSequences/Validation_cff"
925 self.L1HwValDefaultCFF =
"Configuration/StandardSequences/L1HwVal_cff"
926 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOffline_cff"
927 self.HARVESTINGDefaultCFF=
"Configuration/StandardSequences/Harvesting_cff"
928 self.ALCAHARVESTDefaultCFF=
"Configuration/StandardSequences/AlCaHarvesting_cff"
929 self.ENDJOBDefaultCFF=
"Configuration/StandardSequences/EndOfProcess_cff"
930 self.ConditionsDefaultCFF =
"Configuration/StandardSequences/FrontierConditions_GlobalTag_cff"
931 self.CFWRITERDefaultCFF =
"Configuration/StandardSequences/CrossingFrameWriter_cff"
932 self.REPACKDefaultCFF=
"Configuration/StandardSequences/DigiToRaw_Repack_cff"
934 if "DATAMIX" in self.stepMap.keys():
935 self.DATAMIXDefaultCFF=
"Configuration/StandardSequences/DataMixer"+self._options.datamix+
"_cff"
936 if self._options.datamix ==
'PreMix':
937 self.
DIGIDefaultCFF=
"Configuration/StandardSequences/DigiDMPreMix_cff"
941 self.
L1EMDefaultCFF=
'Configuration/StandardSequences/SimL1EmulatorDM_cff'
943 if "DIGIPREMIX" in self.stepMap.keys():
944 self.
DIGIDefaultCFF=
"Configuration/StandardSequences/Digi_PreMix_cff"
946 self.ALCADefaultSeq=
None
947 self.LHEDefaultSeq=
'externalLHEProducer'
948 self.GENDefaultSeq=
'pgen'
949 self.SIMDefaultSeq=
'psim'
950 self.DIGIDefaultSeq=
'pdigi'
951 self.DIGIPREMIXDefaultSeq=
'pdigi'
952 self.DIGIPREMIX_S2DefaultSeq=
'pdigi'
953 self.DATAMIXDefaultSeq=
None
954 self.DIGI2RAWDefaultSeq=
'DigiToRaw'
955 self.HLTDefaultSeq=
'GRun'
956 self.L1DefaultSeq=
None
957 self.L1REPACKDefaultSeq=
'GT'
958 self.HARVESTINGDefaultSeq=
None
959 self.ALCAHARVESTDefaultSeq=
None
960 self.CFWRITERDefaultSeq=
None
961 self.RAW2DIGIDefaultSeq=
'RawToDigi'
962 self.L1RecoDefaultSeq=
'L1Reco'
963 self.L1TrackTriggerDefaultSeq=
'L1TrackTrigger'
964 if self._options.fast
or (
'RAW2DIGI' in self.stepMap
and 'RECO' in self.stepMap):
965 self.RECODefaultSeq=
'reconstruction'
967 self.RECODefaultSeq=
'reconstruction_fromRECO'
969 self.EIDefaultSeq=
'top'
970 self.POSTRECODefaultSeq=
None
971 self.L1HwValDefaultSeq=
'L1HwVal'
972 self.DQMDefaultSeq=
'DQMOffline'
973 self.VALIDATIONDefaultSeq=
''
974 self.ENDJOBDefaultSeq=
'endOfProcess'
975 self.REPACKDefaultSeq=
'DigiToRawRepack'
976 self.PATDefaultSeq=
'miniAOD'
978 self.EVTCONTDefaultCFF=
"Configuration/EventContent/EventContent_cff"
980 if not self._options.beamspot:
981 self._options.beamspot=VtxSmearedDefaultKey
984 if self._options.isMC==
True:
986 self.
RECODefaultCFF=
"Configuration/StandardSequences/Reconstruction_cff"
987 self.
PATDefaultCFF=
"Configuration/StandardSequences/PATMC_cff"
988 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineMC_cff"
989 self.
ALCADefaultCFF=
"Configuration/StandardSequences/AlCaRecoStreamsMC_cff"
991 self._options.beamspot =
None
994 if 'reGEN' in self.stepMap:
995 self.GENDefaultSeq=
'fixGenInfo'
997 if self._options.scenario==
'cosmics':
998 self._options.pileup=
'Cosmics'
999 self.
DIGIDefaultCFF=
"Configuration/StandardSequences/DigiCosmics_cff"
1000 self.
RECODefaultCFF=
"Configuration/StandardSequences/ReconstructionCosmics_cff"
1001 self.SKIMDefaultCFF=
"Configuration/StandardSequences/SkimsCosmics_cff"
1002 self.EVTCONTDefaultCFF=
"Configuration/EventContent/EventContentCosmics_cff"
1003 self.VALIDATIONDefaultCFF=
"Configuration/StandardSequences/ValidationCosmics_cff"
1004 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineCosmics_cff"
1005 if self._options.isMC==
True:
1006 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineCosmicsMC_cff"
1007 self.HARVESTINGDefaultCFF=
"Configuration/StandardSequences/HarvestingCosmics_cff"
1008 self.RECODefaultSeq=
'reconstructionCosmics'
1009 self.DQMDefaultSeq=
'DQMOfflineCosmics'
1011 if self._options.scenario==
'HeavyIons':
1012 if not self._options.beamspot:
1013 self._options.beamspot=VtxSmearedHIDefaultKey
1014 self.HLTDefaultSeq =
'HIon'
1015 self.VALIDATIONDefaultCFF=
"Configuration/StandardSequences/ValidationHeavyIons_cff"
1016 self.VALIDATIONDefaultSeq=
''
1017 self.EVTCONTDefaultCFF=
"Configuration/EventContent/EventContentHeavyIons_cff"
1018 self.
RECODefaultCFF=
"Configuration/StandardSequences/ReconstructionHeavyIons_cff"
1019 self.RECODefaultSeq=
'reconstructionHeavyIons'
1020 self.
ALCADefaultCFF =
"Configuration/StandardSequences/AlCaRecoStreamsHeavyIons_cff"
1021 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineHeavyIons_cff"
1022 self.DQMDefaultSeq=
'DQMOfflineHeavyIons'
1023 self.SKIMDefaultCFF=
"Configuration/StandardSequences/SkimsHeavyIons_cff"
1024 self.HARVESTINGDefaultCFF=
"Configuration/StandardSequences/HarvestingHeavyIons_cff"
1025 if self._options.isMC==
True:
1026 self.DQMOFFLINEDefaultCFF=
"DQMOffline/Configuration/DQMOfflineHeavyIonsMC_cff"
1029 self.RAW2RECODefaultSeq=
','.
join([self.RAW2DIGIDefaultSeq,self.RECODefaultSeq])
1031 self.USERDefaultSeq=
'user'
1032 self.USERDefaultCFF=
None
1035 if self._options.isData:
1036 if self._options.magField==defaultOptions.magField:
1037 print "magnetic field option forced to: AutoFromDBCurrent"
1038 self._options.magField=
'AutoFromDBCurrent'
1039 self.magFieldCFF =
'Configuration/StandardSequences/MagneticField_'+self._options.magField.replace(
'.',
'')+
'_cff'
1040 self.magFieldCFF = self.magFieldCFF.replace(
"__",
'_')
1043 self.GeometryCFF=
'Configuration/StandardSequences/GeometryRecoDB_cff'
1044 self.geometryDBLabel=
None
1046 if self._options.fast:
1047 if 'start' in self._options.conditions.lower():
1048 self.GeometryCFF=
'FastSimulation/Configuration/Geometries_START_cff'
1050 self.GeometryCFF=
'FastSimulation/Configuration/Geometries_MC_cff'
1053 from Configuration.StandardSequences.GeometryConf
import GeometryConf
1054 if opt
in GeometryConf:
1055 return GeometryConf[opt]
1059 geoms=self._options.geometry.split(
',')
1063 if '/' in geoms[1]
or '_cff' in geoms[1]:
1064 self.GeometryCFF=geoms[1]
1066 self.GeometryCFF=
'Configuration/Geometry/Geometry'+geoms[1]+
'_cff'
1068 if (geoms[0].startswith(
'DB:')):
1069 self.SimGeometryCFF=
'Configuration/StandardSequences/GeometrySimDB_cff'
1070 self.geometryDBLabel=geoms[0][3:]
1073 if '/' in geoms[0]
or '_cff' in geoms[0]:
1074 self.SimGeometryCFF=geoms[0]
1076 simGeometry=geoms[0]
1077 if self._options.gflash==
True:
1078 self.SimGeometryCFF=
'Configuration/Geometry/Geometry'+geoms[0]+
'GFlash_cff'
1080 self.SimGeometryCFF=
'Configuration/Geometry/Geometry'+geoms[0]+
'_cff'
1083 if simGeometry
not in defaultOptions.geometryExtendedOptions:
1084 self.
SIMDefaultCFF=
"Configuration/StandardSequences/SimIdeal_cff"
1086 if self._options.scenario==
'nocoll' or self._options.scenario==
'cosmics':
1087 self.
SIMDefaultCFF=
"Configuration/StandardSequences/SimNOBEAM_cff"
1088 self._options.beamspot=
'NoSmear'
1091 if self._options.fast:
1092 self.
SIMDefaultCFF =
'FastSimulation.Configuration.SimIdeal_cff'
1093 self.
RECODefaultCFF=
'FastSimulation.Configuration.Reconstruction_AftMix_cff'
1094 self.RECOBEFMIXDefaultCFF =
'FastSimulation.Configuration.Reconstruction_BefMix_cff'
1095 self.RECOBEFMIXDefaultSeq =
'reconstruction_befmix'
1097 self.DQMOFFLINEDefaultCFF=
"FastSimulation.Configuration.DQMOfflineMC_cff"
1100 if self._options.pileup==
'default':
1101 from Configuration.StandardSequences.Mixing
import MixingDefaultKey
1102 self._options.pileup=MixingDefaultKey
1106 if self._options.isData:
1107 self._options.pileup=
None
1109 if self._options.slhc:
1110 self.GeometryCFF=
'SLHCUpgradeSimulations.Geometry.%s_cmsSimIdealGeometryXML_cff'%(self._options.slhc,)
1111 if 'stdgeom' not in self._options.slhc:
1112 self.SimGeometryCFF=
'SLHCUpgradeSimulations.Geometry.%s_cmsSimIdealGeometryXML_cff'%(self._options.slhc,)
1113 self.
DIGIDefaultCFF=
'SLHCUpgradeSimulations/Geometry/Digi_%s_cff'%(self._options.slhc,)
1114 if self._options.pileup!=defaultOptions.pileup:
1115 self._options.pileup=
'SLHC_%s_%s'%(self._options.pileup,self._options.slhc)
1117 self.REDIGIDefaultSeq=self.DIGIDefaultSeq
1122 output = cms.OutputModule(
"PoolOutputModule")
1123 if stream.selectEvents.parameters_().__len__()!=0:
1124 output.SelectEvents = stream.selectEvents
1126 output.SelectEvents = cms.untracked.PSet()
1127 output.SelectEvents.SelectEvents=cms.vstring()
1128 if isinstance(stream.paths,tuple):
1129 for path
in stream.paths:
1130 output.SelectEvents.SelectEvents.append(path.label())
1132 output.SelectEvents.SelectEvents.append(stream.paths.label())
1136 if isinstance(stream.content,str):
1137 evtPset=getattr(self.process,stream.content)
1138 for p
in evtPset.parameters_():
1139 setattr(output,p,getattr(evtPset,p))
1140 if not self._options.inlineEventContent:
1143 output.outputCommands.__dict__[
"dumpPython"] = doNotInlineEventContent
1145 output.outputCommands = stream.content
1148 output.fileName = cms.untracked.string(self._options.dirout+stream.name+
'.root')
1150 output.dataset = cms.untracked.PSet( dataTier = stream.dataTier,
1151 filterName = cms.untracked.string(stream.name))
1153 if self._options.filtername:
1154 output.dataset.filterName= cms.untracked.string(self._options.filtername+
"_"+stream.name)
1157 output.eventAutoFlushCompressedSize=cms.untracked.int32(5*1024*1024)
1159 if workflow
in (
"producers,full"):
1160 if isinstance(stream.paths,tuple):
1161 for path
in stream.paths:
1162 self.schedule.append(path)
1164 self.schedule.append(stream.paths)
1168 if (
not self._options.relval)
and workflow
in (
"full",
"output"):
1169 self.additionalOutputs[name] = output
1170 setattr(self.process,name,output)
1172 if workflow ==
'output':
1174 filterList = output.SelectEvents.SelectEvents
1175 for i, filter
in enumerate(filterList):
1176 filterList[i] = filter+
":"+self._options.triggerResultsProcess
1186 if ( len(sequence.split(
'.'))==1 ):
1188 elif ( len(sequence.split(
'.'))==2 ):
1190 sequence=sequence.split(
'.')[1]
1192 print "sub sequence configuration must be of the form dir/subdir/cff.a+b+c or cff.a"
1193 print sequence,
"not recognized"
1200 for i,s
in enumerate(seq.split(
'*')):
1202 setattr(self.process,prefix,getattr(cms,what)( getattr(self.process, s) ))
1204 p=getattr(self.process,prefix)
1205 p+=getattr(self.process, s)
1206 self.schedule.append(getattr(self.process,prefix))
1211 if self.nextScheduleIsConditional:
1212 self.conditionalPaths.append(prefix)
1213 setattr(self.process,prefix,getattr(cms,what)( getattr(self.process, seq) ))
1214 self.schedule.append(getattr(self.process,prefix))
1216 for i,s
in enumerate(seq.split(
'+')):
1218 setattr(self.process,sn,getattr(cms,what)( getattr(self.process, s) ))
1219 self.schedule.append(getattr(self.process,sn))
1233 """ Enrich the process with alca streams """
1234 print 'DL enriching',workflow,sequence
1236 sequence = sequence.split(
'.')[-1]
1239 alcaList = sequence.split(
"+")
1241 from Configuration.AlCa.autoAlca
import autoAlca
1245 for name
in alcaConfig.__dict__:
1246 alcastream = getattr(alcaConfig,name)
1247 shortName = name.replace(
'ALCARECOStream',
'')
1248 if shortName
in alcaList
and isinstance(alcastream,cms.FilteredStream):
1249 output = self.
addExtraStream(name,alcastream, workflow = workflow)
1250 self.
executeAndRemember(
'process.ALCARECOEventContent.outputCommands.extend(process.OutALCARECO'+shortName+
'_noDrop.outputCommands)')
1251 self.AlCaPaths.append(shortName)
1252 if 'DQM' in alcaList:
1253 if not self._options.inlineEventContent
and hasattr(self.process,name):
1254 self.
executeAndRemember(
'process.' + name +
'.outputCommands.append("keep *_MEtoEDMConverter_*_*")')
1256 output.outputCommands.append(
"keep *_MEtoEDMConverter_*_*")
1259 if self._options.hltProcess
or 'HLT' in self.stepMap:
1260 if isinstance(alcastream.paths,tuple):
1261 for path
in alcastream.paths:
1266 for i
in range(alcaList.count(shortName)):
1267 alcaList.remove(shortName)
1270 elif name ==
'pathALCARECODQM' and 'DQM' in alcaList:
1271 path = getattr(alcaConfig,name)
1272 self.schedule.append(path)
1273 alcaList.remove(
'DQM')
1275 if isinstance(alcastream,cms.Path):
1277 self.blacklist_paths.append(alcastream)
1280 if len(alcaList) != 0:
1282 for name
in alcaConfig.__dict__:
1283 alcastream = getattr(alcaConfig,name)
1284 if isinstance(alcastream,cms.FilteredStream):
1285 available.append(name.replace(
'ALCARECOStream',
''))
1286 print "The following alcas could not be found "+str(alcaList)
1287 print "available ",available
1289 raise Exception(
"The following alcas could not be found "+str(alcaList))
1294 loadFragment = self._options.evt_type.replace(
'.py',
'',).
replace(
'.',
'_').
replace(
'python/',
'').
replace(
'/',
'.')
1295 print "Loading lhe fragment from",loadFragment
1296 __import__(loadFragment)
1297 self.process.load(loadFragment)
1299 self._options.inlineObjets+=
','+sequence
1301 getattr(self.process,sequence).nEvents = int(self._options.number)
1304 self.process.lhe_step = cms.Path( getattr( self.process,sequence) )
1305 self.excludedPaths.append(
"lhe_step")
1306 self.schedule.append( self.process.lhe_step )
1309 """ load the fragment of generator configuration """
1314 loadFragment = self._options.evt_type.replace(
'.py',
'',).
replace(
'.',
'_').
replace(
'python/',
'')
1316 if not '/' in loadFragment:
1317 loadFragment=
'Configuration.Generator.'+loadFragment
1319 loadFragment=loadFragment.replace(
'/',
'.')
1321 print "Loading generator fragment from",loadFragment
1322 __import__(loadFragment)
1326 if not (self._options.filein
or self._options.dasquery):
1327 raise Exception(
"Neither gen fragment of input files provided: this is an inconsistent GEN step configuration")
1330 generatorModule=sys.modules[loadFragment]
1331 genModules=generatorModule.__dict__
1334 if self.LHEDefaultSeq
in genModules:
1335 del genModules[self.LHEDefaultSeq]
1337 if self._options.hideGen:
1340 self.process.load(loadFragment)
1342 import FWCore.ParameterSet.Modules
as cmstypes
1343 for name
in genModules:
1344 theObject = getattr(generatorModule,name)
1345 if isinstance(theObject, cmstypes._Module):
1346 self._options.inlineObjets=name+
','+self._options.inlineObjets
1347 elif isinstance(theObject, cms.Sequence)
or isinstance(theObject, cmstypes.ESProducer):
1348 self._options.inlineObjets+=
','+name
1350 if sequence == self.GENDefaultSeq
or sequence ==
'pgen_genonly':
1351 if 'ProductionFilterSequence' in genModules
and (
'generator' in genModules):
1352 self.productionFilterSequence =
'ProductionFilterSequence'
1353 elif 'generator' in genModules:
1354 self.productionFilterSequence =
'generator'
1356 """ Enrich the schedule with the rest of the generation step """
1358 genSeqName=sequence.split(
'.')[-1]
1362 from Configuration.StandardSequences.VtxSmeared
import VtxSmeared
1363 cffToBeLoaded=VtxSmeared[self._options.beamspot]
1366 raise Exception(
"VertexSmearing type or beamspot "+self._options.beamspot+
" unknown.")
1368 if self._options.scenario ==
'HeavyIons':
1369 if self._options.pileup==
'HiMixGEN':
1370 self.
loadAndRemember(
"Configuration/StandardSequences/GeneratorMix_cff")
1372 self.
loadAndRemember(
"Configuration/StandardSequences/GeneratorHI_cff")
1374 self.process.generation_step = cms.Path( getattr(self.process,genSeqName) )
1375 self.schedule.append(self.process.generation_step)
1378 self.
executeAndRemember(
'process.genstepfilter.triggerConditions=cms.vstring("generation_step")')
1380 if 'reGEN' in self.stepMap:
1384 """ Enrich the schedule with the summary of the filter step """
1391 """ Enrich the schedule with the simulation step"""
1392 self.loadDefaultOrSpecifiedCFF(sequence,self.SIMDefaultCFF)
1393 if not self._options.fast:
1394 if self._options.gflash==
True:
1395 self.loadAndRemember(
"Configuration/StandardSequences/GFlashSIM_cff")
1397 if self._options.magField==
'0T':
1398 self.executeAndRemember(
"process.g4SimHits.UseMagneticField = cms.bool(False)")
1400 if self._options.magField==
'0T':
1401 self.executeAndRemember(
"process.famosSimHits.UseMagneticField = cms.bool(False)")
1403 self.scheduleSequence(sequence.split(
'.')[-1],
'simulation_step')
1407 """ Enrich the schedule with the digitisation step"""
1410 if self._options.gflash==
True:
1411 self.
loadAndRemember(
"Configuration/StandardSequences/GFlashDIGI_cff")
1413 if sequence ==
'pdigi_valid':
1414 self.
executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersValid)")
1416 if sequence !=
'pdigi_nogen' and sequence !=
'pdigi_valid_nogen' and not self.process.source.type_()==
'EmptySource':
1417 if self._options.inputEventContent==
'':
1418 self._options.inputEventContent=
'REGEN'
1420 self._options.inputEventContent=self._options.inputEventContent+
',REGEN'
1427 """ Enrich the schedule with the digitisation step"""
1432 if sequence ==
'pdigi_valid':
1433 self.
executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersNoNoiseValid)")
1435 self.
executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersNoNoise)")
1441 """ Enrich the schedule with the digitisation step"""
1442 self.loadDefaultOrSpecifiedCFF(sequence,self.DIGIDefaultCFF)
1444 self.loadAndRemember(
"SimGeneral/MixingModule/digi_MixPreMix_cfi")
1447 if sequence ==
'pdigi_valid':
1448 self.executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersMixPreMixValid)")
1450 self.executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersMixPreMix)")
1452 self.scheduleSequence(sequence.split(
'.')[-1],
'digitisation_step')
1456 """ Enrich the schedule with the crossing frame writer step"""
1462 """ Enrich the schedule with the digitisation step"""
1466 if self._options.pileup_input:
1468 if self._options.pileup_input.startswith(
'dbs:')
or self._options.pileup_input.startswith(
'das:'):
1469 theFiles=
filesFromDASQuery(
'file dataset = %s'%(self._options.pileup_input[4:],),self._options.pileup_dasoption)[0]
1470 elif self._options.pileup_input.startswith(
"filelist:"):
1471 theFiles= (
filesFromList(self._options.pileup_input[9:]))[0]
1473 theFiles=self._options.pileup_input.split(
',')
1475 self.
executeAndRemember(
"process.mixData.input.fileNames = cms.untracked.vstring(%s)"%( theFiles ) )
1482 if "DIGIPREMIX" in self.stepMap.keys():
1484 self.
executeAndRemember(
"process.SiStripDigiToRaw.FedReadoutMode = cms.string('PREMIX_RAW')")
1494 """ Enrich the schedule with the L1 simulation step"""
1501 """ 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"""
1502 supported = [
'GT',
'GT1',
'GT2',
'GCTGT',
'Full',
'FullSimTP',
'FullMC',
'Full2015Data',
'uGT']
1503 if sequence
in supported:
1504 self.loadAndRemember(
'Configuration/StandardSequences/SimL1EmulatorRepack_%s_cff'%sequence)
1505 if self._options.scenario ==
'HeavyIons':
1506 self.renameInputTagsInSequence(
"SimL1Emulator",
"rawDataCollector",
"rawDataRepacker")
1507 self.scheduleSequence(
'SimL1Emulator',
'L1RePack_step')
1509 print "L1REPACK with '",sequence,
"' is not supported! Supported choices are: ",supported
1514 """ Enrich the schedule with the HLT simulation step"""
1516 print "no specification of the hlt menu has been given, should never happen"
1517 raise Exception(
'no HLT sequence provided')
1521 from Configuration.HLT.autoHLT
import autoHLT
1524 sequence = autoHLT[key]
1526 raise ValueError(
'no HLT mapping key "%s" found in autoHLT' % key)
1532 if self._options.scenario ==
'HeavyIons':
1533 optionsForHLT[
'type'] =
'HIon'
1535 optionsForHLT[
'type'] =
'GRun'
1536 optionsForHLTConfig =
', '.
join(
'%s=%s' % (key, repr(val))
for (key, val)
in optionsForHLT.iteritems())
1537 if sequence ==
'run,fromSource':
1538 if hasattr(self.process.source,
'firstRun'):
1539 self.
executeAndRemember(
'process.loadHltConfiguration("run:%%d"%%(process.source.firstRun.value()),%s)'%(optionsForHLTConfig))
1540 elif hasattr(self.process.source,
'setRunNumber'):
1541 self.
executeAndRemember(
'process.loadHltConfiguration("run:%%d"%%(process.source.setRunNumber.value()),%s)'%(optionsForHLTConfig))
1543 raise Exception(
'Cannot replace menu to load %s'%(sequence))
1545 self.
executeAndRemember(
'process.loadHltConfiguration("%s",%s)'%(sequence.replace(
',',
':'),optionsForHLTConfig))
1549 if self._options.isMC:
1550 if self._options.fast:
1551 self._options.customisation_file.append(
"HLTrigger/Configuration/customizeHLTforMC.customizeHLTforFastSim")
1553 self._options.customisation_file.append(
"HLTrigger/Configuration/customizeHLTforMC.customizeHLTforFullSim")
1555 if self._options.name !=
'HLT':
1556 self.additionalCommands.append(
'from HLTrigger.Configuration.CustomConfigs import ProcessName')
1557 self.additionalCommands.append(
'process = ProcessName(process)')
1558 self.additionalCommands.append(
'')
1559 from HLTrigger.Configuration.CustomConfigs
import ProcessName
1562 self.schedule.append(self.process.HLTSchedule)
1563 [self.blacklist_paths.append(path)
for path
in self.process.HLTSchedule
if isinstance(path,(cms.Path,cms.EndPath))]
1566 if self._options.fast:
1567 if not hasattr(self.process,
'HLTEndSequence'):
1568 self.
executeAndRemember(
"process.HLTEndSequence = cms.Sequence( process.dummyModule )")
1573 seqReco=sequence.split(
',')[1]
1574 seqDigi=sequence.split(
',')[0]
1576 print "RAW2RECO requires two specifications",sequence,
"insufficient"
1590 self.
loadAndRemember(
"PhysicsTools/PatAlgos/slimming/metFilterPaths_cff")
1592 for filt
in allMetFilterPaths:
1593 self.schedule.append(getattr(self.process,
'Flag_'+filt))
1596 ''' Enrich the schedule with L1 HW validation '''
1599 print '\n\n\n DEPRECATED this has no action \n\n\n'
1603 ''' Enrich the schedule with L1 reconstruction '''
1609 ''' Enrich the schedule with L1 reconstruction '''
1615 ''' Enrich the schedule with a user defined filter sequence '''
1617 filterConfig=self.
load(sequence.split(
'.')[0])
1618 filterSeq=sequence.split(
'.')[-1]
1626 label=visitee.label()
1634 getattr(self.process,filterSeq).
visit( expander )
1635 self._options.inlineObjets+=
','+expander.inliner
1636 self._options.inlineObjets+=
','+filterSeq
1639 self.scheduleSequence(filterSeq,
'filtering_step')
1640 self.nextScheduleIsConditional=
True
1642 self.productionFilterSequence = filterSeq
1647 ''' Enrich the schedule with reconstruction '''
1653 ''' Enrich the schedule with the part of reconstruction that is done before mixing in FastSim'''
1654 if not self._options.fast:
1655 print "ERROR: this step is only implemented for FastSim"
1658 self.
scheduleSequence(sequence.split(
'.')[-1],
'reconstruction_befmix_step')
1662 ''' Enrich the schedule with PAT '''
1663 self.prepare_PATFILTER(self)
1664 self.loadDefaultOrSpecifiedCFF(sequence,self.PATDefaultCFF,1)
1665 if not self._options.runUnscheduled:
1666 raise Exception(
"MiniAOD production can only run in unscheduled mode, please run cmsDriver with --runUnscheduled")
1667 if self._options.isData:
1668 self._options.customisation_file_unsch.append(
"PhysicsTools/PatAlgos/slimming/miniAOD_tools.miniAOD_customizeAllData")
1670 self._options.customisation_file_unsch.append(
"PhysicsTools/PatAlgos/slimming/miniAOD_tools.miniAOD_customizeAllMC")
1671 if self._options.fast:
1672 self._options.customisation_file_unsch.append(
"PhysicsTools/PatAlgos/slimming/metFilterPaths_cff.miniAOD_customizeMETFiltersFastSim")
1676 ''' Enrich the schedule with event interpretation '''
1677 from Configuration.StandardSequences.EventInterpretation
import EventInterpretation
1678 if sequence
in EventInterpretation:
1679 self.EIDefaultCFF = EventInterpretation[sequence]
1680 sequence =
'EIsequence'
1682 raise Exception(
'Cannot set %s event interpretation'%( sequence) )
1688 ''' Enrich the schedule with skimming fragments'''
1690 sequence = sequence.split(
'.')[-1]
1692 skimlist=sequence.split(
'+')
1694 from Configuration.Skimming.autoSkim
import autoSkim
1698 for skim
in skimConfig.__dict__:
1699 skimstream = getattr(skimConfig,skim)
1700 if isinstance(skimstream,cms.Path):
1702 self.blacklist_paths.append(skimstream)
1703 if (
not isinstance(skimstream,cms.FilteredStream)):
1705 shortname = skim.replace(
'SKIMStream',
'')
1706 if (sequence==
"all"):
1708 elif (shortname
in skimlist):
1711 if self._options.datatier==
'DQM':
1712 self.process.load(self.EVTCONTDefaultCFF)
1713 skimstreamDQM = cms.FilteredStream(
1714 responsible = skimstream.responsible,
1715 name = skimstream.name+
'DQM',
1716 paths = skimstream.paths,
1717 selectEvents = skimstream.selectEvents,
1718 content = self._options.datatier+
'EventContent',
1719 dataTier = cms.untracked.string(self._options.datatier)
1722 for i
in range(skimlist.count(shortname)):
1723 skimlist.remove(shortname)
1727 if (skimlist.__len__()!=0
and sequence!=
"all"):
1728 print 'WARNING, possible typo with SKIM:'+
'+'.
join(skimlist)
1729 raise Exception(
'WARNING, possible typo with SKIM:'+
'+'.
join(skimlist))
1732 ''' Enrich the schedule with a user defined sequence '''
1738 """ Enrich the schedule with the postreco step """
1745 print sequence,
"in preparing validation"
1747 from Validation.Configuration.autoValidation
import autoValidation
1749 sequence=sequence.split(
'.')[-1]
1750 if sequence.find(
',')!=-1:
1751 prevalSeqName=sequence.split(
',')[0].
split(
'+')
1752 valSeqName=sequence.split(
',')[1].
split(
'+')
1757 prevalSeqName=sequence.split(
'+')
1758 valSeqName=sequence.split(
'+')
1764 postfix=
'_'+sequence
1765 prevalSeqName=[
'prevalidation'+postfix]
1766 valSeqName=[
'validation'+postfix]
1767 if not hasattr(self.process,valSeqName[0]):
1769 valSeqName=[sequence]
1780 if (
'HLT' in self.stepMap
and not self._options.fast)
or self._options.hltProcess:
1781 for s
in valSeqName+prevalSeqName:
1784 for (i,s)
in enumerate(prevalSeqName):
1786 setattr(self.process,
'prevalidation_step%s'%NFI(i), cms.Path( getattr(self.process, s)) )
1787 self.schedule.append(getattr(self.process,
'prevalidation_step%s'%NFI(i)))
1789 for (i,s)
in enumerate(valSeqName):
1790 setattr(self.process,
'validation_step%s'%NFI(i), cms.EndPath( getattr(self.process, s)))
1791 self.schedule.append(getattr(self.process,
'validation_step%s'%NFI(i)))
1794 if 'PAT' in self.stepMap
and not 'RECO' in self.stepMap:
1797 if not 'DIGI' in self.stepMap
and not self._options.fast
and not any(map(
lambda s : s.startswith(
'genvalid'), valSeqName)):
1798 if self._options.restoreRNDSeeds==
False and not self._options.restoreRNDSeeds==
True:
1799 self._options.restoreRNDSeeds=
True
1801 if not 'DIGI' in self.stepMap
and not self._options.fast:
1805 self._options.customisation_file.append(
"SimGeneral/MixingModule/fullMixCustomize_cff.setCrossingFrameOn")
1807 if hasattr(self.process,
"genstepfilter")
and len(self.process.genstepfilter.triggerConditions):
1809 for (i,s)
in enumerate(valSeqName):
1810 getattr(self.process,
'validation_step%s'%NFI(i))._seq = self.process.genstepfilter * getattr(self.process,
'validation_step%s'%NFI(i))._seq
1816 """Visitor that travels within a cms.Sequence, looks for a parameter and replace its value
1817 It will climb down within PSets, VPSets and VInputTags to find its target"""
1818 def __init__(self, paramSearch, paramReplace, verbose=False, whitelist=()):
1825 if isinstance(pset, cms._Parameterizable):
1826 for name
in pset.parameters_().
keys():
1832 value = getattr(pset,name)
1833 type = value.pythonTypeName()
1834 if type
in (
'cms.PSet',
'cms.untracked.PSet'):
1835 self.
doIt(value,base+
"."+name)
1836 elif type
in (
'cms.VPSet',
'cms.untracked.VPSet'):
1837 for (i,ps)
in enumerate(value): self.
doIt(ps,
"%s.%s[%d]"%(base,name,i) )
1838 elif type
in (
'cms.string',
'cms.untracked.string'):
1840 if self.
_verbose:
print "set string process name %s.%s %s ==> %s"% (base, name, value, self.
_paramReplace)
1842 elif type
in (
'cms.VInputTag',
'cms.untracked.VInputTag'):
1843 for (i,n)
in enumerate(value):
1844 if not isinstance(n, cms.InputTag):
1848 if self.
_verbose:
print "set process name %s.%s[%d] %s ==> %s " % (base, name, i, n, self.
_paramReplace)
1851 elif type
in (
'cms.vstring',
'cms.untracked.vstring'):
1852 for (i,n)
in enumerate(value):
1855 elif type
in (
'cms.InputTag',
'cms.untracked.InputTag'):
1857 if self.
_verbose:
print "set process name %s.%s %s ==> %s " % (base, name, value, self.
_paramReplace)
1858 setattr(getattr(pset, name),
"processName",self.
_paramReplace)
1863 label = visitee.label()
1864 except AttributeError:
1865 label =
'<Module not in a Process>'
1867 label =
'other execption'
1868 self.
doIt(visitee, label)
1875 print "Replacing all InputTag %s => %s"%(oldT,newT)
1878 loadMe=
'from PhysicsTools.PatAlgos.tools.helpers import massSearchReplaceAnyInputTag'
1879 if not loadMe
in self.additionalCommands:
1880 self.additionalCommands.append(loadMe)
1881 self.additionalCommands.append(
'massSearchReplaceAnyInputTag(process.%s,"%s","%s",False,True)'%(sequence,oldT,newT))
1885 if self._options.hltProcess:
1886 proc=self._options.hltProcess
1888 proc=self.process.name_()
1889 if proc==HLTprocess:
return
1891 print "replacing %s process name - sequence %s will use '%s'" % (HLTprocess,sequence, proc)
1893 if 'from Configuration.Applications.ConfigBuilder import ConfigBuilder' not in self.additionalCommands:
1894 self.additionalCommands.append(
'from Configuration.Applications.ConfigBuilder import ConfigBuilder')
1895 self.additionalCommands.append(
'process.%s.visit(ConfigBuilder.MassSearchReplaceProcessNameVisitor("%s", "%s", whitelist = ("subSystemFolder",)))'% (sequence,HLTprocess, proc))
1901 while '@' in repr(seqList)
and level<maxLevel:
1903 for specifiedCommand
in seqList:
1904 if specifiedCommand.startswith(
'@'):
1905 location=specifiedCommand[1:]
1906 if not location
in mapping:
1907 raise Exception(
"Impossible to map "+location+
" from "+repr(mapping))
1908 mappedTo=mapping[location]
1910 mappedTo=mappedTo[index]
1911 seqList.remove(specifiedCommand)
1912 seqList.extend(mappedTo.split(
'+'))
1915 raise Exception(
"Could not fully expand "+repr(seqList)+
" from "+repr(mapping))
1921 sequenceList=sequence.split(
'.')[-1].
split(
'+')
1922 postSequenceList=sequence.split(
'.')[-1].
split(
'+')
1923 from DQMOffline.Configuration.autoDQM
import autoDQM
1927 if len(set(sequenceList))!=len(sequenceList):
1928 sequenceList=
list(set(sequenceList))
1929 print "Duplicate entries for DQM:, using",sequenceList
1931 pathName=
'dqmoffline_step'
1932 for (i,sequence)
in enumerate(sequenceList):
1934 pathName=
'dqmoffline_%d_step'%(i)
1936 if 'HLT' in self.stepMap.keys()
or self._options.hltProcess:
1941 if 'HLT' in self.stepMap.keys()
and not self._options.fast:
1943 setattr(self.process,pathName, cms.EndPath( getattr(self.process, sequence ) ) )
1946 setattr(self.process,pathName, cms.Path( getattr(self.process, sequence) ) )
1947 self.schedule.append(getattr(self.process,pathName))
1949 pathName=
'dqmofflineOnPAT_step'
1950 for (i,sequence)
in enumerate(postSequenceList):
1952 pathName=
'dqmofflineOnPAT_%d_step'%(i)
1955 if 'PAT' in self.stepMap.keys():
1957 setattr(self.process,pathName, cms.EndPath( getattr(self.process, sequence ) ) )
1960 setattr(self.process,pathName, cms.Path( getattr(self.process, sequence) ) )
1961 self.schedule.append(getattr(self.process,pathName))
1964 """ Enrich the process with harvesting step """
1965 self.
DQMSaverCFF=
'Configuration/StandardSequences/DQMSaver'+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
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
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