Commit d5d62538 authored by Javier Montejo's avatar Javier Montejo
Browse files

Added api module to provide lists of unprescaled triggers

The module reads the TriggerDB to provide lists of unprescaled triggers
per type and/or period.
It can provide also information for what is expected to be unprescaled
in the future.
When TriggerMenu is built it produces lists for the current unprescaled
triggers, which can be used by other clients


Former-commit-id: 009d306a5359b3430b758b116f0863ecdf1cab7f
parent 6485b825
......@@ -10,9 +10,10 @@ atlas_install_python_modules( python/*.py python/menu python/l1
python/l1menu python/l1topo python/l1topomenu python/egamma
python/muon python/jet python/bjet python/met python/tau python/afp
python/minbias python/heavyion python/bphysics python/calibcosmicmon
python/test python/combined python/commonUtils )
python/test python/combined python/commonUtils python/api )
atlas_install_joboptions( share/*.py )
atlas_install_scripts( scripts/generate*Menu.py scripts/menuTestTMC.sh )
atlas_install_scripts( scripts/generate*Menu.py scripts/menuTestTMC.sh
scripts/generateUnprescaledLists.py )
atlas_install_xmls( data/*.dtd data/*.xml )
atlas_add_test( generateMenu SCRIPT scripts/testMenu.sh
......@@ -28,3 +29,71 @@ atlas_add_test ( pyflakesMenu
atlas_add_test ( checkL1Menu SCRIPT scripts/checkL1Menu.sh
POST_EXEC_SCRIPT "check_log.pl --config checklogTriggerTest.conf checkL1Menu.log"
)
# Function to create lowest-unprescaled lists
function( atlas_run_lowestunprescaled )
# Don't do anything in release recompilation dryrun mode. In all other
# modes, proceed as usual.
if( ATLAS_RELEASE_RECOMPILE_DRYRUN )
return()
endif()
# Command to build the list of unprescaled triggers.
# Algorithm copied from TriggerMenuXML
add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/unprescaled.stamp
COMMAND ${CMAKE_COMMAND} -E touch
${CMAKE_CURRENT_BINARY_DIR}/unprescaled.attempted.stamp
COMMAND ${CMAKE_COMMAND} -E make_directory
${CMAKE_CURRENT_BINARY_DIR}/LowestUnprescaledLists/unprescaled
COMMAND ${CMAKE_BINARY_DIR}/atlas_build_run.sh
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/generateUnprescaledLists.py ${CMAKE_CURRENT_BINARY_DIR}/LowestUnprescaledLists/unprescaled
COMMAND ${CMAKE_COMMAND} -E make_directory
${CMAKE_PYTHON_OUTPUT_DIRECTORY}/TriggerMenu
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_BINARY_DIR}/LowestUnprescaledLists/unprescaled/
${CMAKE_PYTHON_OUTPUT_DIRECTORY}/TriggerMenu/api/
COMMAND ${CMAKE_COMMAND} -E touch
${CMAKE_CURRENT_BINARY_DIR}/unprescaled.stamp
DEPENDS "Package_$<JOIN:$<TARGET_PROPERTY:ATLAS_PACKAGES_TARGET,ATLAS_PACKAGES>,;Package_>" )
# Create custom target and add it to package dependencies
add_custom_target( build_list_unprescaled ALL SOURCES
${CMAKE_CURRENT_BINARY_DIR}/unprescaled.stamp )
# In case the file generation failed, because it wasn't even attempted
install( CODE "if( NOT EXISTS
${CMAKE_CURRENT_BINARY_DIR}/unprescaled.attempted.stamp )
message( WARNING \"Generating trigger list of unprescaled items\"
\" during the installation\" )
execute_process( COMMAND ${CMAKE_COMMAND} -E touch
${CMAKE_CURRENT_BINARY_DIR}/unprescaled.attempted.stamp )
execute_process(
COMMAND ${CMAKE_COMMAND} -E make_directory
${CMAKE_CURRENT_BINARY_DIR}/LowestUnprescaledLists/unprescaled )
execute_process(
COMMAND ${CMAKE_BINARY_DIR}/atlas_build_run.sh
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/generateUnprescaledLists.py
${CMAKE_CURRENT_BINARY_DIR}/LowestUnprescaledLists/unprescaled )
endif()" )
# Install the generated PYTHON files. Note that this installation rule is
# executed after the previous code. So by this time the files should be
# in place, if they could be produced.
install( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/LowestUnprescaledLists/unprescaled/
DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/TriggerMenu
USE_SOURCE_PERMISSIONS
FILES_MATCHING PATTERN "list*.py" )
# Create a target that will depend on all the other targets, and will
# print the "right message" at the end of the build.
if( NOT TARGET TriggerMenuMain )
add_custom_target( TriggerMenuMain ALL
COMMAND ${CMAKE_COMMAND} -E echo
"TriggerMenu: Package build succeeded" )
endif()
add_dependencies( TriggerMenuMain build_menu_unprescaled )
endfunction ( atlas_run_lowestunprescaled )
atlas_run_lowestunprescaled ( )
#!/usr/bin/env python
import sys, pickle
from TriggerMenu.api.TriggerInfo import *
from TriggerMenu.api.TriggerEnums import TriggerPeriod
class TriggerAPI:
pickleFile = "TriggerInfo.pickle"
try:
with open(pickleFile, 'r') as f:
dbQueries = pickle.load(f)
except Exception as e:
dbQueries = {}
@classmethod
def getLowestUnprescaled(cls, period, triggerType=TriggerType.ALL, additionalTriggerType=TriggerType.UNDEFINED, matchPattern="", reparse=False):
''' Returns a list of the lowest-pt-threshold HLT chains that were always unprescaled in the given period.
period: see TriggerEnums.TriggerPeriod for all possibilities, recommeded TriggerPeriod.y2017
triggerType: see TriggerEnums.TriggerType for all possibilities, example TriggerType.el_single
additionalTriggerType: can request additional types, use TriggerType.ALL to show combined triggers of any kind
matchPattern: provide additionally a regex-like expression to be applied
'''
cls._loadTriggerPeriod(period,reparse)
return cls.dbQueries[period]._getLowestUnprescaled(triggerType, additionalTriggerType, matchPattern)
@classmethod
def getLowestUnprescaledAnyPeriod(cls, period, triggerType=TriggerType.ALL, additionalTriggerType=TriggerType.UNDEFINED, matchPattern="", reparse=False):
''' Returns a list of the lowest-pt-threshold HLT chains that were unprescaled in at least one of
the subperiods within the given period. The lowest granularity can be seen in TriggerEnums.TriggerPeriod
period: see TriggerEnums.TriggerPeriod for all possibilities, recommeded TriggerPeriod.y2017
triggerType: see TriggerEnums.TriggerType for all possibilities, example TriggerType.el_single
additionalTriggerType: can request additional types to match, use TriggerType.ALL to show combined triggers of any kind
accepts also a list as input in that case all types have to match
matchPattern: provide additionally a regex-like expression to be applied
'''
lowset = set()
for i, ibin in enumerate(reversed(bin(period)[2:])): #to binary
ibin = int(ibin)
if not ibin: continue
subperiod = 2**i
cls._loadTriggerPeriod(subperiod, reparse)
subperiodset = set( cls.dbQueries[subperiod]._getLowestUnprescaled(triggerType, additionalTriggerType, matchPattern) )
#print TriggerPeriod(subperiod), subperiodset
lowset |= subperiodset
return list(lowset)
@classmethod
def getUnprescaled(cls, period, triggerType=TriggerType.ALL, additionalTriggerType=TriggerType.UNDEFINED, matchPattern="", reparse=False):
''' Returns a list of always-unprescaled HLT chains, including backup items with higher thresholds.
period: see TriggerEnums.TriggerPeriod for all possibilities, recommeded TriggerPeriod.y2017
triggerType: see TriggerEnums.TriggerType for all possibilities, example TriggerType.el_single
additionalTriggerType: can request additional types, use TriggerType.ALL to show combined triggers of any kind
matchPattern: provide additionally a regex-like expression to be applied
'''
cls._loadTriggerPeriod(period,reparse)
return cls.dbQueries[period]._getUnprescaled(triggerType, additionalTriggerType, matchPattern)
@classmethod
def getAllHLT(cls, period, triggerType=TriggerType.ALL, additionalTriggerType=TriggerType.UNDEFINED, matchPattern="", reparse=False):
''' Returns a map of {HLT chains: average live fraction} for a given period.
The average live fraction is an approximation weighting the number of lumiblocks by prescale.
*** Don't use this number in analysis!!! ***
period: see TriggerEnums.TriggerPeriod for all possibilities, recommeded TriggerPeriod.y2017
triggerType: see TriggerEnums.TriggerType for all possibilities, example TriggerType.el_single
additionalTriggerType: can request additional types, use TriggerType.ALL to show combined triggers of any kind
matchPattern: provide additionally a regex-like expression to be applied
'''
cls._loadTriggerPeriod(period,reparse)
return cls.dbQueries[period]._getAllHLT(triggerType, additionalTriggerType, matchPattern)
@classmethod
def _loadTriggerPeriod(cls, period, reparse):
if period not in cls.dbQueries:
cls.dbQueries[period] = TriggerInfo(period)
if not period & TriggerPeriod.future or period >= TriggerPeriod.runNumber:
#Don't pickle TM information since it can change, very cheap to retrieve anyway
with open(cls.pickleFile, 'w') as f:
pickle.dump( cls.dbQueries , f)
if reparse: cls.dbQueries[period].reparse()
def main():
''' Run some tests '''
from TriggerEnums import TriggerPeriod, TriggerType
for triggerType in TriggerType:
unprescaled = TriggerAPI.getLowestUnprescaled(TriggerPeriod.y2017periodAll,triggerType)
#unprescaled = TriggerAPI.getLowestUnprescaled(332303,triggerType)
print triggerType
print sorted(unprescaled)
print TriggerAPI.getLowestUnprescaled(337833,TriggerType.mu_bphys,matchPattern="bJpsi")
print TriggerAPI.getLowestUnprescaled(337833,TriggerType.xe,matchPattern="pufit")
if __name__ == "__main__":
sys.exit(main())
#!/usr/bin/env python
import sys, pickle
from TriggerMenu.api.TriggerEnums import TriggerPeriod, LBexceptions
from TriggerMenu.api.TriggerPeriodData import TriggerPeriodData
def getRunLBFromU64(runlb):
run = runlb >> 32
lb = runlb & ((1L<<32)-1)
return ( int(run), int(lb) )
def getReadyForPhysicsInRange(period):
"""
returns all runs in the given period which have the ReadyForPhysics flag set in at least 1 LB
"""
print "Loading COOL libs..."
from CoolLumiUtilities.CoolDataReader import CoolDataReader
print "Done loading libs, starting now ..."
myReader = CoolDataReader('COOLONL_TDAQ/CONDBR2', '/TDAQ/RunCtrl/DataTakingMode')
runsWithReady = {}
firstRun = min([x for x in period.keys()])
lastRun = max([x for x in period.keys()])+1
since = ((1L*firstRun) << 32)
until = ((1L*lastRun) << 32)
myReader.setIOVRange( since, until )
myReader.readData()
for obj in myReader.data:
isReady = (obj.payload()['ReadyForPhysics'] == 1)
if not isReady:
continue
sincerun, sincelb = getRunLBFromU64(obj.since())
untilrun, untillb = getRunLBFromU64(obj.until())
if sincerun != untilrun:
print "WARNING: ready block crosses run boundaries:", sincerun, untilrun
if sincerun not in period: continue
#if untilrun not in runlist: print "WTF", sincerun, untilrun
if sincerun in runsWithReady:
runsWithReady[sincerun] += [ (sincelb, untillb) ]
else:
runsWithReady[sincerun] = [ (sincelb, untillb) ]
print runsWithReady
return runsWithReady
def getAllReadyForPhysics(period, doPrint = False):
runsWithReadyForPhysics = getReadyForPhysicsInRange(period)
if doPrint:
for year in years:
print ""
print year
print "===="
print "%i runs with ReadyForPhysics" % len(runsWithReadyForPhysics[year])
for i,r in enumerate( sorted(runsWithReadyForPhysics[year].keys())):
print "%i," % r,
if (i+1)%15 == 0: print ""
print ""
return runsWithReadyForPhysics
def getKeys( listOfRuns, doPrint = False ):
from CoolLumiUtilities.CoolDataReader import CoolDataReader
keysByRun = {}
mySmkReader = CoolDataReader('COOLONL_TRIGGER/CONDBR2', '/TRIGGER/HLT/HltConfigKeys')
myL1pskReader = CoolDataReader('COOLONL_TRIGGER/CONDBR2', '/TRIGGER/LVL1/Lvl1ConfigKey')
myHltpskReader = CoolDataReader('COOLONL_TRIGGER/CONDBR2', '/TRIGGER/HLT/PrescaleKey')
myBgskReader = CoolDataReader('COOLONL_TRIGGER/CONDBR2', '/TRIGGER/LVL1/BunchGroupKey')
for run in sorted(listOfRuns):
listOfReadyBlocks = listOfRuns[run]
print "Getting keys for run %i, lbs %r" % (run, listOfReadyBlocks)
since = ((1L*run) << 32)
until = ((1L*(run+1)) << 32)
# super master key
mySmkReader.setIOVRange( since, until - 1 )
mySmkReader.readData()
for obj in mySmkReader.data:
smk = obj.payload()['MasterConfigurationKey']
sincerun, sincelb = getRunLBFromU64(obj.since())
untilrun, untillb = getRunLBFromU64(obj.until())
keysByRun.setdefault(run,{})['smk'] = smk
for sincelb, untillb in listOfReadyBlocks:
since = ((1L*run) << 32) + sincelb
until = ((1L*run) << 32) + untillb
# l1 prescale keys
myL1pskReader.setIOVRange( since, until )
myL1pskReader.readData()
for obj in myL1pskReader.data:
l1psk = obj.payload()['Lvl1PrescaleConfigurationKey']
sincerun2, sincelb2 = getRunLBFromU64(obj.since())
untilrun2, untillb2 = getRunLBFromU64(obj.until())
if sincelb2 == untillb: break
keysByRun.setdefault(run,{}).setdefault('l1psk',[]).append((l1psk,sincerun2, sincelb2,untilrun2, untillb2-1)) #use same convention as GRL, last lb is included
# hlt prescale keys
myHltpskReader.setIOVRange( since, until )
myHltpskReader.readData()
for obj in myHltpskReader.data:
hltpsk = obj.payload()['HltPrescaleKey']
sincerun2, sincelb2 = getRunLBFromU64(obj.since())
untilrun2, untillb2 = getRunLBFromU64(obj.until())
if sincelb2 == untillb: break
keysByRun.setdefault(run,{}).setdefault('hltpsk',[]).append((hltpsk,sincerun2, sincelb2,untilrun2, untillb2-1)) #use same convention as GRL, last lb is included
## Bunch group key
#myBgskReader.setIOVRange( since, until )
#myBgskReader.readData()
#for obj in myBgskReader.data:
# bgsk = obj.payload()['Lvl1BunchGroupConfigurationKey']
# sincerun2, sincelb2 = getRunLBFromU64(obj.since())
# untilrun2, untillb2 = getRunLBFromU64(obj.until())
# keysByRun.setdefault(run,{}).setdefault('bgsk',[]).append(bgsk)
if doPrint:
print keysByRun
return keysByRun
def getHLTPrescalesRun2(connection,psk):
"""returns set name, prescale and passthrough
values for a given HLT prescale key
@connection - connection string, e.g. TRIGGERDB
@psk - HLT prescale key
@return (ps name, [('L2/EF',chainId,prescale,pass-through),...])
"""
res = queryHLTPrescaleTableRun2(connection,psk)
return {r[0]:r[3] for r in res if r and r[1]=='Prescale'}
def queryHLTPrescaleTableRun2(connection,psk):
from TrigConfigSvc.TrigConfigSvcUtils import getTriggerDBCursor, executeQuery
global cursor, schemaname
cursor,schemaname = getTriggerDBCursor(connection)
output = [ "PS.HPR_CHAIN_COUNTER", "PS.HPR_TYPE", "PS.HPR_CONDITION" , "PS.HPR_VALUE"]
tables = {}
tables['PS'] = 'HLT_PRESCALE'
condition = [ "PS.HPR_PRESCALE_SET_ID = :psk" ]
bindvars = { "psk": psk }
res = executeQuery(cursor, output, condition, schemaname, tables, bindvars)
return res
def fillHLTlist( info, hltList , lbCount, run, grlblocks):
from TrigConfigSvc.TrigConfigSvcUtils import getL1Items, getL1Prescales #, getHLTPrescalesRun2 #,getChains
from copy import deepcopy
items = getL1Items('TRIGGERDB', info['smk']) # returs map item name => CTP ID
chainsHLT = getChainsWithL1seed('TRIGGERDB', info['smk']) # returns map HLT ID => (HLT name, L1 seed)
chainsHLT = {k:v for (k,v) in chainsHLT.iteritems() if "L1" in v[1]}
#l1psname, l1prescales = getL1Prescales('TRIGGERDB', info['l1psk'][0][0]) # here only asking for the first LB prescale key
#l1prescales is a list of 512 prescales, also for IDs which were not used
#hltprescales = getHLTPrescalesRun2('TRIGGERDB', info['hltpsk'][0][0])
#hltprescales is a map HLTID -> prescale
tmphltList = []
for lbrange in info['hltpsk']:
lbstart, lbend = lbrange[2], lbrange[4]
if lbend ==0: lbend = 2000
hltprescales = getHLTPrescalesRun2('TRIGGERDB', lbrange[0])
tmphltList.append(( lbstart, lbend,hltprescales) )
tmpl1List = []
for lbrange in info['l1psk']:
lbstart, lbend = lbrange[2], lbrange[4]
if lbend ==0: lbend = 2000
l1psname, l1prescales = getL1Prescales('TRIGGERDB', lbrange[0])
l1prescales = {l1name: l1prescales[int(l1id)] for (l1name, l1id) in items.iteritems()}
tmpl1List.append(( lbstart, lbend,l1prescales) )
##if the lb limits don't match shut out and skip for the momenet
#if tmpl1List[0][0] != tmphltList[0][0] or tmpl1List[-1][1] != tmphltList[-1][1]:
# print "FUCK", run, tmpl1List[0][:2], tmphltList[0][:2], tmpl1List[-1][:2], tmphltList[-1][:2]
#merge the lb ranges of HLT and L1
hltindex, l1index = 0,0
mergedList = []
while hltindex < len(tmphltList) and l1index < len(tmpl1List) :
if tmphltList[hltindex][1] == tmpl1List[l1index][1]:
lbstart, lbend = max(tmphltList[hltindex][0],tmpl1List[l1index][0]), tmphltList[hltindex][1]
mergedList.append((lbstart, lbend,tmphltList[hltindex][2],tmpl1List[l1index][2]))
hltindex += 1
l1index += 1
elif tmphltList[hltindex][1] > tmpl1List[l1index][1]:
lbstart, lbend = max(tmphltList[hltindex][0],tmpl1List[l1index][0]), tmpl1List[l1index][1]
mergedList.append((lbstart, lbend,tmphltList[hltindex][2],tmpl1List[l1index][2]))
l1index += 1
else:
lbstart, lbend = max(tmphltList[hltindex][0],tmpl1List[l1index][0]), tmphltList[hltindex][1]
mergedList.append((lbstart, lbend,tmphltList[hltindex][2],tmpl1List[l1index][2]))
hltindex += 1
hltMap = {}
for lbstart, lbend, hltprescales, l1prescales in mergedList:
lboverlap = max([min(lbend,grllbend) - max(lbstart,grllbstart) for (grllbstart,grllbend) in grlblocks])+1
if lboverlap <= 0:
#print "Rejected:",(lboverlap, lbstart, lbend, grlblocks)
continue
if run in LBexceptions.exceptions:
if any([lbstart>=exc_start and lbstart<=exc_end for exc_start, exc_end in LBexceptions.exceptions[run]]): continue
#print "Accepted:",(lboverlap, lbstart, lbend, grlblocks)
lbCount += lboverlap
for hltid, hltps in hltprescales.iteritems():
if hltid not in chainsHLT: continue
if hltps < 1: hltps = 1e10
l1seeds = chainsHLT[hltid][1]
l1ps = 1e10
for l1seed in l1seeds.split(","): #protect L1_MU20,L1_MU21
tmpl1ps = l1prescales[l1seed]
if tmpl1ps < 1: tmpl1ps = 1e10
l1ps = min(l1ps, tmpl1ps)
efflb = lboverlap/(hltps*l1ps)
if chainsHLT[hltid][0] == "HLT_2mu6_bUpsimumu_L1BPH-8M15-2MU6_BPH-0DR22-2MU6" and (hltps*l1ps)>1:
print "HLT_mu50:",run,(lboverlap, lbstart, lbend, grlblocks),hltps,l1ps
if not chainsHLT[hltid][0] in hltMap: hltMap[chainsHLT[hltid][0]] = [l1seeds, 0]
hltMap[chainsHLT[hltid][0]][1] += efflb
for i, (hlt,(l1,efflb)) in enumerate(hltList):
if hlt in hltMap: hltMap[hlt][1] += efflb
else: hltMap[hlt] = (l1, efflb)
return hltMap.items(), lbCount
def getChainsWithL1seed(connection, smk):
'''copy of getChains but retrieving also the L1 seed and assuming always run2
https://gitlab.cern.ch/atlas/athena/blob/master/Trigger/TrigConfiguration/TrigConfigSvc/python/TrigConfigSvcUtils.py#L611
'''
from TrigConfigSvc.TrigConfigSvcUtils import getTriggerDBCursor, executeQuery
cursor,schemaname = getTriggerDBCursor(connection)
output = ['TC.HTC_ID', 'TC.HTC_CHAIN_COUNTER', 'TC.HTC_NAME', 'TC.HTC_LOWER_CHAIN_NAME']
tables = {}
tables['SM'] = 'SUPER_MASTER_TABLE'
tables['M2C'] = 'HLT_TM_TO_TC'
tables['TC'] = 'HLT_TRIGGER_CHAIN'
tables['MT'] = 'HLT_MASTER_TABLE'
condition = [ "SM.SMT_ID = :smk",
'SM.SMT_HLT_MASTER_TABLE_ID = MT.HMT_ID',
'MT.HMT_TRIGGER_MENU_ID = M2C.HTM2TC_TRIGGER_MENU_ID',
'M2C.HTM2TC_TRIGGER_CHAIN_ID = TC.HTC_ID' ]
bindvars = { "smk": smk }
res = executeQuery(cursor, output, condition, schemaname, tables, bindvars)
chainsef = {}
for x in res:
if len(x)!=4: continue #protect against HLT_noalg_bkg_L1Bkg and similars
chainsef[x[1]] = (x[2],x[3])
return chainsef
def getHLTlist_fromDB(period):
''' Return a list of (HLT chain, L1 seed, average prescale ) for a given period
The average prescale is an approximation weighting the PS by number of lumiblocks.
*** Don't use this number in analysis!!! ***
'''
triggerPeriod = TriggerPeriodData( period ).grl
runsWithReadyForPhysics = getAllReadyForPhysics(triggerPeriod)
keys = getKeys( runsWithReadyForPhysics)
# get keys for last run
#lastRun = sorted(keys.keys())[-1:]
#lastRuns = sorted(keys.keys())[-10:]
#print "Checking run:",lastRun
hltList = []
lbCount = 0
for run in keys:
print "Filling run:",run
hltList, lbCount = fillHLTlist( keys[run], hltList, lbCount , run, triggerPeriod[run])
#print "After filling, items/lbCount: ",len(hltList),lbCount
#print "mu26_ivarmedium items:",[(x, l1, ps) for x, (l1, ps) in hltList if "mu26_ivarmedium" in x]
return [(x, l1, ps/float(lbCount)) for x, (l1, ps) in hltList]
return 0
def getHLTlist_fromTM(period):
''' Return a list of (HLT chain, L1 seed, prescale ) for a given period
Only "Future" periods make sense here
The format is the same as for TriggerDBAccess for compatibility but the l1seeds are empty
'''
from TriggerMenu.menu import Physics_pp_v7
from TriggerJobOpts.TriggerFlags import TriggerFlags
Physics_pp_v7.setupMenu()
if not period & TriggerPeriod.future: return []
maxlumi = 20000
if period & TriggerPeriod.future1p8e34: maxlumi = 17000
elif period & TriggerPeriod.future2e34: maxlumi = 20000
else: print "Warning non-recongnized future",period
hltList = []
for prop in dir(TriggerFlags):
if prop[-5:]!='Slice': continue
sliceName=prop
m_slice=getattr(TriggerFlags,sliceName)
for m in m_slice.signatures():
#['mu28_ivarmedium', 'L1_MU20MU21', ['L1_MU20'], [PhysicsStream], ['Primary:20000','RATE:SingleMuon', 'BW:Muon'], -1],
hltname = 'HLT_'+m[0]
l1seed = m[1]
comment = m[4][0]
ps = 1e10
if maxlumi <= 20000 and 'Primary:20000' in comment: ps = 1
if maxlumi <= 17000 and 'Primary:17000' in comment: ps = 1
hltList.append( (hltname, l1seed, ps) )
return hltList
def getHLTlist(period):
''' Return a list of (HLT chain, L1 seed, average prescale ) for a given period
The average prescale is an approximation weighting the PS by number of lumiblocks.
*** Don't use this number in analysis!!! ***
For "future" periods, the average prescale is 1 for items flagged as primary in TM and 1e10 for non-primaries
'''
if not period & TriggerPeriod.future or period >= TriggerPeriod.runNumber:
hltlist = getHLTlist_fromDB(period)
else:
hltlist = getHLTlist_fromTM(period)
vetoes = ['calib','noise','noalg','EMPTY','UNPAIRED']
return [(name, l1seed,ps) for name, l1seed,ps in hltlist if not any(v in name for v in vetoes)]
def test():
print getHLTlist(TriggerPeriod.y2017)
if __name__ == "__main__":
sys.exit(test())
#!/usr/bin/env python
from enum import IntEnum
class TriggerType(IntEnum):
el_single = 1 << 0
el_multi = 1 << 1
mu_single = 1 << 2
mu_multi = 1 << 3
j_single = 1 << 4
j_multi = 1 << 5
bj_single = 1 << 6
bj_multi = 1 << 7
tau_single = 1 << 8
tau_multi = 1 << 9
g_single = 1 << 10
g_multi = 1 << 11
xe = 1 << 12
ht = 1 << 13
mu_bphys = 1 << 14
exotics = 1 << 15
el = el_single | el_multi
mu = mu_single | mu_multi
j = j_single | j_multi
bj = bj_single | bj_multi
tau = tau_single| tau_multi
g = g_single | g_multi
ALL = el | mu | j | bj | tau | g | xe | ht | mu_bphys | exotics