From e342d870c8b534c49e2ca67fc128b7abe16b9ed8 Mon Sep 17 00:00:00 2001
From: Atlas-Software Librarian <Atlas-Software.Librarian@cern.ch>
Date: Fri, 8 Apr 2016 16:12:39 +0200
Subject: [PATCH] 'CMakeLists.txt' (PixelConditionsServices-00-24-28)

Former-commit-id: 60b980b8c7b5fee854879eb86295e85bf59ef161
---
 .../src/PixelByteStreamErrorsSvc.cxx          | 24 +++++++++++++++----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/InnerDetector/InDetConditions/PixelConditionsServices/src/PixelByteStreamErrorsSvc.cxx b/InnerDetector/InDetConditions/PixelConditionsServices/src/PixelByteStreamErrorsSvc.cxx
index da021b354fd..476542769e9 100644
--- a/InnerDetector/InDetConditions/PixelConditionsServices/src/PixelByteStreamErrorsSvc.cxx
+++ b/InnerDetector/InDetConditions/PixelConditionsServices/src/PixelByteStreamErrorsSvc.cxx
@@ -368,11 +368,25 @@ StatusCode PixelByteStreamErrorsSvc::readData() {
 // record the data to Storegate: for one event, one entry per module with errors
 StatusCode PixelByteStreamErrorsSvc::recordData() {
 
-  InDetBSErrContainer* cont = new InDetBSErrContainer();
-  StatusCode sc = m_storeGate->overwrite(cont,"PixelByteStreamErrs");
-  if (sc.isFailure() ){
-    msg(MSG::ERROR) <<"Failed to record/overwrite BSErrors to SG"<<endreq;
-    return sc;
+  StatusCode sc(StatusCode::SUCCESS);
+  bool recorded = m_storeGate->contains<InDetBSErrContainer>("PixelByteStreamErrs"); // check if already recorded (by a previous HLT call for example)
+
+  InDetBSErrContainer* cont;
+  if (!recorded){ // create a new object
+    cont = new InDetBSErrContainer();
+    sc = m_storeGate->record(cont,"PixelByteStreamErrs");
+    if (sc.isFailure() ){
+      msg(MSG::ERROR) <<"Failed to record BSErrors to SG"<<endreq;
+      return sc;
+    }
+  }
+  else{ // already recorded, retrieve object and modify
+    sc = m_storeGate->retrieve(cont,"PixelByteStreamErrs");
+    if (sc.isFailure() ){
+      msg(MSG::ERROR) <<"Failed to retrieve BSErrors from SG, but contains() returns true"<<endreq;
+      return sc;
+    }
+    cont->clear(); // delete and fill anew
   }
 
   for (unsigned int i=0; i<m_max_hashes; i++) {
-- 
GitLab