Skip to content
Snippets Groups Projects
Commit d06dc2b9 authored by Catrin Bernius's avatar Catrin Bernius
Browse files

Merge branch '21.1_triggerAPIupdate' into '21.1'

TriggerAPI updates

See merge request atlas/athena!13000

Former-commit-id: 9f902136470785d32c4bc6a9076efd3c37ce3125
parents 18f75184 38694248
No related branches found
No related tags found
No related merge requests found
......@@ -10,10 +10,10 @@ from PathResolver import PathResolver
from AthenaCommon.Logging import logging
class TriggerAPI:
centralPickleFile = PathResolver.FindCalibFile("TriggerMenu/TriggerInfo_20180703.pickle")
centralPickleFile = PathResolver.FindCalibFile("TriggerMenu/TriggerInfo_20180725.pickle")
if centralPickleFile: centralPickleFile = os.path.realpath(centralPickleFile)
privatePickleFile = "TriggerInfo.pickle"
dbQueries = None
dbQueries = {}
privatedbQueries = {}
customGRL = None
log = logging.getLogger( 'TriggerMenu.api.TriggerAPI.py' )
......@@ -26,7 +26,7 @@ class TriggerAPI:
with open(cls.centralPickleFile, 'r') as f:
cls.log.info("Reading cached information from: "+cls.centralPickleFile)
cls.dbQueries = pickle.load(f)
except pickle.PickleError:
except (pickle.PickleError, ValueError):
cls.log.info("Reading cached information failed")
cls.dbQueries = {}
else:
......@@ -35,7 +35,7 @@ class TriggerAPI:
with open(cls.privatePickleFile, 'r') as f:
cls.privatedbQueries = pickle.load(f)
cls.dbQueries.update(cls.privatedbQueries)
except pickle.PickleError:
except (pickle.PickleError, ValueError):
cls.log.error("Error unpickling the private file")
except IOError:
pass
......@@ -67,13 +67,7 @@ class TriggerAPI:
def getLowestUnprescaledAnyPeriod(cls, period, triggerType=TriggerType.ALL, additionalTriggerType=TriggerType.UNDEFINED, matchPattern="", livefraction=1.0, 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
livefraction: accept items that are not unprescaled but have a live fraction above this threshold, example 0.95
The live fraction is only an approximation, weighting the number of lumiblocks by prescale.
See getLowestUnprescaled for a detailed description of the options
'''
lowset = set()
for i, ibin in enumerate(reversed(bin(period)[2:])): #to binary
......@@ -88,13 +82,7 @@ class TriggerAPI:
@classmethod
def getUnprescaled(cls, period, triggerType=TriggerType.ALL, additionalTriggerType=TriggerType.UNDEFINED, matchPattern="", livefraction=1.0, 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 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
livefraction: accept items that are not unprescaled but have a live fraction above this threshold, example 0.95
The live fraction is only an approximation, weighting the number of lumiblocks by prescale.
See getLowestUnprescaled for a detailed description of the options
'''
cls._loadTriggerPeriod(period,reparse)
return cls.dbQueries[(period,cls.customGRL)]._getUnprescaled(triggerType, additionalTriggerType, matchPattern, livefraction)
......@@ -103,13 +91,7 @@ class TriggerAPI:
def getUnprescaledAnyPeriod(cls, period, triggerType=TriggerType.ALL, additionalTriggerType=TriggerType.UNDEFINED, matchPattern="", livefraction=1.0, reparse=False):
''' Returns a list of 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
livefraction: accept items that are not unprescaled but have a live fraction above this threshold, example 0.95
The live fraction is only an approximation, weighting the number of lumiblocks by prescale.
See getLowestUnprescaled for a detailed description of the options
'''
lowset = set()
for i, ibin in enumerate(reversed(bin(period)[2:])): #to binary
......@@ -124,13 +106,7 @@ class TriggerAPI:
@classmethod
def getInactive(cls, period, triggerType=TriggerType.ALL, additionalTriggerType=TriggerType.UNDEFINED, matchPattern="", livefraction=1e-99, reparse=False):
''' Returns a list of HLT chains that were fully inactive, excluding disabled chains in rerun.
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
livefraction: accept items that are not unprescaled but have a live fraction above this threshold, example 0.95
The live fraction is only an approximation, weighting the number of lumiblocks by prescale.
See getLowestUnprescaled for a detailed description of the options
'''
cls._loadTriggerPeriod(period,reparse)
return cls.dbQueries[(period,cls.customGRL)]._getInactive(triggerType, additionalTriggerType, matchPattern, livefraction)
......@@ -138,40 +114,26 @@ class TriggerAPI:
@classmethod
def getActive(cls, period, triggerType=TriggerType.ALL, additionalTriggerType=TriggerType.UNDEFINED, matchPattern="", livefraction=1e-99, reparse=False):
''' Returns a list of HLT chains that were active at some point, including disabled chains in rerun.
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
livefraction: accept items that are not unprescaled but have a live fraction above this threshold, example 0.95
The live fraction is only an approximation, weighting the number of lumiblocks by prescale.
See getLowestUnprescaled for a detailed description of the options
'''
cls._loadTriggerPeriod(period,reparse)
return cls.dbQueries[(period,cls.customGRL)]._getActive(triggerType, additionalTriggerType, matchPattern, livefraction)
@classmethod
def getAllHLT(cls, period, triggerType=TriggerType.ALL, additionalTriggerType=TriggerType.UNDEFINED, matchPattern="", reparse=False):
def getAllHLT(cls, period, triggerType=TriggerType.ALL, additionalTriggerType=TriggerType.UNDEFINED, matchPattern="", livefraction=0, 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 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
See getLowestUnprescaled for a detailed description of the options
'''
cls._loadTriggerPeriod(period,reparse)
return cls.dbQueries[(period,cls.customGRL)]._getAllHLT(triggerType, additionalTriggerType, matchPattern)
return cls.dbQueries[(period,cls.customGRL)]._getAllHLT(triggerType, additionalTriggerType, matchPattern, livefraction)
@classmethod
def checkPeriodConsistency(cls, period=TriggerPeriod.future, triggerType=TriggerType.ALL, additionalTriggerType=TriggerType.UNDEFINED, matchPattern="", reparse=False):
''' Returns a list of triggers that are tighter than the lowest unprescaled but are not flagged as primary
This only makes sense for future periods, the past is already consistent :)
period: see TriggerEnums.TriggerPeriod for all possibilities, recommeded TriggerPeriod.future
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
See getLowestUnprescaled for a detailed description of the options
'''
period &= TriggerPeriod.future #Only meaningful for future periods
cls._loadTriggerPeriod(period,reparse)
......@@ -179,7 +141,7 @@ class TriggerAPI:
@classmethod
def _loadTriggerPeriod(cls, period, reparse):
cls.init()
if not period & TriggerPeriod.future: cls.init()
if (period,cls.customGRL) not in cls.dbQueries:
if TriggerPeriod.isRunNumber(period) or (isinstance(period,TriggerPeriod) and period.isBasePeriod()):
cls.dbQueries[(period,cls.customGRL)] = TriggerInfo(period,cls.customGRL)
......@@ -198,6 +160,9 @@ class TriggerAPI:
@classmethod
def dumpFullPickle(cls):
for period,grl in cls.dbQueries.keys():
if TriggerPeriod.isRunNumber(period) or (isinstance(period,TriggerPeriod) and period.isBasePeriod()): continue
del cls.dbQueries[(period,grl)]
with open(cls.privatePickleFile, 'w') as f:
pickle.dump( cls.dbQueries , f)
print sorted(cls.dbQueries.keys())
......
......@@ -4,7 +4,7 @@ __version__="$Revision: 1.01 $"
__doc__="Access to Trigger DB and TriggerMenu to read past and future prescales"
import sys
from TriggerMenu.api.TriggerEnums import TriggerPeriod, LBexceptions
from TriggerMenu.api.TriggerEnums import TriggerPeriod, LBexceptions, TriggerRenaming
from TriggerMenu.api.TriggerPeriodData import TriggerPeriodData
def getRunLBFromU64(runlb):
......@@ -156,8 +156,12 @@ def queryHLTPrescaleTableRun2(connection,psk):
return res
def fillHLTlist( info, hltList , lbCount, run, grlblocks):
def fillHLTmap( info, hltMap_prev , lbCount, run, grlblocks):
from TrigConfigSvc.TrigConfigSvcUtils import getL1Items, getL1Prescales
from AthenaCommon.Logging import logging
log = logging.getLogger( "TrigConfigSvcUtils.py" )
log.setLevel(logging.ERROR) #avoid the spam from TrigConfigSvcUtils
items = getL1Items('TRIGGERDB', info['smk']) # returs map item name => CTP ID
chainsHLT = getChainsWithL1seed('TRIGGERDB', info['smk']) # returns map HLT ID => (HLT name, L1 seed)
......@@ -218,17 +222,18 @@ def fillHLTlist( info, hltList , lbCount, run, grlblocks):
if tmpl1ps < 1: tmpl1ps = 1e99
l1ps = min(l1ps, tmpl1ps)
efflb = lboverlap/(hltps*l1ps)
if hltps*l1ps < 1e99: efflb = lboverlap/(hltps*l1ps)
else: efflb = 0
if not chainsHLT[hltid][0] in hltMap: hltMap[chainsHLT[hltid][0]] = [l1seeds, 0, hltrerun>0]
hltMap[chainsHLT[hltid][0]][1] += efflb
for i, (hlt,(l1,efflb,rerun)) in enumerate(hltList):
for hlt,(l1,efflb,rerun) in hltMap_prev.iteritems():
if hlt in hltMap:
hltMap[hlt][1] += efflb
hltMap[hlt][2] |= rerun
else: hltMap[hlt] = (l1, efflb,rerun)
else: hltMap[hlt] = [l1, efflb,rerun]
return hltMap.items(), lbCount
return hltMap, lbCount
def getChainsWithL1seed(connection, smk):
......@@ -263,42 +268,39 @@ def getChainsWithL1seed(connection, smk):
def getHLTlist_fromDB(period, customGRL):
''' 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!!! ***
def getHLTmap_fromDB(period, customGRL):
''' Return a map of HLT chain: (L1 seed, active LBs, is-rerun) for a given period
'''
triggerPeriod = TriggerPeriodData( period, customGRL ).grl
if not triggerPeriod: return [],0
if not triggerPeriod: return {},0
runsWithReadyForPhysics = getReadyForPhysicsInRange(triggerPeriod)
keys = getKeys( runsWithReadyForPhysics)
hltList = []
hltMap = {}
lbCount = 0
for run in keys:
print "Filling run:",run
hltList, lbCount = fillHLTlist( keys[run], hltList, lbCount , run, triggerPeriod[run])
hltMap, lbCount = fillHLTmap( keys[run], hltMap, lbCount , run, triggerPeriod[run])
hltList = [(x, l1, activeLB/float(lbCount), activeLB, hasRerun) for x, (l1, activeLB, hasRerun) in hltList]
return hltList, lbCount
return hltMap, lbCount
def getHLTlist_fromTM(period):
''' Return a list of (HLT chain, L1 seed, prescale ) for a given period
def getHLTmap_fromTM(period):
''' Return a map of HLT chain: (L1 seed, active LBs, is-rerun) 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
The format is the same as for TriggerDBAccess for compatibility but rerun is always false
'''
from TriggerMenu.menu import Physics_pp_v7
from TriggerJobOpts.TriggerFlags import TriggerFlags
Physics_pp_v7.setupMenu()
if not period & TriggerPeriod.future: return []
if not period & TriggerPeriod.future: return {}, 0
maxlumi = 20000
if period & TriggerPeriod.future1p8e34: maxlumi = 17000
elif period & TriggerPeriod.future2e34: maxlumi = 20000
else: print "Warning non-recongnized future",period
hltList = []
hltMap = {}
dummyfutureLBs = 1e6
for prop in dir(TriggerFlags):
if prop[-5:]!='Slice': continue
......@@ -312,25 +314,38 @@ def getHLTlist_fromTM(period):
ps = 0
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, dummyfutureLBs*ps, False) ) #hasRerun=False
hltMap[hltname] = (l1seed, dummyfutureLBs*ps, False) #hasRerun=False
return hltList, dummyfutureLBs
return hltMap, dummyfutureLBs
def getHLTlist(period, customGRL):
''' For a given period it returns: [HLT chain, L1 seed, average livefraction, active LB], total LB
The average prescale is an approximation weighting the PS by number of lumiblocks.
''' For a given period it returns: [HLT chain, L1 seed, average livefraction, active LB, is-rerun], total LB
The average livefraction 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 0 for non-primaries
For "future" periods, the average livefraction is 1 for items flagged as primary in TM and 0 for non-primaries
'''
if not period & TriggerPeriod.future or TriggerPeriod.isRunNumber(period):
hltlist, totalLB = getHLTlist_fromDB(period, customGRL)
hltmap, totalLB = getHLTmap_fromDB(period, customGRL)
else:
hltlist, totalLB = getHLTlist_fromTM(period)
hltmap, totalLB = getHLTmap_fromTM(period)
vetoes = ['calib','noise','noalg','satmon','peb']
hltlist = [(name, l1seed, livefraction, activeLB, hasRerun) for name, l1seed, livefraction, activeLB, hasRerun in hltlist if not any(v in name for v in vetoes)]
hltlist = cleanHLTmap(hltmap, totalLB)
return (hltlist, totalLB)
def cleanHLTmap(hltmap, totalLB):
from copy import deepcopy
for name, (l1seed, activeLB, hasRerun) in deepcopy(hltmap).iteritems(): #since it will modify on the fly
for pair in TriggerRenaming.pairs:
if name==pair[0] and pair[1] in hltmap: hltmap[pair[1]][1] += activeLB
#if name==pair[0] and not pair[1] in hltmap: hltmap[pair[1]] = [l1seed, activeLB, hasRerun]
if name==pair[1] and pair[0] in hltmap: hltmap[pair[0]][1] += activeLB
#if name==pair[1] and not pair[0] in hltmap: hltmap[pair[0]] = [l1seed, activeLB, hasRerun]
vetoes = ['calib','noise','noalg','satmon','peb']
hltlist = [(name, l1seed, activeLB/totalLB, activeLB, hasRerun) for name, (l1seed, activeLB, hasRerun) in hltmap.iteritems() if not any(v in name for v in vetoes)]
return hltlist
def test():
print getHLTlist(TriggerPeriod.y2017,None)
......
......@@ -48,8 +48,11 @@ class TriggerPeriod(IntEnum):
y2017periodD6 = 1 << 10
y2017periodEF = 1 << 11
y2017periodGHIK = 1 << 12
y2017periodN = 1 << 13
y2018periodBF = 1 << 14
y2017lowmu = 1 << 13
y2018periodBE = 1 << 14
y2018periodFI = 1 << 15
y2018lowmu = 1 << 16
#y2018periodK = 1 << 17
runNumber = 1 << 18 #Can't get higher than this, enters the run number domain
future1p8e34 = 1 << 19
......@@ -57,8 +60,8 @@ class TriggerPeriod(IntEnum):
y2017periodB = y2017periodB1 | y2017periodB2B4 | y2017periodB5B7 | y2017periodB8
y2017periodD = y2017periodD1D5 | y2017periodD6
y2017periodAll = y2017periodB | y2017periodC | y2017periodD | y2017periodEF | y2017periodGHIK | y2017periodN
y2018 = y2018periodBF
y2017periodAll = y2017periodB | y2017periodC | y2017periodD | y2017periodEF | y2017periodGHIK #low-mu period is not considered
y2018 = y2018periodBE | y2018periodFI #low-mu period is not considered
y2017 = y2017periodAll
y2016 = y2016periodA | y2016periodBD3 | y2016periodD4plus
future = future1p8e34 | future2e34
......@@ -87,8 +90,22 @@ class LBexceptions:
301932: [(233, 234)], #Accidentaly moved to MuScan prescales
302831: [(4 , 10 )], #toroid off keys
336506: [(212, 260)], #Regular muscan but the defect is not in sync with the switch of keys
352448: [(104, 104)], #First LB of emittance scan
341294: [(137, 156)], #Standby keys
}
class TriggerRenaming:
''' Pairs of triggers that have been renamed at some point
The code will complete each other so that each contains
luminosity of both
Assumes that they are orthogonal, i.e. they haven't run both at the same time
'''
pairs = [
("HLT_mu20_mu8noL1_e9_lhvloose_nod0","HLT_e9_lhvloose_nod0_mu20_mu8noL1"),
("HLT_mu20_mu8noL1_e9_lhvloose_nod0_L1EM8VH_MU20","HLT_e9_lhvloose_nod0_mu20_mu8noL1_L1EM8VH_MU20"),
("HLT_mu20_mu8noL1_e9_lhvloose_nod0_L1EM7_MU20","HLT_e9_lhvloose_nod0_mu20_mu8noL1_L1EM7_MU20"),
]
if __name__ == "__main__":
print TriggerPeriod.y2015.isBasePeriod()
print TriggerPeriod.y2017.isBasePeriod()
......
......@@ -4,7 +4,7 @@ __version__="$Revision: 1.01 $"
__doc__="Class containing all the information of an HLT chain"
import re
from TriggerMenu.api.TriggerEnums import TriggerType
from TriggerMenu.api.TriggerEnums import TriggerType, TriggerPeriod
class TriggerInfo:
''' Object containing all the HLT information related to a given period.
......@@ -59,7 +59,7 @@ class TriggerInfo:
continue
append = False
for other in typeMap[chain.triggerType][:]:
comp = chain.isLowerThan(other)
comp = chain.isLowerThan(other,self.period)
if comp == 0:
append = False
break
......@@ -70,12 +70,12 @@ class TriggerInfo:
return [x.name for t in typeMap.itervalues() for x in t ]
def _getAllHLT(self,triggerType, additionalTriggerType, matchPattern):
return {x.name: x.livefraction for x in self.triggerChains if x.passType(triggerType, additionalTriggerType) and re.search(matchPattern, x.name)}
def _getAllHLT(self,triggerType, additionalTriggerType, matchPattern, livefraction):
return {x.name: x.livefraction for x in self.triggerChains if x.passType(triggerType, additionalTriggerType) and re.search(matchPattern, x.name) and x.isUnprescaled(livefraction)}
def _getActive(self,triggerType, additionalTriggerType, matchPattern, livefraction=1.0):
def _getActive(self,triggerType, additionalTriggerType, matchPattern, livefraction):
return [x.name for x in self.triggerChains if x.isActive(livefraction) and x.passType(triggerType, additionalTriggerType) and re.search(matchPattern, x.name)]
def _getInactive(self,triggerType, additionalTriggerType, matchPattern, livefraction=1.0):
def _getInactive(self,triggerType, additionalTriggerType, matchPattern, livefraction):
return [x.name for x in self.triggerChains if x.isInactive(livefraction) and x.passType(triggerType, additionalTriggerType) and re.search(matchPattern, x.name)]
def _checkPeriodConsistency(self,triggerType, additionalTriggerType, matchPattern):
......@@ -86,8 +86,8 @@ class TriggerInfo:
for j in range(i+1,len(self.triggerChains)):
probe2 = self.triggerChains[j]
if not (probe2.passType(triggerType, additionalTriggerType) and re.search(matchPattern, probe2.name)): continue
if probe1.isUnprescaled() and not probe2.isUnprescaled() and probe1.isLowerThan(probe2)==1: inconsistent.add(probe2.name)
if probe2.isUnprescaled() and not probe1.isUnprescaled() and probe2.isLowerThan(probe1)==1: inconsistent.add(probe1.name)
if probe1.isUnprescaled() and not probe2.isUnprescaled() and probe1.isLowerThan(probe2,self.period)==1: inconsistent.add(probe2.name)
if probe2.isUnprescaled() and not probe1.isUnprescaled() and probe2.isLowerThan(probe1,self.period)==1: inconsistent.add(probe1.name)
return inconsistent
......@@ -156,7 +156,7 @@ class TriggerLeg:
def __repr__(self):
return self.legname+" {0:b}".format(self.legtype)
def isLegLowerThan(self, other, debug=False):
def isLegLowerThan(self, other, is2015, debug=False):
''' Returns -9 if none of them is lower than the other (e.g. different met flavour).
Returns -1 if identical
Returns 0 if other is lower than self.
......@@ -169,21 +169,21 @@ class TriggerLeg:
print self.l1seed, other.l1seed
print self.details, other.details
print self.thr, other.thr
print self.compareDetails(other, debug=True)
print self.compareDetails(other, is2015, debug=True)
print self.details == other.details
print "DEBUG LEGS END --------"
if self.legtype != other.legtype: return -9
if self.compareDetails(other) == -1:
if self.compareDetails(other, is2015) == -1:
if self.thr < other.thr: return 1
if self.thr > other.thr: return 0
else: return -1
if self.compareDetails(other) == 1 and self.thr <= other.thr: return 1
if self.compareDetails(other) == 0 and other.thr <= self.thr: return 0
if self.compareDetails(other, is2015) == 1 and self.thr <= other.thr: return 1
if self.compareDetails(other, is2015) == 0 and other.thr <= self.thr: return 0
return -9
def compareDetails(self, other, debug=False):
def compareDetails(self, other, is2015, debug=False):
''' Returns -9 if none of them is lower than the other (e.g. different met flavour).
Returns -1 if identical
Returns 0 if other is lower than self.
......@@ -193,28 +193,28 @@ class TriggerLeg:
if debug: print "compareDetails:",len(self.details), len(other.details),(self.l1seed == other.l1seed),(self.details == other.details)
if len(self.details) != len(other.details):
if any([x.startswith("nod0") for x in self.details]):
if not is2015 and any([x.startswith("nod0") for x in self.details]):
cloneself = deepcopy(self)
cloneself.details = [ x for x in self.details if not x.startswith("nod0")]
compno = cloneself.compareDetails(other,debug)
compno = cloneself.compareDetails(other,is2015,debug)
if compno ==1 or compno == -1:
return 1
if any([x.startswith("nod0") for x in other.details]):
if not is2015 and any([x.startswith("nod0") for x in other.details]):
cloneother = deepcopy(other)
cloneother.details = [ x for x in other.details if not x.startswith("nod0")]
compno = self.compareDetails(cloneother,debug)
compno = self.compareDetails(cloneother,is2015,debug)
if compno ==0 or compno == -1:
return 0
if any([x.startswith("cut") for x in self.details]):
cloneself = deepcopy(self)
cloneself.details = [ x for x in self.details if not x.startswith("cut")]
compno = cloneself.compareDetails(other,debug)
compno = cloneself.compareDetails(other,is2015,debug)
if compno ==0 or compno == -1:
return 0
if any([x.startswith("cut") for x in other.details]):
cloneother = deepcopy(other)
cloneother.details = [ x for x in other.details if not x.startswith("cut")]
compno = self.compareDetails(cloneother,debug)
compno = self.compareDetails(cloneother,is2015,debug)
if compno ==1 or compno == -1:
return 1
return -9
......@@ -420,11 +420,13 @@ class TriggerChain:
print self.name, self.legs, "{0:b}".format(self.triggerType), self.livefraction, self.activeLB
return ""
def isLowerThan(self, other):
def isLowerThan(self, other,period=TriggerPeriod.future):
''' Returns -1 if none of them is lower than the other (e.g. asymmetric dilepton).
Returns 0 if other is lower than self.
Returns 1 if self is lower than other.
'''
is2015 = period & TriggerPeriod.y2015 and not TriggerPeriod.isRunNumber(period)
is2015 |= period <= 284484 and TriggerPeriod.isRunNumber(period)
if self.triggerType != other.triggerType: return -1
if len(self.legs) != len(other.legs): return -1
comp = -1
......@@ -432,7 +434,7 @@ class TriggerChain:
#if re.search("HLT_j55_gsc75_bmv2c1040_split_3j55_gsc75_boffperf_split", self.name): debug = True
if debug: print "DEBUG:",self.name,other.name
for selfleg, otherleg in zip(self.legs, other.legs):
legcomp = selfleg.isLegLowerThan(otherleg, debug)
legcomp = selfleg.isLegLowerThan(otherleg, is2015, debug)
if debug: print "DEBUG LEG return:", legcomp
if legcomp == -9: return -1
elif legcomp == -1: continue
......
......@@ -88,6 +88,11 @@ class TriggerPeriodData:
'D':(350310,352107,20422),
'E':(352123,352137,18296),
'F':(352274,352514,19938),
'G':(354107,354494,17012),
'H':(354826,355224,43.4 ),
'I':(355261,355273,17318),
'J':(355331,355468,18781),
#'K':(355529,355650,19341), still open
}
grlbase = "/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/"
......@@ -95,6 +100,7 @@ class TriggerPeriodData:
y2017grlpath = grlbase+"data17_13TeV/20180619/data17_13TeV.periodAllYear_DetStatus-v99-pro22-01_Unknown_PHYS_StandardGRL_All_Good_25ns_Triggerno17e33prim.xml"
y2016grlpath = grlbase+"data16_13TeV/20180129/data16_13TeV.periodAllYear_DetStatus-v89-pro21-01_DQDefects-00-02-04_PHYS_StandardGRL_All_Good_25ns.xml"
y2015grlpath = grlbase+"data15_13TeV/20170619/data15_13TeV.periodAllYear_DetStatus-v89-pro21-02_Unknown_PHYS_StandardGRL_All_Good_25ns.xml"
y2017lowmugrlpath = grlbase+"data17_13TeV/20180117/data17_13TeV.periodN_DetStatus-v98-pro21-16_Unknown_PHYS_StandardGRL_All_Good_25ns_ignore_GLOBAL_LOWMU.xml"
def __init__(self, period, customGRL=None):
if customGRL:
self.loadGRL(customGRL)
......@@ -104,6 +110,8 @@ class TriggerPeriodData:
self.loadGRL(self.y2015grlpath)
elif period & TriggerPeriod.y2016:
self.loadGRL(self.y2016grlpath)
elif period & TriggerPeriod.y2017lowmu:
self.loadGRL(self.y2017lowmugrlpath)
elif period & TriggerPeriod.y2017:
self.loadGRL(self.y2017grlpath)
elif period & TriggerPeriod.y2018:
......@@ -168,19 +176,28 @@ class TriggerPeriodData:
ranges.append( self.periodMap2017['H'] )
ranges.append( self.periodMap2017['I'] )
ranges.append( self.periodMap2017['K'] )
if period & TriggerPeriod.y2017periodN :
if period & TriggerPeriod.y2017lowmu :
ranges.append( self.periodMap2017['N'] )
if period & TriggerPeriod.y2018periodBF :
if period & TriggerPeriod.y2018periodBE :
ranges.append( self.periodMap2018['B'] )
ranges.append( self.periodMap2018['C'] )
ranges.append( self.periodMap2018['D'] )
ranges.append( self.periodMap2018['E'] )
if period & TriggerPeriod.y2018periodFI :
ranges.append( self.periodMap2018['F'] )
ranges.append( self.periodMap2018['G'] )
ranges.append( self.periodMap2018['H'] )
ranges.append( self.periodMap2018['I'] )
if period & TriggerPeriod.y2018lowmu :
ranges.append( self.periodMap2018['J'] )
#if period & TriggerPeriod.y2018periodK :
# ranges.append( self.periodMap2018['K'] )
for run in self.grl.keys()[:]:
if not any([run >= x[0] and run <= x[1] for x in ranges]): self.grl.pop(run)
def test():
print TriggerPeriodData( TriggerPeriod.y2015 ).grl
print TriggerPeriodData( TriggerPeriod.y2017 ).grl
print TriggerPeriodData( TriggerPeriod.y2017lowmu ).grl
if __name__ == "__main__":
sys.exit(test())
......
......@@ -29,8 +29,8 @@ print "Lowest in at least one period:",TriggerAPI.getLowestUnprescaledAnyPeriod(
# - retrieve items above a certain live fraction instead of unprescaled
# HLT_j225_gsc420_boffperf_split is unprescaled
# HLT_j225_gsc400_boffperf_split recorded >95% of the available luminosity
print TriggerAPI.getLowestUnprescaled(TriggerPeriod.y2017periodB, TriggerType.j_single, matchPattern="j225_gsc")
print TriggerAPI.getLowestUnprescaled(TriggerPeriod.y2017periodB, TriggerType.j_single, matchPattern="j225_gsc", livefraction=0.95)
print "Lowest j225_gsc with 100% data:",TriggerAPI.getLowestUnprescaled(TriggerPeriod.y2017periodB, TriggerType.j_single, matchPattern="j225_gsc")
print "Lowest j225_gsc with 95% data:",TriggerAPI.getLowestUnprescaled(TriggerPeriod.y2017periodB, TriggerType.j_single, matchPattern="j225_gsc", livefraction=0.95)
# - combined items with more than 2 types:
print "Muon+jet+met items:",TriggerAPI.getLowestUnprescaled(337833, TriggerType.mu, [TriggerType.j, TriggerType.xe])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment