41 """Prescale L1 items in CTP fragment used by HLT"""
47 event = kwargs[
"event"]
50 seed =
'%s%s' % (event.bc_time_seconds(),event.bc_time_nanoseconds())
51 random.seed(zlib.crc32(seed))
53 new_event=eformat.write.FullEventFragment()
54 new_event.copy_header(event)
56 if rob.source_id()!=eformat.helper.SourceIdentifier(eformat.helper.SubDetector.TDAQ_CTP,1):
57 new_event.append_unchecked(rob)
59 data = [d
for d
in rob.rod_data()]
60 v = CTPfragment.ctpFormatVersion(rob)
61 TBPpos = CTPfragment._versioned(CTPdataformat,
'TBPpos',v)
62 TBPwords = CTPfragment._versioned(CTPdataformat,
'TBPwords',v)
63 TAVpos = CTPfragment._versioned(CTPdataformat,
'TAVpos',v)
65 L1TBP = CTPfragment.decodeTriggerBits(data[TBPpos:TBPpos+TBPwords])
66 log.debug(
'L1TBP: %s', L1TBP)
71 if random.uniform(0,prescales[ctp])>1:
75 log.debug(
'New L1TAV: %s', newL1TAV)
76 newL1TAVBits = CTPfragment.encodeTriggerBits(newL1TAV,TBPwords)
77 for i,value
in enumerate(newL1TAVBits):
78 data[TAVpos+i] = value
81 newrob = eformat.write.ROBFragment(rob)
83 new_event.append(newrob)
85 l1bits = [b
for b
in event.lvl1_trigger_info()]
86 new_event.lvl1_trigger_info(l1bits[0:TBPwords]+data[TAVpos:TAVpos+TBPwords]*2)
88 return new_event.readonly()