From 219e5bd972967640f495c2328517bacca9c9c378 Mon Sep 17 00:00:00 2001
From: ralfulrich <ralf.ulrich@kit.edu>
Date: Wed, 19 Sep 2018 11:38:37 +0200
Subject: [PATCH] move units to units::si

---
 Documentation/Examples/geometry_example.cc |  2 +-
 Documentation/Examples/helix_example.cc    |  2 +-
 Documentation/Examples/stack_example.cc    |  2 +-
 Framework/Cascade/Cascade.h                |  4 +--
 Framework/Geometry/BaseTrajectory.h        |  2 +-
 Framework/Geometry/CoordinateSystem.h      |  2 +-
 Framework/Geometry/Helix.h                 | 10 ++++----
 Framework/Geometry/LineTrajectory.h        |  4 +--
 Framework/Geometry/Point.h                 |  4 +--
 Framework/Geometry/QuantityVector.h        |  9 ++++---
 Framework/Geometry/Trajectory.h            |  6 ++---
 Framework/Geometry/testGeometry.cc         | 30 +++++++++++-----------
 Framework/Particles/ParticleProperties.h   | 10 ++++----
 Framework/Particles/pdxml_reader.py        |  8 +++---
 Framework/Particles/testParticles.cc       |  2 +-
 Framework/Units/PhysicalConstants.h        |  4 +--
 Framework/Units/PhysicalUnits.h            |  6 ++---
 Framework/Units/testUnits.cc               |  2 +-
 Stack/DummyStack/SuperStupidStack.h        |  4 +--
 Stack/SuperStupidStack/SuperStupidStack.h  |  4 +--
 20 files changed, 59 insertions(+), 58 deletions(-)

diff --git a/Documentation/Examples/geometry_example.cc b/Documentation/Examples/geometry_example.cc
index 9c459db16..6a05974fd 100644
--- a/Documentation/Examples/geometry_example.cc
+++ b/Documentation/Examples/geometry_example.cc
@@ -9,7 +9,7 @@
 #include <typeinfo>
 
 using namespace corsika::geometry;
