Belle II Software  release-08-01-10
DumpDigits.py
1 #!/usr/bin/env python3
2 
3 
10 
11 import basf2 as b2
12 
13 # Some ROOT tools
14 from ROOT import Belle2
15 
16 
17 class DumpDigits(b2.Module):
18 
19  """A simple module to dump PXD digits."""
20 
21  def __init__(self):
22  """Initialize the module"""
23 
24  super().__init__()
25 
26  self.dumpfiledumpfile = 'PXDDigitsDump.txt'
27 
28  self.vxdid_factorsvxdid_factors = (8192, 256, 32)
29 
30  def beginRun(self):
31  """ Write legend for file columns """
32  with open(self.dumpfiledumpfile, 'w') as dumpfile:
33  dumpfile.write('vxd.id layer ladder sensor digit.u digit.v digit.charge ')
34 
35  def event(self):
36  """Find clusters with a truehit and print some stats."""
37 
38  digits = Belle2.PyStoreArray('PXDDigits')
39  # nDigits = digits.getEntries()
40  # Start with clusters and use the relation to get the corresponding
41  # digits and truehits.
42  with open(self.dumpfiledumpfile, 'a') as dumpfile:
43  s = ''
44  for digit in digits:
45  # Sesnor identification
46  sensorID = digit.getSensorID().getID()
47  [layer, ladder, sensor] = self.decodedecode(sensorID)
48  s += f'{sensorID} {layer:3d} {ladder:3d} {sensor:3d} {digit.getUCellID():6d} ' + \
49  f'{digit.getVCellID():6d} {digit.getCharge():8.1f}'
50  s += '\n'
51  dumpfile.write(s)
52 
53  def terminate(self):
54  """ Nothing."""
55 
56  def decode(self, vxdid):
57  """ Utility to decode sensor IDs """
58 
59  result = []
60  for f in self.vxdid_factors:
61  result.append(vxdid // f)
62  vxdid = vxdid % f
63 
64  return result
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72
def decode(self, vxdid)
Definition: DumpDigits.py:56
vxdid_factors
Factors for decoding VXDId's.
Definition: DumpDigits.py:28
dumpfile
Output file object.
Definition: DumpDigits.py:26
int getID(const std::vector< double > &breaks, double t)
get id of the time point t
Definition: calibTools.h:60