Belle II Software
prerelease-10-00-00a
DBImportTBC.py
1
#!/usr/bin/env python
2
3
10
11
# ---------------------------------------------------------------------------------------------------------
12
# Database importer for importing TBC constants to local database.
13
# User has to set the path to TOPTimeBaseCalibrator output files correctly or just run from that directory.
14
# Name and location of local DB can also be changed.
15
#
16
# usage: basf2 DBImportTBC.py
17
# ---------------------------------------------------------------------------------------------------------
18
19
import
basf2
as
b2
20
from
ROOT
import
Belle2
# noqa: make Belle2 namespace available
21
from
ROOT.Belle2
import
TOPDatabaseImporter
22
import
sys
23
import
glob
24
25
# define local database with write access
26
b2.conditions.expert_settings(save_payloads=
"localDB/localDB.txt"
)
27
28
# get a list of root files containing calibration constants
29
folder_name =
'.'
# location of output files from TOPTimeBaseCalibrator
30
fNames = glob.glob(folder_name +
'/*/*.root'
)
31
if
len(fNames) == 0:
32
print(
'No root files found in'
, folder_name)
33
sys.exit()
34
35
# convert the list to a single string
36
fileNames =
''
37
for
fName
in
fNames:
38
fileNames = fileNames +
' '
+ fName
39
40
41
class
PayloadImporter
(b2.Module):
42
''' Payload importer using TOPDatabaseImporter '''
43
44
def
initialize
(self):
45
''' Import timebase calibration '''
46
47
dbImporter = TOPDatabaseImporter()
48
dbImporter.importSampleTimeCalibration(fileNames)
49
50
51
# create path
52
main = b2.create_path()
53
54
# Event info setter - execute single event
55
main.add_module(
'EventInfoSetter'
)
56
57
# Gearbox
58
main.add_module(
'Gearbox'
)
59
60
# Geometry parameters
61
main.add_module(
'TOPGeometryParInitializer'
, useDB=
False
)
62
63
# Importer
64
main.add_module(
PayloadImporter
())
65
66
# process single event
67
b2.process(main)
DBImportTBC.PayloadImporter
Definition
DBImportTBC.py:41
DBImportTBC.PayloadImporter.initialize
initialize(self)
Definition
DBImportTBC.py:44
top
calibration
steering_tools
DBImportTBC.py
Generated on Wed Jul 2 2025 03:32:46 for Belle II Software by
1.13.2