IAP GITLAB

Skip to content
Snippets Groups Projects
Commit b971b99c authored by Maximilian Reininghaus's avatar Maximilian Reininghaus :vulcan:
Browse files

improved code generation script a bit

parent 1c626153
No related branches found
No related tags found
No related merge requests found
...@@ -92,7 +92,7 @@ def c_identifier(name): ...@@ -92,7 +92,7 @@ def c_identifier(name):
# ######################################################## #########################################################
# #
# returns dict containing all data from pythia-xml input # returns dict containing all data from pythia-xml input
# #
...@@ -203,17 +203,17 @@ def gen_classes(pythia_db): ...@@ -203,17 +203,17 @@ def gen_classes(pythia_db):
break break
string += "\n"; string += "\n";
string += "struct " + cname + "{\n" string += ("struct " + cname + " {\n"
string += " static InternalParticleCode GetType() { return Type; }\n" " static constexpr InternalParticleCode GetType() { return Type; }\n"
string += " static quantity<energy_d> GetMass() { return masses[TypeIndex]; }\n" " static auto constexpr GetMass() { return masses[TypeIndex]; }\n"
string += " static quantity<electric_charge_d> GetCharge() { return phys::units::e*electric_charge[TypeIndex]/3; }\n" " static auto constexpr GetCharge() { return phys::units::e*electric_charge[TypeIndex]/3; }\n"
string += " static std::string GetName() { return names[TypeIndex]; }\n" " static auto const GetName() { return names[TypeIndex]; }\n"
string += " static InternalParticleCode GetAntiParticle() { return AntiType; }\n" " static auto constexpr GetAntiParticle() { return AntiType; }\n"
string += " static const InternalParticleCode Type = InternalParticleCode::" + cname + ";\n" " static auto constexpr Type = InternalParticleCode::") + cname + ";\n" + \
string += " static const InternalParticleCode AntiType = InternalParticleCode::" + antiP + ";\n" " static auto constexpr AntiType = InternalParticleCode::" + antiP + ";\n" + \
string += " private:\n" (" private:\n"
string += " static const uint8_t TypeIndex = static_cast<uint8_t const>(Type);\n" " static constexpr uint8_t TypeIndex = static_cast<uint8_t const>(Type);\n"
string += "};\n" "};\n")
return string return string
...@@ -223,16 +223,16 @@ def gen_classes(pythia_db): ...@@ -223,16 +223,16 @@ def gen_classes(pythia_db):
# #
def inc_start(): def inc_start():
string = "" string = (""
string += "#ifndef _include_GeneratedParticleDataTable_h_\n" "#ifndef _include_GeneratedParticleDataTable_h_\n"
string += "#define _include_GeneratedParticleDataTable_h_\n\n" "#define _include_GeneratedParticleDataTable_h_\n\n"
string += "#include <array>\n" "#include <array>\n"
string += "#include <cstdint>\n" "#include <cstdint>\n"
string += "#include <iostream>\n\n" "#include <iostream>\n\n"
string += "using namespace phys::units;\n" "using namespace phys::units;\n"
string += "using namespace phys::units::literals;\n\n" "using namespace phys::units::literals;\n\n"
string += "namespace ParticleProperties {\n\n" "namespace ParticleProperties {\n\n"
string += "typedef int16_t PDGCode;\n\n" "typedef int16_t PDGCode;\n\n")
return string return string
...@@ -254,18 +254,16 @@ def inc_end(): ...@@ -254,18 +254,16 @@ def inc_end():
if __name__ == "__main__": if __name__ == "__main__":
if (len(sys.argv)!=3) : if len(sys.argv) != 3:
print ("pdxml_reader.py Pythia8.xml ClassNames.xml") print("usage: pdxml_reader.py Pythia8.xml ClassNames.xml", file=sys.stderr)
sys.exit(0) sys.exit(0)
names = class_names(sys.argv[2]) names = class_names(sys.argv[2])
pythia_db = build_pythia_db(sys.argv[1], names) pythia_db = build_pythia_db(sys.argv[1], names)
print ("\n pdxml_reader.py: Automatically produce particle-properties from PYTHIA8 xml file\n") print("\n pdxml_reader.py: automatically produce particle properties from PYTHIA8 xml file\n")
counter = itertools.count(0) counter = itertools.count(0)
not_modeled = []
for p in pythia_db: for p in pythia_db:
pythia_db[p]['ngc_code'] = next(counter) pythia_db[p]['ngc_code'] = next(counter)
......
...@@ -27,6 +27,7 @@ using Time = phys::units::quantity<phys::units::time_interval_d, double>; ...@@ -27,6 +27,7 @@ using Time = phys::units::quantity<phys::units::time_interval_d, double>;
using Speed = phys::units::quantity<phys::units::speed_d, double>; using Speed = phys::units::quantity<phys::units::speed_d, double>;
using Frequency = phys::units::quantity<phys::units::frequency_d, double>; using Frequency = phys::units::quantity<phys::units::frequency_d, double>;
using ElectricCharge = phys::units::quantity<phys::units::electric_charge_d, double>; using ElectricCharge = phys::units::quantity<phys::units::electric_charge_d, double>;
using Energy = phys::units::quantity<phys::units::energy_d, double>;
#endif #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