From 67f950cf15b47e89f531666647c4cecc85a43b62 Mon Sep 17 00:00:00 2001
From: Simon Spannagel <simon.spannagel@cern.ch>
Date: Wed, 11 Mar 2020 09:36:07 +0100
Subject: [PATCH] ELEUDAQ2: allow overwriting of calibration_file via module
 config

---
 .../EventLoaderEUDAQ2/EventLoaderEUDAQ2.cpp       | 15 ++++++++-------
 src/modules/EventLoaderEUDAQ2/README.md           |  2 +-
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/modules/EventLoaderEUDAQ2/EventLoaderEUDAQ2.cpp b/src/modules/EventLoaderEUDAQ2/EventLoaderEUDAQ2.cpp
index f71adc5cd..4f5302f2a 100644
--- a/src/modules/EventLoaderEUDAQ2/EventLoaderEUDAQ2.cpp
+++ b/src/modules/EventLoaderEUDAQ2/EventLoaderEUDAQ2.cpp
@@ -26,6 +26,14 @@ EventLoaderEUDAQ2::EventLoaderEUDAQ2(Configuration config, std::shared_ptr<Detec
     m_shift_triggers = m_config.get<int>("shift_triggers", 0);
     m_inclusive = m_config.get("inclusive", true);
 
+    // Provide the calibration file specified in the detector geometry:
+    // NOTE: This should go first to allow overwriting the calibration_file key in the module config
+    auto calibration_file = m_detector->calibrationFile();
+    if(!calibration_file.empty()) {
+        LOG(DEBUG) << "Forwarding detector calibration file: " << calibration_file;
+        cfg.Set("calibration_file", calibration_file);
+    }
+
     // Forward all settings to EUDAQ
     // WARNING: the EUDAQ Configuration class is not very flexible and e.g. booleans have to be passed as 1 and 0.
     eudaq::Configuration cfg;
@@ -35,13 +43,6 @@ EventLoaderEUDAQ2::EventLoaderEUDAQ2(Configuration config, std::shared_ptr<Detec
         cfg.Set(key.first, key.second);
     }
 
-    // In addition, also provide the calibration file specified in the detector geometry:
-    auto calibration_file = m_detector->calibrationFile();
-    if(!calibration_file.empty()) {
-        LOG(DEBUG) << "Forwarding detector calibration file: " << calibration_file;
-        cfg.Set("calibration_file", calibration_file);
-    }
-
     // Converting the newly built configuration to a shared pointer of a cont configuration object
     // Unfortunbately EUDAQ does not provide appropriate member functions for their configuration class to avoid this dance
     const eudaq::Configuration eu_cfg = cfg;
diff --git a/src/modules/EventLoaderEUDAQ2/README.md b/src/modules/EventLoaderEUDAQ2/README.md
index 23043db6c..8118ab726 100644
--- a/src/modules/EventLoaderEUDAQ2/README.md
+++ b/src/modules/EventLoaderEUDAQ2/README.md
@@ -73,7 +73,7 @@ It should be kept in mind that the resulting configuration strings are parsed by
 For example, it does not interpret `true` or `false` alphabetic value of a Boolean variable but will return false in both cases. Thus `key = 0` or `key = 1` have to be used in these cases.
 Also, more complex constructs such as arrays or matrices read by the Corryvreckan configuration are simply interpreted as strings.
 
-In addition, the calibration file of the detector specified in the geometry configuration is passed to the EUDAQ2 event decoder using the key `calibration_file` and its canonical path as value.
+In addition, the calibration file of the detector specified in the geometry configuration is passed to the EUDAQ2 event decoder using the key `calibration_file` and its canonical path as value. Adding the same key to the module configuration will overwrite the file specified in the detector geometry.
 
 ### Parameters
 * `file_name`: File name of the EUDAQ2 raw data file. This parameter is mandatory.
-- 
GitLab