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