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;
245 return isGood(elementIdHash, ctx);
260 ATH_MSG_WARNING(
"moduleId obtained from stripId " << stripId <<
" is invalid.");
272 const unsigned int v_abcdErrorChips{
abcdErrorChips(moduleId, ctx)};
274 const unsigned int badChips{v_tempMaskedChips | v_abcdErrorChips};
277 if (badChips==0)
return true;
279 const int side{
m_sct_id->side(stripId)};
284 if ((side==0 and (badChips & 0x3F)==0) or (side==1 and (badChips & 0xFC0)==0))
return true;
286 int chip{
getChip(stripId, ctx)};
287 if (chip<0 or chip>=12) {
293 const bool badChip{
static_cast<bool>(badChips & (1<<chip))};
295 return (not badChip);
303 if (siElement==
nullptr) {
304 ATH_MSG_DEBUG (
"InDetDD::SiDetectorElement is not obtained from stripId " << stripId);
317std::set<IdentifierHash>
320 std::set<IdentifierHash> result;
321 if (errorType>=0 and errorType<SCT_ByteStreamErrors::NUM_ERROR_TYPES) {
323 if (idcErrCont !=
nullptr) {
324 const std::set<size_t>& Mask = idcErrCont->getMask();
325 const auto& raw = idcErrCont->wholeEventReadAccess();
326 for (
const size_t hashId : Mask) {
327 auto errCode = raw[hashId].load(std::memory_order_relaxed);
329 result.insert(hashId);
348 if (idcErrCont ==
nullptr) {
350 return StatusCode::SUCCESS;
355 unsigned int idcErrCont_set_number = idcErrCont->
numberSet();
357 if (cacheEntry->m_set_number == idcErrCont_set_number){
359 return StatusCode::SUCCESS;
361 cacheEntry->m_set_number = idcErrCont_set_number;
368 const std::vector<std::pair<size_t, uint64_t>> errorcodesforView{idcErrCont->
getAll()};
370 for (
const auto& [ hashId, errCode ] : errorcodesforView) {
374 size_t hash =
static_cast<size_t>(module_id.
get_compact());
375 if (errCode == uint64_t{0}) {
380 cacheEntry->abcdErrorChips[ hash ];
381 cacheEntry->tempMaskedChips[ hash ];
386 ATH_MSG_VERBOSE(
"SCT_ByteStreamErrorsTool filling event cache for module " << module_id <<
" ec " << errCode);
393 if (v_abcdErrorChips) {
394 v_abcdErrorChips >>= SCT_ByteStreamErrors::ABCDError_Chip0;
396 cacheEntry->abcdErrorChips[hash] |= v_abcdErrorChips;
398 cacheEntry->abcdErrorChips[hash] = 0;
401 if (v_tempMaskedChips) {
402 v_tempMaskedChips >>= SCT_ByteStreamErrors::TempMaskedChip0;
404 cacheEntry->tempMaskedChips[hash] |= v_tempMaskedChips;
406 cacheEntry->tempMaskedChips[hash] = 0;
411 return StatusCode::SUCCESS;
418 std::scoped_lock<std::mutex>
lock{*m_cacheMutex.get(ctx)};
420 if (cacheEntry->IDCCache ==
nullptr) {
426 if (status.isFailure()) {
427 ATH_MSG_ERROR(
"SCT_ByteStreamErrorsTool Failure getting temp masked chip errors");
429 return v_tempMaskedChips;
435 std::scoped_lock<std::mutex>
lock{*m_cacheMutex.get(ctx)};
437 if (cacheEntry->IDCCache ==
nullptr) {
443 if (status.isFailure()) {
444 ATH_MSG_ERROR(
"SCT_ByteStreamErrorsTool Failure getting ABCD chip errors");
446 return v_abcdErrorChips;
451 std::unordered_map<size_t, unsigned int>& whereExected)
const {
452 ATH_MSG_VERBOSE(
"SCT_ByteStreamErrorsTool getErrorCodeWithCacheUpdate " << moduleId);
453 size_t modhash =
static_cast<size_t>(moduleId.
get_compact());
454 auto it{whereExected.find(modhash)};
455 if (it != whereExected.end())
return std::make_pair(StatusCode::SUCCESS, it->second);
462 cacheEntry->abcdErrorChips[modhash] = 0;
463 cacheEntry->tempMaskedChips[modhash] = 0;
467 if (
sc.isFailure()) {
468 return std::make_pair(StatusCode::FAILURE, 0);
471 it = whereExected.find(modhash);
472 if (it == whereExected.end()) {
473 ATH_MSG_ERROR(
"After fillData in abcdErrorChips, cache does not have an infomation about the " << moduleId);
474 ATH_MSG_ERROR(
"Likely cause is a request for for different region");
475 return std::make_pair(StatusCode::FAILURE, 0);
477 return std::make_pair(StatusCode::SUCCESS, it->second);
482 if (not condData.
isValid())
return nullptr;
483 return condData->getDetectorElement(waferHash);
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
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