From 785c132cd02cd519d55f88d4eee3b0c506430966 Mon Sep 17 00:00:00 2001
From: scott snyder <sss@karma>
Date: Tue, 5 Mar 2019 16:17:15 +0100
Subject: [PATCH] LArCalibTools: Remove MT-unsafe uses of CaloIdManager.

Remove MT-unsafe uses of CaloIdManager.
---
 .../LArCalibTools/LArAverages2Ntuple.h         |  1 -
 .../LArCalibTools/LArReadParamsFromFile.h      |  2 +-
 .../LArCalibTools/LArReadParamsFromFile.icc    |  9 +++++----
 .../src/LArAutoCorrFromStdNtuple.cxx           |  8 ++++----
 .../LArCalibTools/src/LArAverages2Ntuple.cxx   |  6 ++++--
 .../LArCalibTools/src/LArCond2NtupleBase.cxx   | 18 ++++++++----------
 .../LArCalibTools/src/LArOFCBinAlg.cxx         | 14 ++++++--------
 .../LArCalibTools/src/LArRamps2Ntuple.cxx      |  4 +---
 8 files changed, 29 insertions(+), 33 deletions(-)

diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArAverages2Ntuple.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArAverages2Ntuple.h
index 2294599dd0f1..1c79d78a1a47 100644
--- a/LArCalorimeter/LArCalibTools/LArCalibTools/LArAverages2Ntuple.h
+++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArAverages2Ntuple.h
@@ -25,7 +25,6 @@
 #include "GaudiKernel/ToolHandle.h"
 
 #include "CaloIdentifier/LArEM_ID.h"
-#include "CaloIdentifier/CaloIdManager.h"
 #include "LArIdentifier/LArOnlineID.h"
 #include "LArCabling/LArOnOffIdMapping.h"
 #include "LArRecConditions/LArCalibLineMapping.h"
diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArReadParamsFromFile.h b/LArCalorimeter/LArCalibTools/LArCalibTools/LArReadParamsFromFile.h
index 703219f7ee0a..72c356d4c674 100644
--- a/LArCalorimeter/LArCalibTools/LArCalibTools/LArReadParamsFromFile.h
+++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArReadParamsFromFile.h
@@ -17,7 +17,7 @@
 #define LARREADPARAMSFROMFILE_H
 #include "AthenaBaseComps/AthAlgorithm.h"
 //#include "GaudiKernel/SmartDataPtr.h"
-#include "CaloIdentifier/CaloIdManager.h"
+#include "CaloIdentifier/CaloCell_ID.h"
 
 #include <fstream>
 #include <stdio.h>
diff --git a/LArCalorimeter/LArCalibTools/LArCalibTools/LArReadParamsFromFile.icc b/LArCalorimeter/LArCalibTools/LArCalibTools/LArReadParamsFromFile.icc
index b39eb1b77cec..405e7163a4c8 100644
--- a/LArCalorimeter/LArCalibTools/LArCalibTools/LArReadParamsFromFile.icc
+++ b/LArCalorimeter/LArCalibTools/LArCalibTools/LArReadParamsFromFile.icc
@@ -59,10 +59,11 @@ StatusCode LArReadParamsFromFile<DATA>::initialize() {
     return StatusCode::FAILURE ;
   }
 
