From 3eca9dd3ec2ee66c4cc1148445fff0042a6f42ec Mon Sep 17 00:00:00 2001 From: ralfulrich <ralf.ulrich@kit.edu> Date: Fri, 25 Sep 2020 15:39:53 +0200 Subject: [PATCH] style --- Documentation/Examples/geometry_example.cc | 4 +- Documentation/Examples/helix_example.cc | 2 +- .../Examples/particle_list_example.cc | 2 +- Documentation/Examples/stack_example.cc | 2 +- .../Examples/staticsequence_example.cc | 2 +- Documentation/Examples/stopping_power.cc | 2 +- Framework/Cascade/testCascade.cc | 6 +- Framework/StackInterface/SecondaryView.h | 5 +- .../StackInterface/StackIteratorInterface.h | 59 +++++++++++++------ Processes/CONEXSourceCut/CONEXSourceCut.cc | 4 +- Setup/SetupStack.h | 18 +++--- 11 files changed, 64 insertions(+), 42 deletions(-) diff --git a/Documentation/Examples/geometry_example.cc b/Documentation/Examples/geometry_example.cc index 4c38d1dbf..da23d81e0 100644 --- a/Documentation/Examples/geometry_example.cc +++ b/Documentation/Examples/geometry_example.cc @@ -22,8 +22,8 @@ using namespace corsika::units::si; int main() { - std::cout << "geometry_example" << std::endl; - + std::cout << "geometry_example" << std::endl; + // define the root coordinate system geometry::CoordinateSystem& root = geometry::RootCoordinateSystem::GetInstance().GetRootCoordinateSystem(); diff --git a/Documentation/Examples/helix_example.cc b/Documentation/Examples/helix_example.cc index d200cc996..9f3eba67e 100644 --- a/Documentation/Examples/helix_example.cc +++ b/Documentation/Examples/helix_example.cc @@ -22,7 +22,7 @@ using namespace corsika::units::si; int main() { std::cout << "helix_example" << std::endl; - + geometry::CoordinateSystem& root = geometry::RootCoordinateSystem::GetInstance().GetRootCoordinateSystem(); diff --git a/Documentation/Examples/particle_list_example.cc b/Documentation/Examples/particle_list_example.cc index 5aefdd414..342c08e7f 100644 --- a/Documentation/Examples/particle_list_example.cc +++ b/Documentation/Examples/particle_list_example.cc @@ -27,7 +27,7 @@ using namespace std; int main() { std::cout << "particle_list_example" << std::endl; - + cout << "------------------------------------------" << "particles in CORSIKA" << "------------------------------------------" << endl; diff --git a/Documentation/Examples/stack_example.cc b/Documentation/Examples/stack_example.cc index dd7de9274..cc638dbe8 100644 --- a/Documentation/Examples/stack_example.cc +++ b/Documentation/Examples/stack_example.cc @@ -51,7 +51,7 @@ void read(corsika::stack::super_stupid::SuperStupidStack& s) { int main() { std::cout << "stack_example" << std::endl; - + corsika::stack::super_stupid::SuperStupidStack s; fill(s); read(s); diff --git a/Documentation/Examples/staticsequence_example.cc b/Documentation/Examples/staticsequence_example.cc index 5959ca5f8..ca75fe4b2 100644 --- a/Documentation/Examples/staticsequence_example.cc +++ b/Documentation/Examples/staticsequence_example.cc @@ -102,7 +102,7 @@ void modular() { int main() { std::cout << "staticsequence_example" << std::endl; - + modular(); return 0; } diff --git a/Documentation/Examples/stopping_power.cc b/Documentation/Examples/stopping_power.cc index 4499aaa74..f35584827 100644 --- a/Documentation/Examples/stopping_power.cc +++ b/Documentation/Examples/stopping_power.cc @@ -35,7 +35,7 @@ using namespace corsika::units::si; int main() { std::cout << "stopping_power" << std::endl; - + feenableexcept(FE_INVALID); // setup environment, geometry diff --git a/Framework/Cascade/testCascade.cc b/Framework/Cascade/testCascade.cc index 9db2c73cc..57d565d55 100644 --- a/Framework/Cascade/testCascade.cc +++ b/Framework/Cascade/testCascade.cc @@ -77,11 +77,13 @@ public: view.AddSecondary( std::tuple<particles::Code, units::si::HEPEnergyType, corsika::stack::MomentumVector, geometry::Point, units::si::TimeType>{ - projectile.GetPID(), E / 2, projectile.GetMomentum(), projectile.GetPosition(), projectile.GetTime()}); + projectile.GetPID(), E / 2, projectile.GetMomentum(), + projectile.GetPosition(), projectile.GetTime()}); view.AddSecondary( std::tuple<particles::Code, units::si::HEPEnergyType, corsika::stack::MomentumVector, geometry::Point, units::si::TimeType>{ - projectile.GetPID(), E / 2, projectile.GetMomentum(), projectile.GetPosition(), projectile.GetTime()}); + projectile.GetPID(), E / 2, projectile.GetMomentum(), + projectile.GetPosition(), projectile.GetTime()}); return EProcessReturn::eInteracted; } diff --git a/Framework/StackInterface/SecondaryView.h b/Framework/StackInterface/SecondaryView.h index 6061fa1ba..27f8dc6f3 100644 --- a/Framework/StackInterface/SecondaryView.h +++ b/Framework/StackInterface/SecondaryView.h @@ -78,7 +78,7 @@ namespace corsika::stack { ParticleInterface, InnerStackTypeValue>; using ConstStackIteratorValue = ConstStackIteratorInterface<typename std::remove_reference<StackDataType>::type, - ParticleInterface, InnerStackTypeValue>; + ParticleInterface, InnerStackTypeValue>; /// @} using StackIterator = @@ -123,7 +123,6 @@ namespace corsika::stack { , inner_stack_(vI.GetStack()) , projectile_index_(vI.GetIndex()) {} - /** * This returns the projectile/parent in the original Stack, where this * SecondaryView is derived from. This projectile should not be @@ -142,8 +141,8 @@ namespace corsika::stack { // NOTE: 0 is special marker here for PROJECTILE, see GetIndexFromIterator return StackIterator(*this, 0); } - public: + public: template <typename... Args> StackIterator AddSecondary(const Args... v) { StackIterator proj = GetProjectile(); diff --git a/Framework/StackInterface/StackIteratorInterface.h b/Framework/StackInterface/StackIteratorInterface.h index 010d1fe1e..840962e1a 100644 --- a/Framework/StackInterface/StackIteratorInterface.h +++ b/Framework/StackInterface/StackIteratorInterface.h @@ -24,8 +24,8 @@ namespace corsika::stack { class SecondaryView; // forward decl template <typename TStackData, template <typename> typename TParticleInterface, - typename StackType> - class ConstStackIteratorInterface; // forward decl + typename StackType> + class ConstStackIteratorInterface; // forward decl /** @class StackIteratorInterface @@ -86,13 +86,14 @@ namespace corsika::stack { friend class SecondaryView<TStackData, TParticleInterface>; // access for SecondaryView - template <typename T> - friend class corsika::history::HistorySecondaryView; + template <typename T> + friend class corsika::history::HistorySecondaryView; + + friend class ConstStackIteratorInterface<TStackData, TParticleInterface, StackType>; - friend class ConstStackIteratorInterface<TStackData, TParticleInterface, StackType>; - protected: unsigned int index_ = 0; + private: StackType* data_ = 0; // info: Particles and StackIterators become invalid when parent // Stack is copied or deleted! @@ -175,10 +176,18 @@ namespace corsika::stack { StackIteratorInterface operator+(int delta) const { return StackIteratorInterface(*data_, index_ + delta); } - bool operator==(const StackIteratorInterface& rhs) const { return index_ == rhs.index_; } - bool operator!=(const StackIteratorInterface& rhs) const { return index_ != rhs.index_; } - bool operator==(const ConstStackIteratorInterface<TStackData, TParticleInterface, StackType>& rhs) const; // implement below - bool operator!=(const ConstStackIteratorInterface<TStackData, TParticleInterface, StackType>& rhs) const; // implement below + bool operator==(const StackIteratorInterface& rhs) const { + return index_ == rhs.index_; + } + bool operator!=(const StackIteratorInterface& rhs) const { + return index_ != rhs.index_; + } + bool operator==( + const ConstStackIteratorInterface<TStackData, TParticleInterface, StackType>& rhs) + const; // implement below + bool operator!=( + const ConstStackIteratorInterface<TStackData, TParticleInterface, StackType>& rhs) + const; // implement below /** * Convert iterator to value type, where value type is the user-provided particle @@ -248,6 +257,7 @@ namespace corsika::stack { protected: unsigned int index_ = 0; + private: const StackType* data_ = 0; // info: Particles and StackIterators become invalid when // parent Stack is copied or deleted! @@ -295,7 +305,7 @@ namespace corsika::stack { return tmp; } ConstStackIteratorInterface operator+(const int delta) const { - return ConstStackIteratorInterface(*data_, index_+delta); + return ConstStackIteratorInterface(*data_, index_ + delta); } bool operator==(const ConstStackIteratorInterface& rhs) const { return index_ == rhs.index_; @@ -303,8 +313,14 @@ namespace corsika::stack { bool operator!=(const ConstStackIteratorInterface& rhs) const { return index_ != rhs.index_; } - bool operator==(const StackIteratorInterface<TStackData, TParticleInterface, StackType>& rhs) const { return index_ == rhs.index_; } - bool operator!=(const StackIteratorInterface<TStackData, TParticleInterface, StackType>& rhs) const { return index_ != rhs.index_; } + bool operator==(const StackIteratorInterface<TStackData, TParticleInterface, + StackType>& rhs) const { + return index_ == rhs.index_; + } + bool operator!=(const StackIteratorInterface<TStackData, TParticleInterface, + StackType>& rhs) const { + return index_ != rhs.index_; + } const ParticleInterfaceType& operator*() const { return static_cast<const ParticleInterfaceType&>(*this); @@ -326,13 +342,20 @@ namespace corsika::stack { ///@} }; // end class ConstStackIterator - - template <typename TStackData, template <typename> typename TParticleInterface, + template <typename TStackData, template <typename> typename TParticleInterface, typename StackType> - bool StackIteratorInterface<TStackData, TParticleInterface, StackType>::operator==(const ConstStackIteratorInterface<TStackData, TParticleInterface, StackType>& rhs) const { return index_ == rhs.index_; } + bool StackIteratorInterface<TStackData, TParticleInterface, StackType>::operator==( + const ConstStackIteratorInterface<TStackData, TParticleInterface, StackType>& rhs) + const { + return index_ == rhs.index_; + } - template <typename TStackData, template <typename> typename TParticleInterface, + template <typename TStackData, template <typename> typename TParticleInterface, typename StackType> - bool StackIteratorInterface<TStackData, TParticleInterface, StackType>::operator!=(const ConstStackIteratorInterface<TStackData, TParticleInterface, StackType>& rhs) const { return index_ != rhs.index_; } + bool StackIteratorInterface<TStackData, TParticleInterface, StackType>::operator!=( + const ConstStackIteratorInterface<TStackData, TParticleInterface, StackType>& rhs) + const { + return index_ != rhs.index_; + } } // namespace corsika::stack diff --git a/Processes/CONEXSourceCut/CONEXSourceCut.cc b/Processes/CONEXSourceCut/CONEXSourceCut.cc index 7a0da45a7..8039d8ed8 100644 --- a/Processes/CONEXSourceCut/CONEXSourceCut.cc +++ b/Processes/CONEXSourceCut/CONEXSourceCut.cc @@ -31,11 +31,11 @@ corsika::process::EProcessReturn CONEXSourceCut::DoSecondaries( [=](auto const& p) { return pid == p.first; }); if (it != egs_em_codes_.cend()) { // EM particle - + auto const egs_pid = it->second; addParticle(egs_pid, p.GetEnergy(), p.GetMass(), p.GetPosition(), - p.GetMomentum().normalized(), p.GetTime()); + p.GetMomentum().normalized(), p.GetTime()); p.Delete(); } diff --git a/Setup/SetupStack.h b/Setup/SetupStack.h index 6feb7cfbe..9ec7a86a4 100644 --- a/Setup/SetupStack.h +++ b/Setup/SetupStack.h @@ -95,7 +95,7 @@ namespace corsika::setup { // ------------------------------------------ // add geometry node tracking data to stack: - + // the GeometryNode stack needs to know the type of geometry-nodes from the // environment: template <typename TStackIter> @@ -114,26 +114,24 @@ namespace corsika::setup { corsika::stack::node::GeometryData<setup::SetupEnvironment>, StackWithGeometryInterface>; - // ------------------------------------------ // Add [optional] history data to stack, too: // combine dummy stack with geometry information for tracking template <typename TStackIter> using StackWithHistoryInterface = corsika::stack::CombinedParticleInterface< - StackWithGeometry::PIType, history::HistoryEventDataInterface, - TStackIter>; + StackWithGeometry::PIType, history::HistoryEventDataInterface, TStackIter>; + + using StackWithHistory = + corsika::stack::CombinedStack<typename StackWithGeometry::StackImpl, + history::HistoryEventData, + StackWithHistoryInterface>; - using StackWithHistory = corsika::stack::CombinedStack< - typename StackWithGeometry::StackImpl, - history::HistoryEventData, StackWithHistoryInterface>; - } // namespace detail - // --------------------------------------- // this is the FINAL stack we use in C8: - //using Stack = detail::StackWithGeometry; + // using Stack = detail::StackWithGeometry; using Stack = detail::StackWithHistory; /* -- GitLab