Project
Loading...
Searching...
No Matches
testGeometryMisAligner.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#define BOOST_TEST_MODULE Test MCHSimulation GeometryMisAligner
16#define BOOST_TEST_DYN_LINK
17
18#include <boost/test/unit_test.hpp>
19
24#include "TGeoManager.h"
26#include "MathUtils/Cartesian.h"
27#include "Math/GenVector/Cartesian3D.h"
28#include "boost/format.hpp"
29#include <boost/test/data/test_case.hpp>
30#include <iomanip>
31#include <iostream>
32#include <fmt/format.h>
33
34namespace but = boost::unit_test;
35namespace bdata = boost::unit_test::data;
36namespace btools = boost::test_tools;
37
38BOOST_TEST_DONT_PRINT_LOG_VALUE(o2::mch::geo::MisAligner)
39
40struct GEOMETRY {
42 {
43 if (!gGeoManager) {
46 }
47 };
48}; // namespace boost::test_toolsBOOST_TEST_DONT_PRINT_LOG_VALUE(o2::mch::geo::MisAligner)structGEOMETRY
49
50BOOST_FIXTURE_TEST_SUITE(geometrymisaligner, GEOMETRY)
51
52BOOST_AUTO_TEST_CASE(ZeroMisAlignHalfChambers, *but::tolerance(0.00001))
53{
54 BOOST_REQUIRE(gGeoManager != nullptr);
55
56 std::vector<o2::detectors::AlignParam> params;
57
58 // The misaligner
60
62
63 int nvols = params.size();
64 for (int i = 0; i < nvols; i++) {
65 BOOST_TEST(params[i].getX() == 0.0);
66 BOOST_TEST(params[i].getY() == 0.0);
67 BOOST_TEST(params[i].getZ() == 0.0);
68 BOOST_TEST(params[i].getPsi() == 0.0);
69 BOOST_TEST(params[i].getTheta() == 0.0);
70 BOOST_TEST(params[i].getPhi() == 0.0);
71 }
72}
73
74BOOST_AUTO_TEST_CASE(MisAlignHalfChambers, *but::tolerance(0.00001))
75{
76 BOOST_REQUIRE(gGeoManager != nullptr);
77
78 std::vector<o2::detectors::AlignParam> params;
79
80 // The misaligner
82
83 // To generate module mislaignment (not mandatory)
84 aGMA.setModuleCartMisAlig(0.1, 0.0, 0.2, 0.0, 0.3, 0.0);
85 aGMA.setModuleAngMisAlig(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
86
89 auto tB1000 = transformationB(1000);
91
93
95 auto t100 = transformation(100);
96 auto t1000 = transformation(1000);
98 tB100.LocalToMaster(o2::math_utils::Point3D<double>{0, 0, 0}, poB);
99 t100.LocalToMaster(o2::math_utils::Point3D<double>{0, 0, 0}, po);
100
101 BOOST_TEST(po.X() - poB.X() == 0.1);
102 BOOST_TEST(po.Y() - poB.Y() == 0.2);
103 BOOST_TEST(po.Z() - poB.Z() == 0.3);
104
105 tB1000.LocalToMaster(o2::math_utils::Point3D<double>{0, 0, 0}, poB);
106 t1000.LocalToMaster(o2::math_utils::Point3D<double>{0, 0, 0}, po);
107 BOOST_TEST(po.X() - poB.X() == 0.1);
108 BOOST_TEST(po.Y() - poB.Y() == 0.2 * std::cos(o2::constants::math::Deg2Rad * -0.794) - 0.3 * std::sin(o2::constants::math::Deg2Rad * -0.794));
109 BOOST_TEST(po.Z() - poB.Z() == 0.2 * std::sin(o2::constants::math::Deg2Rad * -0.794) + 0.3 * std::cos(o2::constants::math::Deg2Rad * -0.794));
110
111 int nvols = params.size();
112 for (int i = 0; i < nvols; i++) {
113 if (params[i].getSymName().find("DE") != std::string::npos) {
114 BOOST_TEST(params[i].getX() == 0.0);
115 BOOST_TEST(params[i].getY() == 0.0);
116 BOOST_TEST(params[i].getZ() == 0.0);
117 BOOST_TEST(params[i].getPsi() == 0.0);
118 BOOST_TEST(params[i].getTheta() == 0.0);
119 BOOST_TEST(params[i].getPhi() == 0.0);
120 }
121 }
122}
123
124BOOST_AUTO_TEST_CASE(MisAlignDetectionElements, *but::tolerance(0.00001))
125{
126 BOOST_REQUIRE(gGeoManager != nullptr);
127
128 std::vector<o2::detectors::AlignParam> params;
129
130 // The misaligner
132
133 // To generate detection element misalignment
134 aGMA.setCartMisAlig(0.01, 0.0, 0.02, 0.0, 0.03, 0.0);
135 aGMA.setAngMisAlig(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
136
138
139 int nvols = params.size();
140 for (int i = 0; i < nvols; i++) {
141 std::cout << params[i].getSymName() << std::endl;
142 if (params[i].getSymName() == fmt::format("MCH/HC{}/DE{}", 0, 100)) {
143 BOOST_TEST(params[i].getX() == 0.01);
144 BOOST_TEST(params[i].getY() == 0.02);
145 BOOST_TEST(params[i].getZ() == 0.03);
146 BOOST_TEST(params[i].getPsi() == 0.0);
147 BOOST_TEST(params[i].getTheta() == 0.0);
148 BOOST_TEST(params[i].getPhi() == 0.0);
149 } else if (params[i].getSymName() == fmt::format("MCH/HC{}/DE{}", 0, 101)) {
150 BOOST_TEST(params[i].getX() == -0.01);
151 BOOST_TEST(params[i].getY() == 0.02);
152 BOOST_TEST(params[i].getZ() == -0.03);
153 BOOST_TEST(params[i].getPsi() == 0.0);
154 BOOST_TEST(params[i].getTheta() == 0.0);
155 BOOST_TEST(params[i].getPhi() == 0.0);
156 } else if (params[i].getSymName() == fmt::format("MCH/HC{}/DE{}", 0, 102)) {
157 BOOST_TEST(params[i].getX() == -0.01);
158 BOOST_TEST(params[i].getY() == -0.02);
159 BOOST_TEST(params[i].getZ() == 0.03);
160 BOOST_TEST(params[i].getPsi() == 0.0);
161 BOOST_TEST(params[i].getTheta() == 0.0);
162 BOOST_TEST(params[i].getPhi() == 0.0);
163 } else if (params[i].getSymName() == fmt::format("MCH/HC{}/DE{}", 0, 103)) {
164 BOOST_TEST(params[i].getX() == 0.01);
165 BOOST_TEST(params[i].getY() == -0.02);
166 BOOST_TEST(params[i].getZ() == -0.03);
167 BOOST_TEST(params[i].getPsi() == 0.0);
168 BOOST_TEST(params[i].getTheta() == 0.0);
169 BOOST_TEST(params[i].getPhi() == 0.0);
170 }
171 }
172}
173
174BOOST_AUTO_TEST_CASE(MisAlignHCDE, *but::tolerance(0.00001))
175{
176 BOOST_REQUIRE(gGeoManager != nullptr);
177
178 std::vector<o2::detectors::AlignParam> params;
179
180 // The misaligner
182
183 // To generate half chmaber misalignment
184 aGMA.setModuleCartMisAlig(0.1, 0.0, 0.2, 0.0, 0.3, 0.0);
185 aGMA.setModuleAngMisAlig(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
186 // To generate detection element misalignment
187 aGMA.setCartMisAlig(0.01, 0.0, 0.02, 0.0, 0.03, 0.0);
188 aGMA.setAngMisAlig(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
189
191 auto tB100 = transformationB(100);
192 auto tB1000 = transformationB(1000);
194
196
198 auto t100 = transformation(100);
199 auto t1000 = transformation(1000);
201 tB100.LocalToMaster(o2::math_utils::Point3D<double>{0, 0, 0}, poB);
202 t100.LocalToMaster(o2::math_utils::Point3D<double>{0, 0, 0}, po);
203
204 BOOST_TEST(po.X() - poB.X() == 0.1 + 0.01);
205 BOOST_TEST(po.Y() - poB.Y() == 0.2 + 0.02);
206 BOOST_TEST(po.Z() - poB.Z() == 0.3 + 0.03);
207
208 tB1000.LocalToMaster(o2::math_utils::Point3D<double>{0, 0, 0}, poB);
209 t1000.LocalToMaster(o2::math_utils::Point3D<double>{0, 0, 0}, po);
210 BOOST_TEST(po.X() - poB.X() == 0.1 + 0.01);
211 BOOST_TEST(po.Y() - poB.Y() == (0.2 * std::cos(o2::constants::math::Deg2Rad * -0.794) - 0.3 * std::sin(o2::constants::math::Deg2Rad * -0.794)) -
212 (0.02 * std::cos(o2::constants::math::Deg2Rad * -0.794) - 0.03 * std::sin(o2::constants::math::Deg2Rad * -0.794)));
213 BOOST_TEST(po.Z() - poB.Z() == (0.2 * std::sin(o2::constants::math::Deg2Rad * -0.794) + 0.3 * std::cos(o2::constants::math::Deg2Rad * -0.794)) -
214 (0.02 * std::sin(o2::constants::math::Deg2Rad * -0.794) + 0.03 * std::cos(o2::constants::math::Deg2Rad * -0.794)));
215
216 int nvols = params.size();
217 for (int i = 0; i < nvols; i++) {
218 std::cout << params[i].getSymName() << std::endl;
219 if (params[i].getSymName() == fmt::format("MCH/HC{}/DE{}", 0, 100)) {
220 BOOST_TEST(params[i].getX() == 0.01);
221 BOOST_TEST(params[i].getY() == 0.02);
222 BOOST_TEST(params[i].getZ() == 0.03);
223 BOOST_TEST(params[i].getPsi() == 0.0);
224 BOOST_TEST(params[i].getTheta() == 0.0);
225 BOOST_TEST(params[i].getPhi() == 0.0);
226 } else if (params[i].getSymName() == fmt::format("MCH/HC{}/DE{}", 0, 101)) {
227 BOOST_TEST(params[i].getX() == -0.01);
228 BOOST_TEST(params[i].getY() == 0.02);
229 BOOST_TEST(params[i].getZ() == -0.03);
230 BOOST_TEST(params[i].getPsi() == 0.0);
231 BOOST_TEST(params[i].getTheta() == 0.0);
232 BOOST_TEST(params[i].getPhi() == 0.0);
233 } else if (params[i].getSymName() == fmt::format("MCH/HC{}/DE{}", 0, 102)) {
234 BOOST_TEST(params[i].getX() == -0.01);
235 BOOST_TEST(params[i].getY() == -0.02);
236 BOOST_TEST(params[i].getZ() == 0.03);
237 BOOST_TEST(params[i].getPsi() == 0.0);
238 BOOST_TEST(params[i].getTheta() == 0.0);
239 BOOST_TEST(params[i].getPhi() == 0.0);
240 } else if (params[i].getSymName() == fmt::format("MCH/HC{}/DE{}", 0, 103)) {
241 BOOST_TEST(params[i].getX() == 0.01);
242 BOOST_TEST(params[i].getY() == -0.02);
243 BOOST_TEST(params[i].getZ() == -0.03);
244 BOOST_TEST(params[i].getPsi() == 0.0);
245 BOOST_TEST(params[i].getTheta() == 0.0);
246 BOOST_TEST(params[i].getPhi() == 0.0);
247 }
248 }
249}
250
251BOOST_AUTO_TEST_SUITE_END()
int32_t i
Interface for MCH geometry creation.
useful math constants
void setCartMisAlig(double xmean, double xwidth, double ymean, double ywidth, double zmean=0., double zwidth=0.)
Set cartesian displacement parameters different along x, y.
Definition MisAligner.h:54
void setModuleAngMisAlig(double xmean, double xwidth, double ymean, double ywidth, double zmean, double zwidth)
Set module (half chambers) cartesian displacement parameters.
Definition MisAligner.h:114
void setModuleCartMisAlig(double xmean, double xwidth, double ymean, double ywidth, double zmean, double zwidth)
Set module (half chambers) cartesian displacement parameters.
Definition MisAligner.h:103
void misAlign(std::vector< o2::detectors::AlignParam > &arr, bool verbose=false) const
void setAngMisAlig(double zmean, double zwidth, double xmean=0., double xwidth=0., double ymean=0., double ywidth=0.)
Set angular displacement.
Definition MisAligner.h:74
GLenum const GLfloat * params
Definition glcorearb.h:272
BOOST_AUTO_TEST_CASE(test_headerstack)
constexpr float Deg2Rad
void addAlignableVolumes(TGeoManager &geom)
Definition Geometry.cxx:99
TransformationCreator transformationFromTGeoManager(const TGeoManager &geo)
void createStandaloneGeometry()
Definition Helpers.cxx:112
double * getX(double *xyDxy, int N)
double * getY(double *xyDxy, int N)
o2::math_utils::Point3D< double > poB
o2::mch::geo::MisAligner aGMA
auto transformation
std::vector< o2::detectors::AlignParam > params
auto transformationB
o2::math_utils::Point3D< double > po
BOOST_TEST(po.X() - poB.X()==0.1)