12 #include <klm/calibration/KLMElectronicsMapImporter.h>
15 #include <klm/dataobjects/KLMChannelIndex.h>
16 #include <klm/dbobjects/KLMElectronicsMap.h>
19 #include <framework/database/DBImportObjPtr.h>
20 #include <framework/database/IntervalOfValidity.h>
21 #include <framework/logging/Logger.h>
22 #include <rawdata/dataobjects/RawCOPPERFormat.h>
36 int experimentHigh,
int runHigh)
51 const int minimalVersion = 1;
52 const int maximalVersion = 2;
53 if (version < minimalVersion || version > maximalVersion) {
54 B2FATAL(
"Incorrect version (" << version <<
") of BKLM electronics map. "
55 "It must be from " << minimalVersion <<
" to " << maximalVersion);
63 bklmPlane != bklmPlanes.
endBKLM(); ++bklmPlane) {
64 int section = bklmPlane.getSection();
65 int sector = bklmPlane.getSector();
66 int layer = bklmPlane.getLayer();
67 int plane = bklmPlane.getPlane();
70 if (sector == 3 || sector == 4 || sector == 5 || sector == 6)
71 copperId = 1 + BKLM_ID;
72 if (sector == 1 || sector == 2 || sector == 7 || sector == 8)
73 copperId = 2 + BKLM_ID;
76 if (sector == 3 || sector == 4 || sector == 5 || sector == 6)
77 copperId = 3 + BKLM_ID;
78 if (sector == 1 || sector == 2 || sector == 7 || sector == 8)
79 copperId = 4 + BKLM_ID;
82 if (sector == 3 || sector == 4 || sector == 5 || sector == 6)
84 if (sector == 1 || sector == 2)
86 if (sector == 7 || sector == 8)
101 section, sector, layer, plane);
103 bool dontFlip =
false;
105 (sector == 7 || sector == 8 || sector == 1 || sector == 2))
108 (sector == 4 || sector == 5 || sector == 6 || sector == 7))
111 for (
int iStrip = 1; iStrip <= MaxiChannel; iStrip++) {
112 int channelId = iStrip;
115 channelId = MaxiChannel - iStrip + 1;
126 int channelCheck = channelId;
131 if (channelCheck > 0 && channelCheck < 9)
132 channelId = 9 - channelId;
133 if (channelCheck > 8 && channelCheck < 24)
134 channelId = 54 - channelId;
135 if (channelCheck > 23 && channelCheck < 39)
136 channelId = 54 - channelId;
138 if (channelCheck > 0 && channelCheck < 9)
139 channelId = 9 - channelId;
140 if (channelCheck > 8 && channelCheck < 24)
141 channelId = 39 - channelId;
142 if (channelCheck > 23 && channelCheck < 39)
143 channelId = 69 - channelId;
147 if (channelCheck > 0 && channelCheck < 10)
148 channelId = 10 - channelId;
149 if (channelCheck > 9 && channelCheck < 24)
150 channelId = 40 - channelId;
151 if (channelCheck > 23 && channelCheck < 39)
152 channelId = 69 - channelId;
155 if (channelCheck > 0 && channelCheck < 10)
156 channelId = 10 - channelId;
157 if (channelCheck > 9 && channelCheck < 25)
158 channelId = 40 - channelId;
159 if (channelCheck > 24 && channelCheck < 40)
160 channelId = 70 - channelId;
161 if (channelCheck > 39 && channelCheck < 55)
162 channelId = 100 - channelId;
168 section, sector, layer, plane, iStrip);
170 std::pair<uint16_t, KLMElectronicsChannel>(
183 segment = 4 - segment;
190 int section,
int sector,
int layer,
int copper,
int slot,
int lane)
194 int axis = plane - 1;
197 section, sector, layer, plane, strip);
199 std::pair<uint16_t, KLMElectronicsChannel>(
207 int section,
int sector,
int layer,
int plane,
int segment,
210 std::map<uint16_t, KLMElectronicsChannel>:: iterator it;
214 section, sector, layer, plane, stripPlane);
217 B2FATAL(
"The KLM electronics map is not loaded or incomplete.");
220 it->second.setChannel(channel);
226 const int minimalVersion = 1;
227 const int maximalVersion = 2;
228 if (version < minimalVersion || version > maximalVersion) {
229 B2FATAL(
"Incorrect version (" << version <<
") of EKLM electronics map. "
230 "It must be from " << minimalVersion <<
" to " << maximalVersion);
244 if (mc || (version >= 2)) {
394 int subdetector,
int section,
int sector,
int layer,
int lane)
396 std::map<uint16_t, KLMElectronicsChannel>::iterator it;
398 KLMChannelIndex klmChannel(subdetector, section, sector, layer, minimalPlane, 1);
403 for (; klmChannel != klmNextModule; ++klmChannel) {
407 B2FATAL(
"The KLM electronics map is not loaded or incomplete.");
408 it->second.setLane(lane);
413 int subdetector,
int section,
int sector,
int layer,
int plane,
int lane)
415 std::map<uint16_t, KLMElectronicsChannel>::iterator it;
416 KLMChannelIndex klmChannel(subdetector, section, sector, layer, plane, 1);
421 for (; klmChannel != klmNextPlane; ++klmChannel) {
425 B2FATAL(
"The KLM electronics map is not loaded or incomplete.");
426 it->second.setLane(lane);
434 std::map<uint16_t, KLMElectronicsChannel>::iterator it;
438 it->second.getCopper(),
439 it->second.getSlot(),
440 it->second.getLane(),
441 it->second.getAxis(),
442 it->second.getChannel());
446 electronicsMap.
import(iov);