Belle II Software  release-08-01-10
checkTBCAsic.py
1 #!/usr/bin/env python
2 
3 
10 
11 # ---------------------------------------------------------------------------------------
12 # Search for the shared TBC constants within an ASIC.
13 #
14 # usage: basf2 checkTBCAsic.py expNo runNo [globalTag or localDB]
15 # ---------------------------------------------------------------------------------------
16 
17 import basf2 as b2
18 from ROOT import Belle2
19 import sys
20 
21 argvs = sys.argv
22 if len(argvs) < 3:
23  print("usage: basf2", argvs[0], "expNo runNo [globalTag or localDB]")
24  sys.exit()
25 expNo = int(argvs[1])
26 runNo = int(argvs[2])
27 
28 # Database
29 tag = '(main)'
30 if len(argvs) == 4:
31  tag = argvs[3]
32  if '.txt' in tag:
33  b2.conditions.append_testing_payloads(tag)
34  else:
35  b2.conditions.append_globaltag(tag)
36 
37 
38 class CheckTBCAsic(b2.Module):
39  ''' Search for the shared TBC constants within an ASIC '''
40 
41  def initialize(self):
42  ''' initialize: search is done here '''
43 
44  print()
45  print('Experiment =', expNo, 'Run =', runNo, 'global tag =', tag)
46  print()
47 
48  mapper = Belle2.TOP.TOPGeometryPar.Instance().getFrontEndMapper()
49  tbc = Belle2.PyDBObj('TOPCalTimebase')
50  for slot in range(1, 17):
51  for bs in range(4):
52  femap = mapper.getMap(slot, bs)
53  scrod = femap.getScrodID()
54  print('slot' + str(slot), 'BS' + str(bs), 'scrodID =', scrod)
55  for asic in range(16):
56  sampleTimes = []
57  for ch in range(8):
58  chan = asic * 8 + ch
59  if tbc.isAvailable(scrod, chan):
60  sampleTimes.append(tbc.getSampleTimes(scrod, chan))
61  while len(sampleTimes) > 1:
62  not_eq = []
63  for i in range(1, len(sampleTimes)):
64  if sampleTimes[i].getTimeAxis() == sampleTimes[0].getTimeAxis():
65  ch = sampleTimes[i].getChannel() - asic * 8
66  ch0 = sampleTimes[0].getChannel() - asic * 8
67  print('--> asic =', asic, ': ch' + str(ch), 'sample times are same as ch' + str(ch0))
68  else:
69  not_eq.append(sampleTimes[i])
70  sampleTimes = not_eq
71 
72 
73 # create path
74 main = b2.create_path()
75 
76 # Event info setter - execute single event
77 eventinfosetter = b2.register_module('EventInfoSetter')
78 eventinfosetter.param({'evtNumList': [1], 'runList': [runNo], 'expList': [expNo]})
79 main.add_module(eventinfosetter)
80 
81 # Geometry parameters
82 main.add_module('TOPGeometryParInitializer')
83 
84 # Search for the shared TBC constants within an ASIC
85 main.add_module(CheckTBCAsic())
86 
87 # process single event
88 b2.process(main)
Class to access a DBObjPtr from Python.
Definition: PyDBObj.h:50
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.