11 #include <framework/logging/Logger.h>
13 #include <arich/dbobjects/ARICHChannelMask.h>
19 ARICHChannelMask::ARICHChannelMask()
21 std::fill_n(m_DetectorMask, N_HAPDS * N_CHANNELS / 32 + 1, 0xFFFFFFFF);
24 void ARICHChannelMask::setActiveCh(
unsigned module,
unsigned channel,
bool active)
26 if (module > N_HAPDS || channel > N_CHANNELS) { B2ERROR(
"ARICHChannelMask::setActiveCh: module ID / channel ID out of range!");
return;}
27 int ch = (module - 1) * N_CHANNELS + channel;
29 unsigned int idx = ch / 32;
30 if (active) m_DetectorMask[idx] |= (1 << bit);
31 else m_DetectorMask[idx] &= ~(1 << bit);
34 void ARICHChannelMask::setActiveHAPD(
unsigned module,
bool active)
36 for (
int i = 0; i < N_CHANNELS; i++) {
37 setActiveCh(module, i, active);
41 void ARICHChannelMask::setActiveAPD(
unsigned module,
unsigned apd,
bool active)
43 int fst = N_CHANNELS / 4 * apd;
44 for (
int i = fst; i < fst + N_CHANNELS / 4; i++) {
45 setActiveCh(module, i, active);
49 bool ARICHChannelMask::isActive(
unsigned moduleID,
unsigned channelID)
const
51 int ch = (moduleID - 1) * N_CHANNELS + channelID;
53 unsigned int idx = ch / 32;
54 if (m_DetectorMask[idx] & (1 << bit))
return true;
58 void ARICHChannelMask::print()
const
61 cout << endl <<
"ARICH masked channels" << endl << endl;
62 for (
int i = 0; i < N_HAPDS; i++) {
65 for (
int j = 0; j < N_CHANNELS; j++) {
66 if (!isActive(i + 1, j)) {
67 if (first) cout <<
"Module " << i + 1 <<
": " ;
72 if (!first) cout << endl << endl;