Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:25:20

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/unit_test.hpp>
0010 
0011 #include "Acts/Definitions/ParticleData.hpp"
0012 #include "Acts/Definitions/PdgParticle.hpp"
0013 #include "Acts/Definitions/Units.hpp"
0014 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0015 
0016 using namespace Acts;
0017 using namespace Acts::UnitLiterals;
0018 using namespace Acts::ParticleIdHelper;
0019 
0020 namespace {
0021 // NOTE: the used mass comparison values are not as exact as the data values
0022 static constexpr float eps = 0.001f;
0023 }  // namespace
0024 
0025 namespace ActsTests {
0026 
0027 BOOST_AUTO_TEST_SUITE(UtilitiesSuite)
0028 
0029 BOOST_AUTO_TEST_CASE(InvalidInput) {
0030   BOOST_CHECK(!findCharge(PdgParticle::eInvalid));
0031   BOOST_CHECK(!findMass(PdgParticle::eInvalid));
0032   BOOST_CHECK(!findName(PdgParticle::eInvalid));
0033 }
0034 
0035 BOOST_AUTO_TEST_CASE(Electron) {
0036   BOOST_CHECK_EQUAL(*findCharge(PdgParticle::eAntiElectron), 1_e);
0037   CHECK_CLOSE_REL(*findMass(PdgParticle::eAntiElectron), 511_keV, eps);
0038   BOOST_CHECK_EQUAL(*findName(PdgParticle::eAntiElectron), "e+");
0039   BOOST_CHECK_EQUAL(*findCharge(PdgParticle::eElectron), -1_e);
0040   CHECK_CLOSE_REL(*findMass(PdgParticle::eElectron), 511_keV, eps);
0041   BOOST_CHECK_EQUAL(*findName(PdgParticle::eElectron), "e-");
0042   BOOST_CHECK_EQUAL(*findCharge(PdgParticle::ePositron), 1_e);
0043   CHECK_CLOSE_REL(*findMass(PdgParticle::ePositron), 511_keV, eps);
0044   BOOST_CHECK_EQUAL(*findName(PdgParticle::ePositron), "e+");
0045 }
0046 
0047 BOOST_AUTO_TEST_CASE(Gamma) {
0048   BOOST_CHECK_EQUAL(*findCharge(PdgParticle::eGamma), 0);
0049   BOOST_CHECK_EQUAL(*findMass(PdgParticle::eGamma), 0);
0050   BOOST_CHECK_EQUAL(*findName(PdgParticle::eGamma), "gamma");
0051 }
0052 
0053 BOOST_AUTO_TEST_CASE(Pion) {
0054   BOOST_CHECK_EQUAL(*findCharge(PdgParticle::ePionMinus), -1_e);
0055   CHECK_CLOSE_REL(*findMass(PdgParticle::ePionMinus), 139.57_MeV, eps);
0056   BOOST_CHECK_EQUAL(*findName(PdgParticle::ePionMinus), "pi-");
0057   BOOST_CHECK_EQUAL(*findCharge(PdgParticle::ePionPlus), 1_e);
0058   CHECK_CLOSE_REL(*findMass(PdgParticle::ePionPlus), 139.57_MeV, eps);
0059   BOOST_CHECK_EQUAL(*findName(PdgParticle::ePionPlus), "pi+");
0060   BOOST_CHECK_EQUAL(*findCharge(PdgParticle::ePionZero), 0);
0061   CHECK_CLOSE_REL(*findMass(PdgParticle::ePionZero), 134.98_MeV, eps);
0062   BOOST_CHECK_EQUAL(*findName(PdgParticle::ePionZero), "pi0");
0063 }
0064 
0065 BOOST_AUTO_TEST_CASE(ParticleIdHelperentification) {
0066   // Test leptons
0067   BOOST_CHECK(ParticleIdHelper::isLepton(PdgParticle::eElectron));
0068   BOOST_CHECK(ParticleIdHelper::isLepton(PdgParticle::ePositron));
0069   BOOST_CHECK(ParticleIdHelper::isLepton(PdgParticle::eMuon));
0070   BOOST_CHECK(ParticleIdHelper::isLepton(PdgParticle::eTau));
0071   BOOST_CHECK(!ParticleIdHelper::isLepton(PdgParticle::eProton));
0072   BOOST_CHECK(!ParticleIdHelper::isLepton(PdgParticle::ePionPlus));
0073 
0074   // Test hadrons
0075   BOOST_CHECK(ParticleIdHelper::isHadron(PdgParticle::eProton));
0076   BOOST_CHECK(ParticleIdHelper::isHadron(PdgParticle::eNeutron));
0077   BOOST_CHECK(ParticleIdHelper::isHadron(PdgParticle::ePionPlus));
0078   BOOST_CHECK(ParticleIdHelper::isHadron(PdgParticle::ePionZero));
0079   BOOST_CHECK(ParticleIdHelper::isHadron(PdgParticle::eKaonPlus));
0080   BOOST_CHECK(!ParticleIdHelper::isHadron(PdgParticle::eElectron));
0081   BOOST_CHECK(!ParticleIdHelper::isHadron(PdgParticle::eGamma));
0082 
0083   // Test interacting particles
0084   BOOST_CHECK(ParticleIdHelper::isInteracting(PdgParticle::eProton));
0085   BOOST_CHECK(ParticleIdHelper::isInteracting(PdgParticle::ePionPlus));
0086   BOOST_CHECK(ParticleIdHelper::isInteracting(PdgParticle::eGamma));
0087   BOOST_CHECK(ParticleIdHelper::isInteracting(PdgParticle::eElectron));
0088   // Neutrinos are weakly interacting
0089   BOOST_CHECK(!ParticleIdHelper::isInteracting(PdgParticle::eNeutrinoE));
0090   BOOST_CHECK(!ParticleIdHelper::isInteracting(PdgParticle::eNeutrinoMu));
0091   BOOST_CHECK(!ParticleIdHelper::isInteracting(PdgParticle::eNeutrinoTau));
0092   // Anti-neutrinos should also be non-interacting
0093   BOOST_CHECK(!ParticleIdHelper::isInteracting(PdgParticle::eAntiNeutrinoE));
0094   BOOST_CHECK(!ParticleIdHelper::isInteracting(PdgParticle::eAntiNeutrinoMu));
0095   BOOST_CHECK(!ParticleIdHelper::isInteracting(PdgParticle::eAntiNeutrinoTau));
0096 
0097   // Test hadron types
0098   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(PdgParticle::eProton),
0099                     HadronType::LightBaryon);
0100   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(PdgParticle::ePionPlus),
0101                     HadronType::LightMeson);
0102   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(PdgParticle::eKaonPlus),
0103                     HadronType::StrangeMeson);
0104   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(PdgParticle::eElectron),
0105                     HadronType::Unknown);
0106 }
0107 
0108 BOOST_AUTO_TEST_CASE(MesonIdentification) {
0109   // BBbar mesons (bottomonium)
0110   constexpr Acts::PdgParticle eUpsilon1S = static_cast<Acts::PdgParticle>(553);
0111   BOOST_CHECK(ParticleIdHelper::isHadron(eUpsilon1S));
0112 
0113   constexpr Acts::PdgParticle eUpsilon2S =
0114       static_cast<Acts::PdgParticle>(100553);
0115   BOOST_CHECK(ParticleIdHelper::isHadron(eUpsilon2S));
0116 
0117   constexpr Acts::PdgParticle eUpsilon3S =
0118       static_cast<Acts::PdgParticle>(200553);
0119   BOOST_CHECK(ParticleIdHelper::isHadron(eUpsilon3S));
0120 
0121   constexpr Acts::PdgParticle eChiB = static_cast<Acts::PdgParticle>(10551);
0122   BOOST_CHECK(ParticleIdHelper::isHadron(eChiB));
0123 
0124   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(eUpsilon1S),
0125                     HadronType::BBbarMeson);
0126   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(eUpsilon2S),
0127                     HadronType::BBbarMeson);
0128   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(eUpsilon3S),
0129                     HadronType::BBbarMeson);
0130   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(eChiB),
0131                     HadronType::BBbarMeson);
0132 
0133   // CCbar mesons (charmonium)
0134   constexpr Acts::PdgParticle eJPsi = static_cast<Acts::PdgParticle>(443);
0135   BOOST_CHECK(ParticleIdHelper::isHadron(eJPsi));
0136 
0137   constexpr Acts::PdgParticle ePsi2S = static_cast<Acts::PdgParticle>(100443);
0138   BOOST_CHECK(ParticleIdHelper::isHadron(ePsi2S));
0139 
0140   constexpr Acts::PdgParticle eChiC = static_cast<Acts::PdgParticle>(10441);
0141   BOOST_CHECK(ParticleIdHelper::isHadron(eChiC));
0142 
0143   constexpr Acts::PdgParticle eEta_c = static_cast<Acts::PdgParticle>(441);
0144   BOOST_CHECK(ParticleIdHelper::isHadron(eEta_c));
0145 
0146   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(eJPsi),
0147                     HadronType::CCbarMeson);
0148   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(ePsi2S),
0149                     HadronType::CCbarMeson);
0150   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(eChiC),
0151                     HadronType::CCbarMeson);
0152   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(eEta_c),
0153                     HadronType::CCbarMeson);
0154 
0155   // B mesons (bottom quark)
0156   BOOST_CHECK(ParticleIdHelper::isHadron(PdgParticle::eB0));
0157   BOOST_CHECK(ParticleIdHelper::isHadron(PdgParticle::eBPlus));
0158   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(PdgParticle::eB0),
0159                     HadronType::BottomMeson);
0160   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(PdgParticle::eBPlus),
0161                     HadronType::BottomMeson);
0162 
0163   // D mesons (charm quark)
0164   BOOST_CHECK(ParticleIdHelper::isHadron(PdgParticle::eD0));
0165   BOOST_CHECK(ParticleIdHelper::isHadron(PdgParticle::eDPlus));
0166   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(PdgParticle::eD0),
0167                     HadronType::CharmedMeson);
0168   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(PdgParticle::eDPlus),
0169                     HadronType::CharmedMeson);
0170 
0171   // Strange mesons
0172   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(PdgParticle::eKaonPlus),
0173                     HadronType::StrangeMeson);
0174   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(PdgParticle::eKaonMinus),
0175                     HadronType::StrangeMeson);
0176 
0177   // Light mesons (pions)
0178   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(PdgParticle::ePionPlus),
0179                     HadronType::LightMeson);
0180   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(PdgParticle::ePionMinus),
0181                     HadronType::LightMeson);
0182   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(PdgParticle::ePionZero),
0183                     HadronType::LightMeson);
0184 
0185   // Test anti-particles have same hadron type
0186   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(PdgParticle::eB0),
0187                     ParticleIdHelper::hadronType(PdgParticle::eAntiB0));
0188   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(PdgParticle::eD0),
0189                     ParticleIdHelper::hadronType(PdgParticle::eAntiD0));
0190 }
0191 
0192 BOOST_AUTO_TEST_CASE(HeavyBaryonIdentification) {
0193   // Bottom baryons
0194   constexpr Acts::PdgParticle eLambdaB = static_cast<Acts::PdgParticle>(5122);
0195   BOOST_CHECK(ParticleIdHelper::isHadron(eLambdaB));
0196 
0197   constexpr Acts::PdgParticle eSigmaB = static_cast<Acts::PdgParticle>(5222);
0198   BOOST_CHECK(ParticleIdHelper::isHadron(eSigmaB));
0199 
0200   constexpr Acts::PdgParticle eXiB = static_cast<Acts::PdgParticle>(5322);
0201   BOOST_CHECK(ParticleIdHelper::isHadron(eXiB));
0202 
0203   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(eLambdaB),
0204                     HadronType::BottomBaryon);
0205   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(eSigmaB),
0206                     HadronType::BottomBaryon);
0207   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(eXiB),
0208                     HadronType::BottomBaryon);
0209 
0210   // Charmed baryons
0211   constexpr Acts::PdgParticle eLambdaC = static_cast<Acts::PdgParticle>(4122);
0212   BOOST_CHECK(ParticleIdHelper::isHadron(eLambdaC));
0213 
0214   constexpr Acts::PdgParticle eSigmaC = static_cast<Acts::PdgParticle>(4222);
0215   BOOST_CHECK(ParticleIdHelper::isHadron(eSigmaC));
0216 
0217   constexpr Acts::PdgParticle eXiC = static_cast<Acts::PdgParticle>(4322);
0218   BOOST_CHECK(ParticleIdHelper::isHadron(eXiC));
0219 
0220   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(eLambdaC),
0221                     HadronType::CharmedBaryon);
0222   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(eSigmaC),
0223                     HadronType::CharmedBaryon);
0224   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(eXiC),
0225                     HadronType::CharmedBaryon);
0226 
0227   // Test anti-particles have same hadron type
0228   constexpr Acts::PdgParticle eAntiLambdaB =
0229       static_cast<Acts::PdgParticle>(-5122);
0230   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(eLambdaB),
0231                     ParticleIdHelper::hadronType(eAntiLambdaB));
0232 
0233   constexpr Acts::PdgParticle eAntiLambdaC =
0234       static_cast<Acts::PdgParticle>(-4122);
0235   BOOST_CHECK_EQUAL(ParticleIdHelper::hadronType(eLambdaC),
0236                     ParticleIdHelper::hadronType(eAntiLambdaC));
0237 }
0238 
0239 BOOST_AUTO_TEST_SUITE_END()
0240 
0241 }  // namespace ActsTests