File indexing completed on 2025-10-19 07:58:53
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Definitions/Units.hpp"
0012 #include "Acts/EventData/Charge.hpp"
0013 #include "Acts/EventData/ParticleHypothesis.hpp"
0014 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0015
0016 #include <limits>
0017 #include <type_traits>
0018
0019 using namespace Acts;
0020 using namespace Acts::UnitLiterals;
0021
0022 static auto eps = std::numeric_limits<double>::epsilon();
0023
0024 namespace ActsTests {
0025
0026 BOOST_AUTO_TEST_SUITE(EventDataSuite)
0027
0028 BOOST_AUTO_TEST_CASE(Neutral) {
0029 auto p = NeutralParticleHypothesis::pion0();
0030
0031 BOOST_CHECK_EQUAL(p.extractCharge(1.23), 0_e);
0032 BOOST_CHECK_EQUAL(p.extractCharge(2.54), 0_e);
0033 BOOST_CHECK_EQUAL(p.extractCharge(-1.98), 0_e);
0034 BOOST_CHECK_EQUAL(p.extractCharge(-2.23), 0_e);
0035 CHECK_CLOSE_REL(p.extractMomentum(1 / 64_GeV), 64_GeV, eps);
0036 CHECK_CLOSE_REL(p.extractMomentum(1 / 128_MeV), 128_MeV, eps);
0037 }
0038
0039 BOOST_AUTO_TEST_CASE(SinglyCharged) {
0040 auto p = SinglyChargedParticleHypothesis::pion();
0041
0042 BOOST_CHECK_EQUAL(p.extractCharge(1.23), 1_e);
0043 BOOST_CHECK_EQUAL(p.extractCharge(2.54), 1_e);
0044 BOOST_CHECK_EQUAL(p.extractCharge(-1.98), -1_e);
0045 BOOST_CHECK_EQUAL(p.extractCharge(-2.23), -1_e);
0046 CHECK_CLOSE_REL(p.extractMomentum(1_e / 64_GeV), 64_GeV, eps);
0047 CHECK_CLOSE_REL(p.extractMomentum(1_e / 128_MeV), 128_MeV, eps);
0048 CHECK_CLOSE_REL(p.extractMomentum(-1_e / 128_MeV), 128_MeV, eps);
0049 }
0050
0051 BOOST_AUTO_TEST_CASE(NonNeutralChargeSingle) {
0052 auto p = NonNeutralChargedParticleHypothesis::pion();
0053
0054 BOOST_CHECK_EQUAL(p.extractCharge(1.23), 1_e);
0055 BOOST_CHECK_EQUAL(p.extractCharge(2.54), 1_e);
0056 BOOST_CHECK_EQUAL(p.extractCharge(-1.98), -1_e);
0057 BOOST_CHECK_EQUAL(p.extractCharge(-2.23), -1_e);
0058 CHECK_CLOSE_REL(p.extractMomentum(1_e / 64_GeV), 64_GeV, eps);
0059 CHECK_CLOSE_REL(p.extractMomentum(1_e / 128_MeV), 128_MeV, eps);
0060 CHECK_CLOSE_REL(p.extractMomentum(-1_e / 128_MeV), 128_MeV, eps);
0061 }
0062
0063 BOOST_AUTO_TEST_CASE(NonNeutralChargeMultiple) {
0064 auto p = NonNeutralChargedParticleHypothesis::pionLike(3_e);
0065
0066 BOOST_CHECK_EQUAL(p.extractCharge(1.23), 3_e);
0067 BOOST_CHECK_EQUAL(p.extractCharge(2.54), 3_e);
0068 BOOST_CHECK_EQUAL(p.extractCharge(-1.98), -3_e);
0069 BOOST_CHECK_EQUAL(p.extractCharge(-2.23), -3_e);
0070 CHECK_CLOSE_REL(p.extractMomentum(3_e / 64_GeV), 64_GeV, eps);
0071 CHECK_CLOSE_REL(p.extractMomentum(3_e / 128_MeV), 128_MeV, eps);
0072 CHECK_CLOSE_REL(p.extractMomentum(-3_e / 128_MeV), 128_MeV, eps);
0073 }
0074
0075 BOOST_AUTO_TEST_CASE(AnyChargeNeutral) {
0076 auto p = ParticleHypothesis::pion0();
0077
0078 BOOST_CHECK_EQUAL(p.extractCharge(1.23), 0_e);
0079 BOOST_CHECK_EQUAL(p.extractCharge(2.54), 0_e);
0080 BOOST_CHECK_EQUAL(p.extractCharge(-1.98), 0_e);
0081 BOOST_CHECK_EQUAL(p.extractCharge(-2.23), 0_e);
0082 CHECK_CLOSE_REL(p.extractMomentum(1 / 64_GeV), 64_GeV, eps);
0083 CHECK_CLOSE_REL(p.extractMomentum(1 / 128_MeV), 128_MeV, eps);
0084
0085
0086
0087 CHECK_CLOSE_REL(p.extractMomentum(-1 / 128_MeV), -128_MeV, eps);
0088 }
0089
0090 BOOST_AUTO_TEST_CASE(AnyChargeSingle) {
0091 auto p = ParticleHypothesis::pion();
0092
0093 BOOST_CHECK_EQUAL(p.extractCharge(1.23), 1_e);
0094 BOOST_CHECK_EQUAL(p.extractCharge(2.54), 1_e);
0095 BOOST_CHECK_EQUAL(p.extractCharge(-1.98), -1_e);
0096 BOOST_CHECK_EQUAL(p.extractCharge(-2.23), -1_e);
0097 CHECK_CLOSE_REL(p.extractMomentum(1_e / 64_GeV), 64_GeV, eps);
0098 CHECK_CLOSE_REL(p.extractMomentum(1_e / 128_MeV), 128_MeV, eps);
0099 CHECK_CLOSE_REL(p.extractMomentum(-1_e / 128_MeV), 128_MeV, eps);
0100 }
0101
0102 BOOST_AUTO_TEST_CASE(AnyChargeMultiple) {
0103 auto p = ParticleHypothesis::pionLike(3_e);
0104
0105 BOOST_CHECK_EQUAL(p.extractCharge(1.23), 3_e);
0106 BOOST_CHECK_EQUAL(p.extractCharge(2.54), 3_e);
0107 BOOST_CHECK_EQUAL(p.extractCharge(-1.98), -3_e);
0108 BOOST_CHECK_EQUAL(p.extractCharge(-2.23), -3_e);
0109 CHECK_CLOSE_REL(p.extractMomentum(3_e / 64_GeV), 64_GeV, eps);
0110 CHECK_CLOSE_REL(p.extractMomentum(3_e / 128_MeV), 128_MeV, eps);
0111 CHECK_CLOSE_REL(p.extractMomentum(-3_e / 128_MeV), 128_MeV, eps);
0112 }
0113
0114 BOOST_AUTO_TEST_SUITE_END()
0115
0116 }