diff --git a/Framework/Cascade/Cascade.h b/Framework/Cascade/Cascade.h index 8d2bd1743275ff6b334022d464001334ed7a92c5..9865263330b023e2828a6c7d0eb9e067cd911bfb 100644 --- a/Framework/Cascade/Cascade.h +++ b/Framework/Cascade/Cascade.h @@ -16,6 +16,7 @@ #include <corsika/random/UniformRealDistribution.h> #include <corsika/stack/SecondaryView.h> #include <corsika/units/PhysicalUnits.h> +#include <corsika/history/EventType.hpp> #include <corsika/logging/Logging.h> @@ -325,8 +326,10 @@ namespace corsika::cascade { actual_decay_time); const auto sample_process = uniDist(fRNG); units::si::InverseTimeType inv_decay_count = units::si::InverseTimeType::zero(); - return fProcessSequence.SelectDecay(particle, view, sample_process, + auto const returnCode = fProcessSequence.SelectDecay(particle, view, sample_process, inv_decay_count); + view.GetProjectile().GetEvent()->set_type(history::EventType::Decay); + return returnCode; } auto interaction(Particle& particle, TStackView& view) { @@ -339,8 +342,10 @@ namespace corsika::cascade { current_inv_length); const auto sample_process = uniDist(fRNG); auto inv_lambda_count = units::si::InverseGrammageType::zero(); - return fProcessSequence.SelectInteraction(particle, view, sample_process, + auto const returnCode = fProcessSequence.SelectInteraction(particle, view, sample_process, inv_lambda_count); + view.GetProjectile().GetEvent()->set_type(history::EventType::Interaction); + return returnCode; } // but this here temporarily. Should go into dedicated file later: diff --git a/Stack/History/CMakeLists.txt b/Stack/History/CMakeLists.txt index a1df0e255752f859b701f81e1a36abd706cb650b..6fd9e24a845d70cd7b51fb00014fc47a25c869fd 100644 --- a/Stack/History/CMakeLists.txt +++ b/Stack/History/CMakeLists.txt @@ -1,5 +1,6 @@ set ( HISTORY_HEADERS + EventType.hpp Event.hpp HistorySecondaryProducer.hpp HistoryObservationPlane.hpp diff --git a/Stack/History/Event.hpp b/Stack/History/Event.hpp index eb91de759bf46d94fab6ca998d2754d70d59f4ac..c569a577f62b8614197fcc1178f84bf8097e2679 100644 --- a/Stack/History/Event.hpp +++ b/Stack/History/Event.hpp @@ -8,9 +8,11 @@ #pragma once +#include <corsika/logging/Logging.h> #include <corsika/particles/ParticleProperties.h> #include <corsika/stack/history/SecondaryParticle.hpp> #include <corsika/logging/Logging.h> +#include <corsika/history/EventType.hpp> #include <iostream> #include <memory> @@ -21,15 +23,16 @@ namespace corsika::history { class Event; using EventPtr = std::shared_ptr<history::Event>; - + class Event { - size_t projectileIndex_ = 0; //!< index of projectile on stack + size_t projectile_index_ = 0; //!< index of projectile on stack std::vector<SecondaryParticle> secondaries_; EventPtr parent_event_; - std::optional<corsika::particles::Code> - targetCode_; + EventType type_ = EventType::Uninitialized; + + std::optional<corsika::particles::Code> targetCode_; public: Event() = default; @@ -38,10 +41,10 @@ namespace corsika::history { bool hasParentEvent() const { return bool(parent_event_); } EventPtr& parentEvent() { return parent_event_; } - const EventPtr& parentEvent() const { return parent_event_; } - - void setProjectileIndex(size_t i) { projectileIndex_ = i; } - size_t projectileIndex() const { return projectileIndex_; } + EventPtr const& parentEvent() const { return parent_event_; } + + void setProjectileIndex(size_t i) { projectile_index_ = i; } + size_t projectileIndex() const { return projectile_index_; } template <typename TStackIterator> TStackIterator projectile(TStackIterator begin) { @@ -49,7 +52,7 @@ namespace corsika::history { // MR: This is dangerous. You can pass any iterator though it must // be stack.begin() to yield the correct projectile - return begin + projectileIndex_; + return begin + projectile_index_; } size_t addSecondary(units::si::HEPEnergyType energy, @@ -59,13 +62,18 @@ namespace corsika::history { return secondaries_.size() - 1; } - std::vector<SecondaryParticle>& secondaries() { return secondaries_; } + std::vector<SecondaryParticle> const& secondaries() const { return secondaries_; } void setTargetCode(const particles::Code t) { targetCode_ = t; } std::string as_string() const { - return fmt::format("hasParent={}, projIndex={}, Nsec={}", hasParentEvent(), projectileIndex_, secondaries_.size()); + return fmt::format("hasParent={}, projIndex={}, Nsec={}", hasParentEvent(), + projectile_index_, secondaries_.size()); } + + EventType eventType() const { return type_; } + + void setEventType(EventType t) { type_ = t; } }; } // namespace corsika::history diff --git a/Stack/History/EventType.hpp b/Stack/History/EventType.hpp new file mode 100644 index 0000000000000000000000000000000000000000..4781d5c64c085684a8ea139abda2aa856b56cd66 --- /dev/null +++ b/Stack/History/EventType.hpp @@ -0,0 +1,13 @@ +/* + * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#pragma once + +namespace corsika::history { + enum class EventType { Uninitialized, Interaction, Decay }; +} diff --git a/Stack/History/HistoryObservationPlane.hpp b/Stack/History/HistoryObservationPlane.hpp index 019d5e1ee24895b87606a6ef0fcc4fb188999e1c..ef1aa037371b77347960ac8813ee8e91de732a78 100644 --- a/Stack/History/HistoryObservationPlane.hpp +++ b/Stack/History/HistoryObservationPlane.hpp @@ -21,21 +21,20 @@ namespace corsika::history { namespace detail { inline auto hist_factory() { - /*auto h = boost::histogram::make_histogram( - boost::histogram::axis::regular<double, boost::histogram::axis::transform::log>{ - 130, 1e8, 1e21, "muon energy/eV"}, - boost::histogram::axis::integer<int, boost::histogram::use_default, - boost::histogram::axis::option::growth_t>{ - 0, 10, "hadronic generation"}, - boost::histogram::axis::regular<double, boost::histogram::axis::transform::log>{ - 130, 1e8, 1e21, "hadronic energy/eV"}, - boost::histogram::axis::category<int, boost::histogram::use_default, - boost::histogram::axis::option::growth_t>{});*/ - - auto h = boost::histogram::make_histogram( - boost::histogram::axis::integer<int, boost::histogram::use_default, - boost::histogram::axis::option::growth_t>{ - 0, 10, "hadronic generation"}); + namespace bh = boost::histogram; + namespace bha = bh::axis; + auto h = bh::make_histogram( + bha::regular<double, bha::transform::log>{130, 1e8, 1e21, "muon energy/eV"}, + bha::integer<int, bh::use_default, bha::option::growth_t>{ + 0, 10, "hadronic interaction generation"}, + bha::regular<double, bha::transform::log>{130, 1e8, 1e21, "hadronic energy/eV"}, + bha::category<int, bh::use_default, bha::option::growth_t>{}); + /* + auto h = bh::make_histogram( + bha::integer<int, bh::use_default, + bha::option::growth_t>{ + 0, 10, "hadronic generation"}); + */ return h; } } // namespace detail