24 base_class(
type, name, parent)
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();
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);
137 unsigned int badChips{
m_config->badChips(module_id, ctx)};
140 const int side{
m_sct_id->side(wafer_id)};
141 bool allChipsBad{
true};
144 bool issueABCDError{((v_abcdErrorChips >> chip) & 0x1) != 0};
145 bool isBadChip{((badChips >> chip) & 0x1) != 0};
146 bool isTempMaskedChip{((v_tempMaskedChips >> chip) & 0x1) != 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");
182 if (status.empty()) {
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());
195 constexpr InDet::ChipFlags_t all_flags_set =
static_cast<InDet::ChipFlags_t
>((1ul<<(
N_CHIPS_PER_SIDE)) - 1ul);
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()) {
202 uint64_t error_code = val;
204 status.at(element_i) = status.at(element_i) & not is_bad;
206 ATH_MSG_VERBOSE(
"SCT_ByteStreamErrorsTool Bad Error " << error_code <<
" for ID " << element_i);
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) };
218 const int side{
m_sct_id->side(wafer_id)};
219 bool allChipsBad{
true};
221 InDet::ChipFlags_t bad_chip_flags = 0;
223 bool issueABCDError{((v_abcdErrorChips >> chip) & 0x1) != 0};
224 bool isBadChip{((badChips >> chip) & 0x1) != 0};
225 bool isTempMaskedChip{((v_tempMaskedChips >> chip) & 0x1) != 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);
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;
292 const int side{
m_sct_id->side(stripId)};
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);
330std::set<IdentifierHash>
333 std::set<IdentifierHash>
result;
334 if (errorType>=0 and errorType<SCT_ByteStreamErrors::NUM_ERROR_TYPES) {
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);
350std::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;
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());
394 if (errCode == uint64_t{0}) {
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) {
445 if (status.isFailure()) {
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) {
467 if (status.isFailure()) {
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);
491 cacheEntry->abcdErrorChips[modhash] = 0;
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);
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
This is an Identifier helper class for the SCT subdetector.
Handle class for reading from StoreGate.
Header file for AthHistogramAlgorithm.
IDC like storage for BS errors, TODO, customise implementation further so that we store int rather th...
size_t maxSize() const
Return the maxSize of the collection.
size_t numberSet() const
Return the number of entries set and accessible according to the mask.
std::vector< std::pair< size_t, T > > getAll() const
Make a vector of hashes and values, convenient for iteration and other uses.
This is a "hash" representation of an Identifier.
bool is_valid() const
Check if id is in a valid state.
value_type get_compact() const
Get the compact id.
Class to hold geometrical description of a silicon detector element.
bool swapPhiReadoutDirection() const
Determine if readout direction between online and offline needs swapping.
const std::vector< bool > & getElementStatus() const
const std::vector< ChipFlags_t > & getElementChipStatus() const
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
void addDependency(const EventIDRange &range)
ErrorType
SCT byte stream error type enums used in SCT_RodDecoder, SCT_ByteStreamErrorsTool,...
IDCInDetBSErrContainer::ErrorCode makeError(ErrorType errType)
<
static constexpr uint64_t ABCDErrorMask()
static constexpr uint64_t TempMaskedChipsMask()
static const std::vector< ErrorType > BadErrors
Bad error enums used in SCT_ByteStreamErrorsTool and SCTErrMonAlg.
constexpr unsigned int getChip(unsigned int side, bool swap, unsigned int strip)
Get the physical chip ID for the given strip.
constexpr unsigned int getGeometricalFromPhysicalChipID(unsigned int side, bool swap, unsigned int physical_chip_id)
Get the geometrical chip ID from a physica chip ID.
void reset(EventContext::ContextEvt_t evtId, const IDCInDetBSErrContainer_Cache *cache)
bool needsUpdate(const EventContext &ctx) const
const IDCInDetBSErrContainer_Cache * IDCCache
EventContext::ContextEvt_t eventId