|
|
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 ]
89 args.append(
'--noedsources')
90 for key, vals
in six.iteritems(self.
options):
92 args.extend((
'--'+key,
','.
join(vals)))
95 if 'ERROR' in err
or 'Exhausted Resultset' in err
or 'CONFIG_NOT_FOUND' in err:
96 sys.stderr.write(
"%s: error while retrieving the HLT menu\n\n" % os.path.basename(sys.argv[0]))
97 sys.stderr.write(err +
"\n\n")
103 args = [
'--runNumber', self.
config.menu.run]
105 args = [
'--configName', self.
config.menu.name]
116 if 'ERROR' in err
or 'Exhausted Resultset' in err
or 'CONFIG_NOT_FOUND' in err:
117 sys.stderr.write(
"%s: error while retrieving the list of paths from the HLT menu\n\n" % os.path.basename(sys.argv[0]))
118 sys.stderr.write(err +
"\n\n")
120 filter = re.compile(
r' *= *cms.(End)?Path.*')
121 paths = [ filter.sub(
'', line)
for line
in data.splitlines()
if filter.search(line) ]
136 filter = re.compile(
r'^' + glob.replace(
'?',
'.').
replace(
'*',
'.*').
replace(
'[!',
'[^') +
r'$')
137 matches.extend( negate + element
for element
in collection
if filter.match(element) )
146 for element
in elements:
147 if element[0] ==
'-':
148 result.add( element )
150 result.discard(
'-' + element )
151 return sorted( element
for element
in result )
158 for element
in elements:
159 if element[0] ==
'-':
160 result.discard( element[1:] )
162 result.add( element )
163 return sorted( element
for element
in result )
170 self.
data = re.sub(
r'\bprocess\b',
'fragment', self.
data )
171 self.
data = re.sub(
r'\bProcess\b',
'ProcessFragment', self.
data )
180 # add specific customizations
181 from HLTrigger.Configuration.customizeHLTforALL import customizeHLTforAll
182 fragment = customizeHLTforAll(fragment,"%s")
185 if self.
config.type==
"Fake":
187 elif self.
config.type
in (
"Fake1",
"Fake2",
"2018"):
191 _gtData =
"auto:"+prefix+
"_hlt_"+self.
config.type
192 _gtMc =
"auto:"+prefix+
"_mc_" +self.
config.type
194 # add specific customizations
196 _customInfo['menuType' ]= "%s"
197 _customInfo['globalTags']= {}
198 _customInfo['globalTags'][True ] = "%s"
199 _customInfo['globalTags'][False] = "%s"
200 _customInfo['inputFiles']={}
201 _customInfo['inputFiles'][True] = "file:RelVal_Raw_%s_DATA.root"
202 _customInfo['inputFiles'][False] = "file:RelVal_Raw_%s_MC.root"
203 _customInfo['maxEvents' ]= %s
204 _customInfo['globalTag' ]= "%s"
205 _customInfo['inputFile' ]= %s
206 _customInfo['realData' ]= %s
207 from HLTrigger.Configuration.customizeHLTforALL import customizeHLTforAll
208 %%(process)s = customizeHLTforAll(%%(process)s,"%s",_customInfo)
212 from HLTrigger.Configuration.customizeHLTforCMSSW import customizeHLTforCMSSW
213 %%(process)s = customizeHLTforCMSSW(%%(process)s,"%s")
218 # Eras-based customisations
219 from HLTrigger.Configuration.Eras import modifyHLTforEras
220 modifyHLTforEras(%(process)s)
225 self.
data +=
"#User-defined customization functions\n"
226 for customise
in self.
config.customise.split(
","):
227 customiseValues = customise.split(
".")
228 if len(customiseValues)>=3:
raise Exception(
"--customise option cannot contain more than one dot.")
229 if len(customiseValues)==1:
230 customiseValues.append(
"customise")
231 customiseValues[0] = customiseValues[0].
replace(
"/",
".")
232 self.
data +=
"from "+customiseValues[0]+
" import "+customiseValues[1]+
"\n"
233 self.
data +=
"process = "+customiseValues[1]+
"(process)\n"
239 if not self.
config.fragment:
243 if self.
config.type
in (
'HIon', ):
245 if not self.
config.fragment:
246 self.
_fix_parameter( type =
'InputTag', value =
'rawDataCollector', replace =
'rawDataRepacker')
271 # dummyfy hltGetConditions in cff's
272 if 'hltGetConditions' in %(dict)s and 'HLTriggerFirstPath' in %(dict)s :
273 %(process)s.hltDummyConditions = cms.EDFilter( "HLTBool",
274 result = cms.bool( True )
276 %(process)s.HLTriggerFirstPath.replace(%(process)s.hltGetConditions,%(process)s.hltDummyConditions)
281 match = re.match(
r'(Scouting\w+)Output$', path)
283 module =
'hltOutput' + match.group(1)
284 self.
data = self.
data.
replace(path+
' = cms.EndPath', path+
' = cms.Path')
317 # limit the number of events to be processed
318 %%(process)s.maxEvents = cms.untracked.PSet(
319 input = cms.untracked.int32( %d )
324 # enable TrigReport, TimeReport and MultiThreading
325 %(process)s.options = cms.untracked.PSet(
326 wantSummary = cms.untracked.bool( True ),
327 numberOfThreads = cms.untracked.uint32( 4 ),
328 numberOfStreams = cms.untracked.uint32( 0 ),
329 sizeOfStackForThreadsInKB = cms.untracked.uint32( 10*1024 )
335 name: parameter name (optional)
336 type: parameter type (look for tracked and untracked variants)
337 value: original value
338 replace: replacement value
342 r'%(name)s = cms(?P<tracked>(?:\.untracked)?)\.%(type)s\( (?P<quote>["\']?)%(value)s(?P=quote)' % args,
343 r'%(name)s = cms\g<tracked>.%(type)s( \g<quote>%(replace)s\g<quote>' % args,
347 r'cms(?P<tracked>(?:\.untracked)?)\.%(type)s\( (?P<quote>["\']?)%(value)s(?P=quote)' % args,
348 r'cms\g<tracked>.%(type)s( \g<quote>%(replace)s\g<quote>' % args,
355 if self.
options[
'paths'][0][0] ==
'-':
357 for minuspath
in self.
options[
'paths']:
359 self.
data = re.sub(
r' cms.PSet\( pathName = cms.string\( "%s" \),\n prescales = cms.vuint32\( .* \)\n \),?\n' % path,
'', self.
data)
363 if path
not 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)
366 if self.
config.prescale
and (self.
config.prescale.lower() !=
'none'):
369 # force the use of a specific HLT prescale column
370 if 'PrescaleService' in %(dict)s:
371 %(process)s.PrescaleService.forceDefault = True
372 %(process)s.PrescaleService.lvl1DefaultLabel = '%(prescale)s'
379 filters = [ match[1]
for match
in re.findall(
r'(process\.)?\b(\w+) = cms.EDFilter', self.
data) ]
380 re_sequence = re.compile(
r'cms\.(Path|Sequence)\((.*)\)' )
382 self.
data = re_sequence.sub(
lambda line: re.sub(
r'cms\.ignore *\( *((process\.)?\b(\w+)) *\)',
r'\1', line.group(0) ), self.
data )
383 self.
data = re_sequence.sub(
lambda line: re.sub(
r'~',
'', line.group(0) ), self.
data )
385 for some
in splitter(filters, 1000):
386 re_filters = re.compile(
r'\b((process\.)?(' +
r'|'.
join(some) +
r'))\b' )
387 self.
data = re_sequence.sub(
lambda line: re_filters.sub(
r'cms.ignore( \1 )', line.group(0) ), self.
data )
393 self.
_fix_parameter(name =
'SelectedTriggerType', type =
'int32', value =
'1', replace =
'0')
394 self.
_fix_parameter(name =
'SelectedTriggerType', type =
'int32', value =
'2', replace =
'0')
395 self.
_fix_parameter(name =
'SelectedTriggerType', type =
'int32', value =
'3', replace =
'0')
412 if self.
config.type
in globalTag:
415 self.
config.globaltag = globalTag[
'GRun']
418 if self.
config.l1.override:
420 self.
config.l1.record =
'L1TUtmTriggerMenuRcd'
421 self.
config.l1.connect =
''
423 if not self.
config.l1.snapshotTime:
424 self.
config.l1.snapshotTime =
'9999-12-31 23:59:59.000'
425 self.
config.l1cond =
'%(tag)s,%(record)s,%(connect)s,%(label)s,%(snapshotTime)s' % self.
config.l1.__dict__
431 # override the GlobalTag, connection string and pfnPrefix
432 if 'GlobalTag' in %(dict)s:
433 from Configuration.AlCa.GlobalTag import GlobalTag as customiseGlobalTag
434 %(process)s.GlobalTag = customiseGlobalTag(%(process)s.GlobalTag"""
436 text +=
", globaltag = %s" % repr(self.
config.globaltag)
438 text +=
", conditions = %s" % repr(self.
config.l1cond)
444 if self.
config.l1Xml.XmlFile:
446 # override the GlobalTag's L1T menu from an Xml file
447 from HLTrigger.Configuration.CustomConfigs import L1XML
448 %%(process)s = L1XML(%%(process)s,"%s")
449 """ % (self.
config.l1Xml.XmlFile)
456 # run the Full L1T emulator, then repack the data into a new RAW collection, to be used by the HLT
457 from HLTrigger.Configuration.CustomConfigs import L1REPACK
458 %%(process)s = L1REPACK(%%(process)s,"%s")
459 """ % (self.
config.emulator)
465 r'\b(process\.)?hltOutput(\w+) *= *cms\.OutputModule\( *"ShmStreamConsumer" *,',
466 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 ),',
470 if not self.
config.fragment
and self.
config.output ==
'minimal':
473 # add a single "keep *" output
474 %(process)s.hltOutputMinimal = cms.OutputModule( "PoolOutputModule",
475 fileName = cms.untracked.string( "output.root" ),
476 fastCloning = cms.untracked.bool( False ),
477 dataset = cms.untracked.PSet(
478 dataTier = cms.untracked.string( 'AOD' ),
479 filterName = cms.untracked.string( '' )
481 outputCommands = cms.untracked.vstring( 'drop *',
482 'keep edmTriggerResults_*_*_*',
483 'keep triggerTriggerEvent_*_*_*'
486 %(process)s.MinimalOutput = cms.EndPath( %(process)s.hltOutputMinimal )
488 elif not self.
config.fragment
and self.
config.output ==
'full':
491 # add a single "keep *" output
492 %(process)s.hltOutputFull = cms.OutputModule( "PoolOutputModule",
493 fileName = cms.untracked.string( "output.root" ),
494 fastCloning = cms.untracked.bool( False ),
495 dataset = cms.untracked.PSet(
496 dataTier = cms.untracked.string( 'RECO' ),
497 filterName = cms.untracked.string( '' )
499 outputCommands = cms.untracked.vstring( 'keep *' )
501 %(process)s.FullOutput = cms.EndPath( %(process)s.hltOutputFull )
506 if self.
config.eras
is None:
508 from Configuration.StandardSequences.Eras
import eras
509 erasSplit = self.
config.eras.split(
',')
510 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)
514 if self.
config.setup
is None:
517 self.
data = self.
data[:processLine]+
'\nprocess.load("%s")'%self.
config.setupFile+self.
data[processLine:]
521 if self.
config.name
is None:
528 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)
532 # avoid PrescaleService error due to missing HLT paths
533 if 'PrescaleService' in process.__dict__:
534 for pset in reversed(process.PrescaleService.prescaleTable):
535 if not hasattr(process,pset.pathName.value()):
536 process.PrescaleService.prescaleTable.remove(pset)
543 if 'MessageLogger' in %(dict)s:
544 %(process)s.MessageLogger.categories.append('TriggerSummaryProducerAOD')
545 %(process)s.MessageLogger.categories.append('L1GtTrigReport')
546 %(process)s.MessageLogger.categories.append('L1TGlobalSummary')
547 %(process)s.MessageLogger.categories.append('HLTrigReport')
548 %(process)s.MessageLogger.categories.append('FastReport')
556 if 'GlobalTag' in %%(dict)s:
558 for condition
in conditions:
559 self.
data +=
""" %%(process)s.GlobalTag.toGet.append(
561 record = cms.string( '%(record)s' ),
562 tag = cms.string( '%(tag)s' ),
563 label = cms.untracked.string( '%(label)s' ),
572 return 'from %s import *\n' % module
574 return 'process.load( "%s" )\n' % module
582 self.
data +=
"if '%s' in %%(dict)s:\n" % module
583 for (parameter, value)
in parameters:
584 self.
data +=
" %%(process)s.%s.%s = %s\n" % (module, parameter, value)
592 # instrument the menu with the modules and EndPath needed for timing studies
595 self.
data +=
'\n# configure the FastTimerService\n'
596 self.
loadCff(
'HLTrigger.Timer.FastTimerService_cfi')
598 self.
data +=
"""# print a text summary at the end of the job
599 %(process)s.FastTimerService.printEventSummary = False
600 %(process)s.FastTimerService.printRunSummary = False
601 %(process)s.FastTimerService.printJobSummary = True
604 %(process)s.FastTimerService.enableDQM = True
606 # enable per-path DQM plots (starting with CMSSW 9.2.3-patch2)
607 %(process)s.FastTimerService.enableDQMbyPath = True
609 # enable per-module DQM plots
610 %(process)s.FastTimerService.enableDQMbyModule = True
612 # enable per-event DQM plots vs lumisection
613 %(process)s.FastTimerService.enableDQMbyLumiSection = True
614 %(process)s.FastTimerService.dqmLumiSectionsRange = 2500
616 # set the time resolution of the DQM plots
617 %(process)s.FastTimerService.dqmTimeRange = 2000.
618 %(process)s.FastTimerService.dqmTimeResolution = 10.
619 %(process)s.FastTimerService.dqmPathTimeRange = 1000.
620 %(process)s.FastTimerService.dqmPathTimeResolution = 5.
621 %(process)s.FastTimerService.dqmModuleTimeRange = 200.
622 %(process)s.FastTimerService.dqmModuleTimeResolution = 1.
624 # set the base DQM folder for the plots
625 %(process)s.FastTimerService.dqmPath = 'HLT/TimerService'
626 %(process)s.FastTimerService.enableDQMbyProcesses = False
631 if not self.
config.hilton:
633 if 'hltDQMFileSaver' in self.
data:
634 self.
data = re.sub(
r'\b(process\.)?hltDQMFileSaver \+ ',
'', self.
data)
635 self.
data = re.sub(
r' \+ \b(process\.)?hltDQMFileSaver',
'', self.
data)
636 self.
data = re.sub(
r'\b(process\.)?hltDQMFileSaver',
'', self.
data)
639 dqmstore =
"\n# load the DQMStore and DQMRootOutputModule\n"
642 %(process)s.dqmOutput = cms.OutputModule("DQMRootOutputModule",
643 fileName = cms.untracked.string("DQMIO.root")
647 empty_path = re.compile(
r'.*\b(process\.)?DQMOutput = cms\.EndPath\( *\).*')
648 other_path = re.compile(
r'(.*\b(process\.)?DQMOutput = cms\.EndPath\()(.*)')
649 if empty_path.search(self.
data):
651 self.
data = empty_path.sub(dqmstore +
'\n%(process)s.DQMOutput = cms.EndPath( %(process)s.dqmOutput )\n', self.
data)
652 elif other_path.search(self.
data):
654 self.
data = other_path.sub(dqmstore +
r'\g<1> %(process)s.dqmOutput +\g<3>', self.
data)
657 self.
data += dqmstore
658 self.
data +=
'\n%(process)s.DQMOutput = cms.EndPath( %(process)s.dqmOutput )\n'
663 sys.stderr.write(
'Path selection:\n')
665 sys.stderr.write(
'\t%s\n' % path)
666 sys.stderr.write(
'\n\n')
673 paths = self.
config.paths.split(
',')
683 if self.
config.fragment
or self.
config.output
in (
'none', ):
689 paths.append(
"-*Output" )
690 paths.append(
"-RatesMonitoring")
691 paths.append(
"-DQMHistograms")
692 if self.
config.fragment: paths.append(
"Scouting*Output" )
694 elif self.
config.output
in (
'dqm',
'minimal',
'full'):
697 paths.append(
"DQMHistograms" )
700 paths.append(
"-*Output" )
701 paths.append(
"-RatesMonitoring")
702 if self.
config.fragment: paths.append(
"Scouting*Output" )
707 paths.append(
"*Output" )
708 paths.append(
"DQMHistograms" )
715 paths.append(
"-HLTAnalyzerEndpath" )
718 paths.append(
"-OfflineOutput" )
727 raise RuntimeError(
'Error: option "--paths %s" does not select any valid paths' % self.
config.paths)
743 if not self.
config.hilton:
753 self.
options[
'essources'].
append(
"-XMLIdealGeometryESSource" )
772 self.
options[
'esmodules'].
append(
"-CaloTowerHardcodeGeometryEP" )
773 self.
options[
'esmodules'].
append(
"-CastorHardcodeGeometryEP" )
776 self.
options[
'esmodules'].
append(
"-EcalElectronicsMappingBuilder" )
778 self.
options[
'esmodules'].
append(
"-EcalLaserCorrectionService" )
779 self.
options[
'esmodules'].
append(
"-EcalPreshowerGeometryEP" )
780 self.
options[
'esmodules'].
append(
"-HcalHardcodeGeometryEP" )
782 self.
options[
'esmodules'].
append(
"-MuonNumberingInitialization" )
783 self.
options[
'esmodules'].
append(
"-ParametrizedMagneticFieldProducer" )
786 self.
options[
'esmodules'].
append(
"-SiStripRecHitMatcherESProducer" )
787 self.
options[
'esmodules'].
append(
"-SiStripQualityESProducer" )
788 self.
options[
'esmodules'].
append(
"-StripCPEfromTrackAngleESProducer" )
789 self.
options[
'esmodules'].
append(
"-TrackerDigiGeometryESModule" )
790 self.
options[
'esmodules'].
append(
"-TrackerGeometricDetESModule" )
791 self.
options[
'esmodules'].
append(
"-VolumeBasedMagneticFieldESProducer" )
794 self.
options[
'esmodules'].
append(
"-L1GtTriggerMaskAlgoTrigTrivialProducer" )
795 self.
options[
'esmodules'].
append(
"-L1GtTriggerMaskTechTrigTrivialProducer" )
796 self.
options[
'esmodules'].
append(
"-hltESPEcalTrigTowerConstituentsMapBuilder" )
797 self.
options[
'esmodules'].
append(
"-hltESPGlobalTrackingGeometryESProducer" )
798 self.
options[
'esmodules'].
append(
"-hltESPMuonDetLayerGeometryESProducer" )
799 self.
options[
'esmodules'].
append(
"-hltESPTrackerRecoGeometryESProducer" )
802 self.
options[
'esmodules'].
append(
"-CaloTowerGeometryFromDBEP" )
803 self.
options[
'esmodules'].
append(
"-CastorGeometryFromDBEP" )
804 self.
options[
'esmodules'].
append(
"-EcalBarrelGeometryFromDBEP" )
805 self.
options[
'esmodules'].
append(
"-EcalEndcapGeometryFromDBEP" )
806 self.
options[
'esmodules'].
append(
"-EcalPreshowerGeometryFromDBEP" )
818 self.
options[
'modules'].
append(
"-hltOutputScoutingCaloMuon" )
821 if self.
config.fragment
or (self.
config.prescale
and (self.
config.prescale.lower() ==
'none')):
829 if len(filenames) > 255:
836 self.
data +=
" %s = cms.untracked.vstring%s\n" % (name, token_open)
837 for line
in filenames:
838 self.
data +=
" '%s',\n" % line
839 self.
data +=
" %s,\n" % (token_close)
844 if input[0:8] ==
'dataset:':
845 from .dasFileQuery
import dasFileQuery
851 files = input.split(
',')
860 self.
source = [
"file:RelVal_Raw_%s_DATA.root" % self.
config.type ]
863 self.
source = [
"file:RelVal_Raw_%s_MC.root" % self.
config.type ]
870 %(process)s.source = cms.Source( "PoolSource",
876 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)
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
def updateMessageLogger(self)
def replace(string, replacements)