From e26402aaaff906c6ffac5eb9e6f2a7b06bccd08e Mon Sep 17 00:00:00 2001
From: ralfulrich <ralf.ulrich@kit.edu>
Date: Mon, 14 Jan 2019 12:45:53 +0100
Subject: [PATCH] added FourVector with tests

---
 Framework/Geometry/CMakeLists.txt           | 14 ++++++---
 Framework/Geometry/QuantityVector.h         |  3 +-
 Framework/Geometry/Vector.h                 |  1 +
 Framework/ProcessSequence/ProcessSequence.h | 33 ---------------------
 Framework/Units/PhysicalUnits.h             | 23 +++++++++++---
 ThirdParty/phys/units/quantity.hpp          |  2 +-
 6 files changed, 32 insertions(+), 44 deletions(-)

diff --git a/Framework/Geometry/CMakeLists.txt b/Framework/Geometry/CMakeLists.txt
index 4d708ff10..bb96c2ea6 100644
--- a/Framework/Geometry/CMakeLists.txt
+++ b/Framework/Geometry/CMakeLists.txt
@@ -17,7 +17,7 @@ set (
   BaseVector.h
   QuantityVector.h
   Trajectory.h
-  # BaseTrajectory.h
+  FourVector.h
   )
 
 set (
@@ -57,16 +57,22 @@ install (
   PUBLIC_HEADER DESTINATION include/${GEOMETRY_NAMESPACE}
   )
 
-
 # --------------------
 # code unit testing
 add_executable (testGeometry testGeometry.cc)
-
 target_link_libraries (
   testGeometry
   CORSIKAgeometry
   CORSIKAunits
   CORSIKAthirdparty # for catch2
   )
-
 CORSIKA_ADD_TEST(testGeometry)
+
+add_executable (testFourVector testFourVector.cc) 
+target_link_libraries (
+  testFourVector
+  CORSIKAgeometry
+  CORSIKAunits
+  CORSIKAthirdparty # for catch2
+  )
+CORSIKA_ADD_TEST(testFourVector)
diff --git a/Framework/Geometry/QuantityVector.h b/Framework/Geometry/QuantityVector.h
index bb498f086..e0893e527 100644
--- a/Framework/Geometry/QuantityVector.h
+++ b/Framework/Geometry/QuantityVector.h
@@ -29,8 +29,7 @@ namespace corsika::geometry {
 
   template <typename dim>
   class QuantityVector {
-  protected:
-    // todo: check if we need to move "quantity" into namespace corsika::units
+  public:
     using Quantity = phys::units::quantity<dim, double>; //< the phys::units::quantity
                                                          // corresponding to the dimension
 
diff --git a/Framework/Geometry/Vector.h b/Framework/Geometry/Vector.h
index 94394b90d..712eece61 100644
--- a/Framework/Geometry/Vector.h
+++ b/Framework/Geometry/Vector.h
@@ -31,6 +31,7 @@ namespace corsika::geometry {
 
   template <typename dim>
   class Vector : public BaseVector<dim> {
+  public:
     using Quantity = phys::units::quantity<dim, double>;
 
   public:
diff --git a/Framework/ProcessSequence/ProcessSequence.h b/Framework/ProcessSequence/ProcessSequence.h
index 632c57848..c6a0cb544 100644
--- a/Framework/ProcessSequence/ProcessSequence.h
+++ b/Framework/ProcessSequence/ProcessSequence.h
@@ -259,39 +259,6 @@ namespace corsika::process {
     return ProcessSequence<P1, P2>(A.GetRef(), B.GetRef());
   }
 
-  /* #define OPSEQ(C1, C2) \ */
-  /*   template < \ */
-  /*       typename P1, typename P2, \ */
-  /*       typename std::enable_if<is_process<typename std::decay<P1>::type>::value &&
-   * \ */
-  /*                               is_process<typename
-   * std::decay<P2>::type>::value>::type...> \ */
-  /*   inline auto operator+(P1&& A, P2&& B)->ProcessSequence<P1, P2> { \ */
-  /*     return ProcessSequence<P1, P2>(A.GetRef(), B.GetRef()); \ */
-  /*   } */
-
-  /*   /\*template <typename T1, typename T2>				\ */
-  /* inline ProcessSequence<T1, T2> operator%(C1<T1>& A, C2<T2>& B) {	\ */
-  /* return ProcessSequence<T1, T2>(A.GetRef(), B.GetRef());	\ */
-  /* }*\/ */
-
-  /*   OPSEQ(BaseProcess, BaseProcess) */
-  /*   OPSEQ(BaseProcess, InteractionProcess) */
-  /*   OPSEQ(BaseProcess, ContinuousProcess) */
-  /*   OPSEQ(BaseProcess, DecayProcess) */
-  /*   OPSEQ(ContinuousProcess, BaseProcess) */
-  /*   OPSEQ(ContinuousProcess, InteractionProcess) */
-  /*   OPSEQ(ContinuousProcess, ContinuousProcess) */
-  /*   OPSEQ(ContinuousProcess, DecayProcess) */
-  /*   OPSEQ(InteractionProcess, BaseProcess) */
-  /*   OPSEQ(InteractionProcess, InteractionProcess) */
-  /*   OPSEQ(InteractionProcess, ContinuousProcess) */
-  /*   OPSEQ(InteractionProcess, DecayProcess) */
-  /*   OPSEQ(DecayProcess, BaseProcess) */
-  /*   OPSEQ(DecayProcess, InteractionProcess) */
-  /*   OPSEQ(DecayProcess, ContinuousProcess) */
-  /*   OPSEQ(DecayProcess, DecayProcess) */
-
   /// marker to identify objectas ProcessSequence
   template <typename A, typename B>
   struct is_process_sequence<corsika::process::ProcessSequence<A, B> > {
diff --git a/Framework/Units/PhysicalUnits.h b/Framework/Units/PhysicalUnits.h
index 262e55d1c..5861f9a45 100644
--- a/Framework/Units/PhysicalUnits.h
+++ b/Framework/Units/PhysicalUnits.h
@@ -79,20 +79,35 @@ namespace corsika::units::si {
 /**
  * @file PhysicalUnits
  *
- * Define _XeV literals, alowing 10_GeV in the code.
- * Define _barn literal
  */
 
 namespace phys {
   namespace units {
     namespace literals {
+
+      /**
+       * Define new _XeV literals, alowing 10_GeV in the code.
+       * Define new _barn literal
+       */
+
       QUANTITY_DEFINE_SCALING_LITERALS(eV, hepenergy_d, 1)
 
       QUANTITY_DEFINE_SCALING_LITERALS(barn, corsika::units::si::sigma_d,
                                        magnitude(corsika::units::constants::barn))
 
-      // QUANTITY_DEFINE_SCALING_LITERALS(Ns, corsika::units::si::momentum_d,
-      //                                 magnitude(1_m * 1_kg / 1_s))
+      /**
+       * add additional literals missing in the original library:
+       *
+       */
+
+      QUANTITY_DEFINE_SCALING_LITERALS(gram, mass_d, 1e-3)
+
+	/*
+      QUANTITY_DEFINE_LITERALS(meter, length_d)
+      QUANTITY_DEFINE_LITERALS(second, time_interval_d)
+      QUANTITY_DEFINE_LITERALS(ampere, electric_current_d)
+      QUANTITY_DEFINE_LITERALS(Kelvin, thermodynamic_temperature_d)
+	*/
 
     } // namespace literals
   }   // namespace units
diff --git a/ThirdParty/phys/units/quantity.hpp b/ThirdParty/phys/units/quantity.hpp
index 890061b95..bec553186 100644
--- a/ThirdParty/phys/units/quantity.hpp
+++ b/ThirdParty/phys/units/quantity.hpp
@@ -438,7 +438,7 @@ namespace phys {
     typedef dimensions<0, 0, 0, 0, 1, 0, 0, 0> thermodynamic_temperature_d;
     typedef dimensions<0, 0, 0, 0, 0, 1, 0, 0> amount_of_substance_d;
     typedef dimensions<0, 0, 0, 0, 0, 0, 1, 0> luminous_intensity_d;
-    typedef dimensions<0, 0, 0, 0, 0, 0, 0, 1> hepenergy_d;
+    typedef dimensions<0, 0, 0, 0, 0, 0, 0, 1> hepenergy_d; // this is not an SI unit !
 
     // Addition operators
 
-- 
GitLab