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