diff --git a/Documentation/Examples/vertical_EAS.cc b/Documentation/Examples/vertical_EAS.cc index 7246ce77e9881131e721d89e3beb462fd6e2bcf9..577ea416648e3a9f16249af51d485b5bd1b9063e 100644 --- a/Documentation/Examples/vertical_EAS.cc +++ b/Documentation/Examples/vertical_EAS.cc @@ -38,7 +38,7 @@ #include <corsika/units/PhysicalUnits.h> #include <corsika/utl/CorsikaFenv.h> -#include <corsika/history/HistoryObservationPlane.hpp> +#include <corsika/stack/history/HistoryObservationPlane.hpp> #include <iomanip> #include <iostream> diff --git a/Framework/StackInterface/SecondaryView.h b/Framework/StackInterface/SecondaryView.h index 4d615a12005a11ff1a09364529c2392c8798fc0e..8ab305a81d66543a0054d56d708a9797094f6d36 100644 --- a/Framework/StackInterface/SecondaryView.h +++ b/Framework/StackInterface/SecondaryView.h @@ -132,10 +132,10 @@ namespace corsika::stack { **/ SecondaryView(StackIteratorValue& particle) : Stack<StackDataType&, ParticleInterface>(particle.GetStackData()) + , MSecondaryProducer<StackDataType, ParticleInterface>{particle} , inner_stack_(particle.GetStack()) , projectile_index_(particle.GetIndex()) { C8LOG_TRACE("SecondaryView::SecondaryView(particle)"); - MSecondaryProducer<StackDataType, ParticleInterface>::new_view(particle); } /** * Also allow to create a new View from a Projectile (StackIterator on View) @@ -144,12 +144,12 @@ namespace corsika::stack { * terms of reference to the underlying data stack. It is not a "view to a view". */ SecondaryView(ViewType& view, StackIterator& projectile) - : Stack<StackDataType&, ParticleInterface>(view.GetStackData()) - , inner_stack_(view.inner_stack_) - , projectile_index_(view.GetIndexFromIterator(projectile.GetIndex())) { - C8LOG_TRACE("SecondaryView::SecondaryView(projectile)"); - StackIteratorValue particle(inner_stack_, projectile_index_); - MSecondaryProducer<StackDataType, ParticleInterface>::new_view(particle); + : Stack<StackDataType&, ParticleInterface>{view.GetStackData()} + , MSecondaryProducer<StackDataType, ParticleInterface>{StackIteratorValue{ + view.inner_stack_, view.GetIndexFromIterator(projectile.GetIndex())}} + , inner_stack_{view.inner_stack_} + , projectile_index_{view.GetIndexFromIterator(projectile.GetIndex())} { + C8LOG_TRACE("SecondaryView::SecondaryView(view, projectile)"); } /** @@ -397,7 +397,8 @@ namespace corsika::stack { }; /** - * Class to handle the generation of new secondaries. + * Class to handle the generation of new secondaries. Used as default mix-in for + * SecondaryView. */ template <class T1, template <class> class T2> class DefaultSecondaryProducer { @@ -405,28 +406,28 @@ namespace corsika::stack { public: /** - * Method is called after a new SecondaryView has been - * created. Extra logic can be introduced here. + * Method is called after a new secondary has been created on the + * SecondaryView. Extra logic can be introduced here. * - * The input Particle is a reference object into the original - * parent stack! It is not a reference into the SecondaryView - * itself. + * The input Particle is the new secondary that was produced and + * is of course a reference into the SecondaryView itself. */ template <typename Particle> - void new_view(Particle&) { - C8LOG_TRACE("DefaultSecondaryProducer::init"); + auto new_secondary(Particle&) const { + C8LOG_TRACE("DefaultSecondaryProducer::new_secondary(Particle&)"); } /** - * Method is called after a new Secondary has been created on the - * SecondaryView. Extra logic can be introduced here. + * Method is called when a new SecondaryView is being created + * created. Extra logic can be introduced here. * - * The input Particle is the new secondary that was produced and - * is of course a reference into the SecondaryView itself. + * The input Particle is a reference object into the original + * parent stack! It is not a reference into the SecondaryView + * itself. */ template <typename Particle> - auto new_secondary(Particle&) { - C8LOG_TRACE("DefaultSecondaryProducer::produce(TView,Args&&)"); + DefaultSecondaryProducer([[maybe_unused]] Particle const&) { + C8LOG_TRACE("DefaultSecondaryProducer::DefaultSecondaryProducer(Particle&)"); } }; diff --git a/Setup/SetupStack.h b/Setup/SetupStack.h index e72b191b38be385d2e3607806bdf9ba191ced9a8..8628f3df63181fa082801fd625bd140f8572484d 100644 --- a/Setup/SetupStack.h +++ b/Setup/SetupStack.h @@ -8,11 +8,11 @@ #pragma once -#include <corsika/history/HistoryStackExtension.h> #include <corsika/stack/CombinedStack.h> #include <corsika/stack/node/GeometryNodeStackExtension.h> #include <corsika/stack/nuclear_extension/NuclearStackExtension.h> -#include <corsika/history/HistorySecondaryProducer.hpp> +#include <corsika/stack/history/HistorySecondaryProducer.hpp> +#include <corsika/stack/history/HistoryStackExtension.hpp> #include <corsika/setup/SetupEnvironment.h> diff --git a/Stack/History/CMakeLists.txt b/Stack/History/CMakeLists.txt index 9adb558a24e3a6bab1f94cc29e144f3ce28db0d4..a1df0e255752f859b701f81e1a36abd706cb650b 100644 --- a/Stack/History/CMakeLists.txt +++ b/Stack/History/CMakeLists.txt @@ -3,18 +3,18 @@ set ( Event.hpp HistorySecondaryProducer.hpp HistoryObservationPlane.hpp - HistoryStackExtension.h + HistoryStackExtension.hpp SecondaryParticle.hpp ) set ( HISTORY_NAMESPACE - corsika/history + corsika/stack/history ) set ( HISTORY_SOURCES - HistoryObservationPlane.cc + HistoryObservationPlane.cpp ) #add_library (CORSIKAhistory INTERFACE) @@ -29,8 +29,8 @@ target_link_libraries ( CORSIKAsetup # for HistoryObservationPlane CORSIKAlogging SuperStupidStack - NuclearStackExtension - C8::ext::boost + NuclearStackExtension # for testHistoryView.cc + C8::ext::boost # for HistoryObservationPlane ) target_include_directories ( diff --git a/Stack/History/Event.hpp b/Stack/History/Event.hpp index 327fdf670cec232b65e5c98e0a001c557a11d0ad..eb91de759bf46d94fab6ca998d2754d70d59f4ac 100644 --- a/Stack/History/Event.hpp +++ b/Stack/History/Event.hpp @@ -9,7 +9,7 @@ #pragma once #include <corsika/particles/ParticleProperties.h> -#include <corsika/history/SecondaryParticle.hpp> +#include <corsika/stack/history/SecondaryParticle.hpp> #include <corsika/logging/Logging.h> #include <iostream> diff --git a/Stack/History/HistoryObservationPlane.cc b/Stack/History/HistoryObservationPlane.cpp similarity index 97% rename from Stack/History/HistoryObservationPlane.cc rename to Stack/History/HistoryObservationPlane.cpp index d9374eee7e00ee8177cd3027b86a9fac7bc6b9cd..542478eb5aca9dc99a4576ca3186fd9390a9ad0b 100644 --- a/Stack/History/HistoryObservationPlane.cc +++ b/Stack/History/HistoryObservationPlane.cpp @@ -7,7 +7,7 @@ */ #include <corsika/logging/Logging.h> -#include <corsika/history/HistoryObservationPlane.hpp> +#include <corsika/stack/history/HistoryObservationPlane.hpp> #include <boost/histogram/ostream.hpp> diff --git a/Stack/History/HistorySecondaryProducer.hpp b/Stack/History/HistorySecondaryProducer.hpp index 2d3d560a32e9a242ee32488476f988e939c54d27..0d3a88124da908c785f9d50de92658fa7d223bda 100644 --- a/Stack/History/HistorySecondaryProducer.hpp +++ b/Stack/History/HistorySecondaryProducer.hpp @@ -9,7 +9,7 @@ #pragma once #include <corsika/stack/SecondaryView.h> -#include <corsika/history/Event.hpp> +#include <corsika/stack/history/Event.hpp> #include <corsika/logging/Logging.h> @@ -19,31 +19,17 @@ namespace corsika::history { + //! mix-in class for SecondaryView that fills secondaries into an \class Event template <class T1, template <class> class T2> class HistorySecondaryProducer { - - using TView = corsika::stack::SecondaryView<T1, T2, HistorySecondaryProducer>; - public: EventPtr event_; public: - HistorySecondaryProducer() : - event_{std::make_shared<Event>()} { - C8LOG_TRACE("HistorySecondaryProducer::HistorySecondaryProducer"); - } - - /** - * Method is called after a new SecondaryView has been - * created. Extra logic can be introduced here. - * - * The input Particle is a reference object into the original - * parent stack! It is not a reference into the SecondaryView - * itself. - */ template <typename Particle> - void new_view(Particle& p) { - C8LOG_TRACE("HistorySecondaryProducer::new_view"); + HistorySecondaryProducer(Particle const& p) + : event_{std::make_shared<Event>()} { + C8LOG_TRACE("HistorySecondaryProducer::HistorySecondaryProducer"); event_->setProjectileIndex(p.GetIndex()); event_->setParentEvent(p.GetEvent()); } @@ -51,7 +37,7 @@ namespace corsika::history { /** * Method is called after a new Secondary has been created on the * SecondaryView. Extra logic can be introduced here. - * + * * The input Particle is the new secondary that was produced and * is of course a reference into the SecondaryView itself. */ @@ -60,12 +46,11 @@ namespace corsika::history { C8LOG_TRACE("HistorySecondaryProducer::new_secondary(sec)"); // store particles at production time in Event here - auto const sec_index = event_->addSecondary( - sec.GetEnergy(), sec.GetMomentum(), sec.GetPID()); + auto const sec_index = + event_->addSecondary(sec.GetEnergy(), sec.GetMomentum(), sec.GetPID()); sec.SetParentEventIndex(sec_index); sec.SetEvent(event_); } - }; } // namespace corsika::history diff --git a/Stack/History/HistoryStackExtension.h b/Stack/History/HistoryStackExtension.hpp similarity index 99% rename from Stack/History/HistoryStackExtension.h rename to Stack/History/HistoryStackExtension.hpp index c9a0f289e0ab58bfb105678c44133208b710fa29..67a38b79617b8a5a5dca62fa6485ff17926f927a 100644 --- a/Stack/History/HistoryStackExtension.h +++ b/Stack/History/HistoryStackExtension.hpp @@ -126,7 +126,7 @@ namespace corsika::history { // for user-friendlyness we create the HistoryDataInterface type // with the histoy::Event data content right here: -#include <corsika/history/Event.hpp> +#include <corsika/stack/history/Event.hpp> namespace corsika::history { diff --git a/Stack/History/testHistoryStack.cc b/Stack/History/testHistoryStack.cc index e332d7620d19434d602a085c455e8dc196dd9a1f..ed61b83b6435b822a6eda7b490ffb6448a8dca8e 100644 --- a/Stack/History/testHistoryStack.cc +++ b/Stack/History/testHistoryStack.cc @@ -6,9 +6,9 @@ * the license. */ -#include <corsika/history/HistoryStackExtension.h> #include <corsika/stack/CombinedStack.h> #include <corsika/stack/dummy/DummyStack.h> +#include <corsika/stack/history/HistoryStackExtension.hpp> #include <catch2/catch.hpp> diff --git a/Stack/History/testHistoryView.cc b/Stack/History/testHistoryView.cc index d4c50e7a411b29b2efb93b3e125ff0565356b720..718daac6b8134388819d53971da7612aeb75f78b 100644 --- a/Stack/History/testHistoryView.cc +++ b/Stack/History/testHistoryView.cc @@ -6,9 +6,9 @@ * the license. */ -#include <corsika/history/HistoryStackExtension.h> -#include <corsika/history/Event.hpp> -#include <corsika/history/HistorySecondaryProducer.hpp> +#include <corsika/stack/history/Event.hpp> +#include <corsika/stack/history/HistorySecondaryProducer.hpp> +#include <corsika/stack/history/HistoryStackExtension.hpp> #include <corsika/stack/CombinedStack.h> #include <corsika/stack/dummy/DummyStack.h> @@ -62,7 +62,7 @@ using TheTestStackView = #endif using TestStackView = - TheTestStackView; // history::HistorySecondaryView<TheTestStackView>; + TheTestStackView; // history::HistorySecondaryProducer<TheTestStackView>; TEST_CASE("HistoryStackExtension", "[stack]") {