Belle II Software  release-08-01-10
KLMElectronicsMap.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 /* Own header. */
10 #include <klm/dbobjects/KLMElectronicsMap.h>
11 
12 /* Basf2 headers. */
13 #include <framework/logging/Logger.h>
14 
15 using namespace Belle2;
16 
18 {
19 }
20 
22 {
23 }
24 
26  KLMElectronicsChannel* electronicsChannel) const
27 {
28  std::map<KLMElectronicsChannel, KLMChannelNumber>::const_iterator it;
29  it = m_MapElectronicsDetector.find(*electronicsChannel);
30  if (it == m_MapElectronicsDetector.end())
31  return nullptr;
32  return &(it->second);
33 }
34 
36  KLMChannelNumber detectorChannel) const
37 {
38  std::map<KLMChannelNumber, KLMElectronicsChannel>::const_iterator it;
39  it = m_MapDetectorElectronics.find(detectorChannel);
40  if (it == m_MapDetectorElectronics.end())
41  return nullptr;
42  return &(it->second);
43 }
44 
46  KLMChannelNumber detectorChannel, int copper, int slot, int lane, int axis,
47  int channel)
48 {
49  KLMElectronicsChannel electronicsChannel(copper, slot, lane, axis, channel);
50  if (m_MapDetectorElectronics.find(detectorChannel) != m_MapDetectorElectronics.end()) {
51  B2ERROR("Detector channel already exists in the electronics map."
52  << LogVar("Detector channel", detectorChannel));
53  return;
54  }
55  if (m_MapElectronicsDetector.find(electronicsChannel) != m_MapElectronicsDetector.end()) {
56  B2ERROR("Electronics channel already exists in the electronics map."
57  << LogVar("Copper", copper)
58  << LogVar("Slot", slot)
59  << LogVar("Lane", lane)
60  << LogVar("Axis", axis)
61  << LogVar("Channel", channel));
62  return;
63  }
64  m_MapDetectorElectronics.insert(std::pair<KLMChannelNumber, KLMElectronicsChannel>(
65  detectorChannel, electronicsChannel));
66  m_MapElectronicsDetector.insert(std::pair<KLMElectronicsChannel, KLMChannelNumber>(
67  electronicsChannel, detectorChannel));
68 }
69 
BKLM electronics channel.
const KLMElectronicsChannel * getElectronicsChannel(KLMChannelNumber detectorChannel) const
Get electronics channel by detector channel.
std::map< KLMChannelNumber, KLMElectronicsChannel > m_MapDetectorElectronics
Detector channel - electronics channel map.
const KLMChannelNumber * getDetectorChannel(KLMElectronicsChannel *electronicsChannel) const
Get detector channel by electronics channel.
void addChannel(KLMChannelNumber detectorChannel, int copper, int slot, int lane, int axis, int channel)
Add channel.
std::map< KLMElectronicsChannel, KLMChannelNumber > m_MapElectronicsDetector
Electronics channel - detector channel map.
Class to store variables with their name which were sent to the logging service.
uint16_t KLMChannelNumber
Channel number.
Abstract base class for different kinds of events.