From 4844d57f44cad8c6c36338ed6169848bb94dfcff Mon Sep 17 00:00:00 2001
From: Walter Lampl <walter.lampl@cern.ch>
Date: Thu, 25 Mar 2021 16:47:34 +0000
Subject: [PATCH] LArConditionsContainer: Add dedicated grouping type for
 SuperCells. Use LArOnline_SuperCellID helper in this case

---
 .../LArCalibValidationAlg.h                   |  1 +
 .../src/LArAutoCorrValidationAlg.cxx          |  2 +
 .../LArCalibUtils/src/LArCaliWaveAverage.cxx  |  1 +
 .../LArCalibUtils/src/LArRampBuilder.cxx      |  2 +-
 .../src/LArTCMPhysWavePredictor.cxx           |  1 +
 .../LArConditionsContainer.icc                |  1 -
 .../LArConditionsContainerBase.h              | 15 +++---
 .../LArConditionsContainerDB.h                | 36 ++++++-------
 .../src/LArConditionsContainerBase.cxx        | 51 ++++++++++++++++---
 9 files changed, 75 insertions(+), 35 deletions(-)

diff --git a/LArCalorimeter/LArCalibDataQuality/LArCalibDataQuality/LArCalibValidationAlg.h b/LArCalorimeter/LArCalibDataQuality/LArCalibDataQuality/LArCalibValidationAlg.h
index 07bd53a8a969..16b0edd7bc73 100644
--- a/LArCalorimeter/LArCalibDataQuality/LArCalibDataQuality/LArCalibValidationAlg.h
+++ b/LArCalorimeter/LArCalibDataQuality/LArCalibDataQuality/LArCalibValidationAlg.h
@@ -31,6 +31,7 @@
 #include "LArRecConditions/LArCalibLineMapping.h"
 
 #include "CaloIdentifier/CaloGain.h"
+#include "CaloIdentifier/CaloCell_ID.h"
 
 
 /** 
diff --git a/LArCalorimeter/LArCalibDataQuality/src/LArAutoCorrValidationAlg.cxx b/LArCalorimeter/LArCalibDataQuality/src/LArAutoCorrValidationAlg.cxx
index 14480e7b5a80..58d486f10732 100644
--- a/LArCalorimeter/LArCalibDataQuality/src/LArAutoCorrValidationAlg.cxx
+++ b/LArCalorimeter/LArCalibDataQuality/src/LArAutoCorrValidationAlg.cxx
@@ -4,6 +4,8 @@
 
 #include "LArCalibDataQuality/LArAutoCorrValidationAlg.h"
 #include <cmath>
+#include "CaloIdentifier/CaloCell_ID.h"
+
 LArAutoCorrValidationAlg::LArAutoCorrValidationAlg(const std::string& name, ISvcLocator* pSvcLocator) :
   LArAutoCorrValidationBase(name,pSvcLocator) {
 
diff --git a/LArCalorimeter/LArCalibUtils/src/LArCaliWaveAverage.cxx b/LArCalorimeter/LArCalibUtils/src/LArCaliWaveAverage.cxx
index 2704b113ce7f..6af8ffa1f12b 100644
--- a/LArCalorimeter/LArCalibUtils/src/LArCaliWaveAverage.cxx
+++ b/LArCalorimeter/LArCalibUtils/src/LArCaliWaveAverage.cxx
@@ -10,6 +10,7 @@
 
 #include "LArRawConditions/LArCaliWaveContainer.h"
 #include "CaloIdentifier/CaloGain.h"
+#include "CaloIdentifier/CaloCell_ID.h"
 
 #include <vector>
 #include <map>
diff --git a/LArCalorimeter/LArCalibUtils/src/LArRampBuilder.cxx b/LArCalorimeter/LArCalibUtils/src/LArRampBuilder.cxx
index 2b48120d55ca..234e3c2671c2 100644
--- a/LArCalorimeter/LArCalibUtils/src/LArRampBuilder.cxx
+++ b/LArCalorimeter/LArCalibUtils/src/LArRampBuilder.cxx
@@ -10,7 +10,7 @@
 
 #include "LArIdentifier/LArOnlineID.h"
 #include "LArIdentifier/LArOnline_SuperCellID.h"
-
+#include "CaloIdentifier/CaloCell_ID.h"
 
 #include <Eigen/Dense>
 
diff --git a/LArCalorimeter/LArCalibUtils/src/LArTCMPhysWavePredictor.cxx b/LArCalorimeter/LArCalibUtils/src/LArTCMPhysWavePredictor.cxx
index d77219aefb9e..4e592eefa303 100644
--- a/LArCalorimeter/LArCalibUtils/src/LArTCMPhysWavePredictor.cxx
+++ b/LArCalorimeter/LArCalibUtils/src/LArTCMPhysWavePredictor.cxx
@@ -9,6 +9,7 @@
 
 #include "LArRawConditions/LArCaliWaveContainer.h"
 #include "LArRawConditions/LArPhysWaveContainer.h"
+#include "CaloIdentifier/CaloCell_ID.h"
 
 #include <iostream>
 #include <fstream>
diff --git a/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainer.icc b/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainer.icc
index f8a9980197b4..759e4c6f9352 100755
--- a/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainer.icc
+++ b/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainer.icc
@@ -18,7 +18,6 @@
  */
 // Services/helpers
 #include "LArIdentifier/LArOnlineID.h"
