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