Belle II Software  release-05-01-25
ARICHModulesInfo.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/ARICHModulesInfo.h>
14 #include <iostream>
15 #include<iomanip>
16 
17 using namespace std;
18 using namespace Belle2;
19 
20 ARICHModulesInfo::ARICHModulesInfo()
21 {
22  m_ChannelQE.assign(N_HAPDS * N_CHANNELS, 0);
23  std::fill_n(m_installed, N_HAPDS, false);
24  std::fill_n(m_active, N_HAPDS, false);
25 }
26 
27 double ARICHModulesInfo::getChannelQE(unsigned moduleID, unsigned channelID) const
28 {
29  if (moduleID > N_HAPDS
30  || channelID > N_CHANNELS - 1) B2ERROR("ARICHModulesInfo::getChannelQE: module ID or channel ID out of range");
31 
32  int id = (moduleID - 1) * N_CHANNELS + channelID;
33  return (double)m_ChannelQE[id] / 100.0;
34 }
35 
36 void ARICHModulesInfo::setChannelQE(unsigned modId, unsigned chId, double qe)
37 {
38  if (modId > N_HAPDS || chId > N_CHANNELS - 1) B2ERROR("ARICHModulesInfo::setChannelQE: module ID or channel ID out of range");
39 
40  int chid = (modId - 1) * N_CHANNELS + chId;
41  m_ChannelQE[chid] = uint8_t(qe * 100 + 0.5);
42 }
43 
44 void ARICHModulesInfo::addModule(unsigned modId, std::vector<float>& qeList, bool active)
45 {
46 
47  if (modId > N_HAPDS) B2ERROR("ARICHModulesInfo::addModule: module ID is out of range");
48  if (qeList.size() != N_CHANNELS) B2ERROR("ARICHModulesInfo::addModule: incomplete list of channels QEs");
49 
50  m_installed[modId - 1] = true;
51  m_active[modId - 1] = active;
52 
53  std::vector<uint8_t>::iterator it = m_ChannelQE.begin() + (modId - 1) * N_CHANNELS;
54  for (auto qe : qeList) {
55  *it = uint8_t(qe + 0.5);
56  ++it;
57  }
58 }
59 
60 bool ARICHModulesInfo::isInstalled(unsigned modId) const
61 {
62  if (modId > N_HAPDS) B2ERROR("ARICHModulesInfo::isInstalled: module ID is out of range");
63 
64  return m_installed[modId - 1];
65 }
66 
67 bool ARICHModulesInfo::isActive(unsigned modId) const
68 {
69  if (modId > N_HAPDS) B2ERROR("ARICHModulesInfo::isActive: module ID is out of range");
70 
71  return m_active[modId - 1];
72 }
73 
74 void ARICHModulesInfo::print() const
75 {
76  cout << "ARICHModulesInfo: " << endl;
77  cout << " Modules status " << endl;
78  cout << " ID / installed / active / avg. QE" << endl;
79  double maxQE = 0;
80  for (int i = 1; i < N_HAPDS + 1; i++) {
81  cout << right << setfill(' ') << setw(4) << i << ": ";
82  if (isInstalled(i)) cout << 1;
83  else cout << 0;
84  cout << " ";
85  if (isActive(i)) cout << 1;
86  else cout << 0;
87  double avgQE = 0;
88  for (int j = 0; j < N_CHANNELS; j++) {
89  double chQE = getChannelQE(i, j);
90  avgQE += chQE;
91  if (chQE > maxQE) maxQE = chQE;
92  }
93  avgQE /= double(N_CHANNELS);
94  cout << " " << left << setfill('0') << setw(4) << setprecision(2) << avgQE << " ";
95  if ((i) % 10 == 0) cout << endl;
96  }
97  cout << " Maximal channel QE: " << maxQE << endl;
98 }
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19