File indexing completed on 2026-07-17 07:51:36
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/ParticleHypothesis.hpp"
0013 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0014
0015 #include <limits>
0016
0017 using namespace Acts;
0018 using namespace Acts::UnitLiterals;
0019
0020 static auto eps = std::numeric_limits<double>::epsilon();
0021
0022 namespace ActsTests {
0023
0024 BOOST_AUTO_TEST_SUITE(EventDataSuite)
0025
0026 BOOST_AUTO_TEST_CASE(ChargeHypothesisNeutral) {
0027 ChargeHypothesis q(0_e);
0028
0029 BOOST_CHECK_EQUAL(q.extractCharge(1.23), 0_e);
0030 BOOST_CHECK_EQUAL(q.extractCharge(2.54), 0_e);
0031 BOOST_CHECK_EQUAL(q.extractCharge(-1.98), 0_e);
0032 BOOST_CHECK_EQUAL(q.extractCharge(-2.23), 0_e);
0033
0034 BOOST_CHECK(q == ChargeHypothesis(0_e));
0035 BOOST_CHECK(ChargeHypothesis(0_e) == q);
0036 BOOST_CHECK(!(q == ChargeHypothesis(1_e)));
0037 BOOST_CHECK(!(ChargeHypothesis(1_e) == q));
0038 BOOST_CHECK(!(q == ChargeHypothesis(2_e)));
0039 BOOST_CHECK(!(ChargeHypothesis(2_e) == q));
0040 }
0041
0042 BOOST_AUTO_TEST_CASE(ChargeHypothesisSingle) {
0043 ChargeHypothesis q(1_e);
0044
0045 BOOST_CHECK_EQUAL(q.extractCharge(1.23), 1_e);
0046 BOOST_CHECK_EQUAL(q.extractCharge(2.54), 1_e);
0047 BOOST_CHECK_EQUAL(q.extractCharge(-1.98), -1_e);
0048 BOOST_CHECK_EQUAL(q.extractCharge(-2.23), -1_e);
0049 CHECK_CLOSE_REL(q.extractMomentum(1_e / 64_GeV), 64_GeV, eps);
0050 CHECK_CLOSE_REL(q.extractMomentum(1_e / 128_MeV), 128_MeV, eps);
0051 CHECK_CLOSE_REL(q.extractMomentum(-1_e / 128_MeV), 128_MeV, eps);
0052
0053 BOOST_CHECK(!(q == ChargeHypothesis(0_e)));
0054 BOOST_CHECK(!(ChargeHypothesis(0_e) == q));
0055 BOOST_CHECK(q == ChargeHypothesis(1_e));
0056 BOOST_CHECK(ChargeHypothesis(1_e) == q);
0057 BOOST_CHECK(!(q == ChargeHypothesis(2_e)));
0058 BOOST_CHECK(!(ChargeHypothesis(2_e) == q));
0059 }
0060
0061 BOOST_AUTO_TEST_CASE(ChargeHypothesisMultiple) {
0062 ChargeHypothesis q(3_e);
0063
0064 BOOST_CHECK_EQUAL(q.extractCharge(1.23), 3_e);
0065 BOOST_CHECK_EQUAL(q.extractCharge(2.54), 3_e);
0066 BOOST_CHECK_EQUAL(q.extractCharge(-1.98), -3_e);
0067 BOOST_CHECK_EQUAL(q.extractCharge(-2.23), -3_e);
0068 CHECK_CLOSE_REL(q.extractMomentum(3_e / 64_GeV), 64_GeV, eps);
0069 CHECK_CLOSE_REL(q.extractMomentum(3_e / 128_MeV), 128_MeV, eps);
0070 CHECK_CLOSE_REL(q.extractMomentum(-3_e / 128_MeV), 128_MeV, eps);
0071
0072 BOOST_CHECK(!(q == ChargeHypothesis(0_e)));
0073 BOOST_CHECK(!(ChargeHypothesis(0_e) == q));
0074 BOOST_CHECK(!(q == ChargeHypothesis(1_e)));
0075 BOOST_CHECK(!(ChargeHypothesis(1_e) == q));
0076 BOOST_CHECK(!(q == ChargeHypothesis(2_e)));
0077 BOOST_CHECK(!(ChargeHypothesis(2_e) == q));
0078 BOOST_CHECK(q == ChargeHypothesis(3_e));
0079 BOOST_CHECK(ChargeHypothesis(3_e) == q);
0080 }
0081
0082 BOOST_AUTO_TEST_CASE(AnyChargeNeutral) {
0083 auto p = ParticleHypothesis::pion0();
0084
0085 BOOST_CHECK_EQUAL(p.extractCharge(1.23), 0_e);
0086 BOOST_CHECK_EQUAL(p.extractCharge(2.54), 0_e);
0087 BOOST_CHECK_EQUAL(p.extractCharge(-1.98), 0_e);
0088 BOOST_CHECK_EQUAL(p.extractCharge(-2.23), 0_e);
0089 }
0090
0091 BOOST_AUTO_TEST_CASE(AnyChargeSingle) {
0092 auto p = ParticleHypothesis::pion();
0093
0094 BOOST_CHECK_EQUAL(p.extractCharge(1.23), 1_e);
0095 BOOST_CHECK_EQUAL(p.extractCharge(2.54), 1_e);
0096 BOOST_CHECK_EQUAL(p.extractCharge(-1.98), -1_e);
0097 BOOST_CHECK_EQUAL(p.extractCharge(-2.23), -1_e);
0098 CHECK_CLOSE_REL(p.extractMomentum(1_e / 64_GeV), 64_GeV, eps);
0099 CHECK_CLOSE_REL(p.extractMomentum(1_e / 128_MeV), 128_MeV, eps);
0100 CHECK_CLOSE_REL(p.extractMomentum(-1_e / 128_MeV), 128_MeV, eps);
0101 }
0102
0103 BOOST_AUTO_TEST_CASE(AnyChargeMultiple) {
0104 auto p = ParticleHypothesis::pionLike(3_e);
0105
0106 BOOST_CHECK_EQUAL(p.extractCharge(1.23), 3_e);
0107 BOOST_CHECK_EQUAL(p.extractCharge(2.54), 3_e);
0108 BOOST_CHECK_EQUAL(p.extractCharge(-1.98), -3_e);
0109 BOOST_CHECK_EQUAL(p.extractCharge(-2.23), -3_e);
0110 CHECK_CLOSE_REL(p.extractMomentum(3_e / 64_GeV), 64_GeV, eps);
0111 CHECK_CLOSE_REL(p.extractMomentum(3_e / 128_MeV), 128_MeV, eps);
0112 CHECK_CLOSE_REL(p.extractMomentum(-3_e / 128_MeV), 128_MeV, eps);
0113 }
0114
0115 BOOST_AUTO_TEST_SUITE_END()
0116
0117 }