From d6189b38766d0bc90e415a7b46b9b037c4b4c843 Mon Sep 17 00:00:00 2001
From: Walter Lampl <walter.lampl@cern.ch>
Date: Mon, 12 Nov 2018 14:17:03 +0000
Subject: [PATCH] LArConditionsContainer: Remove dependency on
 LArCablingService

---
 .../src/LArAutoCorrFromStdNtuple.cxx          |  1 +
 .../LArCalibUtils/LArWFParamTool.h            |  2 +
 .../src/LArPhysWavePredictor.cxx              |  2 +
 .../src/LArTimePhysPrediction.cxx             |  1 +
 .../LArRawConditions/LArConditionsContainer.h | 14 ---
 .../LArConditionsContainer.icc                | 94 -------------------
 .../LArConditionsContainerBase.h              |  5 -
 .../LArRawConditions/LArTshaperComplete.h     |  2 -
 .../src/LArConditionsContainerBase.cxx        | 22 +----
 .../src/LArTshaperComplete.cxx                |  5 -
 10 files changed, 7 insertions(+), 141 deletions(-)

diff --git a/LArCalorimeter/LArCalibTools/src/LArAutoCorrFromStdNtuple.cxx b/LArCalorimeter/LArCalibTools/src/LArAutoCorrFromStdNtuple.cxx
index 4241500eb2f..2cbb4646e22 100755
--- a/LArCalorimeter/LArCalibTools/src/LArAutoCorrFromStdNtuple.cxx
+++ b/LArCalorimeter/LArCalibTools/src/LArAutoCorrFromStdNtuple.cxx
@@ -10,6 +10,7 @@
 #include "CaloIdentifier/LArFCAL_ID.h"
 #include "LArRawConditions/LArAutoCorrMC.h"
 #include "LArRawConditions/LArAutoCorrComplete.h"
+#include "LArCabling/LArCablingService.h"
 
 #include "LArTools/LArMCSymTool.h"
 #include "LArElecCalib/ILArMCSymTool.h"
diff --git a/LArCalorimeter/LArCalibUtils/LArCalibUtils/LArWFParamTool.h b/LArCalorimeter/LArCalibUtils/LArCalibUtils/LArWFParamTool.h
index 9497829f22a..76c47b44ee6 100755
--- a/LArCalorimeter/LArCalibUtils/LArCalibUtils/LArWFParamTool.h
+++ b/LArCalorimeter/LArCalibUtils/LArCalibUtils/LArWFParamTool.h
@@ -19,6 +19,8 @@
 #include "LArRawConditions/LArCaliWave.h"
 #include "LArRawConditions/LArWaveHelper.h" 
 
+#include "LArCabling/LArCablingService.h"
+
 static const InterfaceID IID_LArWFParamTool("LArWFParamTool", 1 , 0); 
 
 class LArCablingSvc;
diff --git a/LArCalorimeter/LArCalibUtils/src/LArPhysWavePredictor.cxx b/LArCalorimeter/LArCalibUtils/src/LArPhysWavePredictor.cxx
index 8306a7a18a8..dc038fc5b44 100755
--- a/LArCalorimeter/LArCalibUtils/src/LArPhysWavePredictor.cxx
+++ b/LArCalorimeter/LArCalibUtils/src/LArPhysWavePredictor.cxx
@@ -35,6 +35,8 @@
 
 #include "LArCalibUtils/LArPhysWaveTool.h"
 
+#include "LArCabling/LArCablingService.h"
+
 #include <stdio.h>
 #include <iostream>
 #include <fstream>
diff --git a/LArCalorimeter/LArCalibUtils/src/LArTimePhysPrediction.cxx b/LArCalorimeter/LArCalibUtils/src/LArTimePhysPrediction.cxx
index 6d1f33eac3e..7cae0b7d5d4 100755
--- a/LArCalorimeter/LArCalibUtils/src/LArTimePhysPrediction.cxx
+++ b/LArCalorimeter/LArCalibUtils/src/LArTimePhysPrediction.cxx
@@ -23,6 +23,7 @@
 #include "GaudiKernel/NTuple.h"
 #include "GaudiKernel/IToolSvc.h"
 #include <TMath.h>
+#include "LArCabling/LArCablingService.h"
 
 typedef LArCaliWaveContainer::ConstConditionsMapIterator CaliCellIt;
 typedef LArCaliWaveContainer::LArCaliWaves::const_iterator CaliWaveIt;
