|
|
Go to the documentation of this file.
3 from __future__
import absolute_import
8 from .pipe
import pipe
as _pipe
9 from .options
import globalTag
10 from itertools
import islice
14 i = iterator.__iter__()
16 l = list(islice(i, n))
44 self.
labels[
'process'] =
'fragment'
45 self.
labels[
'dict'] =
'fragment.__dict__'
47 self.
labels[
'process'] =
'process'
48 self.
labels[
'dict'] =
'process.__dict__'
50 if self.
config.prescale
and (self.
config.prescale.lower() !=
'none'):
54 from .confdbOfflineConverter
import OfflineConverter
66 if ".py" in self.
config.setup:
67 self.
config.setupFile = self.
config.setup.split(
".py")[0]
69 args = [
'--configName', self.
config.setup ]
70 args.append(
'--noedsources')
71 args.append(
'--nopaths')
72 for key, vals
in six.iteritems(self.
options):
74 args.extend((
'--'+key,
','.
join(vals)))
77 if 'ERROR' in err
or 'Exhausted Resultset' in err
or 'CONFIG_NOT_FOUND' in err:
78 sys.stderr.write(
"%s: error while retrieving the HLT setup menu\n\n" % os.path.basename(sys.argv[0]))
79 sys.stderr.write(err +
"\n\n")
82 file(self.
config.setupFile+
".py",
"w+").
write(
"# This file is automatically generated by hltGetConfiguration.\n" + data)
86 args = [
'--runNumber', self.
config.menu.run]
88 args = [
'--configName', self.
config.menu.name ]
91 args.append(
'--noedsources')
92 for key, vals
in six.iteritems(self.
options):
94 args.extend((
'--'+key,
','.
join(vals)))
97 if 'ERROR' in err
or 'Exhausted Resultset' in err
or 'CONFIG_NOT_FOUND' in err:
98 sys.stderr.write(
"%s: error while retrieving the HLT menu\n\n" % os.path.basename(sys.argv[0]))
99 sys.stderr.write(err +
"\n\n")
105 args = [
'--runNumber', self.
config.menu.run]
107 args = [
'--configName', self.
config.menu.name]
118 if 'ERROR' in err
or 'Exhausted Resultset' in err
or 'CONFIG_NOT_FOUND' in err:
119 sys.stderr.write(
"%s: error while retrieving the list of paths from the HLT menu\n\n" % os.path.basename(sys.argv[0]))
120 sys.stderr.write(err +
"\n\n")
122 filter = re.compile(
r' *= *cms.(End)?Path.*')
123 paths = [ filter.sub(
'', line)
for line
in data.splitlines()
if filter.search(line) ]
138 filter = re.compile(
r'^' + glob.replace(
'?',
'.').
replace(
'*',
'.*').
replace(
'[!',
'[^') +
r'$')
139 matches.extend( negate + element
for element
in collection
if filter.match(element) )
148 for element
in elements:
149 if element[0] ==
'-':
150 result.add( element )
152 result.discard(
'-' + element )
153 return sorted( element
for element
in result )
160 for element
in elements:
161 if element[0] ==
'-':
162 result.discard( element[1:] )
164 result.add( element )
165 return sorted( element
for element
in result )
172 self.
data = re.sub(
r'\bprocess\b',
'fragment', self.
data )
173 self.
data = re.sub(
r'\bProcess\b',
'ProcessFragment', self.
data )
182 # add specific customizations
183 from HLTrigger.Configuration.customizeHLTforALL import customizeHLTforAll
184 fragment = customizeHLTforAll(fragment,"%s")
190 if self.
config.type==
"Fake":
192 elif self.
config.type
in (
"Fake1",
"Fake2",
"2018"):
196 _gtData =
"auto:"+prefix+
"_hlt_"+self.
config.type
197 _gtMc =
"auto:"+prefix+
"_mc_" +self.
config.type
199 # add specific customizations
201 _customInfo['menuType' ]= "%s"
202 _customInfo['globalTags']= {}
203 _customInfo['globalTags'][True ] = "%s"
204 _customInfo['globalTags'][False] = "%s"
205 _customInfo['inputFiles']={}
206 _customInfo['inputFiles'][True] = "file:RelVal_Raw_%s_DATA.root"
207 _customInfo['inputFiles'][False] = "file:RelVal_Raw_%s_MC.root"
208 _customInfo['maxEvents' ]= %s
209 _customInfo['globalTag' ]= "%s"
210 _customInfo['inputFile' ]= %s
211 _customInfo['realData' ]= %s
212 from HLTrigger.Configuration.customizeHLTforALL import customizeHLTforAll
213 %%(process)s = customizeHLTforAll(%%(process)s,"%s",_customInfo)
217 from HLTrigger.Configuration.customizeHLTforCMSSW import customizeHLTforCMSSW
218 %%(process)s = customizeHLTforCMSSW(%%(process)s,"%s")
223 # Eras-based customisations
224 from HLTrigger.Configuration.Eras import modifyHLTforEras
225 modifyHLTforEras(%(process)s)
230 self.
data +=
"#User-defined customization functions\n"
231 for customise
in self.
config.customise.split(
","):
232 customiseValues = customise.split(
".")
233 if len(customiseValues)>=3:
raise Exception(
"--customise option cannot contain more than one dot.")
234 if len(customiseValues)==1:
235 customiseValues.append(
"customise")
236 customiseValues[0] = customiseValues[0].
replace(
"/",
".")
237 self.
data +=
"from "+customiseValues[0]+
" import "+customiseValues[1]+
"\n"
238 self.
data +=
"process = "+customiseValues[1]+
"(process)\n"
245 if not self.
config.fragment:
249 if self.
config.type
in (
'HIon', ):
251 if not self.
config.fragment:
252 self.
_fix_parameter( type =
'InputTag', value =
'rawDataCollector', replace =
'rawDataRepacker')
277 # dummify hltGetConditions in cff's
278 if 'hltGetConditions' in %(dict)s and 'HLTriggerFirstPath' in %(dict)s :
279 %(process)s.hltDummyConditions = cms.EDFilter( "HLTBool",
280 result = cms.bool( True )
282 %(process)s.HLTriggerFirstPath.replace(%(process)s.hltGetConditions,%(process)s.hltDummyConditions)
287 match = re.match(
r'(Scouting\w+)Output$', path)
289 module =
'hltOutput' + match.group(1)
290 self.
data = self.
data.
replace(path+
' = cms.EndPath', path+
' = cms.Path')
323 # limit the number of events to be processed
324 %%(process)s.maxEvents = cms.untracked.PSet(
325 input = cms.untracked.int32( %d )
330 # enable TrigReport, TimeReport and MultiThreading
331 %(process)s.options = cms.untracked.PSet(
332 wantSummary = cms.untracked.bool( True ),
333 numberOfThreads = cms.untracked.uint32( 4 ),
334 numberOfStreams = cms.untracked.uint32( 0 ),
340 name: parameter name (optional)
341 type: parameter type (look for tracked and untracked variants)
342 value: original value
343 replace: replacement value
347 r'%(name)s = cms(?P<tracked>(?:\.untracked)?)\.%(type)s\( (?P<quote>["\']?)%(value)s(?P=quote)' % args,
348 r'%(name)s = cms\g<tracked>.%(type)s( \g<quote>%(replace)s\g<quote>' % args,
352 r'cms(?P<tracked>(?:\.untracked)?)\.%(type)s\( (?P<quote>["\']?)%(value)s(?P=quote)' % args,
353 r'cms\g<tracked>.%(type)s( \g<quote>%(replace)s\g<quote>' % args,
360 if self.
options[
'paths'][0][0] ==
'-':
362 for minuspath
in self.
options[
'paths']:
364 self.
data = re.sub(
r' cms.PSet\( pathName = cms.string\( "%s" \),\n prescales = cms.vuint32\( .* \)\n \),?\n' % path,
'', self.
data)
368 if path
not in self.
options[
'paths']:
369 self.
data = re.sub(
r' cms.PSet\( pathName = cms.string\( "%s" \),\n prescales = cms.vuint32\( .* \)\n \),?\n' % path,
'', self.
data)
371 if self.
config.prescale
and (self.
config.prescale.lower() !=
'none'):
374 # force the use of a specific HLT prescale column
375 if 'PrescaleService' in %(dict)s:
376 %(process)s.PrescaleService.forceDefault = True
377 %(process)s.PrescaleService.lvl1DefaultLabel = '%(prescale)s'
384 filters = [ match[1]
for match
in re.findall(
r'(process\.)?\b(\w+) = cms.EDFilter', self.
data) ]
385 re_sequence = re.compile(
r'cms\.(Path|Sequence)\((.*)\)' )
387 self.
data = re_sequence.sub(
lambda line: re.sub(
r'cms\.ignore *\( *((process\.)?\b(\w+)) *\)',
r'\1', line.group(0) ), self.
data )
388 self.
data = re_sequence.sub(
lambda line: re.sub(
r'~',
'', line.group(0) ), self.
data )
390 for some
in splitter(filters, 1000):
391 re_filters = re.compile(
r'\b((process\.)?(' +
r'|'.
join(some) +
r'))\b' )
392 self.
data = re_sequence.sub(
lambda line: re_filters.sub(
r'cms.ignore( \1 )', line.group(0) ), self.
data )
398 self.
_fix_parameter(name =
'SelectedTriggerType', type =
'int32', value =
'1', replace =
'0')
399 self.
_fix_parameter(name =
'SelectedTriggerType', type =
'int32', value =
'2', replace =
'0')
400 self.
_fix_parameter(name =
'SelectedTriggerType', type =
'int32', value =
'3', replace =
'0')
417 if self.
config.type
in globalTag:
420 self.
config.globaltag = globalTag[
'GRun']
423 if self.
config.l1.override:
425 self.
config.l1.record =
'L1TUtmTriggerMenuRcd'
426 self.
config.l1.connect =
''
428 if not self.
config.l1.snapshotTime:
429 self.
config.l1.snapshotTime =
'9999-12-31 23:59:59.000'
430 self.
config.l1cond =
'%(tag)s,%(record)s,%(connect)s,%(label)s,%(snapshotTime)s' % self.
config.l1.__dict__
436 # override the GlobalTag, connection string and pfnPrefix
437 if 'GlobalTag' in %(dict)s:
438 from Configuration.AlCa.GlobalTag import GlobalTag as customiseGlobalTag
439 %(process)s.GlobalTag = customiseGlobalTag(%(process)s.GlobalTag"""
441 text +=
", globaltag = %s" % repr(self.
config.globaltag)
443 text +=
", conditions = %s" % repr(self.
config.l1cond)
449 if self.
config.l1Xml.XmlFile:
451 # override the GlobalTag's L1T menu from an Xml file
452 from HLTrigger.Configuration.CustomConfigs import L1XML
453 %%(process)s = L1XML(%%(process)s,"%s")
454 """ % (self.
config.l1Xml.XmlFile)
461 # run the Full L1T emulator, then repack the data into a new RAW collection, to be used by the HLT
462 from HLTrigger.Configuration.CustomConfigs import L1REPACK
463 %%(process)s = L1REPACK(%%(process)s,"%s")
464 """ % (self.
config.emulator)
469 if not self.
config.hilton:
471 r'\b(process\.)?hltOutput(\w+) *= *cms\.OutputModule\( *"ShmStreamConsumer" *,',
472 r'%(process)s.hltOutput\2 = cms.OutputModule( "PoolOutputModule",\n fileName = cms.untracked.string( "output\2.root" ),\n fastCloning = cms.untracked.bool( False ),\n dataset = cms.untracked.PSet(\n filterName = cms.untracked.string( "" ),\n dataTier = cms.untracked.string( "RAW" )\n ),',
476 if not self.
config.fragment
and self.
config.output ==
'minimal':
479 # add a single "keep *" output
480 %(process)s.hltOutputMinimal = cms.OutputModule( "PoolOutputModule",
481 fileName = cms.untracked.string( "output.root" ),
482 fastCloning = cms.untracked.bool( False ),
483 dataset = cms.untracked.PSet(
484 dataTier = cms.untracked.string( 'AOD' ),
485 filterName = cms.untracked.string( '' )
487 outputCommands = cms.untracked.vstring( 'drop *',
488 'keep edmTriggerResults_*_*_*',
489 'keep triggerTriggerEvent_*_*_*'
492 %(process)s.MinimalOutput = cms.EndPath( %(process)s.hltOutputMinimal )
494 elif not self.
config.fragment
and self.
config.output ==
'full':
497 # add a single "keep *" output
498 %(process)s.hltOutputFull = cms.OutputModule( "PoolOutputModule",
499 fileName = cms.untracked.string( "output.root" ),
500 fastCloning = cms.untracked.bool( False ),
501 dataset = cms.untracked.PSet(
502 dataTier = cms.untracked.string( 'RECO' ),
503 filterName = cms.untracked.string( '' )
505 outputCommands = cms.untracked.vstring( 'keep *' )
507 %(process)s.FullOutput = cms.EndPath( %(process)s.hltOutputFull )
512 if self.
config.eras
is None:
514 from Configuration.StandardSequences.Eras
import eras
515 erasSplit = self.
config.eras.split(
',')
516 self.
data = re.sub(
r'process = cms.Process\( *"\w+"',
'\n'.
join(eras.pythonCfgLines[era]
for era
in erasSplit)+
'\n\g<0>, '+
', '.
join(era
for era
in erasSplit), self.
data)
520 if self.
config.setup
is None:
523 self.
data = self.
data[:processLine]+
'\nprocess.load("%s")'%self.
config.setupFile+self.
data[processLine:]
527 if self.
config.name
is None:
534 self.
data = re.compile(
r'^(process\s*=\s*cms\.Process\(\s*' + quote +
r')\w+(' + quote +
r'\s*\).*)$', re.MULTILINE).sub(
r'\1%s\2' % self.
config.name, self.
data, 1)
538 # avoid PrescaleService error due to missing HLT paths
539 if 'PrescaleService' in process.__dict__:
540 for pset in reversed(process.PrescaleService.prescaleTable):
541 if not hasattr(process,pset.pathName.value()):
542 process.PrescaleService.prescaleTable.remove(pset)
549 if 'MessageLogger' in %(dict)s:
550 %(process)s.MessageLogger.TriggerSummaryProducerAOD = cms.untracked.PSet()
551 %(process)s.MessageLogger.L1GtTrigReport = cms.untracked.PSet()
552 %(process)s.MessageLogger.L1TGlobalSummary = cms.untracked.PSet()
553 %(process)s.MessageLogger.HLTrigReport = cms.untracked.PSet()
554 %(process)s.MessageLogger.FastReport = cms.untracked.PSet()
555 %(process)s.MessageLogger.ThroughputService = cms.untracked.PSet()
563 if 'GlobalTag' in %%(dict)s:
565 for condition
in conditions:
566 self.
data +=
""" %%(process)s.GlobalTag.toGet.append(
568 record = cms.string( '%(record)s' ),
569 tag = cms.string( '%(tag)s' ),
570 label = cms.untracked.string( '%(label)s' ),
579 return 'from %s import *\n' % module
581 return 'process.load( "%s" )\n' % module
589 self.
data +=
"if '%s' in %%(dict)s:\n" % module
590 for (parameter, value)
in parameters:
591 self.
data +=
" %%(process)s.%s.%s = %s\n" % (module, parameter, value)
599 # instrument the menu with the modules and EndPath needed for timing studies
602 self.
data +=
'\n# configure the FastTimerService\n'
603 self.
loadCff(
'HLTrigger.Timer.FastTimerService_cfi')
605 self.
data +=
"""# print a text summary at the end of the job
606 %(process)s.FastTimerService.printEventSummary = False
607 %(process)s.FastTimerService.printRunSummary = False
608 %(process)s.FastTimerService.printJobSummary = True
611 %(process)s.FastTimerService.enableDQM = True
613 # enable per-path DQM plots (starting with CMSSW 9.2.3-patch2)
614 %(process)s.FastTimerService.enableDQMbyPath = True
616 # enable per-module DQM plots
617 %(process)s.FastTimerService.enableDQMbyModule = True
619 # enable per-event DQM plots vs lumisection
620 %(process)s.FastTimerService.enableDQMbyLumiSection = True
621 %(process)s.FastTimerService.dqmLumiSectionsRange = 2500
623 # set the time resolution of the DQM plots
624 %(process)s.FastTimerService.dqmTimeRange = 2000.
625 %(process)s.FastTimerService.dqmTimeResolution = 10.
626 %(process)s.FastTimerService.dqmPathTimeRange = 1000.
627 %(process)s.FastTimerService.dqmPathTimeResolution = 5.
628 %(process)s.FastTimerService.dqmModuleTimeRange = 200.
629 %(process)s.FastTimerService.dqmModuleTimeResolution = 1.
631 # set the base DQM folder for the plots
632 %(process)s.FastTimerService.dqmPath = 'HLT/TimerService'
633 %(process)s.FastTimerService.enableDQMbyProcesses = False
638 if not self.
config.hilton:
640 if 'hltDQMFileSaver' in self.
data:
641 self.
data = re.sub(
r'\b(process\.)?hltDQMFileSaver \+ ',
'', self.
data)
642 self.
data = re.sub(
r' \+ \b(process\.)?hltDQMFileSaver',
'', self.
data)
643 self.
data = re.sub(
r'\b(process\.)?hltDQMFileSaver',
'', self.
data)
646 dqmstore =
"\n# load the DQMStore and DQMRootOutputModule\n"
649 %(process)s.dqmOutput = cms.OutputModule("DQMRootOutputModule",
650 fileName = cms.untracked.string("DQMIO.root")
654 empty_path = re.compile(
r'.*\b(process\.)?DQMOutput = cms\.EndPath\( *\).*')
655 other_path = re.compile(
r'(.*\b(process\.)?DQMOutput = cms\.EndPath\()(.*)')
656 if empty_path.search(self.
data):
658 self.
data = empty_path.sub(dqmstore +
'\n%(process)s.DQMOutput = cms.EndPath( %(process)s.dqmOutput )\n', self.
data)
659 elif other_path.search(self.
data):
661 self.
data = other_path.sub(dqmstore +
r'\g<1> %(process)s.dqmOutput +\g<3>', self.
data)
664 self.
data += dqmstore
665 self.
data +=
'\n%(process)s.DQMOutput = cms.EndPath( %(process)s.dqmOutput )\n'
670 sys.stderr.write(
'Path selection:\n')
672 sys.stderr.write(
'\t%s\n' % path)
673 sys.stderr.write(
'\n\n')
680 paths = self.
config.paths.split(
',')
690 if self.
config.fragment
or self.
config.output
in (
'none', ):
696 paths.append(
"-*Output" )
697 paths.append(
"-RatesMonitoring")
698 paths.append(
"-DQMHistograms")
699 if self.
config.fragment: paths.append(
"Scouting*Output" )
701 elif self.
config.output
in (
'dqm',
'minimal',
'full'):
704 paths.append(
"DQMHistograms" )
707 paths.append(
"-*Output" )
708 paths.append(
"-RatesMonitoring")
709 if self.
config.fragment: paths.append(
"Scouting*Output" )
714 paths.append(
"*Output" )
715 paths.append(
"DQMHistograms" )
722 paths.append(
"-HLTAnalyzerEndpath" )
725 paths.append(
"-OfflineOutput" )
734 raise RuntimeError(
'Error: option "--paths %s" does not select any valid paths' % self.
config.paths)
750 if not self.
config.hilton:
760 self.
options[
'essources'].
append(
"-XMLIdealGeometryESSource" )
779 self.
options[
'esmodules'].
append(
"-CaloTowerHardcodeGeometryEP" )
780 self.
options[
'esmodules'].
append(
"-CastorHardcodeGeometryEP" )
783 self.
options[
'esmodules'].
append(
"-EcalElectronicsMappingBuilder" )
785 self.
options[
'esmodules'].
append(
"-EcalLaserCorrectionService" )
786 self.
options[
'esmodules'].
append(
"-EcalPreshowerGeometryEP" )
787 self.
options[
'esmodules'].
append(
"-HcalHardcodeGeometryEP" )
789 self.
options[
'esmodules'].
append(
"-MuonNumberingInitialization" )
790 self.
options[
'esmodules'].
append(
"-ParametrizedMagneticFieldProducer" )
793 self.
options[
'esmodules'].
append(
"-SiStripRecHitMatcherESProducer" )
794 self.
options[
'esmodules'].
append(
"-SiStripQualityESProducer" )
795 self.
options[
'esmodules'].
append(
"-StripCPEfromTrackAngleESProducer" )
796 self.
options[
'esmodules'].
append(
"-TrackerDigiGeometryESModule" )
797 self.
options[
'esmodules'].
append(
"-TrackerGeometricDetESModule" )
798 self.
options[
'esmodules'].
append(
"-VolumeBasedMagneticFieldESProducer" )
801 self.
options[
'esmodules'].
append(
"-L1GtTriggerMaskAlgoTrigTrivialProducer" )
802 self.
options[
'esmodules'].
append(
"-L1GtTriggerMaskTechTrigTrivialProducer" )
803 self.
options[
'esmodules'].
append(
"-hltESPEcalTrigTowerConstituentsMapBuilder" )
804 self.
options[
'esmodules'].
append(
"-hltESPGlobalTrackingGeometryESProducer" )
805 self.
options[
'esmodules'].
append(
"-hltESPMuonDetLayerGeometryESProducer" )
806 self.
options[
'esmodules'].
append(
"-hltESPTrackerRecoGeometryESProducer" )
809 self.
options[
'esmodules'].
append(
"-CaloTowerGeometryFromDBEP" )
810 self.
options[
'esmodules'].
append(
"-CastorGeometryFromDBEP" )
811 self.
options[
'esmodules'].
append(
"-EcalBarrelGeometryFromDBEP" )
812 self.
options[
'esmodules'].
append(
"-EcalEndcapGeometryFromDBEP" )
813 self.
options[
'esmodules'].
append(
"-EcalPreshowerGeometryFromDBEP" )
825 self.
options[
'modules'].
append(
"-hltOutputScoutingCaloMuon" )
828 if self.
config.fragment
or (self.
config.prescale
and (self.
config.prescale.lower() ==
'none')):
836 if len(filenames) > 255:
843 self.
data +=
" %s = cms.untracked.vstring%s\n" % (name, token_open)
844 for line
in filenames:
845 self.
data +=
" '%s',\n" % line
846 self.
data +=
" %s,\n" % (token_close)
851 if input[0:8] ==
'dataset:':
852 from .dasFileQuery
import dasFileQuery
858 files = input.split(
',')
871 self.
source = [
"file:RelVal_Raw_%s_DATA.root" % self.
config.type ]
874 self.
source = [
"file:RelVal_Raw_%s_MC.root" % self.
config.type ]
881 %(process)s.source = cms.Source( "PoolSource",
887 inputCommands = cms.untracked.vstring(
def specificCustomize(self)
def loadCffCommand(self, module)
def getRawConfigurationFromDB(self)
def loadAdditionalConditions(self, comment, *conditions)
def consolidatePositiveList(elements)
static std::string join(char **cmd)
def instrumentOpenMode(self)
def overrideParameters(self, module, parameters)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
def consolidateNegativeList(elements)
def append_filenames(self, name, filenames)
def expandWildcards(globs, collection)
def getSetupConfigurationFromDB(self)
def _fix_parameter(self, **args)
def overrideProcessName(self)
def splitter(iterator, n)
def instrumentErrorEventType(self)
def __init__(self, configuration)
def instrumentTiming(self)
def addGlobalOptions(self)
def expand_filenames(self, input)
def overrideGlobalTag(self)
def overrideL1MenuXml(self)
def loadCff(self, module)
def updateMessageLogger(self)
def replace(string, replacements)