9 #include <boost/test/unit_test.hpp>
19 #include <DD4hep/DetElement.h>
20 #include <DD4hep/DetFactoryHelper.h>
21 #include <DD4hep/Detector.h>
22 #include <XML/Utilities.h>
30 R
""""(
<detectors>
<detector id="0" name="BeamPipe" type="BarrelDetector">
<type_flags type="DetType_TRACKER + DetType_BEAMPIPE"/>
)"""";
33 R
""""(
</detector>
</detectors>
)"""";
37 BOOST_AUTO_TEST_SUITE(DD4hepPlugin)
46 cxml.open(fNameBase +
".xml");
51 <<
"<envelope rmin=\"0*mm\" rmax=\"30*mm\" dz=\"2000*mm\" "
56 cxml << indent_12_xml <<
"<layers>" <<
'\n';
57 cxml << indent_12_xml <<
"<layer name=\"CylinderLayer\" id=\"0\">" <<
'\n';
59 <<
"<acts_volume name=\"CylinderLayerVolume\" sequence=\"1\">" <<
'\n';
61 <<
" <tubs rmin=\"0*mm\" rmax=\"30.0*mm\" dz=\"2000*mm\" />" <<
'\n';
62 cxml << indent_12_xml <<
"</acts_volume>" <<
'\n';
65 cxml << indent_12_xml <<
"<passive_surface>" <<
'\n';
67 <<
" <tubs rmin=\"25*mm\" rmax=\"25.8*mm\" dz=\"1800*mm\" "
70 cxml << indent_12_xml <<
"</passive_surface>" <<
'\n';
71 cxml << indent_12_xml <<
"</layer>" <<
'\n';
72 cxml << indent_12_xml <<
"</layers>" <<
'\n';
78 auto lcdd = &(dd4hep::Detector::getInstance());
79 lcdd->fromCompact(fNameBase +
".xml");
80 lcdd->volumeManager();
81 lcdd->apply(
"DD4hepVolumeManager", 0,
nullptr);
83 auto world = lcdd->world();
91 vOptions.
name =
"CylinderLayerVolume";
93 auto volumeBuilder = volumeStructure.
builder(world, vOptions);
96 volumeBuilder->construct(tContext);
98 BOOST_CHECK(
transform.isApprox(Acts::Transform3::Identity()));
99 BOOST_CHECK(bounds !=
nullptr);
100 BOOST_CHECK(bounds->type() == Acts::VolumeBounds::BoundsType::eCylinder);
101 BOOST_CHECK(bounds->values().size() == 7
u);
102 BOOST_CHECK(bounds->values()[0
u] == 0.);
103 BOOST_CHECK(bounds->values()[1
u] == 30.);
104 BOOST_CHECK(bounds->values()[2
u] == 1000.);
107 lcdd->destroyInstance();
115 std::string fNameBase =
"ShiftedCylindricalVolume";
117 cxml.open(fNameBase +
".xml");
122 <<
"<envelope rmin=\"0*mm\" rmax=\"30*mm\" dz=\"2000*mm\" "
127 cxml << indent_12_xml <<
"<layers>" <<
'\n';
128 cxml << indent_12_xml <<
"<layer name=\"ShiftedCylinderLayer\" id=\"0\">"
130 cxml << indent_12_xml
131 <<
"<acts_volume name=\"ShiftedCylinderLayerVolume\" sequence=\"1\">"
133 cxml << indent_12_xml
134 <<
" <tubs rmin=\"0*mm\" rmax=\"30.0*mm\" dz=\"2000*mm\" "
135 "x=\"10.*mm\" y=\"1.5*cm\" z=\"-1300*mm\"/>"
137 cxml << indent_12_xml <<
"</acts_volume>" <<
'\n';
140 cxml << indent_12_xml <<
"<passive_surface>" <<
'\n';
141 cxml << indent_12_xml
142 <<
" <tubs rmin=\"25*mm\" rmax=\"25.8*mm\" dz=\"1800*mm\" "
145 cxml << indent_12_xml <<
"</passive_surface>" <<
'\n';
146 cxml << indent_12_xml <<
"</layer>" <<
'\n';
147 cxml << indent_12_xml <<
"</layers>" <<
'\n';
153 auto lcdd = &(dd4hep::Detector::getInstance());
154 lcdd->fromCompact(fNameBase +
".xml");
155 lcdd->volumeManager();
156 lcdd->apply(
"DD4hepVolumeManager", 0,
nullptr);
158 auto world = lcdd->world();
166 vOptions.
name =
"ShiftedCylinderLayerVolume";
168 auto volumeBuilder = volumeStructure.
builder(world, vOptions);
171 volumeBuilder->construct(tContext);
173 BOOST_CHECK(bounds !=
nullptr);
174 BOOST_CHECK(bounds->type() == Acts::VolumeBounds::BoundsType::eCylinder);
175 BOOST_CHECK(bounds->values().size() == 7
u);
176 BOOST_CHECK(bounds->values()[0
u] == 0.);
177 BOOST_CHECK(bounds->values()[1
u] == 30.);
178 BOOST_CHECK(bounds->values()[2
u] == 1000.);
187 lcdd->destroyInstance();
190 BOOST_AUTO_TEST_SUITE_END()