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