Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:11:40

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2018-2021 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/data/test_case.hpp>
0010 #include <boost/test/unit_test.hpp>
0011 
0012 #include "Acts/Definitions/Algebra.hpp"
0013 #include "Acts/Definitions/Common.hpp"
0014 #include "Acts/Definitions/PdgParticle.hpp"
0015 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0016 #include "Acts/Tests/CommonHelpers/PredefinedMaterials.hpp"
0017 #include "ActsFatras/EventData/Particle.hpp"
0018 #include "ActsFatras/Physics/ElectroMagnetic/BetheHeitler.hpp"
0019 
0020 #include <array>
0021 #include <random>
0022 #include <utility>
0023 
0024 #include "Dataset.hpp"
0025 
0026 using Generator = std::ranlux48;
0027 
0028 BOOST_DATA_TEST_CASE(
0029     FatrasBetheHeitler,
0030     Dataset::momentumPhi* Dataset::momentumLambda* Dataset::momentumAbs ^
0031         Dataset::rngSeed,
0032     phi, lambda, p, seed) {
0033   Generator gen(seed);
0034   ActsFatras::Particle before =
0035       Dataset::makeParticle(Acts::PdgParticle::eElectron, phi, lambda, p);
0036   ActsFatras::Particle after = before;
0037 
0038   ActsFatras::BetheHeitler process;
0039   const auto outgoing = process(gen, Acts::Test::makeUnitSlab(), after);
0040   // energy loss changes momentum and energy
0041   BOOST_CHECK_LT(after.absoluteMomentum(), before.absoluteMomentum());
0042   BOOST_CHECK_LT(after.energy(), before.energy());
0043   // energy loss creates no new particles
0044   BOOST_CHECK_EQUAL(outgoing.size(), 1);
0045   BOOST_CHECK_GT(outgoing[0].absoluteMomentum(), 0.);
0046   BOOST_CHECK_EQUAL(outgoing[0].pathInX0(), 0.);
0047   BOOST_CHECK_EQUAL(outgoing[0].pathInL0(), 0.);
0048 
0049   // Get the four momenta
0050   Acts::Vector4 p0 = before.fourMomentum();
0051   Acts::Vector4 p1 = after.fourMomentum();
0052   Acts::Vector4 k = outgoing[0].fourMomentum();
0053 
0054   // Test for similar invariant masses
0055   Acts::Vector4 sum = p1 + k;
0056   double s = sum(Acts::eEnergy) * sum(Acts::eEnergy) -
0057              sum.template segment<3>(Acts::eMom0).norm() *
0058                  sum.template segment<3>(Acts::eMom0).norm();
0059   double s0 = p0(Acts::eEnergy) * p0(Acts::eEnergy) -
0060               p0.template segment<3>(Acts::eMom0).norm() *
0061                   p0.template segment<3>(Acts::eMom0).norm();
0062   CHECK_CLOSE_OR_SMALL(s, s0, 1e-2, 1e-2);
0063 }