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