From 444afef64878e2764dc28272249155e0bb46c98c Mon Sep 17 00:00:00 2001
From: abarton <Adam.Edward.Barton@cern.ch>
Date: Fri, 18 Jan 2019 11:41:44 +0000
Subject: [PATCH] Escalate insideView check to error and only check once

---
 .../InDetPrepRawDataFormation/src/CacheCreator.cxx        | 8 ++++++--
 .../InDetPrepRawDataFormation/src/CacheCreator.h          | 2 +-
 .../MuonCnv/MuonByteStream/src/MuonCacheCreator.cxx       | 8 ++++++--
 .../MuonCnv/MuonByteStream/src/MuonCacheCreator.h         | 2 +-
 4 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/CacheCreator.cxx b/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/CacheCreator.cxx
index 96e139890f5..ee0748889c0 100644
--- a/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/CacheCreator.cxx
+++ b/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/CacheCreator.cxx
@@ -66,8 +66,12 @@ namespace InDet{
     StatusCode CacheCreator::execute (const EventContext& ctx) const
     {
 
-        if(!m_disableWarning && isInsideView(ctx)){
-           ATH_MSG_WARNING("CacheCreator is running inside a view, this is probably a misconfiguration");
+        if(!m_disableWarning){
+          if(isInsideView(ctx)){
+            ATH_MSG_ERROR("CacheCreator is running inside a view, this is probably a misconfiguration");
+            return StatusCode::FAILURE;
+          }
+          m_disableWarning = true; //only check once
         }
 
         if(!m_disableTRT) ATH_CHECK(createContainer(m_rioContainerCacheKey, m_pTRTHelper->straw_layer_hash_max(), ctx));
diff --git a/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/CacheCreator.h b/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/CacheCreator.h
index d18484bcfbe..16cc736a056 100644
--- a/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/CacheCreator.h
+++ b/InnerDetector/InDetRecAlgs/InDetPrepRawDataFormation/src/CacheCreator.h
@@ -51,7 +51,7 @@ namespace InDet{
         SG::WriteHandleKey<SCT_RDO_Cache>      m_SCTRDOCacheKey;
         SG::WriteHandleKey<PixelRDO_Cache>     m_PixRDOCacheKey;
         bool m_disableTRT;
-        bool m_disableWarning;
+        mutable bool m_disableWarning;
 	//Temporary workarounds for problem in scheduler - remove later
         SG::ReadCondHandleKey<PixelCalib::PixelOfflineCalibData> m_condKey5{ this, "PixelOfflineCalibData", "PixelOfflineCalibData", "" };
         SG::ReadCondHandleKey<DetectorSpecialPixelMap> m_condKey12{ this, "SpecialPixelMap", "SpecialPixelMap", "" };
diff --git a/MuonSpectrometer/MuonCnv/MuonByteStream/src/MuonCacheCreator.cxx b/MuonSpectrometer/MuonCnv/MuonByteStream/src/MuonCacheCreator.cxx
index f13d808a4c4..b55dc1ff486 100644
--- a/MuonSpectrometer/MuonCnv/MuonByteStream/src/MuonCacheCreator.cxx
+++ b/MuonSpectrometer/MuonCnv/MuonByteStream/src/MuonCacheCreator.cxx
@@ -37,8 +37,12 @@ bool MuonCacheCreator::isInsideView(const EventContext& context) const
 
 StatusCode MuonCacheCreator::execute (const EventContext& ctx) const {
 
-  if(!m_disableWarning && isInsideView(ctx)){
-     ATH_MSG_WARNING("CacheCreator is running inside a view, this is probably a misconfiguration");
+  if(!m_disableWarning){
+     if(isInsideView(ctx)){
+        ATH_MSG_ERROR("CacheCreator is running inside a view, this is probably a misconfiguration");
+        return StatusCode::FAILURE;
+     }
+     m_disableWarning = true; //only check once
   }
   // Create the MDT cache container
   auto maxHashMDTs = m_mdtIdHelper->stationNameIndex("BME") != -1 ?
diff --git a/MuonSpectrometer/MuonCnv/MuonByteStream/src/MuonCacheCreator.h b/MuonSpectrometer/MuonCnv/MuonByteStream/src/MuonCacheCreator.h
index c3908ac00b8..9a78b8520d0 100644
--- a/MuonSpectrometer/MuonCnv/MuonByteStream/src/MuonCacheCreator.h
+++ b/MuonSpectrometer/MuonCnv/MuonByteStream/src/MuonCacheCreator.h
@@ -34,7 +34,7 @@ protected:
 
   /// ID helpers
   const MdtIdHelper* m_mdtIdHelper = 0;
-  bool m_disableWarning = false;
+  mutable bool m_disableWarning = false;
   bool isInsideView(const EventContext&) const;
 };//class MuonCacheCreator
 
-- 
GitLab