ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_ByteStreamErrorsTool Class Reference

Tool that keeps track of modules that give rise to errors in the bytestram. More...

#include <SCT_ByteStreamErrorsTool.h>

Inheritance diagram for SCT_ByteStreamErrorsTool:
Collaboration diagram for SCT_ByteStreamErrorsTool:

Classes

struct  IDCCacheEntry

Public Member Functions

 SCT_ByteStreamErrorsTool (const std::string &type, const std::string &name, const IInterface *parent)
 header file for this class.
virtual ~SCT_ByteStreamErrorsTool ()=default
virtual StatusCode initialize () override
 Initialize.
virtual StatusCode finalize () override
 Finalize.
virtual bool canReportAbout (InDetConditions::Hierarchy h) const override
 Used by ConditionsSummayTool to decide whether to call isGood() for a particular detector element.
virtual bool isGood (const Identifier &elementId, const EventContext &ctx, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override
 Is the detector element good?
virtual bool isGood (const IdentifierHash &elementIdHash, const EventContext &ctx) const override
 this is the principle method which can be accessed via the ConditionsSummaryTool to decide if a wafer is good - in this case we want to return false if the wafer has an error that would result in bad hits or no hits for that event
virtual void getDetectorElementStatus (const EventContext &ctx, InDet::SiDetectorElementStatus &element_status, SG::WriteCondHandle< InDet::SiDetectorElementStatus > *whandle) const override
virtual std::set< IdentifierHashgetErrorSet (int errorType, const EventContext &ctx) const override
 The accessor method that can be used by clients to retrieve a set of IdHashes of wafers with a given type of error.
virtual unsigned int tempMaskedChips (const Identifier &moduleId, const EventContext &ctx) const override
virtual unsigned int abcdErrorChips (const Identifier &moduleId, const EventContext &ctx) const override

Private Types

enum  N_ELEMENTS { N_CHIPS_PER_SIDE = 6 , N_SIDES = 2 , N_STRIPS_PER_CHIP = 128 , N_STRIPS_PER_SIDE = N_STRIPS_PER_CHIP*N_CHIPS_PER_SIDE }

Private Member Functions

const IDCInDetBSErrContainergetContainer (const EventContext &ctx) const
 Obtains container form the SG, if it is missing it will complain (hard-coded 3 times per job) and return nullptr.
IDCCacheEntrygetCacheEntry (const EventContext &ctx) const
 Return cache for the current event If, for current slot, the cache is outdated it is retrieved from the IDC collection.
StatusCode fillData (const EventContext &ctx) const
 Updates information per module & ABCD chip.
bool isGoodChip (const Identifier &stripId, const EventContext &ctx) const
int getChip (const Identifier &stripId, const EventContext &ctx) const
const InDetDD::SiDetectorElementgetDetectorElement (const IdentifierHash &waferHash, const EventContext &ctx) const
std::pair< StatusCode, unsigned int > getErrorCodeWithCacheUpdate (const Identifier &id, const EventContext &ctx, std::unordered_map< size_t, unsigned int > &whereExected) const
 Method that returns BS Error code from the map passed @rag where-Expected If the information is initially missing, the cache update is triggered.

Private Attributes

ToolHandle< ISCT_ConfigurationConditionsToolm_config
SG::ReadHandleKey< IDCInDetBSErrContainerm_bsIDCErrContainerName {this, "IDCByteStreamErrContainer", "SCT_ByteStreamErrs", "SCT BS error key for IDC variant"}
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollectionm_SCTDetEleCollKey {this, "SCTDetEleCollKey", "SCT_DetectorElementCollection", "Key of SiDetectorElementCollection for SCT"}
const SCT_IDm_sct_id {nullptr}
IdContext m_cntx_sct
uint64_t m_badErrorMask {}
SG::SlotSpecificObj< std::mutex > m_cacheMutex ATLAS_THREAD_SAFE
SG::SlotSpecificObj< IDCCacheEntry > m_eventCache ATLAS_THREAD_SAFE
std::atomic_uint m_nRetrievalFailure {0}

Detailed Description

Tool that keeps track of modules that give rise to errors in the bytestram.

The API offers two levels of access, 1) by identifier 2) for "all event" In 1st case the information from entire event is used via the cache if IDC container that keeps an information about errors for so far decoded SCT data. That access pattern is identical for HLT and offline use-case. Missing data in the cache is sign of error.

