Belle II Software development
importFrontEndMaps.py
1#!/usr/bin/env python3
2
3
10
11# -------------------------------------------------------------------------------------
12# Import front-end mappings given by top/data/FrontEndMapping.xml to a local database.
13#
14# usage: basf2 importFrontEndMaps.py [localDB]
15# localDB: path/name of local database (D = "localDB-FEMaps/localDB.txt")
16# -------------------------------------------------------------------------------------
17
18from basf2 import conditions, create_path, process, Module, set_log_level, LogLevel
19from ROOT import Belle2
20import sys
21
22localDBName = "localDB-FEMaps/localDB.txt"
23if len(sys.argv) > 1:
24 localDBName = sys.argv[1]
25
26# define a local database (will be created automatically, if doesn't exist)
27conditions.expert_settings(save_payloads=localDBName)
28
29
30class ImportFrontEndMaps(Module):
31 """ database importer for TOPFrontEndMaps """
32
33 def initialize(self):
34 """ initialize method: import a payload to local database """
35
36 iov = Belle2.IntervalOfValidity(0, 0, -1, -1)
37 mapper = Belle2.TOP.TOPGeometryPar.Instance().getFrontEndMapper()
38 if not mapper.isValid():
39 return
40 mapper.importPayload(iov)
41
42 print()
43 print('Mapping of boardstacks to SCROD IDs')
44 for slot in range(1, 17):
45 print('slot', slot)
46 for bs in range(4):
47 femap = mapper.getMap(slot, bs)
48 if femap:
49 print(' BS' + str(bs) + ':', femap.getScrodID())
50 else:
51 print(' BS' + str(bs) + ': *not available*')
52 print('--> FrontEndMaps imported to local database ' + localDBName)
53
54
55set_log_level(LogLevel.ERROR)
56
57main = create_path()
58main.add_module('EventInfoSetter')
59main.add_module('Gearbox')
60main.add_module('TOPGeometryParInitializer', useDB=False)
61main.add_module(ImportFrontEndMaps())
62
63# process single event
64process(main)
A class that describes the interval of experiments/runs for which an object in the database is valid.
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.