Belle II Software  release-05-01-25
checkInterimFEData.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 # ---------------------------------------------------------------------------------------
5 # Prints a summary of raw data given in Interim FE format v2.1
6 # usage: basf2 checkInterimFEData.py -i <file_name.sroot> [-n <num_of_events_to_process>]
7 # ---------------------------------------------------------------------------------------
8 
9 from basf2 import *
10 from ROOT import Belle2
11 
12 
13 class InspectRawTOP(Module):
14  ''' Print summary of raw data given in Interim FE format '''
15 
16  def swap32(self, x):
17  '''' Swap bytes '''
18 
19  return (((x << 24) & 0xFF000000) |
20  ((x << 8) & 0x00FF0000) |
21  ((x >> 8) & 0x0000FF00) |
22  ((x >> 24) & 0x000000FF))
23 
24  def event(self):
25  ''' Event processor '''
26 
27  rawTOPs = Belle2.PyStoreArray('RawTOPs')
28  if rawTOPs.getEntries() == 0:
29  print('RawTOP is empty - maybe component ID was not set properly at DAQ')
30  indx = 0
31  for raw in rawTOPs:
32  expno = raw.GetExpNo(0)
33  runno = raw.GetRunNo(0)
34  subno = raw.GetSubRunNo(0)
35  eveno = raw.GetEveNo(0)
36  copper = raw.GetNodeID(0) & 0x00FFFFFF
37  print('RawTOP[' + str(indx) + ']:',
38  'COPPER=' + str(copper),
39  'EXP=' + str(expno),
40  'RUN=' + str(runno),
41  'SUBRUN=' + str(subno),
42  'EVENT=' + str(eveno))
43  indx = indx + 1
44  for finesse in range(4):
45  size = raw.GetDetectorNwords(0, finesse)
46  if size == 0:
47  print(' HLSB', str(finesse),
48  ': size =', str(size), 'words')
49  continue
50  data = raw.GetDetectorBuffer(0, finesse)
51  scrod = self.swap32(data[0]) & 0x0FFF
52  numFE = 0
53  numWF = 0
54  numPoz = 0
55  numNeg = 0
56  for i in range(size):
57  word = self.swap32(data[i])
58  k = 0
59  if word == 0xaaaa0100:
60  numFE = numFE + 1
61  k = i + 4
62  elif word == 0xaaaa0103:
63  numFE = numFE + 1
64  numWF = numWF + 1
65  k = i + 4
66  if k > 0 and k < size - 6:
67  if self.swap32(data[k]) != 0xd8f1ffff:
68  numPoz = numPoz + 1
69  if self.swap32(data[k + 6]) != 0x270fffff:
70  numNeg = numNeg + 1
71  print(' HLSB', str(finesse),
72  ': size =', str(size), 'words,',
73  'SCROD', str(scrod) + ',',
74  'FE headers=' + str(numFE),
75  'signalsPoz=' + str(numPoz),
76  'signalsNeg=' + str(numNeg),
77  'Waveforms=' + str(numWF))
78  print()
79 
80 
81 # Create path
82 main = create_path()
83 
84 # input
85 roinput = register_module('SeqRootInput')
86 # roinput = register_module('RootInput')
87 main.add_module(roinput)
88 
89 # conversion from RawCOPPER or RawDataBlock to RawDetector objects
90 converter = register_module('Convert2RawDet')
91 main.add_module(converter)
92 
93 # event info printer
94 main.add_module('EventInfoPrinter')
95 
96 # summary print-out
97 main.add_module(InspectRawTOP())
98 
99 # Process events
100 process(main)
checkInterimFEData.InspectRawTOP.swap32
def swap32(self, x)
Definition: checkInterimFEData.py:16
checkInterimFEData.InspectRawTOP.event
def event(self)
Definition: checkInterimFEData.py:24
checkInterimFEData.InspectRawTOP
Definition: checkInterimFEData.py:13
Belle2::PyStoreArray
a (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:58