From d1b796c6013ad57d17141d63e1b88a778e48ea9e Mon Sep 17 00:00:00 2001 From: Scott Snyder <scott.snyder@cern.ch> Date: Wed, 25 Jan 2017 03:42:18 +0100 Subject: [PATCH] 'Migrate CaloLCOutOfClusterTool to CondHandle. Fix CondHandle key property for CaloLCClassificationTool.' (CaloUtils-01-01-02) * Tagging CaloUtils-01-01-02. * CaloUtils/CaloLCOutOfClusterTool.h, src/CaloLCOutOfClusterTool.cxx: Migrate to CondHandle. * CaloUtils/CaloLCClassificationTool.h, src/CaloLCClassificationTool.cxx: Fix ReadCondHandleKey property. 2017-01-24 Vakho Tsulaia <tsulaia@cern.ch> * Dropping the obsolete IClusterClassificationTool::LoadConditionsData() * Tagging CaloUtils-01-01-01 Former-commit-id: fe98f9866d927c7ab6bd3ff7f1b8a20f5023ffc5 --- .../CaloUtils/CaloLCClassificationTool.h | 11 +---- .../CaloUtils/CaloLCOutOfClusterTool.h | 13 +----- .../EstimEMClusterClassificationTool.h | 3 -- .../src/CaloLCClassificationTool.cxx | 21 ++-------- .../CaloUtils/src/CaloLCOutOfClusterTool.cxx | 41 ++++++------------- 5 files changed, 19 insertions(+), 70 deletions(-) diff --git a/Calorimeter/CaloUtils/CaloUtils/CaloLCClassificationTool.h b/Calorimeter/CaloUtils/CaloUtils/CaloLCClassificationTool.h index 714653d6583..6e65e5344e5 100644 --- a/Calorimeter/CaloUtils/CaloUtils/CaloLCClassificationTool.h +++ b/Calorimeter/CaloUtils/CaloUtils/CaloLCClassificationTool.h @@ -37,8 +37,6 @@ class CaloLCClassificationTool : public AthAlgTool, virtual public IClusterClass const override; virtual StatusCode initialize() override; - virtual StatusCode LoadConditionsData(IOVSVC_CALLBACK_ARGS) override; - CaloLCClassificationTool(const std::string& type, const std::string& name, const IInterface* parent); @@ -47,14 +45,7 @@ class CaloLCClassificationTool : public AthAlgTool, virtual public IClusterClass /** * @brief name of the key for em fraction data */ - std::string m_key; - - /** - * @brief data object containing the em probabilities - * - * This object contains the actual data used for classification. */ - - SG::ReadCondHandleKey<CaloLocalHadCoeff> m_rchk; + SG::ReadCondHandleKey<CaloLocalHadCoeff> m_key; /** * @brief if set to true the spread of EM probabilities in each bin is diff --git a/Calorimeter/CaloUtils/CaloUtils/CaloLCOutOfClusterTool.h b/Calorimeter/CaloUtils/CaloUtils/CaloLCOutOfClusterTool.h index f41ed6fca1f..f49e0d3ab23 100644 --- a/Calorimeter/CaloUtils/CaloUtils/CaloLCOutOfClusterTool.h +++ b/Calorimeter/CaloUtils/CaloUtils/CaloLCOutOfClusterTool.h @@ -20,7 +20,7 @@ #include "CaloInterface/IClusterCellWeightTool.h" #include "CaloConditions/CaloLocalHadCoeff.h" -#include "StoreGate/DataHandle.h" +#include "StoreGate/ReadCondHandleKey.h" #include "AthenaBaseComps/AthAlgTool.h" class CaloLCOutOfClusterTool : public AthAlgTool, virtual public IClusterCellWeightTool @@ -32,8 +32,6 @@ class CaloLCOutOfClusterTool : public AthAlgTool, virtual public IClusterCellWei virtual StatusCode weight(xAOD::CaloCluster* theCluster) const override; virtual StatusCode initialize() override; - virtual StatusCode LoadConditionsData(IOVSVC_CALLBACK_ARGS) override; - CaloLCOutOfClusterTool(const std::string& type, const std::string& name, const IInterface* parent); @@ -42,7 +40,7 @@ class CaloLCOutOfClusterTool : public AthAlgTool, virtual public IClusterCellWei /** * @brief name of the key for out-of-cluster weights */ - std::string m_key; + SG::ReadCondHandleKey<CaloLocalHadCoeff> m_key; /** * @brief look for em-probability moment and apply relative weight only @@ -76,13 +74,6 @@ class CaloLCOutOfClusterTool : public AthAlgTool, virtual public IClusterCellWei * m_invalidSamplingNames. */ std::set<int> m_invalidSamplings; - /** - * @brief data object containing the out-of-cluster constants - * - * This object contains the actual data used for calibration. */ - - const DataHandle<CaloLocalHadCoeff> m_data; - /** * @brief interpolate correction coefficients */ bool m_interpolate; diff --git a/Calorimeter/CaloUtils/CaloUtils/EstimEMClusterClassificationTool.h b/Calorimeter/CaloUtils/CaloUtils/EstimEMClusterClassificationTool.h index 8bc2a55d943..6c038ec8ea0 100644 --- a/Calorimeter/CaloUtils/CaloUtils/EstimEMClusterClassificationTool.h +++ b/Calorimeter/CaloUtils/CaloUtils/EstimEMClusterClassificationTool.h @@ -37,9 +37,6 @@ class EstimEMClusterClassificationTool : public AthAlgTool, virtual public IClus const override; virtual StatusCode initialize() override; - virtual StatusCode LoadConditionsData(IOVSVC_CALLBACK_ARGS) override - { return StatusCode::SUCCESS;} - EstimEMClusterClassificationTool(const std::string& type, const std::string& name, const IInterface* parent); diff --git a/Calorimeter/CaloUtils/src/CaloLCClassificationTool.cxx b/Calorimeter/CaloUtils/src/CaloLCClassificationTool.cxx index 06045cbb19d..c8c1119e462 100644 --- a/Calorimeter/CaloUtils/src/CaloLCClassificationTool.cxx +++ b/Calorimeter/CaloUtils/src/CaloLCClassificationTool.cxx @@ -31,8 +31,7 @@ CaloLCClassificationTool::CaloLCClassificationTool(const std::string& type, const std::string& name, const IInterface* parent) : AthAlgTool(type,name,parent), - m_key("EMFrac"), - m_rchk("EMFracClassify"), + m_key("EMFracClassify"), m_useSpread(false), m_useNormalizedEnergyDensity(true), m_maxProbability(0.5), @@ -63,20 +62,13 @@ CaloLCClassificationTool::CaloLCClassificationTool(const std::string& type, m_interpolateDimensionNames[1] = "DIMC_EDENS"; m_interpolateDimensionNames[2] = "DIMC_LAMBDA"; declareProperty("InterpolateDimensionNames", m_interpolateDimensionNames); - declareProperty("CondhandleKey",m_rchk); } StatusCode CaloLCClassificationTool::initialize() { ATH_MSG_INFO( "Initializing " << name() ); - if (m_rchk.initialize().isFailure()) { - ATH_MSG_ERROR("unable to initialize ReadCondHandleKey" << m_rchk.fullKey()); - return StatusCode::FAILURE; - } - else { - ATH_MSG_DEBUG("Initialized ReadCondHandleKey " << m_rchk.fullKey()); - } + ATH_CHECK( m_key.initialize() ); if(m_interpolate) { msg(MSG::INFO) << "Interpolation is ON, dimensions: "; @@ -100,7 +92,7 @@ StatusCode CaloLCClassificationTool::initialize() CaloRecoStatus::StatusIndicator CaloLCClassificationTool::classify(CaloCluster* thisCluster) const { const CaloLocalHadCoeff* condObject(0); - SG::ReadCondHandle<CaloLocalHadCoeff> rch(m_rchk); + SG::ReadCondHandle<CaloLocalHadCoeff> rch(m_key); condObject = *rch; if(condObject==0) { ATH_MSG_ERROR("Unable to access conditions object"); @@ -207,10 +199,3 @@ CaloLCClassificationTool::~CaloLCClassificationTool() { } - -StatusCode CaloLCClassificationTool::LoadConditionsData(IOVSVC_CALLBACK_ARGS_K(keys)) -{ - ATH_MSG_DEBUG("Callback invoked for " << keys.size() << " keys"); - ATH_MSG_INFO("Dummy Callback. Should never be called!"); - return StatusCode::SUCCESS; -} diff --git a/Calorimeter/CaloUtils/src/CaloLCOutOfClusterTool.cxx b/Calorimeter/CaloUtils/src/CaloLCOutOfClusterTool.cxx index e058098ca38..f6e8bc0985c 100644 --- a/Calorimeter/CaloUtils/src/CaloLCOutOfClusterTool.cxx +++ b/Calorimeter/CaloUtils/src/CaloLCOutOfClusterTool.cxx @@ -127,10 +127,7 @@ StatusCode CaloLCOutOfClusterTool::initialize() } // callback for conditions data - ATH_CHECK( detStore()->regFcn(&IClusterCellWeightTool::LoadConditionsData, - dynamic_cast<IClusterCellWeightTool*>(this), - m_data,m_key) ); - ATH_MSG_INFO( "Registered callback for key: " << m_key ); + ATH_CHECK( m_key.initialize() ); return StatusCode::SUCCESS; } @@ -198,8 +195,15 @@ StatusCode CaloLCOutOfClusterTool::weight(CaloCluster *theCluster) const } double log10cluse = log10(eEM); - - const CaloLocalHadCoeff::LocalHadDimension *logeDim = m_data->getArea(0)->getDimension(2); + + SG::ReadCondHandle<CaloLocalHadCoeff> h (m_key); + const CaloLocalHadCoeff* data = *h; + if (!data) { + ATH_MSG_ERROR("Unable to access conditions object"); + return CaloRecoStatus::TAGGEDUNKNOWN; + } + + const CaloLocalHadCoeff::LocalHadDimension *logeDim = data->getArea(0)->getDimension(2); double lemax = logeDim->getXmax()-0.5*logeDim->getDx(); double lemin = logeDim->getXmin()+0.5*logeDim->getDx(); if ( log10cluse > lemax ) @@ -225,9 +229,9 @@ StatusCode CaloLCOutOfClusterTool::weight(CaloCluster *theCluster) const double oocData(0); // accessing coefficients (non-interpolated) - int iBin = m_data->getBin(0,vars); + int iBin = data->getBin(0,vars); if ( iBin >= 0 ) { - const CaloLocalHadCoeff::LocalHadCoeff * pData = m_data->getCoeff(iBin); + const CaloLocalHadCoeff::LocalHadCoeff * pData = data->getCoeff(iBin); if ( pData && (*pData)[CaloLocalHadDefs::BIN_ENTRIES] > 0 ) { isDataOK = true; oocData = (*pData)[CaloLocalHadDefs::BIN_WEIGHT]; @@ -235,7 +239,7 @@ StatusCode CaloLCOutOfClusterTool::weight(CaloCluster *theCluster) const if(m_interpolate) { // accesing interpolated coefficients CaloLocalHadCoeff::LocalHadCoeff parint; - bool isa = hp.Interpolate(m_data, 0,vars,parint, m_interpolateDimensions); + bool isa = hp.Interpolate(data, 0,vars,parint, m_interpolateDimensions); if(isa && parint[CaloLocalHadDefs::BIN_ENTRIES] > 0) { isDataOK = true; oocData = parint[CaloLocalHadDefs::BIN_WEIGHT]; @@ -296,22 +300,3 @@ CaloLCOutOfClusterTool::~CaloLCOutOfClusterTool() } -StatusCode CaloLCOutOfClusterTool::LoadConditionsData(IOVSVC_CALLBACK_ARGS_K(keys)) -{ - ATH_MSG_DEBUG("Callback invoked for "<< keys.size() << " keys"); - - for (std::list<std::string>::const_iterator itr=keys.begin(); - itr!=keys.end(); ++itr) { - std::string key = *itr; - ATH_MSG_DEBUG("key = " << key); - if(key==m_key) { - ATH_MSG_DEBUG("retrieve CaloLocalHadCoeff"); - ATH_CHECK( detStore()->retrieve(m_data,m_key) ); - } - } - return StatusCode::SUCCESS; -} - - - - -- GitLab