7 from pipe
import pipe
as _pipe
8 from options
import globalTag
9 from itertools
import islice
12 i = iterator.__iter__()
14 l =
list(islice(i, n))
41 if self.config.fragment:
42 self.
labels[
'process'] =
'fragment' 43 self.
labels[
'dict'] =
'fragment.__dict__' 45 self.
labels[
'process'] =
'process' 46 self.
labels[
'dict'] =
'process.__dict__' 48 if self.config.prescale
and (self.config.prescale.lower() !=
'none'):
49 self.
labels[
'prescale'] = self.config.prescale
52 from confdbOfflineConverter
import OfflineConverter
53 self.
converter = OfflineConverter(version = self.config.menu.version, database = self.config.menu.database)
61 if not self.config.setup:
64 if ".py" in self.config.setup:
65 self.config.setupFile = self.config.setup.split(
".py")[0]
67 args = [
'--configName', self.config.setup ]
68 args.append(
'--noedsources')
69 args.append(
'--nopaths')
70 for key, vals
in self.options.iteritems():
72 args.extend((
'--'+key,
','.
join(vals)))
74 data, err = self.converter.query( *args )
75 if 'ERROR' in err
or 'Exhausted Resultset' in err
or 'CONFIG_NOT_FOUND' in err:
76 sys.stderr.write(
"%s: error while retrieving the HLT setup menu\n\n" % os.path.basename(sys.argv[0]))
77 sys.stderr.write(err +
"\n\n")
79 self.config.setupFile =
"setup_"+self.config.setup[1:].
replace(
"/",
"_")+
"_cff" 80 file(self.config.setupFile+
".py",
"w+").
write(
"# This file is automatically generated by hltGetConfiguration.\n" + data)
83 if self.config.menu.run:
84 args = [
'--runNumber', self.config.menu.run]
86 args = [
'--configName', self.config.menu.name ]
87 args.append(
'--noedsources')
88 for key, vals
in self.options.iteritems():
90 args.extend((
'--'+key,
','.
join(vals)))
92 data, err = self.converter.query( *args )
93 if 'ERROR' in err
or 'Exhausted Resultset' in err
or 'CONFIG_NOT_FOUND' in err:
94 sys.stderr.write(
"%s: error while retrieving the HLT menu\n\n" % os.path.basename(sys.argv[0]))
95 sys.stderr.write(err +
"\n\n")
100 if self.config.menu.run:
101 args = [
'--runNumber', self.config.menu.run]
103 args = [
'--configName', self.config.menu.name]
113 data, err = self.converter.query( *args )
114 if 'ERROR' in err
or 'Exhausted Resultset' in err
or 'CONFIG_NOT_FOUND' in err:
115 sys.stderr.write(
"%s: error while retrieving the list of paths from the HLT menu\n\n" % os.path.basename(sys.argv[0]))
116 sys.stderr.write(err +
"\n\n")
118 filter = re.compile(
r' *= *cms.(End)?Path.*')
119 paths = [ filter.sub(
'', line)
for line
in data.splitlines()
if filter.search(line) ]
134 filter = re.compile(
r'^' + glob.replace(
'?',
'.').
replace(
'*',
'.*').
replace(
'[!',
'[^') +
r'$')
135 matches.extend( negate + element
for element
in collection
if filter.match(element) )
144 for element
in elements:
145 if element[0] ==
'-':
146 result.add( element )
148 result.discard(
'-' + element )
149 return sorted( element
for element
in result )
156 for element
in elements:
157 if element[0] ==
'-':
158 result.discard( element[1:] )
160 result.add( element )
161 return sorted( element
for element
in result )
167 if self.config.fragment:
168 self.
data = re.sub(
r'\bprocess\b',
'fragment', self.
data )
169 self.
data = re.sub(
r'\bProcess\b',
'ProcessFragment', self.
data )
176 if self.config.fragment:
178 # add specific customizations 179 from HLTrigger.Configuration.customizeHLTforALL import customizeHLTforAll 180 fragment = customizeHLTforAll(fragment,"%s") 181 """ % (self.config.type)
183 if self.config.type==
"Fake":
187 _gtData =
"auto:"+prefix+
"_hlt_"+self.config.type
188 _gtMc =
"auto:"+prefix+
"_mc_" +self.config.type
190 # add specific customizations 192 _customInfo['menuType' ]= "%s" 193 _customInfo['globalTags']= {} 194 _customInfo['globalTags'][True ] = "%s" 195 _customInfo['globalTags'][False] = "%s" 196 _customInfo['inputFiles']={} 197 _customInfo['inputFiles'][True] = "file:RelVal_Raw_%s_DATA.root" 198 _customInfo['inputFiles'][False] = "file:RelVal_Raw_%s_MC.root" 199 _customInfo['maxEvents' ]= %s 200 _customInfo['globalTag' ]= "%s" 201 _customInfo['inputFile' ]= %s 202 _customInfo['realData' ]= %s 203 from HLTrigger.Configuration.customizeHLTforALL import customizeHLTforAll 204 %%(process)s = customizeHLTforAll(%%(process)s,"%s",_customInfo) 205 """ % (self.config.type,_gtData,_gtMc,self.config.type,self.config.type,self.config.events,self.config.globaltag,self.
source,self.config.data,self.config.type)
208 from HLTrigger.Configuration.customizeHLTforCMSSW import customizeHLTforCMSSW 209 %%(process)s = customizeHLTforCMSSW(%%(process)s,"%s") 210 """ % (self.config.type)
214 # Eras-based customisations 215 from HLTrigger.Configuration.Eras import modifyHLTforEras 216 modifyHLTforEras(%(process)s) 219 if self.config.customise:
221 self.
data +=
"#User-defined customization functions\n" 222 for customise
in self.config.customise.split(
","):
223 customiseValues = customise.split(
".")
224 if len(customiseValues)>=3:
raise Exception(
"--customise option cannot contain more than one dot.")
225 if len(customiseValues)==1:
226 customiseValues.append(
"customise")
227 customiseValues[0] = customiseValues[0].
replace(
"/",
".")
228 self.
data +=
"from "+customiseValues[0]+
" import "+customiseValues[1]+
"\n" 229 self.
data +=
"process = "+customiseValues[1]+
"(process)\n" 235 if not self.config.fragment:
239 if self.config.type
in (
'HIon', ):
241 if not self.config.fragment:
242 self.
_fix_parameter( type =
'InputTag', value =
'rawDataCollector', replace =
'rawDataRepacker')
265 if self.config.fragment:
267 # dummyfy hltGetConditions in cff's 268 if 'hltGetConditions' in %(dict)s and 'HLTriggerFirstPath' in %(dict)s : 269 %(process)s.hltDummyConditions = cms.EDFilter( "HLTBool", 270 result = cms.bool( True ) 272 %(process)s.HLTriggerFirstPath.replace(%(process)s.hltGetConditions,%(process)s.hltDummyConditions) 305 # limit the number of events to be processed 306 %%(process)s.maxEvents = cms.untracked.PSet( 307 input = cms.untracked.int32( %d ) 309 """ % self.config.events
312 # enable TrigReport, TimeReport and MultiThreading 313 %(process)s.options = cms.untracked.PSet( 314 wantSummary = cms.untracked.bool( True ), 315 numberOfThreads = cms.untracked.uint32( 4 ), 316 numberOfStreams = cms.untracked.uint32( 0 ), 317 sizeOfStackForThreadsInKB = cms.untracked.uint32( 10*1024 ) 323 name: parameter name (optional) 324 type: parameter type (look for tracked and untracked variants) 325 value: original value 326 replace: replacement value 330 r'%(name)s = cms(?P<tracked>(?:\.untracked)?)\.%(type)s\( (?P<quote>["\']?)%(value)s(?P=quote)' % args,
331 r'%(name)s = cms\g<tracked>.%(type)s( \g<quote>%(replace)s\g<quote>' % args,
335 r'cms(?P<tracked>(?:\.untracked)?)\.%(type)s\( (?P<quote>["\']?)%(value)s(?P=quote)' % args,
336 r'cms\g<tracked>.%(type)s( \g<quote>%(replace)s\g<quote>' % args,
343 if self.
options[
'paths'][0][0] ==
'-':
345 for minuspath
in self.
options[
'paths']:
347 self.
data = re.sub(
r' cms.PSet\( pathName = cms.string\( "%s" \),\n prescales = cms.vuint32\( .* \)\n \),?\n' % path,
'', self.
data)
351 if path
not in self.
options[
'paths']:
352 self.
data = re.sub(
r' cms.PSet\( pathName = cms.string\( "%s" \),\n prescales = cms.vuint32\( .* \)\n \),?\n' % path,
'', self.
data)
354 if self.config.prescale
and (self.config.prescale.lower() !=
'none'):
357 # force the use of a specific HLT prescale column 358 if 'PrescaleService' in %(dict)s: 359 %(process)s.PrescaleService.forceDefault = True 360 %(process)s.PrescaleService.lvl1DefaultLabel = '%(prescale)s' 367 filters = [ match[1]
for match
in re.findall(
r'(process\.)?\b(\w+) = cms.EDFilter', self.
data) ]
368 re_sequence = re.compile(
r'cms\.(Path|Sequence)\((.*)\)' )
370 self.
data = re_sequence.sub(
lambda line: re.sub(
r'cms\.ignore *\( *((process\.)?\b(\w+)) *\)',
r'\1', line.group(0) ), self.
data )
371 self.
data = re_sequence.sub(
lambda line: re.sub(
r'~',
'', line.group(0) ), self.
data )
373 for some
in splitter(filters, 1000):
374 re_filters = re.compile(
r'\b((process\.)?(' +
r'|'.
join(some) +
r'))\b' )
375 self.
data = re_sequence.sub(
lambda line: re_filters.sub(
r'cms.ignore( \1 )', line.group(0) ), self.
data )
379 if self.config.errortype:
381 self.
_fix_parameter(name =
'SelectedTriggerType', type =
'int32', value =
'1', replace =
'0')
382 self.
_fix_parameter(name =
'SelectedTriggerType', type =
'int32', value =
'2', replace =
'0')
383 self.
_fix_parameter(name =
'SelectedTriggerType', type =
'int32', value =
'3', replace =
'0')
399 if not self.config.data
and not self.config.globaltag:
400 if self.config.type
in globalTag:
401 self.config.globaltag = globalTag[self.config.type]
403 self.config.globaltag = globalTag[
'GRun']
406 if self.config.l1.override:
407 self.config.l1.tag = self.config.l1.override
408 self.config.l1.record =
'L1TUtmTriggerMenuRcd' 409 self.config.l1.connect =
'' 410 self.config.l1.label =
'' 411 if not self.config.l1.snapshotTime:
412 self.config.l1.snapshotTime =
'9999-12-31 23:59:59.000' 413 self.config.l1cond =
'%(tag)s,%(record)s,%(connect)s,%(label)s,%(snapshotTime)s' % self.config.l1.__dict__
415 self.config.l1cond =
None 417 if self.config.globaltag
or self.config.l1cond:
419 # override the GlobalTag, connection string and pfnPrefix 420 if 'GlobalTag' in %(dict)s: 421 from Configuration.AlCa.GlobalTag import GlobalTag as customiseGlobalTag 422 %(process)s.GlobalTag = customiseGlobalTag(%(process)s.GlobalTag""" 423 if self.config.globaltag:
424 text +=
", globaltag = %s" % repr(self.config.globaltag)
425 if self.config.l1cond:
426 text +=
", conditions = %s" % repr(self.config.l1cond)
432 if self.config.l1Xml.XmlFile:
434 # override the GlobalTag's L1T menu from an Xml file 435 from HLTrigger.Configuration.CustomConfigs import L1XML 436 %%(process)s = L1XML(%%(process)s,"%s") 437 """ % (self.config.l1Xml.XmlFile)
442 if self.config.emulator:
444 # run the Full L1T emulator, then repack the data into a new RAW collection, to be used by the HLT 445 from HLTrigger.Configuration.CustomConfigs import L1REPACK 446 %%(process)s = L1REPACK(%%(process)s,"%s") 447 """ % (self.config.emulator)
453 r'\b(process\.)?hltOutput(\w+) *= *cms\.OutputModule\( *"ShmStreamConsumer" *,',
454 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 ),',
458 if not self.config.fragment
and self.config.output ==
'full':
461 # add a single "keep *" output 462 %(process)s.hltOutputFULL = cms.OutputModule( "PoolOutputModule", 463 fileName = cms.untracked.string( "outputFULL.root" ), 464 fastCloning = cms.untracked.bool( False ), 465 dataset = cms.untracked.PSet( 466 dataTier = cms.untracked.string( 'RECO' ), 467 filterName = cms.untracked.string( '' ) 469 outputCommands = cms.untracked.vstring( 'keep *' ) 471 %(process)s.FULLOutput = cms.EndPath( %(process)s.hltOutputFULL ) 475 if self.config.eras
is None:
477 self.
data = re.sub(
r'process = cms.Process\( *"\w+"',
'from Configuration.StandardSequences.Eras import eras\n\g<0>, '+
', '.
join(
'eras.' + era
for era
in self.config.eras.split(
',')), self.
data)
481 if self.config.setup
is None:
483 processLine = self.data.find(
"\n",self.data.find(
"cms.Process"))
484 self.
data = self.
data[:processLine]+
'\nprocess.load("%s")'%self.config.setupFile+self.
data[processLine:]
488 if self.config.name
is None:
492 self.config.name = self.config.name.replace(
"_",
"")
495 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)
498 if self.config.setup: self.
data +=
""" 499 # avoid PrescaleService error due to missing HLT paths 500 if 'PrescaleService' in process.__dict__: 501 for pset in reversed(process.PrescaleService.prescaleTable): 502 if not hasattr(process,pset.pathName.value()): 503 process.PrescaleService.prescaleTable.remove(pset) 510 if 'MessageLogger' in %(dict)s: 511 %(process)s.MessageLogger.categories.append('TriggerSummaryProducerAOD') 512 %(process)s.MessageLogger.categories.append('L1GtTrigReport') 513 %(process)s.MessageLogger.categories.append('L1TGlobalSummary') 514 %(process)s.MessageLogger.categories.append('HLTrigReport') 515 %(process)s.MessageLogger.categories.append('FastReport') 523 if 'GlobalTag' in %%(dict)s: 525 for condition
in conditions:
526 self.
data +=
""" %%(process)s.GlobalTag.toGet.append( 528 record = cms.string( '%(record)s' ), 529 tag = cms.string( '%(tag)s' ), 530 label = cms.untracked.string( '%(label)s' ), 538 if self.config.fragment:
539 return 'from %s import *\n' % module
541 return 'process.load( "%s" )\n' % module
549 self.
data +=
"if '%s' in %%(dict)s:\n" % module
550 for (parameter, value)
in parameters:
551 self.
data +=
" %%(process)s.%s.%s = %s\n" % (module, parameter, value)
557 if self.config.timing:
559 # instrument the menu with the modules and EndPath needed for timing studies 562 self.
data +=
'\n# configure the FastTimerService\n' 563 self.
loadCff(
'HLTrigger.Timer.FastTimerService_cfi')
565 self.
data +=
"""# print a text summary at the end of the job 566 %(process)s.FastTimerService.printEventSummary = False 567 %(process)s.FastTimerService.printRunSummary = False 568 %(process)s.FastTimerService.printJobSummary = True 571 %(process)s.FastTimerService.enableDQM = True 573 # enable per-path DQM plots (starting with CMSSW 9.2.3-patch2) 574 %(process)s.FastTimerService.enableDQMbyPath = True 576 # enable per-module DQM plots 577 %(process)s.FastTimerService.enableDQMbyModule = True 579 # enable per-event DQM plots vs lumisection 580 %(process)s.FastTimerService.enableDQMbyLumiSection = True 581 %(process)s.FastTimerService.dqmLumiSectionsRange = 2500 583 # set the time resolution of the DQM plots 584 %(process)s.FastTimerService.dqmTimeRange = 2000. 585 %(process)s.FastTimerService.dqmTimeResolution = 10. 586 %(process)s.FastTimerService.dqmPathTimeRange = 1000. 587 %(process)s.FastTimerService.dqmPathTimeResolution = 5. 588 %(process)s.FastTimerService.dqmModuleTimeRange = 200. 589 %(process)s.FastTimerService.dqmModuleTimeResolution = 1. 591 # set the base DQM folder for the plots 592 %(process)s.FastTimerService.dqmPath = 'HLT/TimerService' 593 %(process)s.FastTimerService.enableDQMbyProcesses = False 598 if not self.config.hilton:
600 if 'hltDQMFileSaver' in self.
data:
601 self.
data = re.sub(
r'\b(process\.)?hltDQMFileSaver \+ ',
'', self.
data)
602 self.
data = re.sub(
r' \+ \b(process\.)?hltDQMFileSaver',
'', self.
data)
603 self.
data = re.sub(
r'\b(process\.)?hltDQMFileSaver',
'', self.
data)
606 dqmstore =
"\n# load the DQMStore and DQMRootOutputModule\n" 608 dqmstore +=
"%(process)s.DQMStore.enableMultiThread = True\n" 610 %(process)s.dqmOutput = cms.OutputModule("DQMRootOutputModule", 611 fileName = cms.untracked.string("DQMIO.root") 615 empty_path = re.compile(
r'.*\b(process\.)?DQMOutput = cms\.EndPath\( *\).*')
616 other_path = re.compile(
r'(.*\b(process\.)?DQMOutput = cms\.EndPath\()(.*)')
617 if empty_path.search(self.
data):
619 self.
data = empty_path.sub(dqmstore +
'\n%(process)s.DQMOutput = cms.EndPath( %(process)s.dqmOutput )\n', self.
data)
620 elif other_path.search(self.
data):
622 self.
data = other_path.sub(dqmstore +
r'\g<1> %(process)s.dqmOutput +\g<3>', self.
data)
625 self.
data += dqmstore
626 self.
data +=
'\n%(process)s.DQMOutput = cms.EndPath( %(process)s.dqmOutput )\n' 631 sys.stderr.write(
'Path selection:\n')
633 sys.stderr.write(
'\t%s\n' % path)
634 sys.stderr.write(
'\n\n')
639 if self.config.paths:
641 paths = self.config.paths.split(
',')
646 if self.config.fragment
or self.config.output
in (
'none',
'full'):
648 if self.config.paths:
653 paths.append(
"-*Output" )
654 paths.append(
"-RatesMonitoring")
655 paths.append(
"-DQMHistograms")
656 elif self.config.output ==
'minimal':
658 if self.config.paths:
659 paths.append(
"HLTDQMResultsOutput" )
661 paths.append(
"-*Output" )
662 paths.append(
"-RatesMonitoring")
663 paths.append(
"-DQMHistograms")
664 paths.append(
"HLTDQMResultsOutput" )
667 if self.config.paths:
668 paths.append(
"*Output" )
673 if self.config.profiling:
674 paths.append(
"-HLTAnalyzerEndpath" )
677 paths.append(
"-OfflineOutput" )
682 if self.config.paths:
686 raise RuntimeError(
'Error: option "--paths %s" does not select any valid paths' % self.config.paths)
702 if not self.config.hilton:
708 if self.config.fragment:
712 self.
options[
'essources'].
append(
"-XMLIdealGeometryESSource" )
717 self.
options[
'esmodules'].
append(
"-AutoMagneticFieldESProducer" )
732 self.
options[
'esmodules'].
append(
"-CaloTowerHardcodeGeometryEP" )
733 self.
options[
'esmodules'].
append(
"-CastorHardcodeGeometryEP" )
736 self.
options[
'esmodules'].
append(
"-EcalElectronicsMappingBuilder" )
738 self.
options[
'esmodules'].
append(
"-EcalLaserCorrectionService" )
739 self.
options[
'esmodules'].
append(
"-EcalPreshowerGeometryEP" )
740 self.
options[
'esmodules'].
append(
"-HcalHardcodeGeometryEP" )
742 self.
options[
'esmodules'].
append(
"-MuonNumberingInitialization" )
743 self.
options[
'esmodules'].
append(
"-ParametrizedMagneticFieldProducer" )
746 self.
options[
'esmodules'].
append(
"-SiStripRecHitMatcherESProducer" )
747 self.
options[
'esmodules'].
append(
"-SiStripQualityESProducer" )
748 self.
options[
'esmodules'].
append(
"-StripCPEfromTrackAngleESProducer" )
749 self.
options[
'esmodules'].
append(
"-TrackerDigiGeometryESModule" )
750 self.
options[
'esmodules'].
append(
"-TrackerGeometricDetESModule" )
751 self.
options[
'esmodules'].
append(
"-VolumeBasedMagneticFieldESProducer" )
754 self.
options[
'esmodules'].
append(
"-L1GtTriggerMaskAlgoTrigTrivialProducer" )
755 self.
options[
'esmodules'].
append(
"-L1GtTriggerMaskTechTrigTrivialProducer" )
756 self.
options[
'esmodules'].
append(
"-hltESPEcalTrigTowerConstituentsMapBuilder" )
757 self.
options[
'esmodules'].
append(
"-hltESPGlobalTrackingGeometryESProducer" )
758 self.
options[
'esmodules'].
append(
"-hltESPMuonDetLayerGeometryESProducer" )
759 self.
options[
'esmodules'].
append(
"-hltESPTrackerRecoGeometryESProducer" )
762 self.
options[
'esmodules'].
append(
"-CaloTowerGeometryFromDBEP" )
763 self.
options[
'esmodules'].
append(
"-CastorGeometryFromDBEP" )
764 self.
options[
'esmodules'].
append(
"-EcalBarrelGeometryFromDBEP" )
765 self.
options[
'esmodules'].
append(
"-EcalEndcapGeometryFromDBEP" )
766 self.
options[
'esmodules'].
append(
"-EcalPreshowerGeometryFromDBEP" )
777 if self.config.fragment
or (self.config.prescale
and (self.config.prescale.lower() ==
'none')):
780 if self.config.fragment
or self.config.timing:
785 if len(filenames) > 255:
792 self.
data +=
" %s = cms.untracked.vstring%s\n" % (name, token_open)
793 for line
in filenames:
794 self.
data +=
" '%s',\n" % line
795 self.
data +=
" %s,\n" % (token_close)
800 if input[0:8] ==
'dataset:':
801 from dasFileQuery
import dasFileQuery
807 files = input.split(
',')
811 if self.config.input:
814 elif self.config.data:
816 self.
source = [
"file:RelVal_Raw_%s_DATA.root" % self.config.type ]
819 self.
source = [
"file:RelVal_Raw_%s_MC.root" % self.config.type ]
821 if self.config.parent:
826 %(process)s.source = cms.Source( "PoolSource", 832 inputCommands = cms.untracked.vstring( def __init__(self, configuration)
def splitter(iterator, n)
def addGlobalOptions(self)
def getSetupConfigurationFromDB(self)
def overrideProcessName(self)
def instrumentErrorEventType(self)
def replace(string, replacements)
def expand_filenames(self, input)
def updateMessageLogger(self)
def overrideL1MenuXml(self)
def overrideGlobalTag(self)
def specificCustomize(self)
def consolidatePositiveList(elements)
def overrideParameters(self, module, parameters)
def instrumentOpenMode(self)
def getRawConfigurationFromDB(self)
def loadAdditionalConditions(self, comment, conditions)
def loadCffCommand(self, module)
static std::string join(char **cmd)
def loadCff(self, module)
def consolidateNegativeList(elements)
def instrumentTiming(self)
def expandWildcards(globs, collection)
def _fix_parameter(self, args)
def append_filenames(self, name, filenames)
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