The 2nd patter is to request error information for the whole event. In case of trigger these methods can in fact return information for the fragment of the detector data. This depends on the IDC container that the tool is configured to read.

There are two levels of caching involved in data access. First the IDC stores actual BS error codes in the event-wide container called cache. Even if the IDC container may be different, this cache remains the same for the whole event. Secondly the tool itself has a cache that is essentially needed to avoid going to the event store for the IDC container for each call. Inside this local cache object derived information is stored to speed up calls like isGood.

Definition at line 64 of file SCT_ByteStreamErrorsTool.h.

Member Enumeration Documentation

◆ N_ELEMENTS

Constructor & Destructor Documentation

◆ SCT_ByteStreamErrorsTool()

SCT_ByteStreamErrorsTool::SCT_ByteStreamErrorsTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

header file for this class.

Athena includes Constructor

Definition at line 23 of file SCT_ByteStreamErrorsTool.cxx.

23 :
24 base_class(type, name, parent)
25{
26}

◆ ~SCT_ByteStreamErrorsTool()

virtual SCT_ByteStreamErrorsTool::~SCT_ByteStreamErrorsTool ( )
virtualdefault

Member Function Documentation

◆ abcdErrorChips()

unsigned int SCT_ByteStreamErrorsTool::abcdErrorChips ( const Identifier & moduleId,
const EventContext & ctx ) const
overridevirtual

Definition at line 433 of file SCT_ByteStreamErrorsTool.cxx.

433 {
434 ATH_MSG_VERBOSE("SCT_ByteStreamErrorsTool abcdErrorChips");
435 std::scoped_lock<std::mutex> lock{*m_cacheMutex.get(ctx)};
436 auto *cacheEntry{getCacheEntry(ctx)};
437 if (cacheEntry->IDCCache == nullptr) {
438 ATH_MSG_VERBOSE("cacheEntry->IDCCache == nullptr");
439 return 0;
440 }
441
442 auto [status, v_abcdErrorChips] = getErrorCodeWithCacheUpdate(moduleId, ctx, cacheEntry->abcdErrorChips);
443 if (status.isFailure()) {
444 ATH_MSG_ERROR("SCT_ByteStreamErrorsTool Failure getting ABCD chip errors");
445 }
446 return v_abcdErrorChips; // 12 bits are used.
447 // Bit 0 is for chip 0 on side 0, bit 1 is for chip 1 on side 0, ..., and bit 11 is for chip 5 on side 1
448}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
IDCCacheEntry * getCacheEntry(const EventContext &ctx) const
Return cache for the current event If, for current slot, the cache is outdated it is retrieved from t...
std::pair< StatusCode, unsigned int > getErrorCodeWithCacheUpdate(const Identifier &id, const EventContext &ctx, std::unordered_map< size_t, unsigned int > &whereExected) const
Method that returns BS Error code from the map passed @rag where-Expected If the information is initi...
status
Definition merge.py:16

◆ canReportAbout()

bool SCT_ByteStreamErrorsTool::canReportAbout ( InDetConditions::Hierarchy h) const
overridevirtual

Used by ConditionsSummayTool to decide whether to call isGood() for a particular detector element.

In principle we could report about modules and/or strips too, and use the id helper to navigate up or down the hierarchy to the wafer, but in practice we don't want to do the time-consuming isGood() for every strip, so lets only report about wafers..

Definition at line 67 of file SCT_ByteStreamErrorsTool.cxx.

◆ fillData()

StatusCode SCT_ByteStreamErrorsTool::fillData ( const EventContext & ctx) const
private

Updates information per module & ABCD chip.

this function is used to populate the data of this tool from the InDetBSErrContainer in StoreGate

OK, so we found the StoreGate container, now lets iterate over it to populate the sets of errors owned by this Tool.

Definition at line 344 of file SCT_ByteStreamErrorsTool.cxx.

344 {
345 ATH_MSG_VERBOSE("SCT_ByteStreamErrorsTool fillData");
346
347 const IDCInDetBSErrContainer* idcErrCont{getContainer(ctx)};
348 if (idcErrCont == nullptr) {
349 ATH_MSG_VERBOSE("idcErrCont == nullptr");
350 return StatusCode::SUCCESS;
351 }
352
353 auto *cacheEntry{getCacheEntry(ctx)};
354
355 unsigned int idcErrCont_set_number = idcErrCont->numberSet();
356
357 if (cacheEntry->m_set_number == idcErrCont_set_number){
358 ATH_MSG_VERBOSE("Same set number found, skip the next steps.");
359 return StatusCode::SUCCESS;
360 }else{
361 cacheEntry->m_set_number = idcErrCont_set_number; //update the set number in cacheEntry.
362 }
363
367 ATH_MSG_VERBOSE("SCT_ByteStreamErrorsTool size of error container is " << idcErrCont->maxSize());
368 const std::vector<std::pair<size_t, uint64_t>> errorcodesforView{idcErrCont->getAll()};
369
370 for (const auto& [ hashId, errCode ] : errorcodesforView) {
371
372 Identifier wafer_id{m_sct_id->wafer_id(hashId)};
373 Identifier module_id{m_sct_id->module_id(wafer_id)};
374 size_t hash = static_cast<size_t>(module_id.get_compact());
375 if (errCode == uint64_t{0}) {
376 // That means this hashId was decoded but had no error
377 // In such case we want to fill the cache also with zero so we do not have to fill the cache again for a given view
378 // (see logic in: getErrorCodeWithCacheUpdate)
379 // Note: invocation of the [] operator on the map will create missing entry and set the value to default (here 0)
380 cacheEntry->abcdErrorChips[ hash ];
381 cacheEntry->tempMaskedChips[ hash ];
382 continue;
383 }
384
385
386 ATH_MSG_VERBOSE("SCT_ByteStreamErrorsTool filling event cache for module " << module_id << " ec " << errCode);
387
388 const int side{m_sct_id->side(m_sct_id->wafer_id(hashId))};
389 // Each bit of errCode represents each SCT_ByteStreamErrors for one wafer
390 // Multiple bits can be true.
391 // Convert errCode to 12 bits of abcdErrorChips and 12 bits of tempMaskedChips for one module (=two wafers).
393 if (v_abcdErrorChips) {
394 v_abcdErrorChips >>= SCT_ByteStreamErrors::ABCDError_Chip0; // bit 0 (5) is for chip 0 (5) for both sides
395 v_abcdErrorChips <<= (side*N_CHIPS_PER_SIDE); // bit 0 (6) is for chip 0 on side 0 (1)
396 cacheEntry->abcdErrorChips[hash] |= v_abcdErrorChips;
397 } else {
398 cacheEntry->abcdErrorChips[hash] = 0;
399 }
401 if (v_tempMaskedChips) {
402 v_tempMaskedChips >>= SCT_ByteStreamErrors::TempMaskedChip0; // bit 0 (5) is for chip 0 (5) for both sides0
403 v_tempMaskedChips <<= (side*N_CHIPS_PER_SIDE); // bit 0 (6) is for chip 0 on side 0 (1)
404 cacheEntry->tempMaskedChips[hash] |= v_tempMaskedChips;
405 } else {
406 cacheEntry->tempMaskedChips[hash] = 0;
407 }
408
409 }
410
411 return StatusCode::SUCCESS;
412}
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.
value_type get_compact() const
Get the compact id.
const IDCInDetBSErrContainer * getContainer(const EventContext &ctx) const
Obtains container form the SG, if it is missing it will complain (hard-coded 3 times per job) and ret...
static constexpr uint64_t ABCDErrorMask()
static constexpr uint64_t TempMaskedChipsMask()

◆ finalize()

StatusCode SCT_ByteStreamErrorsTool::finalize ( )
overridevirtual

Finalize.

Definition at line 52 of file SCT_ByteStreamErrorsTool.cxx.

52 {
53 return StatusCode::SUCCESS;
54}

◆ getCacheEntry()

SCT_ByteStreamErrorsTool::IDCCacheEntry * SCT_ByteStreamErrorsTool::getCacheEntry ( const EventContext & ctx) const
nodiscardprivate

Return cache for the current event If, for current slot, the cache is outdated it is retrieved from the IDC collection.

If the IDC is missing nullptr is returned.

Definition at line 94 of file SCT_ByteStreamErrorsTool.cxx.

