From 853a111dfcf40ab5fd40586319d06363c95767d2 Mon Sep 17 00:00:00 2001
From: scott snyder <sss@karma>
Date: Mon, 22 Mar 2021 14:13:54 -0400
Subject: [PATCH 1/2] TBRec: Remove use of CaloNoiseTool.

Remove references to obsolete CaloNoiseTool and friends.
Either migrate to CaloNoise or remove entirely.
---
 TestBeam/TBRec/CMakeLists.txt               |   4 +-
 TestBeam/TBRec/src/CBNT_CaloH6.cxx          |  51 +++---
 TestBeam/TBRec/src/CBNT_CaloH6.h            |  19 +--
 TestBeam/TBRec/src/TBClusterMaker.cxx       |  41 +----
 TestBeam/TBRec/src/TBClusterMaker.h         |  11 +-
 TestBeam/TBRec/src/TBTree_CaloClusterH6.cxx | 163 +-------------------
 TestBeam/TBRec/src/TBTree_CaloClusterH6.h   |  23 +--
 7 files changed, 60 insertions(+), 252 deletions(-)

diff --git a/TestBeam/TBRec/CMakeLists.txt b/TestBeam/TBRec/CMakeLists.txt
index c6c2cf730d04..2d8a2de0bcbf 100644
--- a/TestBeam/TBRec/CMakeLists.txt
+++ b/TestBeam/TBRec/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 
 # Declare the package name:
 atlas_subdir( TBRec )
@@ -23,7 +23,7 @@ atlas_add_library( TBRecLib
                    PRIVATE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS}
                    DEFINITIONS ${CLHEP_DEFINITIONS}
                    LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} CaloEvent CaloGeoHelpers CaloIdentifier AthenaBaseComps AthenaKernel AthContainers GeoPrimitives Identifier EventInfo xAODTracking GaudiKernel LArIdentifier LArRawEvent TBEvent TrkDetDescrUtils TrkParameters TrkTrack CaloRecLib CaloUtilsLib StoreGateLib SGtests LArRawUtilsLib LArCablingLib CaloDetDescrLib TBCaloGeometryLib TBCondRunParLib
