8 from ROOT
import gStyle, gROOT, addressof, TTree, vector, string
9 from TrigByteStreamTools.hltResultMT
import get_collections
12 msg = logging.getLogger(
'PyJobTransforms.' + __name__)
16 def __init__(self, dbgStep='_Default', inputFile=''):
44 'HLTSV_DUPLICATION_WARN',
49 'DCM_PROCESSING_TIMEOUT',
50 'HLTPU_PROCESSING_TIMEOUT',
51 'DCM_DUPLICATION_WARN',
52 'DCM_RECOVERED_EVENT',
61 'CANNOT_RETRIEVE_EVENT',
67 'OUTPUT_BUILD_FAILURE',
68 'OUTPUT_SEND_FAILURE',
73 'MISSING_CTP_FRAGMENT',
82 def eventInfo(self, event, L1ChainNames, HLTChainNames):
89 msg.debug(
"Event Counter Lvl1 ID = %s", self.
Lvl1_ID & 0xffffff)
90 msg.debug(
"Event Counter Reset Counter Lvl1 ID = %s", (self.
Lvl1_ID & 0xff000000) >> 24)
95 streamtagNames =
','.
join([tag.name
for tag
in event.stream_tag()])
98 streamtagTypes =
','.
join([tag.type
for tag
in event.stream_tag()])
116 self.
hltInfo(event, HLTChainNames)
123 for key
in configKeys[
'HLTPSK']:
124 if event.lumi_block() >= key[1]
and event.lumi_block() <= key[2]:
131 for rob
in event.children():
132 if rob.source_id().subdetector_id() != eformat.helper.SubDetector.TDAQ_HLT:
135 configList = [c
for c
in collections
if 'xAOD::TrigConfKeys_v' in c.name_persistent]
137 for conf
in configList:
138 configKeys = conf.deserialise()
144 msg.info(
"Smk and hltpskey unavailable in this event")
146 msg.info(
"Cannot retrieve smk and hltpskey")
156 def getBit(word, index):
157 return (word >> index) & 0x1
160 def checkBits(word, firstBit, lastBit, status):
162 for i
in range(firstBit, lastBit):
165 statusIdx = i - firstBit
166 statusList.append(status[statusIdx])
177 if getBit(event.status()[0], 28):
178 statusLen = len(event.status())
181 for i
in range(1, statusLen):
189 msg.warn(
"Cannot find additional words for PSC_PROBLEM")
220 info = event.lvl1_trigger_info()
224 if id
in L1ItemNames:
227 msg.debug(
'Item %s not found in the menu - probably is disabled', id)
234 msg.warn(
"Item name for ctpid %s not found!", id)
236 msg.info(
'LVL1 Triggered ID Chains AV : %s', l1Bits[2])
245 if not HLTChainNames:
250 for rob
in event.children():
251 if rob.source_id().subdetector_id() == eformat.helper.SubDetector.TDAQ_HLT:
252 rod_version = rob.rod_version()
253 minor_version = rod_version.minor_version()
254 minor_version_M = (minor_version & 0xff00) >> 8
255 minor_version_L = minor_version & 0xff
256 version = (minor_version_M, minor_version_L)
260 num_sets = 3
if version[0] < 1
or version==(1,0)
else 2
263 info = event.event_filter_info()
266 for id
in chainList[0]:
271 msg.warn(
"Chain name for counter %s not found!", id)
273 msg.info(
'HLT Triggered ID Chains : %s', chainList[0])
278 assert len(words) % num_sets == 0
279 n_words_per_set = len(words) // num_sets
281 for iset
in range(num_sets):
282 words_in_set = words[iset*n_words_per_set:(iset+1)*n_words_per_set]
284 for iw
in range(len(words_in_set)):
285 bit_indices.extend([base*iw+i
for i
in range(base)
if words_in_set[iw] & (1 << i)])
286 result.append(bit_indices)
293 from cppyy.gbl
import HLT
297 msg.info(
'.... chain {0:-3d}: {1} Counter: {2:-4d} Passed: {3} (Raw: {4} Prescaled: {5} PassThrough: {6}) Rerun: {7} LastStep: {8} Err: {9}'
298 .
format(counter, self.
HLT_Chain_Names[ch.getChainCounter()], ch.getChainCounter(), ch.chainPassed(), ch.chainPassedRaw(),
299 ch.isPrescaled(), ch.isPassedThrough(), ch.isResurrected(), ch.getChainStep(), ch.getErrorCode().
str()))
301 msg.warn(
"Chain with counter %s not found", ch.getChainCounter())
306 msg.info(
'... chains: %s', len(blob))
307 for i
in range(len(blob)):
313 hltResultFound =
False
314 for rob
in event.children():
315 if rob.source_id().subdetector_id() == eformat.helper.SubDetector.TDAQ_HLT:
316 msg.info(
'.. {0} source: {1} source ID: 0x{2:x} size: {3}'
317 .
format(rob.__class__.__name__, rob.source_id(), rob.source_id().
code(), rob.fragment_size_word()*4))
319 msg.info(
'version :%s', rob.rod_version())
320 msg.info(
'l1id :%s', event.lvl1_id())
322 self.
Node_ID = rob.source_id().module_id()
328 hltResultFound =
True
330 except Exception
as ex:
331 msg.info(
'... **** problems in analyzing payload %s', ex)
332 msg.info(
'... **** raw data[:10] %s',
list(rob.rod_data())[:10])
333 msg.info(
'.. EOF HLTResult for HLT')
335 if not hltResultFound:
336 msg.info(
'No HLT Result for HLT')
359 gStyle.SetCanvasColor(0)
360 gStyle.SetOptStat(000000)
361 gROOT.SetStyle(
"Plain")
365 if dbgStep ==
"_Pre" :
366 gROOT.ProcessLine(
"#define STRINGLENGTH "+
str(self.
strlength))
368 "struct EventInfoTree {\
370 Char_t Stream_Tag_Name[STRINGLENGTH];\
371 Char_t Stream_Tag_Type[STRINGLENGTH];\
376 ULong_t SuperMasterKey;\
377 ULong_t HLTPrescaleKey;\
379 Char_t EventStatusNames[STRINGLENGTH];\
383 from ROOT
import EventInfoTree