1
# This file is part of MAUS: http://micewww.pp.rl.ac.uk/projects/maus
3
# MAUS is free software: you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation, either version 3 of the License, or
6
# (at your option) any later version.
8
# MAUS is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with MAUS. If not, see <http://www.gnu.org/licenses/>.
18
Get TOF calibrations from DB
23
from Configuration import Configuration
27
Evaluator class to evaluate mathematical expressions
29
Able to see many simple math expressions and some common units; the
30
standard geant4 system of units is enabled.
35
Initialise the evaluator with math functions and units
37
self._current_cali = {}
40
cfgdoc = cfg.getConfigJSON()
41
cfgdoc_json = json.loads(cfgdoc)
42
cdb_url = cfgdoc_json['cdb_download_url'] + 'calibration?wsdl'
43
self.cdb_server = cdb.Calibration()
44
self.cdb_server.set_url(cdb_url)
45
#print 'Server: ', self.cdb_server.get_name(), \
46
# self.cdb_server.get_version()
48
def get_calib(self, devname, ctype, fromdate):
50
Evaluate a string expression given by formula
52
tof_devs = {'TOF0', 'TOF1', 'TOF2'}
53
tof_ctypes = {'t0', 'tw', 'trigger'}
54
#print 'Calib: ', devname, ctype, fromdate
55
if devname != "" and ctype != "":
56
if devname not in tof_devs or ctype not in tof_ctypes:
57
raise Exception('get_tof_calib failed. \
58
Invalid detector/calib type.')
59
# check whether we are asked for the current calibration
60
# or calibration for an older date
61
if fromdate == "" or fromdate == "current":
62
#print 'getting current calib', devname, ctype
63
self._current_cali = \
64
self.cdb_server.get_current_calibration(devname, ctype)
66
#print 'getting calib for date', fromdate
67
self._current_cali = \
68
self.cdb_server.get_calibration_for_date(devname,fromdate,
70
#print self._current_cali
72
raise Exception('get_tof_calib failed.No device/calibration type.')
73
return self._current_cali
77
Reinitialize calibration
79
self._current_cali = {}