Analysis Software
Documentation for sPHENIX simulation 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 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 
10 #define BOOST_TEST_MODULE AbortList Tests
11 
12 #include <boost/test/included/unit_test.hpp>
13 // leave blank line
14 
15 #include <boost/test/data/test_case.hpp>
16 // leave blank line
17 
18 #include <boost/test/output_test_stream.hpp>
19 // leave blank line
20 
22 
23 namespace bdata = boost::unit_test::data;
24 namespace tt = boost::test_tools;
25 
26 namespace Fatras {
27 
28 namespace Test {
29 
31 struct Generator {};
32 
33 struct Detector {};
34 
35 struct Particle {};
36 
39 
40  int some_parameter = 0;
41 
43  template <typename generator_t, typename detector_t, typename particle_t>
44  bool operator()(generator_t &, const detector_t &, particle_t &,
45  std::vector<particle_t> &) const {
46  return false;
47  }
48 };
49 
51 struct FatalProcess {
52 
54  template <typename generator_t, typename detector_t, typename particle_t>
55  bool operator()(generator_t &, const detector_t &, particle_t &,
56  std::vector<particle_t> &) const {
57  return true;
58  }
59 };
60 
61 // This tests the implementation of the physics list
62 BOOST_AUTO_TEST_CASE(PhysicsLists_test) {
65  Particle in;
66  std::vector<Particle> out;
67 
69  typedef PhysicsList<> ProcessLess;
70  ProcessLess emptyList;
71 
73  BOOST_TEST(!emptyList(generator, detector, in, out));
74 
75  // now create a single sterile process
76  typedef PhysicsList<SterileProcess> SterileList;
77  SterileList sterileProcess;
78 
79  // try to set this parameter
80  auto &sp = sterileProcess.get<SterileProcess>();
81  sp.some_parameter = 2;
82  BOOST_TEST(sterileProcess.get<SterileProcess>().some_parameter == 2);
83 
85  BOOST_TEST(!sterileProcess(generator, detector, in, out));
86 
87  // now create a single fatal process
88  typedef PhysicsList<FatalProcess> FatalList;
89  FatalList fatalProcess;
90 
92  BOOST_TEST(fatalProcess(generator, detector, in, out));
93 
94  // now create a list of a sterile and fatal process
95  typedef PhysicsList<SterileProcess, FatalProcess> SterileFatalList;
96  SterileFatalList stfaProcess;
97 
99  BOOST_TEST(stfaProcess(generator, detector, in, out));
100 }
101 
102 } // namespace Test
103 } // namespace Fatras