From cbdd80bec6c84c66e9df7c5b3c89b123b0165d90 Mon Sep 17 00:00:00 2001
From: yoyamagu <yohei.yamaguchi@cern.ch>
Date: Sun, 8 Nov 2020 23:27:40 +0900
Subject: [PATCH] protect for events not containing NSW

---
 .../TrigAlgorithms/TrigL2MuonSA/src/MmDataPreparator.cxx   | 7 +++++--
 .../TrigAlgorithms/TrigL2MuonSA/src/StgcDataPreparator.cxx | 7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MmDataPreparator.cxx b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MmDataPreparator.cxx
index e492b63ba28..b7fe4807c59 100644
--- a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MmDataPreparator.cxx
+++ b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MmDataPreparator.cxx
@@ -61,15 +61,18 @@ StatusCode TrigL2MuonSA::MmDataPreparator::prepareData(const TrigRoiDescriptor*
   std::vector<IdentifierHash> mmHashList_cache;
 
   // Get MM container
-  const Muon::MMPrepDataContainer* mmPrds;
+  if(m_mmPrepContainerKey.empty()) {
+    ATH_MSG_INFO("no mmPrepContainerKey");
+    return StatusCode::SUCCESS;
+  }
   auto mmPrepContainerHandle = SG::makeHandle(m_mmPrepContainerKey);
-  mmPrds = mmPrepContainerHandle.cptr();
   if (!mmPrepContainerHandle.isValid()) {
     ATH_MSG_ERROR("Cannot retrieve MM PRD Container key: " << m_mmPrepContainerKey.key());
     return StatusCode::FAILURE;
   } else {
     ATH_MSG_DEBUG("MM PRD Container retrieved with key: " << m_mmPrepContainerKey.key());
   }
+  const Muon::MMPrepDataContainer* mmPrds = mmPrepContainerHandle.cptr();
 
   if (m_use_RoIBasedDataAccess) {
     // ATH_MSG_ERROR("RoI based data access is not available yet");
diff --git a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/StgcDataPreparator.cxx b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/StgcDataPreparator.cxx
index 2d81851310c..cfcd83590e0 100644
--- a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/StgcDataPreparator.cxx
+++ b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/StgcDataPreparator.cxx
@@ -61,15 +61,18 @@ StatusCode TrigL2MuonSA::StgcDataPreparator::prepareData(const TrigRoiDescriptor
   std::vector<IdentifierHash> stgcHashList_cache;
 
   // Get sTGC container
-  const Muon::sTgcPrepDataContainer* stgcPrds;
+  if(m_stgcPrepContainerKey.empty()) {
+    ATH_MSG_INFO("no stgcPrepContainerKey");
+    return StatusCode::SUCCESS;
+  }
   auto stgcPrepContainerHandle = SG::makeHandle(m_stgcPrepContainerKey);
-  stgcPrds = stgcPrepContainerHandle.cptr();
   if (!stgcPrepContainerHandle.isValid()) {
     ATH_MSG_ERROR("Cannot retrieve sTgc PRD Container key: " << m_stgcPrepContainerKey.key());
     return StatusCode::FAILURE;
   } else {
     ATH_MSG_DEBUG("sTgc PRD Container retrieved with key: " << m_stgcPrepContainerKey.key());
   }
+  const Muon::sTgcPrepDataContainer* stgcPrds = stgcPrepContainerHandle.cptr();
 
   if (m_use_RoIBasedDataAccess) {
     // ATH_MSG_ERROR("RoI based data access is not available yet");
-- 
GitLab