diff --git a/tests/common/SetupStack.hpp b/tests/common/SetupStack.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e2bd85f2aeaa903f65854357d5a51834f43f0c57 --- /dev/null +++ b/tests/common/SetupStack.hpp @@ -0,0 +1,41 @@ +/* + * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#include <tests/common/TestStack.hpp> + +#include <array> +#include <memory> + +namespace corsika::test { + + // --------------------------------------- + // this is the stack we use in C8 executables: + +#ifdef WITH_HISTORY + +#include <corsika/stack/history/HistoryStackExtension.hpp> +#include <corsika/stack/history/HistorySecondaryProducer.hpp> + + /* + * the version with history + */ + using Stack = detaill::StackWithHistory; + +#else // WITH_HISTORY + + /* + * the version without history + */ + using Stack = detail::StackWithGeometry; + +#endif + + // the correct secondary stack view + using StackView = typename Stack::stack_view_type; + +} // namespace corsika::test \ No newline at end of file diff --git a/tests/common/SetupTestEnvironment.hpp b/tests/common/SetupTestEnvironment.hpp index 358ed6df265851c96198e8f013b03e71a3cae963..2be9f34d53ef3a71ea93730b10c426f98d9fdac7 100644 --- a/tests/common/SetupTestEnvironment.hpp +++ b/tests/common/SetupTestEnvironment.hpp @@ -18,43 +18,51 @@ #include <limits> -namespace corsika::setup::testing { +namespace corsika { - /** - * \function setup_environment - * - * standard environment for unit testing. - * - */ + using DummyEnvironmentInterface = + IMediumPropertyModel<IMagneticFieldModel<IMediumModel>>; + using DummyEnvironment = Environment<DummyEnvironmentInterface>; - inline std::tuple<std::unique_ptr<setup::Environment>, CoordinateSystemPtr const*, - setup::Environment::BaseNodeType*> - setup_environment(Code const vTargetCode, - MagneticFluxType const& BfieldZ = MagneticFluxType::zero()) { - - auto env = std::make_unique<setup::Environment>(); - auto& universe = *(env->getUniverse()); - CoordinateSystemPtr const& cs = env->getCoordinateSystem(); + namespace setup::testing { /** - * our world is a sphere at 0,0,0 with R=infty + * \function setup_environment + * + * standard environment for unit testing. + * */ - auto world = setup::Environment::createNode<Sphere>(Point{cs, 0_m, 0_m, 0_m}, 100_km); - /** - * construct suited environment medium model: - */ - using MyHomogeneousModel = MediumPropertyModel< - UniformMagneticField<HomogeneousMedium<setup::EnvironmentInterface>>>; + inline std::tuple<std::unique_ptr<DummyEnvironment>, CoordinateSystemPtr const*, + DummyEnvironment::BaseNodeType*> + setup_environment(Code const vTargetCode, + MagneticFluxType const& BfieldZ = MagneticFluxType::zero()) { + + auto env = std::make_unique<DummyEnvironment>(); + auto& universe = *(env->getUniverse()); + CoordinateSystemPtr const& cs = env->getCoordinateSystem(); + + /** + * our world is a sphere at 0,0,0 with R=infty + */ + auto world = DummyEnvironment::createNode<Sphere>(Point{cs, 0_m, 0_m, 0_m}, 100_km); + + /** + * construct suited environment medium model: + */ + using MyHomogeneousModel = MediumPropertyModel< + UniformMagneticField<HomogeneousMedium<DummyEnvironmentInterface>>>; + + world->setModelProperties<MyHomogeneousModel>( + Medium::AirDry1Atm, Vector(cs, 0_T, 0_T, BfieldZ), 1_kg / (1_m * 1_m * 1_m), + NuclearComposition(std::vector<Code>{vTargetCode}, std::vector<double>{1.})); - world->setModelProperties<MyHomogeneousModel>( - Medium::AirDry1Atm, Vector(cs, 0_T, 0_T, BfieldZ), 1_kg / (1_m * 1_m * 1_m), - NuclearComposition(std::vector<Code>{vTargetCode}, std::vector<double>{1.})); + DummyEnvironment::BaseNodeType* nodePtr = world.get(); + universe.addChild(std::move(world)); - setup::Environment::BaseNodeType* nodePtr = world.get(); - universe.addChild(std::move(world)); + return std::make_tuple(std::move(env), &cs, nodePtr); + } - return std::make_tuple(std::move(env), &cs, nodePtr); - } + } // namespace setup::testing -} // namespace corsika::setup::testing +} // namespace corsika diff --git a/tests/common/SetupTestStack.hpp b/tests/common/SetupTestStack.hpp index 476c99a54bcd2a5487b9d4cdee591e88607a3409..bbe30c312dcf982218ce67b9bb5437bde7fa04a3 100644 --- a/tests/common/SetupTestStack.hpp +++ b/tests/common/SetupTestStack.hpp @@ -11,8 +11,13 @@ #include <corsika/framework/geometry/Point.hpp> #include <corsika/framework/geometry/RootCoordinateSystem.hpp> #include <corsika/framework/geometry/Vector.hpp> +#include <corsika/framework/geometry/CoordinateSystem.hpp> -#include <corsika/setup/SetupStack.hpp> +#include <corsika/media/UniformMagneticField.hpp> +#include <corsika/media/MediumPropertyModel.hpp> +#include <corsika/media/HomogeneousMedium.hpp> +#include <tests/common/SetupStack.hpp> +#include <SetupStack.hpp> /** * \file SetupTestStack @@ -20,34 +25,42 @@ * standard stack setup for unit tests. */ -namespace corsika::setup::testing { - - /** - * \function setup_stack - * - * standard stack setup for unit tests. - * - * \return a tuple with element 0 being a Stack object filled with - * one particle, and element 1 the StackView on it. - */ - - inline std::tuple<std::unique_ptr<setup::Stack>, std::unique_ptr<setup::StackView>> - setup_stack(Code const vProjectileType, HEPEnergyType const vMomentum, - setup::Environment::BaseNodeType* const vNodePtr, - CoordinateSystemPtr const& cs) { - - auto stack = std::make_unique<setup::Stack>(); - - Point const origin(cs, {0_m, 0_m, 0_m}); - MomentumVector const pLab(cs, {vMomentum, 0_GeV, 0_GeV}); - HEPMassType const mass = get_mass(vProjectileType); - HEPEnergyType const Ekin = sqrt(vMomentum * vMomentum + mass * mass) - mass; - - auto particle = stack->addParticle( - std::make_tuple(vProjectileType, Ekin, pLab.normalized(), origin, 0_ns)); - particle.setNode(vNodePtr); - return std::make_tuple(std::move(stack), - std::make_unique<setup::StackView>(particle)); - } - -} // namespace corsika::setup::testing +namespace corsika { + + using DummyEnvironmentInterface = + IMediumPropertyModel<IMagneticFieldModel<IMediumModel>>; + using DummyEnvironment = Environment<DummyEnvironmentInterface>; + + namespace setup::testing { + + /** + * \function setup_stack + * + * standard stack setup for unit tests. + * + * \return a tuple with element 0 being a Stack object filled with + * one particle, and element 1 the StackView on it. + */ + + inline std::tuple<std::unique_ptr<test::Stack>, std::unique_ptr<test::StackView>> + setup_stack(Code const vProjectileType, HEPEnergyType const vMomentum, + DummyEnvironment::BaseNodeType* const vNodePtr, + CoordinateSystemPtr const& cs) { + + auto stack = std::make_unique<test::Stack>(); + + Point const origin(cs, {0_m, 0_m, 0_m}); + MomentumVector const pLab(cs, {vMomentum, 0_GeV, 0_GeV}); + HEPMassType const mass = get_mass(vProjectileType); + HEPEnergyType const Ekin = sqrt(vMomentum * vMomentum + mass * mass) - mass; + + auto particle = stack->addParticle( + std::make_tuple(vProjectileType, Ekin, pLab.normalized(), origin, 0_ns)); + particle.setNode(vNodePtr); + return std::make_tuple(std::move(stack), + std::make_unique<test::StackView>(particle)); + } + + } // namespace setup::testing + +} // namespace corsika \ No newline at end of file diff --git a/tests/common/TestStack.hpp b/tests/common/TestStack.hpp new file mode 100644 index 0000000000000000000000000000000000000000..299a0742964bbb42b442bc3cfac31d5fbad16ccf --- /dev/null +++ b/tests/common/TestStack.hpp @@ -0,0 +1,65 @@ +/* + * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#pragma once + +#include <corsika/framework/stack/CombinedStack.hpp> +#include <corsika/stack/GeometryNodeStackExtension.hpp> +#include <corsika/stack/VectorStack.hpp> +#include <corsika/stack/WeightStackExtension.hpp> +#include <corsika/stack/history/HistorySecondaryProducer.hpp> +#include <corsika/stack/history/HistoryStackExtension.hpp> + +#include <corsika/setup/SetupEnvironment.hpp> + +namespace corsika { + + // maybe use a similar copy of this file with defined templates for tests? + using DummyEnvironmentInterface = + IMediumPropertyModel<IMagneticFieldModel<IMediumModel>>; + using DummyEnvironment = Environment<DummyEnvironmentInterface>; + + namespace test::detail { + + // ------------------------------------------ + // add geometry node tracking data to stack: + + // the GeometryNode stack needs to know the type of geometry-nodes from the + // environment: + template <typename TStackIter> + using SetupGeometryDataInterface = + typename node::MakeGeometryDataInterface<TStackIter, DummyEnvironment>::type; + + // combine particle data stack with geometry information for tracking + template <typename TStackIter> + using StackWithGeometryInterface = + CombinedParticleInterface<VectorStack::pi_type, SetupGeometryDataInterface, + TStackIter>; + + using StackWithGeometry = + CombinedStack<typename VectorStack::stack_data_type, + node::GeometryData<DummyEnvironment>, StackWithGeometryInterface, + DefaultSecondaryProducer>; + + // ------------------------------------------ + // Add [optional] history data to stack, too: + + // combine dummy stack with geometry information for tracking + template <typename TStackIter> + using StackWithHistoryInterface = + CombinedParticleInterface<StackWithGeometry::pi_type, + history::HistoryEventDataInterface, TStackIter>; + + using StackWithHistory = + CombinedStack<typename StackWithGeometry::stack_data_type, + history::HistoryEventData, StackWithHistoryInterface, + history::HistorySecondaryProducer>; + + } // namespace test::detail + +} // namespace corsika \ No newline at end of file diff --git a/tests/modules/testCONEX.cpp b/tests/modules/testCONEX.cpp index 9596a8acab4bbed0f42a059d855488900e7e8b97..9b350f9dfcd7003150aadf307338adb21c2fd930 100644 --- a/tests/modules/testCONEX.cpp +++ b/tests/modules/testCONEX.cpp @@ -6,7 +6,7 @@ * the license. */ -#include <corsika/setup/SetupEnvironment.hpp> +#include <SetupTestEnvironment.hpp> #include <corsika/media/Environment.hpp> #include <corsika/media/LayeredSphericalAtmosphereBuilder.hpp> @@ -42,6 +42,9 @@ using namespace corsika; +using DummyEnvironmentInterface = IMediumPropertyModel<IMagneticFieldModel<IMediumModel>>; +using DummyEnvironment = Environment<DummyEnvironmentInterface>; + const std::string refDataDir = std::string(REFDATADIR); // from cmake template <typename T> @@ -60,16 +63,16 @@ TEST_CASE("CONEX") { feenableexcept(FE_INVALID); // setup environment, geometry - setup::Environment env; + DummyEnvironment env; CoordinateSystemPtr const& rootCS = env.getCoordinateSystem(); Point const center{rootCS, 0_m, 0_m, 0_m}; auto builder = make_layered_spherical_atmosphere_builder< - setup::EnvironmentInterface, MExtraEnvirnoment>::create(center, - corsika::conex::earthRadius, - Medium::AirDry1Atm, - Vector{rootCS, 0_T, 50_mT, - 0_T}); + DummyEnvironmentInterface, MExtraEnvirnoment>::create(center, + corsika::conex::earthRadius, + Medium::AirDry1Atm, + Vector{rootCS, 0_T, 50_mT, + 0_T}); builder.setNuclearComposition( {{Code::Nitrogen, Code::Oxygen}, diff --git a/tests/modules/testEpos.cpp b/tests/modules/testEpos.cpp index d0f13d94fa941ae6931b9874b43d208240d9b5ad..44168578652834f809cdf5106f0112c577b18687 100644 --- a/tests/modules/testEpos.cpp +++ b/tests/modules/testEpos.cpp @@ -13,6 +13,8 @@ #include <corsika/framework/geometry/Point.hpp> #include <corsika/framework/random/RNGManager.hpp> +#include <SetupTestEnvironment.hpp> + #include <catch2/catch.hpp> #include <tuple> @@ -29,6 +31,9 @@ using namespace corsika; using namespace corsika::epos; +using DummyEnvironmentInterface = IMediumPropertyModel<IMagneticFieldModel<IMediumModel>>; +using DummyEnvironment = Environment<DummyEnvironmentInterface>; + TEST_CASE("EposBasics", "module,process") { logging::set_level(logging::level::trace); @@ -284,10 +289,10 @@ TEST_CASE("Epos", "modules") { HEPEnergyType const P0 = 10_TeV; Code const pid = Code::Proton; auto [stack, viewPtr] = setup::testing::setup_stack( - pid, P0, (setup::Environment::BaseNodeType* const)nodePtr, cs); + pid, P0, (DummyEnvironment::BaseNodeType* const)nodePtr, cs); MomentumVector plab = MomentumVector(cs, {P0, 0_eV, 0_eV}); // this is secret knowledge about - setup::StackView& view = *viewPtr; + test::StackView& view = *viewPtr; // @todo This is very obscure since it fails for -O2, but for both clang and gcc ??? model.doInteraction(view, pid, Code::Oxygen, diff --git a/tests/modules/testObservationPlane.cpp b/tests/modules/testObservationPlane.cpp index 5432c0946fcb9c56dd509ee80b710dfdfd08c93e..0f006ac4040aee990b7abfa4647853349f4a5d2e 100644 --- a/tests/modules/testObservationPlane.cpp +++ b/tests/modules/testObservationPlane.cpp @@ -40,7 +40,7 @@ TEST_CASE("ObservationPlane", "interface") { ObservationPlane has origin at 10,0,0 and a normal in x-direction */ auto [stack, viewPtr] = setup::testing::setup_stack(Code::NuE, 1_GeV, nodePtr, cs); - [[maybe_unused]] setup::StackView& view = *viewPtr; + [[maybe_unused]] test::StackView& view = *viewPtr; auto particle = stack->getNextParticle(); // dummy track. Not used for calculation! diff --git a/tests/modules/testParticleCut.cpp b/tests/modules/testParticleCut.cpp index 3d3c7e666e6c29928a6880119ef267ec8cbc26c5..9915783274b1d93b7e2c2d139c778c199264c07c 100644 --- a/tests/modules/testParticleCut.cpp +++ b/tests/modules/testParticleCut.cpp @@ -18,24 +18,28 @@ #include <SetupTestStack.hpp> #include <SetupTestTrajectory.hpp> +#include <SetupTestEnvironment.hpp> #include <corsika/setup/SetupTrajectory.hpp> #include <catch2/catch.hpp> using namespace corsika; +using DummyEnvironmentInterface = IMediumPropertyModel<IMagneticFieldModel<IMediumModel>>; +using DummyEnvironment = Environment<DummyEnvironmentInterface>; + TEST_CASE("ParticleCut", "process,continuous,secondary") { logging::set_level(logging::level::info); feenableexcept(FE_INVALID); - using EnvType = setup::Environment; + using EnvType = DummyEnvironment; EnvType env; CoordinateSystemPtr const& rootCS = env.getCoordinateSystem(); // setup empty particle stack - setup::Stack stack; + test::Stack stack; stack.clear(); // two energies HEPEnergyType const Eabove = 1_TeV; @@ -60,7 +64,7 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") { std::make_tuple(Code::Proton, Eabove, DirectionVector(rootCS, {1, 0, 0}), Point(rootCS, 0_m, 0_m, 0_m), 0_ns)); // view on secondary particles - setup::StackView view(particle); + test::StackView view(particle); // ref. to primary particle through the secondary view. // only this way the secondary view is populated auto projectile = view.getProjectile(); @@ -85,7 +89,7 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") { auto particle = stack.addParticle(std::make_tuple( Code::Proton, Eabove, DirectionVector(rootCS, {1, 0, 0}), point0, 0_ns)); // view on secondary particles - setup::StackView view(particle); + test::StackView view(particle); // ref. to primary particle through the secondary view. // only this way the secondary view is populated auto projectile = view.getProjectile(); @@ -107,7 +111,7 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") { auto particle = stack.addParticle(std::make_tuple( Code::Proton, Eabove, DirectionVector(rootCS, {1, 0, 0}), point0, 0_ns)); // view on secondary particles - setup::StackView view(particle); + test::StackView view(particle); // ref. to primary particle through the secondary view. // only this way the secondary view is populated auto projectile = view.getProjectile(); @@ -137,7 +141,7 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") { DirectionVector(rootCS, {1, 0, 0}), point0, 0_ns)); // view on secondary particles - setup::StackView view(particle); + test::StackView view(particle); // ref. to primary particle through the secondary view. // only this way the secondary view is populated auto projectile = view.getProjectile(); @@ -180,7 +184,7 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") { auto particle = stack.addParticle(std::make_tuple( Code::Proton, Eabove, DirectionVector(rootCS, {1, 0, 0}), point0, too_late)); // view on secondary particles - setup::StackView view(particle); + test::StackView view(particle); // ref. to primary particle through the secondary view. // only this way the secondary view is populated auto projectile = view.getProjectile(); diff --git a/tests/modules/testPythia8.cpp b/tests/modules/testPythia8.cpp index d54324be5dc00409defa1fc183c2f545f5263350..f1b9892a51412ca963d0636726c97a449a1e00c7 100644 --- a/tests/modules/testPythia8.cpp +++ b/tests/modules/testPythia8.cpp @@ -20,6 +20,9 @@ using namespace corsika; +using DummyEnvironmentInterface = IMediumPropertyModel<IMagneticFieldModel<IMediumModel>>; +using DummyEnvironment = Environment<DummyEnvironmentInterface>; + TEST_CASE("Pythia8", "modules") { logging::set_level(logging::level::info); @@ -106,7 +109,7 @@ TEST_CASE("Pythia8Interface", "modules") { SECTION("pythia decay") { HEPEnergyType const P0 = 10_GeV; auto [stackPtr, secViewPtr] = setup::testing::setup_stack( - Code::PiPlus, P0, (setup::Environment::BaseNodeType* const)nodePtr, *csPtr); + Code::PiPlus, P0, (DummyEnvironment::BaseNodeType* const)nodePtr, *csPtr); auto& stack = *stackPtr; auto& view = *secViewPtr; @@ -166,7 +169,7 @@ TEST_CASE("Pythia8Interface", "modules") { // this will be a p-p collision at sqrts=3.5TeV -> no problem for pythia auto [stackPtr, secViewPtr] = setup::testing::setup_stack( - Code::Proton, 7_TeV, (setup::Environment::BaseNodeType* const)nodePtr, *csPtr); + Code::Proton, 7_TeV, (DummyEnvironment::BaseNodeType* const)nodePtr, *csPtr); auto& view = *secViewPtr; corsika::pythia8::Interaction collision; @@ -200,7 +203,7 @@ TEST_CASE("Pythia8Interface", "modules") { // this is a projectile neutron with very little energy auto [stackPtr, secViewPtr] = setup::testing::setup_stack( - Code::Neutron, 1_GeV, (setup::Environment::BaseNodeType* const)nodePtr, *csPtr); + Code::Neutron, 1_GeV, (DummyEnvironment::BaseNodeType* const)nodePtr, *csPtr); auto& view = *secViewPtr; corsika::pythia8::Interaction collision; @@ -224,7 +227,7 @@ TEST_CASE("Pythia8Interface", "modules") { // resonable projectile, but tool low energy auto [stackPtr, secViewPtr] = setup::testing::setup_stack( - Code::Proton, 1_GeV, (setup::Environment::BaseNodeType* const)nodePtr_Fe, + Code::Proton, 1_GeV, (DummyEnvironment::BaseNodeType* const)nodePtr_Fe, *csPtr_Fe); auto& view = *secViewPtr; { [[maybe_unused]] auto const& dummy_StackPtr = stackPtr; } @@ -250,7 +253,7 @@ TEST_CASE("Pythia8Interface", "modules") { // resonable projectile, but tool low energy auto [stackPtr, secViewPtr] = setup::testing::setup_stack( - Code::Iron, 1_GeV, (setup::Environment::BaseNodeType* const)nodePtr, *csPtr); + Code::Iron, 1_GeV, (DummyEnvironment::BaseNodeType* const)nodePtr, *csPtr); { [[maybe_unused]] auto const& dummy_StackPtr = stackPtr; } corsika::pythia8::Interaction collision; diff --git a/tests/modules/testQGSJetII.cpp b/tests/modules/testQGSJetII.cpp index f39fecc1f04159cb3f405a005bf03d55d3a66f27..9f3e685801b9b70b347dddb43506a8b063eae55c 100644 --- a/tests/modules/testQGSJetII.cpp +++ b/tests/modules/testQGSJetII.cpp @@ -13,6 +13,8 @@ #include <corsika/framework/geometry/Point.hpp> #include <corsika/framework/random/RNGManager.hpp> +#include <SetupTestEnvironment.hpp> + #include <catch2/catch.hpp> #include <string> @@ -31,6 +33,9 @@ using namespace corsika; +using DummyEnvironmentInterface = IMediumPropertyModel<IMagneticFieldModel<IMediumModel>>; +using DummyEnvironment = Environment<DummyEnvironmentInterface>; + template <typename TStackView> auto sumCharge(TStackView const& view) { int totalCharge = 0; @@ -136,8 +141,8 @@ TEST_CASE("QgsjetIIInterface", "interaction,processes") { SECTION("InteractionInterface") { auto [stackPtr, secViewPtr] = setup::testing::setup_stack( - Code::Proton, 110_GeV, (setup::Environment::BaseNodeType* const)nodePtr, *csPtr); - setup::StackView& view = *(secViewPtr.get()); + Code::Proton, 110_GeV, (DummyEnvironment::BaseNodeType* const)nodePtr, *csPtr); + test::StackView& view = *(secViewPtr.get()); auto projectile = secViewPtr->getProjectile(); auto const projectileMomentum = projectile.getMomentum(); @@ -168,8 +173,8 @@ TEST_CASE("QgsjetIIInterface", "interaction,processes") { MomentumVector const plab = MomentumVector(cs, {P0, 0_eV, 0_eV}); Code const pid = get_nucleus_code(60, 30); auto [stackPtr, secViewPtr] = setup::testing::setup_stack( - pid, P0, (setup::Environment::BaseNodeType* const)nodePtr, *csPtr); - setup::StackView& view = *(secViewPtr.get()); + pid, P0, (DummyEnvironment::BaseNodeType* const)nodePtr, *csPtr); + test::StackView& view = *(secViewPtr.get()); HEPEnergyType const Elab = sqrt(static_pow<2>(P0) + static_pow<2>(get_mass(pid))); FourMomentum const projectileP4(Elab, plab); @@ -189,8 +194,8 @@ TEST_CASE("QgsjetIIInterface", "interaction,processes") { auto [stackPtr, secViewPtr] = setup::testing::setup_stack( get_nucleus_code(1000, 1000), 1100_GeV, - (setup::Environment::BaseNodeType* const)nodePtr, *csPtr); - setup::StackView& view = *(secViewPtr.get()); + (DummyEnvironment::BaseNodeType* const)nodePtr, *csPtr); + test::StackView& view = *(secViewPtr.get()); auto projectile = secViewPtr->getProjectile(); auto const projectileMomentum = projectile.getMomentum(); @@ -213,8 +218,8 @@ TEST_CASE("QgsjetIIInterface", "interaction,processes") { { // pi0 is internally converted into pi+/pi- auto [stackPtr, secViewPtr] = setup::testing::setup_stack( - Code::Pi0, 1000_GeV, (setup::Environment::BaseNodeType* const)nodePtr, *csPtr); - [[maybe_unused]] setup::StackView& view = *(secViewPtr.get()); + Code::Pi0, 1000_GeV, (DummyEnvironment::BaseNodeType* const)nodePtr, *csPtr); + [[maybe_unused]] test::StackView& view = *(secViewPtr.get()); [[maybe_unused]] auto particle = stackPtr->first(); corsika::qgsjetII::InteractionModel model; model.doInteraction(view, Code::Pi0, Code::Oxygen, @@ -225,8 +230,8 @@ TEST_CASE("QgsjetIIInterface", "interaction,processes") { } { // rho0 is internally converted into pi-/pi+ auto [stackPtr, secViewPtr] = setup::testing::setup_stack( - Code::Rho0, 1000_GeV, (setup::Environment::BaseNodeType* const)nodePtr, *csPtr); - [[maybe_unused]] setup::StackView& view = *(secViewPtr.get()); + Code::Rho0, 1000_GeV, (DummyEnvironment::BaseNodeType* const)nodePtr, *csPtr); + [[maybe_unused]] test::StackView& view = *(secViewPtr.get()); [[maybe_unused]] auto particle = stackPtr->first(); corsika::qgsjetII::InteractionModel model; model.doInteraction(view, Code::Rho0, Code::Oxygen, @@ -237,9 +242,8 @@ TEST_CASE("QgsjetIIInterface", "interaction,processes") { } { // Lambda is internally converted into neutron auto [stackPtr, secViewPtr] = setup::testing::setup_stack( - Code::Lambda0, 100_GeV, (setup::Environment::BaseNodeType* const)nodePtr, - *csPtr); - [[maybe_unused]] setup::StackView& view = *(secViewPtr.get()); + Code::Lambda0, 100_GeV, (DummyEnvironment::BaseNodeType* const)nodePtr, *csPtr); + [[maybe_unused]] test::StackView& view = *(secViewPtr.get()); [[maybe_unused]] auto particle = stackPtr->first(); corsika::qgsjetII::InteractionModel model; model.doInteraction(view, Code::Lambda0, Code::Oxygen, @@ -250,9 +254,9 @@ TEST_CASE("QgsjetIIInterface", "interaction,processes") { } { // AntiLambda is internally converted into anti neutron auto [stackPtr, secViewPtr] = setup::testing::setup_stack( - Code::Lambda0Bar, 1000_GeV, (setup::Environment::BaseNodeType* const)nodePtr, + Code::Lambda0Bar, 1000_GeV, (DummyEnvironment::BaseNodeType* const)nodePtr, *csPtr); - [[maybe_unused]] setup::StackView& view = *(secViewPtr.get()); + [[maybe_unused]] test::StackView& view = *(secViewPtr.get()); [[maybe_unused]] auto particle = stackPtr->first(); corsika::qgsjetII::InteractionModel model; model.doInteraction(view, Code::Lambda0Bar, Code::Oxygen, diff --git a/tests/modules/testSibyll.cpp b/tests/modules/testSibyll.cpp index c0e07be86cb0410a2f4f6d13b2cd55b00934cc3a..a4dbdd4a1a1c1113dc037f93b72361a3e5107460 100644 --- a/tests/modules/testSibyll.cpp +++ b/tests/modules/testSibyll.cpp @@ -15,6 +15,7 @@ #include <corsika/framework/random/RNGManager.hpp> #include <corsika/framework/utility/COMBoost.hpp> +#include <SetupTestEnvironment.hpp> #include <catch2/catch.hpp> #include <tuple> @@ -31,6 +32,9 @@ using namespace corsika; using namespace corsika::sibyll; +using DummyEnvironmentInterface = IMediumPropertyModel<IMagneticFieldModel<IMediumModel>>; +using DummyEnvironment = Environment<DummyEnvironmentInterface>; + TEST_CASE("Sibyll", "modules") { logging::set_level(logging::level::info); @@ -110,8 +114,8 @@ TEST_CASE("SibyllInterface", "modules") { { [[maybe_unused]] auto const& env_dummy = env; } auto [stack, viewPtr] = setup::testing::setup_stack( - Code::Proton, 10_GeV, (setup::Environment::BaseNodeType* const)nodePtr, cs); - setup::StackView& view = *viewPtr; + Code::Proton, 10_GeV, (DummyEnvironment::BaseNodeType* const)nodePtr, cs); + test::StackView& view = *viewPtr; RNGManager<>::getInstance().registerRandomStream("sibyll"); @@ -304,8 +308,8 @@ TEST_CASE("SibyllDecayInterface", "modules") { SECTION("DecayInterface") { auto [stackPtr, viewPtr] = setup::testing::setup_stack( - Code::Lambda0, 10_GeV, (setup::Environment::BaseNodeType* const)nodePtr, cs); - setup::StackView& view = *viewPtr; + Code::Lambda0, 10_GeV, (DummyEnvironment::BaseNodeType* const)nodePtr, cs); + test::StackView& view = *viewPtr; auto& stack = *stackPtr; auto particle = stack.first(); @@ -323,8 +327,8 @@ TEST_CASE("SibyllDecayInterface", "modules") { SECTION("DecayInterface - decay not handled") { // sibyll does not know the higgs for example auto [stackPtr, viewPtr] = setup::testing::setup_stack( - Code::H0, 10_GeV, (setup::Environment::BaseNodeType* const)nodePtr, cs); - setup::StackView& view = *viewPtr; + Code::H0, 10_GeV, (DummyEnvironment::BaseNodeType* const)nodePtr, cs); + test::StackView& view = *viewPtr; auto& stack = *stackPtr; auto particle = stack.first(); diff --git a/tests/modules/testTracking.cpp b/tests/modules/testTracking.cpp index 02de4348240275c04000b69b10aa5eff08131558..8479ccb5300ad226fa6a571a5523c8c5575428b1 100644 --- a/tests/modules/testTracking.cpp +++ b/tests/modules/testTracking.cpp @@ -24,6 +24,9 @@ using namespace corsika; +using DummyEnvironmentInterface = IMediumPropertyModel<IMagneticFieldModel<IMediumModel>>; +using DummyEnvironment = Environment<DummyEnvironmentInterface>; + struct NonExistingDummyObject : public IVolume { NonExistingDummyObject const& getVolume() const { return *this; } bool contains(Point const&) const { return false; } @@ -114,28 +117,28 @@ TEMPLATE_TEST_CASE("Tracking", "tracking", tracking_leapfrog_curved::Tracking, TestType tracking; Point const center(cs, {0_m, 0_m, 0_m}); - auto target = setup::Environment::createNode<Sphere>(center, radius); + auto target = DummyEnvironment::createNode<Sphere>(center, radius); // every particle should hit target_2 // it is very close to injection and not so small - auto target_2 = setup::Environment::createNode<Sphere>( + auto target_2 = DummyEnvironment::createNode<Sphere>( Point(cs, {-radius * 3 / 4, 0_m, 0_m}), radius * 0.2); // only neutral particles hit_target_neutral // this is far from injection and really small - auto target_neutral = setup::Environment::createNode<Sphere>( + auto target_neutral = DummyEnvironment::createNode<Sphere>( Point(cs, {radius / 2, 0_m, 0_m}), radius * 0.1); // target to be overlapped entirely by target_2 - auto target_2_behind = setup::Environment::createNode<Sphere>( + auto target_2_behind = DummyEnvironment::createNode<Sphere>( Point(cs, {-radius * 3 / 4, 0_m, 0_m}), radius * 0.1); // target to be overlapped partly by target_2 - auto target_2_partly_behind = setup::Environment::createNode<Sphere>( + auto target_2_partly_behind = DummyEnvironment::createNode<Sphere>( Point(cs, {-radius * 3 / 4 + radius * 0.1, 0_m, 0_m}), radius * 0.2); using MyHomogeneousModel = MediumPropertyModel< - UniformMagneticField<HomogeneousMedium<setup::EnvironmentInterface>>>; + UniformMagneticField<HomogeneousMedium<DummyEnvironmentInterface>>>; MagneticFieldVector magneticfield(cs, 0_T, 0_T, Bfield); target->setModelProperties<MyHomogeneousModel>( @@ -244,7 +247,7 @@ TEST_CASE("TrackingLeapFrogCurved") { corsika::Code PID = Code::MuPlus; using MyHomogeneousModel = MediumPropertyModel< - UniformMagneticField<HomogeneousMedium<setup::EnvironmentInterface>>>; + UniformMagneticField<HomogeneousMedium<DummyEnvironmentInterface>>>; SECTION("infinite sphere / universe") { @@ -281,7 +284,7 @@ TEST_CASE("TrackingLeapFrogCurved") { tracking_leapfrog_curved::Tracking tracking; Point const center(cs, {0_m, 0_m, 0_m}); - auto target = setup::Environment::createNode<Sphere>(center, 10_km); + auto target = DummyEnvironment::createNode<Sphere>(center, 10_km); MagneticFieldVector magneticfield(cs, 100_T, 0_T, 0_uT); target->setModelProperties<MyHomogeneousModel>( diff --git a/tests/modules/testUrQMD.cpp b/tests/modules/testUrQMD.cpp index 10f5954330887a57a09c7b4095311c99849feb31..62c285c53f75e55c1a29727d25092aa71a07113f 100644 --- a/tests/modules/testUrQMD.cpp +++ b/tests/modules/testUrQMD.cpp @@ -42,6 +42,9 @@ using namespace corsika; using namespace corsika::urqmd; +using DummyEnvironmentInterface = IMediumPropertyModel<IMagneticFieldModel<IMediumModel>>; +using DummyEnvironment = Environment<DummyEnvironmentInterface>; + template <typename TStackView> auto sumCharge(TStackView const& view) { int totalCharge = 0; @@ -120,7 +123,7 @@ TEST_CASE("UrQMD") { [[maybe_unused]] auto const& node_dummy = nodePtr; // against warnings auto [stackPtr, secViewPtr] = setup::testing::setup_stack( - Code::PiPlus, 40_GeV, (setup::Environment::BaseNodeType* const)nodePtr, *csPtr); + Code::PiPlus, 40_GeV, (DummyEnvironment::BaseNodeType* const)nodePtr, *csPtr); // must be assigned to variable, cannot be used as rvalue?! auto projectile = secViewPtr->getProjectile(); @@ -147,7 +150,7 @@ TEST_CASE("UrQMD") { [[maybe_unused]] auto const& node_dummy = nodePtr; // against warnings auto [stackPtr, secViewPtr] = setup::testing::setup_stack( - Code::K0Long, 40_GeV, (setup::Environment::BaseNodeType* const)nodePtr, *csPtr); + Code::K0Long, 40_GeV, (DummyEnvironment::BaseNodeType* const)nodePtr, *csPtr); CHECK(stackPtr->getEntries() == 1); CHECK(secViewPtr->getEntries() == 0);