-  const CaloIdManager *caloIdMgr=CaloIdManager::instance() ;
-  m_emId   = caloIdMgr->getEM_ID();
-  m_hecId  = caloIdMgr->getHEC_ID();
-  m_fcalId = caloIdMgr->getFCAL_ID();
+  const CaloCell_ID* idHelper = nullptr;
+  ATH_CHECK( detStore()->retrieve (idHelper, "CaloCell_ID") );
+  m_emId   = idHelper->em_idHelper();
+  m_hecId  = idHelper->hec_idHelper();
+  m_fcalId = idHelper->fcal_idHelper();
   if (!m_emId) {
     ATH_MSG_ERROR ( "Could not access lar EM ID helper" );
     return StatusCode::FAILURE;
diff --git a/LArCalorimeter/LArCalibTools/src/LArAutoCorrFromStdNtuple.cxx b/LArCalorimeter/LArCalibTools/src/LArAutoCorrFromStdNtuple.cxx
index 75317ad34387..138df466cf6a 100644
--- a/LArCalorimeter/LArCalibTools/src/LArAutoCorrFromStdNtuple.cxx
+++ b/LArCalorimeter/LArCalibTools/src/LArAutoCorrFromStdNtuple.cxx
@@ -6,7 +6,7 @@
 
 #include "LArIdentifier/LArOnlineID.h"
 #include "CaloIdentifier/CaloGain.h"
-#include "CaloIdentifier/CaloIdManager.h"
+#include "CaloIdentifier/CaloCell_ID.h"
 #include "CaloIdentifier/LArFCAL_ID.h"
 #include "LArRawConditions/LArAutoCorrMC.h"
 #include "LArRawConditions/LArAutoCorrComplete.h"
@@ -92,9 +92,9 @@ StatusCode LArAutoCorrFromStdNtuple::stop()
   const LArOnlineID* onlineHelper = nullptr;
   ATH_CHECK( detStore()->retrieve(onlineHelper, "LArOnlineID") );
   // and helper for FCAL
-  const CaloIdManager* caloId_mgr;
-  ATH_CHECK( detStore()->retrieve(caloId_mgr, "CaloIdManager") );
-  const LArFCAL_ID* fcal_id = caloId_mgr->getFCAL_ID();
+  const CaloCell_ID* idHelper = nullptr;
+  ATH_CHECK( detStore()->retrieve (idHelper, "CaloCell_ID") );
+  const LArFCAL_ID* fcal_id = idHelper->fcal_idHelper();
 
   SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{m_cablingKey};
   const LArOnOffIdMapping* cabling{*cablingHdl};
diff --git a/LArCalorimeter/LArCalibTools/src/LArAverages2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArAverages2Ntuple.cxx
index bf2b7ef96aac..e5f01dbe3e5b 100644
--- a/LArCalorimeter/LArCalibTools/src/LArAverages2Ntuple.cxx
+++ b/LArCalorimeter/LArCalibTools/src/LArAverages2Ntuple.cxx
@@ -5,6 +5,7 @@
 #include "LArCalibTools/LArAverages2Ntuple.h"
 
 #include "LArRawEvent/LArAccumulatedCalibDigitContainer.h"
+#include "CaloIdentifier/CaloCell_ID.h"
 
 #include "GaudiKernel/ToolHandle.h"
 
@@ -27,8 +28,9 @@ StatusCode LArAverages2Ntuple::initialize()
 {
   ATH_MSG_INFO ( "in initialize" );
 
-  const CaloIdManager *caloIdMgr=CaloIdManager::instance() ;
-  m_emId=caloIdMgr->getEM_ID();
+  const CaloCell_ID* idHelper = nullptr;
+  ATH_CHECK( detStore()->retrieve (idHelper, "CaloCell_ID") );
+  m_emId = idHelper->em_idHelper();
   if (!m_emId) {
     ATH_MSG_ERROR ( "Could not access lar EM ID helper" );
     return StatusCode::FAILURE;
diff --git a/LArCalorimeter/LArCalibTools/src/LArCond2NtupleBase.cxx b/LArCalorimeter/LArCalibTools/src/LArCond2NtupleBase.cxx
index 5d2a06671567..4e557d574211 100644
--- a/LArCalorimeter/LArCalibTools/src/LArCond2NtupleBase.cxx
+++ b/LArCalorimeter/LArCalibTools/src/LArCond2NtupleBase.cxx
@@ -6,7 +6,6 @@
 
 #include "LArIdentifier/LArOnlineID.h"
 #include "LArIdentifier/LArOnline_SuperCellID.h"
-#include "CaloIdentifier/CaloIdManager.h"
 #include "CaloIdentifier/CaloCell_ID.h"
 
 LArCond2NtupleBase::LArCond2NtupleBase(const std::string& name, ISvcLocator* pSvcLocator): 
@@ -64,18 +63,17 @@ StatusCode LArCond2NtupleBase::initialize() {
 
   m_detStore= &(*detStore()); //for backward compatiblity 
 
-  const CaloIdManager *caloIdMgr=CaloIdManager::instance() ;
+  const CaloCell_ID* idHelper = nullptr;
   if ( m_isSC ){
-  m_emId=caloIdMgr->getEM_SuperCell_ID();
-  m_fcalId=caloIdMgr->getFCAL_SuperCell_ID();
-  m_hecId=caloIdMgr->getHEC_SuperCell_ID();
+    ATH_CHECK( detStore()->retrieve (idHelper, "CaloCell_SuperCell_ID") );
   }
-  else{
-  m_emId=caloIdMgr->getEM_ID();
-  m_fcalId=caloIdMgr->getFCAL_ID();
-  m_hecId=caloIdMgr->getHEC_ID();
-  m_caloId=caloIdMgr->getCaloCell_ID();
+  else {
+    ATH_CHECK( detStore()->retrieve (idHelper, "CaloCell_ID") );
+    ATH_CHECK( detStore()->retrieve (m_caloId, "CaloCell_ID") );
   }
+  m_emId=idHelper->em_idHelper();
+  m_fcalId=idHelper->fcal_idHelper();
+  m_hecId=idHelper->hec_idHelper();
 
   if (!m_emId) {
     msg(MSG::ERROR) << "Could not access lar EM ID helper" << endmsg;
diff --git a/LArCalorimeter/LArCalibTools/src/LArOFCBinAlg.cxx b/LArCalorimeter/LArCalibTools/src/LArOFCBinAlg.cxx
index e8d20445968e..5c70fd7fe62a 100644
--- a/LArCalorimeter/LArCalibTools/src/LArOFCBinAlg.cxx
+++ b/LArCalorimeter/LArCalibTools/src/LArOFCBinAlg.cxx
@@ -4,7 +4,7 @@
 
 #include "LArCalibTools/LArOFCBinAlg.h"
 #include "LArRawConditions/LArOFCBinComplete.h"
-#include "CaloIdentifier/CaloIdManager.h"
+#include "CaloIdentifier/CaloCell_ID.h"
 
 //#include <ifstream>
 #include <fstream>
@@ -104,13 +104,11 @@ StatusCode LArOFCBinAlg::execute() {
      ATH_MSG_ERROR( "Do not have cabling mapping from key " << m_cablingKey.key() );
      return StatusCode::FAILURE;
   }
-  const LArEM_Base_ID* emId;
-  const LArHEC_Base_ID* hecId;
-  const LArFCAL_Base_ID* fcalId;
-  const CaloIdManager *caloIdMgr=CaloIdManager::instance();
-  emId=caloIdMgr->getEM_ID();
-  fcalId=caloIdMgr->getFCAL_ID();
-  hecId=caloIdMgr->getHEC_ID();
+  const CaloCell_ID* idHelper = nullptr;
+  ATH_CHECK( detStore()->retrieve (idHelper, "CaloCell_ID") );
+  const LArEM_Base_ID* emId = idHelper->em_idHelper();
+  const LArHEC_Base_ID* hecId = idHelper->hec_idHelper();
+  const LArFCAL_Base_ID* fcalId = idHelper->fcal_idHelper();
 
   for (int gain=0;gain<3;++gain) {
     msg(MSG::INFO) << "Working on gain " << gain << endmsg;
diff --git a/LArCalorimeter/LArCalibTools/src/LArRamps2Ntuple.cxx b/LArCalorimeter/LArCalibTools/src/LArRamps2Ntuple.cxx
index 896767289073..22e4567a181e 100755
--- a/LArCalorimeter/LArCalibTools/src/LArRamps2Ntuple.cxx
+++ b/LArCalorimeter/LArCalibTools/src/LArRamps2Ntuple.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "LArCalibTools/LArRamps2Ntuple.h"
@@ -7,8 +7,6 @@
 #include "LArRawConditions/LArRampComplete.h"
 #include "LArRawConditions/LArRampSym.h"
 
-//#include "CaloIdentifier/CaloIdManager.h"
-
 #include <math.h>
 
 LArRamps2Ntuple::LArRamps2Ntuple(const std::string& name, ISvcLocator* pSvcLocator): 
-- 
GitLab