IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 2fd0b996 authored by Maximilian Reininghaus's avatar Maximilian Reininghaus :vulcan: Committed by ralfulrich
Browse files

moved new_view() into constructors of mix-in classes

parent de09cb8c
No related branches found
No related tags found
1 merge request!254History
......@@ -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>
......
......@@ -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&)");
}
};
......
......@@ -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>
......
......@@ -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 (
......
......@@ -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>
......
......@@ -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>
......
......@@ -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
......@@ -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 {
......
......@@ -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>
......
......@@ -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]") {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment