Belle II Software development
KLMElementArrayIndex.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/dataobjects/KLMElementArrayIndex.h>
11
12/* Basf2 headers. */
13#include <framework/logging/Logger.h>
14
15using namespace Belle2;
16
18 enum KLMChannelIndex::IndexLevel indexLevel)
19{
20 uint16_t index = 0;
21 KLMChannelIndex klmElements(indexLevel);
22 m_NElements = 0;
23 for (KLMChannelIndex& klmElement : klmElements) {
24 uint16_t number;
25 switch (indexLevel) {
27 number = klmElement.getKLMChannelNumber();
28 break;
30 number = klmElement.getKLMPlaneNumber();
31 break;
33 number = klmElement.getKLMModuleNumber();
34 break;
36 number = klmElement.getKLMSectorNumber();
37 break;
38 default:
39 B2FATAL("Unsupported index level in KLMElementArrayIndex.");
40 }
41 m_MapNumberIndex.insert(std::pair<uint16_t, uint16_t>(number, index));
42 m_MapIndexNumber.insert(std::pair<uint16_t, uint16_t>(index, number));
43 index++;
45 }
46}
47
49{
50}
51
52uint16_t KLMElementArrayIndex::getIndex(uint16_t number) const
53{
54 std::map<uint16_t, uint16_t>::const_iterator it =
55 m_MapNumberIndex.find(number);
56 if (it == m_MapNumberIndex.end())
57 B2FATAL("Incorrect KLM element number.");
58 return it->second;
59}
60
61uint16_t KLMElementArrayIndex::getNumber(uint16_t index) const
62{
63 std::map<uint16_t, uint16_t>::const_iterator it =
64 m_MapIndexNumber.find(index);
65 if (it == m_MapIndexNumber.end())
66 B2FATAL("Incorrect KLM element index.");
67 return it->second;
68}
KLM channel index.
IndexLevel
Index level (loop over KLM elements at the specified level).
uint16_t getNumber(uint16_t index) const
Get element number.
uint16_t m_NElements
Number of elements.
uint16_t getIndex(uint16_t number) const
Get element index.
std::map< uint16_t, uint16_t > m_MapIndexNumber
Map KLM element index - KLM element number.
virtual ~KLMElementArrayIndex()
Destructor.
KLMElementArrayIndex(enum KLMChannelIndex::IndexLevel indexLevel)
Constructor.
std::map< uint16_t, uint16_t > m_MapNumberIndex
Map KLM element number - KLM element index.
Abstract base class for different kinds of events.