Belle II Software
development
executionTime_utils.py
1
# !/usr/bin/env python
2
3
10
11
#
12
# utils to measure the per-event execution time of all modules
13
# appended to the path, SVD observables are also stored in the tree
14
#
15
# in order to use this function:
16
# import it:
17
# from svd.executionTime_utils import SVDExtraEventStatisticsModule
18
# and then use it to measure execution time of your path
19
#
20
# examples are in svd/examples/executionTime.py
21
#
22
#
23
24
from
ROOT
import
Belle2
25
import
numpy
as
np
26
from
per_event_statistics
import
PerEventStatisticsGetterModule
27
28
29
class
SVDExtraEventStatisticsModule
(
PerEventStatisticsGetterModule
):
30
"""
31
a basf2 python module to export all module time statistics (PerEventStatisticsGetterModule) +
32
number of SVDSpacePoints, SVDClusters, SVDShaperDigits and SVDSHaperDigitsZS5
33
into a ROOT TTree written to a file.
34
"""
35
36
def
__init__
(self, filename):
37
"""
38
creates the module
39
@param filename: name of the rootfile where the TTree is written.
40
"""
41
super().
__init__
(filename)
42
43
self.
svdSPs
=
Belle2.PyStoreArray
(
"SVDSpacePoints"
)
44
45
self.
svdclusters
=
Belle2.PyStoreArray
(
"SVDClusters"
)
46
47
self.
svdstrips
=
Belle2.PyStoreArray
(
"SVDShaperDigits"
)
48
49
self.
svdZS5strips
=
Belle2.PyStoreArray
(
"SVDShaperDigitsZS5"
)
50
51
self.
tracks
=
Belle2.PyStoreArray
(
"Tracks"
)
52
53
def
initialize
(self):
54
"""
55
Create the needed store object pointer in the DataStore and the TFile with the TTree.
56
"""
57
58
super().
initialize
()
59
60
self.
svd_sps
= np.zeros(1, dtype=np.int32)
61
62
self.
svd_clusters
= np.zeros(1, dtype=np.int32)
63
64
self.
svd_strips
= np.zeros(1, dtype=np.int32)
65
66
self.
svd_ZS5strips
= np.zeros(1, dtype=np.int32)
67
68
self.
svd_tracks
= np.zeros(1, dtype=np.int32)
69
70
71
self.
statistics
.Branch(
'svdSPs'
, self.
svd_sps
[0:],
"svdSPs/I"
)
72
73
self.
statistics
.Branch(
'svdClusters'
, self.
svd_clusters
[0:],
"svdClusters/I"
)
74
75
self.
statistics
.Branch(
'svdStrips'
, self.
svd_strips
[0:],
"svdStrips/I"
)
76
77
self.
statistics
.Branch(
'svdZS5strips'
, self.
svd_ZS5strips
[0:],
"svdZS5strips/I"
)
78
79
self.
statistics
.Branch(
'tracks'
, self.
svd_tracks
[0:],
"tracks/I"
)
80
81
self.
svdSPs
.isRequired()
82
self.
svdclusters
.isRequired()
83
self.
svdstrips
.isRequired()
84
85
self.
svdZS5strips
.isOptional()
86
self.
tracks
.isOptional()
87
88
def
event
(self):
89
""" event """
90
91
self.
svd_sps
[0] = self.
svdSPs
.getEntries()
92
self.
svd_clusters
[0] = self.
svdclusters
.getEntries()
93
self.
svd_strips
[0] = self.
svdstrips
.getEntries()
94
95
if
self.
svdZS5strips
.isOptional():
96
self.
svd_ZS5strips
[0] = self.
svdZS5strips
.getEntries()
97
if
self.
tracks
.isOptional():
98
self.
svd_tracks
[0] = self.
tracks
.getEntries()
99
100
super().
event
()
Belle2::PyStoreArray
A (simplified) python wrapper for StoreArray.
Definition
PyStoreArray.h:73
per_event_statistics.PerEventStatisticsGetterModule
Definition
per_event_statistics.py:13
per_event_statistics.PerEventStatisticsGetterModule.statistics
statistics
Will host the TTree later.
Definition
per_event_statistics.py:31
svd.executionTime_utils.SVDExtraEventStatisticsModule
Definition
executionTime_utils.py:29
svd.executionTime_utils.SVDExtraEventStatisticsModule.tracks
tracks
StoreArray of Tracks.
Definition
executionTime_utils.py:51
svd.executionTime_utils.SVDExtraEventStatisticsModule.svdclusters
svdclusters
StoreArray of SVDClusters.
Definition
executionTime_utils.py:45
svd.executionTime_utils.SVDExtraEventStatisticsModule.svdSPs
svdSPs
StoreArray of SVDSpacePoints.
Definition
executionTime_utils.py:43
svd.executionTime_utils.SVDExtraEventStatisticsModule.initialize
initialize(self)
Definition
executionTime_utils.py:53
svd.executionTime_utils.SVDExtraEventStatisticsModule.svd_ZS5strips
svd_ZS5strips
array storing the number of ZS5 SVDShaperDigits
Definition
executionTime_utils.py:66
svd.executionTime_utils.SVDExtraEventStatisticsModule.svd_sps
svd_sps
array storing the number of SVDSpacePoints
Definition
executionTime_utils.py:60
svd.executionTime_utils.SVDExtraEventStatisticsModule.svdstrips
svdstrips
StoreArray of SVDShaperDigits.
Definition
executionTime_utils.py:47
svd.executionTime_utils.SVDExtraEventStatisticsModule.svd_tracks
svd_tracks
array storing the number of tracks
Definition
executionTime_utils.py:68
svd.executionTime_utils.SVDExtraEventStatisticsModule.svdZS5strips
svdZS5strips
StoreArray of ZS5 SVDShaperDigits.
Definition
executionTime_utils.py:49
svd.executionTime_utils.SVDExtraEventStatisticsModule.svd_strips
svd_strips
array storing the number of SVDShaperDigits
Definition
executionTime_utils.py:64
svd.executionTime_utils.SVDExtraEventStatisticsModule.__init__
__init__(self, filename)
Definition
executionTime_utils.py:36
svd.executionTime_utils.SVDExtraEventStatisticsModule.svd_clusters
svd_clusters
array storing the number of SVDClusters
Definition
executionTime_utils.py:62
svd.executionTime_utils.SVDExtraEventStatisticsModule.event
event(self)
Definition
executionTime_utils.py:88
svd
scripts
svd
executionTime_utils.py
Generated on Mon Sep 1 2025 02:56:47 for Belle II Software by
1.13.2