-                   PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} CaloDmDetDescr CaloSimEvent CondDBObjects xAODCaloEvent LArG4TBSimEvent Particle PathResolver TrkSurfaces TrkEventPrimitives TrkExInterfaces CaloTrackingGeometryLib TrackRecordLib )
+                   PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} CaloDmDetDescr CaloSimEvent CondDBObjects xAODCaloEvent LArG4TBSimEvent Particle PathResolver TrkSurfaces TrkEventPrimitives TrkExInterfaces CaloTrackingGeometryLib TrackRecordLib CaloConditions )
 
 atlas_add_component( TBRec
                      src/components/*.cxx
diff --git a/TestBeam/TBRec/src/CBNT_CaloH6.cxx b/TestBeam/TBRec/src/CBNT_CaloH6.cxx
index 59714ae29bac..c8f7d118719e 100644
--- a/TestBeam/TBRec/src/CBNT_CaloH6.cxx
+++ b/TestBeam/TBRec/src/CBNT_CaloH6.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //#####################################################
@@ -16,7 +16,7 @@
 
 #include "CaloIdentifier/CaloCell_ID.h"
 #include "CaloEvent/CaloCellContainer.h"
-#include "CaloInterface/ICaloNoiseTool.h"
+#include "StoreGate/ReadCondHandle.h"
 
 #include "Identifier/Identifier.h"
 
@@ -25,11 +25,9 @@ CBNT_CaloH6::CBNT_CaloH6(const std::string & name, ISvcLocator * pSvcLocator) :
   CBNT_TBRecBase(name, pSvcLocator),
   m_emecID_help(0),
   m_hecID_help(0),
-  m_fcalID_help(0),
-  m_noiseTool("CaloNoiseTool/CaloNoiseToolDefault")
+  m_fcalID_help(0)
 {
   declareProperty("Det_Type", m_det_type);
-  declareProperty("NoiseToolName", m_noiseTool);
   declareProperty("Max_Chan", m_numchan);
   m_noiseSigma = 0;
 
@@ -76,7 +74,7 @@ StatusCode CBNT_CaloH6::CBNT_initialize()
 
   ATH_MSG_DEBUG("Got to before p_toolSvc");
   
-  ATH_CHECK( m_noiseTool.retrieve() );
+  ATH_CHECK( m_elecNoiseKey.initialize() );
 
   ATH_MSG_DEBUG ( "Before Booking Ntuple" );
   
@@ -110,14 +108,10 @@ StatusCode CBNT_CaloH6::CBNT_execute()
   const CaloCellContainer* cellContainer;
   
   ATH_CHECK( evtStore()->retrieve(cellContainer) );
+
+  SG::ReadCondHandle<CaloNoise> elecNoise (m_elecNoiseKey);
   
-  CaloCellContainer::const_iterator ifirst = cellContainer->begin();
-  CaloCellContainer::const_iterator ilast = cellContainer->end();
-  
-  for (; ifirst!=ilast; ifirst++){ //iterating
-    
-    //obtaining cell pointer
-    const CaloCell* cell_ptr = *ifirst;
+  for (const CaloCell* cell_ptr : *cellContainer) {
     
     //obtaining dde pointer
     const CaloDetDescrElement* caloDDE_ptr = cell_ptr->caloDDE();
@@ -129,14 +123,13 @@ StatusCode CBNT_CaloH6::CBNT_execute()
     const CaloCell_ID::CaloSample sampling = caloDDE_ptr->getSampling();                                                
     if (m_det_type=="HEC" && subcalo==CaloCell_ID::LARHEC) { 
       
-      float noiseSigma = m_noiseTool->elecNoiseRMS(cell_ptr);
-
-      ATH_MSG_DEBUG("noiseRMS HEC"<<noiseSigma);
-      
       const Identifier hecid=cell_ptr->ID();
-      
+
+      float noise = elecNoise->getNoise(hecid, cell_ptr->gain());
+      ATH_MSG_DEBUG("noiseRMS HEC"<<noise);
+     
       m_energy->push_back(cell_ptr->energy());
-      m_NoiseRMS->push_back(m_noiseTool->elecNoiseRMS(cell_ptr));
+      m_NoiseRMS->push_back(noise);
       m_eta->push_back(caloDDE_ptr->eta());
       m_phi->push_back(caloDDE_ptr->phi());
       m_ieta->push_back(m_hecID_help->eta(hecid));
@@ -147,14 +140,13 @@ StatusCode CBNT_CaloH6::CBNT_execute()
     
     if (m_det_type=="EMEC" && subcalo==CaloCell_ID::LAREM) {
       
-      float noiseSigma = m_noiseTool->elecNoiseRMS(cell_ptr);
-      
-      ATH_MSG_DEBUG("noiseRMS EMEC"<<noiseSigma);
-      
       const Identifier emecid=cell_ptr->ID();
-      
+
+      float noise = elecNoise->getNoise(emecid, cell_ptr->gain());
+      ATH_MSG_DEBUG("noiseRMS EMEC"<<noise);
+     
       m_energy->push_back(cell_ptr->energy());
-      m_NoiseRMS->push_back(m_noiseTool->elecNoiseRMS(cell_ptr));
+      m_NoiseRMS->push_back(noise);
       m_eta->push_back(caloDDE_ptr->eta());
       m_phi->push_back(caloDDE_ptr->phi());
       m_ieta->push_back(m_emecID_help->eta(emecid));
@@ -163,14 +155,13 @@ StatusCode CBNT_CaloH6::CBNT_execute()
     }
     if (m_det_type=="FCAL" && subcalo==CaloCell_ID::LARFCAL) {
       
-      float noiseSigma = m_noiseTool->elecNoiseRMS(cell_ptr);
-      
-      ATH_MSG_DEBUG("noiseRMS FCAL"<<noiseSigma);
-      
       const Identifier fcalid=cell_ptr->ID();
+
+      float noise = elecNoise->getNoise(fcalid, cell_ptr->gain());
+      ATH_MSG_DEBUG("noiseRMS FCAL"<<noise);
       
       m_energy->push_back(cell_ptr->energy());
-      m_NoiseRMS->push_back(m_noiseTool->elecNoiseRMS(cell_ptr));
+      m_NoiseRMS->push_back(noise);
       m_eta->push_back(caloDDE_ptr->eta());
       m_phi->push_back(caloDDE_ptr->phi());
       m_ieta->push_back(m_fcalID_help->eta(fcalid));
diff --git a/TestBeam/TBRec/src/CBNT_CaloH6.h b/TestBeam/TBRec/src/CBNT_CaloH6.h
index 3bb767da063c..631e2faae47f 100644
--- a/TestBeam/TBRec/src/CBNT_CaloH6.h
+++ b/TestBeam/TBRec/src/CBNT_CaloH6.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 //######################################################
@@ -23,7 +23,8 @@
 // #include "LArDetDescr/LArDetDescrManager.h"
 
 // NOISE
-class ICaloNoiseTool;
+#include "CaloConditions/CaloNoise.h"
+#include "StoreGate/ReadCondHandleKey.h"
 
 #include <fstream>
 #include <string>
@@ -36,13 +37,13 @@ class CBNT_CaloH6 : public CBNT_TBRecBase
  public:
   CBNT_CaloH6(const std::string & name, ISvcLocator * pSvcLocator);
   
-  ~CBNT_CaloH6();
+  virtual ~CBNT_CaloH6();
   
   //standart algorithm methods
-  virtual StatusCode CBNT_initialize();
-  virtual StatusCode CBNT_execute();
-  virtual StatusCode CBNT_finalize();
-  virtual StatusCode CBNT_clear();
+  virtual StatusCode CBNT_initialize() override;
+  virtual StatusCode CBNT_execute() override;
+  virtual StatusCode CBNT_finalize() override;
+  virtual StatusCode CBNT_clear() override;
   
  private:
   // LArDetDescrManager* m_larMgr;
@@ -52,8 +53,8 @@ class CBNT_CaloH6 : public CBNT_TBRecBase
   const LArHEC_ID* m_hecID_help;
   const LArFCAL_ID* m_fcalID_help;
 
-  // noise tool pointer
-  ToolHandle<ICaloNoiseTool> m_noiseTool;
+  SG::ReadCondHandleKey<CaloNoise> m_elecNoiseKey
+    { this, "ElecNoiseKey", "electronicNoise", "SG key for electronic noise" };
   
   float m_noiseSigma;
   
diff --git a/TestBeam/TBRec/src/TBClusterMaker.cxx b/TestBeam/TBRec/src/TBClusterMaker.cxx
index 5790e74bd0c7..a11ac3c5339e 100644
--- a/TestBeam/TBRec/src/TBClusterMaker.cxx
+++ b/TestBeam/TBRec/src/TBClusterMaker.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "TBClusterMaker.h"
@@ -7,7 +7,6 @@
 #include "CLHEP/Units/SystemOfUnits.h"
 #include "CaloDetDescr/CaloDetDescrManager.h"
 #include "CaloGeoHelpers/CaloPhiRange.h"
-#include "CaloInterface/ICalorimeterNoiseTool.h"
 
 #include "CaloEvent/CaloCell.h"
 #include "CaloEvent/CaloCellContainer.h"
@@ -17,7 +16,7 @@
 #include "xAODCaloEvent/CaloClusterKineHelper.h"
 #include "CaloGeoHelpers/proxim.h"
 #include "CaloUtils/CaloClusterStoreHelper.h"
-#include "GaudiKernel/ListItem.h"
+#include "StoreGate/ReadCondHandle.h"
 
 //#############################################################################
 
@@ -32,14 +31,10 @@ TBClusterMaker::TBClusterMaker(const std::string& type,
     m_maxIter(4),
     m_CellEnergyInADC(false),
     m_calo_DDM(0),
-    m_calo_id(0),
-    m_toolSvc(0),
-    m_noiseTool(0)
+    m_calo_id(0)
 {
   // CaloCell Container Name
   declareProperty("caloCellContainerName",m_caloCellContainerName="AllCalo");
-  // Calonoise tool name
-  declareProperty("noiseToolName",m_noiseToolName);
   // Names of used calorimeter samplings
   declareProperty("samplingNames",m_samplingNames);
   // Cone cuts for each (!!) sampling used
@@ -78,27 +73,7 @@ StatusCode TBClusterMaker::initialize(){
   m_calo_DDM  = CaloDetDescrManager::instance(); 
   m_calo_id   = m_calo_DDM->getCaloCell_ID();
 
-  // allocate ToolSvc
-  StatusCode sc = service("ToolSvc", m_toolSvc);
-  if (sc.isFailure()) {
-    log << MSG::FATAL << "cannot allocate ToolSvc" << endmsg;
-    return sc;
-  }
-    
-  IAlgTool* algtool;
-  ListItem ntool(m_noiseToolName);	  
-  sc = m_toolSvc->retrieveTool(ntool.type(), ntool.name(), algtool);
-  if (sc.isFailure()) {
-    log << MSG::ERROR
-	<< "Unable to find tool for " << m_noiseToolName
-	<< endmsg;
-    return sc;
-  }
-  else {
-    log << MSG::INFO << "Noise Tool "
-	<< m_noiseToolName << " is selected!" << endmsg;
-  }
-  m_noiseTool = dynamic_cast<ICalorimeterNoiseTool*>(algtool);
+  ATH_CHECK( m_elecNoiseKey.initialize() );
 
   // setup calorimeter module and sampling lookup tables
   if ((this->setupLookupTables()).isFailure()) {
@@ -156,14 +131,14 @@ StatusCode TBClusterMaker::initialize(){
 }
 
 
-StatusCode TBClusterMaker::execute(const EventContext& /*ctx*/,
+StatusCode TBClusterMaker::execute(const EventContext& ctx,
                                    xAOD::CaloClusterContainer* clusCont) const
 {
-  //static CaloPhiRange range;
-
   MsgStream log(msgSvc(), name());
   log << MSG::DEBUG << "in execute()" << endmsg;
 
+  SG::ReadCondHandle<CaloNoise> elecNoise (m_elecNoiseKey, ctx);
+
   /////////////////
   // Data Access //
   /////////////////
@@ -202,7 +177,7 @@ StatusCode TBClusterMaker::execute(const EventContext& /*ctx*/,
       for (; itc!=cellContainer->endConstCalo(*calo); itc++,cindex++) {
 	const CaloCell* cell = (*itc);
 	double e = cell->energy();
-        double noiseRMS = m_noiseTool->getNoise(cell, ICalorimeterNoiseTool::ELECTRONICNOISE);
+        double noiseRMS = elecNoise->getNoise(cell->ID(), cell->gain());
 	if(noiseRMS <= 0.) noiseRMS = 0.0001;
 	double eSigma = e/noiseRMS;
         CaloSampling::CaloSample idSample=(CaloSampling::CaloSample) m_calo_id->calo_sample(cell->ID());
diff --git a/TestBeam/TBRec/src/TBClusterMaker.h b/TestBeam/TBRec/src/TBClusterMaker.h
index 2fe9b24ea88b..e59ac188bc5b 100644
--- a/TestBeam/TBRec/src/TBClusterMaker.h
+++ b/TestBeam/TBRec/src/TBClusterMaker.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBCLUSTERMAKER_H
@@ -18,11 +18,12 @@
 
 class CaloDetDescrManager; 
 class CaloDetDescrElement;
-class ICalorimeterNoiseTool;
 
 #include "CaloIdentifier/CaloCell_ID.h"
 #include "CaloRec/CaloClusterCollectionProcessor.h"
 #include "CaloGeoHelpers/CaloSampling.h"
+#include "CaloConditions/CaloNoise.h"
+#include "StoreGate/ReadCondHandleKey.h"
 
 #include <map>
 #include <vector>
@@ -92,13 +93,13 @@ class TBClusterMaker: public AthAlgTool, virtual public CaloClusterCollectionPro
   /** Services */
   const CaloDetDescrManager* m_calo_DDM;
   const CaloCell_ID* m_calo_id;
-  IToolSvc* m_toolSvc;
-  ICalorimeterNoiseTool* m_noiseTool;
+
+  SG::ReadCondHandleKey<CaloNoise> m_elecNoiseKey
+    { this, "ElecNoiseKey", "electronicNoise", "SG key for electronic noise" };
   
   /** Names */
   std::string m_caloCellContainerName;
   std::string m_clusterContainerName;
-  std::string m_noiseToolName; 
   std::vector<std::string> m_samplingNames;
 
   std::map<std::string, CaloSampling::CaloSample> m_samplingFromNameLookup;
diff --git a/TestBeam/TBRec/src/TBTree_CaloClusterH6.cxx b/TestBeam/TBRec/src/TBTree_CaloClusterH6.cxx
index 842f7f104b46..717956706cd6 100644
--- a/TestBeam/TBRec/src/TBTree_CaloClusterH6.cxx
+++ b/TestBeam/TBRec/src/TBTree_CaloClusterH6.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 // class TBTree_CaloClusterH6 // make ROOT Tree for H6 CaloCluster
@@ -9,9 +9,7 @@
 
 #include "TBTree_CaloClusterH6.h"
 #include "TBRec/TBH6RunHeader.h"
-
-#include "GaudiKernel/IToolSvc.h"
-#include "GaudiKernel/ListItem.h"
+#include "StoreGate/ReadCondHandle.h"
 
 #include "PathResolver/PathResolver.h"
 
@@ -26,11 +24,9 @@
 #include "CaloEvent/CaloCellContainer.h"
 #include "CaloEvent/CaloCluster.h"
 #include "CaloEvent/CaloClusterContainer.h"
-#include "CaloInterface/ICaloNoiseTool.h"
 
 #include "LArRawEvent/LArDigitContainer.h"
 #include "LArElecCalib/ILArPedestal.h"
-#include "LArElecCalib/ILArADC2MeVTool.h"
 
 #include "TBEvent/TBEventInfo.h"
 #include "TBEvent/TBTrack.h"
@@ -45,7 +41,6 @@ TBTree_CaloClusterH6::TBTree_CaloClusterH6(const std::string& name,
   m_nEventRejected(0),
   m_nEventAccepted(0),
   m_nEventRandomTrigger(0),
-  m_addNoise(true),
   m_addMoments(false),
   m_addGain(false),
   m_addTime(false),
@@ -96,7 +91,6 @@ TBTree_CaloClusterH6::TBTree_CaloClusterH6(const std::string& name,
   m_cell_id(0),
   m_cell_ind_cluster(0),
   m_cell_energy(0),
-  m_cell_noise(0),
   m_cell_gain(0),
   m_cell_time(0),
   m_cell_quality(0),
@@ -110,7 +104,6 @@ TBTree_CaloClusterH6::TBTree_CaloClusterH6(const std::string& name,
   m_beam_slope_y(0),
   m_wtcNOverflow(0),
   m_wtcSignal(0),
-  m_digitContainerName("FREE"),
   m_caloCellContainerName("AllCalo"),
   m_clusterContainerName("TBClusters"),
   m_WTCContainerName("TailCatcher"),
@@ -120,19 +113,13 @@ TBTree_CaloClusterH6::TBTree_CaloClusterH6(const std::string& name,
   m_tree(0),
   m_calo_id(0),
   m_calo_dd_man(0),
-  m_noiseTool(0),
-  m_OFNoiseSupp(0),
-  m_adc2mevTool(0),
   m_txtFileWithXY("xcryo_ytable.txt")
 { 
   declareProperty("ClusterContainer",m_clusterContainerName);
   declareProperty("CellContainer",m_caloCellContainerName);
-  declareProperty("NoiseToolName",m_noiseToolName);
-  declareProperty("OFNoiseSuppToolName",m_OFNoiseSuppToolName);
   declareProperty("RootFileName",m_rootfile_name);
   declareProperty("TBTreeName",m_TBTreeName);
   declareProperty("Suffix", m_suffix);
-  declareProperty("addNoise", m_addNoise);
   declareProperty("addBeamTrack", m_addBeamTrack);
   declareProperty("addMoments", m_addMoments);
   declareProperty("addGain", m_addGain);
@@ -180,7 +167,6 @@ StatusCode TBTree_CaloClusterH6::initialize()
   m_cell_id = new std::vector<int>;
   m_cell_ind_cluster = new std::vector<int>;
   m_cell_energy = new std::vector<float>;
-  if (m_addNoise) m_cell_noise = new std::vector<float>;
   if (m_addGain) m_cell_gain = new std::vector<int>;
   if (m_addTime) m_cell_time = new std::vector<float>;
   if (m_addQuality) m_cell_quality = new std::vector<float>;
@@ -257,8 +243,6 @@ StatusCode TBTree_CaloClusterH6::initialize()
   m_tree->Branch(("cl_cell_id"+m_suffix).c_str(), &m_cell_id);
   m_tree->Branch(("cl_cell_clu_ind"+m_suffix).c_str(), &m_cell_ind_cluster);
   m_tree->Branch(("cl_cell_ener"+m_suffix).c_str(), &m_cell_energy);
-  if (m_addNoise)
-    m_tree->Branch(("cl_cell_noise"+m_suffix).c_str(), &m_cell_noise);
   if (m_addGain) 
     m_tree->Branch(("cl_cell_gain"+m_suffix).c_str(), &m_cell_gain);
   if (m_addTime) 
@@ -296,31 +280,7 @@ StatusCode TBTree_CaloClusterH6::initialize()
   m_calo_dd_man = CaloDetDescrManager::instance(); 
   m_calo_id   = m_calo_dd_man->getCaloCell_ID();
 
-  // allocate ToolSvc
-  IToolSvc* toolSvc;
-  ATH_CHECK( service("ToolSvc", toolSvc) );
-
-  if (m_addNoise) {
-    IAlgTool* algtool;
-    ATH_CHECK( toolSvc->retrieveTool("LArADC2MeVTool", algtool) );
-    m_adc2mevTool=dynamic_cast<ILArADC2MeVTool*>(algtool);
-    if (!m_adc2mevTool) {
-      ATH_MSG_ERROR ( "Unable to d-cast LArADC2MeV" );
-      return StatusCode::FAILURE;
-    }
-  }
-
-  ListItem ntool(m_noiseToolName);	  
-  ATH_CHECK( toolSvc->retrieveTool(ntool.type(), ntool.name(), m_noiseTool) );
-  ATH_MSG_INFO ( "Noise Tool " << m_noiseToolName << " is selected!" );
-  
-  if (m_addNoise) {
-    ListItem ntool(m_OFNoiseSuppToolName);
-    ATH_CHECK( toolSvc->retrieveTool(ntool.type(), ntool.name(), m_OFNoiseSupp) );
-    ATH_MSG_INFO ("Noise Tool " << m_OFNoiseSuppToolName << " is selected!" );
-    // Translate offline ID into online ID
-    ATH_CHECK( m_cablingKey.initialize() );
-  }
+  ATH_CHECK( m_elecNoiseKey.initialize() );
   
   ATH_MSG_INFO ( "end of initialize()" );
   return StatusCode::SUCCESS;
@@ -381,7 +341,6 @@ void TBTree_CaloClusterH6::clear()
   m_cell_id->clear(); 
   m_cell_ind_cluster->clear();
   m_cell_energy->clear(); 
-  if (m_addNoise) m_cell_noise->clear();
   if (m_addGain) m_cell_gain->clear(); 
   if (m_addTime) m_cell_time->clear(); 
   if (m_addQuality) m_cell_quality->clear(); 
@@ -442,7 +401,6 @@ StatusCode TBTree_CaloClusterH6::execute()
     if (m_addGain) m_cell_gain->clear();
     if (m_addTime) m_cell_time->clear();
     if (m_addQuality) m_cell_quality->clear();
-    if (m_addNoise) m_cell_noise->clear();
     // Get cell information
     const CaloCellContainer* cellContainer;
     sc = evtStore()->retrieve(cellContainer, m_caloCellContainerName);
@@ -477,6 +435,8 @@ StatusCode TBTree_CaloClusterH6::execute()
 
   // Do first event initialization (run header filling)
   if (m_first) {
+    SG::ReadCondHandle<CaloNoise> elecNoise (m_elecNoiseKey);
+
     m_first = false;
     // Fill run header
     m_nRun = theEventInfo->getRunNum();
@@ -512,9 +472,7 @@ StatusCode TBTree_CaloClusterH6::execute()
     
     // Cell loop
     int icell=0;
-    CaloCellContainer::const_iterator itc = cellContainer->begin();
-    for (;itc!=cellContainer->end(); itc++) {
-      const CaloCell* cell = (*itc);
+    for (const CaloCell* cell : *cellContainer) {
       const CaloDetDescrElement* caloDDE = cell->caloDDE();
       const Identifier id = cell->ID();
       rh->SetCellID(icell,id.get_identifier32().get_compact());
@@ -537,7 +495,7 @@ StatusCode TBTree_CaloClusterH6::execute()
       rh->SetCellCalo(icell,m_calo_id->sub_calo(id));
       rh->SetCellSampling(icell,m_calo_id->calo_sample(id));
       rh->SetCellNoiseRMS(icell,
-	 m_noiseTool->getNoise(cell,ICalorimeterNoiseTool::ELECTRONICNOISE));
+                          elecNoise->getNoise(id, cell->gain()));
       icell++;
     }
     rh->SetCellNum(icell+1);
@@ -690,7 +648,6 @@ StatusCode TBTree_CaloClusterH6::execute()
     m_etaTotal += fabs((float)cluster->energy())*(float)cluster->eta();
     m_phiTotal += fabs((float)cluster->energy())*(float)cluster->phi();
     //m_cell_energy->reserve(m_nCells);
-    //if (m_addNoise) m_cell_noise->reserve(m_nCells);
     //if (m_addGain) m_cell_gain->reserve(m_nCells);
     //if (m_addTime) m_cell_time->reserve(m_nCells);
     //if (m_addQuality) m_cell_quality->reserve(m_nCells);
@@ -723,10 +680,6 @@ StatusCode TBTree_CaloClusterH6::execute()
       if (m_calo_id->calo_sample(id) == (int)CaloSampling::FCAL2)
 	m_eFCAL2 += (float)cell->energy();
     }
-    // Add noise vector
-    if (m_addNoise) {
-      ATH_CHECK( this->getNoise(cluster) );
-    }
     
     // Add cluster moments
     if (m_addMoments) {
@@ -869,105 +822,3 @@ StatusCode TBTree_CaloClusterH6::getXcryoYtable(float &x, float &y, float &e) {
   return StatusCode::FAILURE;
 }
 
-StatusCode TBTree_CaloClusterH6::getNoise(CaloCluster const * const cluster) {
-  // Constants for EMEC correction
-  float EMEC_eta1=2.5; float EMEC_eta2=2.8; float EMEC_eta3=3.2;
-  float EMEC_eta0_1 = 0.5*(EMEC_eta1 + EMEC_eta2);
-  float EMEC_eta0_2 = 0.5*(EMEC_eta2 + EMEC_eta3);
-  float EMEC_beta1=1.04; float EMEC_alpha1=0.55;
-  float EMEC_beta2=1.00; float EMEC_alpha2=0.55;
-  const float ramp_corr(1.045);
-  const float ramp_corr_eta1=2.8; 
-  const float ramp_corr_eta2=2.9;
-  const float EMEC_rescale=1.215;
-
-  const float inv_ramp_corr = 1. / ramp_corr;
-  const float inv_EMEC_rescale = 1. / EMEC_rescale;
-
-  const LArDigitContainer* digitContainer = 0;
-  const ILArPedestal* larPedestal = 0;
-
-  StatusCode sc=evtStore()->retrieve(digitContainer,m_digitContainerName);
-  if(sc.isFailure()) {
-    ATH_MSG_ERROR ( "Can't retrieve LArDigitContainer with key " <<
-                    m_digitContainerName << "from StoreGate." );
-    return StatusCode::FAILURE;
-  }
-  
-  ATH_CHECK( detStore()->retrieve(larPedestal) );
-
-  SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{m_cablingKey};
-  const LArOnOffIdMapping* cabling{*cablingHdl};
-  if(!cabling) {
-      ATH_MSG_ERROR ( "Do not have cabling mapping from key " << m_cablingKey.key() );
-      return StatusCode::FAILURE;
-  }
-  // Loop over cluster cells
-  CaloCluster::cell_iterator itc=cluster->cell_begin();
-  for (; itc!=cluster->cell_end(); itc++) {
-    float noise = 0;
-    const CaloCell* cell = (*itc);
-    const Identifier id = cell->ID();
-    float eta = cell->eta();
-    const CaloGain::CaloGain gain= cell->gain();
-    HWIdentifier chid;
-    try {
-      chid = cabling->createSignalChannelID(id);
-    }
-    catch ( const LArID_Exception& except) {
-      ATH_MSG_ERROR("HWId not found: "<<(const std::string&)except);
-      return StatusCode::FAILURE;
-    }
-    // Find the cell data in the DigitContainer
-    LArDigitContainer::const_iterator cont_it=digitContainer->begin();
-    for (;cont_it!=digitContainer->end(); cont_it++) {
-      if (chid !=(*cont_it)->channelID()) continue;
-      const std::vector<short>& samples=(*cont_it)->samples();
-      noise = samples[0];
-      break;
-    }
-    if (cont_it == digitContainer->end()) {
-      ATH_MSG_ERROR("Samples are not found for cell with HWId = "<<
-                    chid.get_identifier32().get_compact());
-      return StatusCode::FAILURE;
-    }
-    // Get pedestal
-    float pedestal=larPedestal->pedestal(chid,gain);
-    if (pedestal >= (1.0+LArElecCalib::ERRORCODE)) {
-      float val = m_noiseTool->
-      getNoise(cell,ICalorimeterNoiseTool::ELECTRONICNOISE);
-      noise = m_rndm.Gaus(0,val);
-      ATH_MSG_WARNING("No pedestal found for HWId = "<< chid.get_identifier32().get_compact() <<
-                      " gain = "<<(int)gain<<". Generated(sigma="<<val<<
-                      ") noise taken: "<<noise);
-      return StatusCode::SUCCESS;
-    }
-    noise -= pedestal;
-    // Apply OF noise suppression factor
-    noise *= m_OFNoiseSupp->
-      getNoise(cell,ICalorimeterNoiseTool::ELECTRONICNOISE);
-    // Apply ADCtoMeV factor
-    const std::vector<float>& ramp=m_adc2mevTool->ADC2MEV(chid,gain);
-    if (ramp.size()==0) {
-      ATH_MSG_ERROR("No ADC2MeV data found for channel HWId = "
-                    << chid.get_identifier32().get_compact() <<", gain = "<<(int)gain);
-      return StatusCode::FAILURE;
-    }
-    noise *= ramp[1];
-    // EMEC corrections =======================================================
-    if (cell->caloDDE()->is_lar_em_endcap()) {
-      // Cell level correction of EMEC eta-dependent response
-      if (eta > EMEC_eta1 && eta < EMEC_eta2) {
-	noise *= EMEC_beta1/(1 + EMEC_alpha1*(eta - EMEC_eta0_1));
-      }
-      else if (eta > EMEC_eta2 && eta < EMEC_eta3) {
-	noise *= EMEC_beta2/(1 + EMEC_alpha2*(eta - EMEC_eta0_2));
-      }
-      if (eta > ramp_corr_eta1 && eta < ramp_corr_eta2) noise *= inv_ramp_corr;
-      noise *= inv_EMEC_rescale;
-    }
-    // End of EMEC corrections ================================================
-    m_cell_noise->push_back(noise);
-  }       // for (itc)
-  return StatusCode::SUCCESS;
-}
diff --git a/TestBeam/TBRec/src/TBTree_CaloClusterH6.h b/TestBeam/TBRec/src/TBTree_CaloClusterH6.h
index 2dc7496ed29a..823a44b80588 100644
--- a/TestBeam/TBRec/src/TBTree_CaloClusterH6.h
+++ b/TestBeam/TBRec/src/TBTree_CaloClusterH6.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef TBREC_TBTREE_CALOCLUSTERH6_H
@@ -10,7 +10,8 @@
 // Make ROOT TTree for CaloClusters for H6 CBT
 //
 #include "AthenaBaseComps/AthAlgorithm.h"
-#include "LArCabling/LArOnOffIdMapping.h"
+#include "CaloConditions/CaloNoise.h"
+#include "StoreGate/ReadCondHandleKey.h"
 
 #include <TRandom.h>
 
@@ -20,10 +21,8 @@ class CaloCell_ID;
 class CaloDetDescrManager;
 class CaloCluster;
 class IToolSvc;
-class ICaloNoiseTool;
 class LArDigitContainer;
 class ILArPedestal;
-class ILArADC2MeVTool;
 
 class TBTree_CaloClusterH6: public AthAlgorithm {
  public:    
@@ -38,14 +37,12 @@ class TBTree_CaloClusterH6: public AthAlgorithm {
   void clear();
   /** Get Xcryo and Ytable from a text file */
   StatusCode getXcryoYtable(float &x, float &y, float &eBeam);
-  StatusCode getNoise(CaloCluster const * const cluster);
   
   std::string m_suffix;
   int m_nEvent;                     // counter
   int m_nEventRejected;             // counter
   int m_nEventAccepted;             // counter
   int m_nEventRandomTrigger;        // counter
-  bool m_addNoise;
   bool m_addMoments;
   bool m_addGain;
   bool m_addTime;
@@ -109,7 +106,6 @@ class TBTree_CaloClusterH6: public AthAlgorithm {
   std::vector<int>* m_cell_id;
   std::vector<int>* m_cell_ind_cluster;
   std::vector<float>* m_cell_energy;
-  std::vector<float>* m_cell_noise;
   std::vector<int>* m_cell_gain;
   std::vector<float>* m_cell_time;
   std::vector<float>* m_cell_quality;
@@ -129,12 +125,9 @@ class TBTree_CaloClusterH6: public AthAlgorithm {
   std::vector<float>* m_wtcSignal;
 
   // Names and pointers
-  std::string m_digitContainerName;
   std::string m_caloCellContainerName;    // Cell container name
   std::string m_clusterContainerName;     // Cluster container
   std::string m_WTCContainerName;         // Warm TailCatcher
-  std::string m_noiseToolName;            // Noise tool name
-  std::string m_OFNoiseSuppToolName;      // Noise tool name for OFNoiseSupp
   std::string m_TBTreeName;               // TBTree name
   std::string m_rootfile_name;            // name of the ROOT file with TBTree
   TFile* m_rootfile;                      // and its pointer
@@ -142,16 +135,12 @@ class TBTree_CaloClusterH6: public AthAlgorithm {
 
   const CaloCell_ID* m_calo_id;
   const CaloDetDescrManager* m_calo_dd_man; 
-  ICaloNoiseTool* m_noiseTool;
-  ICaloNoiseTool* m_OFNoiseSupp;
-  const ILArADC2MeVTool* m_adc2mevTool;
-  SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKey{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"};
+
+  SG::ReadCondHandleKey<CaloNoise> m_elecNoiseKey
+    { this, "ElecNoiseKey", "electronicNoise", "SG key for electronic noise" };
 
   /** Text file containing xCryo and yTable */
   std::string m_txtFileWithXY;
-  // Random generator
-  TRandom m_rndm;
-
 };
 
 #endif
-- 
GitLab


From 430781e355ec285245c5cd147052f24afdddb223 Mon Sep 17 00:00:00 2001
From: scott snyder <sss@karma>
Date: Mon, 22 Mar 2021 14:12:13 -0400
Subject: [PATCH 2/2] RecExTB: Remove use of CaloNoiseTool.

Remove references to obsolete CaloNoiseTool and friends.
Either migrate to CaloNoise or remove entirely.
---
 .../RecExTB/share/RecExTB_H6_esdtoesd.py      | 194 ------------------
 .../RecExTB/share/RecExTB_H6_jobOptions.py    |  58 +-----
 2 files changed, 3 insertions(+), 249 deletions(-)
 delete mode 100644 Reconstruction/RecExample/RecExTB/share/RecExTB_H6_esdtoesd.py

diff --git a/Reconstruction/RecExample/RecExTB/share/RecExTB_H6_esdtoesd.py b/Reconstruction/RecExample/RecExTB/share/RecExTB_H6_esdtoesd.py
deleted file mode 100644
index b355c882632a..000000000000
--- a/Reconstruction/RecExample/RecExTB/share/RecExTB_H6_esdtoesd.py
+++ /dev/null
@@ -1,194 +0,0 @@
-# Athena job to run user analysis algorithm on H6 combined testbeam ESD
-# (not able to write ESD yet)
-# (runs with 'athena RecExTBH6_esdtoesd.py' )
-
-
-if not 'inFileName' in dir():
-  inFileName=["/ltmp/gdp/h6prod/rdo2esd/ESD_2.root"]
-
-if not 'outFileName' in dir():
-  outFileName="LCSinglePionsPerformance.root"
-
-if not 'doBeamQuality' in dir():
-  doBeamQuality=False
-
-
-import AthenaCommon.Constants as Lvl
-from AthenaCommon.AppMgr import ServiceMgr as svcMgr
-from AthenaCommon.AppMgr import theApp
-
-theApp.EvtMax = -1
-
-
-## load POOL support
-import AthenaPoolCnvSvc.ReadAthenaPool
-
-## general job configuration
-from AthenaCommon.AlgSequence import AlgSequence
-topSequence = AlgSequence()
-
-from AthenaCommon.GlobalFlags import GlobalFlags
-GlobalFlags.DetGeo.set_ctbh6()
-GlobalFlags.Luminosity.set_zero()
-DetDescrVersion = 'ATLAS-H6-2004-00'
-from AthenaCommon.DetFlags import DetFlags
-DetFlags.detdescr.all_setOff()
-DetFlags.pileup.all_setOff()
-DetFlags.makeRIO.all_setOff()
-DetFlags.readRDOPool.all_setOff()
-DetFlags.readRDOBS.all_setOff()
-GlobalFlags.InputFormat.set_pool()
-include( "LArAthenaPool/LArAthenaPool_joboptions.py" )
-DetFlags.detdescr.LAr_setOn()
-from AthenaCommon.JobProperties import jobproperties
-jobproperties.Global.DetDescrVersion = "ATLAS-H6-2004-00"
-#need also sim Flags unfortunatelly
-from G4AtlasApps.SimFlags import SimFlags
-SimFlags.SimLayout='tb_LArH6_2004'
-SimFlags.LArTB_H6Hec.set_Value(True)
-SimFlags.LArTB_H6Hec.set_On()
-SimFlags.LArTB_H6Emec.set_Value(True)
-SimFlags.LArTB_H6Emec.set_On()
-SimFlags.LArTB_H6Fcal.set_Value(True)
-SimFlags.LArTB_H6Fcal.set_On()
-SimFlags.LArTB_H6Coldnose.set_Value(True)
-SimFlags.LArTB_H6Coldnose.set_On()
-SimFlags.LArTB_H6Run1.set_Value(False)
-SimFlags.LArTB_H6Run1.set_On()
-# Bloct the trigger tower mapping, doesn't exist for TB
-include.block ( "CaloConditions/LArTTCellMap_ATLAS_jobOptions.py" )
-include.block ( "CaloConditions/CaloTTIdMap_ATLAS_jobOptions.py" )
-include ("LArDetDescr/LArDetDescr_H6_joboptions.py")
-include("LArConditionsCommon/LArConditionsCommon_H6G4_jobOptions.py")
-include( "LArConditionsCommon/LArIdMap_H6_jobOptions.py" )
-include( "CaloCondAthenaPool/CaloCondAthenaPool_joboptions.py")
-PoolSvc.ReadCatalog += [ "prfile:PoolCat_H6_tbcond.xml" ]
-print("FileCatalog: ", PoolSvc.ReadCatalog)
-
-
-# - GeoModel ---
-include("AtlasGeoModel/GeoModelInit.py")
-from GeoModelSvc.GeoModelSvcConf import GeoModelSvc
-GeoModelSvc.AtlasVersion='ATLAS-H6-2004-00'
-
-from RecExConfig.ObjKeyStore import ObjKeyStore, objKeyStore
-oks = ObjKeyStore()
-oks.addStreamESD('CaloCellContainer', ['AllCalo'] )
-
-
-# ----------------- new topo clustering --------------
-from CaloRec.CaloTopoClusterFlags import jobproperties
-jobproperties.CaloTopoClusterFlags.doCellWeightCalib = False
-jobproperties.CaloTopoClusterFlags.doTopoClusterLocalCalib = True
-jobproperties.CaloTopoClusterFlags.doCalibHitMoments = True
-
-include ("CaloRec/CaloTopoCluster_jobOptions.py" )
-
-TopoCalibMoments=topSequence.CaloTopoCluster.TopoCalibMoments
-TopoCalibMoments.MomentsNames += ["ENG_CALIB_OUT_L"]
-topSequence.CaloTopoCluster.TopoCalibMoments.MatchDmType = 1 # 1=loose, 2=medium (default), 3=tight
-TopoCalibMoments.CalibrationHitContainerNames = ["LArCalibrationHitInactive","LArCalibrationHitActive"]
-TopoCalibMoments.DMCalibrationHitContainerNames = ["LArCalibrationHitDeadMaterial"]
-
-topSequence.CaloTopoCluster.KeepCorrectionToolAndContainerNames += [
-    "CaloClusterLocalCalib/OOCCalib","CaloWTopoCluster",
-    "CaloClusterLocalCalib/DMCalib", "CaloOOCTopoCluster"]
-
-TopoSeed = 4.0
-TopoNeighbour = 2.0
-TopoCell = 0.0
-topSequence.CaloTopoCluster.TopoMaker.CellThresholdOnAbsEinSigma     =    TopoCell
-topSequence.CaloTopoCluster.TopoMaker.NeighborThresholdOnAbsEinSigma =    TopoNeighbour
-topSequence.CaloTopoCluster.TopoMaker.SeedThresholdOnEorAbsEinSigma  =    TopoSeed
-# FCAL2 is excluded
-topSequence.CaloTopoCluster.TopoMaker.SeedSamplingNames = ["PreSamplerB", "EMB1", "EMB2", "EMB3",
-                                                           "PreSamplerE", "EME1", "EME2", "EME3",
-                                                           "HEC0", "HEC1","HEC2", "HEC3",
-                                                           "TileBar0", "TileBar1", "TileBar2",
-                                                           "TileExt0", "TileExt1", "TileExt2",
-                                                           "TileGap1", "TileGap2", "TileGap3",
-                                                           "FCAL0", "FCAL1"] 
-
-doSimpleNoiseTool = True
-if doSimpleNoiseTool:
-   SimpleNoiseFile = "sigmas_ave.dat"
-   from CaloTools.CaloToolsConf import SimpleNoiseToolFromTextFile
-   SimpleNoiseTool = SimpleNoiseToolFromTextFile("SimpleNoiseTool")
-   SimpleNoiseTool.CellNoiseFileName = SimpleNoiseFile
-   ToolSvc += SimpleNoiseTool
-
-   topSequence.CaloTopoCluster.TopoMaker.CaloNoiseTool           = SimpleNoiseTool
-   topSequence.CaloTopoCluster.LocalCalib.LCWeight.CaloNoiseTool = SimpleNoiseTool
-   topSequence.CaloTopoCluster.DMCalib.LCDeadMaterial.CaloNoiseTool = SimpleNoiseTool
-
-# remove annoying BadChannel tool
-tlist=[]
-for x in topSequence.CaloTopoCluster.ClusterCorrectionTools:
-  if x.find("BadChan") == -1:
-     tlist += [x]
-  else:   
-     print("Removing: ",x," from CaloTopoCluster.ClusterCorrectionTools")
-topSequence.CaloTopoCluster.ClusterCorrectionTools = tlist
-
-
-# =============================================================================
-#
-# Beam Quality
-#
-# =============================================================================
-if doBeamQuality:
-  from TBRec.TBRecConf import TBBeamQualityMC
-  TBBeamQuality = TBBeamQualityMC()
-  TBBeamQuality.ReadFileforXcryo = False
-  TBBeamQuality.CheckTrackParams = False
-  TBBeamQuality.TrackCutX = 35.
-  TBBeamQuality.TrackCutY = 35.
-  TBBeamQuality.CheckPrimaryTrack = True
-  TBBeamQuality.ScintForPrimaryTrack = [6,7]
-  TBBeamQuality.CheckVetoScint = True
-  from AthenaCommon.AppMgr import athMasterSeq
-  athMasterSeq  += TBBeamQuality
-  #from AthenaServices.AthenaServicesConf import AthenaEventLoopMgr
-  #AthenaEventLoopMgr.FailureMode=2
-
-# =============================================================================
-#
-#
-#                                 user analysis
-#
-#
-# =============================================================================
-#include ("H6CTBHadCalib/H6ReadESDWriteTree_jobOptions.py") 
-
-include ("CaloLocalHadCalib/GetLCSinglePionsPerf_jobOptions.py") 
-lcPerf.CalibrationHitContainerNames= ["LArCalibrationHitInactive","LArCalibrationHitActive"]
-lcPerf.DMCalibrationHitContainerNames= ["LArCalibrationHitDeadMaterial"]
-lcPerf.doRecoEfficiency = True
-lcPerf.isTestbeam = True
-
-
-print("topSequence",topSequence)
-print("dumpMasterSequence")
-from AthenaCommon.AlgSequence import dumpMasterSequence
-dumpMasterSequence()
-
-#--------------------------------------------------------------
-# Set output level threshold (2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL )
-#--------------------------------------------------------------
-MessageSvc = svcMgr.MessageSvc
-MessageSvc.OutputLevel = Lvl.WARNING
-#MessageSvc.OutputLevel = Lvl.DEBUG
-MessageSvc.infoLimit = 500000
-svcMgr.EventSelector.InputCollections = inFileName
-#svcMgr.EventSelector.SkipEvents = 4070
-
-#--------------------------------------------------------------
-# statistics
-#--------------------------------------------------------------
-ChronoStatSvc = Service( "ChronoStatSvc" )
-ChronoStatSvc.ChronoDestinationCout = True
-ChronoStatSvc.PrintUserTime     = True
-ChronoStatSvc.PrintSystemTime   = True
-ChronoStatSvc.PrintEllapsedTime = True
-AthenaPoolCnvSvc = Service( "AthenaPoolCnvSvc" )
-AthenaPoolCnvSvc.UseDetailChronoStat = True
diff --git a/Reconstruction/RecExample/RecExTB/share/RecExTB_H6_jobOptions.py b/Reconstruction/RecExample/RecExTB/share/RecExTB_H6_jobOptions.py
index 87d39914c09a..20c4f4f7de9b 100755
--- a/Reconstruction/RecExample/RecExTB/share/RecExTB_H6_jobOptions.py
+++ b/Reconstruction/RecExample/RecExTB/share/RecExTB_H6_jobOptions.py
@@ -77,13 +77,6 @@ if doEMECXTalk and not 'EMECXTalkFactorEMEC2Eta' in dir():
 if not 'doRndm' in dir():
    doRndm = False
 
-if not 'doSimpleNoiseTool' in dir():
-   doSimpleNoiseTool = False
-
-if doSimpleNoiseTool:
-   if not 'SimpleNoiseFile' in dir():
-      SimpleNoiseFile="rdmtrig_noise"
-
 if not 'doCellNoise' in dir():
    doCellNoise = True
 
@@ -455,23 +448,10 @@ if doBeamQuality:
 # -----------------------------
 if doLAr :
 
-    # Default CaloNoiseTool, to be used by all:
-    from CaloTools.CaloNoiseToolDefault import CaloNoiseToolDefault
     from CaloTools.CaloNoiseFlags import jobproperties
-    jobproperties.CaloNoiseFlags.UseCaloLuminosity.set_Value_and_Lock(False)
-    theCaloNoiseTool = CaloNoiseToolDefault()
-    theCaloNoiseTool.NMinBias                = 0
-    theCaloNoiseTool.WithOF                  = True
-    theCaloNoiseTool.UseTile                 = False
-    theCaloNoiseTool.IsMC                    = False
-    theCaloNoiseTool.UseSymmetry             = False
-    theCaloNoiseTool.WorkMode                = 1
-    if doOFC:
-             theCaloNoiseTool.WithOF=True
-    if doSim:
-             theCaloNoiseTool.IsMC=True    
-
-    ToolSvc += theCaloNoiseTool
+    jobproperties.CaloNoiseFlags.FixedLuminosity.set_Value_and_Lock(0)
+    from CaloTools.CaloNoiseCondAlg import CaloNoiseCondAlg
+    CaloNoiseCondAlg ('electronicNoise')
 
     # get public tool LArADC2MeVTool
     from LArRecUtils.LArADC2MeVToolDefault import LArADC2MeVToolDefault
@@ -689,12 +669,6 @@ if doLAr :
     ToolSvc.LArADC2MeVToolDefault.MCSym = False
     ToolSvc.LArOFCToolDefault.FromDatabase=True
 
-    # simple noise tool from text file
-    if doSimpleNoiseTool:
-       from CaloTools.CaloToolsConf import SimpleNoiseToolFromTextFile
-       SimpleNoiseTool = SimpleNoiseToolFromTextFile("SimpleNoiseTool")
-       SimpleNoiseTool.CellNoiseFileName = SimpleNoiseFile
-       ToolSvc += SimpleNoiseTool
 
 if doDMSplit:
    from TBRec.TBRecConf import TBDMContainerSplitter
@@ -728,10 +702,6 @@ if doMakeTBCluster:
     TBCluster.fixClusterPosition = False
     TBCluster.etaCluster         = 2.79
     TBCluster.phiCluster         = 2.49
-    if not doSimpleNoiseTool:
-       TBCluster.noiseToolName      = theCaloNoiseTool.getFullName()
-    else:
-       TBCluster.noiseToolName      = SimpleNoiseTool.getFullName()
     from CaloRec.CaloRecConf import CaloClusterMomentsMaker
     Moments = CaloClusterMomentsMaker("Moments")
     Moments.MaxAxisAngle         = 30*deg
@@ -773,7 +743,6 @@ if doMakeElecCluster:
     EMTBCluster.fixClusterPosition = False
     EMTBCluster.etaCluster         = 99.
     EMTBCluster.phiCluster         = 99.
-    EMTBCluster.noiseToolName      = theCaloNoiseTool.getFullName()
     EMClusterMaker += EMTBCluster
     EMClusterMaker.ClusterMakerTools = [ EMTBCluster.getFullName() ]
     topSequence += EMClusterMaker
@@ -815,10 +784,6 @@ if doMakeTopoCluster:
       topSequence.CaloTopoCluster.TopoCalibMoments.DMCalibrationHitContainerNames = ["LArCalibrationHitDeadMaterial"]
 
 
-    if doSimpleNoiseTool:
-       topSequence.CaloTopoCluster.TopoMaker.CaloNoiseTool           = SimpleNoiseTool
-       topSequence.CaloTopoCluster.LocalCalib.LCWeight.CaloNoiseTool = SimpleNoiseTool
-       topSequence.CaloTopoCluster.DMCalib.LCDeadMaterial.CaloNoiseTool      = SimpleNoiseTool
 
     # remove BadChannel tool from cluster corrections
     tlist=[]
@@ -903,13 +868,9 @@ if doCBNT:
    if doMakeTopoCluster:
        include ("CaloRec/CaloTopoCluster_CBNT_jobOptions.py")
        CBNT_AthenaAware.CBNT_CaloClusterTopo.AddCellDetails = doAddCellDetails
-       if doSimpleNoiseTool:
-          CBNT_AthenaAware.CBNT_CaloClusterTopo.CellDetailsNoiseTool = SimpleNoiseTool
    if doMakeEMTopoCluster:
        include ("CaloRec/EMTopoCluster_CBNT_jobOptions.py")
        CBNT_AthenaAware.CBNT_EMClusterTopo.AddCellDetails = doAddCellDetails
-       if doSimpleNoiseTool:
-          CBNT_AthenaAware.CBNT_EMCaloClusterTopo.CellDetailsNoiseTool = SimpleNoiseTool
 
    from CaloRec.CaloRecConf import CBNTAA_CaloCluster
    if doTopoClusterLocalCalib:
@@ -921,8 +882,6 @@ if doCBNT:
       CBNT_CaloClusterTopoEM.AddCellDetails = doAddCellDetails
       CBNT_CaloClusterTopoEM.MaxCaloCluster = 60
       CBNT_CaloClusterTopoEM.MaxCell = 1024
-      if doSimpleNoiseTool:
-          CBNT_CaloClusterTopoEM.CellDetailsNoiseTool = SimpleNoiseTool
       CBNT_AthenaAware += CBNT_CaloClusterTopoEM
 
       CBNT_CaloClusterTopoW = CBNTAA_CaloCluster("CBNT_CaloClusterTopoW" )
@@ -933,8 +892,6 @@ if doCBNT:
       CBNT_CaloClusterTopoW.AddCellDetails = doAddCellDetails
       CBNT_CaloClusterTopoW.MaxCaloCluster = 60
       CBNT_CaloClusterTopoW.MaxCell = 1024
-      if doSimpleNoiseTool:
-          CBNT_CaloClusterTopoW.CellDetailsNoiseTool = SimpleNoiseTool
       CBNT_AthenaAware += CBNT_CaloClusterTopoW
 
       CBNT_CaloClusterTopoOOC = CBNTAA_CaloCluster("CBNT_CaloClusterTopoOOC" )
@@ -945,8 +902,6 @@ if doCBNT:
       CBNT_CaloClusterTopoOOC.AddCellDetails = doAddCellDetails
       CBNT_CaloClusterTopoOOC.MaxCaloCluster = 60
       CBNT_CaloClusterTopoOOC.MaxCell = 1024
-      if doSimpleNoiseTool:
-          CBNT_CaloClusterTopoOOC.CellDetailsNoiseTool = SimpleNoiseTool
       CBNT_AthenaAware += CBNT_CaloClusterTopoOOC
 
    #  TB clusters part
@@ -958,8 +913,6 @@ if doCBNT:
       CBNT_TBCaloCluster.UseLink=TRUE
       CBNT_TBCaloCluster.AddCellDetails = doAddCellDetails
       CBNT_TBCaloCluster.MaxCell = 1024
-      if doSimpleNoiseTool:
-          CBNT_TBCaloCluster.CellDetailsNoiseTool = SimpleNoiseTool
       CBNT_AthenaAware += CBNT_TBCaloCluster
 
    if doMakeElecCluster:
@@ -970,8 +923,6 @@ if doCBNT:
       CBNT_EMTBCaloCluster.UseLink=TRUE
       CBNT_EMTBCaloCluster.AddCellDetails = doAddCellDetails
       CBNT_EMTBCaloCluster.MaxCell = 1024
-      if doSimpleNoiseTool:
-          CBNT_EMTBCaloCluster.CellDetailsNoiseTool = SimpleNoiseTool
       CBNT_AthenaAware += CBNT_EMTBCaloCluster
 
    #  Cells part
@@ -1020,12 +971,9 @@ if doTBTree:
     TBTree = TBTree_CaloClusterH6("TBTree")
     TBTree.OutputLevel      = OutputLevel
     TBTree.ClusterContainer = "TBClusters"
-    TBTree.NoiseToolName    = theCaloNoiseTool.getFullName()
-    TBTree.OFNoiseSuppToolName = ""
     if doMakeElecCluster:
         TBTree.useEMTBCluster   = True
     TBTree.Suffix           = "_tb"
-    TBTree.addNoise         = False
     TBTree.addMoments       = False
     TBTree.addGain          = True
     TBTree.addTime          = True
-- 
GitLab