From 5f56220e86b69ccc509987c79997c4a1095b6e70 Mon Sep 17 00:00:00 2001
From: Felix Riehn <felix@matilda>
Date: Thu, 23 Apr 2020 12:57:26 +0100
Subject: [PATCH] added sibyll masses to list

---
 .../Examples/particle_list_example.cc         | 21 ++++++++++---------
 Processes/Sibyll/ParticleConversion.cc        |  9 ++++++++
 Processes/Sibyll/ParticleConversion.h         |  5 +++++
 Processes/Sibyll/testSibyll.cc                |  8 +++++++
 4 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/Documentation/Examples/particle_list_example.cc b/Documentation/Examples/particle_list_example.cc
index ec3fba9e6..d51efa039 100644
--- a/Documentation/Examples/particle_list_example.cc
+++ b/Documentation/Examples/particle_list_example.cc
@@ -9,10 +9,10 @@
  */
 
 #include <corsika/particles/ParticleProperties.h>
-#include <corsika/units/PhysicalUnits.h>
 #include <corsika/process/ProcessSequence.h>
-#include <corsika/setup/SetupEnvironment.h>
 #include <corsika/process/sibyll/ParticleConversion.h>
+#include <corsika/setup/SetupEnvironment.h>
+#include <corsika/units/PhysicalUnits.h>
 
 #include <iomanip>
 #include <iostream>
@@ -30,18 +30,19 @@ int main() {
        << "--------------------" << endl;
   cout << std::setw(20) << "Name"
        << " | " << std::setw(10) << "PDG-id"
-       << " |  " << std::setw(10) << "mass (GeV)"
        << " | " << std::setw(10) << "SIBYLL-id"
-       << endl;
+       << " | " << std::setw(18) << "PDG-mass (GeV)"
+       << " | " << std::setw(18) << "SIBYLL-mass (GeV)"
+       << " | " << endl;
   cout << std::setw(58) << std::setfill('-') << "-" << endl;
   for (auto p : corsika::particles::detail::all_particles) {
     if (p != Code::Unknown && !IsNucleus(p))
-      cout << std::setw(20) << std::setfill(' ') << p << " | "	
-           << std::setw(10) << static_cast<int>(GetPDG(p)) << " | "
-	   << std::setw(10) << GetMass(p) / 1_GeV << " | "
-	   << std::setw(10) << static_cast<int>(corsika::process::sibyll::ConvertToSibyll(p)) << " | "
-	   
-	   << endl;
+      cout << std::setw(20) << std::setfill(' ') << p << " | " << std::setw(10)
+           << static_cast<int>(GetPDG(p)) << " | " << std::setw(10)
+           << static_cast<int>(corsika::process::sibyll::ConvertToSibyll(p)) << " | "
+	   << std::setw(18) << GetMass(p) / 1_GeV << " | "
+           << std::setw(18) << corsika::process::sibyll::GetSibyllMass(p) / 1_GeV << " | "
+           << endl;
   }
   cout << std::setw(54) << std::setfill('-') << "-" << endl;
 }
diff --git a/Processes/Sibyll/ParticleConversion.cc b/Processes/Sibyll/ParticleConversion.cc
index 4a19f2fb9..fd15e2aa0 100644
--- a/Processes/Sibyll/ParticleConversion.cc
+++ b/Processes/Sibyll/ParticleConversion.cc
@@ -13,6 +13,15 @@
 
 using namespace corsika::process::sibyll;
 
+corsika::units::si::HEPMassType corsika::process::sibyll::GetSibyllMass(corsika::particles::Code const pCode) {
+  using namespace corsika::units;
+  using namespace corsika::units::si;
+  if (pCode == corsika::particles::Code::Nucleus)
+    throw std::runtime_error("Cannot GetMass() of particle::Nucleus -> unspecified");
+  auto sCode = ConvertToSibyllRaw(pCode);
+  return sqrt(get_sibyll_mass2(sCode)) * 1_GeV;
+}
+
 // const std::map<sibyll::PID, ParticleProperties::InternalParticleCode>
 //   process::sibyll::Sibyll2Corsika = {
 //        {PID::E_MINUS, InternalParticleCode::Electron},
diff --git a/Processes/Sibyll/ParticleConversion.h b/Processes/Sibyll/ParticleConversion.h
index 62ccdda99..26f6b3b14 100644
--- a/Processes/Sibyll/ParticleConversion.h
+++ b/Processes/Sibyll/ParticleConversion.h
@@ -11,7 +11,9 @@
 #ifndef _include_processes_sibyll_particles_h_
 #define _include_processes_sibyll_particles_h_
 
+#include <corsika/units/PhysicalUnits.h>
 #include <corsika/particles/ParticleProperties.h>
+#include <corsika/process/sibyll/sibyll2.3c.h>
 
 #include <string>
 
@@ -50,6 +52,9 @@ namespace corsika::process::sibyll {
     return GetSibyllXSCode(pCode) > 0;
   }
 
+  corsika::units::si::HEPMassType GetSibyllMass(corsika::particles::Code const);
+  
+
 } // namespace corsika::process::sibyll
 
 #endif
diff --git a/Processes/Sibyll/testSibyll.cc b/Processes/Sibyll/testSibyll.cc
index 0453220f4..a8dd5488e 100644
--- a/Processes/Sibyll/testSibyll.cc
+++ b/Processes/Sibyll/testSibyll.cc
@@ -24,6 +24,8 @@
 
 using namespace corsika;
 using namespace corsika::process::sibyll;
+using namespace corsika::units;
+using namespace corsika::units::si;
 
 TEST_CASE("Sibyll", "[processes]") {
 
@@ -60,6 +62,12 @@ TEST_CASE("Sibyll", "[processes]") {
     REQUIRE(process::sibyll::GetSibyllXSCode(particles::Code::SigmaPlus) == 1);
     REQUIRE(process::sibyll::GetSibyllXSCode(particles::Code::PiMinus) == 2);
   }
+
+  SECTION("sibyll mass") {
+
+    REQUIRE_FALSE(process::sibyll::GetSibyllMass(particles::Code::Electron) == 0_GeV);
+  }
+
 }
 
 #include <corsika/geometry/Point.h>
-- 
GitLab