From f8b78693bc3596c25e55eb4bc2c05dbfb452cd19 Mon Sep 17 00:00:00 2001
From: Soshi Tsuno <soshi.tsuno@cern.ch>
Date: Thu, 6 Aug 2020 09:43:41 +0200
Subject: [PATCH] update

---
 .../src/PixelRawDataProvider.cxx              |  8 ++++++++
 .../src/PixelRawDataProvider.h                |  1 +
 .../src/PixelRawDataProviderTool.cxx          | 20 ++-----------------
 .../src/PixelRawDataProviderTool.h            |  5 -----
 .../src/TrigPixRawDataProvider.cxx            |  2 +-
 5 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.cxx b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.cxx
index e608f17c6a86..d50b392fd753 100644
--- a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.cxx
+++ b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.cxx
@@ -17,6 +17,7 @@ PixelRawDataProvider::PixelRawDataProvider(const std::string& name,
 				       ISvcLocator* pSvcLocator) :
   AthReentrantAlgorithm(name, pSvcLocator) {
   declareProperty("RDOCacheKey", m_rdoCacheKey);
+  declareProperty("BSErrorsCacheKey", m_bsErrorsCacheKey);
 }
 
 // Destructor
@@ -50,6 +51,7 @@ StatusCode PixelRawDataProvider::initialize() {
   ATH_CHECK( m_rdoCacheKey.initialize( SG::AllowEmpty ) );
 
   ATH_CHECK( m_bsErrorsKey.initialize() );
+  ATH_CHECK( m_bsErrorsCacheKey.initialize( SG::AllowEmpty ) );
 
   if (m_roiSeeded) {
     ATH_CHECK( m_roiCollectionKey.initialize() );
@@ -133,6 +135,12 @@ StatusCode PixelRawDataProvider::execute(const EventContext& ctx) const {
          static_cast< IPixelRDO_Container* >(rdoContainer.ptr());
 
   std::unique_ptr<IDCInDetBSErrContainer> decodingErrors;
+  if ( not m_bsErrorsCacheKey.empty() ) {
+    SG::UpdateHandle<IDCInDetBSErrContainer_Cache> bsErrorsCacheHandle( m_bsErrorsCacheKey, ctx);
+    decodingErrors = std::make_unique<IDCInDetBSErrContainer>( bsErrorsCacheHandle.ptr() );
+  } else {
+    decodingErrors = std::make_unique<IDCInDetBSErrContainer>( m_rawDataTool->SizeOfIDCInDetBSErrContainer(), std::numeric_limits<int>::min() );
+  }
 
   // ask PixelRawDataProviderTool to decode it and to fill the IDC
   if (m_rawDataTool->convert(listOfRobf,  containerInterface, *decodingErrors).isFailure())
diff --git a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.h b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.h
index e47b72587b3f..888a96778f02 100644
--- a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.h
+++ b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProvider.h
@@ -57,6 +57,7 @@ private:
   SG::WriteHandleKey<PixelRDO_Container> m_rdoContainerKey              { this, "RDOKey", "PixelRDOs"};
   SG::UpdateHandleKey<PixelRDO_Cache> m_rdoCacheKey;
   SG::WriteHandleKey<IDCInDetBSErrContainer> m_bsErrorsKey              { this, "BSErrorsKey", "PixBSErr"};  
+  SG::UpdateHandleKey<IDCInDetBSErrContainer_Cache> m_bsErrorsCacheKey;
   SG::ReadCondHandleKey<PixelCablingCondData> m_condCablingKey          { this, "PixelCablingCondData", "PixelCablingCondData", "Pixel cabling key"};
 
 };
diff --git a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProviderTool.cxx b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProviderTool.cxx
index 787b7e81d756..1462f149d266 100644
--- a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProviderTool.cxx
+++ b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProviderTool.cxx
@@ -19,10 +19,6 @@ PixelRawDataProviderTool::PixelRawDataProviderTool(const std::string& type, cons
 {
   declareProperty("checkLVL1ID", m_checkLVL1ID = true);
   declareInterface<IPixelRawDataProviderTool>(this);   
-
-  // NEW
-  declareProperty("BSErrorsCacheKey", m_bsErrorsCacheKey);
-
 }
 
 PixelRawDataProviderTool::~PixelRawDataProviderTool() {}
@@ -36,8 +32,6 @@ StatusCode PixelRawDataProviderTool::initialize() {
   ATH_CHECK(m_LVL1CollectionKey.initialize());
   ATH_CHECK(m_BCIDCollectionKey.initialize());
 
-  ATH_CHECK( m_bsErrorsCacheKey.initialize( SG::AllowEmpty ) );
-
   return StatusCode::SUCCESS;
 }
 
@@ -47,7 +41,7 @@ StatusCode PixelRawDataProviderTool::finalize() {
 }
 
 StatusCode PixelRawDataProviderTool::convert(std::vector<const ROBFragment*>& vecRobs, IPixelRDO_Container* rdoIdc,
-					     IDCInDetBSErrContainer& xdecodingErrors ) const {
+					     IDCInDetBSErrContainer& decodingErrors ) const {
   if (vecRobs.size()==0) { return StatusCode::SUCCESS; }
 
   std::vector<const ROBFragment*>::const_iterator rob_it = vecRobs.begin();
@@ -93,14 +87,6 @@ StatusCode PixelRawDataProviderTool::convert(std::vector<const ROBFragment*>& ve
 
   }
 
-  std::unique_ptr<IDCInDetBSErrContainer> decodingErrors;
-  if ( not m_bsErrorsCacheKey.empty() ) {
-    SG::UpdateHandle<IDCInDetBSErrContainer_Cache> bsErrorsCacheHandle( m_bsErrorsCacheKey, ctx);
-    decodingErrors = std::make_unique<IDCInDetBSErrContainer>( bsErrorsCacheHandle.ptr() );
-  } else {
-    decodingErrors = std::make_unique<IDCInDetBSErrContainer>( SizeOfIDCInDetBSErrContainer(), std::numeric_limits<int>::min() );
-  }
-
   // loop over the ROB fragments
   for (; rob_it!=vecRobs.end(); ++rob_it) {
     uint32_t robid = (*rob_it)->rob_source_id();
@@ -122,9 +108,7 @@ StatusCode PixelRawDataProviderTool::convert(std::vector<const ROBFragment*>& ve
 
     // here the code for the timing monitoring should be reinserted
     // using 1 container per event and subdetector
-    StatusCode sc = m_decoder->fillCollection(&**rob_it, rdoIdc, *decodingErrors);
-
-    xdecodingErrors = *decodingErrors;
+    StatusCode sc = m_decoder->fillCollection(&**rob_it, rdoIdc, decodingErrors);
 
     const int issuesMessageCountLimit = 100;
     if (sc==StatusCode::FAILURE) {
diff --git a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProviderTool.h b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProviderTool.h
index 9d0d8024d6f1..31c98e90fd99 100644
--- a/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProviderTool.h
+++ b/InnerDetector/InDetEventCnv/PixelRawDataByteStreamCnv/src/PixelRawDataProviderTool.h
@@ -12,9 +12,6 @@
 #include "StoreGate/WriteHandleKey.h"
 #include "InDetRawData/InDetTimeCollection.h"
 
-// NEW
-#include "InDetByteStreamErrors/IDCInDetBSErrContainer.h"
-
 #include "GaudiKernel/EventContext.h"
 #include "GaudiKernel/ToolHandle.h"
 
@@ -56,8 +53,6 @@ private:
   SG::WriteHandleKey<InDetTimeCollection> m_LVL1CollectionKey{this, "LVL1CollectionName", "PixelLVL1ID"};
   SG::WriteHandleKey<InDetTimeCollection> m_BCIDCollectionKey{this, "BCIDCollectionName", "PixelBCID"};
 
-  SG::UpdateHandleKey<IDCInDetBSErrContainer_Cache> m_bsErrorsCacheKey;
-
   mutable std::atomic_int m_DecodeErrCount;
   bool m_checkLVL1ID;
 
diff --git a/InnerDetector/InDetTrigRecAlgs/InDetTrigRawDataProvider/src/TrigPixRawDataProvider.cxx b/InnerDetector/InDetTrigRecAlgs/InDetTrigRawDataProvider/src/TrigPixRawDataProvider.cxx
index f7e531d826b5..d2f13d2b79ab 100644
--- a/InnerDetector/InDetTrigRecAlgs/InDetTrigRawDataProvider/src/TrigPixRawDataProvider.cxx
+++ b/InnerDetector/InDetTrigRecAlgs/InDetTrigRawDataProvider/src/TrigPixRawDataProvider.cxx
@@ -112,7 +112,7 @@ namespace InDet {
     }
 
     if( !evtStore()->transientContains<IDCInDetBSErrContainer>(m_decodingErrorsKey) ) {
-      m_decodingErrors = new IDCInDetBSErrContainer(m_id->wafer_hash_max(),  std::numeric_limits<int>::min());
+      m_decodingErrors = new IDCInDetBSErrContainer(m_rawDataTool->SizeOfIDCInDetBSErrContainer(),  std::numeric_limits<int>::min());
       ATH_CHECK(evtStore()->record(m_decodingErrors, m_decodingErrorsKey));
     } else {
       ATH_CHECK(evtStore()->retrieve(m_decodingErrors, m_decodingErrorsKey));
-- 
GitLab