IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 23ba39ea authored by ralfulrich's avatar ralfulrich
Browse files

more straightforward naming scheme for particle properties, added processes directory

parent 08cdf486
No related branches found
No related tags found
No related merge requests found
......@@ -42,7 +42,7 @@ find_package (Eigen3 REQUIRED)
add_subdirectory (ThirdParty)
add_subdirectory (Framework)
add_subdirectory (Stack)
#add_subdirectory (Processes)
add_subdirectory (Processes)
add_subdirectory (Documentation)
add_subdirectory (Main)
#include <fwk/ParticleProperties.h>
#include <stack/super_stupid/SuperStupidStack.h>
#include <fwk/Particles.h>
#include <iomanip>
#include <iostream>
......@@ -11,7 +11,7 @@ using namespace fwk::literals;
void fill(stack::super_stupid::SuperStupidStack& s) {
for (int i = 0; i < 11; ++i) {
auto p = s.NewParticle();
p.SetId(fwk::particle::InternalParticleCode::Electron);
p.SetId(fwk::particle::Code::Electron);
p.SetEnergy(1.5_GeV * i);
}
}
......@@ -21,7 +21,8 @@ void read(stack::super_stupid::SuperStupidStack& s) {
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 << "particle: " << p.GetId() << " with " << p.GetEnergy() / 1_GeV << " GeV"
<< endl;
}
cout << "Etot=" << Etot << " = " << Etot / 1_GeV << " GeV" << endl;
}
......
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one
// cpp file
#include <catch2/catch.hpp>
#include <fwk/PhysicalUnits.h>
......@@ -6,25 +7,14 @@
using namespace phys::units;
using namespace phys::units::literals;
TEST_CASE( "Geometry", "[Geometry]" )
{
SECTION( "Coordinate Systems" )
{
}
SECTION( "Point" )
{
}
SECTION( "Vector" )
{
}
TEST_CASE("Geometry", "[Geometry]") {
SECTION("Coordinate Systems") {}
SECTION( "Helix" )
{
}
SECTION("Point") {}
SECTION( "Line" )
{
}
SECTION("Vector") {}
SECTION("Helix") {}
SECTION("Line") {}
}
add_custom_command (
OUTPUT ${PROJECT_BINARY_DIR}/Framework/Particles/GeneratedParticleProperties.inc
COMMAND ${PROJECT_SOURCE_DIR}/Framework/Particles/pdxml_reader.py ${PROJECT_SOURCE_DIR}/Framework/Particles/ParticleData.xml ${PROJECT_SOURCE_DIR}/Framework/Particles/ParticleClassNames.xml
DEPENDS
pdxml_reader.py
ParticleData.xml
ParticleClassNames.xml
OUTPUT ${PROJECT_BINARY_DIR}/Framework/Particles/GeneratedParticleProperties.inc
COMMAND ${PROJECT_SOURCE_DIR}/Framework/Particles/pdxml_reader.py
${PROJECT_SOURCE_DIR}/Framework/Particles/ParticleData.xml
${PROJECT_SOURCE_DIR}/Framework/Particles/ParticleClassNames.xml
DEPENDS pdxml_reader.py
ParticleData.xml
ParticleClassNames.xml
WORKING_DIRECTORY
${PROJECT_BINARY_DIR}/Framework/Particles/
${PROJECT_BINARY_DIR}/Framework/Particles/
COMMENT "Read PYTHIA8 particle data and produce C++ source code GeneratedParticleProperties.inc"
VERBATIM
)
......@@ -15,16 +16,10 @@ add_custom_command (
# all public header files of library, includes automatic generated file(s)
set (
PARTICLE_HEADERS
Particles.h
ParticleProperties.h
${PROJECT_BINARY_DIR}/Framework/Particles/GeneratedParticleProperties.inc # this one is auto-generated
)
# we need 2nd list with just the header files from the source code directory
set (
PARTICLE_HEADERS_SOURCE
Particles.h
)
set (
PARTICLE_NAMESPACE
fwk
......@@ -34,10 +29,23 @@ add_library (CORSIKAparticles INTERFACE)
CORSIKA_COPY_HEADERS_TO_NAMESPACE (CORSIKAparticles ${PARTICLE_NAMESPACE} ${PARTICLE_HEADERS})
# ....................................................
# since GeneratedParticleProperties.inc is an automatically produced file in the build directory,
# create a symbolic link into the source tree, so that it can be found and edited more easily
# this is not needed for the build to succeed! .......
add_custom_command (
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/GeneratedParticleProperties.inc
COMMAND ${CMAKE_COMMAND} -E create_symlink ${PROJECT_BINARY_DIR}/include/fwk/GeneratedParticleProperties.inc ${CMAKE_CURRENT_SOURCE_DIR}/GeneratedParticleProperties.inc
COMMENT "Generate link in source-dir: ${CMAKE_CURRENT_SOURCE_DIR}/GeneratedParticleProperties.inc"
)
add_custom_target (SourceDirLink DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/GeneratedParticleProperties.inc)
add_dependencies (CORSIKAparticles SourceDirLink)
# .....................................................
target_include_directories (
CORSIKAparticles
INTERFACE
# ${EIGEN3_INCLUDE_DIR}
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>
)
......
......@@ -30,29 +30,29 @@ namespace fwk {
*
* return mass of particle
*/
auto constexpr GetMass(InternalParticleCode const p) {
auto constexpr GetMass(Code const p) {
return masses[static_cast<uint8_t const>(p)];
}
auto constexpr GetPDG(InternalParticleCode const p) {
auto constexpr GetPDG(Code const p) {
return pdg_codes[static_cast<uint8_t const>(p)];
}
auto constexpr GetElectricChargeNumber(InternalParticleCode const p) {
auto constexpr GetElectricChargeNumber(Code const p) {
return electric_charge[static_cast<uint8_t const>(p)] / 3;
}
auto constexpr GetElectricCharge(InternalParticleCode const p) {
auto constexpr GetElectricCharge(Code const p) {
return GetElectricChargeNumber(p) * (phys::units::e);
}
auto const GetName(InternalParticleCode const p) {
auto const GetName(Code const p) {
return names[static_cast<uint8_t const>(p)];
}
namespace io {
std::ostream& operator<<(std::ostream& stream, InternalParticleCode const p) {
std::ostream& operator<<(std::ostream& stream, Code const p) {
stream << GetName(p);
return stream;
}
......
......@@ -186,10 +186,15 @@ def build_pythia_db(filename, classnames):
#
def gen_internal_enum(pythia_db):
string = "enum class InternalParticleCode : uint8_t {\n"
string = "enum class Code : uint8_t {\n"
string += " FirstParticle = 1, // if you want to loop over particles, you want to start with \"1\" \n" # identifier for eventual loops...
last_ngc_id = 0
for k in filter(lambda k: "ngc_code" in pythia_db[k], pythia_db):
string += " {key:s} = {code:d},\n".format(key = k, code = pythia_db[k]['ngc_code'])
last_ngc_id = pythia_db[k]['ngc_code']
string += " {key:s} = {code:d},\n".format(key = k, code = last_ngc_id)
string += " LastParticle = " + str(last_ngc_id+1) + ",\n" # identifier for eventual loops...
string += "};"
return string
......@@ -271,14 +276,14 @@ def gen_classes(pythia_db):
string += "*/\n\n"
string += "class " + cname + "{\n"
string += " public:\n"
string += " static InternalParticleCode GetType() { return Type; }\n"
string += " static Code GetCode() { return Type; }\n"
string += " static quantity<energy_d> GetMass() { return masses[TypeIndex]; }\n"
string += " static quantity<electric_charge_d> GetCharge() { return phys::units::e*electric_charge[TypeIndex]/3; }\n"
string += " static int GetChargeNumber() { return electric_charge[TypeIndex]/3; }\n"
string += " static std::string GetName() { return names[TypeIndex]; }\n"
string += " static InternalParticleCode GetAntiParticle() { return AntiType; }\n"
string += " static const InternalParticleCode Type = InternalParticleCode::" + cname + ";\n"
string += " static const InternalParticleCode AntiType = InternalParticleCode::" + antiP + ";\n"
string += " static Code GetAntiParticle() { return AntiType; }\n"
string += " static const Code Type = Code::" + cname + ";\n"
string += " static const Code AntiType = Code::" + antiP + ";\n"
string += " private:\n"
string += " static const uint8_t TypeIndex = static_cast<uint8_t const>(Type);\n"
string += "};\n"
......@@ -294,9 +299,10 @@ def inc_start():
string = ""
string += "#ifndef _include_GeneratedParticleDataTable_h_\n"
string += "#define _include_GeneratedParticleDataTable_h_\n\n"
string += "#include <fwk/PhysicalUnits.h>\n"
string += "#include <array>\n"
string += "#include <cstdint>\n"
string += "#include <iostream>\n\n"
# string += "#include <iostream>\n\n"
string += "using namespace phys::units;\n"
string += "using namespace phys::units::literals;\n\n"
string += "namespace fwk { \n\n"
......
......@@ -4,19 +4,20 @@
#include <fwk/PhysicalUnits.h>
#include <fwk/Particles.h>
#include <fwk/ParticleProperties.h>
using namespace phys::units;
using namespace phys::units::literals;
// using namespace phys::units;
// using namespace phys::units::literals;
using namespace fwk::particle;
TEST_CASE("Particles", "[Particles]") {
SECTION("Types") { REQUIRE(Electron::GetType() == InternalParticleCode::Electron); }
SECTION("Types") { REQUIRE(Electron::GetCode() == Code::Electron); }
SECTION("Data") {
REQUIRE(Electron::GetMass() / 0.511_MeV == Approx(1));
REQUIRE(Electron::GetMass() / GetMass(InternalParticleCode::Electron) == Approx(1));
REQUIRE(Electron::GetMass() / GetMass(Code::Electron) == Approx(1));
REQUIRE(Electron::GetCharge() / phys::units::e == Approx(-1));
REQUIRE(Positron::GetCharge() / phys::units::e == Approx(+1));
REQUIRE(GetElectricCharge(Positron::GetAntiParticle()) / phys::units::e ==
......
add_subdirectory (NullModel)
add_subdirectory (Sibyll)
#include <Processes/NullModel/NullModel.h>
#include <process/null_model/NullModel.h>
using namespace process::null_model;
NullModel::NullModel() {}
NullModel::~NullModel() {}
void NullModel::init() {}
void NullModel::run() {}
double NullModel::GetStepLength() { return 0; }
#ifndef _Physics_NullModel_NullModel_h_
#define _Physics_NullModel_NullModel_h_
namespace processes {
namespace process {
class NullModel {
namespace null_model {
public:
NullModel();
~NullModel();
void init();
void run();
double GetStepLength();
};
class NullModel {
public:
NullModel();
~NullModel();
void init();
void run();
double GetStepLength();
};
} // namespace null_model
}
} // namespace process
#endif
#include <Sibyll/Particle.h>
using namespace processes;
const std::map<sibyll::PID, ParticleProperties::InternalParticleCode>
processes::sibyll::Sibyll2Corsika = {
{sibyll::PID::E_MINUS, InternalParticleCode::Electron},
};
#ifndef _include_processes_sibyll_particles_h_
#define _include_processes_sibyll_particles_h_
#include <Particles/Particles.h>
#include <map>
namespace processes {
namespace sibyll {
enum class PID : int {
E_MINUS = 3,
E_PLUS = 2,
NU_E=15,
NU_E_BAR=16,
MU_MINUS=5,
MU_PLUS=4,
NU_MU=17,
NU_MU_BAR=18,
TAU_MINUS=91,
TAU_PLUS=90,
NU_TAU=92,
NU_TAU_BAR=93,
GAMMA=1,
/*etc etc etc
PI_0 6
RHO_0 27
K_L_0 11
PI_PLUS 7
PI_MINUS 8
RHO_PLUS 25
RHO_MINUS 26
ETA 23
OMEGA 32
K_S_0 12
K_STAR_0 30
K_STAR_BAR_0 31
K_PLUS 9
K_MINUS 10
K_STAR_PLUS 28
K_STAR_MINUS 29
D_PLUS 59
D_MINUS 60
D_STAR_PLUS 78
D_STAR_MINUS 79
D_0 71
D_BAR_0 72
D_STAR_0 80
D_STAR_BAR_0 81
D_S_PLUS 74
D_S_MINUS 75
D_STAR_S_PLUS 76
D_STAR_S_MINUS 77
ETA_C 73
N_0 14
N_BAR_0 -14
DELTA_0 42
DELTA_BAR_0 -42
P_PLUS 13
P_BAR_MINUS -13
DELTA_PLUS 41
DELTA_BAR_MINUS -41
DELTA_PLUS_PLUS 40
DELTA_BAR_MINUS_MINUS -40
SIGMA_MINUS 36
SIGMA_BAR_PLUS -36
LAMBDA_0 39
LAMBDA_BAR_0 -39
SIGMA_0 35
SIGMA_BAR_0 -35
SIGMA_PLUS 34
SIGMA_BAR_MINUS -34
XI_MINUS 38
XI_BAR_PLUS -38
XI_0 37
XI_BAR_0 -37
OMEGA_MINUS 49
OMEGA_BAR_PLUS -49
SIGMA_C_0 86
SIGMA_C_BAR_0 -86
SIGMA_STAR_C_0 96
SIGMA_STAR_C_BAR_0 -96
LAMBDA_C_PLUS 89
LAMBDA_C_BAR_MINUS -89
XI_C_0 88
XI_C_BAR_0 -88
SIGMA_C_PLUS 85
SIGMA_C_BAR_MINUS -85
SIGMA_STAR_C_PLUS 95
SIGMA_STAR_C_BAR_MINUS -95
SIGMA_C_PLUS_PLUS 84
SIGMA_C_BAR_MINUS_MINUS -84
SIGMA_STAR_C_PLUS_PLUS 94
SIGMA_STAR_C_BAR_MINUS_MINUS -94
XI_C_PLUS 87
XI_C_BAR_MINUS -87
OMEGA_C_0 99
OMEGA_C_BAR_0 -99
J_PSI 83
VOID 0
*/
};
static const std::map<sibyll::PID, ParticleProperties::InternalParticleCode> Sibyll2Corsika;
/*
E_MINUS 3
E_PLUS 2
NU_E 15
NU_E_BAR 16
MU_MINUS 5
MU_PLUS 4
NU_MU 17
NU_MU_BAR 18
TAU_MINUS 91
TAU_PLUS 90
NU_TAU 92
NU_TAU_BAR 93
GAMMA 1
PI_0 6
RHO_0 27
K_L_0 11
PI_PLUS 7
PI_MINUS 8
RHO_PLUS 25
RHO_MINUS 26
ETA 23
OMEGA 32
K_S_0 12
K_STAR_0 30
K_STAR_BAR_0 31
K_PLUS 9
K_MINUS 10
K_STAR_PLUS 28
K_STAR_MINUS 29
D_PLUS 59
D_MINUS 60
D_STAR_PLUS 78
D_STAR_MINUS 79
D_0 71
D_BAR_0 72
D_STAR_0 80
D_STAR_BAR_0 81
D_S_PLUS 74
D_S_MINUS 75
D_STAR_S_PLUS 76
D_STAR_S_MINUS 77
ETA_C 73
N_0 14
N_BAR_0 -14
DELTA_0 42
DELTA_BAR_0 -42
P_PLUS 13
P_BAR_MINUS -13
DELTA_PLUS 41
DELTA_BAR_MINUS -41
DELTA_PLUS_PLUS 40
DELTA_BAR_MINUS_MINUS -40
SIGMA_MINUS 36
SIGMA_BAR_PLUS -36
LAMBDA_0 39
LAMBDA_BAR_0 -39
SIGMA_0 35
SIGMA_BAR_0 -35
SIGMA_PLUS 34
SIGMA_BAR_MINUS -34
XI_MINUS 38
XI_BAR_PLUS -38
XI_0 37
XI_BAR_0 -37
OMEGA_MINUS 49
OMEGA_BAR_PLUS -49
SIGMA_C_0 86
SIGMA_C_BAR_0 -86
SIGMA_STAR_C_0 96
SIGMA_STAR_C_BAR_0 -96
LAMBDA_C_PLUS 89
LAMBDA_C_BAR_MINUS -89
XI_C_0 88
XI_C_BAR_0 -88
SIGMA_C_PLUS 85
SIGMA_C_BAR_MINUS -85
SIGMA_STAR_C_PLUS 95
SIGMA_STAR_C_BAR_MINUS -95
SIGMA_C_PLUS_PLUS 84
SIGMA_C_BAR_MINUS_MINUS -84
SIGMA_STAR_C_PLUS_PLUS 94
SIGMA_STAR_C_BAR_MINUS_MINUS -94
XI_C_PLUS 87
XI_C_BAR_MINUS -87
OMEGA_C_0 99
OMEGA_C_BAR_0 -99
J_PSI 83
VOID 0
*/
#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