Belle II Software development
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
14using namespace std;
15
16namespace Belle2 {
21
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
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
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
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
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
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
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
std::string m_name
geometry object name
Definition TOPGeoBase.h:89
Geometry parameters of a module (optical components + positioning)
std::map< unsigned, float > m_tuneFactorsPDE
PDE tuning factors of PMT types.
TOPGeoFrontEnd m_frontEnd
geometry parameters of front-end electronics
TOPGeoQBB m_QBB
geometry parameters of quartz bar box
TOPNominalQE m_nominalQE
nominal quantum efficiency of PMT
TOPNominalTTS m_nominalTTS
nominal time transition spread of PMT
unsigned m_numBoardStacks
number of boardstacks per module
TOPNominalTDC m_nominalTDC
nominal time-to-digit conversion parameters
TOPWavelengthFilter m_wavelengthFilter
transmittance of wavelength filter
std::vector< TOPGeoModule > m_modules
geometry parameters of modules
std::map< unsigned, TOPNominalTTS > m_tts
TTS of PMT types.
Nominal time transition spread of PMT.
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
bool isConsistent() const override
Check for consistency of data members.
void appendModule(const TOPGeoModule &module)
Appends module (if its ID differs from already appended modules)
void print(const std::string &title="TOP geometry parameters") const override
Print the content of the class.
double getForwardZ() const
Returns forward z of the volume devoted to TOP counter.
bool isModuleIDValid(int moduleID) const
Checks if module exists in m_modules.
const TOPGeoModule & getModule(int moduleID) const
Returns module.
double getOuterRadius() const
Returns outer radius of the volume devoted to TOP counter.
double getInnerRadius() const
Returns inner radius of the volume devoted to TOP counter.
const TOPNominalTTS & getTTS(unsigned type) const
Returns time transition spread of a given PMT type.
double getRadius() const
Returns average radius of modules.
double getBackwardZ() const
Returns backward z of the volume devoted to TOP counter.
double getPDETuningFactor(unsigned type) const
Returns photon detection efficiency tuning factor of a given PMT type.
Abstract base class for different kinds of events.
STL namespace.