From 375b3bc3cc82d7593db7ff00e1e36d4b8ae05de8 Mon Sep 17 00:00:00 2001
From: Rafal Bielski <rafal.bielski@cern.ch>
Date: Tue, 17 Dec 2019 15:43:26 +0100
Subject: [PATCH] Skip bits and stream tag making with a warning if event
 crashed

---
 .../TrigOutputHandling/src/StreamTagMakerTool.cxx |  8 +++++++-
 .../src/TriggerBitsMakerTool.cxx                  | 15 ++++++++++++---
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/Trigger/TrigSteer/TrigOutputHandling/src/StreamTagMakerTool.cxx b/Trigger/TrigSteer/TrigOutputHandling/src/StreamTagMakerTool.cxx
index 9086c0d2533f..fa2bef05deb0 100644
--- a/Trigger/TrigSteer/TrigOutputHandling/src/StreamTagMakerTool.cxx
+++ b/Trigger/TrigSteer/TrigOutputHandling/src/StreamTagMakerTool.cxx
@@ -5,6 +5,7 @@
 #include "StreamTagMakerTool.h"
 #include "TrigConfData/HLTMenu.h"
 #include "TrigConfData/HLTChain.h"
+#include "GaudiKernel/IAlgExecStateSvc.h"
 #include "eformat/StreamTag.h"
 
 using namespace TrigCompositeUtils;
@@ -78,7 +79,12 @@ StatusCode StreamTagMakerTool::fill( HLT::HLTResultMT& resultToFill, const Event
   using namespace TrigCompositeUtils;
   auto chainsHandle = SG::makeHandle( m_finalChainDecisions, ctx );
   if (!chainsHandle.isValid()) {
-    ATH_MSG_ERROR("Unable to read in the HLTNav_Summary from the DecisionSummaryMakerAlg");
+    SmartIF<IAlgExecStateSvc> aess = svcLoc()->service<IAlgExecStateSvc>("AlgExecStateSvc", false);
+    if (aess.isValid() && aess->eventStatus(ctx) != EventStatus::Success) {
+      ATH_MSG_WARNING("Failed event, " << m_finalChainDecisions.key() << " is unavailable. Skipping stream tag making.");
+      return StatusCode::SUCCESS;
+    }
+    ATH_MSG_ERROR("Unable to read in the " << m_finalChainDecisions.key() << " from the DecisionSummaryMakerAlg");
     return StatusCode::FAILURE;
   }
 
diff --git a/Trigger/TrigSteer/TrigOutputHandling/src/TriggerBitsMakerTool.cxx b/Trigger/TrigSteer/TrigOutputHandling/src/TriggerBitsMakerTool.cxx
index 4ced78eba4ac..f4689c8b1410 100644
--- a/Trigger/TrigSteer/TrigOutputHandling/src/TriggerBitsMakerTool.cxx
+++ b/Trigger/TrigSteer/TrigOutputHandling/src/TriggerBitsMakerTool.cxx
@@ -4,6 +4,7 @@
 #include "DecisionHandling/HLTIdentifier.h"
 #include "TrigOutputHandling/TriggerBitsMakerTool.h"
 #include "TrigConfHLTData/HLTUtils.h"
+#include "GaudiKernel/IAlgExecStateSvc.h"
 
 #include <algorithm>
 
@@ -80,13 +81,21 @@ StatusCode TriggerBitsMakerTool::getBits(boost::dynamic_bitset<uint32_t>& passRa
   prescaled.clear();
   rerun.clear();
 
+  auto chainsHandle = SG::makeHandle(m_finalChainDecisions, ctx);
+  if (!chainsHandle.isValid()) {
+    SmartIF<IAlgExecStateSvc> aess = svcLoc()->service<IAlgExecStateSvc>("AlgExecStateSvc", false);
+    if (aess.isValid() && aess->eventStatus(ctx) != EventStatus::Success) {
+      ATH_MSG_WARNING("Failed event, " << m_finalChainDecisions.key() << " is unavailable. Skipping trigger bits making.");
+      return StatusCode::SUCCESS;
+    }
+    ATH_MSG_ERROR("Unable to read in the " << m_finalChainDecisions.key() << " from the DecisionSummaryMakerAlg");
+    return StatusCode::FAILURE;
+  }
+
   passRaw.resize(m_largestBit + 1);
   prescaled.resize(m_largestBit + 1);
   rerun.resize(m_largestBit + 1);
 
-  auto chainsHandle = SG::makeHandle(m_finalChainDecisions, ctx);
-  ATH_CHECK(chainsHandle.isValid());
-
   const Decision* HLTPassRaw = nullptr;
   const Decision* HLTPrescaled = nullptr;
   const Decision* HLTRerun = nullptr;
-- 
GitLab