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)};
126 for (
auto badError : SCT_ByteStreamErrors::BadErrors) {
128 ATH_MSG_VERBOSE(
"SCT_ByteStreamErrorsTool Bad Error " << errorCode <<
" for ID " << elementIdHash);
137 unsigned int badChips{
m_config->badChips(module_id, ctx)};
141 bool allChipsBad{
true};
144 bool issueABCDError{((v_abcdErrorChips >> chip) & 0
x1) != 0};
145 bool isBadChip{((badChips >> chip) & 0
x1) != 0};
146 bool isTempMaskedChip{((v_tempMaskedChips >> chip) & 0
x1) != 0};
147 allChipsBad = (issueABCDError or isBadChip or isTempMaskedChip);
148 if (not allChipsBad)
break;
154 unsigned int getValueOrZero(
const std::unordered_map<size_t, unsigned int> &map,
size_t key) {
155 std::unordered_map<size_t, unsigned int>::const_iterator iter = map.find(
key);
156 return iter != map.end() ? iter->second : 0;
164 std::scoped_lock<std::mutex> lock{*m_cacheMutex.get(ctx)};
167 if (idcCachePtr ==
nullptr || !idcCachePtr->IDCCache) {
172 ATH_MSG_ERROR(
"SCT_ByteStreamErrorsTool is not for conditions objects");
183 status.resize(idcCachePtr->IDCCache->rawReadAccess().size(),
true);
186 if (not si_element_list.isValid()) {
187 std::stringstream
msg;
189 throw std::runtime_error(
msg.str());
197 if (chip_status.empty()) {
198 chip_status.resize(
status.size(), all_flags_set);
200 unsigned int element_i=0;
201 for (
const auto &
val : idcCachePtr->IDCCache->rawReadAccess()) {
204 status.at(element_i) =
status.at(element_i) & not is_bad;
213 size_t modhash =
static_cast<size_t>(module_id.get_compact());
215 unsigned int badChips{
m_config->badChips(module_id, ctx)};
216 unsigned int v_abcdErrorChips{ getValueOrZero( idcCachePtr->abcdErrorChips, modhash) };
217 unsigned int v_tempMaskedChips{ getValueOrZero( idcCachePtr->tempMaskedChips, modhash) };
219 bool allChipsBad{
true};
223 bool issueABCDError{((v_abcdErrorChips >> chip) & 0
x1) != 0};
224 bool isBadChip{((badChips >> chip) & 0
x1) != 0};
225 bool isTempMaskedChip{((v_tempMaskedChips >> chip) & 0
x1) != 0};
226 bool isBad = (issueABCDError or isBadChip or isTempMaskedChip);
228 allChipsBad &= isBad;
230 status.at(element_i) =
status.at(element_i) & not allChipsBad;
231 chip_status.at(element_i) &= (~bad_chip_flags) & all_flags_set;
241 const EventContext& ctx{Gaudi::Hive::currentContext()};
243 return isGood(elementIdHash, ctx);
252 return isGood(elementIdHash, ctx);
263 const EventContext& ctx{Gaudi::Hive::currentContext()};
264 return isGood(elementId, ctx,
h);
272 if (not moduleId.is_valid()) {
273 ATH_MSG_WARNING(
"moduleId obtained from stripId " << stripId <<
" is invalid.");
285 const unsigned int v_abcdErrorChips{
abcdErrorChips(moduleId, ctx)};
287 const unsigned int badChips{v_tempMaskedChips | v_abcdErrorChips};
290 if (badChips==0)
return true;
297 if ((
side==0 and (badChips & 0x3F)==0) or (
side==1 and (badChips & 0xFC0)==0))
return true;
299 int chip{
getChip(stripId, ctx)};
300 if (chip<0 or chip>=12) {
306 const bool badChip{
static_cast<bool>(badChips & (1<<chip))};
308 return (not badChip);
316 if (siElement==
nullptr) {
317 ATH_MSG_DEBUG (
"InDetDD::SiDetectorElement is not obtained from stripId " << stripId);
330 std::set<IdentifierHash>
333 std::set<IdentifierHash>
result;
336 if (idcErrCont !=
nullptr) {
337 const std::set<size_t>& Mask = idcErrCont->
getMask();
338 const auto& raw = idcErrCont->wholeEventReadAccess();
339 for (
const size_t hashId : Mask) {
340 auto errCode = raw[hashId].load(std::memory_order_relaxed);
350 std::set<IdentifierHash>
352 const EventContext& ctx{Gaudi::Hive::currentContext()};
367 if (idcErrCont ==
nullptr) {
369 return StatusCode::SUCCESS;
374 unsigned int idcErrCont_set_number = idcErrCont->numberSet();
376 if (cacheEntry->m_set_number == idcErrCont_set_number){
378 return StatusCode::SUCCESS;
380 cacheEntry->m_set_number = idcErrCont_set_number;
386 ATH_MSG_VERBOSE(
"SCT_ByteStreamErrorsTool size of error container is " << idcErrCont->maxSize());
387 const std::vector<std::pair<size_t, uint64_t>> errorcodesforView{idcErrCont->getAll()};
389 for (
const auto& [ hashId, errCode ] : errorcodesforView) {
393 size_t hash =
static_cast<size_t>(module_id.get_compact());
399 cacheEntry->abcdErrorChips[
hash ];
400 cacheEntry->tempMaskedChips[
hash ];
405 ATH_MSG_VERBOSE(
"SCT_ByteStreamErrorsTool filling event cache for module " << module_id <<
" ec " << errCode);
412 if (v_abcdErrorChips) {
413 v_abcdErrorChips >>= SCT_ByteStreamErrors::ABCDError_Chip0;
415 cacheEntry->abcdErrorChips[
hash] |= v_abcdErrorChips;
417 cacheEntry->abcdErrorChips[
hash] = 0;
420 if (v_tempMaskedChips) {
421 v_tempMaskedChips >>= SCT_ByteStreamErrors::TempMaskedChip0;
423 cacheEntry->tempMaskedChips[
hash] |= v_tempMaskedChips;
425 cacheEntry->tempMaskedChips[
hash] = 0;
430 return StatusCode::SUCCESS;
437 std::scoped_lock<std::mutex> lock{*m_cacheMutex.get(ctx)};
439 if (cacheEntry->IDCCache ==
nullptr) {
446 ATH_MSG_ERROR(
"SCT_ByteStreamErrorsTool Failure getting temp masked chip errors");
448 return v_tempMaskedChips;
453 const EventContext& ctx{Gaudi::Hive::currentContext()};
459 std::scoped_lock<std::mutex> lock{*m_cacheMutex.get(ctx)};
461 if (cacheEntry->IDCCache ==
nullptr) {
468 ATH_MSG_ERROR(
"SCT_ByteStreamErrorsTool Failure getting ABCD chip errors");
470 return v_abcdErrorChips;
475 const EventContext& ctx{Gaudi::Hive::currentContext()};
480 std::unordered_map<size_t, unsigned int>& whereExected)
const {
481 ATH_MSG_VERBOSE(
"SCT_ByteStreamErrorsTool getErrorCodeWithCacheUpdate " << moduleId);
482 size_t modhash =
static_cast<size_t>(moduleId.
get_compact());
483 auto it{whereExected.find(modhash)};
484 if (
it != whereExected.end())
return std::make_pair(StatusCode::SUCCESS,
it->second);
492 cacheEntry->tempMaskedChips[modhash] = 0;
496 if (
sc.isFailure()) {
497 return std::make_pair(StatusCode::FAILURE, 0);
500 it = whereExected.find(modhash);
501 if (
it == whereExected.end()) {
502 ATH_MSG_ERROR(
"After fillData in abcdErrorChips, cache does not have an infomation about the " << moduleId);
503 ATH_MSG_ERROR(
"Likely cause is a request for for different region");
504 return std::make_pair(StatusCode::FAILURE, 0);
506 return std::make_pair(StatusCode::SUCCESS,
it->second);
511 if (not condData.isValid())
return nullptr;
512 return condData->getDetectorElement(waferHash);