94 {
95 IDCCacheEntry* cacheEntry{m_eventCache.get(ctx)};
96 if (cacheEntry->needsUpdate(ctx)) {
97 const auto *idcErrContPtr{getContainer(ctx)};
98 if (idcErrContPtr == nullptr) { // missing or not, the cache needs to be reset
99 cacheEntry->reset(ctx.evt(), nullptr);
100 } else {
101 cacheEntry->reset(ctx.evt(), idcErrContPtr->cache());
102 }
103 ATH_MSG_VERBOSE("SCT_ByteStreamErrorsTool Cache for the event reset " << cacheEntry->eventId << " with IDC container" << idcErrContPtr);
104 }
105 return cacheEntry;
106}

◆ getChip()

int SCT_ByteStreamErrorsTool::getChip ( const Identifier & stripId,
const EventContext & ctx ) const
private

Definition at line 299 of file SCT_ByteStreamErrorsTool.cxx.

299 {
300 const Identifier waferId{m_sct_id->wafer_id(stripId)};
301 const IdentifierHash waferHash{m_sct_id->wafer_hash(waferId)};
302 const InDetDD::SiDetectorElement* siElement{getDetectorElement(waferHash, ctx)};
303 if (siElement==nullptr) {
304 ATH_MSG_DEBUG ("InDetDD::SiDetectorElement is not obtained from stripId " << stripId);
305 return -1;
306 }
307 return SCT::getChip(*m_sct_id, *siElement, stripId);
308}
#define ATH_MSG_DEBUG(x)
const InDetDD::SiDetectorElement * getDetectorElement(const IdentifierHash &waferHash, const EventContext &ctx) const
constexpr unsigned int getChip(unsigned int side, bool swap, unsigned int strip)
Get the physical chip ID for the given strip.

◆ getContainer()

const IDCInDetBSErrContainer * SCT_ByteStreamErrorsTool::getContainer ( const EventContext & ctx) const
nodiscardprivate

Obtains container form the SG, if it is missing it will complain (hard-coded 3 times per job) and return nullptr.

When running over ESD files without BSErr container stored, don't want to flood the user with error messages. Should just have a bunch of empty sets, and keep quiet.

Definition at line 71 of file SCT_ByteStreamErrorsTool.cxx.

71 {
72 SG::ReadHandle<IDCInDetBSErrContainer> idcErrCont(m_bsIDCErrContainerName, ctx);
77 if (not idcErrCont.isValid()) {
79 if (m_nRetrievalFailure<=3) {
80 ATH_MSG_INFO("SCT_ByteStreamErrorsTool Failed to retrieve BS error container "
82 << " from StoreGate.");
83 if (m_nRetrievalFailure==3) {
84 ATH_MSG_INFO("SCT_ByteStreamErrorsTool This message on retrieval failure of " << m_bsIDCErrContainerName.key() << " is suppressed.");
85 }
86 }
87 return nullptr;
88 }
89 ATH_MSG_VERBOSE("SCT_ByteStreamErrorsTool IDC Container fetched " << m_bsIDCErrContainerName.key());
90 return idcErrCont.cptr();
91}
#define ATH_MSG_INFO(x)
SG::ReadHandleKey< IDCInDetBSErrContainer > m_bsIDCErrContainerName

◆ getDetectorElement()

const InDetDD::SiDetectorElement * SCT_ByteStreamErrorsTool::getDetectorElement ( const IdentifierHash & waferHash,
const EventContext & ctx ) const
private

Definition at line 480 of file SCT_ByteStreamErrorsTool.cxx.

480 {
481 SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> condData{m_SCTDetEleCollKey, ctx};
482 if (not condData.isValid()) return nullptr;
483 return condData->getDetectorElement(waferHash);
484}
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey

◆ getDetectorElementStatus()

void SCT_ByteStreamErrorsTool::getDetectorElementStatus ( const EventContext & ctx,
InDet::SiDetectorElementStatus & element_status,
SG::WriteCondHandle< InDet::SiDetectorElementStatus > * whandle ) const
overridevirtual

Definition at line 162 of file SCT_ByteStreamErrorsTool.cxx.

