 |
Belle II Software
release-05-02-19
|
3 from ROOT
import Belle2
7 ROOT.gROOT.ProcessLine(
"#include <framework/utilities/MakeROOTCompatible.h>")
12 A basf2 python module to export *all* module time statistics (of every event, not just averaged)
13 into a ROOT TTree written to a file.
18 Create a new PerEventStatisticsGetterModule. You have to give the name of the
19 file, where the TTree with the full event statistics will be saved.
45 Create the needed store object pointer in the DataStore and the TFile with the TTree.
54 self.
statistics = ROOT.TTree(
"statistics",
"Per event execution Statistics for all modules")
69 The event loop: Store the statistics as a new row in the TTree.
75 module_stats = basf2.statistics.modules
90 basf2.B2FATAL(
"PerEventStatisticsGetterModule can only be used in single processing mode or in the output process")
92 self.
ttree_inputs = np.zeros(len(module_stats), dtype=float)
95 for i, stat
in enumerate(module_stats):
100 ttree.Branch(module_name, self.
ttree_inputs[i:], f
"{module_name}/D")
105 time_sum = np.array([m.time_sum(basf2.statistics.EVENT)
for m
in module_stats], dtype=float)
116 ROOT.gDirectory = old
120 Write out the merged statistics to the ROOT file.
121 This should only be called once, as we would end up with different versions otherwise.
124 old = ROOT.gDirectory
131 ROOT.gDirectory = old
tfile
Will host the pointer to the opened TFile later.
a (simplified) python wrapper for StoreObjPtr.
static bool isOutputProcess()
Return true if the process is an output process.
def __init__(self, output_file_name)
std::string makeROOTCompatible(std::string str)
Remove special characters that ROOT dislikes in branch names, e.g.
ttree_inputs
The columns for the statistics TTree (they will be filled in the event function).
static ExpRun getRun(map< ExpRun, pair< double, double >> runs, double t)
Get exp number + run number from time.
output_file_name
Name of the output file.
event_number
The columns to store the event number.
statistics
Will host the TTree later.
event_meta_data
The event meta data.
branches_added
A flag to indicate that we have already added the Branches to the TTree (which we will do in the firs...
static bool parallelProcessingUsed()
Returns true if multiple processes have been spawned, false in single-core mode.
last_time_sum
Last recored sum of event calls for all modules.