diff --git a/Calorimeter/CaloBadChannelTool/CaloBadChannelTool/CaloBadChanTool.h b/Calorimeter/CaloBadChannelTool/CaloBadChannelTool/CaloBadChanTool.h index db0b28852b32a6f2263f2bcec1677900e846d038..38c44b229ae63b5e11aaf8fe4a860224280bb9a9 100644 --- a/Calorimeter/CaloBadChannelTool/CaloBadChannelTool/CaloBadChanTool.h +++ b/Calorimeter/CaloBadChannelTool/CaloBadChannelTool/CaloBadChanTool.h @@ -22,17 +22,25 @@ public: CaloBadChanTool(const std::string& type, const std::string& name, const IInterface* parent); - virtual ~CaloBadChanTool(); + virtual ~CaloBadChanTool() override; - virtual StatusCode initialize(); - - virtual CaloBadChannel caloStatus( Identifier id) const; + virtual StatusCode initialize() override; + using ICaloBadChanTool::caloStatus; + virtual CaloBadChannel caloStatus(const EventContext& ctx, + Identifier id) const override; private: - - SG::ReadCondHandleKey<LArBadChannelCont> m_larBCKey{this, "LArBadChanKey", "LArBadChannel", "LAr bad channel SG key"}; - ToolHandle<ICaloBadChanTool> m_tileBCT{this, "TileBadChanTool", "TileBadChanTool", "Tile bad channel tool"}; + SG::ReadCondHandleKey<LArBadChannelCont> m_larBCKey{ + this, + "LArBadChanKey", + "LArBadChannel", + "LAr bad channel SG key" + }; + ToolHandle<ICaloBadChanTool> m_tileBCT{ this, + "TileBadChanTool", + "TileBadChanTool", + "Tile bad channel tool" }; const CaloCell_ID* m_caloID; }; diff --git a/Calorimeter/CaloBadChannelTool/src/CaloBadChanTool.cxx b/Calorimeter/CaloBadChannelTool/src/CaloBadChanTool.cxx index 9db108c108c322f476b2f67a7d5b50327bf7891d..70d49eb9916bdcadcc9d533af8f322e4f3cf4f62 100644 --- a/Calorimeter/CaloBadChannelTool/src/CaloBadChanTool.cxx +++ b/Calorimeter/CaloBadChannelTool/src/CaloBadChanTool.cxx @@ -6,7 +6,7 @@ //#include "GaudiKernel/MsgStream.h" -CaloBadChanTool::CaloBadChanTool(const std::string& type, const std::string& name, +CaloBadChanTool::CaloBadChanTool(const std::string& type, const std::string& name, const IInterface* parent) : AthAlgTool( type, name, parent), m_caloID(nullptr) @@ -26,7 +26,7 @@ StatusCode CaloBadChanTool::initialize() if (sc.isFailure()) { ATH_MSG_WARNING ( "Unable to initialize LAr bad channels key: no LAr bad channel info will be provided " ); } - else + else ATH_MSG_DEBUG ( "LAr bad channels key initialized" ); @@ -34,41 +34,40 @@ StatusCode CaloBadChanTool::initialize() if (sc.isFailure()) { ATH_MSG_WARNING ( "Unable to get TileBadChannelTool: no Tile bad channel info will be provided " ); } - else + else ATH_MSG_DEBUG ( "TileBadChannelTool retrieved" ); ATH_CHECK( detStore()->retrieve(m_caloID, "CaloCell_ID") ); return StatusCode::SUCCESS; } -CaloBadChannel CaloBadChanTool::caloStatus(Identifier id) const{ +CaloBadChannel +CaloBadChanTool::caloStatus(const EventContext& ctx, Identifier id) const +{ if (m_tileBCT && m_caloID->is_tile(id)) { - return m_tileBCT->caloStatus(id); - } - else if(m_caloID->is_lar(id)) { - SG::ReadCondHandle<LArBadChannelCont> bch{m_larBCKey}; - const LArBadChannelCont* bcCont{*bch}; - if(bcCont) { - CaloBadChannel::BitWord res = 0; - LArBadChannel lbc = bcCont->offlineStatus(id); - - if ( lbc.reallyNoisy() || lbc.sporadicBurstNoise()) { - CaloBadChannel::setBit( CaloBadChannel::noisyBit, res); - } - if (lbc.deadReadout() || lbc.deadPhys()) { - CaloBadChannel::setBit( CaloBadChannel::deadBit, res); - } - else if ( ! lbc.good()) { - CaloBadChannel::setBit( CaloBadChannel::affectedBit, res); - } - return CaloBadChannel(res); - } else { - CaloBadChannel empty; - return empty; - } - } - else { + return m_tileBCT->caloStatus(ctx,id); + } else if (m_caloID->is_lar(id)) { + SG::ReadCondHandle<LArBadChannelCont> bch{ m_larBCKey, ctx }; + const LArBadChannelCont* bcCont{ *bch }; + if (bcCont) { + CaloBadChannel::BitWord res = 0; + LArBadChannel lbc = bcCont->offlineStatus(id); + + if (lbc.reallyNoisy() || lbc.sporadicBurstNoise()) { + CaloBadChannel::setBit(CaloBadChannel::noisyBit, res); + } + if (lbc.deadReadout() || lbc.deadPhys()) { + CaloBadChannel::setBit(CaloBadChannel::deadBit, res); + } else if (!lbc.good()) { + CaloBadChannel::setBit(CaloBadChannel::affectedBit, res); + } + return CaloBadChannel(res); + } else { CaloBadChannel empty; return empty; + } + } else { + CaloBadChannel empty; + return empty; } } diff --git a/Calorimeter/CaloClusterCorrection/src/CaloClusterBadChannelList.cxx b/Calorimeter/CaloClusterCorrection/src/CaloClusterBadChannelList.cxx index c5bda73dddce237a31028aea9e6a61add20a0d90..920085af0c427587c8d8a40f130ea4c8a163abb4 100755 --- a/Calorimeter/CaloClusterCorrection/src/CaloClusterBadChannelList.cxx +++ b/Calorimeter/CaloClusterCorrection/src/CaloClusterBadChannelList.cxx @@ -35,7 +35,7 @@ StatusCode CaloClusterBadChannelList::initialize() } -void CaloClusterBadChannelList::makeCorrection (const Context& /*myctx*/, +void CaloClusterBadChannelList::makeCorrection (const Context& myctx, CaloCluster* cluster) const { xAOD::CaloClusterBadChannelList badChanList; @@ -44,8 +44,8 @@ void CaloClusterBadChannelList::makeCorrection (const Context& /*myctx*/, CaloCluster::cell_iterator cellIterEnd = cluster->cell_end(); for( ;cellIter!=cellIterEnd;cellIter++) { const CaloCell* cell = (*cellIter); - const Identifier id = cell->ID(); - CaloBadChannel status = m_badChannelTool->caloStatus(id); + const Identifier id = cell->ID(); + CaloBadChannel status = m_badChannelTool->caloStatus(myctx.ctx(),id); bool isBad = cell->badcell(); if (status.dead() || status.noisy() || isBad ) { const float eta = cell->eta(); @@ -56,8 +56,9 @@ void CaloClusterBadChannelList::makeCorrection (const Context& /*myctx*/, if (isBad && !status.dead()) { CaloBadChannel::setBit(CaloBadChannel::deadBit,myword,true); } - ATH_MSG_DEBUG(" bad channel found eta,phi,layer,status " << eta << " " << phi << " " << layer << " " << myword); - badChanList.emplace_back(eta,phi,layer,myword); + ATH_MSG_DEBUG(" bad channel found eta,phi,layer,status " + << eta << " " << phi << " " << layer << " " << myword); + badChanList.emplace_back(eta, phi, layer, myword); } } // end loop over cells cluster->setBadChannelList(badChanList); diff --git a/Calorimeter/CaloConditions/CaloConditions/ICaloBadChanTool.h b/Calorimeter/CaloConditions/CaloConditions/ICaloBadChanTool.h index 4aa9304052aff3b0c4ec4f319c03c80af7496791..11d50456c9cf6f18c069093194a0316273cc76c3 100644 --- a/Calorimeter/CaloConditions/CaloConditions/ICaloBadChanTool.h +++ b/Calorimeter/CaloConditions/CaloConditions/ICaloBadChanTool.h @@ -8,13 +8,22 @@ #include "Identifier/Identifier.h" #include "CaloConditions/CaloBadChannel.h" #include "GaudiKernel/IAlgTool.h" +#include "GaudiKernel/EventContext.h" +#include "GaudiKernel/ThreadLocalContext.h" + class ICaloBadChanTool : public virtual IAlgTool { public: virtual ~ICaloBadChanTool() {} - - virtual CaloBadChannel caloStatus( Identifier id) const = 0; + + virtual CaloBadChannel caloStatus(const EventContext& ctx, + Identifier id) const = 0; + + virtual CaloBadChannel caloStatus(Identifier id) const + { + return caloStatus(Gaudi::Hive::currentContext(), id); + } static const InterfaceID& interfaceID() { static const InterfaceID id("ICaloBadChanTool", 1 , 0); diff --git a/TileCalorimeter/TileConditions/TileConditions/TileBadChanTool.h b/TileCalorimeter/TileConditions/TileConditions/TileBadChanTool.h index f7af1ad527f9c8ee5597324dc4e469b655005038..52c7df546971a3b788ee5e01b2b0c530f7545acb 100644 --- a/TileCalorimeter/TileConditions/TileConditions/TileBadChanTool.h +++ b/TileCalorimeter/TileConditions/TileConditions/TileBadChanTool.h @@ -51,7 +51,9 @@ class TileBadChanTool: public extends<AthAlgTool, ITileBadChanTool, ICaloBadChan * @brief ICaloBadChanTool interface. * @param cell_id Calo cell identifier */ - virtual CaloBadChannel caloStatus(Identifier cell_id) const override; + using ICaloBadChanTool::caloStatus; + virtual CaloBadChannel caloStatus(const EventContext& ctx, + Identifier cell_id) const override; //=============================================================== //=== ITileBadChanTool methods diff --git a/TileCalorimeter/TileConditions/src/TileBadChanTool.cxx b/TileCalorimeter/TileConditions/src/TileBadChanTool.cxx index 7417de199984e25b6f27dcada43f34b7e3c1083b..9b70a2572c63bf870fbf957a7e1de7276db6f25b 100644 --- a/TileCalorimeter/TileConditions/src/TileBadChanTool.cxx +++ b/TileCalorimeter/TileConditions/src/TileBadChanTool.cxx @@ -81,7 +81,9 @@ StatusCode TileBadChanTool::finalize() { // //____________________________________________________________________ -CaloBadChannel TileBadChanTool::caloStatus(Identifier cell_id) const { +CaloBadChannel +TileBadChanTool::caloStatus(const EventContext& ctx, Identifier cell_id) const +{ CaloBadChannel::BitWord res = 0; @@ -94,7 +96,7 @@ CaloBadChannel TileBadChanTool::caloStatus(Identifier cell_id) const { std::abort(); } - SG::ReadCondHandle<TileBadChannels> badChannels(m_badChannelsKey); + SG::ReadCondHandle<TileBadChannels> badChannels(m_badChannelsKey,ctx); IdentifierHash hash1_id(elem->onl1()); IdentifierHash hash2_id(elem->onl2());