Belle II Software  release-05-01-25
ARICHChannelMask.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Luka Santelj *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <framework/logging/Logger.h>
12 
13 #include <arich/dbobjects/ARICHChannelMask.h>
14 #include <iostream>
15 
16 using namespace std;
17 using namespace Belle2;
18 
19 ARICHChannelMask::ARICHChannelMask()
20 {
21  std::fill_n(m_DetectorMask, N_HAPDS * N_CHANNELS / 32 + 1, 0xFFFFFFFF);
22 }
23 
24 void ARICHChannelMask::setActiveCh(unsigned module, unsigned channel, bool active)
25 {
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;
28  int bit = ch % 32;
29  unsigned int idx = ch / 32;
30  if (active) m_DetectorMask[idx] |= (1 << bit);
31  else m_DetectorMask[idx] &= ~(1 << bit);
32 }
33 
34 void ARICHChannelMask::setActiveHAPD(unsigned module, bool active)
35 {
36  for (int i = 0; i < N_CHANNELS; i++) {
37  setActiveCh(module, i, active);
38  }
39 }
40 
41 void ARICHChannelMask::setActiveAPD(unsigned module, unsigned apd, bool active)
42 {
43  int fst = N_CHANNELS / 4 * apd;
44  for (int i = fst; i < fst + N_CHANNELS / 4; i++) {
45  setActiveCh(module, i, active);
46  }
47 }
48 
49 bool ARICHChannelMask::isActive(unsigned moduleID, unsigned channelID) const
50 {
51  int ch = (moduleID - 1) * N_CHANNELS + channelID;
52  int bit = ch % 32;
53  unsigned int idx = ch / 32;
54  if (m_DetectorMask[idx] & (1 << bit)) return true;
55  return false;
56 }
57 
58 void ARICHChannelMask::print() const
59 {
60 
61  cout << endl << "ARICH masked channels" << endl << endl;
62  for (int i = 0; i < N_HAPDS; i++) {
63  int first = 1;
64  //cout << "Module "<< i+1 << ": " ;
65  for (int j = 0; j < N_CHANNELS; j++) {
66  if (!isActive(i + 1, j)) {
67  if (first) cout << "Module " << i + 1 << ": " ;
68  cout << j << " ";
69  first = 0;
70  }
71  }
72  if (!first) cout << endl << endl;
73 
74  }
75 }
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19