163 {
164 std::scoped_lock<std::mutex> lock{*m_cacheMutex.get(ctx)};
165
166 const auto *idcCachePtr{getCacheEntry(ctx)};
167 if (idcCachePtr == nullptr || !idcCachePtr->IDCCache) {
168 ATH_MSG_VERBOSE("SCT_ByteStreamErrorsTool No cache! ");
169 return;
170 }
171 if (whandle) {
172 ATH_MSG_ERROR("SCT_ByteStreamErrorsTool is not for conditions objects");
174 }
175
176 if (fillData(ctx).isFailure()) {
177 return; // @TODO what is the correct way to handle this ? set status to false for all ?
178 }
179
180 std::vector<bool> &status = element_status.getElementStatus();
181 std::vector<InDet::ChipFlags_t> &chip_status = element_status.getElementChipStatus();
182 if (status.empty()) {
183 status.resize(idcCachePtr->IDCCache->rawReadAccess().size(),true);
184 }
185 SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> si_element_list{m_SCTDetEleCollKey, ctx};
186 if (not si_element_list.isValid()) {
187 std::stringstream msg;
188 msg << "Failed to get SCT detector element collection with key " << m_SCTDetEleCollKey.key();
189 throw std::runtime_error(msg.str());
190 }
191 if (whandle) {
192 whandle->addDependency (si_element_list);
193 }
194
195 constexpr InDet::ChipFlags_t all_flags_set = static_cast<InDet::ChipFlags_t>((1ul<<(N_CHIPS_PER_SIDE)) - 1ul);
196 static_assert( (1ul<<(N_CHIPS_PER_SIDE*N_SIDES)) - 1ul <= std::numeric_limits<InDet::ChipFlags_t>::max());
197 if (chip_status.empty()) {
198 chip_status.resize(status.size(), all_flags_set);
199 }
200 unsigned int element_i=0;
201 for ( const auto &val : idcCachePtr->IDCCache->rawReadAccess()) {
203 bool is_bad = error_code & m_badErrorMask;
204 status.at(element_i) = status.at(element_i) & not is_bad;
205 if ( is_bad ) {
206 ATH_MSG_VERBOSE("SCT_ByteStreamErrorsTool Bad Error " << error_code << " for ID " << element_i);
207 }
208 else {
209 IdentifierHash hash(element_i);
210 const InDetDD::SiDetectorElement *siElement = si_element_list->getDetectorElement(hash);
211 const Identifier wafer_id{m_sct_id->wafer_id(hash)};
212 const Identifier module_id{m_sct_id->module_id(wafer_id)};
213 size_t modhash = static_cast<size_t>(module_id.get_compact());
214
215 unsigned int badChips{m_config->badChips(module_id, ctx)}; // @todo only call once for all
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};
220 const int chipMax{static_cast<short>(side==0 ? N_CHIPS_PER_SIDE : N_CHIPS_PER_SIDE*N_SIDES)};
221 InDet::ChipFlags_t bad_chip_flags = 0;
222 for (int chip{chipMax-N_CHIPS_PER_SIDE}; chip<chipMax; chip++) {
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);
227 bad_chip_flags |= static_cast<InDet::ChipFlags_t>(isBad) << SCT::getGeometricalFromPhysicalChipID(side, siElement->swapPhiReadoutDirection(), chip);
228 allChipsBad &= isBad;
229 }
230 status.at(element_i) = status.at(element_i) & not allChipsBad;
231 chip_status.at(element_i) &= (~bad_chip_flags) & all_flags_set;
232 }
233
234 ++element_i;
235 }
236}
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
unsigned short ChipFlags_t
StatusCode fillData(const EventContext &ctx) const
Updates information per module & ABCD chip.
ToolHandle< ISCT_ConfigurationConditionsTool > m_config
void addDependency(const EventIDRange &range)
constexpr unsigned int getGeometricalFromPhysicalChipID(unsigned int side, bool swap, unsigned int physical_chip_id)
Get the geometrical chip ID from a physica chip ID.
MsgStream & msg
Definition testRead.cxx:32

◆ getErrorCodeWithCacheUpdate()

std::pair< StatusCode, unsigned int > SCT_ByteStreamErrorsTool::getErrorCodeWithCacheUpdate ( const Identifier & id,
const EventContext & ctx,
std::unordered_map< size_t, unsigned int > & whereExected ) const
private

Method that returns BS Error code from the map passed @rag where-Expected If the information is initially missing, the cache update is triggered.

Definition at line 450 of file SCT_ByteStreamErrorsTool.cxx.

