Belle II Software development
KLMChannelMapValue.h
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#pragma once
10
11/* KLM headers. */
12#include <klm/dataobjects/KLMChannelIndex.h>
13
14/* Basf2 headers. */
15#include <framework/logging/Logger.h>
16
17/* ROOT headers. */
18#include <TNamed.h>
19
20/* C++ headers. */
21#include <cstdint>
22#include <map>
23
24namespace Belle2 {
33 template<class T> class KLMChannelMapValue : public TNamed {
34
35 public:
36
41 {
42 }
43
48 {
49 }
50
55 const T getChannelData(KLMChannelNumber channel) const
56 {
57 typename std::map<KLMChannelNumber, T>::const_iterator it;
58 it = m_ChannelData.find(channel);
59 if (it == m_ChannelData.end()) {
60 B2ERROR("No data for KLM channel in map." <<
61 LogVar("Channel number", channel));
62 }
63 return it->second;
64 }
65
71 void setChannelData(KLMChannelNumber channel, const T data)
72 {
73 typename std::map<KLMChannelNumber, T>::iterator it;
74 it = m_ChannelData.find(channel);
75 if (it == m_ChannelData.end()) {
76 m_ChannelData.insert(std::pair<KLMChannelNumber, T>(channel, data));
77 } else {
78 it->second = data;
79 }
80 }
81
86 void setDataAllChannels(const T data)
87 {
88 KLMChannelIndex klmChannels;
89 for (KLMChannelIndex& klmChannel : klmChannels)
90 setChannelData(klmChannel.getKLMChannelNumber(), data);
91 }
92
93 private:
94
96 std::map<KLMChannelNumber, T> m_ChannelData;
97
100
101 };
102
104}
KLM channel index.
void setChannelData(KLMChannelNumber channel, const T data)
Set channel data.
ClassDef(Belle2::KLMChannelMapValue< T >, 1)
Class version.
std::map< KLMChannelNumber, T > m_ChannelData
Channel data.
const T getChannelData(KLMChannelNumber channel) const
Get channel data.
void setDataAllChannels(const T data)
Set data for all channels.
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.