9 #include <boost/test/unit_test.hpp>
54 struct MaterialCollector {
61 template <
typename propagator_state_t,
typename stepper_t,
66 if (navigator.currentVolume(state.navigation) !=
nullptr) {
67 auto position = stepper.position(state.stepping);
69 (navigator.currentVolume(state.navigation)->volumeMaterial() !=
71 ? navigator.currentVolume(state.navigation)
85 using namespace Acts::UnitLiterals;
87 BinUtility bu1(4, 0_m, 1_m,
open,
binX);
88 bu1 += BinUtility(2, -0.5_m, 0.5_m,
open,
binY);
89 bu1 += BinUtility(2, -0.5_m, 0.5_m,
open,
binZ);
91 BinUtility bu2(4, 1_m, 2_m,
open,
binX);
92 bu2 += BinUtility(2, -0.5_m, 0.5_m,
open,
binY);
93 bu2 += BinUtility(2, -0.5_m, 0.5_m,
open,
binZ);
95 BinUtility bu3(4, 2_m, 3_m,
open,
binX);
96 bu3 += BinUtility(2, -0.5_m, 0.5_m,
open,
binY);
97 bu3 += BinUtility(2, -0.5_m, 0.5_m,
open,
binZ);
100 CuboidVolumeBuilder::VolumeConfig vCfg1;
101 vCfg1.position =
Vector3(0.5_m, 0., 0.);
102 vCfg1.length =
Vector3(1_m, 1_m, 1_m);
103 vCfg1.name =
"Vacuum volume";
104 vCfg1.volumeMaterial = std::make_shared<const ProtoVolumeMaterial>(bu1);
107 CuboidVolumeBuilder::VolumeConfig vCfg2;
108 vCfg2.position =
Vector3(1.5_m, 0., 0.);
109 vCfg2.length =
Vector3(1_m, 1_m, 1_m);
110 vCfg2.name =
"First material volume";
111 vCfg2.volumeMaterial = std::make_shared<const ProtoVolumeMaterial>(bu2);
114 CuboidVolumeBuilder::VolumeConfig vCfg3;
115 vCfg3.position =
Vector3(2.5_m, 0., 0.);
116 vCfg3.length =
Vector3(1_m, 1_m, 1_m);
117 vCfg3.name =
"Second material volume";
118 vCfg3.volumeMaterial = std::make_shared<const ProtoVolumeMaterial>(bu3);
124 cfg.volumeCfg = {vCfg1, vCfg2, vCfg3};
129 CuboidVolumeBuilder cvb(
cfg);
131 tgbCfg.trackingVolumeBuilders.push_back(
132 [=](
const auto& context,
const auto& inner,
const auto&) {
133 return cvb.trackingVolume(context, inner,
nullptr);
135 TrackingGeometryBuilder tgb(tgbCfg);
136 std::shared_ptr<const TrackingGeometry>
tGeometry = tgb.trackingGeometry(gc);
155 auto mState = vmMapper.createState(gCtx, mfCtx, *
tGeometry);
158 BOOST_CHECK_EQUAL(mState.materialBin.size(), 3
u);
164 using namespace Acts::UnitLiterals;
169 vCfg1.length =
Vector3(1_m, 1_m, 1_m);
170 vCfg1.name =
"Vacuum volume";
171 vCfg1.volumeMaterial =
172 std::make_shared<const HomogeneousVolumeMaterial>(
Material());
177 vCfg2.length =
Vector3(1_m, 1_m, 1_m);
178 vCfg2.name =
"First material volume";
179 vCfg2.volumeMaterial =
180 std::make_shared<HomogeneousVolumeMaterial>(
makeSilicon());
185 vCfg3.length =
Vector3(1_m, 1_m, 1_m);
186 vCfg3.name =
"Second material volume";
187 vCfg3.volumeMaterial =
188 std::make_shared<const HomogeneousVolumeMaterial>(
Material());
194 cfg.volumeCfg = {vCfg1, vCfg2, vCfg3};
202 [=](
const auto& context,
const auto& inner,
const auto&) {
214 std::random_device
rd;
215 std::mt19937
gen(42);
216 std::uniform_real_distribution<> disX(0., 3_m);
217 std::uniform_real_distribution<> disYZ(-0.5_m, 0.5_m);
221 for (
unsigned int i = 0;
i < 1e4;
i++) {
222 Vector3 pos(disX(gen), disYZ(gen), disYZ(gen));
223 std::vector<Vector3> volPos;
224 volPos.push_back(pos);
226 (
detector->lowestTrackingVolume(gc, pos)->volumeMaterial() !=
nullptr)
227 ? (
detector->lowestTrackingVolume(gc, pos)->volumeMaterial())
231 matRecord.push_back(std::make_pair(matProp, volPos));
236 std::function<Vector3(Vector3)> transfoGlobalToLocal =
242 for (
const auto& rm : matRecord) {
244 for (
const auto&
point : rm.second) {
274 const auto& result = prop.
propagate(sctp, po).value();
279 std::vector<Material> matvector;
280 double gridX0 = 0., gridL0 = 0., trueX0 = 0., trueL0 = 0.;
281 for (
unsigned int i = 0;
i < stepResult.position.size();
i++) {
282 matvector.push_back(matGrid.atPosition(stepResult.position[
i]));
283 gridX0 += 1 / matvector[
i].X0();
284 gridL0 += 1 / matvector[
i].L0();
285 trueX0 += 1 / stepResult.
matTrue[
i].X0();
286 trueL0 += 1 / stepResult.matTrue[
i].L0();