diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f3362bf105cc99e7b7421f8b70024281cea58ed..c436d8906e31f56c3d010e255736cc16c87a7050 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/Documentation/Examples/stack_example.cc b/Documentation/Examples/stack_example.cc index 940247698d8bbd561887d08bae628dc57fb14eb6..a1f1c0e7c7ff7cc564d40c5a70c510bafa2bae0e 100644 --- a/Documentation/Examples/stack_example.cc +++ b/Documentation/Examples/stack_example.cc @@ -1,5 +1,5 @@ +#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; } diff --git a/Framework/Geometry/testGeometry.cc b/Framework/Geometry/testGeometry.cc index 2af6e2c50d21a5008f13c65d4ec490ea5eb363d8..7de635c6ce8d6597a7969718186c5bea93d7f5b0 100644 --- a/Framework/Geometry/testGeometry.cc +++ b/Framework/Geometry/testGeometry.cc @@ -1,4 +1,5 @@ -#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") {} } diff --git a/Framework/Particles/CMakeLists.txt b/Framework/Particles/CMakeLists.txt index 46ee9f8399f3ba089c8b92377042ad2df9203782..7602fe9ff871ccae04dbe3a87f9fdb76561ff0a4 100644 --- a/Framework/Particles/CMakeLists.txt +++ b/Framework/Particles/CMakeLists.txt @@ -1,13 +1,14 @@ 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> ) diff --git a/Framework/Particles/Particles.h b/Framework/Particles/ParticleProperties.h similarity index 73% rename from Framework/Particles/Particles.h rename to Framework/Particles/ParticleProperties.h index 3b443a687ca1058447a7634bdb205be06954fd94..7f2f433d925b5febe49909fcf1269eba8db1d8bb 100644 --- a/Framework/Particles/Particles.h +++ b/Framework/Particles/ParticleProperties.h @@ -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; } diff --git a/Framework/Particles/pdxml_reader.py b/Framework/Particles/pdxml_reader.py index 6d0eb7021e3e1c554cac6d77a0b5bd08b7bf2278..6c1fc3bd95339c0d6366452705d57d0bc7aabefc 100755 --- a/Framework/Particles/pdxml_reader.py +++ b/Framework/Particles/pdxml_reader.py @@ -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" diff --git a/Framework/Particles/testParticles.cc b/Framework/Particles/testParticles.cc index c31aa2612e49d189e13f50218b8198f915df0fcd..8b219a3eded171c52a0df47b09de7821b9b128e0 100644 --- a/Framework/Particles/testParticles.cc +++ b/Framework/Particles/testParticles.cc @@ -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 == diff --git a/Processes/CMakeLists.txt b/Processes/CMakeLists.txt index f1e2ce31a5222add07914f66e1f8b9d5b48be415..9b81c6d9857687cb808691565a1b5c9b6b413cfd 100644 --- a/Processes/CMakeLists.txt +++ b/Processes/CMakeLists.txt @@ -1 +1,2 @@ add_subdirectory (NullModel) +add_subdirectory (Sibyll) diff --git a/Processes/NullModel/NullModel.cc b/Processes/NullModel/NullModel.cc index 96972982496c08a681e56b1a4cd68d604d266801..8863c12931f86291252154150ada64a2b76613f4 100644 --- a/Processes/NullModel/NullModel.cc +++ b/Processes/NullModel/NullModel.cc @@ -1,2 +1,13 @@ -#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; } diff --git a/Processes/NullModel/NullModel.h b/Processes/NullModel/NullModel.h index a78e14d14eeeb8b9f7b1739e7d29860a4f506b05..bd33c4f53a7c79900403d5a1f7597c59658b5944 100644 --- a/Processes/NullModel/NullModel.h +++ b/Processes/NullModel/NullModel.h @@ -1,20 +1,23 @@ #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 - diff --git a/Processes/Sibyll/Particles.cc b/Processes/Sibyll/Particles.cc deleted file mode 100644 index fc449b0223badebad1249a48bf60af3b3e8b5fea..0000000000000000000000000000000000000000 --- a/Processes/Sibyll/Particles.cc +++ /dev/null @@ -1,9 +0,0 @@ -#include <Sibyll/Particle.h> - -using namespace processes; - -const std::map<sibyll::PID, ParticleProperties::InternalParticleCode> -processes::sibyll::Sibyll2Corsika = { - {sibyll::PID::E_MINUS, InternalParticleCode::Electron}, -}; - diff --git a/Processes/Sibyll/Particles.h b/Processes/Sibyll/Particles.h deleted file mode 100644 index aa6ddfd5073a7ab742704b87a4c158ee4ced5892..0000000000000000000000000000000000000000 --- a/Processes/Sibyll/Particles.h +++ /dev/null @@ -1,199 +0,0 @@ -#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