40 for (
auto badError : SCT_ByteStreamErrors::BadErrors) {
42 ATH_MSG_FATAL(
"Logic error: Error code too large and cannot represented as a bit.");
47 return StatusCode::SUCCESS;
53 return StatusCode::SUCCESS;
80 ATH_MSG_INFO(
"SCT_ByteStreamErrorsTool Failed to retrieve BS error container "
82 <<
" from StoreGate.");
90 return idcErrCont.
cptr();
96 if (cacheEntry->needsUpdate(ctx)) {
98 if (idcErrContPtr ==
nullptr) {
99 cacheEntry->reset(ctx.evt(),
nullptr);
101 cacheEntry->reset(ctx.evt(), idcErrContPtr->cache());
103 ATH_MSG_VERBOSE(
"SCT_ByteStreamErrorsTool Cache for the event reset " << cacheEntry->eventId <<
" with IDC container" << idcErrContPtr);
116 std::scoped_lock<std::mutex> lock{*m_cacheMutex.get(ctx)};
117 ATH_MSG_VERBOSE(
"SCT_ByteStreamErrorsTool isGood called for " << elementIdHash);
119 if (idcCachePtr ==
nullptr) {
124 auto errorCode{idcCachePtr->retrieve(elementIdHash)};
128 ATH_MSG_VERBOSE(
"SCT_ByteStreamErrorsTool Bad Error " << errorCode <<
" for ID " << elementIdHash);
136 unsigned int badChips{
m_config->badChips(module_id, ctx)};
140 bool allChipsBad{
true};
143 bool issueABCDError{((v_abcdErrorChips >> chip) & 0
x1) != 0};
144 bool isBadChip{((badChips >> chip) & 0
x1) != 0};
145 bool isTempMaskedChip{((v_tempMaskedChips >> chip) & 0
x1) != 0};
146 allChipsBad = (issueABCDError or isBadChip or isTempMaskedChip);
147 if (not allChipsBad)
break;
153 unsigned int getValueOrZero(
const std::unordered_map<size_t, unsigned int> &map,
size_t key) {
154 std::unordered_map<size_t, unsigned int>::const_iterator iter = map.find(
key);
155 return iter != map.end() ? iter->second : 0;
163 std::scoped_lock<std::mutex> lock{*m_cacheMutex.get(ctx)};
166 if (idcCachePtr ==
nullptr || !idcCachePtr->IDCCache) {
171 ATH_MSG_ERROR(
"SCT_ByteStreamErrorsTool is not for conditions objects");
182 status.resize(idcCachePtr->IDCCache->rawReadAccess().size(),
true);
185 if (not si_element_list.isValid()) {
186 std::stringstream
msg;
188 throw std::runtime_error(
msg.str());
196 if (chip_status.empty()) {
197 chip_status.resize(
status.size(), all_flags_set);
199 unsigned int element_i=0;
200 for (
const auto &
val : idcCachePtr->IDCCache->rawReadAccess()) {
203 status.at(element_i) =
status.at(element_i) & not is_bad;
212 size_t modhash =
static_cast<size_t>(module_id.get_compact());
214 unsigned int badChips{
m_config->badChips(module_id, ctx)};
215 unsigned int v_abcdErrorChips{ getValueOrZero( idcCachePtr->abcdErrorChips, modhash) };
216 unsigned int v_tempMaskedChips{ getValueOrZero( idcCachePtr->tempMaskedChips, modhash) };
218 bool allChipsBad{
true};
222 bool issueABCDError{((v_abcdErrorChips >> chip) & 0
x1) != 0};
223 bool isBadChip{((badChips >> chip) & 0
x1) != 0};
224 bool isTempMaskedChip{((v_tempMaskedChips >> chip) & 0
x1) != 0};
225 bool isBad = (issueABCDError or isBadChip or isTempMaskedChip);
227 allChipsBad &= isBad;
229 status.at(element_i) =
status.at(element_i) & not allChipsBad;
230 chip_status.at(element_i) &= (~bad_chip_flags) & all_flags_set;
240 const EventContext& ctx{Gaudi::Hive::currentContext()};
242 return isGood(elementIdHash, ctx);
251 return isGood(elementIdHash, ctx);
262 const EventContext& ctx{Gaudi::Hive::currentContext()};
263 return isGood(elementId, ctx,
h);
271 if (not moduleId.is_valid()) {
272 ATH_MSG_WARNING(
"moduleId obtained from stripId " << stripId <<
" is invalid.");
284 const unsigned int v_abcdErrorChips{
abcdErrorChips(moduleId, ctx)};
286 const unsigned int badChips{v_tempMaskedChips | v_abcdErrorChips};
289 if (badChips==0)
return true;
296 if ((
side==0 and (badChips & 0x3F)==0) or (
side==1 and (badChips & 0xFC0)==0))
return true;
298 int chip{
getChip(stripId, ctx)};
299 if (chip<0 or chip>=12) {
305 const bool badChip{
static_cast<bool>(badChips & (1<<chip))};
307 return (not badChip);
315 if (siElement==
nullptr) {
316 ATH_MSG_DEBUG (
"InDetDD::SiDetectorElement is not obtained from stripId " << stripId);
329 std::set<IdentifierHash>
332 std::set<IdentifierHash>
result;
335 if (idcErrCont !=
nullptr) {
336 const std::set<size_t>& Mask = idcErrCont->
getMask();
337 const auto& raw = idcErrCont->wholeEventReadAccess();
338 for (
const size_t hashId : Mask) {
339 auto errCode = raw[hashId].load(std::memory_order_relaxed);
349 std::set<IdentifierHash>
351 const EventContext& ctx{Gaudi::Hive::currentContext()};
366 if (idcErrCont ==
nullptr) {
368 return StatusCode::SUCCESS;
373 unsigned int idcErrCont_set_number = idcErrCont->numberSet();
375 if (cacheEntry->m_set_number == idcErrCont_set_number){
377 return StatusCode::SUCCESS;
379 cacheEntry->m_set_number = idcErrCont_set_number;
385 ATH_MSG_VERBOSE(
"SCT_ByteStreamErrorsTool size of error container is " << idcErrCont->maxSize());
386 const std::vector<std::pair<size_t, uint64_t>> errorcodesforView{idcErrCont->getAll()};
388 for (
const auto& [ hashId, errCode ] : errorcodesforView) {
392 size_t hash =
static_cast<size_t>(module_id.get_compact());
398 cacheEntry->abcdErrorChips[
hash ];
399 cacheEntry->tempMaskedChips[
hash ];
404 ATH_MSG_VERBOSE(
"SCT_ByteStreamErrorsTool filling event cache for module " << module_id <<
" ec " << errCode);
411 if (v_abcdErrorChips) {
412 v_abcdErrorChips >>= SCT_ByteStreamErrors::ABCDError_Chip0;
414 cacheEntry->abcdErrorChips[
hash] |= v_abcdErrorChips;
416 cacheEntry->abcdErrorChips[
hash] = 0;
419 if (v_tempMaskedChips) {
420 v_tempMaskedChips >>= SCT_ByteStreamErrors::TempMaskedChip0;
422 cacheEntry->tempMaskedChips[
hash] |= v_tempMaskedChips;
424 cacheEntry->tempMaskedChips[
hash] = 0;
429 return StatusCode::SUCCESS;
436 std::scoped_lock<std::mutex> lock{*m_cacheMutex.get(ctx)};
438 if (cacheEntry->IDCCache ==
nullptr) {
445 ATH_MSG_ERROR(
"SCT_ByteStreamErrorsTool Failure getting temp masked chip errors");
447 return v_tempMaskedChips;
452 const EventContext& ctx{Gaudi::Hive::currentContext()};
458 std::scoped_lock<std::mutex> lock{*m_cacheMutex.get(ctx)};
460 if (cacheEntry->IDCCache ==
nullptr) {
467 ATH_MSG_ERROR(
"SCT_ByteStreamErrorsTool Failure getting ABCD chip errors");
469 return v_abcdErrorChips;
474 const EventContext& ctx{Gaudi::Hive::currentContext()};
479 std::unordered_map<size_t, unsigned int>& whereExected)
const {
480 ATH_MSG_VERBOSE(
"SCT_ByteStreamErrorsTool getErrorCodeWithCacheUpdate " << moduleId);
481 size_t modhash =
static_cast<size_t>(moduleId.
get_compact());
482 auto it{whereExected.find(modhash)};
483 if (
it != whereExected.end())
return std::make_pair(StatusCode::SUCCESS,
it->second);
491 cacheEntry->tempMaskedChips[modhash] = 0;
495 if (
sc.isFailure()) {
496 return std::make_pair(StatusCode::FAILURE, 0);
499 it = whereExected.find(modhash);
500 if (
it == whereExected.end()) {
501 ATH_MSG_ERROR(
"After fillData in abcdErrorChips, cache does not have an infomation about the " << moduleId);
502 ATH_MSG_ERROR(
"Likely cause is a request for for different region");
503 return std::make_pair(StatusCode::FAILURE, 0);
505 return std::make_pair(StatusCode::SUCCESS,
it->second);
510 if (not condData.isValid())
return nullptr;
511 return condData->getDetectorElement(waferHash);