Belle II Software
development
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.
dumpfile
=
'PXDDigitsDump.txt'
27
28
self.
vxdid_factors
= (8192, 256, 32)
29
30
def
beginRun
(self):
31
""" Write legend for file columns """
32
with
open(self.
dumpfile
,
'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.
dumpfile
,
'a'
)
as
dumpfile:
43
s =
''
44
for
digit
in
digits:
45
# Sensor identification
46
sensorID = digit.getSensorID().getID()
47
[layer, ladder, sensor] = self.
decode
(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
Belle2::PyStoreArray
A (simplified) python wrapper for StoreArray.
Definition
PyStoreArray.h:73
DumpDigits.DumpDigits
Definition
DumpDigits.py:17
DumpDigits.DumpDigits.terminate
terminate(self)
Definition
DumpDigits.py:53
DumpDigits.DumpDigits.dumpfile
str dumpfile
Output file object.
Definition
DumpDigits.py:26
DumpDigits.DumpDigits.decode
decode(self, vxdid)
Definition
DumpDigits.py:56
DumpDigits.DumpDigits.vxdid_factors
tuple vxdid_factors
Factors for decoding VXDId's.
Definition
DumpDigits.py:28
DumpDigits.DumpDigits.__init__
__init__(self)
Definition
DumpDigits.py:21
DumpDigits.DumpDigits.event
event(self)
Definition
DumpDigits.py:35
DumpDigits.DumpDigits.beginRun
beginRun(self)
Definition
DumpDigits.py:30
pxd
examples
DumpDigits.py
Generated on Mon Sep 1 2025 02:54:48 for Belle II Software by
1.13.2