Belle II Software  release-08-01-10
checkFrontEndMaps.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 # -------------------------------------------------------------------------------------
13 # Check front-end mappings (boardstacks to SCROD IDs)
14 #
15 # usage: basf2 checkFrontEndMaps.py expNo runNo [globalTag or localDB]
16 # -------------------------------------------------------------------------------------
17 
18 from basf2 import conditions, create_path, process, Module, set_log_level, LogLevel
19 from ROOT import Belle2
20 import sys
21 
22 argvs = sys.argv
23 if len(argvs) < 3:
24  print("usage: basf2", argvs[0], "expNo runNo [globalTag or localDB]")
25  sys.exit()
26 
27 expNo = int(argvs[1])
28 runNo = int(argvs[2])
29 tag = '(main)'
30 tagtxt = 'globalTag:'
31 if len(argvs) == 4:
32  tag = argvs[3]
33  if '.txt' in tag:
34  conditions.append_globaltag('online')
35  conditions.append_testing_payloads(tag)
36  tagtxt = 'localDB:'
37  else:
38  conditions.append_globaltag(tag)
39 
40 
41 class CheckFrontEndMaps(Module):
42  """ Print SCROD to boardstack mapping given by TOPFrontEndMaps """
43 
44  def initialize(self):
45  """ initialize method: prints SCROD mappings """
46 
47  mapper = Belle2.TOP.TOPGeometryPar.Instance().getFrontEndMapper()
48  if not mapper.isValid():
49  return
50 
51  print()
52  print('expNo:', expNo, 'runNo:', runNo, tagtxt, tag)
53  print('Mapping of boardstacks to SCROD IDs')
54  for slot in range(1, 17):
55  print('slot', slot)
56  for bs in range(4):
57  femap = mapper.getMap(slot, bs)
58  if femap:
59  print(' BS' + str(bs) + ':', femap.getScrodID())
60  else:
61  print(' BS' + str(bs) + ': *not available*')
62 
63 
64 set_log_level(LogLevel.ERROR)
65 
66 main = create_path()
67 main.add_module('EventInfoSetter', expList=[expNo], runList=[runNo])
68 main.add_module('TOPGeometryParInitializer')
69 main.add_module(CheckFrontEndMaps())
70 
71 # process single event
72 process(main)
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.