Belle II Software  release-06-02-00
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 
15 using namespace std;
16 
17 namespace Belle2 {
23  TOPGeoModule::TOPGeoModule(const TOPGeoModule& module): TOPGeoBase(module.getName())
24  {
25  *this = module;
26  m_rotation = 0;
28  m_translation = 0;
32  }
33 
35  {
36  if (this != &module) {
37  TOPGeoBase::operator=(module);
38  m_moduleID = module.getModuleID();
39  m_radius = module.getRadius();
40  m_phi = module.getPhi();
41  m_backwardZ = module.getBackwardZ();
42  m_moduleCNumber = module.getModuleCNumber();
43  m_bar1 = module.getBarSegment1();
44  m_bar2 = module.getBarSegment2();
45  m_mirror = module.getMirrorSegment();
46  m_prism = module.getPrism();
47  m_pmtArray = module.getPMTArray();
48  m_arrayDisplacement = module.getPMTArrayDisplacement();
49  m_moduleDisplacement = module.getModuleDisplacement();
50  if (m_rotation) delete m_rotation;
52  if (m_translation) delete m_translation;
56  m_rotation = 0;
58  m_translation = 0;
62  }
63  return *this;
64  }
65 
67  {
68  if (m_rotation) delete m_rotation;
70  if (m_translation) delete m_translation;
74  }
75 
77  {
78  TRotation Rphi;
79  Rphi.RotateZ(m_phi - M_PI / 2);
80  TVector3 translation(0, m_radius, getZc() * s_unit);
81  m_rotationNominal = new TRotation(Rphi);
82  m_rotationNominalInverse = new TRotation(Rphi.Inverse());
83  m_translationNominal = new TVector3(Rphi * translation);
84 
85  TRotation Rot = Rphi * m_moduleDisplacement.getRotation();
86  translation += m_moduleDisplacement.getTranslation();
87  m_rotation = new TRotation(Rot);
88  m_rotationInverse = new TRotation(Rot.Inverse());
89  m_translation = new TVector3(Rphi * translation);
90  }
91 
92 
93  void TOPGeoModule::setBrokenGlue(int glueID, double fraction, double angle,
94  const std::string& material)
95  {
96  switch (glueID) {
97  case 1:
98  m_mirror.setGlueDelamination(fraction, angle, material);
99  break;
100  case 2:
101  m_bar1.setGlueDelamination(fraction, angle, material);
102  break;
103  case 3:
104  m_bar2.setGlueDelamination(fraction, angle, material);
105  break;
106  default:
107  B2ERROR("TOPGeoModule::setBrokenGlue: invalid glue ID."
108  << LogVar("glue ID", glueID));
109  }
110  }
111 
112 
113  void TOPGeoModule::setPeelOffRegions(double thickness, const std::string& material)
114  {
115  double size = 2 * m_pmtArray.getDx();
116  double offset = (m_pmtArray.getX(1) + m_pmtArray.getX(2)) / 2 +
118  m_prism.setPeelOffRegions(size, offset, thickness, material);
119  }
120 
121 
122  TVector3 TOPGeoModule::pointToGlobal(const TVector3& point) const
123  {
125  return (*m_rotation) * point + (*m_translation);
126  }
127 
128  TVector3 TOPGeoModule::momentumToGlobal(const TVector3& momentum) const
129  {
131  return (*m_rotation) * momentum;
132  }
133 
134  TVector3 TOPGeoModule::pointToLocal(const TVector3& point) const
135  {
137  return (*m_rotationInverse) * (point - (*m_translation));
138  }
139 
140  TVector3 TOPGeoModule::momentumToLocal(const TVector3& momentum) const
141  {
143  return (*m_rotationInverse) * momentum;
144  }
145 
146  TVector3 TOPGeoModule::pointNominalToGlobal(const TVector3& point) const
147  {
149  return (*m_rotationNominal) * point + (*m_translationNominal);
150  }
151 
152  TVector3 TOPGeoModule::momentumNominalToGlobal(const TVector3& momentum) const
153  {
155  return (*m_rotationNominal) * momentum;
156  }
157 
158  TVector3 TOPGeoModule::pointGlobalToNominal(const TVector3& point) const
159  {
161  return (*m_rotationNominalInverse) * (point - (*m_translationNominal));
162  }
163 
164  TVector3 TOPGeoModule::momentumGlobalToNominal(const TVector3& momentum) const
165  {
167  return (*m_rotationNominalInverse) * momentum;
168  }
169 
171  {
172  if (m_moduleID <= 0) return false;
173  if (!m_bar1.isConsistent()) return false;
174  if (!m_bar2.isConsistent()) return false;
175  if (!m_mirror.isConsistent()) return false;
176  if (!m_prism.isConsistent()) return false;
177  if (!m_pmtArray.isConsistent()) return false;
178  return true;
179  }
180 
181 
182  void TOPGeoModule::print(const std::string&) const
183  {
184  cout << "Slot " << getModuleID() << " geometry parameters:" << endl;
185  cout << "---------------------------" << endl;
186  cout << " name: " << m_name << endl;
187  cout << " moduleID = " << getModuleID();
188  cout << ", radius = " << getRadius() << " " << s_unitName;
189  cout << ", phi = " << getPhi() / Unit::deg << " deg";
190  cout << ", backward z = " << getBackwardZ() << " " << s_unitName;
191  cout << ", construction number = " << getModuleCNumber() << endl;
192  cout << endl;
193 
194  m_prism.print();
195  cout << endl;
196  m_bar2.print("Bar segment 2 (backward) geometry parameters");
197  cout << endl;
198  m_bar1.print("Bar segment 1 (forward) geometry parameters");
199  cout << endl;
200  m_mirror.print();
201  cout << endl;
202  m_pmtArray.print();
203  cout << endl;
205  cout << endl;
207  cout << endl;
208 
209  }
210 
212 } // 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
TRotation getRotation() const
Returns rotation matrix.
TVector3 getTranslation() const
Returns translation vector (always in basf2 units!)
Geometry parameters of a module (optical components + positioning)
Definition: TOPGeoModule.h:30
TVector3 * m_translationNominal
do not write out
Definition: TOPGeoModule.h:412
unsigned getModuleCNumber() const
Returns module construction number (0 = ideal module)
Definition: TOPGeoModule.h:193
TOPGeoPMTArrayDisplacement m_arrayDisplacement
PMT array displacement.
Definition: TOPGeoModule.h:397
float m_backwardZ
z position of prism-bar joint in Belle II frame
Definition: TOPGeoModule.h:389
double getPhi() const
Returns module azimuthal angle in Belle II frame.
Definition: TOPGeoModule.h:181
float m_phi
azimuthal angle in Belle II frame
Definition: TOPGeoModule.h:388
TRotation * m_rotation
cache for rotation matrix from internal (= nominal & displaced) to Belle II frame
Definition: TOPGeoModule.h:401
double getZc() const
Returns z of bar center (w/o prism) in Belle II frame.
Definition: TOPGeoModule.h:302
float m_radius
radius of bar central plane in Belle II frame
Definition: TOPGeoModule.h:387
int m_moduleID
module ID
Definition: TOPGeoModule.h:386
int getModuleID() const
Returns module ID.
Definition: TOPGeoModule.h:169
TVector3 * m_translation
do not write out
Definition: TOPGeoModule.h:405
TOPGeoPMTArray m_pmtArray
geometry parameters of PMT array
Definition: TOPGeoModule.h:396
TOPGeoMirrorSegment m_mirror
mirror segment
Definition: TOPGeoModule.h:394
TOPGeoPrism m_prism
prism
Definition: TOPGeoModule.h:395
double getRadius() const
Returns radius of the bar central plane in Belle II frame.
Definition: TOPGeoModule.h:175
TOPGeoBarSegment m_bar2
bar segment 2 (backward bar)
Definition: TOPGeoModule.h:393
TOPGeoModuleDisplacement m_moduleDisplacement
module displacement
Definition: TOPGeoModule.h:398
TRotation * m_rotationNominalInverse
do not write out
Definition: TOPGeoModule.h:410
unsigned m_moduleCNumber
module construction number, 0 = ideal module
Definition: TOPGeoModule.h:391
TRotation * m_rotationInverse
do not write out
Definition: TOPGeoModule.h:403
double getBackwardZ() const
Returns the z position of prism-bar joint in Belle II frame.
Definition: TOPGeoModule.h:187
TRotation * m_rotationNominal
do not write out
Definition: TOPGeoModule.h:408
TOPGeoBarSegment m_bar1
bar segment 1 (forward bar)
Definition: TOPGeoModule.h:392
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:104
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.
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.
TVector3 pointToGlobal(const TVector3 &point) const
Transforms 3D point from module internal (= nominal & displaced) frame to Belle II frame.
TVector3 momentumGlobalToNominal(const TVector3 &momentum) const
Transforms momentum vector from Belle II to module nominal frame.
~TOPGeoModule()
Destructor.
Definition: TOPGeoModule.cc:66
TVector3 pointGlobalToNominal(const TVector3 &point) const
Transforms 3D point from Belle II to module nominal frame.
void setTransformation() const
Sets transformation cache.
Definition: TOPGeoModule.cc:76
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.
TVector3 pointNominalToGlobal(const TVector3 &point) const
Transforms 3D point from module nominal frame to Belle II frame.
TVector3 momentumToGlobal(const TVector3 &momentum) const
Transforms momentum vector from module internal (= nominal & displaced) frame to Belle II frame.
void setPeelOffRegions(double thickness, const std::string &material)
Sets parameters of the peel-off cookie volumes.
void print(const std::string &title="PMT array displacement parameters") const override
Print the content of the class.
TVector3 pointToLocal(const TVector3 &point) const
Transforms 3D point from Belle II to module internal (= nominal & displaced) frame.
TVector3 momentumToLocal(const TVector3 &momentum) const
Transforms momentum vector from Belle II to module internal (= nominal & displaced) frame.
TVector3 momentumNominalToGlobal(const TVector3 &momentum) const
Transforms momentum vector from module nominal frame to Belle II frame.
void print(const std::string &title="Prism geometry parameters") const override
Print the content of the class.
Definition: TOPGeoPrism.cc:59
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:93
TOPGeoModule & operator=(const TOPGeoModule &module)
Assignment operator.
Definition: TOPGeoModule.cc:34
Abstract base class for different kinds of events.