Belle II Software development
ARICHChannelMask.cc
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#include <framework/logging/Logger.h>
10
11#include <arich/dbobjects/ARICHChannelMask.h>
12#include <iostream>
13
14using namespace std;
15using namespace Belle2;
16
18{
19 std::fill_n(m_DetectorMask, N_HAPDS * N_CHANNELS / 32 + 1, 0xFFFFFFFF);
20}
21
22void ARICHChannelMask::setActiveCh(unsigned module, unsigned channel, bool active)
23{
24 if (module > N_HAPDS || channel > N_CHANNELS) { B2ERROR("ARICHChannelMask::setActiveCh: module ID / channel ID out of range!"); return;}
25 int ch = (module - 1) * N_CHANNELS + channel;
26 int bit = ch % 32;
27 unsigned int idx = ch / 32;
28 if (active) m_DetectorMask[idx] |= (1 << bit);
29 else m_DetectorMask[idx] &= ~(1 << bit);
30}
31
32void ARICHChannelMask::setActiveHAPD(unsigned module, bool active)
33{
34 for (int i = 0; i < N_CHANNELS; i++) {
35 setActiveCh(module, i, active);
36 }
37}
38
39void ARICHChannelMask::setActiveAPD(unsigned module, unsigned apd, bool active)
40{
41 int fst = N_CHANNELS / 4 * apd;
42 for (int i = fst; i < fst + N_CHANNELS / 4; i++) {
43 setActiveCh(module, i, active);
44 }
45}
46
47bool ARICHChannelMask::isActive(unsigned moduleID, unsigned channelID) const
48{
49 int ch = (moduleID - 1) * N_CHANNELS + channelID;
50 int bit = ch % 32;
51 unsigned int idx = ch / 32;
52 if (m_DetectorMask[idx] & (1 << bit)) return true;
53 return false;
54}
55
57{
58
59 cout << endl << "ARICH masked channels" << endl << endl;
60 for (int i = 0; i < N_HAPDS; i++) {
61 int first = 1;
62 //cout << "Module "<< i+1 << ": " ;
63 for (int j = 0; j < N_CHANNELS; j++) {
64 if (!isActive(i + 1, j)) {
65 if (first) cout << "Module " << i + 1 << ": " ;
66 cout << j << " ";
67 first = 0;
68 }
69 }
70 if (!first) cout << endl << endl;
71
72 }
73}
void setActiveHAPD(unsigned modId, bool active)
Set active/non-active HAPD module.
ARICHChannelMask()
Default constructor.
void setActiveCh(unsigned modId, unsigned chNo, bool active)
Set active/non-active channel.
void setActiveAPD(unsigned modId, unsigned apdId, bool active)
Set active/non-active APD of HAPD module.
uint32_t m_DetectorMask[N_HAPDS *N_CHANNELS/32+1]
Detector Mask of active channels.
void print() const
dump content
bool isActive(unsigned modId, unsigned chNo) const
Check if channel is active.
Abstract base class for different kinds of events.
STL namespace.