Belle II Software development
TOPASICChannel.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#include <top/dbobjects/TOPASICPedestals.h>
13#include <top/dbobjects/TOPASICGains.h>
14#include <vector>
15
16namespace Belle2 {
25 class TOPASICChannel: public TObject {
26 public:
27
32 {
33 }
34
41 TOPASICChannel(int moduleID, unsigned channel, int numWindows):
42 m_moduleID(moduleID), m_channel(channel)
43 {
44 for (int i = 0; i < numWindows; i++) m_pedestals.push_back(NULL);
45 }
46
50 TOPASICChannel(const TOPASICChannel& chan): TObject()
51 {
52 *this = chan;
53 }
54
59 {
60 if (this != &chan) {
61 m_moduleID = chan.getModuleID();
62 m_channel = chan.getChannel();
63 for (auto& pedestals : m_pedestals) {
64 if (pedestals) delete pedestals;
65 }
67 for (auto& pedestals : m_pedestals) {
68 if (pedestals) pedestals = new TOPASICPedestals(*pedestals);
69 }
70 for (auto& gains : m_gains) {
71 if (gains) delete gains;
72 }
73 m_gains = chan.getGains();
74 for (auto& gains : m_gains) {
75 if (gains) gains = new TOPASICGains(*gains);
76 }
77 }
78 return *this;
79 }
80
85 {
86 for (auto& window : m_pedestals) {
87 if (window) delete window;
88 }
89 for (auto& window : m_gains) {
90 if (window) delete window;
91 }
92 }
93
99 bool setPedestals(const TOPASICPedestals& pedestals)
100 {
101 unsigned i = pedestals.getASICWindow();
102 if (i < m_pedestals.size()) {
103 if (m_pedestals[i]) {
104 *m_pedestals[i] = pedestals;
105 } else {
106 m_pedestals[i] = new TOPASICPedestals(pedestals);
107 }
108 return true;
109 }
110 return false;
111 }
112
118 bool setGains(const TOPASICGains& gains)
119 {
120 if (m_gains.empty()) {
121 for (unsigned i = 0; i < m_pedestals.size(); i++) m_gains.push_back(NULL);
122 }
123 unsigned i = gains.getASICWindow();
124 if (i < m_gains.size()) {
125 if (m_gains[i]) {
126 *m_gains[i] = gains;
127 } else {
128 m_gains[i] = new TOPASICGains(gains);
129 }
130 return true;
131 }
132 return false;
133 }
134
139 int getModuleID() const {return m_moduleID;}
140
145 unsigned getChannel() const {return m_channel;}
146
151 unsigned getNumofWindows() const
152 {
153 return m_pedestals.size();
154 }
155
161 const TOPASICPedestals* getPedestals(unsigned window) const
162 {
163 if (window < m_pedestals.size()) return m_pedestals[window];
164 return NULL;
165 }
166
171 const std::vector<TOPASICPedestals*>& getPedestals() const {return m_pedestals;}
172
178 const TOPASICGains* getGains(unsigned window) const
179 {
180 if (window < m_gains.size()) return m_gains[window];
181 if (window < m_pedestals.size()) return &m_defaultGain;
182 return NULL;
183 }
184
189 const std::vector<TOPASICGains*>& getGains() const {return m_gains;}
190
195 unsigned getNumofGoodWindows() const
196 {
197 unsigned n = 0;
198 for (auto& pedestal : m_pedestals) if (pedestal) n++;
199 return n;
200 }
201
202
203 private:
204
205 int m_moduleID = 0;
206 unsigned m_channel = 0;
207 std::vector<TOPASICPedestals*> m_pedestals;
208 std::vector<TOPASICGains*> m_gains;
214 };
215
217} // end namespace Belle2
218
Calibration constants of a singe ASIC channel: pedestals, gains and time axis.
~TOPASICChannel()
Destructor.
TOPASICChannel(int moduleID, unsigned channel, int numWindows)
Constructor with module ID, hardware channel number and number of ASIC windows.
unsigned m_channel
hardware channel number
std::vector< TOPASICPedestals * > m_pedestals
pedestals
bool setPedestals(const TOPASICPedestals &pedestals)
Set pedestals of a single ASIC window.
unsigned getNumofGoodWindows() const
Return number of good ASIC windows (e.g.
ClassDef(TOPASICChannel, 4)
ClassDef.
TOPASICGains m_defaultGain
default gain
std::vector< TOPASICGains * > m_gains
gains
unsigned getNumofWindows() const
Return number of ASIC windows.
const TOPASICPedestals * getPedestals(unsigned window) const
Return pedestals of an ASIC window.
int getModuleID() const
Return module ID.
unsigned getChannel() const
Return hardware channel number.
TOPASICChannel & operator=(const TOPASICChannel &chan)
Assignment operator.
const std::vector< TOPASICGains * > & getGains() const
Returns a vector of gains.
bool setGains(const TOPASICGains &gains)
Set gains of a single ASIC window.
TOPASICChannel(const TOPASICChannel &chan)
Copy constructor.
const TOPASICGains * getGains(unsigned window) const
Return gains of an ASIC window.
TOPASICChannel()
Default constructor.
const std::vector< TOPASICPedestals * > & getPedestals() const
Returns a vector of pedestals.
Calibration constants of a single ASIC window: gains.
Definition: TOPASICGains.h:22
unsigned getASICWindow() const
Return ASIC window number.
Definition: TOPASICGains.h:62
Calibration constants of a single ASIC window: pedestals.
unsigned getASICWindow() const
Return ASIC window number.
Abstract base class for different kinds of events.