diff --git a/Framework/Units/PhysicalUnits.h b/Framework/Units/PhysicalUnits.h index be06ec192261140748f503cceeb7ee6f63c4c4ea..deca41d9b7991da7ac7be2fe3780dd7d700d1612 100644 --- a/Framework/Units/PhysicalUnits.h +++ b/Framework/Units/PhysicalUnits.h @@ -24,17 +24,6 @@ namespace phys { } // namespace units } // namespace phys -namespace phys { - namespace units { - namespace literals { - QUANTITY_DEFINE_SCALING_LITERALS(barn, area_d, - magnitude(corsika::units::si::constants::barn)) - - // phys::units::quantity<energy_d/mass_d> Joule2Kg = c2; // 1_Joule / 1_kg; - - } // namespace literals - } // namespace units -} namespace phys { namespace units { @@ -49,6 +38,7 @@ namespace phys { } + namespace corsika::units::si { using namespace phys::units; using namespace phys::units::literals; @@ -78,6 +68,30 @@ namespace corsika::units::si { } // end namespace corsika::units::si +namespace phys { + namespace units { + namespace literals { + QUANTITY_DEFINE_SCALING_LITERALS(barn, corsika::units::si::sigma_d, + magnitude(corsika::units::si::constants::barn)) + + // phys::units::quantity<energy_d/mass_d> Joule2Kg = c2; // 1_Joule / 1_kg; + + } // namespace literals + } // namespace units +} + +namespace phys { + namespace units { + namespace literals { + QUANTITY_DEFINE_SCALING_LITERALS(newton_second, corsika::units::si::momentum_d, + magnitude(corsika::units::si::newton_second)) + + // phys::units::quantity<energy_d/mass_d> Joule2Kg = c2; // 1_Joule / 1_kg; + + } // namespace literals + } // namespace units +} + // 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 eeed886296ce988fef2e0f87d84d691513dbfad5..52a23d8e4aca4ed71a906e0e5787ab900cd17583 100644 --- a/Framework/Units/testUnits.cc +++ b/Framework/Units/testUnits.cc @@ -32,7 +32,7 @@ TEST_CASE("PhysicalUnits", "[Units]") { LengthType l1 = 10_nm; l1 = l1; - + LengthType arr0[5]; arr0[0] = 5_m; @@ -41,6 +41,9 @@ TEST_CASE("PhysicalUnits", "[Units]") { std::array<EnergyType, 4> arr2; // empty array [[maybe_unused]] std::array<EnergyType, 4> arr3 = {1_GeV, 1_eV, 5_MeV}; + + [[maybe_unused]] auto p1 = 10_newton_second; + REQUIRE(p1 == 10_newton_second); } SECTION("Powers in literal units") { @@ -77,6 +80,10 @@ TEST_CASE("PhysicalUnits", "[Units]") { REQUIRE(E2 == 40_GeV); REQUIRE(E2 / 1_GeV == Approx(40)); + const MassType m = 1_kg; + const SpeedType v = 1_m / 1_s; + REQUIRE( m*v == 1_newton_second); + const double lgE = log10(E2 / 1_GeV); REQUIRE(lgE == Approx(log10(40.)));