9 #include <boost/test/unit_test.hpp>
20 #include <DD4hep/DetElement.h>
21 #include <DD4hep/Detector.h>
23 #include "DD4hep/DetFactoryHelper.h"
24 #include "XML/Utilities.h"
30 R
""""(
<detectors>
<detector id="1" name="Cylinder" type="Cylinder">
<type_flags type="DetType_TRACKER"/>
<tubs name="Cylinder" rmin="10*cm" rmax="11*cm" dz="100*cm" material="Vacuum" sensitive="true"/>
</detector>
</detectors>
)"""";
33 R
""""(
<detectors>
<detector id="1" name="SectoralCylinder" type="Cylinder">
<type_flags type="DetType_TRACKER"/>
<tubs name="Cylinder" rmin="10*cm" rmax="11*cm" dz="100*cm" phimin="0.1*rad" phimax="0.8*rad" material="Vacuum" sensitive="true"/>
</detector>
</detectors>
)"""";
36 R
""""(
<detectors>
<detector id="1" name="Disc" type="Disc">
<type_flags type="DetType_TRACKER"/>
<tubs name="Disc" rmin="10*cm" rmax="90*cm" dz="1*cm" material="Vacuum" sensitive="true"/>
</detector>
</detectors>
)"""";
39 R
""""(
<detectors>
<detector id="1" name="SectoralDisc" type="Disc">
<type_flags type="DetType_TRACKER"/>
<tubs name="Disc" rmin="10*cm" rmax="90*cm" dz="1*cm" phimin="0.*rad" phimax="1.5*rad" material="Vacuum" sensitive="true"/>
</detector>
</detectors>
)"""";
42 R
""""(
<detectors>
<detector id="1" name="Rectangle" type="Rectangle">
<type_flags type="DetType_TRACKER"/>
<box name="Rectangle" dx="10*cm" dy="90*cm" dz="0.1*cm" cx="1.*cm" cy="2.*cm" cz="3.*cm" material="Vacuum" sensitive="true"/>
</detector>
</detectors>
)"""";
45 R
""""(
<detectors>
<detector id="1" name="Trapezoid" type="Trapezoid">
<type_flags type="DetType_TRACKER"/>
<trap name="Trapezoid" x1="10*cm" x2="20*cm" dy="30*cm" dz="0.1*cm" cx="2.*cm" cy="3.*cm" cz="4.*cm" material="Vacuum" sensitive="true"/>
</detector>
</detectors>
)"""";
47 BOOST_AUTO_TEST_SUITE(DD4hepPlugin)
51 cxml.open("Cylinder.xml");
57 auto lcdd = &(dd4hep::Detector::getInstance());
58 lcdd->fromCompact(
"Cylinder.xml");
59 lcdd->volumeManager();
60 lcdd->apply(
"DD4hepVolumeManager", 0,
nullptr);
62 auto world = lcdd->world();
64 std::shared_ptr<Acts::DD4hepDetectorElement> cylindricalElement =
nullptr;
65 for (
auto [chn,
child] : world.children()) {
67 std::make_shared<Acts::DD4hepDetectorElement>(
child,
"XYZ", 10.);
70 BOOST_CHECK(cylindricalElement !=
nullptr);
72 const auto&
surface = cylindricalElement->surface();
73 BOOST_CHECK(
surface.type() == Acts::Surface::SurfaceType::Cylinder);
75 surface.transform(tContext).isApprox(Acts::Transform3::Identity()));
76 auto boundValues =
surface.bounds().values();
79 lcdd->destroyInstance();
84 cxml.open(
"SectoralCylinder.xml");
90 auto lcdd = &(dd4hep::Detector::getInstance());
91 lcdd->fromCompact(
"SectoralCylinder.xml");
92 lcdd->volumeManager();
93 lcdd->apply(
"DD4hepVolumeManager", 0,
nullptr);
95 auto world = lcdd->world();
97 std::shared_ptr<Acts::DD4hepDetectorElement> cylindricalElement =
nullptr;
98 for (
auto [chn,
child] : world.children()) {
100 std::make_shared<Acts::DD4hepDetectorElement>(
child,
"XYZ", 10.);
103 BOOST_CHECK(cylindricalElement !=
nullptr);
105 const auto&
surface = cylindricalElement->surface();
106 BOOST_CHECK(
surface.type() == Acts::Surface::SurfaceType::Cylinder);
108 surface.transform(tContext).isApprox(Acts::Transform3::Identity()));
109 auto boundValues =
surface.bounds().values();
114 lcdd->destroyInstance();
119 cxml.open(
"Disc.xml");
125 auto lcdd = &(dd4hep::Detector::getInstance());
126 lcdd->fromCompact(
"Disc.xml");
127 lcdd->volumeManager();
128 lcdd->apply(
"DD4hepVolumeManager", 0,
nullptr);
130 auto world = lcdd->world();
132 std::shared_ptr<Acts::DD4hepDetectorElement> discElement =
nullptr;
133 for (
auto [chn,
child] : world.children()) {
135 std::make_shared<Acts::DD4hepDetectorElement>(
child,
"XYZ", 10.,
true);
138 BOOST_CHECK(discElement !=
nullptr);
140 const auto&
surface = discElement->surface();
141 BOOST_CHECK(
surface.type() == Acts::Surface::SurfaceType::Disc);
143 surface.transform(tContext).isApprox(Acts::Transform3::Identity()));
144 auto boundValues =
surface.bounds().values();
147 lcdd->destroyInstance();
152 cxml.open(
"SectoralDisc.xml");
158 auto lcdd = &(dd4hep::Detector::getInstance());
159 lcdd->fromCompact(
"SectoralDisc.xml");
160 lcdd->volumeManager();
161 lcdd->apply(
"DD4hepVolumeManager", 0,
nullptr);
163 auto world = lcdd->world();
165 std::shared_ptr<Acts::DD4hepDetectorElement> discElement =
nullptr;
166 for (
auto [chn,
child] : world.children()) {
168 std::make_shared<Acts::DD4hepDetectorElement>(
child,
"XYZ", 10.,
true);
171 BOOST_CHECK(discElement !=
nullptr);
173 const auto&
surface = discElement->surface();
174 BOOST_CHECK(
surface.type() == Acts::Surface::SurfaceType::Disc);
176 surface.transform(tContext).isApprox(Acts::Transform3::Identity()));
177 auto boundValues =
surface.bounds().values();
183 lcdd->destroyInstance();
188 cxml.open(
"Rectangle.xml");
194 auto lcdd = &(dd4hep::Detector::getInstance());
195 lcdd->fromCompact(
"Rectangle.xml");
196 lcdd->volumeManager();
197 lcdd->apply(
"DD4hepVolumeManager", 0,
nullptr);
199 auto world = lcdd->world();
201 std::shared_ptr<Acts::DD4hepDetectorElement> rectangleElement =
nullptr;
202 for (
auto [chn,
child] : world.children()) {
204 std::make_shared<Acts::DD4hepDetectorElement>(
child,
"XYZ", 10.,
true);
207 BOOST_CHECK(rectangleElement !=
nullptr);
209 const auto&
surface = rectangleElement->surface();
210 BOOST_CHECK(
surface.type() == Acts::Surface::SurfaceType::Plane);
213 BOOST_CHECK(sTransform.translation().isApprox(
Acts::Vector3(10., 20., 30.)));
215 const auto& sBounds =
surface.bounds();
216 BOOST_CHECK(sBounds.type() == Acts::SurfaceBounds::BoundsType::eRectangle);
218 auto boundValues = sBounds.values();
225 lcdd->destroyInstance();
230 cxml.open(
"Trapezoid.xml");
236 auto lcdd = &(dd4hep::Detector::getInstance());
237 lcdd->fromCompact(
"Trapezoid.xml");
238 lcdd->volumeManager();
239 lcdd->apply(
"DD4hepVolumeManager", 0,
nullptr);
241 auto world = lcdd->world();
243 std::shared_ptr<Acts::DD4hepDetectorElement> trapezoidElement =
nullptr;
244 for (
auto [chn,
child] : world.children()) {
246 std::make_shared<Acts::DD4hepDetectorElement>(
child,
"xZ", 10.,
true);
249 BOOST_CHECK(trapezoidElement !=
nullptr);
251 const auto&
surface = trapezoidElement->surface();
252 BOOST_CHECK(
surface.type() == Acts::Surface::SurfaceType::Plane);
255 BOOST_CHECK(sTransform.translation().isApprox(
Acts::Vector3(20., 30., 40.)));
257 const auto& sBounds =
surface.bounds();
258 BOOST_CHECK(sBounds.type() == Acts::SurfaceBounds::BoundsType::eTrapezoid);
260 auto boundValues = sBounds.values();
265 lcdd->destroyInstance();
268 BOOST_AUTO_TEST_SUITE_END()