6 Dumping HLT chains PS bit vs the chain counter and vs the L1 event number
13 from TrigByteStreamTools.hltResult
import hltResult
15 optparser = optparse.OptionParser(usage =
"%prog [options] FILES",
16 description = __doc__)
18 optparser.add_option(
"",
"--pickle", default=
'l2bits.pickle',
19 help=
"output file for the result pickle")
21 optparser.add_option(
"",
"--comp", action=
"store_true", default=
False,
22 help=
"Run comparison")
24 optparser.add_option(
"",
"--one", default=
'',
25 help=
"1st file for the comparison")
27 optparser.add_option(
"",
"--two", default=
'',
28 help=
"2nd file for the comparison")
30 optparser.add_option(
"",
"--ef", action=
"store_true", default=
False,
31 help=
"Use EF result instead of L2")
33 (opt, args) = optparser.parse_args()
41 HLTChain = cppyy.makeClass(
'HLT::Chain')
44 """Runs the dumping routines"""
48 print(
"Opening %s" % bsfile)
53 input = eformat.istream(bsfile)
54 subdet = eformat.helper.SubDetector.TDAQ_EVENT_FILTER
if opt.ef
else eformat.helper.SubDetector.TDAQ_LVL2
57 ev = ( event.global_id(), event.lvl1_id() )
60 for f
in event.children():
61 if f.source_id().subdetector_id() == subdet:
63 chains_data =
list(res.getChainResult())
65 for c
in chains_data[1:]:
67 chains[chain.getChainCounter()] = chain.isPrescaled()
72 output =
open(opt.pickle,
"wb")
73 cPickle.dump(events, output)
80 one = cPickle.load(
open(f1,
"rb"))
81 two = cPickle.load(
open(f2,
"rb"))
82 print(
'.. eventdumps read in correctly %s %s' % (f1, f2))
85 print(
".. the prescale bits are the same")
88 kone =
set(one.keys())
89 ktwo =
set(two.keys())
91 print(
".... the event sets are different in the two files; one has: %d two has: %d events" % (len(kone), len(ktwo)))
92 print(
".... will compare only events present in both sets")
96 print(
".. event difference global_id: %d l1_id: %d, fmt: chain_counter: PS bit,... " % k)
97 print(
".. event in file: %s " % opt.one)
99 print(
".. event in file: %s" % opt.two)
100 pprint.pprint(two[k])
103 print(
'.. prescale bits are the same in all %d common events ' % len(komon))
105 print(
'.. there are differences !')
109 if __name__ ==
"__main__":