Belle II Software  release-05-02-19
TOPCalChannelMask.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Umberto Tamponi (tamponi@to.infn.it) *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <TObject.h>
14 
15 namespace Belle2 {
31  class TOPCalChannelMask: public TObject {
32  public:
33 
37  enum EStatus {c_Active = 0,
38  c_Dead = 1,
39  c_Noisy = 2
40  };
41 
46 
53  void setStatus(int moduleID, unsigned channel, EStatus status);
54 
60  void setActive(int moduleID, unsigned channel);
61 
67  void setDead(int moduleID, unsigned channel);
68 
74  void setNoisy(int moduleID, unsigned channel);
75 
82  EStatus getStatus(int moduleID, unsigned channel) const;
83 
90  bool isActive(int moduleID, unsigned channel) const;
91 
95  int getNumOfChannels() const {return c_numChannels * c_numModules;}
96 
100  int getNumOfModuleChannels() const {return c_numChannels;}
101 
105  int getNumOfActiveChannels() const {return getNumOf(c_Active);}
106 
110  int getNumOfDeadChannels() const {return getNumOf(c_Dead);}
111 
115  int getNumOfNoisyChannels() const {return getNumOf(c_Noisy);}
116 
120  double getActiveFraction() const
121  {
122  return static_cast<double>(getNumOfActiveChannels()) / c_numModules / c_numChannels;
123  }
124 
128  int getNumOfActiveChannels(int moduleID) const {return getNumOf(c_Active, moduleID);}
129 
133  int getNumOfDeadChannels(int moduleID) const {return getNumOf(c_Dead, moduleID);}
134 
138  int getNumOfNoisyChannels(int moduleID) const {return getNumOf(c_Noisy, moduleID);}
139 
143  double getActiveFraction(int moduleID) const
144  {
145  return static_cast<double>(getNumOfActiveChannels(moduleID)) / c_numChannels;
146  }
147 
148 
149  private:
150 
154  bool check(const int module, const unsigned channel) const;
155 
161  int getNumOf(EStatus check) const;
162 
169  int getNumOf(EStatus check, int moduleID) const;
170 
174  enum {c_numModules = 16,
175  c_numChannels = 512
176  };
177 
178  EStatus m_status[c_numModules][c_numChannels] = {{ c_Active }};
179  // instantiating an array with too few entries fills with zeroes (==active)
180 
183  };
184 
186 } // end namespace Belle2
187 
Belle2::TOPCalChannelMask::c_numChannels
@ c_numChannels
number of channels per module
Definition: TOPCalChannelMask.h:183
Belle2::TOPCalChannelMask::getNumOfChannels
int getNumOfChannels() const
Returns number of all channels.
Definition: TOPCalChannelMask.h:103
Belle2::TOPCalChannelMask::getNumOfNoisyChannels
int getNumOfNoisyChannels() const
Returns number of noisy channels.
Definition: TOPCalChannelMask.h:123
Belle2::TOPCalChannelMask::m_status
EStatus m_status[c_numModules][c_numChannels]
channel status
Definition: TOPCalChannelMask.h:186
Belle2::TOPCalChannelMask::setActive
void setActive(int moduleID, unsigned channel)
Sets a specific channel as active.
Definition: TOPCalChannelMask.cc:33
Belle2::TOPCalChannelMask::setNoisy
void setNoisy(int moduleID, unsigned channel)
Sets a specific channel as noisy.
Definition: TOPCalChannelMask.cc:53
Belle2::TOPCalChannelMask::EStatus
EStatus
Status of the channel.
Definition: TOPCalChannelMask.h:45
Belle2::TOPCalChannelMask::getNumOfActiveChannels
int getNumOfActiveChannels() const
Returns number of active channels.
Definition: TOPCalChannelMask.h:113
Belle2::TOPCalChannelMask::check
bool check(const int module, const unsigned channel) const
Check input module and channel arguments are sane.
Definition: TOPCalChannelMask.cc:84
Belle2::TOPCalChannelMask::getNumOf
int getNumOf(EStatus check) const
Counts and returns the number of channels having a given status.
Definition: TOPCalChannelMask.cc:101
Belle2::TOPCalChannelMask::c_numModules
@ c_numModules
number of modules
Definition: TOPCalChannelMask.h:182
Belle2::TOPCalChannelMask::setDead
void setDead(int moduleID, unsigned channel)
Sets a specific channel as dead.
Definition: TOPCalChannelMask.cc:43
Belle2::TOPCalChannelMask::setStatus
void setStatus(int moduleID, unsigned channel, EStatus status)
Sets the status for a single channel.
Definition: TOPCalChannelMask.cc:23
Belle2::TOPCalChannelMask::getActiveFraction
double getActiveFraction() const
Returns fraction of active channels.
Definition: TOPCalChannelMask.h:128
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TOPCalChannelMask::getNumOfModuleChannels
int getNumOfModuleChannels() const
Returns number of channels in a module.
Definition: TOPCalChannelMask.h:108
Belle2::TOPCalChannelMask::getStatus
EStatus getStatus(int moduleID, unsigned channel) const
Returns the status of a single channel.
Definition: TOPCalChannelMask.cc:63
Belle2::TOPCalChannelMask::getNumOfDeadChannels
int getNumOfDeadChannels() const
Returns number of dead channels.
Definition: TOPCalChannelMask.h:118
Belle2::TOPCalChannelMask::TOPCalChannelMask
TOPCalChannelMask()
Default constructor.
Definition: TOPCalChannelMask.h:53
Belle2::TOPCalChannelMask::isActive
bool isActive(int moduleID, unsigned channel) const
Returns false if the channel is dead or noisy, and true is the channel is active.
Definition: TOPCalChannelMask.cc:74
Belle2::TOPCalChannelMask::ClassDef
ClassDef(TOPCalChannelMask, 1)
ClassDef.