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