Belle II Software development
TOPCalChannelMask.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#include <TObject.h>
12
13namespace Belle2 {
29 class TOPCalChannelMask: public TObject {
30 public:
31
35 enum EStatus {c_Active = 0,
36 c_Dead = 1,
37 c_Noisy = 2
38 };
39
44
51 void setStatus(int moduleID, unsigned channel, EStatus status);
52
58 void setActive(int moduleID, unsigned channel);
59
65 void setDead(int moduleID, unsigned channel);
66
72 void setNoisy(int moduleID, unsigned channel);
73
80 EStatus getStatus(int moduleID, unsigned channel) const;
81
88 bool isActive(int moduleID, unsigned channel) const;
89
94
99
103 int getNumOfActiveChannels() const {return getNumOf(c_Active);}
104
108 int getNumOfDeadChannels() const {return getNumOf(c_Dead);}
109
113 int getNumOfNoisyChannels() const {return getNumOf(c_Noisy);}
114
118 double getActiveFraction() const
119 {
120 return static_cast<double>(getNumOfActiveChannels()) / static_cast<double>(c_numModules) / static_cast<double>(c_numChannels);
121 }
122
126 int getNumOfActiveChannels(int moduleID) const {return getNumOf(c_Active, moduleID);}
127
131 int getNumOfDeadChannels(int moduleID) const {return getNumOf(c_Dead, moduleID);}
132
136 int getNumOfNoisyChannels(int moduleID) const {return getNumOf(c_Noisy, moduleID);}
137
141 double getActiveFraction(int moduleID) const
142 {
143 return static_cast<double>(getNumOfActiveChannels(moduleID)) / static_cast<double>(c_numChannels);
144 }
145
146
147 private:
148
152 bool check(const int module, const unsigned channel) const;
153
159 int getNumOf(EStatus check) const;
160
167 int getNumOf(EStatus check, int moduleID) const;
168
172 enum {c_numModules = 16,
173 c_numChannels = 512
174 };
175
177 // instantiating an array with too few entries fills with zeroes (==active)
178
181 };
182
184} // end namespace Belle2
185
Channel status for all 512 channels of 16 modules.
int getNumOfDeadChannels() const
Returns number of dead channels.
ClassDef(TOPCalChannelMask, 1)
ClassDef.
int getNumOfNoisyChannels(int moduleID) const
Returns number of module noisy channels.
EStatus m_status[c_numModules][c_numChannels]
channel status
int getNumOfActiveChannels() const
Returns number of active channels.
int getNumOfChannels() const
Returns number of all channels.
@ c_numChannels
number of channels per module
@ c_numModules
number of modules
double getActiveFraction(int moduleID) const
Returns fraction of module active channels.
EStatus
Status of the channel.
int getNumOfNoisyChannels() const
Returns number of noisy channels.
TOPCalChannelMask()
Default constructor.
int getNumOfDeadChannels(int moduleID) const
Returns number of module dead channels.
int getNumOfModuleChannels() const
Returns number of channels in a module.
double getActiveFraction() const
Returns fraction of active channels.
int getNumOfActiveChannels(int moduleID) const
Returns number of module active channels.
void setActive(int moduleID, unsigned channel)
Sets a specific channel as active.
int getNumOf(EStatus check) const
Counts and returns the number of channels having a given status.
void setNoisy(int moduleID, unsigned channel)
Sets a specific channel as noisy.
void setDead(int moduleID, unsigned channel)
Sets a specific channel as dead.
void setStatus(int moduleID, unsigned channel, EStatus status)
Sets the status for a single channel.
bool isActive(int moduleID, unsigned channel) const
Returns false if the channel is dead or noisy, and true is the channel is active.
EStatus getStatus(int moduleID, unsigned channel) const
Returns the status of a single channel.
bool check(const int module, const unsigned channel) const
Check input module and channel arguments are sane.
Abstract base class for different kinds of events.