diff --git a/Documentation/Examples/stack_example.cc b/Documentation/Examples/stack_example.cc index b38d07250f0303fb12daccd27150faa78ea45383..940247698d8bbd561887d08bae628dc57fb14eb6 100644 --- a/Documentation/Examples/stack_example.cc +++ b/Documentation/Examples/stack_example.cc @@ -1,25 +1,29 @@ #include <stack/super_stupid/SuperStupidStack.h> +#include <fwk/Particles.h> #include <iomanip> #include <iostream> using namespace std; - -// using namespace fwk; +using namespace fwk::literals; +// using namespace fwk::io; void fill(stack::super_stupid::SuperStupidStack& s) { for (int i = 0; i < 11; ++i) { auto p = s.NewParticle(); - p.SetId(i); - p.SetEnergy(1.5 * i); + p.SetId(fwk::particle::InternalParticleCode::Electron); + p.SetEnergy(1.5_GeV * i); } } void read(stack::super_stupid::SuperStupidStack& s) { cout << "found Stack with " << s.GetSize() << " particles. " << endl; - double Etot = 0; - for (auto p : s) { Etot += p.GetEnergy(); } - cout << "Etot=" << Etot << endl; + fwk::quantity<fwk::energy_d> Etot; + for (auto p : s) { + Etot += p.GetEnergy(); + cout << "particle: " << p.GetId() << " with " << p.GetEnergy()/1_GeV << " GeV" << endl; + } + cout << "Etot=" << Etot << " = " << Etot / 1_GeV << " GeV" << endl; } int main() { diff --git a/Framework/Particles/Particles.h b/Framework/Particles/Particles.h index cf1fbdaa468b15ee458dafa06860d999984c9d82..3b443a687ca1058447a7634bdb205be06954fd94 100644 --- a/Framework/Particles/Particles.h +++ b/Framework/Particles/Particles.h @@ -13,57 +13,57 @@ #include <fwk/GeneratedParticleProperties.inc> - namespace fwk { /** * @namespace particle - * - * The properties of all elementary particles is stored here. The data + * + * The properties of all elementary particles is stored here. The data * is taken from the Pythia ParticleData.xml file. - * + * */ - + namespace particle { /** * @function GetMass - * + * * return mass of particle */ - auto constexpr GetMass(InternalParticleCode const p) - { + auto constexpr GetMass(InternalParticleCode const p) { return masses[static_cast<uint8_t const>(p)]; } - - auto constexpr GetPDG(InternalParticleCode const p) - { + + auto constexpr GetPDG(InternalParticleCode const p) { return pdg_codes[static_cast<uint8_t const>(p)]; } - - auto constexpr GetElectricChargeNumber(InternalParticleCode const p) - { + + auto constexpr GetElectricChargeNumber(InternalParticleCode const p) { return electric_charge[static_cast<uint8_t const>(p)] / 3; } - - auto constexpr GetElectricCharge(InternalParticleCode const p) - { + + auto constexpr GetElectricCharge(InternalParticleCode const p) { return GetElectricChargeNumber(p) * (phys::units::e); } - - auto const GetName(InternalParticleCode const p) - { + + auto const GetName(InternalParticleCode const p) { return names[static_cast<uint8_t const>(p)]; } - - std::ostream& operator<< (std::ostream& stream, InternalParticleCode const p) - { - stream << GetName(p); - return stream; + + namespace io { + + std::ostream& operator<<(std::ostream& stream, InternalParticleCode const p) { + stream << GetName(p); + return stream; } - } // end namespace - -} // end namespace + } // namespace io + + } // namespace particle + +} // namespace fwk + +// to inject the operator<< into the root namespace +using namespace fwk::particle::io; #endif diff --git a/Framework/StackInterface/CMakeLists.txt b/Framework/StackInterface/CMakeLists.txt index 5388bb05152d83a422cb690a3ed62f211d6276a0..9c3ab779ae5b339725daf2e64bbfe4934bc4127e 100644 --- a/Framework/StackInterface/CMakeLists.txt +++ b/Framework/StackInterface/CMakeLists.txt @@ -23,13 +23,6 @@ target_include_directories ( $<INSTALL_INTERFACE:include> ) -#add_custom_command ( -# TARGET -# CORSIKAstackinterfaceerface -# PRE_BUILD -# COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CORSIKAstackinterfaceerface_HEADERS} ${PROJECT_BINARY_DIR}/include/corsika -# ) - install ( FILES ${CORSIKAstackinterface_HEADERS} diff --git a/Framework/Units/PhysicalUnits.h b/Framework/Units/PhysicalUnits.h index d9bb61ac4d78826cc4a5c2bfdbc2c90ee661e89e..b5ee98bff29baf44223e0aa02aded7e7fb7cc091 100644 --- a/Framework/Units/PhysicalUnits.h +++ b/Framework/Units/PhysicalUnits.h @@ -1,15 +1,15 @@ #ifndef _include_PhysicalUnits_h_ #define _include_PhysicalUnits_h_ -#include <phys/units/quantity.hpp> #include <phys/units/io.hpp> #include <phys/units/physical_constants.hpp> +#include <phys/units/quantity.hpp> /** - @file PhysicalUnits - - Define _XeV literals, alowing 10_GeV in the code. -*/ + * @file PhysicalUnits + * + * Define _XeV literals, alowing 10_GeV in the code. + */ /*using namespace phys::units::io; using namespace phys::units::literals;*/ @@ -17,16 +17,27 @@ using namespace phys::units::literals;*/ namespace phys { namespace units { namespace literals { - QUANTITY_DEFINE_SCALING_LITERALS(eV, energy_d, magnitude(eV) ) + QUANTITY_DEFINE_SCALING_LITERALS(eV, energy_d, magnitude(eV)) } - } -} + } // namespace units +} // namespace phys -using Length = phys::units::quantity<phys::units::length_d, double>; -using Time = phys::units::quantity<phys::units::time_interval_d, double>; -using Speed = phys::units::quantity<phys::units::speed_d, double>; -using Frequency = phys::units::quantity<phys::units::frequency_d, double>; -using ElectricCharge = phys::units::quantity<phys::units::electric_charge_d, double>; +namespace fwk { -#endif + using namespace phys; + using namespace phys::units; + // using namespace phys::units::literals; + + using Length = phys::units::quantity<phys::units::length_d, double>; + using Time = phys::units::quantity<phys::units::time_interval_d, double>; + using Speed = phys::units::quantity<phys::units::speed_d, double>; + using Frequency = phys::units::quantity<phys::units::frequency_d, double>; + using ElectricCharge = phys::units::quantity<phys::units::electric_charge_d, double>; + using Energy = phys::units::quantity<phys::units::energy_d, double>; +} // end namespace fwk + +// we want to call the operator<< without namespace... I think +using namespace phys::units::io; + +#endif