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