9 #include <boost/test/unit_test.hpp>
32 #include "G4LogicalVolume.hh"
33 #include "G4Material.hh"
34 #include "G4PVPlacement.hh"
35 #include "G4RotationMatrix.hh"
36 #include "G4SystemOfUnits.hh"
37 #include "G4ThreeVector.hh"
40 #include "G4VPhysicalVolume.hh"
47 BOOST_AUTO_TEST_SUITE(Geant4Plugin)
50 G4ThreeVector g4Translation(10., 20., 30.);
53 auto actsTranslation = translated.translation();
54 BOOST_CHECK(actsTranslation[0] == 10.);
55 BOOST_CHECK(actsTranslation[1] == 20.);
56 BOOST_CHECK(actsTranslation[2] == 30.);
58 auto translatedScaled =
60 auto actsTranslationScaled = translatedScaled.translation();
61 BOOST_CHECK(actsTranslationScaled[0] == 100.);
62 BOOST_CHECK(actsTranslationScaled[1] == 200.);
63 BOOST_CHECK(actsTranslationScaled[2] == 300.);
67 G4Tubs cylinder(
"Cylinder", 399., 401., 800., -M_PI * CLHEP::radian,
68 2 * M_PI * CLHEP::radian);
76 bounds->get(Acts::CylinderBounds::BoundValues::eHalfPhiSector), M_PI,
84 G4Tubs disc(
"disc", 40., 400., 2., -M_PI * CLHEP::radian,
85 2 * M_PI * CLHEP::radian);
99 G4Tubs
line(
"line", 0., 20., 400., 0., 2 * M_PI);
108 G4Box sensorXY(
"SensorXY", 23., 34., 1.);
109 auto [boundsXY,
axesXY, thicknessZ] =
113 auto refXY = std::array<int, 2u>{0, 1};
114 BOOST_CHECK(axesXY == refXY);
117 G4Box sensorYZ(
"SensorYZ", 2., 45., 56.);
118 auto [boundsYZ, axesYZ, thicknessX] =
122 auto refYZ = std::array<int, 2u>{1, 2};
123 BOOST_CHECK(axesYZ == refYZ);
126 G4Box sensorZX(
"SensorZX", 78., 2., 67.);
127 auto [boundsZX, axesZX, thicknessY] =
131 auto refZX = std::array<int, 2u>{2, 0};
132 BOOST_CHECK(axesZX == refZX);
136 G4Box sensorXz(
"SensorXz", 78., 2., 67.);
137 auto [boundsXz, axesXz, thicknessY2] =
141 auto refXz = std::array<int, 2u>{0, -2};
142 BOOST_CHECK(axesXz == refXz);
148 G4Trd trdXY(
"trdXY", 100, 150, 200, 200, 2);
149 auto [boundsXY,
axesXY, thicknessZ] =
152 boundsXY->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthXnegY), 100,
155 boundsXY->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthXposY), 150,
158 boundsXY->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthY), 200,
160 auto refXY = std::array<int, 2u>{0, 1};
161 BOOST_CHECK(axesXY == refXY);
165 G4Trd trdyX(
"trdyX", 200, 200, 100, 150, 2);
166 auto [boundsyX, axesyX, thicknessZ2] =
169 boundsyX->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthXnegY), 100,
172 boundsyX->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthXposY), 150,
175 boundsyX->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthY), 200,
177 auto refyX = std::array<int, 2u>{-1, 0};
178 BOOST_CHECK(axesyX == refyX);
182 G4Trd trdYZ(
"trdYZ", 2, 2, 120, 140, 200);
183 auto [boundsYZ, axesYZ, thicknessX] =
186 boundsYZ->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthXnegY), 120.,
189 boundsYZ->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthXposY), 140.,
192 boundsYZ->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthY), 200.,
194 auto refYZ = std::array<int, 2u>{1, 2};
195 BOOST_CHECK(axesYZ == refYZ);
199 G4Trd trdXz(
"trdXz", 50, 75, 1, 1, 200);
200 auto [boundsXz, axesXz, thicknessY] =
203 boundsXz->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthXnegY), 50.,
206 boundsXz->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthXposY), 75.,
209 boundsXz->get(Acts::TrapezoidBounds::BoundValues::eHalfLengthY), 200.,
211 auto refXz = std::array<int, 2u>{0, -2};
212 BOOST_CHECK(axesXz == refXz);
217 G4Box boxXY(
"boxXY", 23., 34., 1.);
221 BOOST_CHECK(rBounds !=
nullptr);
223 G4Trd trdXY(
"trdXY", 100, 150, 200, 200, 2);
227 BOOST_CHECK(tBounds !=
nullptr);
233 G4Box* g4Box =
new G4Box(
"Box", 23., 34., 0.5 * thickness);
234 G4RotationMatrix* g4Rot =
new G4RotationMatrix({0., 0., 1.}, 1.2);
235 G4LogicalVolume* g4BoxLog =
new G4LogicalVolume(g4Box,
g4Material,
"BoxLog");
237 G4ThreeVector g4Trans(0., 0., 100.);
238 G4PVPlacement g4BoxPhys(g4Rot, g4Trans, g4BoxLog,
"BoxPhys",
nullptr,
false,
242 g4BoxPhys, Acts::Transform3::Identity(),
true, thickness);
243 BOOST_CHECK(planeSurface !=
nullptr);
244 BOOST_CHECK(planeSurface->type() == Acts::Surface::SurfaceType::Plane);
246 auto material = planeSurface->surfaceMaterial();
247 BOOST_CHECK(material !=
nullptr);
249 auto materialSlab = material->materialSlab(
Acts::Vector3{0., 0., 0.});
253 materialSlab.thicknessInX0(), 0.1);
258 g4BoxPhys, Acts::Transform3::Identity(),
true, thickness / compression);
259 BOOST_CHECK(planeSurface !=
nullptr);
260 BOOST_CHECK(planeSurface->type() == Acts::Surface::SurfaceType::Plane);
262 material = planeSurface->surfaceMaterial();
263 BOOST_CHECK(material !=
nullptr);
264 materialSlab = material->materialSlab(
Acts::Vector3{0., 0., 0.});
270 materialSlab.thicknessInX0(), 0.01);
272 CHECK_CLOSE_ABS(materialSlab.thickness(), thickness / compression, 0.01);
286 G4Tubs* g4Tube =
new G4Tubs(
"Tube", radius, radius + thickness, halfLengthZ,
287 -M_PI * CLHEP::radian, 2 * M_PI * CLHEP::radian);
289 G4RotationMatrix* g4Rot =
new G4RotationMatrix({0., 0., 1.}, 0.);
290 G4LogicalVolume* g4TubeLog =
291 new G4LogicalVolume(g4Tube,
g4Material,
"TubeLog");
292 G4ThreeVector g4Trans(0., 0., 100.);
293 G4PVPlacement g4CylinderPhys(g4Rot, g4Trans, g4TubeLog,
"TubePhys",
nullptr,
297 g4CylinderPhys, Acts::Transform3::Identity(),
true, thickness);
298 BOOST_CHECK(cylinderSurface !=
nullptr);
299 BOOST_CHECK(cylinderSurface->type() == Acts::Surface::SurfaceType::Cylinder);
301 auto material = cylinderSurface->surfaceMaterial();
302 BOOST_CHECK(material !=
nullptr);
304 auto materialSlab = material->materialSlab(
Acts::Vector3{0., 0., 0.});
306 materialSlab.thicknessInX0(), 0.1);
314 .
surface(g4CylinderPhys, Acts::Transform3::Identity(),
true,
328 G4Tubs* g4Tube =
new G4Tubs(
"Disc", innerRadius, outerRadius, 0.5 * thickness,
329 -M_PI * CLHEP::radian, 2 * M_PI * CLHEP::radian);
331 G4RotationMatrix* g4Rot =
new G4RotationMatrix({0., 0., 1.}, 0.);
332 G4LogicalVolume* g4TubeLog =
333 new G4LogicalVolume(g4Tube,
g4Material,
"TubeLog");
334 G4ThreeVector g4Trans(0., 0., 100.);
335 G4PVPlacement g4discPhys(g4Rot, g4Trans, g4TubeLog,
"TubePhys",
nullptr,
339 g4discPhys, Acts::Transform3::Identity(),
true, thickness);
340 BOOST_CHECK(discSurface !=
nullptr);
341 BOOST_CHECK(discSurface->type() == Acts::Surface::SurfaceType::Disc);
343 auto material = discSurface->surfaceMaterial();
344 BOOST_CHECK(material !=
nullptr);
346 auto materialSlab = material->materialSlab(
Acts::Vector3{0., 0., 0.});
360 G4Tubs* g4Tube =
new G4Tubs(
"Line", innerRadius, outerRadius, 0.5 * thickness,
361 -M_PI * CLHEP::radian, 2 * M_PI * CLHEP::radian);
363 G4RotationMatrix* g4Rot =
new G4RotationMatrix({0., 0., 1.}, 0.);
364 G4LogicalVolume* g4TubeLog =
365 new G4LogicalVolume(g4Tube,
g4Material,
"LineLog");
366 G4ThreeVector g4Trans(0., 0., 100.);
367 G4PVPlacement g4linePhys(g4Rot, g4Trans, g4TubeLog,
"LinePhys",
nullptr,
372 .
surface(g4linePhys, Acts::Transform3::Identity(),
true, thickness);
373 BOOST_CHECK(lineSurface !=
nullptr);
374 BOOST_CHECK(lineSurface->type() == Acts::Surface::SurfaceType::Straw);
381 BOOST_AUTO_TEST_SUITE_END()