Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ProcessTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ProcessTests.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 
21 #include "Acts/Utilities/Definitions.hpp"
25 #include "Particle.hpp"
26 #include <algorithm>
27 #include <random>
28 
29 namespace bdata = boost::unit_test::data;
30 namespace tt = boost::test_tools;
31 
32 namespace Fatras {
33 
34 namespace Test {
35 
37 typedef std::mt19937 Generator;
38 
40 struct Detector {};
41 
43 struct Selector {
44 
46  template <typename detector_t, typename particle_t>
47  bool operator()(const detector_t &, const particle_t &) const {
48  return true;
49  }
50 };
51 
54 
55  // constant 10 percent of enery loss
56  double cvalue = 0.90;
57 
58  template <typename generator_t, typename detector_t, typename particle_t>
59  std::vector<particle_t> operator()(generator_t &, const detector_t &,
60  particle_t &in) const {
61 
62  in.energyLoss((1. - cvalue) * in.E());
63  return {};
64  }
65 };
66 
69  Process_test_,
70  bdata::random(
71  (bdata::seed = 20,
72  bdata::distribution = std::uniform_real_distribution<>(0., 1.))) ^
73  bdata::random(
74  (bdata::seed = 21,
75  bdata::distribution = std::uniform_real_distribution<>(0., 1.))) ^
76  bdata::random(
77  (bdata::seed = 22,
78  bdata::distribution = std::uniform_real_distribution<>(0., 1.))) ^
79  bdata::random((
80  bdata::seed = 23,
81  bdata::distribution = std::uniform_real_distribution<>(1., 100.))) ^
82  bdata::xrange(100),
83  x, y, z, p, index) {
84  // standard generator
86 
87  // Dummy detctor
89 
90  // create the particle and set the momentum
92  Acts::Vector3D position{0., 0., 0.};
93  // pT of 1 GeV
94  Acts::Vector3D momentum =
95  p * Acts::units::_GeV * Acts::Vector3D(x, y, z).normalized();
96  // positively charged
97  double q = 1.;
98  double m = 105.658367 * Acts::units::_MeV; // muon mass
99 
100  // create the particle
101  Particle particle(position, momentum, m, q, 13, 1);
102 
103  // outgoing particles (always none for scattering)
104  std::vector<Particle> outgoing;
105 
106  // T"{he select all list
107  typedef SelectorListAND<Selector> All;
108  typedef Process<EnergyDecreaser, All, All, All> EnergyLoss;
109  EnergyLoss cEnergyLoss;
110 
111  // energy loss is not allowed to throw abort command
112  BOOST_CHECK(!cEnergyLoss(generator, detector, particle, outgoing));
113 
114  // check the the particle momentum magnitude is NOT identical
115  BOOST_CHECK(momentum.norm() != particle.momentum().norm());
116 
117  // let's test this as part of a physics list
118  PhysicsList<EnergyLoss> energyLossPhysics;
119 
120  // scattering is not allowed to throw abort command
121  BOOST_CHECK(!energyLossPhysics(generator, detector, particle, outgoing));
122 }
123 
124 } // namespace Test
125 } // namespace Fatras