From fdad1b9c3e7ec08e80f8036050f30a2c33433901 Mon Sep 17 00:00:00 2001
From: scott snyder <sss@karma>
Date: Wed, 10 Jun 2020 17:05:30 +0200
Subject: [PATCH] CaloCondPhysAlgs: Migrate LArMinBiasAlg to LArMCSym.

Migrate LArMinBiasAlg from the obsolete LArMCSymTool to the
LArMCSym conditions object.

Needed to avoid warings from the thread-safety checker.
---
 Calorimeter/CaloCondPhysAlgs/CMakeLists.txt      |  3 ++-
 .../share/LArMinBiasAlg_jobOptions.py            |  3 +++
 .../CaloCondPhysAlgs/src/LArMinBiasAlg.cxx       | 16 +++++++++-------
 Calorimeter/CaloCondPhysAlgs/src/LArMinBiasAlg.h |  7 ++++---
 4 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/Calorimeter/CaloCondPhysAlgs/CMakeLists.txt b/Calorimeter/CaloCondPhysAlgs/CMakeLists.txt
index 51d446b0f6a..2a7b7ca629b 100644
--- a/Calorimeter/CaloCondPhysAlgs/CMakeLists.txt
+++ b/Calorimeter/CaloCondPhysAlgs/CMakeLists.txt
@@ -21,6 +21,7 @@ atlas_depends_on_subdirs( PUBLIC
                           LArCalorimeter/LArIdentifier
                           LArCalorimeter/LArRecUtils
                           LArCalorimeter/LArTools
+                          LArCalorimeter/LArRawConditions
                           Trigger/TrigAnalysis/TrigDecisionTool
                           PRIVATE
                           Calorimeter/CaloConditions
@@ -46,7 +47,7 @@ atlas_add_component( CaloCondPhysAlgs
                      src/components/*.cxx
                      INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} ${COOL_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS}
                      LINK_LIBRARIES ${ROOT_LIBRARIES} ${CORAL_LIBRARIES} ${COOL_LIBRARIES} ${CLHEP_LIBRARIES} CaloCondBlobObjs CaloDetDescrLib CaloGeoHelpers 
-		     CaloIdentifier AthenaBaseComps AthenaKernel StoreGateLib SGtests GaudiKernel LArCablingLib LArIdentifier TrigDecisionToolLib 
+		     CaloIdentifier AthenaBaseComps AthenaKernel StoreGateLib SGtests GaudiKernel LArCablingLib LArIdentifier TrigDecisionToolLib LArRawConditions
 		     CaloConditions CaloEvent CaloUtilsLib AthenaPoolUtilities Identifier xAODEventInfo LArHV LArReadoutGeometry LArSimEvent CxxUtils)
 
 # Install files from the package:
diff --git a/Calorimeter/CaloCondPhysAlgs/share/LArMinBiasAlg_jobOptions.py b/Calorimeter/CaloCondPhysAlgs/share/LArMinBiasAlg_jobOptions.py
index 9dd71c33fc0..97d31e34f09 100644
--- a/Calorimeter/CaloCondPhysAlgs/share/LArMinBiasAlg_jobOptions.py
+++ b/Calorimeter/CaloCondPhysAlgs/share/LArMinBiasAlg_jobOptions.py
@@ -61,6 +61,9 @@ include( "LArDetDescr/LArDetDescr_joboptions.py" )
 include("TileConditions/TileConditions_jobOptions.py" )
 include("LArConditionsCommon/LArConditionsCommon_MC_jobOptions.py")
 
+from LArRecUtils.LArMCSymCondAlg import LArMCSymCondAlgDefault
+LArMCSymCondAlgDefault()
+
 from CaloCondPhysAlgs.CaloCondPhysAlgsConf import LArMinBiasAlg
 larMinBiasAlg = LArMinBiasAlg()
 larMinBiasAlg.datasetID_lowPt =119995
diff --git a/Calorimeter/CaloCondPhysAlgs/src/LArMinBiasAlg.cxx b/Calorimeter/CaloCondPhysAlgs/src/LArMinBiasAlg.cxx
index 5236823be77..d634db31e2d 100644
--- a/Calorimeter/CaloCondPhysAlgs/src/LArMinBiasAlg.cxx
+++ b/Calorimeter/CaloCondPhysAlgs/src/LArMinBiasAlg.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "LArMinBiasAlg.h"
@@ -20,7 +20,6 @@
   //Constructor
   LArMinBiasAlg:: LArMinBiasAlg(const std::string& name, ISvcLocator* pSvcLocator):
     AthAlgorithm(name,pSvcLocator),
-    m_larmcsym("LArMCSymTool"),
     m_datasetID_lowPt(119995),
     m_datasetID_highPt(119996),
     m_weight_lowPt(39.8606),
@@ -76,7 +75,7 @@
 //  retrieve CaloDetDescrMgr 
     ATH_CHECK( detStore()->retrieve(m_calodetdescrmgr) );
 
-    ATH_CHECK(m_larmcsym.retrieve());
+    ATH_CHECK(m_mcSymKey.initialize());
 
     ATH_CHECK(m_cablingKey.initialize());
 
@@ -112,9 +111,12 @@
     
     ATH_MSG_DEBUG(" LArMinBiasAlg execute()");
 
+    const EventContext& ctx = Gaudi::Hive::currentContext();
+
     if (m_first) {
 
-      SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{m_cablingKey};
+      SG::ReadCondHandle<LArMCSym>  mcsym      (m_mcSymKey, ctx);
+      SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl (m_cablingKey, ctx);
       const LArOnOffIdMapping* cabling{*cablingHdl};
       if(!cabling) {
          ATH_MSG_ERROR( "Do not have cabling mapping from key " << m_cablingKey.key() );
@@ -140,14 +142,14 @@
         IdentifierHash idHash=i;
         Identifier id=m_calo_id->cell_id(idHash);
         if (m_calo_id->is_tile(id)) continue;
-        // convert cell id to symetric identifier
-        HWIdentifier hwid2=m_larmcsym->symOnline(id);
+        // convert cell id to symmetric identifier
+        HWIdentifier hwid2 = mcsym->ZPhiSymOfl(id);
         Identifier id2 = cabling->cnvToIdentifier(hwid2);
         int i2 = (int) (m_calo_id->calo_cell_hash(id2));
         if(i2>=m_ncell) {
            ATH_MSG_WARNING("problem: i2: "<<i2<<" for id: "<<m_calo_id->print_to_string(id)<<" symmetrized: "<<m_calo_id->print_to_string(id2));
         }
-        // we have already processed this hash => just need to associate cell i to the same symetric cell
+        // we have already processed this hash => just need to associate cell i to the same symmetric cell
         if (doneCell[i2]>=0) {
            m_symCellIndex[i]=doneCell[i2];
         }
diff --git a/Calorimeter/CaloCondPhysAlgs/src/LArMinBiasAlg.h b/Calorimeter/CaloCondPhysAlgs/src/LArMinBiasAlg.h
index 0a8e3fc737f..2038ccd85de 100644
--- a/Calorimeter/CaloCondPhysAlgs/src/LArMinBiasAlg.h
+++ b/Calorimeter/CaloCondPhysAlgs/src/LArMinBiasAlg.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 */
 
 // TheLArMinBiasAlg.h
@@ -22,9 +22,9 @@
 #include "CaloIdentifier/CaloCell_ID.h"
 #include "CaloDetDescr/CaloDetDescrManager.h"
 
-#include "LArElecCalib/ILArMCSymTool.h"
 #include "LArElecCalib/ILArMinBias.h"
 #include "LArCabling/LArOnOffIdMapping.h"
+#include "LArRawConditions/LArMCSym.h"
 
 #include "GaudiKernel/ITHistSvc.h"
 #include "TTree.h"
@@ -56,11 +56,12 @@
   //---------------------------------------------------
   // Member variables
   //---------------------------------------------------
-  ToolHandle<ILArMCSymTool>  m_larmcsym;
   int m_datasetID_lowPt;
   int m_datasetID_highPt;
   double m_weight_lowPt;
   double m_weight_highPt;
+  SG::ReadCondHandleKey<LArMCSym> m_mcSymKey
+  { this, "MCSymKey", "LArMCSym", "SG Key of LArMCSym object" };
   SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKey{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"};
 
   const CaloDetDescrManager* m_calodetdescrmgr = nullptr;
-- 
GitLab