File indexing completed on 2025-01-18 09:13:05
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Geometry/GeometryIdentifier.hpp"
0012 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0013 #include "ActsFatras/EventData/Barcode.hpp"
0014 #include "ActsFatras/EventData/Hit.hpp"
0015
0016 #include <limits>
0017
0018 using namespace ActsFatras;
0019
0020 namespace {
0021 constexpr auto eps = std::numeric_limits<double>::epsilon();
0022 const auto pid = Barcode().setVertexPrimary(12).setParticle(23);
0023 const auto gid =
0024 Acts::GeometryIdentifier().setVolume(1).setLayer(2).setSensitive(3);
0025 }
0026
0027 BOOST_AUTO_TEST_SUITE(FatrasHit)
0028
0029 BOOST_AUTO_TEST_CASE(WithoutInteraction) {
0030
0031 auto p4 = Acts::Vector4(1, 2, 3, 4);
0032
0033 auto m4 = Acts::Vector4(1, 1, 1, 4);
0034 auto h = Hit(gid, pid, p4, m4, m4, 12u);
0035
0036 BOOST_CHECK_EQUAL(h.geometryId(), gid);
0037 BOOST_CHECK_EQUAL(h.particleId(), pid);
0038 BOOST_CHECK_EQUAL(h.index(), 12u);
0039 CHECK_CLOSE_REL(h.fourPosition(), p4, eps);
0040 CHECK_CLOSE_REL(h.position(), Acts::Vector3(1, 2, 3), eps);
0041 CHECK_CLOSE_REL(h.time(), 4, eps);
0042 CHECK_CLOSE_REL(h.momentum4Before(), m4, eps);
0043 CHECK_CLOSE_REL(h.momentum4After(), m4, eps);
0044 CHECK_CLOSE_REL(h.directionBefore(), Acts::Vector3(1, 1, 1).normalized(),
0045 eps);
0046 CHECK_CLOSE_REL(h.directionAfter(), Acts::Vector3(1, 1, 1).normalized(), eps);
0047 CHECK_CLOSE_REL(h.direction(), Acts::Vector3(1, 1, 1).normalized(), eps);
0048 CHECK_SMALL(h.depositedEnergy(), eps);
0049 }
0050
0051 BOOST_AUTO_TEST_CASE(WithEnergyLoss) {
0052
0053 auto p4 = Acts::Vector4(1, 2, 3, 4);
0054
0055 auto m40 = Acts::Vector4(2, 0, 0, 2);
0056 auto m41 = Acts::Vector4(1.5, 0, 0, 1.5);
0057 auto h = Hit(gid, pid, p4, m40, m41, 13u);
0058
0059 BOOST_CHECK_EQUAL(h.geometryId(), gid);
0060 BOOST_CHECK_EQUAL(h.particleId(), pid);
0061 BOOST_CHECK_EQUAL(h.index(), 13u);
0062 CHECK_CLOSE_REL(h.fourPosition(), p4, eps);
0063 CHECK_CLOSE_REL(h.position(), Acts::Vector3(1, 2, 3), eps);
0064 CHECK_CLOSE_REL(h.time(), 4, eps);
0065 CHECK_CLOSE_OR_SMALL(h.momentum4Before(), m40, eps, eps);
0066 CHECK_CLOSE_OR_SMALL(h.momentum4After(), m41, eps, eps);
0067 CHECK_CLOSE_OR_SMALL(h.directionBefore(), Acts::Vector3(1, 0, 0), eps, eps);
0068 CHECK_CLOSE_OR_SMALL(h.directionAfter(), Acts::Vector3(1, 0, 0), eps, eps);
0069 CHECK_CLOSE_OR_SMALL(h.direction(), Acts::Vector3(1, 0, 0), eps, eps);
0070 CHECK_CLOSE_REL(h.depositedEnergy(), 0.5, eps);
0071 }
0072
0073 BOOST_AUTO_TEST_CASE(WithScattering) {
0074
0075 auto p4 = Acts::Vector4(1, 2, 3, 4);
0076
0077 auto m40 = Acts::Vector4(2, 0, 2, 5);
0078 auto m41 = Acts::Vector4(0, -2, 2, 5);
0079 auto h = Hit(gid, pid, p4, m40, m41, 42u);
0080
0081 BOOST_CHECK_EQUAL(h.geometryId(), gid);
0082 BOOST_CHECK_EQUAL(h.particleId(), pid);
0083 BOOST_CHECK_EQUAL(h.index(), 42u);
0084 CHECK_CLOSE_REL(h.fourPosition(), p4, eps);
0085 CHECK_CLOSE_REL(h.position(), Acts::Vector3(1, 2, 3), eps);
0086 CHECK_CLOSE_REL(h.time(), 4, eps);
0087 CHECK_CLOSE_OR_SMALL(h.momentum4Before(), m40, eps, eps);
0088 CHECK_CLOSE_OR_SMALL(h.momentum4After(), m41, eps, eps);
0089 CHECK_CLOSE_OR_SMALL(h.directionBefore(), Acts::Vector3(1, 0, 1).normalized(),
0090 eps, eps);
0091 CHECK_CLOSE_OR_SMALL(h.directionAfter(), Acts::Vector3(0, -1, 1).normalized(),
0092 eps, eps);
0093 CHECK_CLOSE_REL(h.direction(), Acts::Vector3(1, -1, 2).normalized(), eps);
0094 CHECK_SMALL(h.depositedEnergy(), eps);
0095 }
0096
0097 BOOST_AUTO_TEST_CASE(WithEverything) {
0098
0099 auto p4 = Acts::Vector4(1, 2, 3, 4);
0100
0101 auto m40 = Acts::Vector4(3, 2, 2, 5);
0102 auto m41 = Acts::Vector4(2, 1, 2, 4);
0103 auto h = Hit(gid, pid, p4, m40, m41, 1u);
0104
0105 BOOST_CHECK_EQUAL(h.geometryId(), gid);
0106 BOOST_CHECK_EQUAL(h.particleId(), pid);
0107 BOOST_CHECK_EQUAL(h.index(), 1u);
0108 CHECK_CLOSE_REL(h.fourPosition(), p4, eps);
0109 CHECK_CLOSE_REL(h.position(), Acts::Vector3(1, 2, 3), eps);
0110 CHECK_CLOSE_REL(h.time(), 4, eps);
0111 CHECK_CLOSE_OR_SMALL(h.momentum4Before(), m40, eps, eps);
0112 CHECK_CLOSE_OR_SMALL(h.momentum4After(), m41, eps, eps);
0113 CHECK_CLOSE_REL(h.directionBefore(), Acts::Vector3(3, 2, 2).normalized(),
0114 eps);
0115 CHECK_CLOSE_REL(h.directionAfter(), Acts::Vector3(2, 1, 2).normalized(), eps);
0116 CHECK_CLOSE_REL(h.direction(),
0117 Acts::Vector3(0.7023994590205035, 0.41229136135810396,
0118 0.5802161953247991),
0119 eps);
0120 CHECK_CLOSE_REL(h.depositedEnergy(), 1, eps);
0121 }
0122
0123 BOOST_AUTO_TEST_SUITE_END()