ATLAS Offline Software
Loading...
Searching...
No Matches
TileBadChanTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Tile includes
10
11// Calo includes
12#include "CaloDetDescr/CaloDetDescrElement.h"
13
14// Athena incldues
17
18// Gaudi includes
19#include "GaudiKernel/EventContext.h"
20
21#include <string>
22#include <algorithm>
23
24
25//
26//____________________________________________________________________
27TileBadChanTool::TileBadChanTool(const std::string& type, const std::string& name, const IInterface* parent)
28 : base_class(type, name, parent)
29 , m_tileMgr(nullptr)
30 , m_tileHWID(nullptr)
32 , m_defaultTripsProbs(TileCalibUtils::MAX_DRAWER, 0.0F)
33{
34
35}
36
37//
38//____________________________________________________________________
42
43
44//
45//____________________________________________________________________
47 ATH_MSG_DEBUG( "in initialize()" );
48
49 //=== Initialize bad channels key
50 ATH_CHECK( m_badChannelsKey.initialize() );
51
52 //=== TileDetDescrManager
53 ATH_CHECK( detStore()->retrieve(m_tileMgr) );
54
55 //=== TileDetDescrManager
56 ATH_CHECK( detStore()->retrieve(m_tileHWID) );
57
60
61 for (unsigned int ros = 0; ros < TileCalibUtils::MAX_ROS; ++ros) {
62 for (unsigned int drawer = 0; drawer < TileCalibUtils::getMaxDrawer(ros); ++drawer) {
63 unsigned int drawerIdx = TileCalibUtils::getDrawerIdx(ros, drawer);
64 m_roses[drawerIdx] = ros;
65 m_drawers[drawerIdx] = drawer;
66 }
67 }
68
69
70 return StatusCode::SUCCESS;
71}
72
73//
74//____________________________________________________________________
76
77 ATH_MSG_DEBUG( "finalize called" );
78 return StatusCode::SUCCESS;
79
80}
81
82//
83//____________________________________________________________________
85TileBadChanTool::caloStatus(const EventContext& ctx, Identifier cell_id) const
86{
87
89
90 //=== get the TileHWIDs of the two channels connected to the caloCellnxs id
91 const CaloDetDescrElement* elem = m_tileMgr->get_cell_element(cell_id);
92
93 if (!elem) {
94 //=== this should never happen
95 ATH_MSG_ERROR( "CaloMgr returns NULL CaloDetDescrElement" );
96 std::abort();
97 }
98
100
101 IdentifierHash hash1_id(elem->onl1());
102 IdentifierHash hash2_id(elem->onl2());
103
104 //=== status of 1. connected channel
105 TileBchStatus channel1_status = (hash1_id != TileHWID::NOT_VALID_HASH) ?
106 badChannels->getChannelStatus(m_tileHWID->channel_id(hash1_id)) : m_defaultStatus;
107
108 //=== status of 2. connected channel
109 TileBchStatus channel2_status = (hash2_id != TileHWID::NOT_VALID_HASH) ?
110 badChannels->getChannelStatus(m_tileHWID->channel_id(hash2_id)) : m_defaultStatus;
111
112 //=== set cell status depending on channel status
113 if (channel1_status.isBad() && channel2_status.isBad()) {
115 } else if (channel1_status.isAffected() || channel2_status.isAffected()) {
117 }
118
119 return CaloBadChannel(res);
120}
121
122//
123//____________________________________________________________________
124const TileBchStatus&
125TileBadChanTool::getAdcStatus(const HWIdentifier& adc_id, const EventContext& ctx) const {
126
128 return badChannels->getAdcStatus(adc_id);
129
130}
131
132//
133//____________________________________________________________________
134const TileBchStatus&
135TileBadChanTool::getAdcStatus(IdentifierHash hash_id, unsigned int adc) const {
136
137 if (hash_id != TileHWID::NOT_VALID_HASH) {
138 HWIdentifier adc_id = m_tileHWID->adc_id(hash_id, adc);
139
141 return badChannels->getAdcStatus(adc_id);
142 } else {
143 return m_defaultStatus;
144 }
145
146}
147
148//
149//____________________________________________________________________
150const TileBchStatus&
152
153 if (hash_id != TileHWID::NOT_VALID_HASH) {
154 HWIdentifier channel_id = m_tileHWID->channel_id(hash_id);
155
157 return badChannels->getChannelStatus(channel_id);
158 } else {
159 return m_defaultStatus;
160 }
161
162}
163
164//
165//____________________________________________________________________
166const TileBchStatus&
167TileBadChanTool::getChannelStatus(const HWIdentifier& channel_id, const EventContext& ctx) const {
168
170 return badChannels->getChannelStatus(channel_id);
171
172}
173
174//
175//____________________________________________________________________
176const TileBchStatus&
177TileBadChanTool::getChannelStatus(unsigned int drawerIdx, unsigned int channel, const EventContext& ctx) const {
178
179 HWIdentifier channel_id = m_tileHWID->channel_id(m_roses[drawerIdx], m_drawers[drawerIdx], channel);
180
182 return badChannels->getChannelStatus(channel_id);
183
184}
185
186//
187//____________________________________________________________________
188const TileBchStatus&
189TileBadChanTool::getAdcStatus(unsigned int drawerIdx, unsigned int channel, unsigned int adc, const EventContext& ctx) const {
190
191 HWIdentifier adc_id = m_tileHWID->adc_id(m_roses[drawerIdx], m_drawers[drawerIdx], channel, adc);
192
194 return badChannels->getAdcStatus(adc_id);
195
196}
197
198//
199//____________________________________________________________________
200uint32_t TileBadChanTool::encodeStatus(const TileBchStatus& status) const {
201 return TileBadChannels::encodeStatus(status);
202}
203
204const std::vector<float>& TileBadChanTool::getTripsProbabilities(unsigned int ros, const EventContext& ctx) const {
205
207
208 const std::vector<std::vector<float>>& tripsProbs = badChannels->getTripsProbabilities();
209
210 if (!tripsProbs.empty()) {
211 return tripsProbs.at(ros - 1);
212 }
213
214 return m_defaultTripsProbs;
215}
216
217bool TileBadChanTool::isDrawerMasked(unsigned int frag_id, const EventContext& ctx) const {
218
220 const std::vector<int>& maskedDrawers = badChannels->getMaskedDrawers();
221
222 return std::binary_search (maskedDrawers.begin(),
223 maskedDrawers.end(),
224 frag_id);
225}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
Helpers for checking error return status codes and reporting errors.
std::pair< std::vector< unsigned int >, bool > res
unsigned int BitWord
static void setBit(ProblemType pb, BitWord &word, bool value=true)
Sets the bit corresponding to "pb" inside the word passed as second argument to "value".
This class groups all DetDescr information related to a CaloCell.
This is a "hash" representation of an Identifier.
const TileHWID * m_tileHWID
SG::ReadCondHandleKey< TileBadChannels > m_badChannelsKey
Name of TileBadChannels in condition store.
const TileBchStatus & getChannelStatus(IdentifierHash hash_id) const
TileBchStatus m_defaultStatus
virtual bool isDrawerMasked(unsigned int frag_id, const EventContext &ctx) const override
Check if Tile drawer is masked completely.
std::vector< float > m_defaultTripsProbs
const TileDetDescrManager * m_tileMgr
const TileBchStatus & getAdcStatus(IdentifierHash hash_id, unsigned int adc) const
TileBadChanTool(const std::string &type, const std::string &name, const IInterface *parent)
std::vector< unsigned int > m_roses
virtual StatusCode initialize() override
virtual const std::vector< float > & getTripsProbabilities(unsigned int ros, const EventContext &ctx) const override
Return trips probabilities for all Tile drawers.
virtual StatusCode finalize() override
virtual ~TileBadChanTool()
std::vector< unsigned int > m_drawers
virtual uint32_t encodeStatus(const TileBchStatus &status) const override
virtual CaloBadChannel caloStatus(const EventContext &ctx, Identifier cell_id) const override
static uint32_t encodeStatus(const TileBchStatus &status)
Class holding bad channel problems.
bool isAffected() const
bool isBad() const
Static class providing several utility functions and constants.
static const unsigned int MAX_DRAWERIDX
Maximal drawer index.
static const unsigned int MAX_ROS
Number of ROSs.
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
static unsigned int getMaxDrawer(unsigned int ros)
Returns the maximal channel number for a given drawer.
@ NOT_VALID_HASH
Definition TileHWID.h:314