From 0c6ef128468a734b974a01d17edb064130dfa17e Mon Sep 17 00:00:00 2001
From: Vakho Tsulaia <vakhtang.tsulaia@cern.ch>
Date: Wed, 19 Jan 2022 23:16:24 +0100
Subject: [PATCH] LArRawDataContByteStreamTool migrated to retrieving
 CaloDetDescrManager from the Condition Store

This is part of the ongoing migration of all clients of the CaloDetDescrManager
---
 .../LArLATOMEHeaderContByteStreamCnv.h        |  1 -
 .../LArRawDataContByteStreamTool.h            |  7 +++++--
 .../LArByteStream/LArRawScContByteStreamCnv.h |  1 -
 .../python/LArByteStreamConfig.py             |  3 ++-
 .../src/LArRawDataContByteStreamTool.cxx      | 19 ++++++++-----------
 5 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/LArCalorimeter/LArCnv/LArByteStream/LArByteStream/LArLATOMEHeaderContByteStreamCnv.h b/LArCalorimeter/LArCnv/LArByteStream/LArByteStream/LArLATOMEHeaderContByteStreamCnv.h
index 28a4df736005..ea7eeaa5c669 100644
--- a/LArCalorimeter/LArCnv/LArByteStream/LArByteStream/LArLATOMEHeaderContByteStreamCnv.h
+++ b/LArCalorimeter/LArCnv/LArByteStream/LArByteStream/LArLATOMEHeaderContByteStreamCnv.h
@@ -21,7 +21,6 @@ class IByteStreamEventAccess;
 class StoreGateSvc; 
 class MsgStream; 
 class LArDigitContainer; 
-class LArRawDataContByteStreamTool ; 
 class IROBDataProviderSvc; 
 class ByteStreamCnvSvc;
 class LArABBADecoder;
