From 37d1a8c4247872bd84f5458fc94921d398d7d01a Mon Sep 17 00:00:00 2001 From: ralfulrich <ralf.ulrich@kit.edu> Date: Sat, 18 Jul 2020 10:23:24 +0200 Subject: [PATCH] cleanup some Inits sneaking in via other MRs --- Documentation/Examples/vertical_EAS.cc | 7 ++----- Environment/BaseExponential.h | 1 - Environment/SlidingPlanarExponential.h | 1 - Environment/testShowerAxis.cc | 2 -- .../ProcessSequence/testProcessSequence.cc | 21 +++++++------------ Processes/CONEXSourceCut/CONEXSourceCut.cc | 5 ----- Processes/CONEXSourceCut/CONEXSourceCut.h | 6 ------ Processes/CONEXSourceCut/CONEX_f.h | 2 -- .../CONEXSourceCut/testCONEXSourceCut.cc | 9 +++----- .../testInteractionCounter.cc | 3 +-- Processes/ParticleCut/ParticleCut.cc | 1 - Processes/ParticleCut/testParticleCut.cc | 1 - Processes/Sibyll/Interaction.cc | 6 ++++-- Processes/Sibyll/Interaction.h | 4 ++-- 14 files changed, 20 insertions(+), 49 deletions(-) diff --git a/Documentation/Examples/vertical_EAS.cc b/Documentation/Examples/vertical_EAS.cc index 5d4731ad8..3e1af668f 100644 --- a/Documentation/Examples/vertical_EAS.cc +++ b/Documentation/Examples/vertical_EAS.cc @@ -195,9 +195,6 @@ int main(int argc, char** argv) { process::UrQMD::UrQMD urqmd; process::interaction_counter::InteractionCounter urqmdCounted{urqmd}; - sibyllNuc.Init(); - sibyll.Init(); - process::conex_source_cut::CONEXSourceCut conexSource( center, showerAxis, t, injectionHeight, E0, particles::GetPDG(particles::Code::Proton)); @@ -209,8 +206,8 @@ int main(int argc, char** argv) { 55_GeV); auto decaySequence = decayPythia << decaySibyll; - auto sequence = switchProcess << reset_particle_mass << decaySequence << conexSource << longprof - << eLoss << cut << observationLevel; + auto sequence = switchProcess << reset_particle_mass << decaySequence << conexSource + << longprof << eLoss << cut << observationLevel; // define air shower object, run simulation tracking_line::TrackingLine tracking; diff --git a/Environment/BaseExponential.h b/Environment/BaseExponential.h index 47391dc56..97e2689bc 100644 --- a/Environment/BaseExponential.h +++ b/Environment/BaseExponential.h @@ -6,7 +6,6 @@ * the license. */ - #pragma once #include <corsika/geometry/Line.h> diff --git a/Environment/SlidingPlanarExponential.h b/Environment/SlidingPlanarExponential.h index 305b8666c..41058d864 100644 --- a/Environment/SlidingPlanarExponential.h +++ b/Environment/SlidingPlanarExponential.h @@ -6,7 +6,6 @@ * the license. */ - #pragma once #include <corsika/environment/FlatExponential.h> diff --git a/Environment/testShowerAxis.cc b/Environment/testShowerAxis.cc index 8c2441b98..232b734cb 100644 --- a/Environment/testShowerAxis.cc +++ b/Environment/testShowerAxis.cc @@ -1,8 +1,6 @@ /* * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu * - * See file AUTHORS for a list of contributors. - * * 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. diff --git a/Framework/ProcessSequence/testProcessSequence.cc b/Framework/ProcessSequence/testProcessSequence.cc index 4b71e89c0..e10d82e59 100644 --- a/Framework/ProcessSequence/testProcessSequence.cc +++ b/Framework/ProcessSequence/testProcessSequence.cc @@ -32,7 +32,6 @@ public: : fV(v) { cout << "globalCount: " << globalCount << ", fV: " << fV << std::endl; - assert(globalCount == fV); globalCount++; } @@ -51,7 +50,6 @@ public: ContinuousProcess2(const int v) : fV(v) { cout << "globalCount: " << globalCount << ", fV: " << fV << std::endl; - assert(globalCount == fV); globalCount++; } @@ -68,7 +66,6 @@ public: Process1(const int v) : fV(v) { cout << "globalCount: " << globalCount << ", fV: " << fV << std::endl; - assert(globalCount == fV); globalCount++; } @@ -77,7 +74,8 @@ public: for (int i = 0; i < nData; ++i) d.p[i] += 1 + i; return EProcessReturn::eOk; } - // private: + +private: int fV; }; @@ -88,7 +86,6 @@ public: Process2(const int v) : fV(v) { cout << "globalCount: " << globalCount << ", fV: " << fV << std::endl; - assert(globalCount == fV); globalCount++; } @@ -111,7 +108,6 @@ public: Process3(const int v) : fV(v) { cout << "globalCount: " << globalCount << ", fV: " << fV << std::endl; - assert(globalCount == fV); globalCount++; } @@ -134,7 +130,6 @@ public: Process4(const int v) : fV(v) { cout << "globalCount: " << globalCount << ", fV: " << fV << std::endl; - assert(globalCount == fV); globalCount++; } @@ -143,7 +138,6 @@ public: for (int i = 0; i < nData; ++i) { d.p[i] /= 1.2; } return EProcessReturn::eOk; } - // inline double MinStepLength(D& d) { template <typename Particle> EProcessReturn DoInteraction(Particle&) const { return EProcessReturn::eOk; @@ -157,7 +151,6 @@ public: Decay1(const int v) : fV(v) { cout << "Decay1()" << endl; - assert(globalCount == fV); globalCount++; } @@ -193,16 +186,18 @@ struct DummyTrajectory {}; TEST_CASE("Process Sequence", "[Process Sequence]") { - SECTION("Check init order") { + SECTION("Check construction") { globalCount = 0; Process1 m1(0); + CHECK(globalCount == 1); Process2 m2(1); + CHECK(globalCount == 2); Process3 m3(2); + CHECK(globalCount == 3); Process4 m4(3); + CHECK(globalCount == 4); - auto sequence = m1 << m2 << m3 << m4; - - globalCount = 0; + [[maybe_unused]] auto sequence = m1 << m2 << m3 << m4; } SECTION("interaction length") { diff --git a/Processes/CONEXSourceCut/CONEXSourceCut.cc b/Processes/CONEXSourceCut/CONEXSourceCut.cc index 5d0f68f8c..8b90ff0ab 100644 --- a/Processes/CONEXSourceCut/CONEXSourceCut.cc +++ b/Processes/CONEXSourceCut/CONEXSourceCut.cc @@ -1,8 +1,6 @@ /* * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu * - * See file AUTHORS for a list of contributors. - * * 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. @@ -119,8 +117,6 @@ void CONEXSourceCut::addParticle(int egs_pid, HEPEnergyType energy, conex::cegs4_(n, i); } -void CONEXSourceCut::Init() {} - void CONEXSourceCut::SolveCE() { conex::conexcascade_(); @@ -163,7 +159,6 @@ void CONEXSourceCut::SolveCE() { } } - CONEXSourceCut::CONEXSourceCut(geometry::Point center, environment::ShowerAxis const& showerAxis, units::si::LengthType groundDist, diff --git a/Processes/CONEXSourceCut/CONEXSourceCut.h b/Processes/CONEXSourceCut/CONEXSourceCut.h index 9ea6e3d68..fec7190d3 100644 --- a/Processes/CONEXSourceCut/CONEXSourceCut.h +++ b/Processes/CONEXSourceCut/CONEXSourceCut.h @@ -1,8 +1,6 @@ /* * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu * - * See file AUTHORS for a list of contributors. - * * 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. @@ -37,8 +35,6 @@ namespace corsika::process { particles::PDGCode primaryID); corsika::process::EProcessReturn DoSecondaries(corsika::setup::StackView&); - void Init(); - void SolveCE(); void addParticle(int egs_pid, units::si::HEPEnergyType energy, @@ -49,7 +45,6 @@ namespace corsika::process { auto const& GetObserverCS() const { return conexObservationCS_; } private: - //! CONEX e.m. particle codes static std::array<std::pair<particles::Code, int>, 3> constexpr egs_em_codes_{ {{particles::Code::Gamma, 0}, @@ -66,4 +61,3 @@ namespace corsika::process { }; } // namespace conex_source_cut } // namespace corsika::process - diff --git a/Processes/CONEXSourceCut/CONEX_f.h b/Processes/CONEXSourceCut/CONEX_f.h index a3076f5b6..3baba085e 100644 --- a/Processes/CONEXSourceCut/CONEX_f.h +++ b/Processes/CONEXSourceCut/CONEX_f.h @@ -1,8 +1,6 @@ /* * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu * - * See file AUTHORS for a list of contributors. - * * 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. diff --git a/Processes/CONEXSourceCut/testCONEXSourceCut.cc b/Processes/CONEXSourceCut/testCONEXSourceCut.cc index 058714e95..3dfc6c73e 100644 --- a/Processes/CONEXSourceCut/testCONEXSourceCut.cc +++ b/Processes/CONEXSourceCut/testCONEXSourceCut.cc @@ -1,8 +1,6 @@ /* * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu * - * See file AUTHORS for a list of contributors. - * * 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. @@ -69,10 +67,9 @@ TEST_CASE("CONEXSourceCut") { environment::ShowerAxis const showerAxis{injectionPos, (showerCore - injectionPos) * 1.02, env}; - corsika::process::sibyll::Interaction sibyll; - process::sibyll::NuclearInteraction sibyllNuc(sibyll, env); - sibyll.Init(); - sibyllNuc.Init(); + // need to initialize Sibyll, done in constructor: + process::sibyll::Interaction sibyll; + [[maybe_unused]] process::sibyll::NuclearInteraction sibyllNuc(sibyll, env); corsika::process::conex_source_cut::CONEXSourceCut conex( center, showerAxis, t, injectionHeight, E0, diff --git a/Processes/InteractionCounter/testInteractionCounter.cc b/Processes/InteractionCounter/testInteractionCounter.cc index 880e86f5c..8b47f1bf6 100644 --- a/Processes/InteractionCounter/testInteractionCounter.cc +++ b/Processes/InteractionCounter/testInteractionCounter.cc @@ -6,7 +6,6 @@ * the license. */ - #include <corsika/process/interaction_counter/InteractionCounter.h> #include <corsika/environment/Environment.h> @@ -118,7 +117,7 @@ TEST_CASE("InteractionCounter") { auto [env, csPtr, nodePtr] = setupEnvironment(particles::Code::Oxygen); [[maybe_unused]] auto& env_dummy = env; - + SECTION("DoInteraction nucleus") { unsigned short constexpr A = 14, Z = 7; auto [stackPtr, secViewPtr] = setupStack(A, Z, 105_TeV, nodePtr, *csPtr); diff --git a/Processes/ParticleCut/ParticleCut.cc b/Processes/ParticleCut/ParticleCut.cc index 23a860bd6..defa0c101 100644 --- a/Processes/ParticleCut/ParticleCut.cc +++ b/Processes/ParticleCut/ParticleCut.cc @@ -6,7 +6,6 @@ * the license. */ - #include <corsika/process/particle_cut/ParticleCut.h> using namespace std; diff --git a/Processes/ParticleCut/testParticleCut.cc b/Processes/ParticleCut/testParticleCut.cc index 9c98697f0..b3d375f20 100644 --- a/Processes/ParticleCut/testParticleCut.cc +++ b/Processes/ParticleCut/testParticleCut.cc @@ -6,7 +6,6 @@ * the license. */ - #include <corsika/process/particle_cut/ParticleCut.h> #include <corsika/environment/Environment.h> diff --git a/Processes/Sibyll/Interaction.cc b/Processes/Sibyll/Interaction.cc index 19a13678d..8300462c6 100644 --- a/Processes/Sibyll/Interaction.cc +++ b/Processes/Sibyll/Interaction.cc @@ -32,6 +32,8 @@ using Track = Trajectory; namespace corsika::process::sibyll { + bool Interaction::initialized_ = false; + Interaction::Interaction() { using random::RNGManager; @@ -317,8 +319,8 @@ namespace corsika::process::sibyll { auto pnew = vP.AddSecondary( tuple<particles::Code, units::si::HEPEnergyType, stack::MomentumVector, geometry::Point, units::si::TimeType>{ - pid, Plab.GetTimeLikeComponent(), Plab.GetSpaceLikeComponents(), pOrig, - tOrig}); + pid, Plab.GetTimeLikeComponent(), Plab.GetSpaceLikeComponents(), pOrig, + tOrig}); Plab_final += pnew.GetMomentum(); Elab_final += pnew.GetEnergy(); diff --git a/Processes/Sibyll/Interaction.h b/Processes/Sibyll/Interaction.h index a37021e80..bcc9b632e 100644 --- a/Processes/Sibyll/Interaction.h +++ b/Processes/Sibyll/Interaction.h @@ -20,7 +20,7 @@ namespace corsika::process::sibyll { int count_ = 0; int nucCount_ = 0; - bool initialized_ = false; + static bool initialized_; ///! flag to assure init is done only once public: Interaction(); @@ -28,7 +28,7 @@ namespace corsika::process::sibyll { void SetAllStable(); - bool WasInitialized() { return initialized_; } + static bool WasInitialized() { return initialized_; } bool IsValidCoMEnergy(corsika::units::si::HEPEnergyType ecm) const { return (minEnergyCoM_ <= ecm) && (ecm <= maxEnergyCoM_); } -- GitLab