From ecc99ec1e0a09e97f34d3e0288b5fc23b843f35c Mon Sep 17 00:00:00 2001 From: ralfulrich <ralf.ulrich@kit.edu> Date: Thu, 16 Dec 2021 14:51:20 +0100 Subject: [PATCH] coverage --- corsika/detail/modules/conex/CONEXhybrid.inl | 11 ++++------- corsika/detail/modules/writers/EnergyLossWriter.inl | 4 ++-- corsika/modules/conex/CONEXhybrid.hpp | 2 +- corsika/modules/writers/EnergyLossWriter.hpp | 2 +- tests/framework/CMakeLists.txt | 1 + tests/output/CMakeLists.txt | 2 ++ tests/output/testOutputManager.cpp | 10 +++++++--- 7 files changed, 18 insertions(+), 14 deletions(-) diff --git a/corsika/detail/modules/conex/CONEXhybrid.inl b/corsika/detail/modules/conex/CONEXhybrid.inl index 58107e4b2..36f5f93ce 100644 --- a/corsika/detail/modules/conex/CONEXhybrid.inl +++ b/corsika/detail/modules/conex/CONEXhybrid.inl @@ -23,13 +23,12 @@ namespace corsika { template <typename TOutputE, typename TOutputN> - // template <typename... TArgs1, typename... TArgs2> inline CONEXhybrid<TOutputE, TOutputN>::CONEXhybrid( Point const& center, ShowerAxis const& showerAxis, LengthType groundDist, LengthType injectionHeight, HEPEnergyType primaryEnergy, PDGCode primaryPDG, TOutputE& args1, TOutputN& args2) - : SubWriter<TOutputE>(args1) //(std::forward<TArgs1>(args1)...) - , SubWriter<TOutputN>(args2) // std::forward<TArgs2>(args2)...) + : SubWriter<TOutputE>(args1) + , SubWriter<TOutputN>(args2) , center_{center} , showerAxis_{showerAxis} , groundDist_{groundDist} @@ -154,7 +153,7 @@ namespace corsika { template <typename TOutputE, typename TOutputN> inline bool CONEXhybrid<TOutputE, TOutputN>::addParticle( Code pid, HEPEnergyType energy, HEPEnergyType mass, Point const& position, - DirectionVector const& direction, TimeType t) { + DirectionVector const& direction, TimeType t, double weight) { auto const it = std::find_if(egs_em_codes_.cbegin(), egs_em_codes_.cend(), [=](auto const& p) { return pid == p.first; }); @@ -189,9 +188,6 @@ namespace corsika { double const v = direction.dot(x_sf_).magnitude(); double const w = direction.dot(showerAxis_.getDirection()).magnitude(); - double const weight = - 1; // particle.getWeight(); // NEEDS TO BE CHANGED WHEN WE HAVE WEIGHTS! - // generation, TO BE CHANGED WHEN WE HAVE THAT INFORMATION AVAILABLE int const latchin = 1; @@ -282,6 +278,7 @@ namespace corsika { for (int i = 0; i < nX; ++i) { GrammageType curX = X[i] * 1_g / square(1_cm); SubWriter<TOutputE>::write(curX, curX + dX, + Code::Unknown, // this is sum of all dEdX dEdX[i] * 1_GeV / 1_g * square(1_cm) * dX); SubWriter<TOutputN>::write(curX, curX + dX, Code::Photon, Photon[i]); SubWriter<TOutputN>::write(curX, curX + dX, Code::Proton, Hadrons[i]); diff --git a/corsika/detail/modules/writers/EnergyLossWriter.inl b/corsika/detail/modules/writers/EnergyLossWriter.inl index f6a0cbd6e..27756e48f 100644 --- a/corsika/detail/modules/writers/EnergyLossWriter.inl +++ b/corsika/detail/modules/writers/EnergyLossWriter.inl @@ -119,7 +119,7 @@ namespace corsika { } template <typename TOutput> - inline void EnergyLossWriter<TOutput>::write(Point const& point, Code const PID, + inline void EnergyLossWriter<TOutput>::write(Point const& point, Code const, HEPEnergyType const dE) { GrammageType grammage = showerAxis_.getProjectedX(point); int const maxBin = int(profile_.size() - 1); @@ -135,7 +135,7 @@ namespace corsika { template <typename TOutput> inline void EnergyLossWriter<TOutput>::write(GrammageType const Xstart, - GrammageType const Xend, + GrammageType const Xend, Code const, HEPEnergyType const dE) { double const bstart = Xstart / dX_; double const bend = Xend / dX_; diff --git a/corsika/modules/conex/CONEXhybrid.hpp b/corsika/modules/conex/CONEXhybrid.hpp index 4e5119e5c..f20ec8528 100644 --- a/corsika/modules/conex/CONEXhybrid.hpp +++ b/corsika/modules/conex/CONEXhybrid.hpp @@ -95,7 +95,7 @@ namespace corsika { */ bool addParticle(Code pid, HEPEnergyType energy, HEPEnergyType mass, Point const& position, Vector<dimensionless_d> const& direction, - TimeType t); + TimeType t, double weight = 1); CoordinateSystemPtr const& getObserverCS() const { return conexObservationCS_; } diff --git a/corsika/modules/writers/EnergyLossWriter.hpp b/corsika/modules/writers/EnergyLossWriter.hpp index 58cc69ebc..56ff1da67 100644 --- a/corsika/modules/writers/EnergyLossWriter.hpp +++ b/corsika/modules/writers/EnergyLossWriter.hpp @@ -139,7 +139,7 @@ namespace corsika { /** * Add binned energy loss. */ - void write(GrammageType const Xstart, GrammageType const Xend, + void write(GrammageType const Xstart, GrammageType const Xend, Code const PID, HEPEnergyType const dE); /** diff --git a/tests/framework/CMakeLists.txt b/tests/framework/CMakeLists.txt index 7d67ad5aa..caaec9e4c 100644 --- a/tests/framework/CMakeLists.txt +++ b/tests/framework/CMakeLists.txt @@ -22,6 +22,7 @@ set (test_framework_sources testInteractionCounter.cpp testInteractionLengthModifier.cpp testSolver.cpp + testEnergyMomentum.cpp ) CORSIKA_ADD_TEST (testFramework SOURCES ${test_framework_sources}) diff --git a/tests/output/CMakeLists.txt b/tests/output/CMakeLists.txt index 98a43b4c2..6014c5807 100644 --- a/tests/output/CMakeLists.txt +++ b/tests/output/CMakeLists.txt @@ -5,6 +5,8 @@ set (test_output_sources testParquetStreamer.cpp testWriterObservationPlane.cpp testWriterTracks.cpp + testWriterEnergyLoss.cpp + testWriterLongitudinal.cpp ) CORSIKA_ADD_TEST (testOutput SOURCES ${test_output_sources}) diff --git a/tests/output/testOutputManager.cpp b/tests/output/testOutputManager.cpp index d06b7d3b2..5d3d072bd 100644 --- a/tests/output/testOutputManager.cpp +++ b/tests/output/testOutputManager.cpp @@ -24,7 +24,6 @@ struct DummyNoOutput : public NoOutput { NoOutput::endOfShower(0); NoOutput::endOfLibrary(); } - YAML::Node getConfig() const final override { return YAML::Node(); } void checkWrite() { NoOutput::write(Code::Unknown, 1_eV, 1_m, 1_m, 1_ns); } }; @@ -37,8 +36,11 @@ struct DummyOutput : public BaseOutput { void startOfLibrary(boost::filesystem::path const&) override { startLibrary_ = true; } + YAML::Node getConfig() const final override { return YAML::Node(); } + void startOfShower(unsigned int const shower = 0) override { BaseOutput::startOfShower(shower); + setInit(true); startShower_ = true; } @@ -46,8 +48,6 @@ struct DummyOutput : public BaseOutput { void endOfLibrary() override { endLibrary_ = true; } - YAML::Node getConfig() const final override { return YAML::Node(); } - YAML::Node getSummary() const final override { YAML::Node summary; summary["test"] = "test"; @@ -82,7 +82,9 @@ TEST_CASE("OutputManager") { CHECK(test.startLibrary_); test.startLibrary_ = false; + CHECK_FALSE(test.isInit()); output.startOfShower(); + CHECK(test.isInit()); CHECK(test.startShower_); test.startShower_ = false; @@ -156,5 +158,7 @@ TEST_CASE("OutputManager") { nothing.check(); nothing.checkWrite(); + nothing.getConfig(); + nothing.getSummary(); } } -- GitLab