451 {
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);
456
457 // even if there are no errors for this module at all filled
458 // we want the entry of value 0 so we know we walked over it and do not need to invoke filling again
459 // and and do not need to do it again
460
461 auto *cacheEntry{getCacheEntry(ctx)};
462 cacheEntry->abcdErrorChips[modhash] = 0;
463 cacheEntry->tempMaskedChips[modhash] = 0;
464
465 // the content is missing, look for actual errors
466 StatusCode sc{fillData(ctx)};
467 if (sc.isFailure()) {
468 return std::make_pair(StatusCode::FAILURE, 0);
469 }
470 // handle situation when the cache does not contain desired datum after the update
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);
476 }
477 return std::make_pair(StatusCode::SUCCESS, it->second);
478}
static Double_t sc
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ getErrorSet()

std::set< IdentifierHash > SCT_ByteStreamErrorsTool::getErrorSet ( int errorType,
const EventContext & ctx ) const
overridevirtual

The accessor method that can be used by clients to retrieve a set of IdHashes of wafers with a given type of error.

e.g. for monitoring plots.

Definition at line 318 of file SCT_ByteStreamErrorsTool.cxx.

318 {
319 ATH_MSG_VERBOSE("SCT_ByteStreamErrorsTool getErrorSet " << errorType);
320 std::set<IdentifierHash> result;
321 if (errorType>=0 and errorType<SCT_ByteStreamErrors::NUM_ERROR_TYPES) {
322 const auto *idcErrCont{getContainer(ctx)};
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);
328 if (SCT_ByteStreamErrors::hasError(errCode, static_cast<SCT_ByteStreamErrors::ErrorType>(errorType))) {
329 result.insert(hashId);
330 }
331 }
332 }
333 }
334 return result;
335}
ErrorType
SCT byte stream error type enums used in SCT_RodDecoder, SCT_ByteStreamErrorsTool,...

◆ initialize()

StatusCode SCT_ByteStreamErrorsTool::initialize ( )
overridevirtual

Initialize.

Definition at line 30 of file SCT_ByteStreamErrorsTool.cxx.

30 {
31 ATH_CHECK(detStore()->retrieve(m_sct_id, "SCT_ID"));
32 m_cntx_sct = m_sct_id->wafer_context();
33
34 ATH_CHECK(m_config.retrieve());
35
36 // Read (Cond)Handle Keys
38 ATH_CHECK(m_SCTDetEleCollKey.initialize());
40 for (auto badError : SCT_ByteStreamErrors::BadErrors) {
41 if (badError>=63) {
42 ATH_MSG_FATAL("Logic error: Error code too large and cannot represented as a bit.");
43 }
45 }
46
47 return StatusCode::SUCCESS;
48}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
IDCInDetBSErrContainer::ErrorCode makeError(ErrorType errType)
<
static const std::vector< ErrorType > BadErrors
Bad error enums used in SCT_ByteStreamErrorsTool and SCTErrMonAlg.

◆ isGood() [1/2]

bool SCT_ByteStreamErrorsTool::isGood ( const Identifier & elementId,
const EventContext & ctx,
InDetConditions::Hierarchy h = InDetConditions::DEFAULT ) const
overridevirtual

Is the detector element good?

Definition at line 240 of file SCT_ByteStreamErrorsTool.cxx.

