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.py %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.VALIDATIONDefaultCFF =
"FastSimulation.Configuration.Validation_cff"
1095 self.RECOBEFMIXDefaultCFF =
'FastSimulation.Configuration.Reconstruction_BefMix_cff'
1096 self.RECOBEFMIXDefaultSeq =
'reconstruction_befmix'
1102 if self._options.pileup==
'default':
1103 from Configuration.StandardSequences.Mixing
import MixingDefaultKey
1104 self._options.pileup=MixingDefaultKey
1108 if self._options.isData:
1109 self._options.pileup=
None
1111 if self._options.slhc:
1112 self.GeometryCFF=
'SLHCUpgradeSimulations.Geometry.%s_cmsSimIdealGeometryXML_cff'%(self._options.slhc,)
1113 if 'stdgeom' not in self._options.slhc:
1114 self.SimGeometryCFF=
'SLHCUpgradeSimulations.Geometry.%s_cmsSimIdealGeometryXML_cff'%(self._options.slhc,)
1115 self.
DIGIDefaultCFF=
'SLHCUpgradeSimulations/Geometry/Digi_%s_cff'%(self._options.slhc,)
1116 if self._options.pileup!=defaultOptions.pileup:
1117 self._options.pileup=
'SLHC_%s_%s'%(self._options.pileup,self._options.slhc)
1119 self.REDIGIDefaultSeq=self.DIGIDefaultSeq
1124 output = cms.OutputModule(
"PoolOutputModule")
1125 if stream.selectEvents.parameters_().__len__()!=0:
1126 output.SelectEvents = stream.selectEvents
1128 output.SelectEvents = cms.untracked.PSet()
1129 output.SelectEvents.SelectEvents=cms.vstring()
1130 if isinstance(stream.paths,tuple):
1131 for path
in stream.paths:
1132 output.SelectEvents.SelectEvents.append(path.label())
1134 output.SelectEvents.SelectEvents.append(stream.paths.label())
1138 if isinstance(stream.content,str):
1139 evtPset=getattr(self.process,stream.content)
1140 for p
in evtPset.parameters_():
1141 setattr(output,p,getattr(evtPset,p))
1142 if not self._options.inlineEventContent:
1145 output.outputCommands.__dict__[
"dumpPython"] = doNotInlineEventContent
1147 output.outputCommands = stream.content
1150 output.fileName = cms.untracked.string(self._options.dirout+stream.name+
'.root')
1152 output.dataset = cms.untracked.PSet( dataTier = stream.dataTier,
1153 filterName = cms.untracked.string(stream.name))
1155 if self._options.filtername:
1156 output.dataset.filterName= cms.untracked.string(self._options.filtername+
"_"+stream.name)
1159 output.eventAutoFlushCompressedSize=cms.untracked.int32(5*1024*1024)
1161 if workflow
in (
"producers,full"):
1162 if isinstance(stream.paths,tuple):
1163 for path
in stream.paths:
1164 self.schedule.append(path)
1166 self.schedule.append(stream.paths)
1170 if (
not self._options.relval)
and workflow
in (
"full",
"output"):
1171 self.additionalOutputs[name] = output
1172 setattr(self.process,name,output)
1174 if workflow ==
'output':
1176 filterList = output.SelectEvents.SelectEvents
1177 for i, filter
in enumerate(filterList):
1178 filterList[i] = filter+
":"+self._options.triggerResultsProcess
1188 if ( len(sequence.split(
'.'))==1 ):
1190 elif ( len(sequence.split(
'.'))==2 ):
1192 sequence=sequence.split(
'.')[1]
1194 print "sub sequence configuration must be of the form dir/subdir/cff.a+b+c or cff.a"
1195 print sequence,
"not recognized"
1202 for i,s
in enumerate(seq.split(
'*')):
1204 setattr(self.process,prefix,getattr(cms,what)( getattr(self.process, s) ))
1206 p=getattr(self.process,prefix)
1207 p+=getattr(self.process, s)
1208 self.schedule.append(getattr(self.process,prefix))
1213 if self.nextScheduleIsConditional:
1214 self.conditionalPaths.append(prefix)
1215 setattr(self.process,prefix,getattr(cms,what)( getattr(self.process, seq) ))
1216 self.schedule.append(getattr(self.process,prefix))
1218 for i,s
in enumerate(seq.split(
'+')):
1220 setattr(self.process,sn,getattr(cms,what)( getattr(self.process, s) ))
1221 self.schedule.append(getattr(self.process,sn))
1235 """ Enrich the process with alca streams """
1236 print 'DL enriching',workflow,sequence
1238 sequence = sequence.split(
'.')[-1]
1241 alcaList = sequence.split(
"+")
1243 from Configuration.AlCa.autoAlca
import autoAlca
1247 for name
in alcaConfig.__dict__:
1248 alcastream = getattr(alcaConfig,name)
1249 shortName = name.replace(
'ALCARECOStream',
'')
1250 if shortName
in alcaList
and isinstance(alcastream,cms.FilteredStream):
1251 output = self.
addExtraStream(name,alcastream, workflow = workflow)
1252 self.
executeAndRemember(
'process.ALCARECOEventContent.outputCommands.extend(process.OutALCARECO'+shortName+
'_noDrop.outputCommands)')
1253 self.AlCaPaths.append(shortName)
1254 if 'DQM' in alcaList:
1255 if not self._options.inlineEventContent
and hasattr(self.process,name):
1256 self.
executeAndRemember(
'process.' + name +
'.outputCommands.append("keep *_MEtoEDMConverter_*_*")')
1258 output.outputCommands.append(
"keep *_MEtoEDMConverter_*_*")
1261 if self._options.hltProcess
or 'HLT' in self.stepMap:
1262 if isinstance(alcastream.paths,tuple):
1263 for path
in alcastream.paths:
1268 for i
in range(alcaList.count(shortName)):
1269 alcaList.remove(shortName)
1272 elif name ==
'pathALCARECODQM' and 'DQM' in alcaList:
1273 path = getattr(alcaConfig,name)
1274 self.schedule.append(path)
1275 alcaList.remove(
'DQM')
1277 if isinstance(alcastream,cms.Path):
1279 self.blacklist_paths.append(alcastream)
1282 if len(alcaList) != 0:
1284 for name
in alcaConfig.__dict__:
1285 alcastream = getattr(alcaConfig,name)
1286 if isinstance(alcastream,cms.FilteredStream):
1287 available.append(name.replace(
'ALCARECOStream',
''))
1288 print "The following alcas could not be found "+str(alcaList)
1289 print "available ",available
1291 raise Exception(
"The following alcas could not be found "+str(alcaList))
1296 loadFragment = self._options.evt_type.replace(
'.py',
'',).
replace(
'.',
'_').
replace(
'python/',
'').
replace(
'/',
'.')
1297 print "Loading lhe fragment from",loadFragment
1298 __import__(loadFragment)
1299 self.process.load(loadFragment)
1301 self._options.inlineObjets+=
','+sequence
1303 getattr(self.process,sequence).nEvents = int(self._options.number)
1306 self.process.lhe_step = cms.Path( getattr( self.process,sequence) )
1307 self.excludedPaths.append(
"lhe_step")
1308 self.schedule.append( self.process.lhe_step )
1311 """ load the fragment of generator configuration """
1316 loadFragment = self._options.evt_type.replace(
'.py',
'',).
replace(
'.',
'_').
replace(
'python/',
'')
1318 if not '/' in loadFragment:
1319 loadFragment=
'Configuration.Generator.'+loadFragment
1321 loadFragment=loadFragment.replace(
'/',
'.')
1323 print "Loading generator fragment from",loadFragment
1324 __import__(loadFragment)
1328 if not (self._options.filein
or self._options.dasquery):
1329 raise Exception(
"Neither gen fragment of input files provided: this is an inconsistent GEN step configuration")
1332 generatorModule=sys.modules[loadFragment]
1333 genModules=generatorModule.__dict__
1336 if self.LHEDefaultSeq
in genModules:
1337 del genModules[self.LHEDefaultSeq]
1339 if self._options.hideGen:
1342 self.process.load(loadFragment)
1344 import FWCore.ParameterSet.Modules
as cmstypes
1345 for name
in genModules:
1346 theObject = getattr(generatorModule,name)
1347 if isinstance(theObject, cmstypes._Module):
1348 self._options.inlineObjets=name+
','+self._options.inlineObjets
1349 elif isinstance(theObject, cms.Sequence)
or isinstance(theObject, cmstypes.ESProducer):
1350 self._options.inlineObjets+=
','+name
1352 if sequence == self.GENDefaultSeq
or sequence ==
'pgen_genonly':
1353 if 'ProductionFilterSequence' in genModules
and (
'generator' in genModules):
1354 self.productionFilterSequence =
'ProductionFilterSequence'
1355 elif 'generator' in genModules:
1356 self.productionFilterSequence =
'generator'
1358 """ Enrich the schedule with the rest of the generation step """
1360 genSeqName=sequence.split(
'.')[-1]
1364 from Configuration.StandardSequences.VtxSmeared
import VtxSmeared
1365 cffToBeLoaded=VtxSmeared[self._options.beamspot]
1368 raise Exception(
"VertexSmearing type or beamspot "+self._options.beamspot+
" unknown.")
1370 if self._options.scenario ==
'HeavyIons':
1371 if self._options.pileup==
'HiMixGEN':
1372 self.
loadAndRemember(
"Configuration/StandardSequences/GeneratorMix_cff")
1374 self.
loadAndRemember(
"Configuration/StandardSequences/GeneratorHI_cff")
1376 self.process.generation_step = cms.Path( getattr(self.process,genSeqName) )
1377 self.schedule.append(self.process.generation_step)
1380 self.
executeAndRemember(
'process.genstepfilter.triggerConditions=cms.vstring("generation_step")')
1382 if 'reGEN' in self.stepMap:
1386 """ Enrich the schedule with the summary of the filter step """
1393 """ Enrich the schedule with the simulation step"""
1394 self.loadDefaultOrSpecifiedCFF(sequence,self.SIMDefaultCFF)
1395 if not self._options.fast:
1396 if self._options.gflash==
True:
1397 self.loadAndRemember(
"Configuration/StandardSequences/GFlashSIM_cff")
1399 if self._options.magField==
'0T':
1400 self.executeAndRemember(
"process.g4SimHits.UseMagneticField = cms.bool(False)")
1402 if self._options.magField==
'0T':
1403 self.executeAndRemember(
"process.famosSimHits.UseMagneticField = cms.bool(False)")
1405 self.scheduleSequence(sequence.split(
'.')[-1],
'simulation_step')
1409 """ Enrich the schedule with the digitisation step"""
1412 if self._options.gflash==
True:
1413 self.
loadAndRemember(
"Configuration/StandardSequences/GFlashDIGI_cff")
1415 if sequence ==
'pdigi_valid':
1416 self.
executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersValid)")
1418 if sequence !=
'pdigi_nogen' and sequence !=
'pdigi_valid_nogen' and not self.process.source.type_()==
'EmptySource':
1419 if self._options.inputEventContent==
'':
1420 self._options.inputEventContent=
'REGEN'
1422 self._options.inputEventContent=self._options.inputEventContent+
',REGEN'
1429 """ Enrich the schedule with the digitisation step"""
1434 if sequence ==
'pdigi_valid':
1435 self.
executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersNoNoiseValid)")
1437 self.
executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersNoNoise)")
1443 """ Enrich the schedule with the digitisation step"""
1444 self.loadDefaultOrSpecifiedCFF(sequence,self.DIGIDefaultCFF)
1446 self.loadAndRemember(
"SimGeneral/MixingModule/digi_MixPreMix_cfi")
1449 if sequence ==
'pdigi_valid':
1450 self.executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersMixPreMixValid)")
1452 self.executeAndRemember(
"process.mix.digitizers = cms.PSet(process.theDigitizersMixPreMix)")
1454 self.scheduleSequence(sequence.split(
'.')[-1],
'digitisation_step')
1458 """ Enrich the schedule with the crossing frame writer step"""
1464 """ Enrich the schedule with the digitisation step"""
1468 if self._options.pileup_input:
1470 if self._options.pileup_input.startswith(
'dbs:')
or self._options.pileup_input.startswith(
'das:'):
1471 theFiles=
filesFromDASQuery(
'file dataset = %s'%(self._options.pileup_input[4:],),self._options.pileup_dasoption)[0]
1472 elif self._options.pileup_input.startswith(
"filelist:"):
1473 theFiles= (
filesFromList(self._options.pileup_input[9:]))[0]
1475 theFiles=self._options.pileup_input.split(
',')
1477 self.
executeAndRemember(
"process.mixData.input.fileNames = cms.untracked.vstring(%s)"%( theFiles ) )
1484 if "DIGIPREMIX" in self.stepMap.keys():
1486 self.
executeAndRemember(
"process.SiStripDigiToRaw.FedReadoutMode = cms.string('PREMIX_RAW')")
1496 """ Enrich the schedule with the L1 simulation step"""
1503 """ 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"""
1504 supported = [
'GT',
'GT1',
'GT2',
'GCTGT',
'Full']
1505 if sequence
in supported:
1506 self.loadAndRemember(
'Configuration/StandardSequences/SimL1EmulatorRepack_%s_cff'%sequence)
1507 if self._options.scenario ==
'HeavyIons':
1508 self.renameInputTagsInSequence(
"SimL1Emulator",
"rawDataCollector",
"rawDataRepacker")
1509 self.scheduleSequence(
'SimL1Emulator',
'L1RePack_step')
1511 print "L1REPACK with '",sequence,
"' is not supported! Supported choices are: ",supported
1516 """ Enrich the schedule with the HLT simulation step"""
1518 print "no specification of the hlt menu has been given, should never happen"
1519 raise Exception(
'no HLT sequence provided')
1523 from Configuration.HLT.autoHLT
import autoHLT
1526 sequence = autoHLT[key]
1528 raise ValueError(
'no HLT mapping key "%s" found in autoHLT' % key)
1534 if self._options.scenario ==
'HeavyIons':
1535 optionsForHLT[
'type'] =
'HIon'
1537 optionsForHLT[
'type'] =
'GRun'
1538 optionsForHLTConfig =
', '.
join(
'%s=%s' % (key, repr(val))
for (key, val)
in optionsForHLT.iteritems())
1539 if sequence ==
'run,fromSource':
1540 if hasattr(self.process.source,
'firstRun'):
1541 self.
executeAndRemember(
'process.loadHltConfiguration("run:%%d"%%(process.source.firstRun.value()),%s)'%(optionsForHLTConfig))
1542 elif hasattr(self.process.source,
'setRunNumber'):
1543 self.
executeAndRemember(
'process.loadHltConfiguration("run:%%d"%%(process.source.setRunNumber.value()),%s)'%(optionsForHLTConfig))
1545 raise Exception(
'Cannot replace menu to load %s'%(sequence))
1547 self.
executeAndRemember(
'process.loadHltConfiguration("%s",%s)'%(sequence.replace(
',',
':'),optionsForHLTConfig))
1551 if self._options.isMC:
1552 if self._options.fast:
1553 self._options.customisation_file.append(
"HLTrigger/Configuration/customizeHLTforMC.customizeHLTforFastSim")
1555 self._options.customisation_file.append(
"HLTrigger/Configuration/customizeHLTforMC.customizeHLTforFullSim")
1557 if self._options.name !=
'HLT':
1558 self.additionalCommands.append(
'from HLTrigger.Configuration.CustomConfigs import ProcessName')
1559 self.additionalCommands.append(
'process = ProcessName(process)')
1560 self.additionalCommands.append(
'')
1561 from HLTrigger.Configuration.CustomConfigs
import ProcessName
1564 self.schedule.append(self.process.HLTSchedule)
1565 [self.blacklist_paths.append(path)
for path
in self.process.HLTSchedule
if isinstance(path,(cms.Path,cms.EndPath))]
1568 if self._options.fast:
1569 if not hasattr(self.process,
'HLTEndSequence'):
1570 self.
executeAndRemember(
"process.HLTEndSequence = cms.Sequence( process.dummyModule )")
1575 seqReco=sequence.split(
',')[1]
1576 seqDigi=sequence.split(
',')[0]
1578 print "RAW2RECO requires two specifications",sequence,
"insufficient"
1592 self.
loadAndRemember(
"PhysicsTools/PatAlgos/slimming/metFilterPaths_cff")
1594 for filt
in allMetFilterPaths:
1595 self.schedule.append(getattr(self.process,
'Flag_'+filt))
1598 ''' Enrich the schedule with L1 HW validation '''
1601 print '\n\n\n DEPRECATED this has no action \n\n\n'
1605 ''' Enrich the schedule with L1 reconstruction '''
1611 ''' Enrich the schedule with L1 reconstruction '''
1617 ''' Enrich the schedule with a user defined filter sequence '''
1619 filterConfig=self.
load(sequence.split(
'.')[0])
1620 filterSeq=sequence.split(
'.')[-1]
1628 label=visitee.label()
1636 getattr(self.process,filterSeq).
visit( expander )
1637 self._options.inlineObjets+=
','+expander.inliner
1638 self._options.inlineObjets+=
','+filterSeq
1641 self.scheduleSequence(filterSeq,
'filtering_step')
1642 self.nextScheduleIsConditional=
True
1644 self.productionFilterSequence = filterSeq
1649 ''' Enrich the schedule with reconstruction '''
1655 ''' Enrich the schedule with the part of reconstruction that is done before mixing in FastSim'''
1656 if not self._options.fast:
1657 print "ERROR: this step is only implemented for FastSim"
1660 self.
scheduleSequence(sequence.split(
'.')[-1],
'reconstruction_befmix_step')
1664 ''' Enrich the schedule with PAT '''
1665 self.prepare_PATFILTER(self)
1666 self.loadDefaultOrSpecifiedCFF(sequence,self.PATDefaultCFF,1)
1667 if not self._options.runUnscheduled:
1668 raise Exception(
"MiniAOD production can only run in unscheduled mode, please run cmsDriver with --runUnscheduled")
1669 if self._options.isData:
1670 self._options.customisation_file_unsch.append(
"PhysicsTools/PatAlgos/slimming/miniAOD_tools.miniAOD_customizeAllData")
1672 self._options.customisation_file_unsch.append(
"PhysicsTools/PatAlgos/slimming/miniAOD_tools.miniAOD_customizeAllMC")
1673 if self._options.fast:
1674 self._options.customisation_file_unsch.append(
"PhysicsTools/PatAlgos/slimming/metFilterPaths_cff.miniAOD_customizeMETFiltersFastSim")
1678 ''' Enrich the schedule with event interpretation '''
1679 from Configuration.StandardSequences.EventInterpretation
import EventInterpretation
1680 if sequence
in EventInterpretation:
1681 self.EIDefaultCFF = EventInterpretation[sequence]
1682 sequence =
'EIsequence'
1684 raise Exception(
'Cannot set %s event interpretation'%( sequence) )
1690 ''' Enrich the schedule with skimming fragments'''
1692 sequence = sequence.split(
'.')[-1]
1694 skimlist=sequence.split(
'+')
1696 from Configuration.Skimming.autoSkim
import autoSkim
1700 for skim
in skimConfig.__dict__:
1701 skimstream = getattr(skimConfig,skim)
1702 if isinstance(skimstream,cms.Path):
1704 self.blacklist_paths.append(skimstream)
1705 if (
not isinstance(skimstream,cms.FilteredStream)):
1707 shortname = skim.replace(
'SKIMStream',
'')
1708 if (sequence==
"all"):
1710 elif (shortname
in skimlist):
1713 if self._options.datatier==
'DQM':
1714 self.process.load(self.EVTCONTDefaultCFF)
1715 skimstreamDQM = cms.FilteredStream(
1716 responsible = skimstream.responsible,
1717 name = skimstream.name+
'DQM',
1718 paths = skimstream.paths,
1719 selectEvents = skimstream.selectEvents,
1720 content = self._options.datatier+
'EventContent',
1721 dataTier = cms.untracked.string(self._options.datatier)
1724 for i
in range(skimlist.count(shortname)):
1725 skimlist.remove(shortname)
1729 if (skimlist.__len__()!=0
and sequence!=
"all"):
1730 print 'WARNING, possible typo with SKIM:'+
'+'.
join(skimlist)
1731 raise Exception(
'WARNING, possible typo with SKIM:'+
'+'.
join(skimlist))
1734 ''' Enrich the schedule with a user defined sequence '''
1740 """ Enrich the schedule with the postreco step """
1747 print sequence,
"in preparing validation"
1749 from Validation.Configuration.autoValidation
import autoValidation
1751 sequence=sequence.split(
'.')[-1]
1752 if sequence.find(
',')!=-1:
1753 prevalSeqName=sequence.split(
',')[0].
split(
'+')
1754 valSeqName=sequence.split(
',')[1].
split(
'+')
1759 prevalSeqName=sequence.split(
'+')
1760 valSeqName=sequence.split(
'+')
1766 postfix=
'_'+sequence
1767 prevalSeqName=[
'prevalidation'+postfix]
1768 valSeqName=[
'validation'+postfix]
1769 if not hasattr(self.process,valSeqName[0]):
1771 valSeqName=[sequence]
1782 if (
'HLT' in self.stepMap
and not self._options.fast)
or self._options.hltProcess:
1783 for s
in valSeqName+prevalSeqName:
1786 for (i,s)
in enumerate(prevalSeqName):
1788 setattr(self.process,
'prevalidation_step%s'%NFI(i), cms.Path( getattr(self.process, s)) )
1789 self.schedule.append(getattr(self.process,
'prevalidation_step%s'%NFI(i)))
1791 for (i,s)
in enumerate(valSeqName):
1792 setattr(self.process,
'validation_step%s'%NFI(i), cms.EndPath( getattr(self.process, s)))
1793 self.schedule.append(getattr(self.process,
'validation_step%s'%NFI(i)))
1796 if 'PAT' in self.stepMap
and not 'RECO' in self.stepMap:
1799 if not 'DIGI' in self.stepMap
and not self._options.fast
and not any(map(
lambda s : s.startswith(
'genvalid'), valSeqName)):
1800 if self._options.restoreRNDSeeds==
False and not self._options.restoreRNDSeeds==
True:
1801 self._options.restoreRNDSeeds=
True
1803 if not 'DIGI' in self.stepMap
and not self._options.fast:
1807 self._options.customisation_file.append(
"SimGeneral/MixingModule/fullMixCustomize_cff.setCrossingFrameOn")
1809 if hasattr(self.process,
"genstepfilter")
and len(self.process.genstepfilter.triggerConditions):
1811 for (i,s)
in enumerate(valSeqName):
1812 getattr(self.process,
'validation_step%s'%NFI(i))._seq = self.process.genstepfilter * getattr(self.process,
'validation_step%s'%NFI(i))._seq
1818 """Visitor that travels within a cms.Sequence, looks for a parameter and replace its value
1819 It will climb down within PSets, VPSets and VInputTags to find its target"""
1820 def __init__(self, paramSearch, paramReplace, verbose=False, whitelist=()):
1827 if isinstance(pset, cms._Parameterizable):
1828 for name
in pset.parameters_().
keys():
1834 value = getattr(pset,name)
1835 type = value.pythonTypeName()
1836 if type
in (
'cms.PSet',
'cms.untracked.PSet'):
1837 self.
doIt(value,base+
"."+name)
1838 elif type
in (
'cms.VPSet',
'cms.untracked.VPSet'):
1839 for (i,ps)
in enumerate(value): self.
doIt(ps,
"%s.%s[%d]"%(base,name,i) )
1840 elif type
in (
'cms.string',
'cms.untracked.string'):
1842 if self.
_verbose:
print "set string process name %s.%s %s ==> %s"% (base, name, value, self.
_paramReplace)
1844 elif type
in (
'cms.VInputTag',
'cms.untracked.VInputTag'):
1845 for (i,n)
in enumerate(value):
1846 if not isinstance(n, cms.InputTag):
1850 if self.
_verbose:
print "set process name %s.%s[%d] %s ==> %s " % (base, name, i, n, self.
_paramReplace)
1853 elif type
in (
'cms.vstring',
'cms.untracked.vstring'):
1854 for (i,n)
in enumerate(value):
1857 elif type
in (
'cms.InputTag',
'cms.untracked.InputTag'):
1859 if self.
_verbose:
print "set process name %s.%s %s ==> %s " % (base, name, value, self.
_paramReplace)
1860 setattr(getattr(pset, name),
"processName",self.
_paramReplace)
1865 label = visitee.label()
1866 except AttributeError:
1867 label =
'<Module not in a Process>'
1869 label =
'other execption'
1870 self.
doIt(visitee, label)
1877 print "Replacing all InputTag %s => %s"%(oldT,newT)
1880 loadMe=
'from PhysicsTools.PatAlgos.tools.helpers import massSearchReplaceAnyInputTag'
1881 if not loadMe
in self.additionalCommands:
1882 self.additionalCommands.append(loadMe)
1883 self.additionalCommands.append(
'massSearchReplaceAnyInputTag(process.%s,"%s","%s",False,True)'%(sequence,oldT,newT))
1887 if self._options.hltProcess:
1888 proc=self._options.hltProcess
1890 proc=self.process.name_()
1891 if proc==HLTprocess:
return
1893 print "replacing %s process name - sequence %s will use '%s'" % (HLTprocess,sequence, proc)
1895 if 'from Configuration.Applications.ConfigBuilder import ConfigBuilder' not in self.additionalCommands:
1896 self.additionalCommands.append(
'from Configuration.Applications.ConfigBuilder import ConfigBuilder')
1897 self.additionalCommands.append(
'process.%s.visit(ConfigBuilder.MassSearchReplaceProcessNameVisitor("%s", "%s", whitelist = ("subSystemFolder",)))'% (sequence,HLTprocess, proc))
1903 while '@' in repr(seqList)
and level<maxLevel:
1905 for specifiedCommand
in seqList:
1906 if specifiedCommand.startswith(
'@'):
1907 location=specifiedCommand[1:]
1908 if not location
in mapping:
1909 raise Exception(
"Impossible to map "+location+
" from "+repr(mapping))
1910 mappedTo=mapping[location]
1912 mappedTo=mappedTo[index]
1913 seqList.remove(specifiedCommand)
1914 seqList.extend(mappedTo.split(
'+'))
1917 raise Exception(
"Could not fully expand "+repr(seqList)+
" from "+repr(mapping))
1923 sequenceList=sequence.split(
'.')[-1].
split(
'+')
1924 postSequenceList=sequence.split(
'.')[-1].
split(
'+')
1925 from DQMOffline.Configuration.autoDQM
import autoDQM
1929 if len(set(sequenceList))!=len(sequenceList):
1930 sequenceList=
list(set(sequenceList))
1931 print "Duplicate entries for DQM:, using",sequenceList
1933 pathName=
'dqmoffline_step'
1934 for (i,sequence)
in enumerate(sequenceList):
1936 pathName=
'dqmoffline_%d_step'%(i)
1938 if 'HLT' in self.stepMap.keys()
or self._options.hltProcess:
1942 if 'HLT' in self.stepMap.keys():
1944 setattr(self.process,pathName, cms.EndPath( getattr(self.process, sequence ) ) )
1947 setattr(self.process,pathName, cms.Path( getattr(self.process, sequence) ) )
1948 self.schedule.append(getattr(self.process,pathName))
1950 pathName=
'dqmofflineOnPAT_step'
1951 for (i,sequence)
in enumerate(postSequenceList):
1953 pathName=
'dqmofflineOnPAT_%d_step'%(i)
1956 if 'PAT' in self.stepMap.keys():
1958 setattr(self.process,pathName, cms.EndPath( getattr(self.process, sequence ) ) )
1961 setattr(self.process,pathName, cms.Path( getattr(self.process, sequence) ) )
1962 self.schedule.append(getattr(self.process,pathName))
1965 """ Enrich the process with harvesting step """
1966 self.
DQMSaverCFF=
'Configuration/StandardSequences/DQMSaver'+self._options.harvesting+
'_cff'
1970 sequence = sequence.split(
'.')[-1]
1973 harvestingList = sequence.split(
"+")
1974 from DQMOffline.Configuration.autoDQM
import autoDQM
1975 from Validation.Configuration.autoValidation
import autoValidation
1977 combined_mapping = copy.deepcopy( autoDQM )
1978 combined_mapping.update( autoValidation )
1979 self.
expandMapping(harvestingList,combined_mapping,index=-1)
1981 if len(set(harvestingList))!=len(harvestingList):
1982 harvestingList=
list(set(harvestingList))
1983 print "Duplicate entries for HARVESTING, using",harvestingList
1985 for name
in harvestingList:
1986 if not name
in harvestingConfig.__dict__:
1987 print name,
"is not a possible harvesting type. Available are",harvestingConfig.__dict__.keys()
1989 harvestingstream = getattr(harvestingConfig,name)
1990 if isinstance(harvestingstream,cms.Path):
1991 self.schedule.append(harvestingstream)
1992 self.blacklist_paths.append(harvestingstream)
1993 if isinstance(harvestingstream,cms.Sequence):
1994 setattr(self.process,name+
"_step",cms.Path(harvestingstream))
1995 self.schedule.append(getattr(self.process,name+
"_step"))
2001 """ Enrich the process with AlCaHarvesting step """
2003 sequence=sequence.split(
".")[-1]
2006 harvestingList = sequence.split(
"+")
2010 from Configuration.AlCa.autoPCL
import autoPCL
2013 for name
in harvestingConfig.__dict__:
2014 harvestingstream = getattr(harvestingConfig,name)
2015 if name
in harvestingList
and isinstance(harvestingstream,cms.Path):
2016 self.schedule.append(harvestingstream)
2017 self.
executeAndRemember(
"process.PoolDBOutputService.toPut.append(process.ALCAHARVEST" + name +
"_dbOutput)")
2018 self.
executeAndRemember(
"process.pclMetadataWriter.recordsToMap.append(process.ALCAHARVEST" + name +
"_metadata)")
2019 harvestingList.remove(name)
2021 lastStep = getattr(harvestingConfig,
"ALCAHARVESTDQMSaveAndMetadataWriter")
2022 self.schedule.append(lastStep)
2024 if len(harvestingList) != 0
and 'dummyHarvesting' not in harvestingList :
2025 print "The following harvesting could not be found : ", harvestingList
2026 raise Exception(
"The following harvesting could not be found : "+str(harvestingList))
2036 self.process.reconstruction = cms.Path(self.process.reconstructionWithFamos)
2037 self.schedule.append(self.process.reconstruction)
2041 """ Add useful info for the production. """
2042 self.process.configurationMetadata=cms.untracked.PSet\
2043 (version=cms.untracked.string(
"$Revision: 1.19 $"),
2044 name=cms.untracked.string(
"Applications"),
2045 annotation=cms.untracked.string(evt_type+
" nevts:"+str(evtnumber))
2048 self.addedObjects.append((
"Production Info",
"configurationMetadata"))
2052 """ Prepare the configuration string and add missing pieces."""
2064 outputModuleCfgCode=
""
2065 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:
2070 self.pythonCfgCode =
"# Auto generated configuration file\n"
2071 self.pythonCfgCode +=
"# using: \n# "+__version__[1:-1]+
"\n# "+__source__[1:-1]+
'\n'
2072 self.pythonCfgCode +=
"# with command line options: "+self._options.arguments+
'\n'
2073 self.pythonCfgCode +=
"import FWCore.ParameterSet.Config as cms\n\n"
2074 if hasattr(self.
_options,
"era")
and self._options.era :
2075 self.pythonCfgCode +=
"from Configuration.StandardSequences.Eras import eras\n\n"
2076 self.pythonCfgCode +=
"process = cms.Process('"+self.process.name_()+
"'"
2078 for requestedEra
in self._options.era.split(
",") :
2079 self.pythonCfgCode +=
",eras."+requestedEra
2080 self.pythonCfgCode +=
")\n\n"
2082 self.pythonCfgCode +=
"process = cms.Process('"+self.process.name_()+
"')\n\n"
2084 self.pythonCfgCode +=
"# import of standard configurations\n"
2085 for module
in self.imports:
2086 self.pythonCfgCode += (
"process.load('"+module+
"')\n")
2089 if not hasattr(self.process,
"configurationMetadata"):
2093 self.addedObjects.append((
"Production Info",
"configurationMetadata"))
2095 self.pythonCfgCode +=
"\n"
2096 for comment,object
in self.addedObjects:
2098 self.pythonCfgCode +=
"\n# "+comment+
"\n"
2099 self.pythonCfgCode +=
dumpPython(self.process,object)
2102 self.pythonCfgCode +=
"\n# Output definition\n"
2103 self.pythonCfgCode += outputModuleCfgCode
2106 self.pythonCfgCode +=
"\n# Additional output definition\n"
2108 nl=self.additionalOutputs.keys()
2111 output = self.additionalOutputs[name]
2112 self.pythonCfgCode +=
"process.%s = %s" %(name, output.dumpPython())
2113 tmpOut = cms.EndPath(output)
2114 setattr(self.process,name+
'OutPath',tmpOut)
2115 self.schedule.append(tmpOut)
2118 self.pythonCfgCode +=
"\n# Other statements\n"
2119 for command
in self.additionalCommands:
2120 self.pythonCfgCode += command +
"\n"
2123 for object
in self._options.inlineObjets.split(
','):
2126 if not hasattr(self.process,object):
2127 print 'cannot inline -'+object+
'- : not known'
2129 self.pythonCfgCode +=
'\n'
2130 self.pythonCfgCode +=
dumpPython(self.process,object)
2133 self.pythonCfgCode +=
"\n# Path and EndPath definitions\n"
2134 for path
in self.process.paths:
2135 if getattr(self.process,path)
not in self.blacklist_paths:
2136 self.pythonCfgCode +=
dumpPython(self.process,path)
2138 for endpath
in self.process.endpaths:
2139 if getattr(self.process,endpath)
not in self.blacklist_paths:
2140 self.pythonCfgCode +=
dumpPython(self.process,endpath)
2143 self.pythonCfgCode +=
"\n# Schedule definition\n"
2144 result =
"process.schedule = cms.Schedule("
2147 self.process.schedule = cms.Schedule()
2148 for item
in self.schedule:
2149 if not isinstance(item, cms.Schedule):
2150 self.process.schedule.append(item)
2152 self.process.schedule.extend(item)
2154 if hasattr(self.process,
"HLTSchedule"):
2155 beforeHLT = self.schedule[:self.schedule.index(self.process.HLTSchedule)]
2156 afterHLT = self.schedule[self.schedule.index(self.process.HLTSchedule)+1:]
2157 pathNames = [
'process.'+p.label_()
for p
in beforeHLT]
2158 result +=
','.
join(pathNames)+
')\n'
2159 result +=
'process.schedule.extend(process.HLTSchedule)\n'
2160 pathNames = [
'process.'+p.label_()
for p
in afterHLT]
2161 result +=
'process.schedule.extend(['+
','.
join(pathNames)+
'])\n'
2163 pathNames = [
'process.'+p.label_()
for p
in self.schedule]
2164 result =
'process.schedule = cms.Schedule('+
','.
join(pathNames)+
')\n'
2166 self.pythonCfgCode += result
2168 if self._options.nThreads
is not "1":
2169 self.pythonCfgCode +=
"\n"
2170 self.pythonCfgCode +=
"#Setup FWK for multithreaded\n"
2171 self.pythonCfgCode +=
"process.options.numberOfThreads=cms.untracked.uint32("+self._options.nThreads+
")\n"
2172 self.pythonCfgCode +=
"process.options.numberOfStreams=cms.untracked.uint32(0)\n"
2174 if self._options.isRepacked:
2175 self.pythonCfgCode +=
"\n"
2176 self.pythonCfgCode +=
"from Configuration.Applications.ConfigBuilder import MassReplaceInputTag\n"
2177 self.pythonCfgCode +=
"MassReplaceInputTag(process)\n"
2181 if self.productionFilterSequence:
2182 self.pythonCfgCode +=
'# filter all path with the production filter sequence\n'
2183 self.pythonCfgCode +=
'for path in process.paths:\n'
2184 if len(self.conditionalPaths):
2185 self.pythonCfgCode +=
'\tif not path in %s: continue\n'%str(self.conditionalPaths)
2186 if len(self.excludedPaths):
2187 self.pythonCfgCode +=
'\tif path in %s: continue\n'%str(self.excludedPaths)
2188 self.pythonCfgCode +=
'\tgetattr(process,path)._seq = process.%s * getattr(process,path)._seq \n'%(self.productionFilterSequence,)
2189 pfs = getattr(self.process,self.productionFilterSequence)
2190 for path
in self.process.paths:
2191 if not path
in self.conditionalPaths:
continue
2192 if path
in self.excludedPaths:
continue
2193 getattr(self.process,path)._seq = pfs * getattr(self.process,path)._seq
2199 if self._options.runUnscheduled:
2202 self.pythonCfgCode+=
"#do not add changes to your config after this point (unless you know what you are doing)\n"
2203 self.pythonCfgCode+=
"from FWCore.ParameterSet.Utilities import convertToUnscheduled\n"
2204 self.pythonCfgCode+=
"process=convertToUnscheduled(process)\n"
2206 from FWCore.ParameterSet.Utilities
import convertToUnscheduled
2210 for module
in self.importsUnsch:
2211 self.process.load(module)
2212 self.pythonCfgCode += (
"process.load('"+module+
"')\n")
2215 self.pythonCfgCode+=
"from FWCore.ParameterSet.Utilities import cleanUnscheduled\n"
2216 self.pythonCfgCode+=
"process=cleanUnscheduled(process)\n"
2218 from FWCore.ParameterSet.Utilities
import cleanUnscheduled
2227 if self._options.io:
2229 if not self._options.io.endswith(
'.io'): self._option.io+=
'.io'
2230 io=open(self._options.io,
'w')
2232 if hasattr(self.process.source,
"fileNames"):
2233 if len(self.process.source.fileNames.value()):
2234 ioJson[
'primary']=self.process.source.fileNames.value()
2235 if hasattr(self.process.source,
"secondaryFileNames"):
2236 if len(self.process.source.secondaryFileNames.value()):
2237 ioJson[
'secondary']=self.process.source.secondaryFileNames.value()
2238 if self._options.pileup_input
and (self._options.pileup_input.startswith(
'dbs:')
or self._options.pileup_input.startswith(
'das:')):
2239 ioJson[
'pileup']=self._options.pileup_input[4:]
2240 for (o,om)
in self.process.outputModules_().items():
2241 ioJson[o]=om.fileName.value()
2242 ioJson[
'GT']=self.process.GlobalTag.globaltag.value()
2243 if self.productionFilterSequence:
2244 ioJson[
'filter']=self.productionFilterSequence
2246 io.write(json.dumps(ioJson))
def renameInputTagsInSequence
bool any(const std::vector< T > &v, const T &what)
def scheduleSequenceAtEnd
def visit
Retrieve data from a perf suite output (sub) directory, only examines TimeSize at the moment...
def prepare_RECO
put the filtering path in the schedule
def doNotInlineEventContent
def massSearchReplaceAnyInputTag
def build_production_info
def prepare_L1TrackTrigger
print it in the configuration
inliner
needs to be in reverse order
static std::string join(char **cmd)
def loadDefaultOrSpecifiedCFF
def prepare_DIGIPREMIX_S2
def renameHLTprocessInSequence
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run