From 61691cdcf1b27e0b1f902971190fd8a462a5be19 Mon Sep 17 00:00:00 2001 From: Felix Riehn <felix@matilda> Date: Sat, 29 Dec 2018 14:32:28 +0000 Subject: [PATCH] added field for Environment to Sibyll process --- Documentation/Examples/cascade_example.cc | 2 +- Processes/Sibyll/CMakeLists.txt | 1 + Processes/Sibyll/Interaction.h | 8 +++++-- Processes/Sibyll/testSibyll.cc | 29 ++++++++++++++++++++--- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/Documentation/Examples/cascade_example.cc b/Documentation/Examples/cascade_example.cc index 49e2c11b7..2e375024c 100644 --- a/Documentation/Examples/cascade_example.cc +++ b/Documentation/Examples/cascade_example.cc @@ -226,7 +226,7 @@ int main() { // setup processes, decays and interactions tracking_line::TrackingLine<setup::Stack> tracking(env); stack_inspector::StackInspector<setup::Stack> p0(true); - corsika::process::sibyll::Interaction sibyll; + corsika::process::sibyll::Interaction sibyll(env); corsika::process::sibyll::Decay decay; ProcessCut cut(8_GeV); corsika::process::TrackWriter::TrackWriter trackWriter("tracks.dat"); diff --git a/Processes/Sibyll/CMakeLists.txt b/Processes/Sibyll/CMakeLists.txt index ab8f9b3e0..bf89db756 100644 --- a/Processes/Sibyll/CMakeLists.txt +++ b/Processes/Sibyll/CMakeLists.txt @@ -69,6 +69,7 @@ target_link_libraries ( CORSIKAunits CORSIKAthirdparty CORSIKAgeometry + CORSIKAenvironment ) target_include_directories ( diff --git a/Processes/Sibyll/Interaction.h b/Processes/Sibyll/Interaction.h index fac0dd578..23156dbb9 100644 --- a/Processes/Sibyll/Interaction.h +++ b/Processes/Sibyll/Interaction.h @@ -21,6 +21,7 @@ #include <corsika/particles/ParticleProperties.h> #include <corsika/random/RNGManager.h> #include <corsika/units/PhysicalUnits.h> +#include <corsika/environment/Environment.h> namespace corsika::process::sibyll { @@ -28,9 +29,8 @@ namespace corsika::process::sibyll { int fCount = 0; int fNucCount = 0; - public: - Interaction() {} + Interaction(corsika::environment::Environment const& env) : fEnvironment(env) { } ~Interaction() { std::cout << "Sibyll::Interaction n=" << fCount << " Nnuc=" << fNucCount << std::endl; @@ -334,6 +334,10 @@ namespace corsika::process::sibyll { } return process::EProcessReturn::eOk; } + + private: + corsika::environment::Environment const& fEnvironment; + }; } // namespace corsika::process::sibyll diff --git a/Processes/Sibyll/testSibyll.cc b/Processes/Sibyll/testSibyll.cc index 3d7d425d9..1c9100956 100644 --- a/Processes/Sibyll/testSibyll.cc +++ b/Processes/Sibyll/testSibyll.cc @@ -18,6 +18,10 @@ #include <corsika/geometry/Point.h> #include <corsika/units/PhysicalUnits.h> +#include <corsika/environment/Environment.h> +#include <corsika/environment/HomogeneousMedium.h> +#include <corsika/environment/NuclearComposition.h> + #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one // cpp file #include <catch2/catch.hpp> @@ -79,20 +83,39 @@ using namespace corsika::units; TEST_CASE("SibyllInterface", "[processes]") { - auto const& cs = - geometry::RootCoordinateSystem::GetInstance().GetRootCoordinateSystem(); + // setup environment, geometry + corsika::environment::Environment env; + auto& universe = *(env.GetUniverse()); + + auto theMedium = corsika::environment::Environment::CreateNode<geometry::Sphere>( + geometry::Point{env.GetCoordinateSystem(), 0_m, 0_m, 0_m}, + 1_km * std::numeric_limits<double>::infinity()); + + using MyHomogeneousModel = + corsika::environment::HomogeneousMedium<corsika::environment::IMediumModel>; + theMedium->SetModelProperties<MyHomogeneousModel>( + 1_kg / (1_m * 1_m * 1_m), + corsika::environment::NuclearComposition( + std::vector<corsika::particles::Code>{corsika::particles::Code::Oxygen}, + std::vector<float>{1.})); + + universe.AddChild(std::move(theMedium)); + + const geometry::CoordinateSystem& cs = env.GetCoordinateSystem(); + geometry::Point const origin(cs, {0_m, 0_m, 0_m}); geometry::Vector<corsika::units::si::SpeedType::dimension_type> v( cs, 0_m / second, 0_m / second, 1_m / second); geometry::Line line(origin, v); geometry::Trajectory<geometry::Line> track(line, 10_s); + SECTION("InteractionInterface") { setup::Stack stack; auto particle = stack.NewParticle(); - Interaction model; + Interaction model(env); model.Init(); [[maybe_unused]] const process::EProcessReturn ret = -- GitLab