Belle II Software  release-08-01-10
ImportElectronicsMap.py
1 #!/usr/bin/env python
2 
3 
10 
11 # Import BKLM electronics mapping payloads.
12 
13 import sys
14 import basf2
15 from ROOT.Belle2 import KLMElectronicsMapImporter, KLMElementNumbers, BKLMElementNumbers
16 
17 basf2.set_log_level(basf2.LogLevel.INFO)
18 
19 mc = False
20 if (len(sys.argv) >= 2):
21  if (sys.argv[1] == 'mc'):
22  mc = True
23 
24 # Database importer.
25 importer = KLMElectronicsMapImporter()
26 
27 
28 def clear_electronics_map():
29  """
30  Clear electronics map (to load another version).
31  """
32  importer.clearElectronicsMap()
33 
34 
35 def load_bklm_electronics_map(version, mc):
36  """
37  Load BKLM electronics map.
38  Versions:
39  1 = before experiment 10.
40  2 = experiment 10 and later (mapping in chimney sector has changed).
41  """
42  if mc:
43  importer.loadBKLMElectronicsMap(1)
44  else:
45  importer.loadBKLMElectronicsMap(version)
46  # Switch lanes for real-data map.
47  # The fibers of layer 1 and 2 are switched in BB6.
48  importer.setLane(KLMElementNumbers.c_BKLM,
49  BKLMElementNumbers.c_BackwardSection,
50  7, 1, 2)
51  importer.setLane(KLMElementNumbers.c_BKLM,
52  BKLMElementNumbers.c_BackwardSection,
53  7, 2, 1)
54 
55 
56 def load_eklm_electronics_map(version, mc):
57  """
58  Load EKLM electronics map.
59  Versions:
60  1 = phase 2 (wrong connection of cables for backward sectors 2 and 3).
61  2 = phase 3
62  """
63  importer.loadEKLMElectronicsMap(version, mc)
64 
65 
66 if mc:
67  # MC map: a single version of map is used for all periods.
68 
69  load_bklm_electronics_map(1, True)
70  load_eklm_electronics_map(1, True)
71 
72  importer.setIOV(0, 0, 0, -1)
73  importer.importElectronicsMap()
74 
75  importer.setIOV(1002, 0, 1002, -1)
76  importer.importElectronicsMap()
77 
78  importer.setIOV(1003, 0, 1003, -1)
79  importer.importElectronicsMap()
80 
81 else:
82  # Data map.
83 
84  # Experiments 0 - 3.
85  load_bklm_electronics_map(1, False)
86  load_eklm_electronics_map(1, False)
87  importer.setIOV(1, 0, 3, -1)
88  importer.importElectronicsMap()
89 
90  # Experiments 4 - 9.
91  clear_electronics_map()
92  load_bklm_electronics_map(1, False)
93  load_eklm_electronics_map(2, False)
94  importer.setIOV(4, 0, 9, -1)
95  importer.importElectronicsMap()
96 
97  # Experiment 10 and later.
98  clear_electronics_map()
99  load_bklm_electronics_map(2, False)
100  load_eklm_electronics_map(2, False)
101  importer.setIOV(10, 0, -1, -1)
102  importer.importElectronicsMap()