IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 08cdf486 authored by ralfulrich's avatar ralfulrich
Browse files

stack example with fwk::Energy and fwk::particle::InternalParticleCode

parent f478571e
No related branches found
No related tags found
No related merge requests found
#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() {
......
......@@ -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
......@@ -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}
......
#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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment