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