Belle II Software  release-05-01-25
TOPCalIntegratedCharge.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2018 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Marko Staric *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <TObject.h>
14 #include <framework/logging/Logger.h>
15 
16 namespace Belle2 {
25  class TOPCalIntegratedCharge: public TObject {
26  public:
27 
31  enum EStatus {
32  c_Default = 0,
34  c_Unusable = 2
35  };
36 
41 
48  void setCharge(int moduleID, unsigned channel, double charge)
49  {
50  unsigned module = moduleID - 1;
51  if (module >= c_numModules) {
52  B2ERROR("Invalid module number, constant not set (" << ClassName() << ")");
53  return;
54  }
55  if (channel >= c_numChannels) {
56  B2ERROR("Invalid channel number, constant not set (" << ClassName() << ")");
57  return;
58  }
59  m_charge[module][channel] = charge;
60  m_status[module][channel] = c_Calibrated;
61  }
62 
68  void setUnusable(int moduleID, unsigned channel)
69  {
70  unsigned module = moduleID - 1;
71  if (module >= c_numModules) {
72  B2ERROR("Invalid module number, status not set (" << ClassName() << ")");
73  return;
74  }
75  if (channel >= c_numChannels) {
76  B2ERROR("Invalid channel number, status not set (" << ClassName() << ")");
77  return;
78  }
79  m_status[module][channel] = c_Unusable;
80  }
81 
88  double getCharge(int moduleID, unsigned channel) const
89  {
90  unsigned module = moduleID - 1;
91  if (module >= c_numModules) {
92  B2WARNING("Invalid module number, returning 0 (" << ClassName() << ")");
93  return 0;
94  }
95  if (channel >= c_numChannels) {
96  B2WARNING("Invalid channel number, returning 0 (" << ClassName() << ")");
97  return 0;
98  }
99  return m_charge[module][channel];
100  }
101 
108  bool isCalibrated(int moduleID, unsigned channel) const
109  {
110  unsigned module = moduleID - 1;
111  if (module >= c_numModules) return false;
112  if (channel >= c_numChannels) return false;
113  return m_status[module][channel] == c_Calibrated;
114  }
115 
122  bool isDefault(int moduleID, unsigned channel) const
123  {
124  unsigned module = moduleID - 1;
125  if (module >= c_numModules) return false;
126  if (channel >= c_numChannels) return false;
127  return m_status[module][channel] == c_Default;
128  }
129 
136  bool isUnusable(int moduleID, unsigned channel) const
137  {
138  unsigned module = moduleID - 1;
139  if (module >= c_numModules) return false;
140  if (channel >= c_numChannels) return false;
141  return m_status[module][channel] == c_Unusable;
142  }
143 
144  private:
145 
149  enum {
150  c_numModules = 16,
151  c_numChannels = 512
152  };
153 
154  float m_charge[c_numModules][c_numChannels] = {{0}};
159  };
160 
162 } // end namespace Belle2
163 
Belle2::TOPCalIntegratedCharge::isDefault
bool isDefault(int moduleID, unsigned channel) const
Returns calibration status.
Definition: TOPCalIntegratedCharge.h:130
Belle2::TOPCalIntegratedCharge::isUnusable
bool isUnusable(int moduleID, unsigned channel) const
Returns calibration status.
Definition: TOPCalIntegratedCharge.h:144
Belle2::TOPCalIntegratedCharge::isCalibrated
bool isCalibrated(int moduleID, unsigned channel) const
Returns calibration status.
Definition: TOPCalIntegratedCharge.h:116
Belle2::TOPCalIntegratedCharge::setUnusable
void setUnusable(int moduleID, unsigned channel)
Switches calibration status to unusable to flag badly calibrated constant.
Definition: TOPCalIntegratedCharge.h:76
Belle2::TOPCalIntegratedCharge::c_numChannels
@ c_numChannels
number of channels per module
Definition: TOPCalIntegratedCharge.h:159
Belle2::TOPCalIntegratedCharge::getCharge
double getCharge(int moduleID, unsigned channel) const
Returns the integrated charge of a single channel.
Definition: TOPCalIntegratedCharge.h:96
Belle2::TOPCalIntegratedCharge::m_charge
float m_charge[c_numModules][c_numChannels]
integrated charge [C/cm^2]
Definition: TOPCalIntegratedCharge.h:162
Belle2::TOPCalIntegratedCharge::c_Unusable
@ c_Unusable
bad calibrated value
Definition: TOPCalIntegratedCharge.h:42
Belle2::TOPCalIntegratedCharge::m_status
EStatus m_status[c_numModules][c_numChannels]
calibration status
Definition: TOPCalIntegratedCharge.h:163
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TOPCalIntegratedCharge::c_numModules
@ c_numModules
number of modules
Definition: TOPCalIntegratedCharge.h:158
Belle2::TOPCalIntegratedCharge::ClassDef
ClassDef(TOPCalIntegratedCharge, 1)
ClassDef.
Belle2::TOPCalIntegratedCharge::c_Calibrated
@ c_Calibrated
good calibrated value
Definition: TOPCalIntegratedCharge.h:41
Belle2::TOPCalIntegratedCharge::setCharge
void setCharge(int moduleID, unsigned channel, double charge)
Sets the integrated charge for a single channel and switches status to calibrated.
Definition: TOPCalIntegratedCharge.h:56
Belle2::TOPCalIntegratedCharge::c_Default
@ c_Default
uncalibrated default value
Definition: TOPCalIntegratedCharge.h:40
Belle2::TOPCalIntegratedCharge::EStatus
EStatus
Calibration status of a constant.
Definition: TOPCalIntegratedCharge.h:39
Belle2::TOPCalIntegratedCharge::TOPCalIntegratedCharge
TOPCalIntegratedCharge()
Default constructor.
Definition: TOPCalIntegratedCharge.h:48