74 {
75
77
80 return StatusCode::SUCCESS;
81 }
82
83 EventIDRange eventRange;
84
85
86 std::unique_ptr<TileCalibData<TileCalibDrawerBch>> onlBchData
87 = std::make_unique<TileCalibData<TileCalibDrawerBch>>();
88
90 EventIDRange onlBchRange;
92 eventRange = EventIDRange::intersect(eventRange, onlBchRange);
93 }
94
95 std::unique_ptr<TileCalibData<TileCalibDrawerBch>> oflBchData
96 = std::make_unique<TileCalibData<TileCalibDrawerBch>>();
97
99 EventIDRange oflBchRange;
101 eventRange = EventIDRange::intersect(eventRange, oflBchRange);
102 }
103
104
105 std::unique_ptr<TileBadChannels> badChannelsData = std::make_unique<TileBadChannels>();
106
107 try {
108
109
111
113
116
117 unsigned int drawerIdx(0);
120
121 for (IdentifierHash adcHash = 0; adcHash < maxAdcHash; adcHash += 1) {
122 HWIdentifier adcId;
123 if (tileHWID->
get_id(adcHash, adcId, &adcContext) == 0) {
124
125 if (tileHWID->
ros(adcId) == 0)
continue;
126
128
130
131 std::vector<const TileCalibDrawerBch*> calibDrawers;
133
134 calibDrawers.push_back( onlBchData->getCalibDrawer(drawerIdx) );
135 }
136
138
139 calibDrawers.push_back( oflBchData->getCalibDrawer(drawerIdx) );
140 }
141
142 for (const TileCalibDrawerBch* calibDrawer : calibDrawers) {
144 calibDrawer->getStatusWords(channel, adc, adcBits, channelBits);
146 }
147
148 if (!adcStatus.
isGood()) {
149
151 badChannelsData->addAdcStatus(channelId, adcId, adcStatus);
152 }
153 }
154 }
155
156
157
158
159
160
161
162
163
164
165
166
167
168
170
174
176
177
180 if (channelStatus.isAffected()) {
181 ATH_MSG_INFO(
"Updating TileBchStatus::isBad() definition from DB" );
183 } else {
184 ATH_MSG_INFO(
"No TileBchStatus::isBad() definition found in DB, using defaults" );
185 }
186
187
190 if (channelStatus.isAffected()) {
191 ATH_MSG_INFO(
"Updating TileBchStatus::isNoisy() definition from DB" );
193 } else {
194 ATH_MSG_INFO(
"No TileBchStatus::isNoisy() definition found in DB, using defaults" );
195 }
196
197
200 if (channelStatus.isAffected()) {
201 ATH_MSG_INFO(
"Updating TileBchStatus::isNoGainL1() definition from DB" );
203 } else {
204 ATH_MSG_INFO(
"No TileBchStatus::isNoGainL1() definition found in DB, using defaults" );
205 }
206
207
208
211 if (channelStatus.isAffected()) {
212 ATH_MSG_INFO(
"Updating TileBchStatus::isBadTiming() definition from DB" );
214 } else {
215 ATH_MSG_INFO(
"No TileBchStatus::isBadTiming() definition found in DB, using defaults" );
216 }
217
218
221 if (channelStatus.isAffected()) {
222 ATH_MSG_INFO(
"Updating TileBchStatus::isWrongBCID() definition from DB" );
224 } else {
225 ATH_MSG_INFO(
"No TileBchStatus::isWrongBCID() definition found in DB, using defaults" );
226 }
227
228
231 ATH_MSG_INFO(
"TileBchStatus::isNoisy() is defined by: "
233 ATH_MSG_INFO(
"TileBchStatus::isNoGainL1() is defined by: "
235 ATH_MSG_INFO(
"TileBchStatus::isBadTiming() is defined by: "
237 ATH_MSG_INFO(
"TileBchStatus::isWrongBCID() is defined by: "
239
240
241 std::vector<int> maskedDrawers;
243 unsigned int maxChannels =
cabling->getMaxChannels();
244
251 HWIdentifier channelID = tileHWID->
channel_id(ros, drawer, channel);
252 cabling->h2s_cell_id_index(channelID, index, pmt);
253 if (index >= 0 && !badChannelsData->getChannelStatus(channelID).isBad()) {
254 break;
255 }
256 }
257 if (channel == maxChannels) maskedDrawers.push_back(tileHWID->
frag(ros, drawer));
258 }
259 }
260
261
263 if (!maskedDrawers.empty()) {
264 msg(MSG::DEBUG) <<
"List of fully masked drawers: " << MSG::hex;
265 for(int maskedDrawer : maskedDrawers) {
266 msg(MSG::DEBUG) <<
" 0x" << maskedDrawer;
267 }
269 } else {
270 msg(MSG::DEBUG) <<
"No bad drawers found" <<
endmsg;
271 }
272 }
273
274 if (!maskedDrawers.empty()) badChannelsData->setMaskedDrawers(std::move(maskedDrawers));
275
276
277
278
279
280
281
282
283
286
289
290
292
294
295
296
297
303 }
304 }
305
306 badChannelsData->setTripsProbabilities(std::move(tripsProbs));
307
308 } else {
309 ATH_MSG_INFO(
"No drawer trips probabilities found in DB");
310 }
311 }
312 } catch (TileCalib::Exception& e) {
314 return StatusCode::FAILURE;
315 }
316
317
318
319
320 if(badChannels.
record(eventRange, badChannelsData.release()).isFailure()) {
321 ATH_MSG_ERROR(
"Could not record TileBadChannels object with "
323 << " with EventRange " << eventRange
324 << " into Conditions Store");
325 return StatusCode::FAILURE;
326 } else {
327
330 << " with EventRange " << eventRange
331 << " into Conditions Store");
332 }
333
334
335
336 return StatusCode::SUCCESS;
337
338}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
bool msgLvl(const MSG::Level lvl) const
const std::string & key() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
SG::WriteCondHandleKey< TileBadChannels > m_badChannelsKey
Name of output TileBadChannels.
ToolHandle< ITileCondProxy< TileCalibDrawerBch > > m_onlBchProxy
Tool to provide online Tile bad channel status.
ToolHandle< ITileCondProxy< TileCalibDrawerBch > > m_oflBchProxy
Tool to provide ofline Tile bad channel status If it is provided online and offline Tile bad channel ...
ToolHandle< TileCondIdTransforms > m_tileIdTrans
ServiceHandle< TileCablingSvc > m_cablingSvc
Name of Tile cabling service.
static void initClassifierDefinitions()
static TileBchStatus getDefinitionNoisy()
static void defineNoGainL1(const TileBchStatus &status)
static TileBchStatus getDefinitionWrongBCID()
static void defineBadTiming(const TileBchStatus &status)
static TileBchStatus getDefinitionNoGainL1()
static TileBchStatus getDefinitionBadTiming()
static TileBchStatus getDefinitionBad()
static void defineNoisy(const TileBchStatus &status)
static void defineBad(const TileBchStatus &status)
static void defineWrongBCID(const TileBchStatus &status)
void getStatusWords(unsigned int channel, unsigned int adc, uint32_t &adcStatus, uint32_t &chnStatus) const
Extracts the adc and channel status words.
TileBchDecoder::BitPatVer getBitPatternVersion() const
Returns the bit pattern version.
static const unsigned int MAX_ROS
Number of ROSs.
static const unsigned int NOGAINL1_DEFINITION_CHAN
Channel used for storing of NoGainLevel1 channel definitions.
static const unsigned int BADTIMING_DEFINITION_CHAN
Channel used for storing of bad timing channel definitions.
static const unsigned int WRONGBCID_DEFINITION_CHAN
Channel used for storing of wrong BCID channel definitions.
static const unsigned int MAX_DRAWER
Number of drawers in ROS 1-4.
static const unsigned int NOISY_DEFINITION_CHAN
Channel used for storing of noisy channel definitions.
static const unsigned int TRIPS_DRAWERIDX
DrawerIdx used for storing trips probabilities.
static const unsigned int DEFINITIONS_DRAWERIDX
Drawer used for storing of bad and noisy channel definitions.
static const unsigned int BAD_DEFINITION_CHAN
Channel used for storing of bad channel definitions.
int frag(const HWIdentifier &id) const
extract frag field from HW identifier
size_type adc_hash_max() const
ADC hash table max size.
virtual int get_id(const IdentifierHash &hash_id, HWIdentifier &id, const IdContext *context=0) const
create compact HW ID from hash id (return == 0 for OK)
HWIdentifier channel_id(int ros, int drawer, int channel) const
channel HWIdentifer
IdContext adc_context() const
idContext for ADCs
int ros(const HWIdentifier &id) const
extract ros field from HW identifier
double decode(number_type binnedWeight)
Convert weight from unsigned to double.