Belle II Software development
TOPGeoModule.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/TOPGeoModule.h>
10#include <framework/gearbox/Unit.h>
11#include <framework/logging/Logger.h>
12#include <math.h>
13#include <iostream>
14#include <Math/RotationZ.h>
15
16
17using namespace std;
18using namespace ROOT::Math;
19
20namespace Belle2 {
26 TOPGeoModule::TOPGeoModule(const TOPGeoModule& module): TOPGeoBase(module.getName())
27 {
28 *this = module;
29 m_transform = 0;
31 }
32
34 {
35 if (this != &module) {
36 TOPGeoBase::operator=(module);
37 m_moduleID = module.getModuleID();
38 m_radius = module.getRadius();
39 m_phi = module.getPhi();
40 m_backwardZ = module.getBackwardZ();
41 m_moduleCNumber = module.getModuleCNumber();
42 m_bar1 = module.getBarSegment1();
43 m_bar2 = module.getBarSegment2();
44 m_mirror = module.getMirrorSegment();
45 m_prism = module.getPrism();
46 m_pmtArray = module.getPMTArray();
47 m_arrayDisplacement = module.getPMTArrayDisplacement();
48 m_moduleDisplacement = module.getModuleDisplacement();
49
50 if (m_transform) delete m_transform;
52 m_transform = 0;
54 }
55 return *this;
56 }
57
59 {
60 if (m_transform) delete m_transform;
62 }
63
65 {
66 RotationZ Rz(m_phi - M_PI / 2);
67 m_transformNominal = new Transform3D(Rz, Rz * XYZVector(0, m_radius, getZc() * s_unit));
69 }
70
71
72 void TOPGeoModule::setBrokenGlue(int glueID, double fraction, double angle,
73 const std::string& material)
74 {
75 switch (glueID) {
76 case 1:
77 m_mirror.setGlueDelamination(fraction, angle, material);
78 break;
79 case 2:
80 m_bar1.setGlueDelamination(fraction, angle, material);
81 break;
82 case 3:
83 m_bar2.setGlueDelamination(fraction, angle, material);
84 break;
85 default:
86 B2ERROR("TOPGeoModule::setBrokenGlue: invalid glue ID."
87 << LogVar("glue ID", glueID));
88 }
89 }
90
91
92 void TOPGeoModule::setPeelOffRegions(double thickness, const std::string& material)
93 {
94 double size = 2 * m_pmtArray.getDx();
95 double offset = (m_pmtArray.getX(1) + m_pmtArray.getX(2)) / 2 +
97 m_prism.setPeelOffRegions(size, offset, thickness, material);
98 }
99
100
101 XYZPoint TOPGeoModule::pointToGlobal(const XYZPoint& point) const
102 {
104 return *m_transform * point;
105 }
106
107 XYZVector TOPGeoModule::momentumToGlobal(const XYZVector& momentum) const
108 {
110 return *m_transform * momentum;
111 }
112
113 XYZPoint TOPGeoModule::pointToLocal(const XYZPoint& point) const
114 {
116 return m_transform->ApplyInverse(point);
117 }
118
119 XYZVector TOPGeoModule::momentumToLocal(const XYZVector& momentum) const
120 {
122 return m_transform->ApplyInverse(momentum);
123 }
124
125 XYZPoint TOPGeoModule::pointNominalToGlobal(const XYZPoint& point) const
126 {
128 return *m_transformNominal * point;
129 }
130
131 XYZVector TOPGeoModule::momentumNominalToGlobal(const XYZVector& momentum) const
132 {
134 return *m_transformNominal * momentum;
135 }
136
137 XYZPoint TOPGeoModule::pointGlobalToNominal(const XYZPoint& point) const
138 {
140 return m_transformNominal->ApplyInverse(point);
141 }
142
143 XYZVector TOPGeoModule::momentumGlobalToNominal(const XYZVector& momentum) const
144 {
146 return m_transformNominal->ApplyInverse(momentum);
147 }
148
149
151 {
152 if (m_moduleID <= 0) return false;
153 if (!m_bar1.isConsistent()) return false;
154 if (!m_bar2.isConsistent()) return false;
155 if (!m_mirror.isConsistent()) return false;
156 if (!m_prism.isConsistent()) return false;
157 if (!m_pmtArray.isConsistent()) return false;
158 return true;
159 }
160
161
162 void TOPGeoModule::print(const std::string&) const
163 {
164 cout << "Slot " << getModuleID() << " geometry parameters:" << endl;
165 cout << "---------------------------" << endl;
166 cout << " name: " << m_name << endl;
167 cout << " moduleID = " << getModuleID();
168 cout << ", radius = " << getRadius() << " " << s_unitName;
169 cout << ", phi = " << getPhi() / Unit::deg << " deg";
170 cout << ", backward z = " << getBackwardZ() << " " << s_unitName;
171 cout << ", construction number = " << getModuleCNumber() << endl;
172 cout << endl;
173
174 m_prism.print();
175 cout << endl;
176 m_bar2.print("Bar segment 2 (backward) geometry parameters");
177 cout << endl;
178 m_bar1.print("Bar segment 1 (forward) geometry parameters");
179 cout << endl;
180 m_mirror.print();
181 cout << endl;
183 cout << endl;
185 cout << endl;
187 cout << endl;
188
189 }
190
192} // end Belle2 namespace
virtual void setGlueDelamination(double fraction, double angle, const std::string &material)
Sets glue to be broken (delaminated)
Base class for geometry parameters.
Definition: TOPGeoBase.h:25
std::string m_name
geometry object name
Definition: TOPGeoBase.h:89
Geometry parameters of a module (optical components + positioning)
Definition: TOPGeoModule.h:31
ROOT::Math::Transform3D * m_transformNominal
do not write out
Definition: TOPGeoModule.h:435
unsigned getModuleCNumber() const
Returns module construction number (0 = ideal module)
Definition: TOPGeoModule.h:194
TOPGeoPMTArrayDisplacement m_arrayDisplacement
PMT array displacement.
Definition: TOPGeoModule.h:429
float m_backwardZ
z position of prism-bar joint in Belle II frame
Definition: TOPGeoModule.h:421
double getPhi() const
Returns module azimuthal angle in Belle II frame.
Definition: TOPGeoModule.h:182
float m_phi
azimuthal angle in Belle II frame
Definition: TOPGeoModule.h:420
double getZc() const
Returns z of bar center (w/o prism) in Belle II frame.
Definition: TOPGeoModule.h:314
float m_radius
radius of bar central plane in Belle II frame
Definition: TOPGeoModule.h:419
ROOT::Math::Transform3D * m_transform
cache for transformation from internal (= nominal & displaced) to Belle II frame
Definition: TOPGeoModule.h:433
int m_moduleID
module ID
Definition: TOPGeoModule.h:418
int getModuleID() const
Returns module ID.
Definition: TOPGeoModule.h:170
TOPGeoPMTArray m_pmtArray
geometry parameters of PMT array
Definition: TOPGeoModule.h:428
TOPGeoMirrorSegment m_mirror
mirror segment
Definition: TOPGeoModule.h:426
TOPGeoPrism m_prism
prism
Definition: TOPGeoModule.h:427
double getRadius() const
Returns radius of the bar central plane in Belle II frame.
Definition: TOPGeoModule.h:176
TOPGeoBarSegment m_bar2
bar segment 2 (backward bar)
Definition: TOPGeoModule.h:425
TOPGeoModuleDisplacement m_moduleDisplacement
module displacement
Definition: TOPGeoModule.h:430
TOPGeoModule()
Default constructor.
Definition: TOPGeoModule.h:37
unsigned m_moduleCNumber
module construction number, 0 = ideal module
Definition: TOPGeoModule.h:423
double getBackwardZ() const
Returns the z position of prism-bar joint in Belle II frame.
Definition: TOPGeoModule.h:188
TOPGeoBarSegment m_bar1
bar segment 1 (forward bar)
Definition: TOPGeoModule.h:424
double getX() const
Returns translation in x.
double getX(unsigned col) const
Returns x coordinate of column center.
double getDx() const
Returns spacing in x (column width)
void setPeelOffRegions(double size, double offset, double thickness, const std::string &material)
Sets parameters of the peel-off cookie volumes.
Definition: TOPGeoPrism.h:105
static const double deg
degree to radians
Definition: Unit.h:109
Class to store variables with their name which were sent to the logging service.
ROOT::Math::XYZPoint pointToLocal(const ROOT::Math::XYZPoint &point) const
Transforms 3D point from Belle II to module internal (= nominal & displaced) frame.
bool isConsistent() const override
Check for consistency of data members.
void print(const std::string &title="Module geometry parameters") const override
Print the content of the class.
static double s_unit
conversion unit for length
Definition: TOPGeoBase.h:86
virtual void print(const std::string &title="Bar segment geometry parameters") const override
Print the content of the class.
ROOT::Math::XYZPoint pointGlobalToNominal(const ROOT::Math::XYZPoint &point) const
Transforms 3D point from Belle II to module nominal frame.
~TOPGeoModule()
Destructor.
Definition: TOPGeoModule.cc:58
ROOT::Math::XYZPoint pointNominalToGlobal(const ROOT::Math::XYZPoint &point) const
Transforms 3D point from module nominal frame to Belle II frame.
ROOT::Math::Transform3D getTransformation() const
Returns transformation from local to nominal frame.
void setTransformation() const
Sets transformation cache.
Definition: TOPGeoModule.cc:64
void print(const std::string &title="PMT array geometry parameters") const override
Print the content of the class.
void print(const std::string &title="Module displacement parameters") const override
Print the content of the class.
void setPeelOffRegions(double thickness, const std::string &material)
Sets parameters of the peel-off cookie volumes.
Definition: TOPGeoModule.cc:92
ROOT::Math::XYZPoint pointToGlobal(const ROOT::Math::XYZPoint &point) const
Transforms 3D point from module internal (= nominal & displaced) frame to Belle II frame.
void print(const std::string &title="PMT array displacement parameters") const override
Print the content of the class.
ROOT::Math::XYZVector momentumGlobalToNominal(const ROOT::Math::XYZVector &momentum) const
Transforms momentum vector from Belle II to module nominal frame.
ROOT::Math::XYZVector momentumToLocal(const ROOT::Math::XYZVector &momentum) const
Transforms momentum vector from Belle II to module internal (= nominal & displaced) frame.
void print(const std::string &title="Prism geometry parameters") const override
Print the content of the class.
Definition: TOPGeoPrism.cc:60
static std::string s_unitName
conversion unit name
Definition: TOPGeoBase.h:87
void print(const std::string &title="Mirror segment geometry parameters") const override
Print the content of the class.
void setBrokenGlue(int glueID, double fraction, double angle, const std::string &material)
Sets glue to be broken (delaminated)
Definition: TOPGeoModule.cc:72
ROOT::Math::XYZVector momentumNominalToGlobal(const ROOT::Math::XYZVector &momentum) const
Transforms momentum vector from module nominal frame to Belle II frame.
TOPGeoModule & operator=(const TOPGeoModule &module)
Assignment operator.
Definition: TOPGeoModule.cc:33
ROOT::Math::XYZVector momentumToGlobal(const ROOT::Math::XYZVector &momentum) const
Transforms momentum vector from module internal (= nominal & displaced) frame to Belle II frame.
Abstract base class for different kinds of events.
STL namespace.