Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:09:25

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2018 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 ///  Boost include(s)
0010 #define BOOST_TEST_MODULE KinemtaicCast Tests
0011 
0012 #include <boost/test/included/unit_test.hpp>
0013 // leave blank line
0014 
0015 #include <boost/test/data/test_case.hpp>
0016 // leave blank line
0017 
0018 #include <boost/test/output_test_stream.hpp>
0019 // leave blank line
0020 
0021 #include "Acts/Utilities/Units.hpp"
0022 #include "Fatras/Selectors/KinematicCasts.hpp"
0023 #include "Fatras/Selectors/SelectorHelpers.hpp"
0024 #include "Particle.hpp"
0025 
0026 namespace bdata = boost::unit_test::data;
0027 namespace tt = boost::test_tools;
0028 
0029 namespace Fatras {
0030 
0031 namespace Test {
0032 
0033 struct Detector {};
0034 
0035 double m_pion = 134.9766 * Acts::units::_MeV; // pi0 rest mass
0036 
0037 // This tests the implementation of kinematic cast operators
0038 BOOST_AUTO_TEST_CASE(SelectorHelper_tests) {
0039 
0040   Detector detector;
0041 
0042   Acts::Vector3D position(0., 0., 0.);
0043   Acts::Vector3D momentumCast(1500. * Acts::units::_MeV, 0., 0.);
0044 
0045   // e central electron
0046   Particle pionCast(position, momentumCast, m_pion, -1.);
0047   Acts::Vector3D positionForward(0., 0., 100. * Acts::units::_mm);
0048   Acts::Vector3D momentumForward(10. * Acts::units::_MeV,
0049                                  10. * Acts::units::_MeV,
0050                                  1500. * Acts::units::_MeV);
0051 
0052   Particle pionForward(positionForward, momentumForward, m_pion, -1.);
0053 
0054   Acts::Vector3D positionBackward(0., 0., 0.);
0055   Acts::Vector3D momentumBackward(10. * Acts::units::_MeV,
0056                                   10. * Acts::units::_MeV,
0057                                   -1500. * Acts::units::_MeV);
0058 
0059   Particle pionBackward(positionBackward, momentumBackward, m_pion, -1.);
0060 
0061   // the list of possible casts
0062   casts::eta etaCast;
0063   casts::absEta etaAbsCast;
0064 
0065   // A minimum of 0.5 Eta is required
0066   Min<casts::eta> minEta05;
0067   minEta05.valMin = 0.5;
0068 
0069   Min<casts::absEta> minEtaAbs05;
0070   minEtaAbs05.valMin = 0.5;
0071 
0072   // the central will fail both
0073   BOOST_CHECK(!minEta05(detector, pionCast));
0074   BOOST_CHECK(!minEtaAbs05(detector, pionCast));
0075 
0076   // the forward will satisfy both
0077   BOOST_CHECK(minEta05(detector, pionForward));
0078   BOOST_CHECK(minEtaAbs05(detector, pionForward));
0079 
0080   // A maximum of 0.5 Eta is required
0081   Max<casts::eta> maxEta05;
0082   maxEta05.valMax = 0.5;
0083 
0084   // the central will satisfy both
0085   BOOST_CHECK(maxEta05(detector, pionCast));
0086   BOOST_CHECK(maxEta05(detector, pionCast));
0087 
0088   // the forward will fail both
0089   BOOST_CHECK(!maxEta05(detector, pionForward));
0090   BOOST_CHECK(!maxEta05(detector, pionForward));
0091 
0092   // a range test
0093   Range<casts::eta> rangeEtaM0;
0094   rangeEtaM0.valMin = -6.;
0095   rangeEtaM0.valMax = -0.5;
0096 
0097   Range<casts::absEta> rangeEtaM1;
0098   rangeEtaM1.valMin = -6.;
0099   rangeEtaM1.valMax = -0.5;
0100 
0101   // the central will fail both
0102   BOOST_CHECK(!rangeEtaM0(detector, pionCast));
0103   BOOST_CHECK(!rangeEtaM1(detector, pionCast));
0104 
0105   // the forward will fail both
0106   BOOST_CHECK(!rangeEtaM0(detector, pionForward));
0107   BOOST_CHECK(!rangeEtaM1(detector, pionForward));
0108 
0109   // the backeard will satsify the eta cast, not the abs(eta)
0110   BOOST_CHECK(rangeEtaM0(detector, pionBackward));
0111   BOOST_CHECK(!rangeEtaM1(detector, pionBackward));
0112 }
0113 
0114 } // namespace Test
0115 } // namespace Fatras