19 hslb = ((
'11000001',
'b'),
24 integrity_check =
False
29 from ROOT
import Belle2
33 from bitstring
import BitArray
37 [steering, srootFile] = sys.argv[:2]
38 if len(sys.argv) >= 3:
39 pickleSigFile = sys.argv[2]
40 isPickleFile = pickleSigFile[pickleSigFile.rfind(
'.'):] ==
'.p'
45 pickleIt = len(sys.argv) == 2
or isPickleFile
48 def finesse(x):
return ord(x) - ord(
'a')
51 def copper(x):
return int(x, 16)
54 hslb = [(copper(ele[0]), finesse(ele[1]))
for ele
in hslb]
58 return BitArray([]).join([BitArray(uint=i, length=32)
for i
in ary])
68 Example module to drop into ipython and create some objects to look at.
69 If you just want to start IPython and create PyStoreArray etc.
70 interactively in your own steering file, the 'Interactive' module
76 reimplement Module::event()
80 frombuffer = np.frombuffer
81 GetNodeID = Belle2.RawTRG.GetNodeID
82 GetDetectorNwords = Belle2.RawTRG.GetDetectorNwords
83 GetDetectorBuffer = Belle2.RawTRG.GetDetectorBuffer
91 print(len(trgary),
'copper(s)')
93 for entry
in range(evt.GetNumEntries()):
94 print(
'{:0x}'.format(GetNodeID(evt, entry)))
97 if (GetNodeID(evt, entry), bid)
in hslb:
98 count = GetDetectorNwords(evt, entry, bid)
99 print(bid,
"exist, ", count,
"words.")
104 for entry
in range(evt.GetNumEntries()):
108 if (GetNodeID(evt, entry), bid)
not in hslb:
110 count = GetDetectorNwords(evt, entry, bid)
114 bf = GetDetectorBuffer(evt, entry, bid)
115 ary = frombuffer(bf, np.uintc, count)
122 dataList.append(join(ary))
124 event = evtmeta.getEvent()
125 run = evtmeta.getRun()
126 subrun = evtmeta.getSubrun()
127 meta.append((event, run, subrun))
128 data.append(dataList)
133 set_log_level(LogLevel.INFO)
139 if srootFile[-5:] ==
'sroot':
140 root_input = register_module(
'SeqRootInput')
142 root_input = register_module(
'RootInput')
143 root_input.param(
'inputFileName', srootFile)
145 prog = register_module(
'Progress')
148 main.add_module(root_input)
149 main.add_module(prog)
152 main.add_module(readout)
154 emptypath = create_path()
155 readout.if_false(emptypath)
160 vcdFile = sys.argv[3]
if len(sys.argv) >= 4
else re.sub(
r'.+/',
'', re.sub(
r'sroot',
'vcd', srootFile))
161 with open(pickleSigFile)
as fin:
162 evtsize = [int(width)
for width
in fin.readline().split()]
163 B2INFO(
'Interpreting B2L data format with dimension ' + str(evtsize))
164 atlas = b2vcd_48.makeAtlas(fin.read(), evtsize)
170 pica = pickleSigFile
if isPickleFile
else re.sub(
r'.+/',
'ana/', re.sub(
r'sroot',
'p', srootFile))
171 wfp = open(pica,
'wb')
172 pickle.dump(data, wfp, protocol=2)
173 pickle.dump(meta, wfp, protocol=2)
179 B2INFO(
'Output pickle file ' + pica +
' saved.')
181 b2vcd_48.writeVCD(meta, data, atlas, vcdFile, evtsize)