Belle II Software  release-05-02-19
checkCalibDB.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 from basf2 import *
5 import os
6 import sys
7 from ROOT import Belle2
8 
9 # --------------------------------------------------------------------
10 # useful tool for checking the status of TOP calibration in central DB
11 #
12 # usage: basf2 checkCalibDB.py expNo runNo [globalTag]
13 # --------------------------------------------------------------------
14 
15 argvs = sys.argv
16 if len(argvs) < 3:
17  print("usage: basf2", argvs[0], "expNo runNo [globalTag]")
18  sys.exit()
19 
20 expNo = int(argvs[1])
21 runNo = int(argvs[2])
22 tag = '(default)'
23 if len(argvs) == 4:
24  tag = argvs[3]
25 
26 
27 class CheckCalibDB(Module):
28  ''' print calibration status of TOPCal payloads '''
29 
30  def printChannel(self, payload):
31  ''' print status of a payload given by the argument '''
32 
33  db = Belle2.PyDBObj(payload)
34  if not db:
35  B2ERROR(payload + ' not found')
36  return
37  calibrated = 0
38  all = 0
39  for moduleID in range(1, 17):
40  for channel in range(512):
41  all += 1
42  if db.isCalibrated(moduleID, channel):
43  calibrated += 1
44  print(payload + ': ' + str(calibrated) + '/' + str(all) + ' calibrated')
45 
46  def printChannelMask(self):
47  ''' print status of channel masks '''
48 
49  payload = 'TOPCalChannelMask'
50  db = Belle2.PyDBObj(payload)
51  if not db:
52  B2ERROR(payload + ' not found')
53  return
54  active = db.getNumOfActiveChannels()
55  all = db.getNumOfChannels()
56  print(payload + ': ' + str(active) + '/' + str(all) + ' active')
57 
58  def printModule(self, payload):
59  ''' print status of a payload given by the argument '''
60 
61  db = Belle2.PyDBObj(payload)
62  if not db:
63  B2ERROR(payload + ' not found')
64  return
65  calibrated = 0
66  all = 0
67  for moduleID in range(1, 17):
68  all += 1
69  if db.isCalibrated(moduleID):
70  calibrated += 1
71  print(payload + ': ' + str(calibrated) + '/' + str(all) + ' calibrated')
72 
73  def printCommon(self, payload):
74  ''' print status of a payload given by the argument '''
75 
76  db = Belle2.PyDBObj(payload)
77  if not db:
78  B2ERROR(payload + ' not found')
79  return
80  calibrated = 0
81  all = 1
82  if db.isCalibrated():
83  calibrated += 1
84  print(payload + ': ' + str(calibrated) + '/' + str(all) + ' calibrated')
85 
86  def printTimeBase(self):
87  ''' print status of time base calibration '''
88 
89  payload = 'TOPCalTimebase'
90  db = Belle2.PyDBObj(payload)
91  if not db:
92  B2ERROR(payload + ' not found')
93  return
94  calibrated = 0
95  all = 8192
96  for sampleTimes in db.getSampleTimes():
97  if sampleTimes.isCalibrated():
98  calibrated += 1
99  print(payload + ': ' + str(calibrated) + '/' + str(all) + ' calibrated')
100 
101  def event(self):
102  ''' event processing '''
103 
104  print()
105  print('Calibration status of GT =', tag)
106  print('Experiment =', expNo, 'Run =', runNo)
107  print()
108  self.printTimeBase()
109  self.printChannel('TOPCalChannelT0')
110  self.printModule('TOPCalModuleT0')
111  self.printCommon('TOPCalCommonT0')
112  self.printChannel('TOPCalChannelNoise')
113  self.printChannel('TOPCalChannelPulseHeight')
114  self.printChannel('TOPCalChannelRQE')
115  self.printChannel('TOPCalChannelThresholdEff')
116  self.printChannel('TOPCalChannelThreshold')
117  self.printChannel('TOPCalIntegratedCharge')
118  self.printModule('TOPCalModuleAlignment')
119  self.printChannelMask()
120  print()
121 
122 
123 # Central database
124 if len(argvs) == 4:
125  use_central_database(tag)
126 
127 # Create path
128 main = create_path()
129 
130 # Set number of events to generate
131 eventinfosetter = register_module('EventInfoSetter')
132 eventinfosetter.param({'evtNumList': [1], 'runList': [runNo], 'expList': [expNo]})
133 main.add_module(eventinfosetter)
134 
135 # Run checker
136 main.add_module(CheckCalibDB())
137 
138 # Process events
139 process(main)
checkCalibDB.CheckCalibDB.printChannel
def printChannel(self, payload)
Definition: checkCalibDB.py:30
checkCalibDB.CheckCalibDB.printCommon
def printCommon(self, payload)
Definition: checkCalibDB.py:73
checkCalibDB.CheckCalibDB.printChannelMask
def printChannelMask(self)
Definition: checkCalibDB.py:46
checkCalibDB.CheckCalibDB.printTimeBase
def printTimeBase(self)
Definition: checkCalibDB.py:86
Belle2::PyDBObj
Class to access a DBObjPtr from Python.
Definition: PyDBObj.h:50
checkCalibDB.CheckCalibDB.event
def event(self)
Definition: checkCalibDB.py:101
checkCalibDB.CheckCalibDB.printModule
def printModule(self, payload)
Definition: checkCalibDB.py:58
checkCalibDB.CheckCalibDB
Definition: checkCalibDB.py:27