-#include "CaloIdentifier/CaloCell_ID.h"
 
 #include <algorithm>
 #include <deque>
diff --git a/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainerBase.h b/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainerBase.h
index 790e56ae5baa..96a0912728ed 100755
--- a/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainerBase.h
+++ b/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainerBase.h
@@ -32,8 +32,8 @@
 #include <string>
 
 // Forward delcarations
-class LArOnlineID;
-class CaloCell_ID;
+class LArOnlineID_Base;
+class CaloCell_Base_ID;
 class MsgStream;
 
 class LArConditionsContainerBase
@@ -47,7 +47,8 @@ public:
 	SubDetectorGrouping,
 	FeedThroughGrouping,
 	ExtendedFTGrouping,
-	ExtendedSubDetGrouping
+	ExtendedSubDetGrouping,
+	SuperCells
     };
 
     typedef LArCondFEBIdChanMap::FEBIdVector  FEBIdVector;
@@ -73,10 +74,10 @@ public:
     StatusCode                  setGroupingType(const std::string& groupingStr, MsgStream& logStr);
 
     /// provide access to online id helper
-    const LArOnlineID*          onlineHelper() const;
+    const LArOnlineID_Base*     onlineHelper() const;
 
     /// provide access to offline id helper
-    const CaloCell_ID*          offlineHelper() const;
+    const CaloCell_Base_ID*     offlineHelper() const;
 
     /// Access to a FEB ID vector for a given gain and  COOL channel
     const FEBIdVector&          febIdVector(unsigned int gain, 
@@ -105,8 +106,8 @@ protected:
 
     GroupingType                m_groupType;
     LArCondFEBIdChanMap         m_febIdChanMap;
-    const LArOnlineID*          m_onlineHelper;
-    const CaloCell_ID*          m_offlineHelper;
+    const LArOnlineID_Base*     m_onlineHelper;
+    const CaloCell_Base_ID*     m_offlineHelper;
 
     // 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/LArConditionsContainerDB.h b/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainerDB.h
index bc67f430eb68..6ddabb427dc6 100755
--- a/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainerDB.h
+++ b/LArCalorimeter/LArRawConditions/LArRawConditions/LArConditionsContainerDB.h
@@ -38,7 +38,7 @@
 **/
 
 #include "LArRawConditions/LArConditionsSubset.h"
-#include "LArIdentifier/LArOnlineID.h"
+#include "LArIdentifier/LArOnlineID_Base.h"
 #include <map>
 #include <unordered_map>
 #include <vector>
@@ -76,11 +76,11 @@ public:
 	iteratorT(MAP_ITERATOR febit, 
                   CHAN_ITERATOR chanit, 
                   MAP_ITERATOR febendit,
-                  const LArOnlineID* onlineHelper);
+                  const LArOnlineID_Base* onlineHelper);
 	iteratorT(MAP_ITERATOR febit, 
                   CHAN_ITERATOR chanit, 
                   MAP_ITERATOR febendit,
-                  const LArOnlineID* onlineHelper,
+                  const LArOnlineID_Base* onlineHelper,
                   const FebIdVec& febIds);
 	REFERENCE operator*() const;
         POINTER   operator->() const;
@@ -99,7 +99,7 @@ public:
 	// m_lastFebit is initialized with m_febMap.end()...
 	//...and decremented to point to the last filled FEB.
 	MAP_ITERATOR m_lastFebIt;
-	const LArOnlineID*         m_onlineHelper;
+	const LArOnlineID_Base*         m_onlineHelper;
 	FebIdVec                   m_febIds;
 	unsigned int               m_febIdsIndex;
 
@@ -133,17 +133,17 @@ public:
     bool                         exist(FebId id) const;
 
     /// Iterator over all channels 
-    const_iterator               begin(const LArOnlineID* onlineHelper) const;
-    const_iterator               end  (const LArOnlineID* onlineHelper) const;
+    const_iterator               begin(const LArOnlineID_Base* onlineHelper) const;
+    const_iterator               end  (const LArOnlineID_Base* onlineHelper) const;
 
