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 AbortList 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 "Fatras/Kernel/PhysicsList.hpp"
0022 
0023 namespace bdata = boost::unit_test::data;
0024 namespace tt = boost::test_tools;
0025 
0026 namespace Fatras {
0027 
0028 namespace Test {
0029 
0030 /// needed are :  generator, detector, particle
0031 struct Generator {};
0032 
0033 struct Detector {};
0034 
0035 struct Particle {};
0036 
0037 /// Physics process that does not trigger a break
0038 struct SterileProcess {
0039 
0040   int some_parameter = 0;
0041 
0042   /// call operator
0043   template <typename generator_t, typename detector_t, typename particle_t>
0044   bool operator()(generator_t &, const detector_t &, particle_t &,
0045                   std::vector<particle_t> &) const {
0046     return false;
0047   }
0048 };
0049 
0050 /// Physics process that DOES trigger a break
0051 struct FatalProcess {
0052 
0053   /// call operator
0054   template <typename generator_t, typename detector_t, typename particle_t>
0055   bool operator()(generator_t &, const detector_t &, particle_t &,
0056                   std::vector<particle_t> &) const {
0057     return true;
0058   }
0059 };
0060 
0061 // This tests the implementation of the physics list
0062 BOOST_AUTO_TEST_CASE(PhysicsLists_test) {
0063   Generator generator;
0064   Detector detector;
0065   Particle in;
0066   std::vector<Particle> out;
0067 
0068   /// empty physics_list
0069   typedef PhysicsList<> ProcessLess;
0070   ProcessLess emptyList;
0071 
0072   /// sterile test should never send the abort command
0073   BOOST_TEST(!emptyList(generator, detector, in, out));
0074 
0075   // now create a single sterile process
0076   typedef PhysicsList<SterileProcess> SterileList;
0077   SterileList sterileProcess;
0078 
0079   // try to set this parameter
0080   auto &sp = sterileProcess.get<SterileProcess>();
0081   sp.some_parameter = 2;
0082   BOOST_TEST(sterileProcess.get<SterileProcess>().some_parameter == 2);
0083 
0084   /// sterile test should not send the abort command
0085   BOOST_TEST(!sterileProcess(generator, detector, in, out));
0086 
0087   // now create a single fatal process
0088   typedef PhysicsList<FatalProcess> FatalList;
0089   FatalList fatalProcess;
0090 
0091   /// fatal test should send  abort command
0092   BOOST_TEST(fatalProcess(generator, detector, in, out));
0093 
0094   // now create a list of a sterile and fatal process
0095   typedef PhysicsList<SterileProcess, FatalProcess> SterileFatalList;
0096   SterileFatalList stfaProcess;
0097 
0098   /// fatal test should send  abort command
0099   BOOST_TEST(stfaProcess(generator, detector, in, out));
0100 }
0101 
0102 } // namespace Test
0103 } // namespace Fatras