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