Belle II Software development
print_calib_trig_results.py
1#!/usr/bin/env python3
2
3
10
11# --------------------------------------------------------------------------
12# Prints Calibration trigger results from a raw sroot file
13# --------------------------------------------------------------------------
14
15import basf2 as b2
16from ROOT import Belle2
17
18from collections import defaultdict
19
20results = defaultdict(int)
21
22
23class PrintCalibTriggerResults(b2.Module):
24
25 '''
26 Prints Calibration trigger results in a well formatted way.
27 User is prompted to continue or quit at each event
28 '''
29
30 def event(self):
31 '''
32 Print log likelihoods and wait for user respond.
33 '''
34
35 evtMetaData = Belle2.PyStoreObj('EventMetaData')
36 exp = evtMetaData.obj().getExperiment()
37 run = evtMetaData.obj().getRun()
38 evt = evtMetaData.obj().getEvent()
39 print()
40 print('Experiment ' + str(exp) + ' Run ' + str(run) + ' Event ' + str(evt) + ':')
41 print()
42 trigger_result = Belle2.PyStoreObj('SoftwareTriggerResult')
43 for name, result in trigger_result.getResults():
44 print('Result ' + str(name) + ': ' + str(result))
45 if result == 1:
46 global results
47 results[name] += 1
48 print('')
49
50
51b2.set_log_level(b2.LogLevel.ERROR)
52
53# Create path
54main = b2.create_path()
55
56# Root input
57roinput = b2.register_module('SeqRootInput')
58main.add_module(roinput)
59
60# print array of log likelihoods
61main.add_module(PrintCalibTriggerResults())
62
63# Process events
64b2.process(main)
65
66print(results)
a (simplified) python wrapper for StoreObjPtr.
Definition: PyStoreObj.h:67