Skip to content
Snippets Groups Projects
Commit 63704526 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

Merge branch 'CaloBadChanTool_EventContext_aware' into 'master'

Make CaloBanChanTool EventContext aware to avoid lookups

See merge request atlas/athena!39235
parents a7085710 a84d6d45
No related branches found
No related tags found
No related merge requests found
...@@ -22,17 +22,25 @@ public: ...@@ -22,17 +22,25 @@ public:
CaloBadChanTool(const std::string& type, const std::string& name, CaloBadChanTool(const std::string& type, const std::string& name,
const IInterface* parent); const IInterface* parent);
virtual ~CaloBadChanTool(); virtual ~CaloBadChanTool() override;
virtual StatusCode initialize(); virtual StatusCode initialize() override;
virtual CaloBadChannel caloStatus( Identifier id) const;
using ICaloBadChanTool::caloStatus;
virtual CaloBadChannel caloStatus(const EventContext& ctx,
Identifier id) const override;
private: private:
SG::ReadCondHandleKey<LArBadChannelCont> m_larBCKey{
SG::ReadCondHandleKey<LArBadChannelCont> m_larBCKey{this, "LArBadChanKey", "LArBadChannel", "LAr bad channel SG key"}; this,
ToolHandle<ICaloBadChanTool> m_tileBCT{this, "TileBadChanTool", "TileBadChanTool", "Tile bad channel tool"}; "LArBadChanKey",
"LArBadChannel",
"LAr bad channel SG key"
};
ToolHandle<ICaloBadChanTool> m_tileBCT{ this,
"TileBadChanTool",
"TileBadChanTool",
"Tile bad channel tool" };
const CaloCell_ID* m_caloID; const CaloCell_ID* m_caloID;
}; };
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
//#include "GaudiKernel/MsgStream.h" //#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) : const IInterface* parent) :
AthAlgTool( type, name, parent), AthAlgTool( type, name, parent),
m_caloID(nullptr) m_caloID(nullptr)
...@@ -26,7 +26,7 @@ StatusCode CaloBadChanTool::initialize() ...@@ -26,7 +26,7 @@ StatusCode CaloBadChanTool::initialize()
if (sc.isFailure()) { if (sc.isFailure()) {
ATH_MSG_WARNING ( "Unable to initialize LAr bad channels key: no LAr bad channel info will be provided " ); 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" ); ATH_MSG_DEBUG ( "LAr bad channels key initialized" );
...@@ -34,41 +34,40 @@ StatusCode CaloBadChanTool::initialize() ...@@ -34,41 +34,40 @@ StatusCode CaloBadChanTool::initialize()
if (sc.isFailure()) { if (sc.isFailure()) {
ATH_MSG_WARNING ( "Unable to get TileBadChannelTool: no Tile bad channel info will be provided " ); ATH_MSG_WARNING ( "Unable to get TileBadChannelTool: no Tile bad channel info will be provided " );
} }
else else
ATH_MSG_DEBUG ( "TileBadChannelTool retrieved" ); ATH_MSG_DEBUG ( "TileBadChannelTool retrieved" );
ATH_CHECK( detStore()->retrieve(m_caloID, "CaloCell_ID") ); ATH_CHECK( detStore()->retrieve(m_caloID, "CaloCell_ID") );
return StatusCode::SUCCESS; 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)) { if (m_tileBCT && m_caloID->is_tile(id)) {
return m_tileBCT->caloStatus(id); return m_tileBCT->caloStatus(ctx,id);
} } else if (m_caloID->is_lar(id)) {
else if(m_caloID->is_lar(id)) { SG::ReadCondHandle<LArBadChannelCont> bch{ m_larBCKey, ctx };
SG::ReadCondHandle<LArBadChannelCont> bch{m_larBCKey}; const LArBadChannelCont* bcCont{ *bch };
const LArBadChannelCont* bcCont{*bch}; if (bcCont) {
if(bcCont) { CaloBadChannel::BitWord res = 0;
CaloBadChannel::BitWord res = 0; LArBadChannel lbc = bcCont->offlineStatus(id);
LArBadChannel lbc = bcCont->offlineStatus(id);
if (lbc.reallyNoisy() || lbc.sporadicBurstNoise()) {
if ( lbc.reallyNoisy() || lbc.sporadicBurstNoise()) { CaloBadChannel::setBit(CaloBadChannel::noisyBit, res);
CaloBadChannel::setBit( CaloBadChannel::noisyBit, res); }
} if (lbc.deadReadout() || lbc.deadPhys()) {
if (lbc.deadReadout() || lbc.deadPhys()) { CaloBadChannel::setBit(CaloBadChannel::deadBit, res);
CaloBadChannel::setBit( CaloBadChannel::deadBit, res); } else if (!lbc.good()) {
} CaloBadChannel::setBit(CaloBadChannel::affectedBit, res);
else if ( ! lbc.good()) { }
CaloBadChannel::setBit( CaloBadChannel::affectedBit, res); return CaloBadChannel(res);
} } else {
return CaloBadChannel(res);
} else {
CaloBadChannel empty;
return empty;
}
}
else {
CaloBadChannel empty; CaloBadChannel empty;
return empty; return empty;
}
} else {
CaloBadChannel empty;
return empty;
} }
} }
...@@ -35,7 +35,7 @@ StatusCode CaloClusterBadChannelList::initialize() ...@@ -35,7 +35,7 @@ StatusCode CaloClusterBadChannelList::initialize()
} }
void CaloClusterBadChannelList::makeCorrection (const Context& /*myctx*/, void CaloClusterBadChannelList::makeCorrection (const Context& myctx,
CaloCluster* cluster) const CaloCluster* cluster) const
{ {
xAOD::CaloClusterBadChannelList badChanList; xAOD::CaloClusterBadChannelList badChanList;
...@@ -44,8 +44,8 @@ void CaloClusterBadChannelList::makeCorrection (const Context& /*myctx*/, ...@@ -44,8 +44,8 @@ void CaloClusterBadChannelList::makeCorrection (const Context& /*myctx*/,
CaloCluster::cell_iterator cellIterEnd = cluster->cell_end(); CaloCluster::cell_iterator cellIterEnd = cluster->cell_end();
for( ;cellIter!=cellIterEnd;cellIter++) { for( ;cellIter!=cellIterEnd;cellIter++) {
const CaloCell* cell = (*cellIter); const CaloCell* cell = (*cellIter);
const Identifier id = cell->ID(); const Identifier id = cell->ID();
CaloBadChannel status = m_badChannelTool->caloStatus(id); CaloBadChannel status = m_badChannelTool->caloStatus(myctx.ctx(),id);
bool isBad = cell->badcell(); bool isBad = cell->badcell();
if (status.dead() || status.noisy() || isBad ) { if (status.dead() || status.noisy() || isBad ) {
const float eta = cell->eta(); const float eta = cell->eta();
...@@ -56,8 +56,9 @@ void CaloClusterBadChannelList::makeCorrection (const Context& /*myctx*/, ...@@ -56,8 +56,9 @@ void CaloClusterBadChannelList::makeCorrection (const Context& /*myctx*/,
if (isBad && !status.dead()) { if (isBad && !status.dead()) {
CaloBadChannel::setBit(CaloBadChannel::deadBit,myword,true); CaloBadChannel::setBit(CaloBadChannel::deadBit,myword,true);
} }
ATH_MSG_DEBUG(" bad channel found eta,phi,layer,status " << eta << " " << phi << " " << layer << " " << myword); ATH_MSG_DEBUG(" bad channel found eta,phi,layer,status "
badChanList.emplace_back(eta,phi,layer,myword); << eta << " " << phi << " " << layer << " " << myword);
badChanList.emplace_back(eta, phi, layer, myword);
} }
} // end loop over cells } // end loop over cells
cluster->setBadChannelList(badChanList); cluster->setBadChannelList(badChanList);
......
...@@ -8,13 +8,22 @@ ...@@ -8,13 +8,22 @@
#include "Identifier/Identifier.h" #include "Identifier/Identifier.h"
#include "CaloConditions/CaloBadChannel.h" #include "CaloConditions/CaloBadChannel.h"
#include "GaudiKernel/IAlgTool.h" #include "GaudiKernel/IAlgTool.h"
#include "GaudiKernel/EventContext.h"
#include "GaudiKernel/ThreadLocalContext.h"
class ICaloBadChanTool : public virtual IAlgTool { class ICaloBadChanTool : public virtual IAlgTool {
public: public:
virtual ~ICaloBadChanTool() {} 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& interfaceID() {
static const InterfaceID id("ICaloBadChanTool", 1 , 0); static const InterfaceID id("ICaloBadChanTool", 1 , 0);
......
...@@ -51,7 +51,9 @@ class TileBadChanTool: public extends<AthAlgTool, ITileBadChanTool, ICaloBadChan ...@@ -51,7 +51,9 @@ class TileBadChanTool: public extends<AthAlgTool, ITileBadChanTool, ICaloBadChan
* @brief ICaloBadChanTool interface. * @brief ICaloBadChanTool interface.
* @param cell_id Calo cell identifier * @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 //=== ITileBadChanTool methods
......
...@@ -81,7 +81,9 @@ StatusCode TileBadChanTool::finalize() { ...@@ -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; CaloBadChannel::BitWord res = 0;
...@@ -94,7 +96,7 @@ CaloBadChannel TileBadChanTool::caloStatus(Identifier cell_id) const { ...@@ -94,7 +96,7 @@ CaloBadChannel TileBadChanTool::caloStatus(Identifier cell_id) const {
std::abort(); std::abort();
} }
SG::ReadCondHandle<TileBadChannels> badChannels(m_badChannelsKey); SG::ReadCondHandle<TileBadChannels> badChannels(m_badChannelsKey,ctx);
IdentifierHash hash1_id(elem->onl1()); IdentifierHash hash1_id(elem->onl1());
IdentifierHash hash2_id(elem->onl2()); IdentifierHash hash2_id(elem->onl2());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment