EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PhysicsListTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PhysicsListTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2018-2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/unit_test.hpp>
10 
13 #include "Acts/Utilities/Units.hpp"
16 
17 #include <random>
18 
19 using namespace Acts::UnitLiterals;
20 
21 namespace {
23 struct SterileProcess {
24  int some_parameter = 0;
25 
27  template <typename generator_t, typename detector_t, typename particle_t>
28  bool operator()(generator_t &, const detector_t &, particle_t &,
29  std::vector<particle_t> &) const {
30  return false;
31  }
32 };
33 
35 struct FatalProcess {
37  template <typename generator_t, typename detector_t, typename particle_t>
38  bool operator()(generator_t &, const detector_t &, particle_t &,
39  std::vector<particle_t> &) const {
40  return true;
41  }
42 };
43 
44 struct Fixture {
45  std::ranlux48 generator{23};
46  Acts::MaterialSlab slab =
48  ActsFatras::Particle inputParticle;
49 };
50 } // namespace
51 
52 BOOST_AUTO_TEST_SUITE(FatrasPhysicsList)
53 
55  Fixture fix;
56  ActsFatras::PhysicsList<> emptyList;
57  std::vector<ActsFatras::Particle> outgoing;
58 
59  // w/o processes the list should never abort
60  BOOST_CHECK(
61  not emptyList(fix.generator, fix.slab, fix.inputParticle, outgoing));
62 }
63 
64 BOOST_AUTO_TEST_CASE(SingleSterile) {
65  Fixture fix;
67  std::vector<ActsFatras::Particle> outgoing;
68 
69  // set some process parameters
70  sterileList.get<SterileProcess>().some_parameter = 2;
71  BOOST_CHECK_EQUAL(sterileList.get<SterileProcess>().some_parameter, 2);
72 
73  // sterile process should never abort
74  BOOST_CHECK(
75  not sterileList(fix.generator, fix.slab, fix.inputParticle, outgoing));
76 }
77 
78 BOOST_AUTO_TEST_CASE(SingleFatal) {
79  Fixture fix;
81  std::vector<ActsFatras::Particle> outgoing;
82 
83  // fatal process must always abort
84  BOOST_CHECK(fatalList(fix.generator, fix.slab, fix.inputParticle, outgoing));
85  // unless we disable it
86  fatalList.disable<FatalProcess>();
87  BOOST_CHECK(
88  not fatalList(fix.generator, fix.slab, fix.inputParticle, outgoing));
89 }
90 
91 BOOST_AUTO_TEST_CASE(SterileFatal) {
92  Fixture fix;
94  std::vector<ActsFatras::Particle> outgoing;
95 
96  // the contained fatal process must always abort
97  BOOST_CHECK(
98  physicsList(fix.generator, fix.slab, fix.inputParticle, outgoing));
99  // with the fatal process disabled, it should go through again
100  physicsList.disable<FatalProcess>();
101  BOOST_CHECK(
102  not physicsList(fix.generator, fix.slab, fix.inputParticle, outgoing));
103 }
104 
105 BOOST_AUTO_TEST_SUITE_END()