diff --git a/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainer.h b/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainer.h
index 47d699d9d4a..99227b6e668 100755
--- a/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainer.h
+++ b/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainer.h
@@ -55,7 +55,6 @@
 #include "AthenaPoolUtilities/CondMultChanCollection.h"
 #include "LArRawConditions/LArConditionsContainerDB.h"
 #include "Identifier/HWIdentifier.h"
-#include "Identifier/Identifier.h"
 #include "Identifier/IdentifierHash.h"
 
 
@@ -122,14 +121,6 @@ public:
     Reference           get     (const HWIdentifier id, 
 				 unsigned int gain=0); 
 
-    /// get data with offline hash identifier
-    ConstReference      get     (const IdentifierHash hashId, 
-				 unsigned int gain=0) const; 
-
-    /// get data with offline identifier
-    ConstReference       get_offline     (const Identifier hashId, 
-					  unsigned int gain=0) const; 
-
     /// Return the COOL channel number for a given online id and gain
     unsigned int        coolChannel (const HWIdentifier id,
 				     unsigned int gain=0) const; 
@@ -304,9 +295,6 @@ private:
     void                  sortSubsets();
 
 
-    /// initialize the vector for access via hashes
-    void                  initHashVec() const; 
-
     class SubsetSort 
     {
     public:
@@ -332,9 +320,7 @@ private:
     typedef typename SubsetDV::iterator                     iterator;
     
 
-    mutable TVectorMap           m_hashVec  ;
     mutable CorrectionVectors    m_correctionsUndo;
-    mutable bool                 m_hashVecValid ;
     mutable bool                 m_correctionsApplied;
     CorrectionVector             m_emptyCorrectionVec;
 #endif 
diff --git a/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainer.icc b/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainer.icc
index 387f32b4c3a..c5cf699054c 100755
--- a/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainer.icc
+++ b/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainer.icc
@@ -19,7 +19,6 @@
 // Services/helpers
 #include "LArIdentifier/LArOnlineID.h"
 #include "CaloIdentifier/CaloCell_ID.h"
-#include "LArCabling/LArCablingService.h" 
 
 #include <algorithm>
 #include <deque>
@@ -37,7 +36,6 @@ inline
 LArConditionsContainer<T>::LArConditionsContainer()
 	:
 	LArConditionsContainerBase(),
-	m_hashVecValid(false),
 	m_correctionsApplied(false)
 
 
@@ -48,7 +46,6 @@ inline
 LArConditionsContainer<T>::LArConditionsContainer(GroupingType type)
 	:
 	LArConditionsContainerBase(type),
-	m_hashVecValid(false),
 	m_correctionsApplied(false)
 
 {} 
@@ -189,8 +186,6 @@ LArConditionsContainer<T>::updateConditionsMap(FebId febId, unsigned int gain,
         FebPairReference pair = *subsetIt;
         conditionsMap.add(febId, &pair.second);
 
-	// This invalids the hash vector
-	m_hashVecValid=false;
     }
     else {
 	std::cout << " LArConditionsContainer::updateConditionsMap:  unable to get channel: febid/gain "
@@ -299,17 +294,6 @@ LArConditionsContainer<T>::get(const HWIdentifier id,
 
 }
 
-template<class T> 
-inline 
-typename LArConditionsContainer<T>::ConstReference
-LArConditionsContainer<T>::get_offline(const Identifier id, 
-				       unsigned int gain) const
-{
-  const IdentifierHash hId=this->offlineHelper()->calo_cell_hash(id);
-  return this->get(hId,gain);//Creates a hash-indexed vector of pointers to the payload object
-}
-
-
 
 template<class T> 
 inline 
@@ -344,25 +328,6 @@ LArConditionsContainer<T>::get(const HWIdentifier id,
     return (gainMapIt->second.getNonConst(febId,channel));
 }
 
-template<class T> 
-inline 
-typename LArConditionsContainer<T>::ConstReference
-LArConditionsContainer<T>::get(const IdentifierHash hashId,
-			       unsigned int gain) const
-{
-  if (!m_hashVecValid) initHashVec();
-  TVectorMapIterator it =  m_hashVec.find(gain);
-  if(it!=m_hashVec.end()) {
-    ConstPointer elm_ptr =  (*it).second[hashId];
-    if (elm_ptr) { //Check if NULL pointer 
-      return *elm_ptr;
-    }
-    else {
-	return (empty());
-    }
-  } 	
-  return (empty());
-} 
 
 template<class T> 
 inline
@@ -559,65 +524,6 @@ LArConditionsContainer<T>::totalNumberOfCorrections() const
 }
 
 
-template<class T> 
-inline
-void LArConditionsContainer<T>::initHashVec() const 
-{
-    const unsigned hashMax=m_offlineHelper->calo_cell_hash_max();
-    ConstGainMapIterator it_gain = m_cached.begin() ; 
-    ConstGainMapIterator it_gain_e = m_cached.end() ; 
-
-    try { 
-	// loop lover gains 
-	for(; it_gain!=it_gain_e;++it_gain) { 
-	    unsigned int gain = (*it_gain).first; 
-	    const ConditionsMap& db = (*it_gain).second; 
-
-	    TVector& hashVec= m_hashVec[gain];
-	    hashVec.clear();
-	    hashVec.resize(hashMax,0);
-
-	    //std::vector<T*>::const_iterator it=m_hashVec.begin();
-	    //std::vector<T*>::const_iterator it_e=m_hashVec.end();
-
-//    typedef  ConditionsMap::const_iterator P_IT; 
-	    ConstConditionsMapIterator it_chan   = db.begin(m_onlineHelper); 
-	    ConstConditionsMapIterator it_chan_e = db.end(m_onlineHelper); 
-
-	    // loop over available channels for this gain 
-	    for(; it_chan!=it_chan_e;++it_chan) {
-		HWIdentifier hid = m_onlineHelper->channel_Id(
-		    HWIdentifier(it_chan.getFebId()), it_chan.getChannel());
-		if (m_larCablingSvc->isOnlineConnected(hid)) {
-		  Identifier id = m_larCablingSvc->cnvToIdentifier(hid); 
-		  IdentifierHash hash = m_offlineHelper->calo_cell_hash(id);
-		  //if (hash>hashVec.size()) std::cout << "Hash too big" << std::endl;
-                  ConstReference ref = *it_chan;
-		  hashVec[(unsigned int)hash]=&ref;
-		}
-	    }
-	}
-	m_hashVecValid=true;
-    }
-    catch (LArID_Exception & except) {
-	std::cout<<" LArConditionsContainer: ERROR Failed to get hash id"<<std::endl;
-	m_hashVecValid=false;
-    }
-    return;
-}
-
-// template<class T> 
-// void LArConditionsContainer<T>::copy ( const GainMap* p) 
-// {
-//   GainMapIterator it   = p->begin(); 
-//   GainMapIterator it_e = p->end(); 
-  
-//   for(; it!=it_e;++it){
-//     m_cached[(*it).first] = (*it).second; 
-//   } 
-
-//   return ; 
-// }
 
     /// Have corrections been applied?
 template<class T> 
diff --git a/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainerBase.h b/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainerBase.h
index 0af0058c84a..790e56ae5ba 100755
--- a/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainerBase.h
+++ b/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainerBase.h
@@ -34,7 +34,6 @@
 // Forward delcarations
 class LArOnlineID;
 class CaloCell_ID;
-class LArCablingService;
 class MsgStream;
 
 class LArConditionsContainerBase
@@ -79,9 +78,6 @@ public:
     /// provide access to offline id helper
     const CaloCell_ID*          offlineHelper() const;
 
-    /// provide access to cabling service id helper
-    LArCablingService*          larCablingSvc() const;
-
     /// Access to a FEB ID vector for a given gain and  COOL channel
     const FEBIdVector&          febIdVector(unsigned int gain, 
 					    unsigned int coolChannel) const;
@@ -111,7 +107,6 @@ protected:
     LArCondFEBIdChanMap         m_febIdChanMap;
     const LArOnlineID*          m_onlineHelper;
     const CaloCell_ID*          m_offlineHelper;
-    LArCablingService*          m_larCablingSvc;
 
     // Table to map from Cool channel number to index in
     // CondMultChanCollection - when writing this can be all mixed up 
diff --git a/LArCalorimeter/LArRawConditions/LArRawConditions/LArTshaperComplete.h b/LArCalorimeter/LArRawConditions/LArRawConditions/LArTshaperComplete.h
index 34fd84f19f6..70cabe5e764 100755
--- a/LArCalorimeter/LArRawConditions/LArRawConditions/LArTshaperComplete.h
+++ b/LArCalorimeter/LArRawConditions/LArRawConditions/LArTshaperComplete.h
@@ -38,8 +38,6 @@ class LArTshaperComplete: public ILArTshaper,
   
   virtual const float& Tshaper(const HWIdentifier&  CellID) const ;
   
-  virtual const float& Tshaper(const Identifier&  CellID) const;
-  
   // set method filling the data members individually (if one
   // wants to fill this class not using the DB)
   void set(const HWIdentifier& CellID, float vTshaper);
diff --git a/LArCalorimeter/LArRawConditions/src/LArConditionsContainerBase.cxx b/LArCalorimeter/LArRawConditions/src/LArConditionsContainerBase.cxx
index 58e46c3c5f3..671cbef5b4e 100755
--- a/LArCalorimeter/LArRawConditions/src/LArConditionsContainerBase.cxx
+++ b/LArCalorimeter/LArRawConditions/src/LArConditionsContainerBase.cxx
@@ -18,7 +18,6 @@
 // Services/helpers
 #include "LArIdentifier/LArOnlineID.h"
 #include "CaloIdentifier/CaloCell_ID.h"
-#include "LArCabling/LArCablingService.h" 
 
 // Gaudi/Athena
 #include "GaudiKernel/Bootstrap.h"
@@ -33,7 +32,6 @@ LArConditionsContainerBase::LArConditionsContainerBase( )
 	m_groupType(SubDetectorGrouping),
 	m_onlineHelper(0),
 	m_offlineHelper(0),
-	m_larCablingSvc(0),
 	m_isInitialized(false)
 {}
 
@@ -42,7 +40,6 @@ LArConditionsContainerBase::LArConditionsContainerBase(GroupingType type)
 	m_groupType(type),
 	m_onlineHelper(0),
 	m_offlineHelper(0),
-	m_larCablingSvc(0),
 	m_isInitialized(false)
 {}
 
@@ -81,19 +78,8 @@ LArConditionsContainerBase::initializeBase()
 	log << MSG::ERROR << "Cannot get CaloCell_ID!" << endmsg;
 	return sc;
     }
