9 #include <top/dbobjects/TOPCalModuleAlignment.h>
10 #include <framework/logging/Logger.h>
11 #include <Math/RotationX.h>
12 #include <Math/RotationY.h>
13 #include <Math/RotationZ.h>
14 #include <Math/Translation3D.h>
17 using namespace ROOT::Math;
25 void TOPCalModuleAlignment::setAlpha(
int moduleID,
double alpha,
double errAlpha)
27 unsigned module = moduleID - 1;
28 if (module >= c_numModules) {
29 B2ERROR(
"Invalid module number, constant not set (" << ClassName() <<
")");
32 m_alpha[module] = alpha;
33 m_errAlpha[module] = errAlpha;
37 void TOPCalModuleAlignment::setBeta(
int moduleID,
double beta,
double errBeta)
39 unsigned module = moduleID - 1;
40 if (module >= c_numModules) {
41 B2ERROR(
"Invalid module number, constant not set (" << ClassName() <<
")");
44 m_beta[module] = beta;
45 m_errBeta[module] = errBeta;
49 void TOPCalModuleAlignment::setGamma(
int moduleID,
double gamma,
double errGamma)
51 unsigned module = moduleID - 1;
52 if (module >= c_numModules) {
53 B2ERROR(
"Invalid module number, constant not set (" << ClassName() <<
")");
56 m_gamma[module] = gamma;
57 m_errGamma[module] = errGamma;
61 void TOPCalModuleAlignment::setX(
int moduleID,
double x,
double errX)
63 unsigned module = moduleID - 1;
64 if (module >= c_numModules) {
65 B2ERROR(
"Invalid module number, constant not set (" << ClassName() <<
")");
69 m_errX[module] = errX;
73 void TOPCalModuleAlignment::setY(
int moduleID,
double y,
double errY)
75 unsigned module = moduleID - 1;
76 if (module >= c_numModules) {
77 B2ERROR(
"Invalid module number, constant not set (" << ClassName() <<
")");
81 m_errY[module] = errY;
85 void TOPCalModuleAlignment::setZ(
int moduleID,
double z,
double errZ)
87 unsigned module = moduleID - 1;
88 if (module >= c_numModules) {
89 B2ERROR(
"Invalid module number, constant not set (" << ClassName() <<
")");
93 m_errZ[module] = errZ;
97 void TOPCalModuleAlignment::setCalibrated(
int moduleID)
99 unsigned module = moduleID - 1;
100 if (module >= c_numModules) {
101 B2ERROR(
"Invalid module number, status not set (" << ClassName() <<
")");
104 m_status[module] = c_Calibrated;
105 m_transforms.clear();
108 void TOPCalModuleAlignment::setUnusable(
int moduleID)
110 unsigned module = moduleID - 1;
111 if (module >= c_numModules) {
112 B2ERROR(
"Invalid module number, status not set (" << ClassName() <<
")");
115 m_status[module] = c_Unusable;
116 m_transforms.clear();
119 double TOPCalModuleAlignment::getAlpha(
int moduleID)
const
121 unsigned module = moduleID - 1;
122 if (module >= c_numModules) {
123 B2WARNING(
"Invalid module number, returning 0 (" << ClassName() <<
")");
126 return m_alpha[module];
129 double TOPCalModuleAlignment::getBeta(
int moduleID)
const
131 unsigned module = moduleID - 1;
132 if (module >= c_numModules) {
133 B2WARNING(
"Invalid module number, returning 0 (" << ClassName() <<
")");
136 return m_beta[module];
139 double TOPCalModuleAlignment::getGamma(
int moduleID)
const
141 unsigned module = moduleID - 1;
142 if (module >= c_numModules) {
143 B2WARNING(
"Invalid module number, returning 0 (" << ClassName() <<
")");
146 return m_gamma[module];
149 double TOPCalModuleAlignment::getX(
int moduleID)
const
151 unsigned module = moduleID - 1;
152 if (module >= c_numModules) {
153 B2WARNING(
"Invalid module number, returning 0 (" << ClassName() <<
")");
159 double TOPCalModuleAlignment::getY(
int moduleID)
const
161 unsigned module = moduleID - 1;
162 if (module >= c_numModules) {
163 B2WARNING(
"Invalid module number, returning 0 (" << ClassName() <<
")");
169 double TOPCalModuleAlignment::getZ(
int moduleID)
const
171 unsigned module = moduleID - 1;
172 if (module >= c_numModules) {
173 B2WARNING(
"Invalid module number, returning 0 (" << ClassName() <<
")");
179 double TOPCalModuleAlignment::getAlphaErr(
int moduleID)
const
181 unsigned module = moduleID - 1;
182 if (module >= c_numModules) {
183 B2WARNING(
"Invalid module number, returning 0 (" << ClassName() <<
")");
186 return m_errAlpha[module];
189 double TOPCalModuleAlignment::getBetaErr(
int moduleID)
const
191 unsigned module = moduleID - 1;
192 if (module >= c_numModules) {
193 B2WARNING(
"Invalid module number, returning 0 (" << ClassName() <<
")");
196 return m_errBeta[module];
199 double TOPCalModuleAlignment::getGammaErr(
int moduleID)
const
201 unsigned module = moduleID - 1;
202 if (module >= c_numModules) {
203 B2WARNING(
"Invalid module number, returning 0 (" << ClassName() <<
")");
206 return m_errGamma[module];
209 double TOPCalModuleAlignment::getXErr(
int moduleID)
const
211 unsigned module = moduleID - 1;
212 if (module >= c_numModules) {
213 B2WARNING(
"Invalid module number, returning 0 (" << ClassName() <<
")");
216 return m_errX[module];
219 double TOPCalModuleAlignment::getYErr(
int moduleID)
const
221 unsigned module = moduleID - 1;
222 if (module >= c_numModules) {
223 B2WARNING(
"Invalid module number, returning 0 (" << ClassName() <<
")");
226 return m_errY[module];
229 double TOPCalModuleAlignment::getZErr(
int moduleID)
const
231 unsigned module = moduleID - 1;
232 if (module >= c_numModules) {
233 B2WARNING(
"Invalid module number, returning 0 (" << ClassName() <<
")");
236 return m_errZ[module];
239 bool TOPCalModuleAlignment::isCalibrated(
int moduleID)
const
241 unsigned module = moduleID - 1;
242 if (module >= c_numModules)
return false ;
243 return m_status[module] == c_Calibrated;
246 bool TOPCalModuleAlignment::isDefault(
int moduleID)
const
248 unsigned module = moduleID - 1;
249 if (module >= c_numModules)
return false ;
250 return m_status[module] == c_Default;
253 bool TOPCalModuleAlignment::isUnusable(
int moduleID)
const
255 unsigned module = moduleID - 1;
256 if (module >= c_numModules)
return false ;
257 return m_status[module] == c_Unusable;
260 bool TOPCalModuleAlignment::areAllCalibrated()
const
262 for (
int i = 0; i < c_numModules; i++) {
263 if (m_status[i] != c_Calibrated)
return false;
268 bool TOPCalModuleAlignment::areAllPrecise(
double spatialPrecision,
269 double angularPrecision)
const
271 for (
int i = 0; i < c_numModules; i++) {
272 if (m_errAlpha[i] > angularPrecision)
return false;
273 if (m_errBeta[i] > angularPrecision)
return false;
274 if (m_errGamma[i] > angularPrecision)
return false;
275 if (m_errX[i] > spatialPrecision)
return false;
276 if (m_errY[i] > spatialPrecision)
return false;
277 if (m_errZ[i] > spatialPrecision)
return false;
282 void TOPCalModuleAlignment::setTransformations()
const
284 for (
int i = 0; i < c_numModules; i++) {
286 if (m_status[i] == c_Calibrated) {
287 RotationX Rx(m_alpha[i]);
288 RotationY Ry(m_beta[i]);
289 RotationZ Rz(m_gamma[i]);
290 Translation3D t(m_x[i], m_y[i], m_z[i]);
291 T = Transform3D(Rz * Ry * Rx, t);
293 m_transforms.push_back(T);
295 m_transforms.push_back(Transform3D());
298 const Transform3D& TOPCalModuleAlignment::getTransformation(
int moduleID)
const
300 if (m_transforms.empty()) setTransformations();
301 unsigned module = moduleID - 1;
302 if (module >= c_numModules) {
303 B2ERROR(
"Invalid module number, returning identity transformation (" << ClassName() <<
")");
304 return m_transforms[c_numModules];
306 return m_transforms[module];
Abstract base class for different kinds of events.