EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VolumeMaterialInteractionTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file VolumeMaterialInteractionTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/unit_test.hpp>
10 
17 #include "Acts/Utilities/Units.hpp"
18 
19 namespace tt = boost::test_tools;
20 using namespace Acts::UnitLiterals;
21 
22 namespace Acts {
23 namespace Test {
24 
26 struct StepperState {
27  Vector3D pos, dir;
28  double t, p, q;
31 };
32 
34 struct State {
35  struct {
36  double mass;
38  } options;
39 
40  struct {
42  } navigation;
43 
45 };
46 
48 struct Stepper {
49  Stepper() = default;
50 
51  Vector3D position(const StepperState& state) const { return state.pos; }
52 
53  double time(const StepperState& state) const { return state.t; }
54 
55  Vector3D direction(const StepperState& state) const { return state.dir; }
56 
57  double momentum(const StepperState& state) const { return state.p; }
58 
59  double charge(const StepperState& state) const { return state.q; };
60 };
61 
62 BOOST_AUTO_TEST_CASE(volume_material_interaction_test) {
63  // Create a Tracking Volume
64  auto htrans = Transform3D(Translation3D{-10., -10., 0.});
65  auto bound = std::make_shared<const CuboidVolumeBounds>(1_m, 1_m, 1_m);
66  auto mat = makeSilicon();
67  auto volMat = std::make_shared<const HomogeneousVolumeMaterial>(mat);
68  auto volume = (TrackingVolume::create(htrans, bound, volMat)).get();
69 
70  // Create a propagator state
71  State state;
72  state.stepping.pos = Vector3D(1., 2., 3.);
73  state.stepping.dir = Vector3D(4., 5., 6.);
74  state.stepping.t = 7.;
75  state.stepping.p = 8.;
76  state.stepping.q = 9.;
77  state.stepping.covTransport = true;
78  state.stepping.navDir = backward;
79  state.options.mass = 10.;
80  state.options.absPdgCode = 11;
82 
84 
85  // Build the VolumeMaterialInteraction & test assignments
86  detail::VolumeMaterialInteraction volMatInt(volume, state, stepper);
87  BOOST_CHECK_EQUAL(volMatInt.volume, volume);
88  BOOST_CHECK_EQUAL(volMatInt.pos, state.stepping.pos);
89  BOOST_CHECK_EQUAL(volMatInt.time, state.stepping.t);
90  BOOST_CHECK_EQUAL(volMatInt.dir, state.stepping.dir);
91  BOOST_CHECK_EQUAL(volMatInt.momentum, state.stepping.p);
92  BOOST_CHECK_EQUAL(volMatInt.q, state.stepping.q);
93  CHECK_CLOSE_ABS(volMatInt.qOverP, state.stepping.q / state.stepping.p, 1e-6);
94  BOOST_CHECK_EQUAL(volMatInt.mass, state.options.mass);
95  BOOST_CHECK_EQUAL(volMatInt.pdg, state.options.absPdgCode);
96  BOOST_CHECK_EQUAL(volMatInt.performCovarianceTransport,
97  state.stepping.covTransport);
98  BOOST_CHECK_EQUAL(volMatInt.nav, state.stepping.navDir);
99 
100  // Evaluate the material
101  bool result = volMatInt.evaluateMaterialSlab(state);
102  BOOST_CHECK(result);
103  BOOST_CHECK_EQUAL(volMatInt.slab.material(), mat);
104  BOOST_CHECK_EQUAL(volMatInt.slab.thickness(), 1.);
105  BOOST_CHECK_EQUAL(volMatInt.pathCorrection, 0.);
106 
107  // Evaluate the material without a tracking volume
108  state.navigation.currentVolume = nullptr;
109  result = volMatInt.evaluateMaterialSlab(state);
110  BOOST_CHECK(!result);
111  BOOST_CHECK_EQUAL(volMatInt.pathCorrection, 0.);
112 }
113 } // namespace Test
114 } // namespace Acts