Belle II Software  release-08-01-10
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 
15 import basf2 as b2
16 from ROOT import Belle2
17 
18 from collections import defaultdict
19 
20 results = defaultdict(int)
21 
22 
23 class 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 
51 b2.set_log_level(b2.LogLevel.ERROR)
52 
53 # Create path
54 main = b2.create_path()
55 
56 # Root input
57 roinput = b2.register_module('SeqRootInput')
58 main.add_module(roinput)
59 
60 # print array of log likelihoods
61 main.add_module(PrintCalibTriggerResults())
62 
63 # Process events
64 b2.process(main)
65 
66 print(results)
a (simplified) python wrapper for StoreObjPtr.
Definition: PyStoreObj.h:67
static ExpRun getRun(std::map< ExpRun, std::pair< double, double >> runs, double t)
Get exp number + run number from time.
Definition: Splitter.cc:262