-using namespace corsika::units;
+using namespace corsika::units::si;
 
 int main() {
   // define the root coordinate system
diff --git a/Documentation/Examples/helix_example.cc b/Documentation/Examples/helix_example.cc
index 5caf35a43..9d6cdb23c 100644
--- a/Documentation/Examples/helix_example.cc
+++ b/Documentation/Examples/helix_example.cc
@@ -8,7 +8,7 @@
 #include <iostream>
 
 using namespace corsika::geometry;
-using namespace corsika::units;
+using namespace corsika::units::si;
 
 int main() {
 
diff --git a/Documentation/Examples/stack_example.cc b/Documentation/Examples/stack_example.cc
index e70b7e6c8..691cdb384 100644
--- a/Documentation/Examples/stack_example.cc
+++ b/Documentation/Examples/stack_example.cc
@@ -7,7 +7,7 @@ using namespace std;
 // using namespace corsika::literals;
 // using namespace corsika::io;
 
-using namespace corsika::units;
+using namespace corsika::units::si;
 using namespace corsika::stack;
 
 void fill(corsika::stack::super_stupid::SuperStupidStack& s) {
diff --git a/Framework/Cascade/Cascade.h b/Framework/Cascade/Cascade.h
index 6fe5e1700..3ef8ce928 100644
--- a/Framework/Cascade/Cascade.h
+++ b/Framework/Cascade/Cascade.h
@@ -5,7 +5,7 @@
 #include <corsika/geometry/Point.h>          // to be removed
 #include <corsika/units/PhysicalUnits.h>
 
-using namespace corsika::units;
+using namespace corsika::units::si;
 
 namespace corsika::cascade {
 
@@ -53,7 +53,7 @@ namespace corsika::cascade {
       corsika::geometry::CoordinateSystem root;
       Trajectory trajectory(
           corsika::geometry::Point(root, {0_m, 0_m, 0_m}),
-          corsika::geometry::Vector<corsika::units::SpeedType::dimension_type>(
+          corsika::geometry::Vector<corsika::units::si::SpeedType::dimension_type>(
               root, 0 * 1_m / second, 0 * 1_m / second, 1 * 1_m / second));
       fProcesseList.DoContinuous(particle, trajectory, fStack);
       // if (particle.IsMarkedToBeDeleted())
diff --git a/Framework/Geometry/BaseTrajectory.h b/Framework/Geometry/BaseTrajectory.h
index ec5e4062c..485e4b734 100644
--- a/Framework/Geometry/BaseTrajectory.h
+++ b/Framework/Geometry/BaseTrajectory.h
@@ -15,7 +15,7 @@ namespace corsika::geometry {
 
   public:
     //!< t for \f$ t = 0 \f$, the starting Point shall be returned.
-    virtual Point GetPosition(corsika::units::TimeType t) const = 0;
+    virtual Point GetPosition(corsika::units::si::TimeType t) const = 0;
   };
 
 } // namespace corsika::geometry
diff --git a/Framework/Geometry/CoordinateSystem.h b/Framework/Geometry/CoordinateSystem.h
index b8a7afc25..d30e9b438 100644
--- a/Framework/Geometry/CoordinateSystem.h
+++ b/Framework/Geometry/CoordinateSystem.h
@@ -10,7 +10,7 @@ typedef Eigen::Translation<double, 3> EigenTranslation;
 
 namespace corsika::geometry {
 
-  using corsika::units::length_d;
+  using corsika::units::si::length_d;
 
   class CoordinateSystem {
     CoordinateSystem const* reference = nullptr;
diff --git a/Framework/Geometry/Helix.h b/Framework/Geometry/Helix.h
index 29bb49438..af92a68a5 100644
--- a/Framework/Geometry/Helix.h
+++ b/Framework/Geometry/Helix.h
@@ -21,17 +21,17 @@ namespace corsika::geometry {
    */
 
   class Helix : public BaseTrajectory {
-    using VelocityVec = Vector<corsika::units::SpeedType::dimension_type>;
+    using VelocityVec = Vector<corsika::units::si::SpeedType::dimension_type>;
 
     Point const r0;
-    corsika::units::FrequencyType const omegaC;
+    corsika::units::si::FrequencyType const omegaC;
     VelocityVec const vPar;
     VelocityVec const vPerp, uPerp;
 
-    corsika::units::LengthType const radius;
+    corsika::units::si::LengthType const radius;
 
   public:
-    Helix(Point const& pR0, corsika::units::FrequencyType pOmegaC,
+    Helix(Point const& pR0, corsika::units::si::FrequencyType pOmegaC,
           VelocityVec const& pvPar, VelocityVec const& pvPerp)
         : r0(pR0)
         , omegaC(pOmegaC)
@@ -40,7 +40,7 @@ namespace corsika::geometry {
         , uPerp(vPerp.cross(vPar.normalized()))
         , radius(pvPar.norm() / abs(pOmegaC)) {}
 
-    Point GetPosition(corsika::units::TimeType t) const {
+    Point GetPosition(corsika::units::si::TimeType t) const {
       return r0 + vPar * t +
              (vPerp * (cos(omegaC * t) - 1) + uPerp * sin(omegaC * t)) / omegaC;
     }
diff --git a/Framework/Geometry/LineTrajectory.h b/Framework/Geometry/LineTrajectory.h
index 556da4642..b3aa4423e 100644
--- a/Framework/Geometry/LineTrajectory.h
+++ b/Framework/Geometry/LineTrajectory.h
@@ -9,7 +9,7 @@
 namespace corsika::geometry {
 
   class LineTrajectory : public BaseTrajectory {
-    using VelocityVec = Vector<corsika::units::SpeedType::dimension_type>;
+    using VelocityVec = Vector<corsika::units::si::SpeedType::dimension_type>;
 
     Point const r0;
     VelocityVec const v0;
@@ -19,7 +19,7 @@ namespace corsika::geometry {
         : r0(pR0)
         , v0(pV0) {}
 
-    Point GetPosition(corsika::units::TimeType t) const override { return r0 + v0 * t; }
+    Point GetPosition(corsika::units::si::TimeType t) const override { return r0 + v0 * t; }
   };
 
 } // namespace corsika::geometry
diff --git a/Framework/Geometry/Point.h b/Framework/Geometry/Point.h
index 108fe87f4..debbf9185 100644
--- a/Framework/Geometry/Point.h
+++ b/Framework/Geometry/Point.h
@@ -8,8 +8,8 @@
 
 namespace corsika::geometry {
 
-  using corsika::units::length_d;
-  using corsika::units::LengthType;
+  using corsika::units::si::length_d;
+  using corsika::units::si::LengthType;
 
   /*!
    * A Point represents a point in position space. It is defined by its
diff --git a/Framework/Geometry/QuantityVector.h b/Framework/Geometry/QuantityVector.h
index 671a68560..6066e1d50 100644
--- a/Framework/Geometry/QuantityVector.h
+++ b/Framework/Geometry/QuantityVector.h
@@ -8,17 +8,18 @@
 #include <iostream>
 #include <utility>
 
-namespace corsika {
+namespace corsika::geometry {
 
   /*!
    * A QuantityVector is a three-component container based on Eigen::Vector3d
-   * with a phys::units::dimension. Arithmethic operators are defined that
+   * with a phys::units::si::dimension. Arithmethic operators are defined that
    * propagate the dimensions by dimensional analysis.
    */
-
+  
   template <typename dim>
   class QuantityVector {
   protected:
+    // todo: check if we need to move "quantity" into namespace corsika::units 
     using Quantity = phys::units::quantity<dim, double>; //< the phys::units::quantity
                                                          // corresponding to the dimension
 
@@ -108,7 +109,7 @@ namespace corsika {
 } // end namespace corsika
 
 template <typename dim>
-auto& operator<<(std::ostream& os, corsika::QuantityVector<dim> qv) {
+auto& operator<<(std::ostream& os, corsika::geometry::QuantityVector<dim> qv) {
   using Quantity = phys::units::quantity<dim, double>;
 
   os << '(' << qv.eVector(0) << ' ' << qv.eVector(1) << ' ' << qv.eVector(2) << ") "
diff --git a/Framework/Geometry/Trajectory.h b/Framework/Geometry/Trajectory.h
index 8a640cacd..5c8cc739d 100644
--- a/Framework/Geometry/Trajectory.h
+++ b/Framework/Geometry/Trajectory.h
@@ -7,17 +7,17 @@
 namespace corsika::geometry {
 
   class Trajectory {
-    corsika::units::TimeType const fTStart, fTEnd;
+    corsika::units::si::TimeType const fTStart, fTEnd;
     BaseTrajectory const& fTrajectory;
 
   public:
-    Trajectory(corsika::units::TimeType pTStart, corsika::units::TimeType pTEnd,
+  Trajectory(corsika::units::si::TimeType pTStart, corsika::units::si::TimeType pTEnd,
                BaseTrajectory const& pTrajectory)
         : fTStart(pTStart)
         , fTEnd(pTEnd)
         , fTrajectory(pTrajectory) {}
 
-    Point GetPosition(corsika::units::TimeType t) const {
+    Point GetPosition(corsika::units::si::TimeType t) const {
       return fTrajectory.GetPosition(t + fTStart);
     }
 
diff --git a/Framework/Geometry/testGeometry.cc b/Framework/Geometry/testGeometry.cc
index 469d2dec6..ac444ef16 100644
--- a/Framework/Geometry/testGeometry.cc
+++ b/Framework/Geometry/testGeometry.cc
@@ -12,10 +12,10 @@
 #include <cmath>
 
 using namespace corsika::geometry;
-using namespace corsika::units;
+using namespace corsika::units::si;
 
 double constexpr absMargin = 1.0e-8;
-;
+
 
 TEST_CASE("transformations between CoordinateSystems") {
   CoordinateSystem rootCS;
@@ -23,10 +23,10 @@ TEST_CASE("transformations between CoordinateSystems") {
   REQUIRE(CoordinateSystem::GetTransformation(rootCS, rootCS)
               .isApprox(EigenTransform::Identity()));
 
-  corsika::QuantityVector<length_d> const coordinates{0_m, 0_m, 0_m};
+  QuantityVector<length_d> const coordinates{0_m, 0_m, 0_m};
   Point p1(rootCS, coordinates);
 
-  corsika::QuantityVector<magnetic_flux_density_d> components{1. * tesla, 0. * tesla,
+  QuantityVector<magnetic_flux_density_d> components{1. * tesla, 0. * tesla,
                                                               0. * tesla};
   Vector<magnetic_flux_density_d> v1(rootCS, components);
 
@@ -41,7 +41,7 @@ TEST_CASE("transformations between CoordinateSystems") {
   }
 
   SECTION("translations") {
-    corsika::QuantityVector<length_d> const translationVector{0_m, 4_m, 0_m};
+    QuantityVector<length_d> const translationVector{0_m, 4_m, 0_m};
 
     CoordinateSystem translatedCS = rootCS.translate(translationVector);
 
@@ -61,13 +61,13 @@ TEST_CASE("transformations between CoordinateSystems") {
   }
 
   SECTION("multiple translations") {
-    corsika::QuantityVector<length_d> const tv1{0_m, 5_m, 0_m};
+    QuantityVector<length_d> const tv1{0_m, 5_m, 0_m};
     CoordinateSystem cs2 = rootCS.translate(tv1);
 
-    corsika::QuantityVector<length_d> const tv2{3_m, 0_m, 0_m};
+    QuantityVector<length_d> const tv2{3_m, 0_m, 0_m};
     CoordinateSystem cs3 = rootCS.translate(tv2);
 
-    corsika::QuantityVector<length_d> const tv3{0_m, 0_m, 2_m};
+    QuantityVector<length_d> const tv3{0_m, 0_m, 2_m};
     CoordinateSystem cs4 = cs3.translate(tv3);
 
     REQUIRE(cs4.GetReference()->GetReference() == &rootCS);
@@ -79,7 +79,7 @@ TEST_CASE("transformations between CoordinateSystems") {
   }
 
   SECTION("rotations") {
-    corsika::QuantityVector<length_d> const axis{0_m, 0_m, 1_km};
+    QuantityVector<length_d> const axis{0_m, 0_m, 1_km};
     double const angle = 90. / 180. * M_PI;
 
     CoordinateSystem rotatedCS = rootCS.rotate(axis, angle);
@@ -94,9 +94,9 @@ TEST_CASE("transformations between CoordinateSystems") {
   }
 
   SECTION("multiple rotations") {
-    corsika::QuantityVector<length_d> const zAxis{0_m, 0_m, 1_km};
-    corsika::QuantityVector<length_d> const yAxis{0_m, 7_nm, 0_m};
-    corsika::QuantityVector<length_d> const xAxis{2_m, 0_nm, 0_m};
+    QuantityVector<length_d> const zAxis{0_m, 0_m, 1_km};
+    QuantityVector<length_d> const yAxis{0_m, 7_nm, 0_m};
+    QuantityVector<length_d> const xAxis{2_m, 0_nm, 0_m};
 
     double const angle = 90. / 180. * M_PI;
 
@@ -133,7 +133,7 @@ TEST_CASE("Trajectories") {
 
     LineTrajectory const lineTrajectory(r0, v0);
     CHECK((lineTrajectory.GetPosition(2_s).GetCoordinates() -
-           corsika::QuantityVector<length_d>(2_m, 0_m, 0_m))
+           QuantityVector<length_d>(2_m, 0_m, 0_m))
               .norm()
               .magnitude() == Approx(0).margin(absMargin));
 
@@ -151,12 +151,12 @@ TEST_CASE("Trajectories") {
     Helix const helix(r0, omegaC, vPar, vPerp);
 
     CHECK((helix.GetPosition(1_s).GetCoordinates() -
-           corsika::QuantityVector<length_d>(0_m, 0_m, 4_m))
+           QuantityVector<length_d>(0_m, 0_m, 4_m))
               .norm()
               .magnitude() == Approx(0).margin(absMargin));
 
     CHECK((helix.GetPosition(0.25_s).GetCoordinates() -
-           corsika::QuantityVector<length_d>(-1_m / (2 * M_PI), -1_m / (2 * M_PI), 1_m))
+           QuantityVector<length_d>(-1_m / (2 * M_PI), -1_m / (2 * M_PI), 1_m))
               .norm()
               .magnitude() == Approx(0).margin(absMargin));
 
diff --git a/Framework/Particles/ParticleProperties.h b/Framework/Particles/ParticleProperties.h
index 23ef23698..9e3c557d6 100644
--- a/Framework/Particles/ParticleProperties.h
+++ b/Framework/Particles/ParticleProperties.h
@@ -31,8 +31,8 @@ namespace corsika::particles {
 
   // forward declarations to be used in GeneratedParticleProperties
   int16_t constexpr GetElectricChargeNumber(Code const);
-  corsika::units::ElectricChargeType constexpr GetElectricCharge(Code const);
-  corsika::units::MassType constexpr GetMass(Code const);
+  corsika::units::si::ElectricChargeType constexpr GetElectricCharge(Code const);
+  corsika::units::si::MassType constexpr GetMass(Code const);
   PDGCodeType constexpr GetPDG(Code const);
   std::string const GetName(Code const);
 
@@ -41,7 +41,7 @@ namespace corsika::particles {
   /*!
    * returns mass of particle
    */
-  corsika::units::MassType constexpr GetMass(Code const p) {
+  corsika::units::si::MassType constexpr GetMass(Code const p) {
     return masses[static_cast<CodeIntType const>(p)];
   }
 
@@ -56,8 +56,8 @@ namespace corsika::particles {
     return electric_charges[static_cast<CodeIntType const>(p)];
   }
 
-  corsika::units::ElectricChargeType constexpr GetElectricCharge(Code const p) {
-    return GetElectricChargeNumber(p) * (corsika::units::constants::e / 3.);
+  corsika::units::si::ElectricChargeType constexpr GetElectricCharge(Code const p) {
+    return GetElectricChargeNumber(p) * (corsika::units::si::constants::e / 3.);
   }
 
   std::string const GetName(Code const p) {
diff --git a/Framework/Particles/pdxml_reader.py b/Framework/Particles/pdxml_reader.py
index 4c271e8fb..8f39bd7ef 100755
--- a/Framework/Particles/pdxml_reader.py
+++ b/Framework/Particles/pdxml_reader.py
@@ -216,9 +216,9 @@ def gen_properties(pythia_db):
     string += "\n"
     
     # particle masses table
-    string += "static constexpr std::array<corsika::units::MassType const, size> masses = {\n"    
+    string += "static constexpr std::array<corsika::units::si::MassType const, size> masses = {\n"    
     for p in pythia_db.values():
-        string += "  {mass:f} * (1e9 * corsika::units::constants::eV / corsika::units::constants::cSquared), // {name:s}\n".format(mass = p['mass'], name = p['name'])              
+        string += "  {mass:f} * (1e9 * corsika::units::si::constants::eV / corsika::units::si::constants::cSquared), // {name:s}\n".format(mass = p['mass'], name = p['name'])              
     string += "};\n\n"
                    
     # PDG code table
@@ -279,8 +279,8 @@ def gen_classes(pythia_db):
         string += "class " + cname + " {\n"
         string += "  public:\n"
         string += "   static constexpr Code GetCode() { return Type; }\n"
-        string += "   static constexpr corsika::units::MassType GetMass() { return corsika::particles::GetMass(Type); }\n"
-        string += "   static constexpr corsika::units::ElectricChargeType GetCharge() { return corsika::particles::GetElectricCharge(Type); }\n"
+        string += "   static constexpr corsika::units::si::MassType GetMass() { return corsika::particles::GetMass(Type); }\n"
+        string += "   static constexpr corsika::units::si::ElectricChargeType GetCharge() { return corsika::particles::GetElectricCharge(Type); }\n"
         string += "   static constexpr int16_t GetChargeNumber() { return corsika::particles::GetElectricChargeNumber(Type); }\n"
         string += "   static std::string const GetName() { return corsika::particles::GetName(Type); }\n"
         string += "   static constexpr Code GetAntiParticle() { return AntiType; }\n"
diff --git a/Framework/Particles/testParticles.cc b/Framework/Particles/testParticles.cc
index 12947cb32..5e80d0081 100644
--- a/Framework/Particles/testParticles.cc
+++ b/Framework/Particles/testParticles.cc
@@ -6,7 +6,7 @@
                           // cpp file
 #include <catch2/catch.hpp>
 
-using namespace corsika::units;
+using namespace corsika::units::si;
 using namespace corsika::particles;
 
 TEST_CASE("ParticleProperties", "[Particles]") {
diff --git a/Framework/Units/PhysicalConstants.h b/Framework/Units/PhysicalConstants.h
index 5c1b3a91c..7add499dd 100644
--- a/Framework/Units/PhysicalConstants.h
+++ b/Framework/Units/PhysicalConstants.h
@@ -27,7 +27,7 @@
 
 #include <phys/units/quantity.hpp>
 
-namespace corsika::units::constants {
+namespace corsika::units::si::constants {
 
   using namespace phys::units;
 
@@ -56,6 +56,6 @@ namespace corsika::units::constants {
 
   // etc.
 
-} // namespace corsika::units::constants
+} // namespace corsika::units::si::constants
 
 #endif // PHYS_UNITS_PHYSICAL_CONSTANTS_HPP_INCLUDED
diff --git a/Framework/Units/PhysicalUnits.h b/Framework/Units/PhysicalUnits.h
index c1cf07bb9..23dbbb871 100644
--- a/Framework/Units/PhysicalUnits.h
+++ b/Framework/Units/PhysicalUnits.h
@@ -16,7 +16,7 @@ namespace phys {
   namespace units {
     namespace literals {
       QUANTITY_DEFINE_SCALING_LITERALS(eV, energy_d,
-                                       magnitude(corsika::units::constants::eV))
+                                       magnitude(corsika::units::si::constants::eV))
 
       // phys::units::quantity<energy_d/mass_d> Joule2Kg = c2; // 1_Joule / 1_kg;
 
@@ -24,7 +24,7 @@ namespace phys {
   }   // namespace units
 } // namespace phys
 
-namespace corsika::units {
+namespace corsika::units::si {
   using namespace phys::units;
   using namespace phys::units::literals;
   // namespace literals = phys::units::literals;
@@ -38,7 +38,7 @@ namespace corsika::units {
   using EnergyType = phys::units::quantity<phys::units::energy_d, double>;
   using MassType = phys::units::quantity<phys::units::mass_d, double>;
 
-} // end namespace corsika::units
+} // end namespace corsika::units::si
 
 // we want to call the operator<< without namespace... I think
 using namespace phys::units::io;
diff --git a/Framework/Units/testUnits.cc b/Framework/Units/testUnits.cc
index 619ef5d6c..6e77e4a01 100644
--- a/Framework/Units/testUnits.cc
+++ b/Framework/Units/testUnits.cc
@@ -6,7 +6,7 @@
 
 #include <array>
 
-using namespace corsika::units;
+using namespace corsika::units::si;
 
 TEST_CASE("PhysicalUnits", "[Units]") {
 
diff --git a/Stack/DummyStack/SuperStupidStack.h b/Stack/DummyStack/SuperStupidStack.h
index a4e931b39..c1b9215d0 100644
--- a/Stack/DummyStack/SuperStupidStack.h
+++ b/Stack/DummyStack/SuperStupidStack.h
@@ -13,8 +13,8 @@ namespace corsika::stack {
   namespace super_stupid {
 
     using corsika::particles::Code;
-    using corsika::units::EnergyType;
-    using corsika::units::operator""_GeV; // literals;
+    using corsika::units::si::EnergyType;
+    using corsika::units::si::operator""_GeV; // literals;
 
     /**
      * Example of a particle object on the stack.
diff --git a/Stack/SuperStupidStack/SuperStupidStack.h b/Stack/SuperStupidStack/SuperStupidStack.h
index 2ab8ea790..a09fe930f 100644
--- a/Stack/SuperStupidStack/SuperStupidStack.h
+++ b/Stack/SuperStupidStack/SuperStupidStack.h
@@ -12,8 +12,8 @@ namespace corsika::stack {
   namespace super_stupid {
 
     using corsika::particles::Code;
-    using corsika::units::EnergyType;
-    using corsika::units::operator""_GeV; // literals;
+    using corsika::units::si::EnergyType;
+    using corsika::units::si::operator""_GeV; // literals;
 
     /**
      * Example of a particle object on the stack.
-- 
GitLab