From 58ac567f7e8b3ea2a7c2a6b0d61e138369ffcaa0 Mon Sep 17 00:00:00 2001 From: Remy Prechelt <prechelt@hawaii.edu> Date: Tue, 18 May 2021 09:47:46 -1000 Subject: [PATCH] Removed setup from ObservationPlane. --- corsika/detail/modules/ObservationPlane.inl | 37 ++++++++++--------- corsika/modules/ObservationPlane.hpp | 16 ++++---- corsika/modules/energy_loss/BetheBlochPDG.hpp | 3 -- examples/corsika.cpp | 4 +- examples/em_shower.cpp | 2 +- examples/hybrid_MC.cpp | 2 +- examples/vertical_EAS.cpp | 3 +- tests/modules/testObservationPlane.cpp | 8 ++-- 8 files changed, 38 insertions(+), 37 deletions(-) diff --git a/corsika/detail/modules/ObservationPlane.inl b/corsika/detail/modules/ObservationPlane.inl index e2ace2806..3a1ab82e6 100644 --- a/corsika/detail/modules/ObservationPlane.inl +++ b/corsika/detail/modules/ObservationPlane.inl @@ -8,8 +8,8 @@ namespace corsika { - template <typename TOutput> - ObservationPlane<TOutput>::ObservationPlane(Plane const& obsPlane, + template <typename TTracking, typename TOutput> + ObservationPlane<TTracking, TOutput>::ObservationPlane(Plane const& obsPlane, DirectionVector const& x_axis, bool deleteOnHit) : plane_(obsPlane) @@ -19,9 +19,10 @@ namespace corsika { , xAxis_(x_axis.normalized()) , yAxis_(obsPlane.getNormal().cross(xAxis_)) {} - template <typename TOutput> - inline ProcessReturn ObservationPlane<TOutput>::doContinuous( - corsika::setup::Stack::particle_type& particle, corsika::setup::Trajectory&, + template <typename TTracking, typename TOutput> + template <typename TParticle, typename TTrajectory> + inline ProcessReturn ObservationPlane<TTracking, TOutput>::doContinuous( + TParticle& particle, TTrajectory&, bool const stepLimit) { /* The current step did not yet reach the ObservationPlane, do nothing now and wait: @@ -58,17 +59,17 @@ namespace corsika { } } - template <typename TOutput> - inline LengthType ObservationPlane<TOutput>::getMaxStepLength( - corsika::setup::Stack::particle_type const& particle, - corsika::setup::Trajectory const& trajectory) { + template <typename TTracking, typename TOutput> + template <typename TParticle, typename TTrajectory> + inline LengthType ObservationPlane<TTracking, TOutput>::getMaxStepLength( + TParticle const& particle, + TTrajectory const& trajectory) { CORSIKA_LOG_TRACE("particle={}, pos={}, dir={}, plane={}", particle.asString(), particle.getPosition(), particle.getDirection(), plane_.asString()); - Intersections const intersection = - setup::Tracking::intersect<corsika::setup::Stack::particle_type>(particle, - plane_); + auto const intersection = TTracking::intersect(particle, plane_); + TimeType const timeOfIntersection = intersection.getEntry(); CORSIKA_LOG_TRACE("timeOfIntersection={}", timeOfIntersection); if (timeOfIntersection < TimeType::zero()) { @@ -84,8 +85,8 @@ namespace corsika { return dist; } - template <typename TOutput> - inline void ObservationPlane<TOutput>::showResults() const { + template <typename TTracking, typename TOutput> + inline void ObservationPlane<TTracking, TOutput>::showResults() const { CORSIKA_LOG_INFO( " ******************************\n" " ObservationPlane: \n" @@ -95,8 +96,8 @@ namespace corsika { energy_ground_ / 1_GeV, count_ground_); } - template <typename TOutput> - inline YAML::Node ObservationPlane<TOutput>::getConfig() const { + template <typename TTracking, typename TOutput> + inline YAML::Node ObservationPlane<TTracking, TOutput>::getConfig() const { using namespace units::si; // construct the top-level node @@ -138,8 +139,8 @@ namespace corsika { return node; } - template <typename TOutput> - inline void ObservationPlane<TOutput>::reset() { + template <typename TTracking, typename TOutput> + inline void ObservationPlane<TTracking, TOutput>::reset() { energy_ground_ = 0_GeV; count_ground_ = 0; } diff --git a/corsika/modules/ObservationPlane.hpp b/corsika/modules/ObservationPlane.hpp index 613708d10..522631ff2 100644 --- a/corsika/modules/ObservationPlane.hpp +++ b/corsika/modules/ObservationPlane.hpp @@ -11,8 +11,6 @@ #include <corsika/framework/core/PhysicalUnits.hpp> #include <corsika/framework/geometry/Plane.hpp> #include <corsika/framework/process/ContinuousProcess.hpp> -#include <corsika/setup/SetupStack.hpp> -#include <corsika/setup/SetupTrajectory.hpp> #include <corsika/modules/writers/ObservationPlaneWriterParquet.hpp> namespace corsika { @@ -32,19 +30,21 @@ namespace corsika { small gap in between the two plane in such a scenario, or develop another more specialized output class. */ - template <typename TOutputWriter = ObservationPlaneWriterParquet> - class ObservationPlane : public ContinuousProcess<ObservationPlane<TOutputWriter>>, + template <typename TTracking, typename TOutputWriter = ObservationPlaneWriterParquet> + class ObservationPlane : public ContinuousProcess<ObservationPlane<TTracking, TOutputWriter>>, public TOutputWriter { public: ObservationPlane(Plane const&, DirectionVector const&, bool = true); - ProcessReturn doContinuous(corsika::setup::Stack::particle_type& vParticle, - corsika::setup::Trajectory& vTrajectory, + template <typename TParticle, typename TTrajectory> + ProcessReturn doContinuous(TParticle& vParticle, + TTrajectory& vTrajectory, bool const stepLimit); - LengthType getMaxStepLength(corsika::setup::Stack::particle_type const&, - corsika::setup::Trajectory const& vTrajectory); + template <typename TParticle, typename TTrajectory> + LengthType getMaxStepLength(TParticle const&, + TTrajectory const& vTrajectory); void showResults() const; void reset(); diff --git a/corsika/modules/energy_loss/BetheBlochPDG.hpp b/corsika/modules/energy_loss/BetheBlochPDG.hpp index 9c069f0f3..ce527abdd 100644 --- a/corsika/modules/energy_loss/BetheBlochPDG.hpp +++ b/corsika/modules/energy_loss/BetheBlochPDG.hpp @@ -14,9 +14,6 @@ #include <corsika/framework/process/ContinuousProcess.hpp> #include <corsika/media/ShowerAxis.hpp> -#include <corsika/setup/SetupStack.hpp> -#include <corsika/setup/SetupTrajectory.hpp> - #include <map> namespace corsika { diff --git a/examples/corsika.cpp b/examples/corsika.cpp index 9bb4ee592..dcd8b50b0 100644 --- a/examples/corsika.cpp +++ b/examples/corsika.cpp @@ -28,6 +28,7 @@ #include <corsika/framework/geometry/PhysicalGeometry.hpp> #include <corsika/output/OutputManager.hpp> +#include <corsika/output/NoOutput.hpp> #include <corsika/media/Environment.hpp> #include <corsika/media/FlatExponential.hpp> @@ -314,7 +315,8 @@ int main(int argc, char** argv) { // observation plane Plane const obsPlane(showerCore, DirectionVector(rootCS, {0., 0., 1.})); ObservationPlane observationLevel(obsPlane, DirectionVector(rootCS, {1., 0., 0.})); - output.add("obslevel", observationLevel); + // register the observation plane with the output + output.add("particles", observationLevel); // assemble the final process sequence auto sequence = diff --git a/examples/em_shower.cpp b/examples/em_shower.cpp index 9e8d2a39e..d5a3f8f9b 100644 --- a/examples/em_shower.cpp +++ b/examples/em_shower.cpp @@ -156,7 +156,7 @@ int main(int argc, char** argv) { LongitudinalProfile longprof{showerAxis}; Plane const obsPlane(showerCore, DirectionVector(rootCS, {0., 0., 1.})); - ObservationPlane observationLevel(obsPlane, DirectionVector(rootCS, {1., 0., 0.}), + ObservationPlane<setup::Tracking> observationLevel(obsPlane, DirectionVector(rootCS, {1., 0., 0.}), "particles.dat"); output.add("obsplane", observationLevel); diff --git a/examples/hybrid_MC.cpp b/examples/hybrid_MC.cpp index dc4f7e8ee..3b82b0cd6 100644 --- a/examples/hybrid_MC.cpp +++ b/examples/hybrid_MC.cpp @@ -220,7 +220,7 @@ int main(int argc, char** argv) { LongitudinalProfile longprof{showerAxis}; Plane const obsPlane(showerCore, DirectionVector(rootCS, {0., 0., 1.})); - ObservationPlane observationLevel(obsPlane, DirectionVector(rootCS, {1., 0., 0.}), + ObservationPlane<setup::Tracking> observationLevel(obsPlane, DirectionVector(rootCS, {1., 0., 0.}), "particles.dat"); output.add("obsplane", observationLevel); diff --git a/examples/vertical_EAS.cpp b/examples/vertical_EAS.cpp index b8e16ab43..ac6944585 100644 --- a/examples/vertical_EAS.cpp +++ b/examples/vertical_EAS.cpp @@ -28,6 +28,7 @@ #include <corsika/framework/geometry/PhysicalGeometry.hpp> #include <corsika/output/OutputManager.hpp> +#include <corsika/output/NoOutput.hpp> #include <corsika/media/Environment.hpp> #include <corsika/media/FlatExponential.hpp> @@ -285,7 +286,7 @@ int main(int argc, char** argv) { LongitudinalProfile longprof{showerAxis}; Plane const obsPlane(showerCore, DirectionVector(rootCS, {0., 0., 1.})); - ObservationPlane observationLevel(obsPlane, DirectionVector(rootCS, {1., 0., 0.})); + ObservationPlane<setup::Tracking, NoOutput> observationLevel(obsPlane, DirectionVector(rootCS, {1., 0., 0.})); // register the observation plane with the output output.add("particles", observationLevel); diff --git a/tests/modules/testObservationPlane.cpp b/tests/modules/testObservationPlane.cpp index 62983a2e0..fc123722d 100644 --- a/tests/modules/testObservationPlane.cpp +++ b/tests/modules/testObservationPlane.cpp @@ -55,7 +55,7 @@ TEST_CASE("ObservationPlane", "interface") { SECTION("horizontal plane") { Plane const obsPlane(Point(cs, {10_m, 0_m, 0_m}), DirectionVector(cs, {1., 0., 0.})); - ObservationPlane<NoOutput> obs(obsPlane, DirectionVector(cs, {0., 1., 0.})); + ObservationPlane<setup::Tracking, NoOutput> obs(obsPlane, DirectionVector(cs, {0., 1., 0.})); LengthType const length = obs.getMaxStepLength(particle, no_used_track); ProcessReturn const ret = obs.doContinuous(particle, no_used_track, true); @@ -83,7 +83,7 @@ TEST_CASE("ObservationPlane", "interface") { SECTION("transparent plane") { Plane const obsPlane(Point(cs, {1_m, 0_m, 0_m}), DirectionVector(cs, {1., 0., 0.})); - ObservationPlane<NoOutput> obs(obsPlane, DirectionVector(cs, {0., 0., 1.}), false); + ObservationPlane<setup::Tracking, NoOutput> obs(obsPlane, DirectionVector(cs, {0., 0., 1.}), false); LengthType const length = obs.getMaxStepLength(particle, no_used_track); ProcessReturn const ret = obs.doContinuous(particle, no_used_track, false); @@ -101,7 +101,7 @@ TEST_CASE("ObservationPlane", "interface") { Plane const obsPlane(Point(cs, {10_m, 5_m, 5_m}), DirectionVector(cs, {1, 0.1, -0.05})); - ObservationPlane<NoOutput> obs(obsPlane, DirectionVector(cs, {0., 1., 0.})); + ObservationPlane<setup::Tracking, NoOutput> obs(obsPlane, DirectionVector(cs, {0., 1., 0.})); LengthType const length = obs.getMaxStepLength(particle, no_used_track); ProcessReturn const ret = obs.doContinuous(particle, no_used_track, true); @@ -112,7 +112,7 @@ TEST_CASE("ObservationPlane", "interface") { SECTION("output") { Plane const obsPlane(Point(cs, {1_m, 0_m, 0_m}), DirectionVector(cs, {1., 0., 0.})); - ObservationPlane<NoOutput> obs(obsPlane, DirectionVector(cs, {0., 0., 1.}), false); + ObservationPlane<setup::Tracking, NoOutput> obs(obsPlane, DirectionVector(cs, {0., 0., 1.}), false); auto const cfg = obs.getConfig(); CHECK(cfg["type"]); } -- GitLab