Belle II Software  release-05-02-19
TOPGeoModule.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/TOPGeoModule.h>
12 #include <framework/gearbox/Unit.h>
13 #include <framework/logging/Logger.h>
14 #include <math.h>
15 #include <iostream>
16 
17 using namespace std;
18 
19 namespace Belle2 {
25  void TOPGeoModule::setBrokenGlue(int glueID, double fraction, double angle,
26  const std::string& material)
27  {
28  switch (glueID) {
29  case 1:
30  m_mirror.setGlueDelamination(fraction, angle, material);
31  break;
32  case 2:
33  m_bar1.setGlueDelamination(fraction, angle, material);
34  break;
35  case 3:
36  m_bar2.setGlueDelamination(fraction, angle, material);
37  break;
38  default:
39  B2ERROR("TOPGeoModule::setBrokenGlue: invalid glue ID."
40  << LogVar("glue ID", glueID));
41  }
42  }
43 
44 
45  void TOPGeoModule::setPeelOffRegions(double thickness, const std::string& material)
46  {
47  double size = 2 * m_pmtArray.getDx();
48  double offset = (m_pmtArray.getX(1) + m_pmtArray.getX(2)) / 2 +
49  m_arrayDisplacement.getX();
50  m_prism.setPeelOffRegions(size, offset, thickness, material);
51  }
52 
53 
54  TVector3 TOPGeoModule::pointToGlobal(const TVector3& point) const
55  {
56  if (!m_rotation) setTransformation();
57  return (*m_rotation) * point + (*m_translation);
58  }
59 
60  TVector3 TOPGeoModule::momentumToGlobal(const TVector3& momentum) const
61  {
62  if (!m_rotation) setTransformation();
63  return (*m_rotation) * momentum;
64  }
65 
66  TVector3 TOPGeoModule::pointToLocal(const TVector3& point) const
67  {
68  if (!m_rotation) setTransformation();
69  return (*m_rotationInverse) * (point - (*m_translation));
70  }
71 
72  TVector3 TOPGeoModule::momentumToLocal(const TVector3& momentum) const
73  {
74  if (!m_rotation) setTransformation();
75  return (*m_rotationInverse) * momentum;
76  }
77 
78  void TOPGeoModule::setTransformation() const
79  {
80 
81  TRotation Rphi;
82  Rphi.RotateZ(m_phi - M_PI / 2);
83  TVector3 translation(0, m_radius, getZc() * s_unit);
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  bool TOPGeoModule::isConsistent() const
94  {
95  if (m_moduleID <= 0) return false;
96  if (!m_bar1.isConsistent()) return false;
97  if (!m_bar2.isConsistent()) return false;
98  if (!m_mirror.isConsistent()) return false;
99  if (!m_prism.isConsistent()) return false;
100  if (!m_pmtArray.isConsistent()) return false;
101  return true;
102  }
103 
104 
105  void TOPGeoModule::print(const std::string&) const
106  {
107  cout << "Slot " << getModuleID() << " geometry parameters:" << endl;
108  cout << "---------------------------" << endl;
109  cout << " name: " << m_name << endl;
110  cout << " moduleID = " << getModuleID();
111  cout << ", radius = " << getRadius() << " " << s_unitName;
112  cout << ", phi = " << getPhi() / Unit::deg << " deg";
113  cout << ", backward z = " << getBackwardZ() << " " << s_unitName;
114  cout << ", construction number = " << getModuleCNumber() << endl;
115  cout << endl;
116 
117  m_prism.print();
118  cout << endl;
119  m_bar2.print("Bar segment 2 (backward) geometry parameters");
120  cout << endl;
121  m_bar1.print("Bar segment 1 (forward) geometry parameters");
122  cout << endl;
123  m_mirror.print();
124  cout << endl;
125  m_pmtArray.print();
126  cout << endl;
127  m_arrayDisplacement.print();
128  cout << endl;
129  m_moduleDisplacement.print();
130  cout << endl;
131 
132  }
133 
135 } // end Belle2 namespace
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