Belle II Software  release-08-02-06
TOPGeometry.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 <top/dbobjects/TOPGeometry.h>
10 #include <framework/logging/Logger.h>
11 #include <math.h>
12 #include <iostream>
13 
14 using namespace std;
15 
16 namespace Belle2 {
22  void TOPGeometry::appendModule(const TOPGeoModule& module)
23  {
24  if (isModuleIDValid(module.getModuleID())) {
25  B2ERROR("TOPGeometry::appendModule: module already appended."
26  << LogVar("ID", module.getModuleID()));
27  return;
28  }
29  m_modules.push_back(module);
30  }
31 
32 
33  bool TOPGeometry::isModuleIDValid(int moduleID) const
34  {
35  for (const auto& module : m_modules) {
36  if (module.getModuleID() == moduleID) return true;
37  }
38  return false;
39  }
40 
41 
42  const TOPGeoModule& TOPGeometry::getModule(int moduleID) const
43  {
44  for (const auto& module : m_modules) {
45  if (module.getModuleID() == moduleID) return module;
46  }
47  B2FATAL("TOPGeometry::getModule: invalid module, ID = " << moduleID);
48  }
49 
50  const TOPNominalTTS& TOPGeometry::getTTS(unsigned type) const
51  {
52  std::map<unsigned, TOPNominalTTS>::const_iterator it = m_tts.find(type);
53  if (it == m_tts.end()) return m_nominalTTS;
54  return it->second;
55  }
56 
57  double TOPGeometry::getPDETuningFactor(unsigned type) const
58  {
59  std::map<unsigned, float>::const_iterator it = m_tuneFactorsPDE.find(type);
60  if (it == m_tuneFactorsPDE.end()) return 1.0;
61  return it->second;
62  }
63 
64  double TOPGeometry::getInnerRadius() const
65  {
66  if (m_modules.empty()) return 0;
67 
68  double R = m_modules[0].getRadius();
69  for (auto& module : m_modules) {
70  double tmp = module.getRadius() + module.getBarThickness() / 2
71  - module.getPrism().getExitThickness();
72  if (tmp < R) R = tmp;
73  }
74  return R;
75  }
76 
77  double TOPGeometry::getOuterRadius() const
78  {
79  if (m_modules.empty()) return 0;
80 
81  double R = m_modules[0].getRadius();
82  for (auto& module : m_modules) {
83  double x = module.getBarWidth() / 2;
84  double y = module.getRadius() + module.getBarThickness() / 2;
85  double tmp = sqrt(x * x + y * y);
86  if (tmp > R) R = tmp;
87  }
88  return R;
89  }
90 
91  double TOPGeometry::getRadius() const
92  {
93  if (m_modules.empty()) return 0;
94 
95  double R = 0;
96  for (auto& module : m_modules) {
97  R += module.getRadius();
98  }
99  return R / m_modules.size();
100  }
101 
102  double TOPGeometry::getBackwardZ() const
103  {
104  if (m_modules.empty()) return 0;
105 
106  double z = m_modules[0].getBackwardZ();
107  for (auto& module : m_modules) {
108  double tmp = module.getBackwardZ() - module.getPrism().getFullLength();
109  if (tmp < z) z = tmp;
110  }
111  return z;
112  }
113 
114  double TOPGeometry::getForwardZ() const
115  {
116  if (m_modules.empty()) return 0;
117 
118  double z = m_modules[0].getForwardZ();
119  for (auto& module : m_modules) {
120  double tmp = module.getForwardZ();
121  if (tmp > z) z = tmp;
122  }
123  return z;
124  }
125 
126  bool TOPGeometry::isConsistent() const
127  {
128  if (m_modules.empty()) return false;
129  for (const auto& module : m_modules) {
130  if (!module.isConsistent()) return false;
131  }
132  if (!m_frontEnd.isConsistent()) return false;
133  if (!m_QBB.isConsistent()) return false;
134  if (m_numBoardStacks == 0) return false;
135  if (!m_nominalQE.isConsistent()) return false;
136  if (!m_nominalTTS.isConsistent()) return false;
137  if (!m_nominalTDC.isConsistent()) return false;
138  if (!m_wavelengthFilter.isConsistent()) return false;
139  return true;
140  }
141 
142  void TOPGeometry::print(const std::string&) const
143  {
144  cout << endl;
145  cout << "Geometry parameters of TOP counter:" << endl;
146  cout << "===================================" << endl;
147  cout << " name: " << m_name << endl;
148  cout << " number of modules: " << m_modules.size() << endl << endl;
149 
150  for (const auto& module : m_modules) {
151  module.print();
152  cout << endl;
153  }
154  m_frontEnd.print();
155  cout << " Number of board stacks: " << m_numBoardStacks << endl;
156  cout << endl;
157  m_QBB.print();
158  cout << endl;
159  m_nominalQE.print();
160  cout << endl;
161  cout << "Photo-detection efficiency tuning factors" << endl;
162  cout << "-----------------------------------------" << endl;
163  if (m_tuneFactorsPDE.empty()) {
164  cout << " Not available" << endl;
165  } else {
166  for (const auto& x : m_tuneFactorsPDE) {
167  cout << " PMT type: " << x.first << " factor = " << x.second << endl;
168  }
169  }
170  cout << endl;
171  m_nominalTTS.print();
172  cout << endl;
173  for (const auto& tts : m_tts) {
174  tts.second.print("TTS distribution");
175  cout << endl;
176  }
177  m_nominalTDC.print();
178  cout << endl;
179  m_wavelengthFilter.print();
180  cout << endl;
181 
182  }
183 
185 } // end Belle2 namespace
double R
typedef autogenerated by FFTW
Geometry parameters of a module (optical components + positioning)
Definition: TOPGeoModule.h:31
Nominal time transition spread of PMT.
Definition: TOPNominalTTS.h:23
Class to store variables with their name which were sent to the logging service.
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
Abstract base class for different kinds of events.