-    iterator                     begin(const LArOnlineID* onlineHelper);
-    iterator                     end  (const LArOnlineID* onlineHelper);
+    iterator                     begin(const LArOnlineID_Base* onlineHelper);
+    iterator                     end  (const LArOnlineID_Base* onlineHelper);
 
     /// Iterator over all channels of selected FEBs
-    const_iterator               begin(const LArOnlineID* onlineHelper,
+    const_iterator               begin(const LArOnlineID_Base* onlineHelper,
 				       const FebIdVec& febIds) const;
 
-    iterator                     begin(const LArOnlineID* onlineHelper,
+    iterator                     begin(const LArOnlineID_Base* onlineHelper,
 				       const FebIdVec& febIds);
 
     /// Size of map
@@ -193,7 +193,7 @@ LArConditionsContainerDB<T>::LArConditionsContainerDB(unsigned int gain)
 template<class T> 
 inline
 typename LArConditionsContainerDB<T>::const_iterator 
-LArConditionsContainerDB<T>::begin(const LArOnlineID* onlineHelper) const 
+LArConditionsContainerDB<T>::begin(const LArOnlineID_Base* onlineHelper) const 
 {
     if (m_febMap.size()==0) { //no elements yet, begin() and end() have to be identical
 	return m_dummyConstIt;
@@ -208,7 +208,7 @@ LArConditionsContainerDB<T>::begin(const LArOnlineID* onlineHelper) const
 template<class T> 
 inline
 typename LArConditionsContainerDB<T>::iterator 
-LArConditionsContainerDB<T>::begin(const LArOnlineID* onlineHelper)
+LArConditionsContainerDB<T>::begin(const LArOnlineID_Base* onlineHelper)
 {
     if (m_febMap.size()==0) { //no elements yet, begin() and end() have to be identical
 	return m_dummyIt;
@@ -223,7 +223,7 @@ LArConditionsContainerDB<T>::begin(const LArOnlineID* onlineHelper)
 template<class T> 
 inline
 typename LArConditionsContainerDB<T>::const_iterator 
-LArConditionsContainerDB<T>::begin(const LArOnlineID* onlineHelper,
+LArConditionsContainerDB<T>::begin(const LArOnlineID_Base* onlineHelper,
 				   const FebIdVec& febIds) const 
 {
     if (m_febMap.size()==0) { //no elements yet, begin() and end() have to be identical
@@ -251,7 +251,7 @@ LArConditionsContainerDB<T>::begin(const LArOnlineID* onlineHelper,
 template<class T> 
 inline
 typename LArConditionsContainerDB<T>::iterator 
-LArConditionsContainerDB<T>::begin(const LArOnlineID* onlineHelper,
+LArConditionsContainerDB<T>::begin(const LArOnlineID_Base* onlineHelper,
 				   const FebIdVec& febIds)
 {
     if (m_febMap.size()==0) { //no elements yet, begin() and end() have to be identical
@@ -280,7 +280,7 @@ LArConditionsContainerDB<T>::begin(const LArOnlineID* onlineHelper,
 template<class T> 
 inline
 typename LArConditionsContainerDB<T>::const_iterator
-LArConditionsContainerDB<T>::end(const LArOnlineID* onlineHelper) const
+LArConditionsContainerDB<T>::end(const LArOnlineID_Base* onlineHelper) const
 {
     if (m_febMap.size()==0) {
 	return m_dummyConstIt;
@@ -300,7 +300,7 @@ LArConditionsContainerDB<T>::end(const LArOnlineID* onlineHelper) const
 template<class T> 
 inline
 typename LArConditionsContainerDB<T>::iterator
-LArConditionsContainerDB<T>::end(const LArOnlineID* onlineHelper)
+LArConditionsContainerDB<T>::end(const LArOnlineID_Base* onlineHelper)
 {
     if (m_febMap.size()==0) {
 	return m_dummyIt;
@@ -337,7 +337,7 @@ LArConditionsContainerDB<T>::ITERATORT::iteratorT
   (MAP_ITERATOR febit, 
    CHAN_ITERATOR chanit, 
    MAP_ITERATOR febendit,
-   const LArOnlineID* onlineHelper) : 
+   const LArOnlineID_Base* onlineHelper) : 
 	m_channelIt(chanit),
 	m_febIt(febit),
 	m_lastFebIt(febendit),
@@ -352,7 +352,7 @@ LArConditionsContainerDB<T>::ITERATORT::iteratorT
   (MAP_ITERATOR febit, 
    CHAN_ITERATOR chanit, 
    MAP_ITERATOR febendit,
-   const LArOnlineID* onlineHelper,
+   const LArOnlineID_Base* onlineHelper,
    const FebIdVec& febIds)
 	:
 	m_channelIt(chanit),
diff --git a/LArCalorimeter/LArRawConditions/src/LArConditionsContainerBase.cxx b/LArCalorimeter/LArRawConditions/src/LArConditionsContainerBase.cxx
index 32c7e0c68df4..0a5a56bd4ad0 100755
--- a/LArCalorimeter/LArRawConditions/src/LArConditionsContainerBase.cxx
+++ b/LArCalorimeter/LArRawConditions/src/LArConditionsContainerBase.cxx
@@ -17,7 +17,9 @@
 
 // Services/helpers
 #include "LArIdentifier/LArOnlineID.h"
+#include "LArIdentifier/LArOnline_SuperCellID.h"
 #include "CaloIdentifier/CaloCell_ID.h"
+#include "CaloIdentifier/CaloCell_SuperCell_ID.h"
 
 // Gaudi/Athena
 #include "GaudiKernel/Bootstrap.h"
@@ -69,15 +71,42 @@ LArConditionsContainerBase::initializeBase()
 	log << MSG::ERROR << "Cannot get DetectorStore!" << endmsg;
 	return sc;
     }
-    sc = detStore->retrieve(m_onlineHelper,"LArOnlineID");
-    if (sc.isFailure()) {
-	log << MSG::ERROR << "Cannot get LArOnlineID!" << endmsg;
+
+    if (m_groupType == LArConditionsContainerBase::SuperCells) {
+      //Dealing with supercells, need supercell identifier helper
+      const LArOnline_SuperCellID* onlID;
+      sc = detStore->retrieve(onlID,"LArOnline_SuperCellID");
+      if (sc.isFailure()) {
+	log << MSG::ERROR << "Cannot get LArOnline_SuperCellID!" << endmsg;
 	return sc;
+      }
+      m_onlineHelper=onlID;//cast to base-class
+
+      const CaloCell_SuperCell_ID* oflID;
+      sc = detStore->retrieve(oflID,"CaloCell_SuperCell_ID");
+      if (sc.isFailure()) {
+	log << MSG::ERROR << "Cannot get CaloCell_SuperCell_ID!" << endmsg;
+	return sc;
+      }
+      m_offlineHelper=oflID; //cast to base-class
     }
-    sc = detStore->retrieve(m_offlineHelper,"CaloCell_ID");
-    if (sc.isFailure()) {
+    else {
+      //Regular readout
+      const LArOnlineID* onlID;
+      sc = detStore->retrieve(onlID,"LArOnlineID");
+      if (sc.isFailure()) {
+	log << MSG::ERROR << "Cannot get LArOnlineID!" << endmsg;
+	return sc;
+      }
+      m_onlineHelper=onlID;//cast to base-class
+
+      const CaloCell_ID* oflID;
+      sc = detStore->retrieve(oflID,"CaloCell_ID");
+      if (sc.isFailure()) {
 	log << MSG::ERROR << "Cannot get CaloCell_ID!" << endmsg;
 	return sc;
+      }
+      m_offlineHelper=oflID; //cast to base-class
     }
 
     // initialize the grouping
@@ -125,6 +154,10 @@ LArConditionsContainerBase::setGroupingType(const std::string& groupingStr, MsgS
     setGroupingType(LArConditionsContainerBase:: ExtendedFTGrouping);
     return StatusCode::SUCCESS;
   }
+  else if (groupingStr == "SuperCells") {
+    setGroupingType(LArConditionsContainerBase::SuperCells);
+    return StatusCode::SUCCESS;
+  }
 
   logStr << MSG::ERROR << "Unknown COOL Channel Grouping '"<< groupingStr <<"'.  Allowed values are:" << endmsg;
   logStr << MSG::ERROR << "'Single','SubDetector', 'ExtendedSubDetector','FeedThrough','ExtendedFeedThrough'" << endmsg;
@@ -145,7 +178,7 @@ LArConditionsContainerBase::initGrouping()
 
 	// Not yet known
     }
-    if (SingleGroup == m_groupType) {
+    if (SingleGroup == m_groupType || SuperCells == m_groupType) {
 
 	log << MSG::DEBUG << "Single group "<< endmsg;
 
@@ -476,17 +509,19 @@ LArConditionsContainerBase::groupingTypeToString() const
 	    return ("ExtendedFTGrouping");
         case 5:
 	    return ("ExtendedSubDetGrouping");
+        case 6:
+            return ("SuperCells");
     }
     return ("Unknown");
 }
 
-const LArOnlineID*          
+const LArOnlineID_Base*          
 LArConditionsContainerBase::onlineHelper() const
 {
     return (m_onlineHelper);
 }
 
-const CaloCell_ID*          
+const CaloCell_Base_ID*          
 LArConditionsContainerBase::offlineHelper() const
 {
     return (m_offlineHelper);
-- 
GitLab