From 8112877b5d4206a928313c4ec575a6cb3cf6980a Mon Sep 17 00:00:00 2001 From: Remy Prechelt <prechelt@hawaii.edu> Date: Fri, 10 Jul 2020 08:38:36 -1000 Subject: [PATCH] Remove Init() from Sibyll. --- Processes/Sibyll/Decay.cc | 1 - Processes/Sibyll/Decay.h | 1 - Processes/Sibyll/Interaction.cc | 13 +++---- Processes/Sibyll/Interaction.h | 2 -- Processes/Sibyll/NuclearInteraction.cc | 49 ++++++++++++-------------- Processes/Sibyll/NuclearInteraction.h | 2 +- Processes/Sibyll/SibStack.h | 1 - Processes/Sibyll/testSibyll.cc | 4 --- 8 files changed, 29 insertions(+), 44 deletions(-) diff --git a/Processes/Sibyll/Decay.cc b/Processes/Sibyll/Decay.cc index 04113d40b..d1a0c0cb1 100644 --- a/Processes/Sibyll/Decay.cc +++ b/Processes/Sibyll/Decay.cc @@ -42,7 +42,6 @@ namespace corsika::process::sibyll { } Decay::~Decay() { cout << "Sibyll::Decay n=" << fCount << endl; } - void Decay::Init() {} bool Decay::CanHandleDecay(const particles::Code vParticleCode) { using namespace corsika::particles; diff --git a/Processes/Sibyll/Decay.h b/Processes/Sibyll/Decay.h index de8a730d1..85e622737 100644 --- a/Processes/Sibyll/Decay.h +++ b/Processes/Sibyll/Decay.h @@ -27,7 +27,6 @@ namespace corsika::process { Decay(); Decay(std::set<particles::Code>); ~Decay(); - void Init(); void PrintDecayConfig(const corsika::particles::Code); void PrintDecayConfig(); diff --git a/Processes/Sibyll/Interaction.cc b/Processes/Sibyll/Interaction.cc index 4894301e7..19a13678d 100644 --- a/Processes/Sibyll/Interaction.cc +++ b/Processes/Sibyll/Interaction.cc @@ -32,14 +32,7 @@ using Track = Trajectory; namespace corsika::process::sibyll { - Interaction::Interaction() {} - - Interaction::~Interaction() { - cout << "Sibyll::Interaction n=" << count_ << " Nnuc=" << nucCount_ << endl; - } - - void Interaction::Init() { - + Interaction::Interaction() { using random::RNGManager; // initialize Sibyll @@ -49,6 +42,10 @@ namespace corsika::process::sibyll { } } + Interaction::~Interaction() { + cout << "Sibyll::Interaction n=" << count_ << " Nnuc=" << nucCount_ << endl; + } + void Interaction::SetAllStable() { for (int i = 0; i < 99; ++i) s_csydec_.idb[i] = -1 * abs(s_csydec_.idb[i]); } diff --git a/Processes/Sibyll/Interaction.h b/Processes/Sibyll/Interaction.h index 80a128218..a37021e80 100644 --- a/Processes/Sibyll/Interaction.h +++ b/Processes/Sibyll/Interaction.h @@ -26,8 +26,6 @@ namespace corsika::process::sibyll { Interaction(); ~Interaction(); - void Init(); - void SetAllStable(); bool WasInitialized() { return initialized_; } diff --git a/Processes/Sibyll/NuclearInteraction.cc b/Processes/Sibyll/NuclearInteraction.cc index 802cee933..451a5c643 100644 --- a/Processes/Sibyll/NuclearInteraction.cc +++ b/Processes/Sibyll/NuclearInteraction.cc @@ -34,12 +34,6 @@ using Track = Trajectory; namespace corsika::process::sibyll { - template <> - NuclearInteraction<SetupEnvironment>::NuclearInteraction( - process::sibyll::Interaction& hadint, SetupEnvironment const& env) - : environment_(env) - , hadronicInteraction_(hadint) {} - template <> NuclearInteraction<SetupEnvironment>::~NuclearInteraction() { cout << "Nuclib::NuclearInteraction n=" << count_ << " Nnuc=" << nucCount_ << endl; @@ -134,26 +128,6 @@ namespace corsika::process::sibyll { } } - template <> - void NuclearInteraction<SetupEnvironment>::Init() { - // initialize hadronic interaction module - // TODO: safe to run multiple initializations? - if (!hadronicInteraction_.WasInitialized()) hadronicInteraction_.Init(); - - // check compatibility of energy ranges, someone could try to use low-energy model.. - if (!hadronicInteraction_.IsValidCoMEnergy(GetMinEnergyPerNucleonCoM()) || - !hadronicInteraction_.IsValidCoMEnergy(GetMaxEnergyPerNucleonCoM())) - throw std::runtime_error( - "NuclearInteraction: hadronic interaction model incompatible!"); - - // initialize nuclib - // TODO: make sure this does not overlap with sibyll - nuc_nuc_ini_(); - - // initialize cross sections - InitializeNuclearCrossSections(); - } - template <> units::si::CrossSectionType NuclearInteraction<SetupEnvironment>::ReadCrossSectionTable( const int ia, particles::Code pTarget, units::si::HEPEnergyType elabnuc) { @@ -608,4 +582,27 @@ namespace corsika::process::sibyll { return process::EProcessReturn::eOk; } + template <> + NuclearInteraction<SetupEnvironment>::NuclearInteraction( + process::sibyll::Interaction& hadint, SetupEnvironment const& env) + : environment_(env) + , hadronicInteraction_(hadint) { + + // initialize hadronic interaction module + // TODO: safe to run multiple initializations? + + // check compatibility of energy ranges, someone could try to use low-energy model.. + if (!hadronicInteraction_.IsValidCoMEnergy(GetMinEnergyPerNucleonCoM()) || + !hadronicInteraction_.IsValidCoMEnergy(GetMaxEnergyPerNucleonCoM())) + throw std::runtime_error( + "NuclearInteraction: hadronic interaction model incompatible!"); + + // initialize nuclib + // TODO: make sure this does not overlap with sibyll + nuc_nuc_ini_(); + + // initialize cross sections + InitializeNuclearCrossSections(); + } + } // namespace corsika::process::sibyll diff --git a/Processes/Sibyll/NuclearInteraction.h b/Processes/Sibyll/NuclearInteraction.h index 061545c76..8897d199d 100644 --- a/Processes/Sibyll/NuclearInteraction.h +++ b/Processes/Sibyll/NuclearInteraction.h @@ -30,7 +30,7 @@ namespace corsika::process::sibyll { public: NuclearInteraction(corsika::process::sibyll::Interaction&, TEnvironment const&); ~NuclearInteraction(); - void Init(); + void InitializeNuclearCrossSections(); void PrintCrossSectionTable(corsika::particles::Code); corsika::units::si::CrossSectionType ReadCrossSectionTable( diff --git a/Processes/Sibyll/SibStack.h b/Processes/Sibyll/SibStack.h index 41cbce1e4..e3ebcc8ff 100644 --- a/Processes/Sibyll/SibStack.h +++ b/Processes/Sibyll/SibStack.h @@ -22,7 +22,6 @@ namespace corsika::process::sibyll { class SibStackData { public: - void Init(); void Dump() const {} void Clear() { s_plist_.np = 0; } diff --git a/Processes/Sibyll/testSibyll.cc b/Processes/Sibyll/testSibyll.cc index 7568f2b74..2aab98c2a 100644 --- a/Processes/Sibyll/testSibyll.cc +++ b/Processes/Sibyll/testSibyll.cc @@ -135,7 +135,6 @@ TEST_CASE("SibyllInterface", "[processes]") { Interaction model; - model.Init(); [[maybe_unused]] const process::EProcessReturn ret = model.DoInteraction(projectile); [[maybe_unused]] auto const pSum = sumMomentum(view, cs); @@ -163,7 +162,6 @@ TEST_CASE("SibyllInterface", "[processes]") { Interaction hmodel; NuclearInteraction model(hmodel, env); - model.Init(); [[maybe_unused]] const process::EProcessReturn ret = model.DoInteraction(projectile); [[maybe_unused]] const GrammageType length = model.GetInteractionLength(particle); } @@ -187,8 +185,6 @@ TEST_CASE("SibyllInterface", "[processes]") { model.PrintDecayConfig(); - model.Init(); - [[maybe_unused]] const TimeType time = model.GetLifetime(particle); /*[[maybe_unused]] const process::EProcessReturn ret =*/model.DoDecay(projectile); -- GitLab