From 6f30d89b0e87593aab5a4f09f0e8fe75faabd191 Mon Sep 17 00:00:00 2001
From: Felix Riehn <felix@matilda>
Date: Thu, 29 Nov 2018 17:59:02 +0000
Subject: [PATCH] added momentum and cross section quantity, unit and types

---
 Documentation/Examples/cascade_example.cc |  2 +-
 Framework/Units/PhysicalConstants.h       |  5 +++--
 Framework/Units/PhysicalUnits.h           | 13 ++++++++++++-
 Framework/Units/testUnits.cc              |  2 +-
 4 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/Documentation/Examples/cascade_example.cc b/Documentation/Examples/cascade_example.cc
index 2490cd34..5fe5e5bc 100644
--- a/Documentation/Examples/cascade_example.cc
+++ b/Documentation/Examples/cascade_example.cc
@@ -62,7 +62,7 @@ public:
     sib_sigma_hnuc_(kBeam, kTarget, beamEnergy, prodCrossSection, dummy );
     
     std::cout << "ProcessSplit: " << "MinStep: sibyll return: " << prodCrossSection << std::endl;
-    CrossSectionType sig = prodCrossSection  / 1000. * barn;
+    CrossSectionType sig = prodCrossSection * 1_mbarn;
     std::cout << "ProcessSplit: " << "MinStep: CrossSection (mb): " << sig / 1_mbarn << std::endl;
 
     const MassType nucleon_mass = 0.93827_GeV / corsika::units::si::constants::cSquared;
diff --git a/Framework/Units/PhysicalConstants.h b/Framework/Units/PhysicalConstants.h
index c3d5824e..65a98e48 100644
--- a/Framework/Units/PhysicalConstants.h
+++ b/Framework/Units/PhysicalConstants.h
@@ -54,8 +54,9 @@ namespace corsika::units::si::constants {
   // unified atomic mass unit
   constexpr quantity<mass_d> u{Rep(1.6605402e-27L) * kilogram};
 
-  // barn
-  constexpr quantity<area_d> barn{Rep(1.e-28L) * meter * meter};
+  // barn moved to PhysicalUnits
+  //  constexpr quantity<area_d> barn{Rep(1.e-28L) * meter * meter};
+  
   
   // etc.
 
diff --git a/Framework/Units/PhysicalUnits.h b/Framework/Units/PhysicalUnits.h
index 9060037e..be06ec19 100644
--- a/Framework/Units/PhysicalUnits.h
+++ b/Framework/Units/PhysicalUnits.h
@@ -63,7 +63,18 @@ namespace corsika::units::si {
   using EnergyType = phys::units::quantity<phys::units::energy_d, double>;
   using MassType = phys::units::quantity<phys::units::mass_d, double>;
 
-  using CrossSectionType = phys::units::quantity<phys::units::area_d, double>;
+  // defining momentum you suckers
+  // dimensions, i.e. composition in base SI dimensions
+  using momentum_d                     = phys::units::dimensions< 1, 1, -1 >;
+  // defining the unit of momentum, so far newton-meter, maybe go to HEP?
+  constexpr phys::units::quantity< momentum_d > newton_second   { meter * kilogram / second };
+  // defining the type
+  using MomentumType = phys::units::quantity<momentum_d, double>;
+
+  // defining cross section
+  using sigma_d      = phys::units::dimensions< 2, 0, 0 >;
+  constexpr phys::units::quantity< sigma_d  > barn       {Rep(1.e-28L) * meter * meter};
+  using CrossSectionType = phys::units::quantity<sigma_d, double>;
   
 } // end namespace corsika::units::si
 
diff --git a/Framework/Units/testUnits.cc b/Framework/Units/testUnits.cc
index fc844c10..eeed8862 100644
--- a/Framework/Units/testUnits.cc
+++ b/Framework/Units/testUnits.cc
@@ -54,7 +54,7 @@ TEST_CASE("PhysicalUnits", "[Units]") {
     REQUIRE(1_mol / 1_amol == Approx(1e18));
     REQUIRE(1_K / 1_zK == Approx(1e21));
     REQUIRE(1_K / 1_yK == Approx(1e24));
-    //    REQUIRE(1_barn / 1_mbarn == Approx(1e3));
+    REQUIRE(1_barn / 1_mbarn == Approx(1e3));
     
     REQUIRE(1_A / 1_hA == Approx(1e-2));
     REQUIRE(1_m / 1_km == Approx(1e-3));
-- 
GitLab