240 {
241 if (not canReportAbout(h)) return true;
242
244 const IdentifierHash elementIdHash{m_sct_id->wafer_hash(elementId)};
245 return isGood(elementIdHash, ctx);
246 }
248 return isGoodChip(elementId, ctx);
249 }
250
251 return true;
252}
virtual bool isGood(const Identifier &elementId, const EventContext &ctx, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override
Is the detector element good?
virtual bool canReportAbout(InDetConditions::Hierarchy h) const override
Used by ConditionsSummayTool to decide whether to call isGood() for a particular detector element.
bool isGoodChip(const Identifier &stripId, const EventContext &ctx) const

◆ isGood() [2/2]

bool SCT_ByteStreamErrorsTool::isGood ( const IdentifierHash & elementIdHash,
const EventContext & ctx ) const
overridevirtual

this is the principle method which can be accessed via the ConditionsSummaryTool to decide if a wafer is good - in this case we want to return false if the wafer has an error that would result in bad hits or no hits for that event

Definition at line 113 of file SCT_ByteStreamErrorsTool.cxx.

113 {
114 {
115
116 std::scoped_lock<std::mutex> lock{*m_cacheMutex.get(ctx)};
117 ATH_MSG_VERBOSE("SCT_ByteStreamErrorsTool isGood called for " << elementIdHash);
118 const auto *idcCachePtr{getCacheEntry(ctx)->IDCCache};
119 if (idcCachePtr == nullptr) {
120 ATH_MSG_VERBOSE("SCT_ByteStreamErrorsTool No cache! ");
121 return true;
122 }
123
124 auto errorCode{idcCachePtr->retrieve(elementIdHash)};
125
126 bool is_bad = errorCode & m_badErrorMask;
127 if (is_bad) {
128 ATH_MSG_VERBOSE("SCT_ByteStreamErrorsTool Bad Error " << errorCode << " for ID " << elementIdHash);
129 return false;
130 }
131
132 } // end of cache operations protection via m_cacheMutex, following code has own protection
133
134 // If all 6 chips of a link issue ABCD errors or are bad chips or temporarily masked chips, the link is treated as bad one.
135 const Identifier wafer_id{m_sct_id->wafer_id(elementIdHash)};
136 const Identifier module_id{m_sct_id->module_id(wafer_id)};
137 unsigned int badChips{m_config->badChips(module_id, ctx)};
138 unsigned int v_abcdErrorChips{abcdErrorChips(module_id, ctx)};
139 unsigned int v_tempMaskedChips{tempMaskedChips(module_id, ctx)};
140 const int side{m_sct_id->side(wafer_id)};
141 bool allChipsBad{true};
142 const int chipMax{static_cast<short>(side==0 ? N_CHIPS_PER_SIDE : N_CHIPS_PER_SIDE*N_SIDES)};
143 for (int chip{chipMax-N_CHIPS_PER_SIDE}; chip<chipMax; chip++) {
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;
149 }
150 return !allChipsBad;
151}
virtual unsigned int abcdErrorChips(const Identifier &moduleId, const EventContext &ctx) const override
virtual unsigned int tempMaskedChips(const Identifier &moduleId, const EventContext &ctx) const override
const IDCInDetBSErrContainer_Cache * IDCCache

◆ isGoodChip()

bool SCT_ByteStreamErrorsTool::isGoodChip ( const Identifier & stripId,
const EventContext & ctx ) const
private

Definition at line 255 of file SCT_ByteStreamErrorsTool.cxx.

255 {
256 // This check assumes present SCT.
257 // Get module number
258 const Identifier moduleId{m_sct_id->module_id(stripId)};
259 if (not moduleId.is_valid()) {
260 ATH_MSG_WARNING("moduleId obtained from stripId " << stripId << " is invalid.");
261 return false;
262 }
263
264 // tempMaskedChips and abcdErrorChips hold 12 bits.
265 // bit 0 (LSB) is chip 0 for side 0.
266 // bit 5 is chip 5 for side 0.
267 // bit 6 is chip 6 for side 1.
268 // bit 11 is chip 11 for side 1.
269 // Temporarily masked chip information
270 const unsigned int v_tempMaskedChips{tempMaskedChips(moduleId, ctx)};
271 // Information of chips with ABCD errors
272 const unsigned int v_abcdErrorChips{abcdErrorChips(moduleId, ctx)};
273 // Take 'OR' of tempMaskedChips and abcdErrorChips
274 const unsigned int badChips{v_tempMaskedChips | v_abcdErrorChips};
275
276 // If there is no bad chip, this check is done.
277 if (badChips==0) return true;
278
279 const int side{m_sct_id->side(stripId)};
280 // Check the six chips on the side
281 // 0x3F = 0000 0011 1111
282 // 0xFC0 = 1111 1100 0000
283 // If there is no bad chip on the side, this check is done.
284 if ((side==0 and (badChips & 0x3F)==0) or (side==1 and (badChips & 0xFC0)==0)) return true;
285
286 int chip{getChip(stripId, ctx)};
287 if (chip<0 or chip>=12) {
288 ATH_MSG_WARNING("chip number is invalid: " << chip);
289 return false;
290 }
291
292 // Check if the chip is bad
293 const bool badChip{static_cast<bool>(badChips & (1<<chip))};
294
295 return (not badChip);
296}
#define ATH_MSG_WARNING(x)
bool is_valid() const
Check if id is in a valid state.
int getChip(const Identifier &stripId, const EventContext &ctx) const

◆ tempMaskedChips()

unsigned int SCT_ByteStreamErrorsTool::tempMaskedChips ( const Identifier & moduleId,
const EventContext & ctx ) const
overridevirtual

Definition at line 416 of file SCT_ByteStreamErrorsTool.cxx.

416 {
417 ATH_MSG_VERBOSE("SCT_ByteStreamErrorsTool tempMaskedChips");
418 std::scoped_lock<std::mutex> lock{*m_cacheMutex.get(ctx)};
419 auto *cacheEntry{getCacheEntry(ctx)};
420 if (cacheEntry->IDCCache == nullptr) {
421 ATH_MSG_VERBOSE("cacheEntry->IDCCache == nullptr");
422 return 0;
423 }
424
425 auto [status, v_tempMaskedChips] = getErrorCodeWithCacheUpdate(moduleId, ctx, cacheEntry->tempMaskedChips);
426 if (status.isFailure()) {
427 ATH_MSG_ERROR("SCT_ByteStreamErrorsTool Failure getting temp masked chip errors");
428 }
429 return v_tempMaskedChips; // 12 bits are used.
430 // Bit 0 is for chip 0 on side 0, bit 1 is for chip 1 on side 0, ..., and bit 11 is for chip 5 on side 1
431}

Member Data Documentation

◆ ATLAS_THREAD_SAFE [1/2]

SG::SlotSpecificObj<IDCCacheEntry> m_eventCache SCT_ByteStreamErrorsTool::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 131 of file SCT_ByteStreamErrorsTool.h.

◆ ATLAS_THREAD_SAFE [2/2]

SG::SlotSpecificObj<std::mutex> m_cacheMutex SCT_ByteStreamErrorsTool::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 102 of file SCT_ByteStreamErrorsTool.h.

◆ m_badErrorMask

uint64_t SCT_ByteStreamErrorsTool::m_badErrorMask {}
private

Definition at line 100 of file SCT_ByteStreamErrorsTool.h.

100{};

◆ m_bsIDCErrContainerName

SG::ReadHandleKey<IDCInDetBSErrContainer> SCT_ByteStreamErrorsTool::m_bsIDCErrContainerName {this, "IDCByteStreamErrContainer", "SCT_ByteStreamErrs", "SCT BS error key for IDC variant"}
private

Definition at line 95 of file SCT_ByteStreamErrorsTool.h.

95{this, "IDCByteStreamErrContainer", "SCT_ByteStreamErrs", "SCT BS error key for IDC variant"};

◆ m_cntx_sct

IdContext SCT_ByteStreamErrorsTool::m_cntx_sct
private

Definition at line 99 of file SCT_ByteStreamErrorsTool.h.

◆ m_config

ToolHandle<ISCT_ConfigurationConditionsTool> SCT_ByteStreamErrorsTool::m_config
private
Initial value:
{this, "ConfigTool",
"SCT_ConfigurationConditionsTool/InDetSCT_ConfigurationConditionsTool", "Tool to retrieve SCT Configuration Tool"}

Definition at line 92 of file SCT_ByteStreamErrorsTool.h.

92 {this, "ConfigTool",
93 "SCT_ConfigurationConditionsTool/InDetSCT_ConfigurationConditionsTool", "Tool to retrieve SCT Configuration Tool"};

◆ m_nRetrievalFailure

std::atomic_uint SCT_ByteStreamErrorsTool::m_nRetrievalFailure {0}
mutableprivate

Definition at line 137 of file SCT_ByteStreamErrorsTool.h.

137{0};

◆ m_sct_id

const SCT_ID* SCT_ByteStreamErrorsTool::m_sct_id {nullptr}
private

Definition at line 98 of file SCT_ByteStreamErrorsTool.h.

98{nullptr};

◆ m_SCTDetEleCollKey

SG::ReadCondHandleKey<InDetDD::SiDetectorElementCollection> SCT_ByteStreamErrorsTool::m_SCTDetEleCollKey {this, "SCTDetEleCollKey", "SCT_DetectorElementCollection", "Key of SiDetectorElementCollection for SCT"}
private

Definition at line 96 of file SCT_ByteStreamErrorsTool.h.

96{this, "SCTDetEleCollKey", "SCT_DetectorElementCollection", "Key of SiDetectorElementCollection for SCT"};

The documentation for this class was generated from the following files: