diff --git a/Framework/Logging/CMakeLists.txt b/Framework/Logging/CMakeLists.txt index d74849f26c8f1c683899f51517cc150f9a787e3b..09da545c1f1588e5aafb2cead512ce2b2e68773c 100644 --- a/Framework/Logging/CMakeLists.txt +++ b/Framework/Logging/CMakeLists.txt @@ -25,7 +25,7 @@ target_include_directories ( INTERFACE $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include> $<INSTALL_INTERFACE:include/> - C8::ext:boost +# C8::ext:boost ) # and link against spdlog diff --git a/Framework/Logging/Logging.h b/Framework/Logging/Logging.h index 774bffab01117476f62c66792328d00a9a1a2ce5..b6190739979a34f7c93670e4fc2efe2dde074449 100644 --- a/Framework/Logging/Logging.h +++ b/Framework/Logging/Logging.h @@ -168,7 +168,7 @@ namespace corsika::logging { inline auto ResetPattern(TLogger& logger) -> void { logger->set_pattern(default_pattern); } - + // define our macro-style loggers #define C8LOG_TRACE SPDLOG_TRACE #define C8LOG_DEBUG SPDLOG_DEBUG @@ -186,3 +186,5 @@ namespace corsika::logging { #define C8LOG_LOGGER_CRITICAL SPDLOG_LOGGER_CRITICAL } // namespace corsika::logging + + diff --git a/Framework/StackInterface/CMakeLists.txt b/Framework/StackInterface/CMakeLists.txt index cf0970e26816fb76633da1bae0e63d5eecaeb01f..47c605f748b813b50fd3b2f9afecf000cdd227e1 100644 --- a/Framework/StackInterface/CMakeLists.txt +++ b/Framework/StackInterface/CMakeLists.txt @@ -21,6 +21,12 @@ CORSIKA_COPY_HEADERS_TO_NAMESPACE ( CORSIKAstackinterface ${CORSIKAstackinterface_NAMESPACE} ${CORSIKAstackinterface_HEADERS} ) +target_link_libraries ( + CORSIKAstackinterface + INTERFACE + CORSIKAlogging + ) + target_include_directories ( CORSIKAstackinterface INTERFACE diff --git a/Framework/StackInterface/SecondaryView.h b/Framework/StackInterface/SecondaryView.h index 27f8dc6f316a818f5d22a7f97bbb855c29e48fb7..bda66b88351a0283bb49e35df4ca49769d9d9ba6 100644 --- a/Framework/StackInterface/SecondaryView.h +++ b/Framework/StackInterface/SecondaryView.h @@ -10,6 +10,8 @@ #include <corsika/stack/Stack.h> +#include <corsika/logging/Logging.h> + #include <stdexcept> #include <vector> @@ -100,6 +102,8 @@ namespace corsika::stack { friend class ConstStackIteratorInterface< typename std::remove_reference<StackDataType>::type, ParticleInterface, ViewType>; + friend class ParticleBase<StackIterator>; + private: /** * This is not accessible, since we don't want to allow creating a @@ -143,14 +147,29 @@ namespace corsika::stack { } public: + /** + * Method to add a new secondary particle on this SecondaryView + */ template <typename... Args> StackIterator AddSecondary(const Args... v) { + C8LOG_DEBUG("SecondaryView::AddSecondary(Args&&)"); StackIterator proj = GetProjectile(); return AddSecondary(proj, v...); } + protected: + /** + * Overwrite of Stack::StackIterator + * + * increase stack size, create new particle at end of stack, + * related to parent particle/projectile + * + * This should only get internally called from a + * StackIterator::AddSecondary via ParticleBase + */ template <typename... Args> StackIterator AddSecondary(StackIterator& proj, const Args... v) { + C8LOG_DEBUG("SecondaryView::AddSecondary(StackIterator&, Args&&)"); // make space on stack InnerStackTypeRef::GetStackData().IncrementSize(); inner_stack_.deleted_.push_back(false); @@ -163,7 +182,9 @@ namespace corsika::stack { // GetIndexFromIterator return StackIterator(*this, idSec + 1, proj, v...); } - + + public: + /** * overwrite Stack::GetSize to return actual number of secondaries */ diff --git a/Framework/StackInterface/Stack.h b/Framework/StackInterface/Stack.h index 4c4e1be75f52d6f5068d7194e551afede821c02f..ea59b2cff44fa27460b64b0f9adf1fa79426c376 100644 --- a/Framework/StackInterface/Stack.h +++ b/Framework/StackInterface/Stack.h @@ -9,8 +9,6 @@ #pragma once #include <corsika/stack/StackIteratorInterface.h> -// must be after StackIteratorInterface -// #include <corsika/stack/SecondaryView.h> #include <corsika/utl/MetaProgramming.h> #include <stdexcept> @@ -128,7 +126,8 @@ namespace corsika::stack { friend class ConstStackIteratorInterface<StackDataValueType, TParticleInterface, Stack>; friend class SecondaryView<StackDataValueType, TParticleInterface>; - + friend class ParticleBase<StackIterator>; + public: /** * @name Most generic proxy methods for TStackData data_ @@ -215,9 +214,13 @@ namespace corsika::stack { return StackIterator(*this, getSize() - 1, v...); } + protected: /** * increase stack size, create new particle at end of stack, related to parent * particle/projectile + * + * This should only get internally called from a + * StackIterator::AddSecondary via ParticleBase */ template <typename... Args> StackIterator AddSecondary(StackIterator& parent, const Args... v) { @@ -226,6 +229,7 @@ namespace corsika::stack { return StackIterator(*this, getSize() - 1, parent, v...); } + public: void Swap(StackIterator a, StackIterator b) { data_.Swap(a.GetIndex(), b.GetIndex()); std::swap(deleted_[a.GetIndex()], deleted_[b.GetIndex()]); diff --git a/Processes/ObservationPlane/CMakeLists.txt b/Processes/ObservationPlane/CMakeLists.txt index e1c3c41799d3d3d17a6680de995aba3a64f35933..800c5dbd6b2e900f8e2228fe9e64615f304c4d28 100644 --- a/Processes/ObservationPlane/CMakeLists.txt +++ b/Processes/ObservationPlane/CMakeLists.txt @@ -21,6 +21,7 @@ target_link_libraries ( ProcessObservationPlane CORSIKAgeometry CORSIKAprocesssequence + CORSIKAlogging ) target_include_directories ( diff --git a/Stack/History/CMakeLists.txt b/Stack/History/CMakeLists.txt index c97b5fffb464c63045775e581064e45fc6f7bec1..de272dc23f91c533033f1abf4410be5466e16205 100644 --- a/Stack/History/CMakeLists.txt +++ b/Stack/History/CMakeLists.txt @@ -28,6 +28,7 @@ target_link_libraries ( CORSIKAgeometry CORSIKAprocesssequence # for HistoryObservationPlane CORSIKAsetup # for HistoryObservationPlane + CORSIKAlogging SuperStupidStack NuclearStackExtension C8::ext::boost diff --git a/Stack/History/HistorySecondaryView.hpp b/Stack/History/HistorySecondaryView.hpp index 51c21ad855e15859a8a7b799c4303cd253a8d459..235566b5e19ced2ac6f6f035e3942768afc40997 100644 --- a/Stack/History/HistorySecondaryView.hpp +++ b/Stack/History/HistorySecondaryView.hpp @@ -11,6 +11,8 @@ #include <corsika/stack/SecondaryView.h> #include <corsika/history/Event.hpp> +#include <corsika/logging/Logging.h> + #include <memory> #include <type_traits> #include <utility> @@ -35,6 +37,7 @@ namespace corsika::history { template <typename... Args> StackIterator AddSecondary(Args&&... args) { + C8LOG_TRACE("HistorySecondaryView::AddSecondary(Args&&)"); auto stack_sec = TView::AddSecondary(std::forward<Args...>(args...)); // store particles at production time in Event here @@ -49,6 +52,13 @@ namespace corsika::history { return stack_sec; } + + template <typename... Args> + StackIterator AddSecondary(StackIterator& proj, const Args... args) { + C8LOG_TRACE("HistorySecondaryView::AddSecondary(StackIterator&, Args&&)"); + return TView::AddSecondary(proj, std::forward<Args...>(args...)); + } + }; } // namespace corsika::history diff --git a/Stack/History/HistoryStackExtension.h b/Stack/History/HistoryStackExtension.h index d3168d896f7382ab3eab0c80adc6a77315c0c0f9..92b3fd025c5d9dccb5b3f417058bde1d1c94f756 100644 --- a/Stack/History/HistoryStackExtension.h +++ b/Stack/History/HistoryStackExtension.h @@ -9,6 +9,7 @@ #pragma once #include <corsika/stack/Stack.h> +#include <corsika/logging/Logging.h> #include <memory> #include <utility> @@ -81,10 +82,22 @@ namespace corsika::history { public: // create a new particle from scratch - void SetParticleData() { GetStackData().SetParentEventIndex(GetIndex(), -1); } + void SetParticleData() { + C8LOG_TRACE("HistoyDatatInterface::SetParticleData()"); + GetStackData().SetParentEventIndex(GetIndex(), -1); } // create a new particle as secondary of a parent - void SetParticleData(HistoryDataInterface& /*parent*/) { SetParticleData(); } + void SetParticleData(HistoryDataInterface& /*parent*/) { + C8LOG_TRACE("HistoyDatatInterface::SetParticleData(parnt)"); + SetParticleData(); + + + // store particles at production time in Event here + auto const sec_index = event_->addSecondary( + stack_sec.GetEnergy(), stack_sec.GetMomentum(), stack_sec.GetPID()); + stack_sec.SetParentEventIndex(sec_index); + stack_sec.SetEvent(event_); + } void SetEvent(const std::shared_ptr<TEvent>& v) { GetStackData().SetEvent(GetIndex(), v); diff --git a/Stack/History/testHistoryView.cc b/Stack/History/testHistoryView.cc index 9079c815b3b625ce21b799c767e7a8b315b50ec8..5c14fdf1ea553519e29f7d98790c60935d9d2edb 100644 --- a/Stack/History/testHistoryView.cc +++ b/Stack/History/testHistoryView.cc @@ -57,6 +57,9 @@ using TestStackView = corsika::stack::MakeView<TestStack>::type; TEST_CASE("HistoryStackExtension", "[stack]") { + logging::SetDefaultLevel(logging::level::debug); + logging::SetLevel(logging::level::trace); + geometry::CoordinateSystem& dummyCS = geometry::RootCoordinateSystem::GetInstance().GetRootCoordinateSystem(); @@ -82,7 +85,9 @@ TEST_CASE("HistoryStackExtension", "[stack]") { auto const ev0 = p0.GetEvent(); CHECK(ev0 == nullptr); - + + C8LOG_DEBUG("loop VIEW"); + // add 5 secondaries for (int i = 0; i < 5; ++i) { auto sec = hview0.AddSecondary( @@ -132,12 +137,15 @@ TEST_CASE("HistoryStackExtension", "[stack]") { // add third generation of secondaries // add 15 secondaries for (int i = 0; i < 15; ++i) { + C8LOG_TRACE("loop, view: " + std::to_string(i)); + auto sec = hview2.AddSecondary( std::tuple<particles::Code, units::si::HEPEnergyType, corsika::stack::MomentumVector, geometry::Point, units::si::TimeType>{ particles::Code::Electron, 1.5_GeV, corsika::stack::MomentumVector(dummyCS, {1_GeV, 1_GeV, 1_GeV}), Point(dummyCS, {1 * meter, 1 * meter, 1 * meter}), 100_s}); + C8LOG_TRACE("loop, ---- " ); CHECK(sec.GetParentEventIndex() == i); CHECK(sec.GetEvent()->parentEvent() == ev2); @@ -186,9 +194,12 @@ TEST_CASE("HistoryStackExtension", "[stack]") { auto proj0 = hview0.GetProjectile(); auto const ev0 = p0.GetEvent(); CHECK(ev0 == nullptr); + + C8LOG_TRACE("loop"); // add 5 secondaries for (int i = 0; i < 5; ++i) { + C8LOG_TRACE("loop " + std::to_string(i)); auto sec = proj0.AddSecondary( std::tuple<particles::Code, units::si::HEPEnergyType, corsika::stack::MomentumVector, geometry::Point, units::si::TimeType>{