9 #include <framework/logging/Logger.h>
11 #include <arich/dbobjects/ARICHModulesInfo.h>
18 ARICHModulesInfo::ARICHModulesInfo()
20 m_ChannelQE.assign(N_HAPDS * N_CHANNELS, 0);
21 std::fill_n(m_installed, N_HAPDS,
false);
22 std::fill_n(m_active, N_HAPDS,
false);
25 double ARICHModulesInfo::getChannelQE(
unsigned moduleID,
unsigned channelID)
const
27 if (moduleID > N_HAPDS
28 || channelID > N_CHANNELS - 1) B2ERROR(
"ARICHModulesInfo::getChannelQE: module ID or channel ID out of range");
30 int id = (moduleID - 1) * N_CHANNELS + channelID;
31 return (
double)m_ChannelQE[id] / 100.0;
34 void ARICHModulesInfo::setChannelQE(
unsigned modId,
unsigned chId,
double qe)
36 if (modId > N_HAPDS || chId > N_CHANNELS - 1) B2ERROR(
"ARICHModulesInfo::setChannelQE: module ID or channel ID out of range");
38 int chid = (modId - 1) * N_CHANNELS + chId;
39 m_ChannelQE[chid] = uint8_t(qe * 100 + 0.5);
42 void ARICHModulesInfo::addModule(
unsigned modId, std::vector<float>& qeList,
bool active)
45 if (modId > N_HAPDS) B2ERROR(
"ARICHModulesInfo::addModule: module ID is out of range");
46 if (qeList.size() != N_CHANNELS) B2ERROR(
"ARICHModulesInfo::addModule: incomplete list of channels QEs");
48 m_installed[modId - 1] =
true;
49 m_active[modId - 1] = active;
51 std::vector<uint8_t>::iterator it = m_ChannelQE.begin() + (modId - 1) * N_CHANNELS;
52 for (
auto qe : qeList) {
53 *it = uint8_t(qe + 0.5);
58 bool ARICHModulesInfo::isInstalled(
unsigned modId)
const
60 if (modId > N_HAPDS) B2ERROR(
"ARICHModulesInfo::isInstalled: module ID is out of range");
62 return m_installed[modId - 1];
65 bool ARICHModulesInfo::isActive(
unsigned modId)
const
67 if (modId > N_HAPDS) B2ERROR(
"ARICHModulesInfo::isActive: module ID is out of range");
69 return m_active[modId - 1];
72 void ARICHModulesInfo::print()
const
74 cout <<
"ARICHModulesInfo: " << endl;
75 cout <<
" Modules status " << endl;
76 cout <<
" ID / installed / active / avg. QE" << endl;
78 for (
int i = 1; i < N_HAPDS + 1; i++) {
79 cout << right << setfill(
' ') << setw(4) << i <<
": ";
80 if (isInstalled(i)) cout << 1;
83 if (isActive(i)) cout << 1;
86 for (
int j = 0; j < N_CHANNELS; j++) {
87 double chQE = getChannelQE(i, j);
89 if (chQE > maxQE) maxQE = chQE;
91 avgQE /= double(N_CHANNELS);
92 cout <<
" " << left << setfill(
'0') << setw(4) << setprecision(2) << avgQE <<
" ";
93 if ((i) % 10 == 0) cout << endl;
95 cout <<
" Maximal channel QE: " << maxQE << endl;
Abstract base class for different kinds of events.