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
24from ROOT import Belle2
25import numpy as np
26from per_event_statistics import PerEventStatisticsGetterModule
27
28
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()
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72
svd_ZS5strips
array storing the number of ZS5 SVDShaperDigits
svd_sps
array storing the number of SVDSpacePoints
svd_strips
array storing the number of SVDShaperDigits
svd_clusters
array storing the number of SVDClusters