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:
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;
};
......
......@@ -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;
}
}
......@@ -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);
......
......@@ -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);
......
......@@ -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
......
......@@ -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());
......
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