diff --git a/LArCalorimeter/LArCnv/LArByteStream/LArByteStream/LArRawDataContByteStreamTool.h b/LArCalorimeter/LArCnv/LArByteStream/LArByteStream/LArRawDataContByteStreamTool.h
index 14b1dcca3448..68ba8c508936 100644
--- a/LArCalorimeter/LArCnv/LArByteStream/LArByteStream/LArRawDataContByteStreamTool.h
+++ b/LArCalorimeter/LArCnv/LArByteStream/LArByteStream/LArRawDataContByteStreamTool.h
@@ -1,7 +1,7 @@
 //Dear emacs, this is -*- c++ -*-
 
 /*
-  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
 */
 
 /**
@@ -16,7 +16,6 @@
 
 #include <stdint.h>
 #include "AthenaBaseComps/AthAlgTool.h"
-//#include "GaudiKernel/ToolHandle.h"
 #include "LArByteStream/Hid2RESrcID.h"
 #include "LArByteStream/RodRobIdMap.h"
 #include "LArCabling/LArOnOffIdMapping.h"
@@ -28,6 +27,7 @@
 #include "CaloIdentifier/CaloGain.h"
 #include "CaloConditions/CaloNoise.h"
 #include "StoreGate/ReadCondHandleKey.h"
+#include "CaloDetDescr/CaloDetDescrManager.h"
 #include "CxxUtils/CachedUniquePtr.h"
 
 #include "LArRawEvent/LArFebHeaderContainer.h"
@@ -171,6 +171,9 @@ private:
 
   SG::ReadCondHandleKey<LArFebRodMapping> m_febRodMappingKey
   { this, "FebRodMappingKey", "LArFebRodMap", "LArFebRodMap" };
+
+  SG::ReadCondHandleKey<CaloDetDescrManager> m_caloMgrKey
+  { this, "CaloDetDescrManager", "CaloDetDescrManager", "SG Key for CaloDetDescrManager in the Condition Store" };
 };
 
 
diff --git a/LArCalorimeter/LArCnv/LArByteStream/LArByteStream/LArRawScContByteStreamCnv.h b/LArCalorimeter/LArCnv/LArByteStream/LArByteStream/LArRawScContByteStreamCnv.h
index 88759cf71d52..d4a7be11af76 100644
--- a/LArCalorimeter/LArCnv/LArByteStream/LArByteStream/LArRawScContByteStreamCnv.h
+++ b/LArCalorimeter/LArCnv/LArByteStream/LArByteStream/LArRawScContByteStreamCnv.h
@@ -21,7 +21,6 @@ class IByteStreamEventAccess;
 class StoreGateSvc; 
 class MsgStream; 
 class LArDigitContainer; 
-class LArRawDataContByteStreamTool ; 
 class IROBDataProviderSvc; 
 class ByteStreamCnvSvc;
 class LArABBADecoder;
diff --git a/LArCalorimeter/LArCnv/LArByteStream/python/LArByteStreamConfig.py b/LArCalorimeter/LArCnv/LArByteStream/python/LArByteStreamConfig.py
index a011d077c959..e9d33479b895 100644
--- a/LArCalorimeter/LArCnv/LArByteStream/python/LArByteStreamConfig.py
+++ b/LArCalorimeter/LArCnv/LArByteStream/python/LArByteStreamConfig.py
@@ -51,7 +51,8 @@ def LArRawDataContByteStreamToolCfg (flags,
          extraOutputs = [
             ('CaloNoise', 'ConditionStore+totalNoise'),
             ('LArOnOffIdMapping', 'ConditionStore+LArOnOffIdMap'),
-            ('LArFebRodMapping', 'ConditionStore+LArFebRodMap')
+            ('LArFebRodMapping', 'ConditionStore+LArFebRodMap'),
+            ('CaloDetDescrManager', 'ConditionStore+CaloDetDescrManager')
          ]
 
       return acc, extraOutputs
diff --git a/LArCalorimeter/LArCnv/LArByteStream/src/LArRawDataContByteStreamTool.cxx b/LArCalorimeter/LArCnv/LArByteStream/src/LArRawDataContByteStreamTool.cxx
index aaede022fc4f..2fce5ba9897e 100644
--- a/LArCalorimeter/LArCnv/LArByteStream/src/LArRawDataContByteStreamTool.cxx
+++ b/LArCalorimeter/LArCnv/LArByteStream/src/LArRawDataContByteStreamTool.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "LArByteStream/LArRawDataContByteStreamTool.h"
@@ -15,7 +15,6 @@
 #include "LArCabling/LArOnOffIdMapping.h"
 
 #include "LArByteStream/LArRodBlockStructure.h"
-//#include "LArByteStream/LArRodBlockStructure_0.h"
 #include "LArByteStream/LArRodBlockTransparentV0.h"
 #include "LArByteStream/LArRodBlockCalibrationV0.h"
 #include "LArByteStream/LArRodBlockPhysicsV0.h"
@@ -83,6 +82,7 @@ LArRawDataContByteStreamTool::initialize()
   ATH_CHECK( m_caloNoiseKey.initialize (m_initializeForWriting) );
   ATH_CHECK( m_onOffIdMappingKey.initialize (m_initializeForWriting) );
   ATH_CHECK( m_febRodMappingKey.initialize (m_initializeForWriting) );
+  ATH_CHECK( m_caloMgrKey.initialize (m_initializeForWriting) );
 
   return StatusCode::SUCCESS;  
 }
@@ -130,11 +130,10 @@ LArRawDataContByteStreamTool::WriteLArDigits(const LArDigitContainer* digitCont,
    return StatusCode::SUCCESS;
  }
 
- const CaloDetDescrManager* calodd = nullptr;
- ATH_CHECK( detStore()->retrieve (calodd, "CaloMgr") );
  const EventContext& ctx = Gaudi::Hive::currentContext();
  SG::ReadCondHandle<LArOnOffIdMapping> onOffMapping (m_onOffIdMappingKey, ctx);
  SG::ReadCondHandle<LArFebRodMapping> febRodMapping (m_febRodMappingKey, ctx);
+ SG::ReadCondHandle<CaloDetDescrManager> caloMgr (m_caloMgrKey, ctx);
  const Hid2RESrcID& hid2re = getHid2RESrcID (**febRodMapping);
 
  std::map<uint32_t, LArRodEncoder> mapEncoder; 
@@ -142,7 +141,7 @@ LArRawDataContByteStreamTool::WriteLArDigits(const LArDigitContainer* digitCont,
  auto getEncoder = [&] (uint32_t reid) -> LArRodEncoder&
                    { return mapEncoder.try_emplace (reid,
                                                     *m_onlineHelper,
-                                                    *calodd,
+                                                    **caloMgr,
                                                     **onOffMapping,
                                                     blstruct.get()).first->second; };
 
@@ -235,11 +234,10 @@ LArRawDataContByteStreamTool::WriteLArCalibDigits(const LArCalibDigitContainer*
    return StatusCode::FAILURE;
  }
 
- const CaloDetDescrManager* calodd = nullptr;
- ATH_CHECK( detStore()->retrieve (calodd, "CaloMgr") );
  const EventContext& ctx = Gaudi::Hive::currentContext();
  SG::ReadCondHandle<LArOnOffIdMapping> onOffMapping (m_onOffIdMappingKey, ctx);
  SG::ReadCondHandle<LArFebRodMapping> febRodMapping (m_febRodMappingKey, ctx);
+ SG::ReadCondHandle<CaloDetDescrManager> caloMgr (m_caloMgrKey, ctx);
  const Hid2RESrcID& hid2re = getHid2RESrcID (**febRodMapping);
 
  std::map<uint32_t, LArRodEncoder> mapEncoder; 
@@ -247,7 +245,7 @@ LArRawDataContByteStreamTool::WriteLArCalibDigits(const LArCalibDigitContainer*
  auto getEncoder = [&] (uint32_t reid) -> LArRodEncoder&
                    { return mapEncoder.try_emplace (reid,
                                                     *m_onlineHelper,
-                                                    *calodd,
+                                                    **caloMgr,
                                                     **onOffMapping,
                                                     blstruct.get()).first->second; };
 
@@ -314,11 +312,10 @@ LArRawDataContByteStreamTool::WriteLArRawChannels(const LArRawChannelContainer*
    return StatusCode::SUCCESS;
  }
 
- const CaloDetDescrManager* calodd = nullptr;
- ATH_CHECK( detStore()->retrieve (calodd, "CaloMgr") );
  const EventContext& ctx = Gaudi::Hive::currentContext();
  SG::ReadCondHandle<LArOnOffIdMapping> onOffMapping (m_onOffIdMappingKey, ctx);
  SG::ReadCondHandle<LArFebRodMapping> febRodMapping (m_febRodMappingKey, ctx);
+ SG::ReadCondHandle<CaloDetDescrManager> caloMgr (m_caloMgrKey, ctx);
  const Hid2RESrcID& hid2re = getHid2RESrcID (**febRodMapping);
 
  std::map<uint32_t, LArRodEncoder> mapEncoder; 
@@ -326,7 +323,7 @@ LArRawDataContByteStreamTool::WriteLArRawChannels(const LArRawChannelContainer*
  auto getEncoder = [&] (uint32_t reid) -> LArRodEncoder&
                    { return mapEncoder.try_emplace (reid,
                                                     *m_onlineHelper,
-                                                    *calodd,
+                                                    **caloMgr,
                                                     **onOffMapping,
                                                     blstruct.get()).first->second; };
 
-- 
GitLab