Belle II Software  release-08-01-10
eclCreateUnpackerParams.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 import ROOT
13 from ROOT import Belle2
14 
15 """
16 Create and fill ECLChannelMap class.
17 Can be used for creating run-dependent ECLUnpacker parameters.
18 """
19 
20 FIRST_EXP = 12
21 FIRST_RUN = 2251
22 LAST_EXP = 12
23 LAST_RUN = 2366
24 DBOBJECT_NAME = 'ECLUnpackingParameters'
25 
26 
27 def getValue(crate, shaper, channel):
28  """
29  Edit this function according to your current use-case.
30  If you are preparing ECLUnpackingParameters, see
31  ECLUnpackerModule::ECLUnpack for bit definitions.
32  """
33  if crate == 32 and shaper == 9:
34  return 7
35  return 0
36 
37 
38 
39 
40 def main():
41  """
42  """
43  coefs_bar = []
44  coefs_fwd = []
45  coefs_bwd = []
46 
47  for crate in range(1, 52 + 1):
48  if crate < 37:
49  sh_count = 12
50  elif crate < 45:
51  sh_count = 10
52  else:
53  sh_count = 8
54  for shaper in range(1, sh_count + 1):
55  for channel in range(1, 16 + 1):
56  val = getValue(crate, shaper, channel)
57  if crate < 37:
58  coefs_bar.append(val)
59  elif crate < 45:
60  coefs_fwd.append(val)
61  else:
62  coefs_bwd.append(val)
63 
64  vec_bar = ROOT.std.vector('int')()
65  vec_bar += coefs_bar
66  vec_fwd = ROOT.std.vector('int')()
67  vec_fwd += coefs_fwd
68  vec_bwd = ROOT.std.vector('int')()
69  vec_bwd += coefs_bwd
70 
71  coefs = Belle2.ECLChannelMap()
72  coefs.setMappingVectors(vec_bar, vec_fwd, vec_bwd)
73 
75  iov = Belle2.IntervalOfValidity(FIRST_EXP, FIRST_RUN, LAST_EXP, LAST_RUN)
76  db.storeData(DBOBJECT_NAME, coefs, iov)
77 
78 
79 if __name__ == '__main__':
80  main()
DB object to store correspondence table of type (Crate id, ShaperDSP id, Channel id) <-> (ECL CellID)
Definition: ECLChannelMap.h:51
A class that describes the interval of experiments/runs for which an object in the database is valid.
static Database & Instance()
Instance of a singleton Database.
Definition: Database.cc:42
Definition: main.py:1
int main(int argc, char **argv)
Run all tests.
Definition: test_main.cc:91