diff --git a/tests/common/SetupTestEnvironment.hpp b/tests/common/SetupTestEnvironment.hpp index 358ed6df265851c96198e8f013b03e71a3cae963..e1ab056d466b8f292daf9ec7b0005e01be9d8529 100644 --- a/tests/common/SetupTestEnvironment.hpp +++ b/tests/common/SetupTestEnvironment.hpp @@ -18,43 +18,52 @@ #include <limits> -namespace corsika::setup::testing { +namespace corsika { - /** + using DummyEnvironmentInterface = IMediumPropertyModel<IMagneticFieldModel<IMediumModel>>; + using DummyEnvironment = Environment<DummyEnvironmentInterface>; + + + namespace setup::testing { + + /** * \function setup_environment * * standard environment for unit testing. * - */ + */ - inline std::tuple<std::unique_ptr<setup::Environment>, CoordinateSystemPtr const*, - setup::Environment::BaseNodeType*> - setup_environment(Code const vTargetCode, - MagneticFluxType const& BfieldZ = MagneticFluxType::zero()) { + 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<setup::Environment>(); - auto& universe = *(env->getUniverse()); - CoordinateSystemPtr const& cs = env->getCoordinateSystem(); + 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 = setup::Environment::createNode<Sphere>(Point{cs, 0_m, 0_m, 0_m}, 100_km); + */ + 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<setup::EnvironmentInterface>>>; + */ + 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..b3fe64f48c7a0376c67b81dbc646d3d5c037f4a6 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,41 @@ * standard stack setup for unit tests. */ -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) { - 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<test::Stack>(); - 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; - 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)); + } - 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 setup::testing -} // namespace corsika::setup::testing +} // namespace corsika \ No newline at end of file