From e1cfad0fac6588eba2e8217c6981a2eccf44d46b Mon Sep 17 00:00:00 2001
From: ralfulrich <ralf.ulrich@kit.edu>
Date: Sat, 1 May 2021 12:55:35 +0200
Subject: [PATCH] better ctest output, qgsjet better filename handling

---
 .gitlab-ci.yml                                  |  1 +
 corsika/detail/modules/qgsjetII/Interaction.inl | 12 +++---------
 corsika/modules/qgsjetII/Interaction.hpp        | 17 ++++++++++-------
 3 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index aa52dd3f3..a97787668 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -16,6 +16,7 @@ variables:
   # _alternatively_ corsika-data can be downloaded as submodule:
   GIT_SUBMODULE_STRATEGY: normal # none: we get the submodules in before_script,
                                  # normal: get submodules automatically
+  CTEST_OUTPUT_ON_FAILURE: 1
 
 
 #
diff --git a/corsika/detail/modules/qgsjetII/Interaction.inl b/corsika/detail/modules/qgsjetII/Interaction.inl
index 217fe30b7..9a86aa880 100644
--- a/corsika/detail/modules/qgsjetII/Interaction.inl
+++ b/corsika/detail/modules/qgsjetII/Interaction.inl
@@ -27,20 +27,14 @@
 
 namespace corsika::qgsjetII {
 
-  inline Interaction::Interaction(const std::string& dataPath)
-      : data_path_(dataPath) {
-    if (dataPath == "") {
-      if (std::getenv("CORSIKA_DATA")) {
-        data_path_ = std::string(std::getenv("CORSIKA_DATA")) + "/QGSJetII/";
-        CORSIKA_LOG_DEBUG("Searching for QGSJetII data tables in {}", data_path_);
-      }
-    }
+  inline Interaction::Interaction(boost::filesystem::path dataPath) {
+    CORSIKA_LOG_DEBUG("Reading QGSJetII data tables from {}", dataPath);
 
     // initialize QgsjetII
     static bool initialized = false;
     if (!initialized) {
       qgset_();
-      datadir DIR(data_path_);
+      datadir DIR(dataPath.string() + "/");
       qgaini_(DIR.data);
       initialized = true;
     }
diff --git a/corsika/modules/qgsjetII/Interaction.hpp b/corsika/modules/qgsjetII/Interaction.hpp
index a45282f58..63c878df5 100644
--- a/corsika/modules/qgsjetII/Interaction.hpp
+++ b/corsika/modules/qgsjetII/Interaction.hpp
@@ -13,6 +13,10 @@
 #include <corsika/framework/random/RNGManager.hpp>
 #include <corsika/framework/process/InteractionProcess.hpp>
 #include <corsika/modules/qgsjetII/ParticleConversion.hpp>
+#include <corsika/framework/utility/CorsikaData.hpp>
+
+#include <boost/filesystem/path.hpp>
+
 #include <qgsjet-II-04.hpp>
 
 #include <string>
@@ -21,14 +25,8 @@ namespace corsika::qgsjetII {
 
   class Interaction : public corsika::InteractionProcess<Interaction> {
 
-    std::string data_path_;
-    int count_ = 0;
-    bool initialized_ = false;
-    QgsjetIIHadronType alternate_ =
-        QgsjetIIHadronType::PiPlusType; // for pi0, rho0 projectiles
-
   public:
-    Interaction(const std::string& dataPath = "");
+    Interaction(boost::filesystem::path dataPath = corsika_data("QGSJetII"));
     ~Interaction();
 
     bool wasInitialized() { return initialized_; }
@@ -53,6 +51,11 @@ namespace corsika::qgsjetII {
     void doInteraction(TSecondaryView&);
 
   private:
+    int count_ = 0;
+    bool initialized_ = false;
+    QgsjetIIHadronType alternate_ =
+        QgsjetIIHadronType::PiPlusType; // for pi0, rho0 projectiles
+
     corsika::default_prng_type& rng_ =
         corsika::RNGManager::getInstance().getRandomStream("qgsjet");
     const int maxMassNumber_ = 208;
-- 
GitLab