10#include <klm/calibration/KLMElectronicsMapImporter.h>
13#include <klm/dataobjects/KLMChannelIndex.h>
14#include <klm/dbobjects/KLMElectronicsMap.h>
17#include <framework/database/DBImportObjPtr.h>
18#include <framework/database/IntervalOfValidity.h>
19#include <framework/logging/Logger.h>
20#include <rawdata/dataobjects/RawCOPPERFormat.h>
34 int experimentHigh,
int runHigh)
49 const int minimalVersion = 1;
50 const int maximalVersion = 2;
51 if (version < minimalVersion || version > maximalVersion) {
52 B2FATAL(
"Incorrect version (" << version <<
") of BKLM electronics map. "
53 "It must be from " << minimalVersion <<
" to " << maximalVersion);
61 bklmPlane != bklmPlanes.
endBKLM(); ++bklmPlane) {
62 int section = bklmPlane.getSection();
63 int sector = bklmPlane.getSector();
64 int layer = bklmPlane.getLayer();
65 int plane = bklmPlane.getPlane();
68 if (sector == 3 || sector == 4 || sector == 5 || sector == 6)
69 copperId = 1 + BKLM_ID;
70 if (sector == 1 || sector == 2 || sector == 7 || sector == 8)
71 copperId = 2 + BKLM_ID;
74 if (sector == 3 || sector == 4 || sector == 5 || sector == 6)
75 copperId = 3 + BKLM_ID;
76 if (sector == 1 || sector == 2 || sector == 7 || sector == 8)
77 copperId = 4 + BKLM_ID;
80 if (sector == 3 || sector == 4 || sector == 5 || sector == 6)
82 if (sector == 1 || sector == 2)
84 if (sector == 7 || sector == 8)
99 section, sector, layer, plane);
101 bool dontFlip =
false;
103 (sector == 7 || sector == 8 || sector == 1 || sector == 2))
106 (sector == 4 || sector == 5 || sector == 6 || sector == 7))
109 for (
int iStrip = 1; iStrip <= MaxiChannel; iStrip++) {
110 int channelId = iStrip;
113 channelId = MaxiChannel - iStrip + 1;
124 int channelCheck = channelId;
129 if (channelCheck > 0 && channelCheck < 9)
130 channelId = 9 - channelId;
131 if (channelCheck > 8 && channelCheck < 24)
132 channelId = 54 - channelId;
133 if (channelCheck > 23 && channelCheck < 39)
134 channelId = 54 - channelId;
136 if (channelCheck > 0 && channelCheck < 9)
137 channelId = 9 - channelId;
138 if (channelCheck > 8 && channelCheck < 24)
139 channelId = 39 - channelId;
140 if (channelCheck > 23 && channelCheck < 39)
141 channelId = 69 - channelId;
145 if (channelCheck > 0 && channelCheck < 10)
146 channelId = 10 - channelId;
147 if (channelCheck > 9 && channelCheck < 24)
148 channelId = 40 - channelId;
149 if (channelCheck > 23 && channelCheck < 39)
150 channelId = 69 - channelId;
153 if (channelCheck > 0 && channelCheck < 10)
154 channelId = 10 - channelId;
155 if (channelCheck > 9 && channelCheck < 25)
156 channelId = 40 - channelId;
157 if (channelCheck > 24 && channelCheck < 40)
158 channelId = 70 - channelId;
159 if (channelCheck > 39 && channelCheck < 55)
160 channelId = 100 - channelId;
166 section, sector, layer, plane, iStrip);
168 std::pair<KLMChannelNumber, KLMElectronicsChannel>(
181 segment = 4 - segment;
188 int section,
int sector,
int layer,
int copper,
int slot,
int lane)
192 int axis = plane - 1;
195 section, sector, layer, plane, strip);
197 std::pair<KLMChannelNumber, KLMElectronicsChannel>(
205 int section,
int sector,
int layer,
int plane,
int segment,
208 std::map<KLMChannelNumber, KLMElectronicsChannel>:: iterator it;
212 section, sector, layer, plane, stripPlane);
215 B2FATAL(
"The KLM electronics map is not loaded or incomplete.");
218 it->second.setChannel(channel);
224 const int minimalVersion = 1;
225 const int maximalVersion = 2;
226 if (version < minimalVersion || version > maximalVersion) {
227 B2FATAL(
"Incorrect version (" << version <<
") of EKLM electronics map. "
228 "It must be from " << minimalVersion <<
" to " << maximalVersion);
242 if (mc || (version >= 2)) {
392 int subdetector,
int section,
int sector,
int layer,
int lane)
394 std::map<KLMChannelNumber, KLMElectronicsChannel>::iterator it;
396 KLMChannelIndex klmChannel(subdetector, section, sector, layer, minimalPlane, 1);
401 for (; klmChannel != klmNextModule; ++klmChannel) {
405 B2FATAL(
"The KLM electronics map is not loaded or incomplete.");
406 it->second.setLane(lane);
411 int subdetector,
int section,
int sector,
int layer,
int plane,
int lane)
413 std::map<KLMChannelNumber, KLMElectronicsChannel>::iterator it;
414 KLMChannelIndex klmChannel(subdetector, section, sector, layer, plane, 1);
419 for (; klmChannel != klmNextPlane; ++klmChannel) {
423 B2FATAL(
"The KLM electronics map is not loaded or incomplete.");
424 it->second.setLane(lane);
432 std::map<KLMChannelNumber, KLMElectronicsChannel>::iterator it;
434 electronicsMap->addChannel(
436 it->second.getCopper(),
437 it->second.getSlot(),
438 it->second.getLane(),
439 it->second.getAxis(),
440 it->second.getChannel());
444 electronicsMap.
import(iov);
@ c_ChimneySector
Chimney sector: BB3 in 1-based notation; BB2 in 0-based notation.
@ c_FirstRPCLayer
First RPC layer.
@ c_ForwardSection
Forward.
@ c_BackwardSection
Backward.
static int getNStrips(int section, int sector, int layer, int plane)
Get number of strips.
bool import(const IntervalOfValidity &iov)
Import the object to database.
Class for importing a single object to the database.
void construct(Args &&... params)
Construct an object of type T in this DBImportObjPtr using the provided constructor arguments.
static constexpr int getMaximalStripNumber()
Get maximal strip number.
@ c_ForwardSection
Forward.
@ c_BackwardSection
Backward.
static constexpr int getNStripsSegment()
Get number of strips in a segment.
static constexpr int getMaximalPlaneNumber()
Get maximal plane number.
A class that describes the interval of experiments/runs for which an object in the database is valid.
KLMChannelIndex beginBKLM()
First channel for BKLM.
@ c_IndexLevelLayer
Layer.
@ c_IndexLevelPlane
Plane.
KLMChannelNumber getKLMChannelNumber() const
Get KLM channel number.
void setIndexLevel(enum IndexLevel indexLevel)
Set index level.
KLMChannelIndex & endBKLM()
Last channel for BKLM.
BKLM electronics channel.
int m_ExperimentHigh
High experiment.
const KLMElementNumbers * m_ElementNumbers
Element numbers.
int m_ExperimentLow
Low experiment.
void setChannelsEKLMSegment(int section, int sector, int layer, int plane, int segment, int firmwareSegment)
Set channels for EKLM segment.
~KLMElectronicsMapImporter()
Destructor.
void setIOV(int experimentLow, int runLow, int experimentHigh, int runHigh)
Set interval of validity.
void clearElectronicsMap()
Clear electronics map (to be able to import its multiple versions).
void addEKLMLane(int section, int sector, int layer, int copper, int slot, int lane)
Add EKLM electronics map lane.
void setLane(int subdetector, int section, int sector, int layer, int lane)
Set non-default lane for all channels in a module.
void loadEKLMElectronicsMap(int version, bool mc)
Load EKLM electronics map.
KLMElectronicsMapImporter()
Constructor.
void loadBKLMElectronicsMap(int version)
Load BKLM electronics map.
std::map< KLMChannelNumber, KLMElectronicsChannel > m_ChannelMap
Data for creation of the electronics map.
void importElectronicsMap()
Import electronics map.
int getEKLMStripFirmwareBySoftware(int stripSoftware) const
Get EKLM firmware strip number by software strip number.
KLMChannelNumber channelNumberBKLM(int section, int sector, int layer, int plane, int strip) const
Get channel number for BKLM.
int getMinimalPlaneNumber(int subdetector) const
Get minimal plane number.
KLMChannelNumber channelNumberEKLM(int section, int sector, int layer, int plane, int strip) const
Get channel number for EKLM.
uint16_t KLMChannelNumber
Channel number.
Abstract base class for different kinds of events.