From 1659fcec1444951e2184a5df3b1b11eefc93d1ee Mon Sep 17 00:00:00 2001
From: Martin Hierholzer <martin.hierholzer@desy.de>
Date: Fri, 17 Jan 2020 09:44:35 +0100
Subject: [PATCH] propagate initial values through TriggerFanOuts

---
 include/TriggerFanOut.h | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/include/TriggerFanOut.h b/include/TriggerFanOut.h
index 10649501..56894c43 100644
--- a/include/TriggerFanOut.h
+++ b/include/TriggerFanOut.h
@@ -64,13 +64,8 @@ namespace ChimeraTK {
     void run() {
       Application::registerThread("TrFO" + externalTrigger->getName());
       Application::testableModeLock("start");
+      ChimeraTK::VersionNumber version;
       while(true) {
-        // wait for external trigger
-        boost::this_thread::interruption_point();
-        Profiler::stopMeasurement();
-        externalTrigger->read();
-        Profiler::startMeasurement();
-        boost::this_thread::interruption_point();
         // receive data. We need to catch exceptions here, since the ExceptionHandlingDecorator cannot do this for us
         // inside a TransferGroup, if the exception is thrown inside doReadTransfer() (as it is directly called on the
         // lowest-level TransferElements inside the group).
@@ -89,9 +84,15 @@ namespace ChimeraTK {
           dm.reportException(e.what());
           goto retry;
         }
-        // send the data to the consumers
-        auto version = externalTrigger->getVersionNumber();
+        // send the version number to the consumers
         boost::fusion::for_each(fanOutMap.table, SendDataToConsumers(version));
+        // wait for external trigger
+        boost::this_thread::interruption_point();
+        Profiler::stopMeasurement();
+        externalTrigger->read();
+        Profiler::startMeasurement();
+        boost::this_thread::interruption_point();
+        version = externalTrigger->getVersionNumber();
       }
     }
 
-- 
GitLab