Belle II Software
development
checkHitHeightAndWidth.py
1
#!/usr/bin/env python3
2
3
10
11
import
basf2
as
b2
12
from
ROOT
import
Belle2
13
from
ROOT
import
TH2F, TFile, gDirectory
14
15
#
16
# ------------------------------------------------------------------------
17
# Simple module to study the width and amplitude of TOPDigits
18
#
19
# usage: basf2 checkHitHeightAndWidth.py -i <raw_data.root>
20
# ------------------------------------------------------------------------
21
22
23
class
Histogrammer
(b2.Module):
24
25
''' A module to histogram width and amplitude of TOPDigits '''
26
27
def
initialize
(self):
28
''' Open output file and book histograms '''
29
30
31
self.
tfile
= TFile.Open(
'hitHeightAndWidth.root'
,
'recreate'
)
32
dirs = [gDirectory.mkdir(
'slot_'
+ f
'{slot:02d}'
)
for
slot
in
range(1, 17)]
33
34
35
self.
hist
= []
36
37
self.
histSampling
= []
38
39
for
slot
in
range(1, 17):
40
dirs[slot - 1].cd()
41
h = TH2F(
'WidthVSAmplitude'
,
'Slot '
+ str(slot) +
42
';amplitude [ADC counts]; width [ns]'
, 2000, 0, 2000, 200, 0, 10)
43
self.
hist
.append(h)
44
hh = [TH2F(
'WidthVSample_ch'
+ f
'{ch:03d}'
,
'Slot '
+ str(slot) +
', channel '
+ str(ch) +
45
';sample; width [ns]'
, 256, 0, 256, 200, 0, 10)
for
ch
in
range(512)]
46
self.
histSampling
.append(hh)
47
48
def
event
(self):
49
''' Event processor: fill histograms '''
50
51
digits =
Belle2.PyStoreArray
(
'TOPDigits'
)
52
for
digit
in
digits:
53
if
digit.getHitQuality() == 0:
54
continue
55
slotID = digit.getModuleID()
56
hwchan = digit.getChannel()
57
self.
hist
[slotID - 1].Fill(digit.getPulseHeight(), digit.getPulseWidth())
58
self.
histSampling
[slotID - 1][hwchan].Fill(digit.getModulo256Sample(), digit.getPulseWidth())
59
60
def
terminate
(self):
61
''' Write histograms to file '''
62
63
self.
tfile
.Write()
64
self.
tfile
.Close()
65
66
67
# Suppress messages and warnings during processing
68
b2.set_log_level(b2.LogLevel.ERROR)
69
70
# Define a global tag
71
b2.conditions.override_globaltags()
72
b2.conditions.append_globaltag(
'online'
)
73
74
# Create path
75
main = b2.create_path()
76
77
# input
78
# roinput = b2.register_module('SeqRootInput') # sroot files
79
roinput = b2.register_module(
'RootInput'
)
# root files
80
main.add_module(roinput)
81
82
# Initialize TOP geometry parameters (creation of Geant geometry is not needed)
83
main.add_module(
'TOPGeometryParInitializer'
)
84
85
# Unpacking (format auto detection works now)
86
unpack = b2.register_module(
'TOPUnpacker'
)
87
main.add_module(unpack)
88
89
# Convert to TOPDigits
90
converter = b2.register_module(
'TOPRawDigitConverter'
)
91
main.add_module(converter)
92
93
# Histogrammer
94
histogramModule =
Histogrammer
()
95
main.add_module(histogramModule)
96
97
# Show progress of processing
98
progress = b2.register_module(
'Progress'
)
99
main.add_module(progress)
100
101
# Process events
102
b2.process(main)
Belle2::PyStoreArray
A (simplified) python wrapper for StoreArray.
Definition
PyStoreArray.h:73
checkHitHeightAndWidth.Histogrammer
Definition
checkHitHeightAndWidth.py:23
checkHitHeightAndWidth.Histogrammer.histSampling
list histSampling
Width as function of the sample number in each channel.
Definition
checkHitHeightAndWidth.py:37
checkHitHeightAndWidth.Histogrammer.terminate
terminate(self)
Definition
checkHitHeightAndWidth.py:60
checkHitHeightAndWidth.Histogrammer.initialize
initialize(self)
Definition
checkHitHeightAndWidth.py:27
checkHitHeightAndWidth.Histogrammer.hist
list hist
Width VS amplitude plot in each slot.
Definition
checkHitHeightAndWidth.py:35
checkHitHeightAndWidth.Histogrammer.tfile
tfile
output file
Definition
checkHitHeightAndWidth.py:31
checkHitHeightAndWidth.Histogrammer.event
event(self)
Definition
checkHitHeightAndWidth.py:48
top
analysis
checkHitHeightAndWidth.py
Generated on Mon Sep 1 2025 02:56:55 for Belle II Software by
1.13.2