-    IToolSvc* toolSvc;
-    sc = svcLoc->service( "ToolSvc",toolSvc  );
-    if (sc.isFailure()) {
-      log << MSG::ERROR << "Cannot get ToolSvc!" << endmsg;
-      return sc;
-    }
-    sc = toolSvc->retrieveTool("LArCablingService",m_larCablingSvc);
-     if (sc.isFailure()) {
-      log << MSG::ERROR << "Cannot get LArCablingSvc!" << endmsg;
-      return sc;
-    }
 
-    // initialize the groupint
+    // initialize the grouping
     sc = initGrouping();
     if (sc.isFailure()) {
 	log << MSG::ERROR << "Cannot initialize the Grouping" << endmsg;
@@ -506,12 +492,6 @@ LArConditionsContainerBase::offlineHelper() const
 }
 
 
-LArCablingService*          
-LArConditionsContainerBase::larCablingSvc() const
-{
-    return (m_larCablingSvc);
-}
-
 const LArConditionsContainerBase::FEBIdVector&
 LArConditionsContainerBase::febIdVector(unsigned int gain, 
 					unsigned int coolChannel) const
diff --git a/LArCalorimeter/LArRawConditions/src/LArTshaperComplete.cxx b/LArCalorimeter/LArRawConditions/src/LArTshaperComplete.cxx
index 173d8236ea5..ef506617ff1 100755
--- a/LArCalorimeter/LArRawConditions/src/LArTshaperComplete.cxx
+++ b/LArCalorimeter/LArRawConditions/src/LArTshaperComplete.cxx
@@ -28,9 +28,4 @@ const float& LArTshaperComplete::Tshaper(const HWIdentifier& CellID) const
   return (t.m_Tshaper);
 }
 
-const float& LArTshaperComplete::Tshaper(const Identifier&  CellID) const
-{
 
-  const LArTshaperP& t = this->get_offline(CellID); 
-  return (t.m_Tshaper);
-}
-- 
GitLab