ATLAS Offline Software
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
SCT_ByteStreamErrorsTool Class Reference

#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. More...
 
virtual ~SCT_ByteStreamErrorsTool ()=default
 
virtual StatusCode initialize () override
 Initialize. More...
 
virtual StatusCode finalize () override
 Finalize. More...
 
virtual bool canReportAbout (InDetConditions::Hierarchy h) const override
 Used by ConditionsSummayTool to decide whether to call isGood() for a particular detector element. More...
 
virtual bool isGood (const Identifier &elementId, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override
 Is the detector element good? More...
 
virtual bool isGood (const Identifier &elementId, const EventContext &ctx, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override
 
virtual bool isGood (const IdentifierHash &elementIdHash) const override
 
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 More...
 
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. More...
 
virtual std::set< IdentifierHashgetErrorSet (int errorType) const override
 
virtual unsigned int tempMaskedChips (const Identifier &moduleId, const EventContext &ctx) const override
 
virtual unsigned int tempMaskedChips (const Identifier &moduleId) const override
 
virtual unsigned int abcdErrorChips (const Identifier &moduleId) 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. More...
 
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. More...
 
StatusCode fillData (const EventContext &ctx) const
 Updates information per module & ABCD chip. More...
 
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. More...
 

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.

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

Enumerator
N_CHIPS_PER_SIDE 
N_SIDES 
N_STRIPS_PER_CHIP 
N_STRIPS_PER_SIDE 

Definition at line 95 of file SCT_ByteStreamErrorsTool.h.

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() [1/2]

unsigned int SCT_ByteStreamErrorsTool::abcdErrorChips ( const Identifier moduleId) const
overridevirtual

Definition at line 473 of file SCT_ByteStreamErrorsTool.cxx.

473  {
474  const EventContext& ctx{Gaudi::Hive::currentContext()};
475  return abcdErrorChips(moduleId, ctx);
476 }

◆ abcdErrorChips() [2/2]

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

Definition at line 456 of file SCT_ByteStreamErrorsTool.cxx.

456  {
457  ATH_MSG_VERBOSE("SCT_ByteStreamErrorsTool abcdErrorChips");
458  std::scoped_lock<std::mutex> lock{*m_cacheMutex.get(ctx)};
459  auto *cacheEntry{getCacheEntry(ctx)};
460  if (cacheEntry->IDCCache == nullptr) {
461  ATH_MSG_VERBOSE("cacheEntry->IDCCache == nullptr");
462  return 0;
463  }
464 
465  auto [status, v_abcdErrorChips] = getErrorCodeWithCacheUpdate(moduleId, ctx, cacheEntry->abcdErrorChips);
466  if (status.isFailure()) {
467  ATH_MSG_ERROR("SCT_ByteStreamErrorsTool Failure getting ABCD chip errors");
468  }
469  return v_abcdErrorChips; // 12 bits are used.
470  // 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
471 }

◆ 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.

67  {
69 }

◆ 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 362 of file SCT_ByteStreamErrorsTool.cxx.

362  {
363  ATH_MSG_VERBOSE("SCT_ByteStreamErrorsTool fillData");
364 
365  const IDCInDetBSErrContainer* idcErrCont{getContainer(ctx)};
366  if (idcErrCont == nullptr) {
367  ATH_MSG_VERBOSE("idcErrCont == nullptr");
368  return StatusCode::SUCCESS;
369  }
370 
371  auto *cacheEntry{getCacheEntry(ctx)};
372 
373  unsigned int idcErrCont_set_number = idcErrCont->numberSet();
374 
375  if (cacheEntry->m_set_number == idcErrCont_set_number){
376  ATH_MSG_VERBOSE("Same set number found, skip the next steps.");
377  return StatusCode::SUCCESS;
378  }else{
379  cacheEntry->m_set_number = idcErrCont_set_number; //update the set number in cacheEntry.
380  }
381 
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()};
387 
388  for (const auto& [ hashId, errCode ] : errorcodesforView) {
389 
390  Identifier wafer_id{m_sct_id->wafer_id(hashId)};
391  Identifier module_id{m_sct_id->module_id(wafer_id)};
392  size_t hash = static_cast<size_t>(module_id.get_compact());
393  if (errCode == uint64_t{0}) {
394  // That means this hashId was decoded but had no error
395  // 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
396  // (see logic in: getErrorCodeWithCacheUpdate)
397  // Note: invocation of the [] operator on the map will create missing entry and set the value to default (here 0)
398  cacheEntry->abcdErrorChips[ hash ];
399  cacheEntry->tempMaskedChips[ hash ];
400  continue;
401  }
402 
403 
404  ATH_MSG_VERBOSE("SCT_ByteStreamErrorsTool filling event cache for module " << module_id << " ec " << errCode);
405 
406  const int side{m_sct_id->side(m_sct_id->wafer_id(hashId))};
407  // Each bit of errCode represents each SCT_ByteStreamErrors for one wafer
408  // Multiple bits can be true.
409  // Convert errCode to 12 bits of abcdErrorChips and 12 bits of tempMaskedChips for one module (=two wafers).
410  IDCInDetBSErrContainer::ErrorCode v_abcdErrorChips{errCode & SCT_ByteStreamErrors::ABCDErrorMask()};
411  if (v_abcdErrorChips) {
412  v_abcdErrorChips >>= SCT_ByteStreamErrors::ABCDError_Chip0; // bit 0 (5) is for chip 0 (5) for both sides
413  v_abcdErrorChips <<= (side*N_CHIPS_PER_SIDE); // bit 0 (6) is for chip 0 on side 0 (1)
414  cacheEntry->abcdErrorChips[hash] |= v_abcdErrorChips;
415  } else {
416  cacheEntry->abcdErrorChips[hash] = 0;
417  }
418  IDCInDetBSErrContainer::ErrorCode v_tempMaskedChips{errCode & SCT_ByteStreamErrors::TempMaskedChipsMask()};
419  if (v_tempMaskedChips) {
420  v_tempMaskedChips >>= SCT_ByteStreamErrors::TempMaskedChip0; // bit 0 (5) is for chip 0 (5) for both sides0
421  v_tempMaskedChips <<= (side*N_CHIPS_PER_SIDE); // bit 0 (6) is for chip 0 on side 0 (1)
422  cacheEntry->tempMaskedChips[hash] |= v_tempMaskedChips;
423  } else {
424  cacheEntry->tempMaskedChips[hash] = 0;
425  }
426 
427  }
428 
429  return StatusCode::SUCCESS;
430 }

◆ 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
private

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 311 of file SCT_ByteStreamErrorsTool.cxx.

311  {
312  const Identifier waferId{m_sct_id->wafer_id(stripId)};
313  const IdentifierHash waferHash{m_sct_id->wafer_hash(waferId)};
314  const InDetDD::SiDetectorElement* siElement{getDetectorElement(waferHash, ctx)};
315  if (siElement==nullptr) {
316  ATH_MSG_DEBUG ("InDetDD::SiDetectorElement is not obtained from stripId " << stripId);
317  return -1;
318  }
319  return SCT::getChip(*m_sct_id, *siElement, stripId);
320 }

◆ getContainer()

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

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  {
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 }

◆ getDetectorElement()

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

Definition at line 508 of file SCT_ByteStreamErrorsTool.cxx.

508  {
510  if (not condData.isValid()) return nullptr;
511  return condData->getDetectorElement(waferHash);
512 }

◆ getDetectorElementStatus()

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

Definition at line 161 of file SCT_ByteStreamErrorsTool.cxx.

162  {
163  std::scoped_lock<std::mutex> lock{*m_cacheMutex.get(ctx)};
164 
165  const auto *idcCachePtr{getCacheEntry(ctx)};
166  if (idcCachePtr == nullptr || !idcCachePtr->IDCCache) {
167  ATH_MSG_VERBOSE("SCT_ByteStreamErrorsTool No cache! ");
168  return;
169  }
170  if (whandle) {
171  ATH_MSG_ERROR("SCT_ByteStreamErrorsTool is not for conditions objects");
173  }
174 
175  if (fillData(ctx).isFailure()) {
176  return; // @TODO what is the correct way to handle this ? set status to false for all ?
177  }
178 
179  std::vector<bool> &status = element_status.getElementStatus();
180  std::vector<InDet::ChipFlags_t> &chip_status = element_status.getElementChipStatus();
181  if (status.empty()) {
182  status.resize(idcCachePtr->IDCCache->rawReadAccess().size(),true);
183  }
185  if (not si_element_list.isValid()) {
186  std::stringstream msg;
187  msg << "Failed to get SCT detector element collection with key " << m_SCTDetEleCollKey.key();
188  throw std::runtime_error(msg.str());
189  }
190  if (whandle) {
191  whandle->addDependency (si_element_list);
192  }
193 
194  constexpr InDet::ChipFlags_t all_flags_set = static_cast<InDet::ChipFlags_t>((1ul<<(N_CHIPS_PER_SIDE)) - 1ul);
196  if (chip_status.empty()) {
197  chip_status.resize(status.size(), all_flags_set);
198  }
199  unsigned int element_i=0;
200  for ( const auto &val : idcCachePtr->IDCCache->rawReadAccess()) {
202  bool is_bad = error_code & m_badErrorMask;
203  status.at(element_i) = status.at(element_i) & not is_bad;
204  if ( is_bad ) {
205  ATH_MSG_VERBOSE("SCT_ByteStreamErrorsTool Bad Error " << error_code << " for ID " << element_i);
206  }
207  else {
208  IdentifierHash hash(element_i);
209  const InDetDD::SiDetectorElement *siElement = si_element_list->getDetectorElement(hash);
210  const Identifier wafer_id{m_sct_id->wafer_id(hash)};
211  const Identifier module_id{m_sct_id->module_id(wafer_id)};
212  size_t modhash = static_cast<size_t>(module_id.get_compact());
213 
214  unsigned int badChips{m_config->badChips(module_id, ctx)}; // @todo only call once for all
215  unsigned int v_abcdErrorChips{ getValueOrZero( idcCachePtr->abcdErrorChips, modhash) };
216  unsigned int v_tempMaskedChips{ getValueOrZero( idcCachePtr->tempMaskedChips, modhash) };
217  const int side{m_sct_id->side(wafer_id)};
218  bool allChipsBad{true};
219  const int chipMax{static_cast<short>(side==0 ? N_CHIPS_PER_SIDE : N_CHIPS_PER_SIDE*N_SIDES)};
220  InDet::ChipFlags_t bad_chip_flags = 0;
221  for (int chip{chipMax-N_CHIPS_PER_SIDE}; chip<chipMax; chip++) {
222  bool issueABCDError{((v_abcdErrorChips >> chip) & 0x1) != 0};
223  bool isBadChip{((badChips >> chip) & 0x1) != 0};
224  bool isTempMaskedChip{((v_tempMaskedChips >> chip) & 0x1) != 0};
225  bool isBad = (issueABCDError or isBadChip or isTempMaskedChip);
226  bad_chip_flags |= static_cast<InDet::ChipFlags_t>(isBad) << SCT::getGeometricalFromPhysicalChipID(side, siElement->swapPhiReadoutDirection(), chip);
227  allChipsBad &= isBad;
228  }
229  status.at(element_i) = status.at(element_i) & not allChipsBad;
230  chip_status.at(element_i) &= (~bad_chip_flags) & all_flags_set;
231  }
232 
233  ++element_i;
234  }
235 }

◆ 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 478 of file SCT_ByteStreamErrorsTool.cxx.

479  {
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);
484 
485  // even if there are no errors for this module at all filled
486  // we want the entry of value 0 so we know we walked over it and do not need to invoke filling again
487  // and and do not need to do it again
488 
489  auto *cacheEntry{getCacheEntry(ctx)};
490  cacheEntry->abcdErrorChips[modhash] = 0;
491  cacheEntry->tempMaskedChips[modhash] = 0;
492 
493  // the content is missing, look for actual errors
494  StatusCode sc{fillData(ctx)};
495  if (sc.isFailure()) {
496  return std::make_pair(StatusCode::FAILURE, 0);
497  }
498  // handle situation when the cache does not contain desired datum after the update
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);
504  }
505  return std::make_pair(StatusCode::SUCCESS, it->second);
506 }

◆ getErrorSet() [1/2]

std::set< IdentifierHash > SCT_ByteStreamErrorsTool::getErrorSet ( int  errorType) const
overridevirtual

Definition at line 350 of file SCT_ByteStreamErrorsTool.cxx.

350  {
351  const EventContext& ctx{Gaudi::Hive::currentContext()};
352  return getErrorSet(errorType, ctx);
353 }

◆ getErrorSet() [2/2]

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 330 of file SCT_ByteStreamErrorsTool.cxx.

330  {
331  ATH_MSG_VERBOSE("SCT_ByteStreamErrorsTool getErrorSet " << errorType);
332  std::set<IdentifierHash> result;
333  if (errorType>=0 and errorType<SCT_ByteStreamErrors::NUM_ERROR_TYPES) {
334  const auto *idcErrCont{getContainer(ctx)};
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);
340  if (SCT_ByteStreamErrors::hasError(errCode, static_cast<SCT_ByteStreamErrors::ErrorType>(errorType))) {
341  result.insert(hashId);
342  }
343  }
344  }
345  }
346  return result;
347 }

◆ 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"));
33 
34  ATH_CHECK(m_config.retrieve());
35 
36  // Read (Cond)Handle Keys
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 }

◆ isGood() [1/4]

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

Definition at line 246 of file SCT_ByteStreamErrorsTool.cxx.

246  {
247  if (not canReportAbout(h)) return true;
248 
250  const IdentifierHash elementIdHash{m_sct_id->wafer_hash(elementId)};
251  return isGood(elementIdHash, ctx);
252  }
254  return isGoodChip(elementId, ctx);
255  }
256 
257  return true;
258 }

◆ isGood() [2/4]

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

Is the detector element good?

Definition at line 261 of file SCT_ByteStreamErrorsTool.cxx.

261  {
262  const EventContext& ctx{Gaudi::Hive::currentContext()};
263  return isGood(elementId, ctx, h);
264 }

◆ isGood() [3/4]

bool SCT_ByteStreamErrorsTool::isGood ( const IdentifierHash elementIdHash) const
overridevirtual

Definition at line 239 of file SCT_ByteStreamErrorsTool.cxx.

239  {
240  const EventContext& ctx{Gaudi::Hive::currentContext()};
241 
242  return isGood(elementIdHash, ctx);
243 }

◆ isGood() [4/4]

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  } // end of cache operations protection via m_cacheMutex, following code has own protection
132 
133  // 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.
134  const Identifier wafer_id{m_sct_id->wafer_id(elementIdHash)};
135  const Identifier module_id{m_sct_id->module_id(wafer_id)};
136  unsigned int badChips{m_config->badChips(module_id, ctx)};
137  unsigned int v_abcdErrorChips{abcdErrorChips(module_id, ctx)};
138  unsigned int v_tempMaskedChips{tempMaskedChips(module_id, ctx)};
139  const int side{m_sct_id->side(wafer_id)};
140  bool allChipsBad{true};
141  const int chipMax{static_cast<short>(side==0 ? N_CHIPS_PER_SIDE : N_CHIPS_PER_SIDE*N_SIDES)};
142  for (int chip{chipMax-N_CHIPS_PER_SIDE}; chip<chipMax; chip++) {
143  bool issueABCDError{((v_abcdErrorChips >> chip) & 0x1) != 0};
144  bool isBadChip{((badChips >> chip) & 0x1) != 0};
145  bool isTempMaskedChip{((v_tempMaskedChips >> chip) & 0x1) != 0};
146  allChipsBad = (issueABCDError or isBadChip or isTempMaskedChip);
147  if (not allChipsBad) break;
148  }
149  return !allChipsBad;
150 }

◆ isGoodChip()

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

Definition at line 267 of file SCT_ByteStreamErrorsTool.cxx.

267  {
268  // This check assumes present SCT.
269  // Get module number
270  const Identifier moduleId{m_sct_id->module_id(stripId)};
271  if (not moduleId.is_valid()) {
272  ATH_MSG_WARNING("moduleId obtained from stripId " << stripId << " is invalid.");
273  return false;
274  }
275 
276  // tempMaskedChips and abcdErrorChips hold 12 bits.
277  // bit 0 (LSB) is chip 0 for side 0.
278  // bit 5 is chip 5 for side 0.
279  // bit 6 is chip 6 for side 1.
280  // bit 11 is chip 11 for side 1.
281  // Temporarily masked chip information
282  const unsigned int v_tempMaskedChips{tempMaskedChips(moduleId, ctx)};
283  // Information of chips with ABCD errors
284  const unsigned int v_abcdErrorChips{abcdErrorChips(moduleId, ctx)};
285  // Take 'OR' of tempMaskedChips and abcdErrorChips
286  const unsigned int badChips{v_tempMaskedChips | v_abcdErrorChips};
287 
288  // If there is no bad chip, this check is done.
289  if (badChips==0) return true;
290 
291  const int side{m_sct_id->side(stripId)};
292  // Check the six chips on the side
293  // 0x3F = 0000 0011 1111
294  // 0xFC0 = 1111 1100 0000
295  // If there is no bad chip on the side, this check is done.
296  if ((side==0 and (badChips & 0x3F)==0) or (side==1 and (badChips & 0xFC0)==0)) return true;
297 
298  int chip{getChip(stripId, ctx)};
299  if (chip<0 or chip>=12) {
300  ATH_MSG_WARNING("chip number is invalid: " << chip);
301  return false;
302  }
303 
304  // Check if the chip is bad
305  const bool badChip{static_cast<bool>(badChips & (1<<chip))};
306 
307  return (not badChip);
308 }

◆ tempMaskedChips() [1/2]

unsigned int SCT_ByteStreamErrorsTool::tempMaskedChips ( const Identifier moduleId) const
overridevirtual

Definition at line 451 of file SCT_ByteStreamErrorsTool.cxx.

451  {
452  const EventContext& ctx{Gaudi::Hive::currentContext()};
453  return tempMaskedChips(moduleId, ctx);
454 }

◆ tempMaskedChips() [2/2]

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

Definition at line 434 of file SCT_ByteStreamErrorsTool.cxx.

434  {
435  ATH_MSG_VERBOSE("SCT_ByteStreamErrorsTool tempMaskedChips");
436  std::scoped_lock<std::mutex> lock{*m_cacheMutex.get(ctx)};
437  auto *cacheEntry{getCacheEntry(ctx)};
438  if (cacheEntry->IDCCache == nullptr) {
439  ATH_MSG_VERBOSE("cacheEntry->IDCCache == nullptr");
440  return 0;
441  }
442 
443  auto [status, v_tempMaskedChips] = getErrorCodeWithCacheUpdate(moduleId, ctx, cacheEntry->tempMaskedChips);
444  if (status.isFailure()) {
445  ATH_MSG_ERROR("SCT_ByteStreamErrorsTool Failure getting temp masked chip errors");
446  }
447  return v_tempMaskedChips; // 12 bits are used.
448  // 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
449 }

Member Data Documentation

◆ ATLAS_THREAD_SAFE [1/2]

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

Definition at line 107 of file SCT_ByteStreamErrorsTool.h.

◆ ATLAS_THREAD_SAFE [2/2]

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

Definition at line 136 of file SCT_ByteStreamErrorsTool.h.

◆ m_badErrorMask

uint64_t SCT_ByteStreamErrorsTool::m_badErrorMask {}
private

Definition at line 105 of file SCT_ByteStreamErrorsTool.h.

◆ m_bsIDCErrContainerName

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

Definition at line 100 of file SCT_ByteStreamErrorsTool.h.

◆ m_cntx_sct

IdContext SCT_ByteStreamErrorsTool::m_cntx_sct
private

Definition at line 104 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 97 of file SCT_ByteStreamErrorsTool.h.

◆ m_nRetrievalFailure

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

Definition at line 142 of file SCT_ByteStreamErrorsTool.h.

◆ m_sct_id

const SCT_ID* SCT_ByteStreamErrorsTool::m_sct_id {nullptr}
private

Definition at line 103 of file SCT_ByteStreamErrorsTool.h.

◆ m_SCTDetEleCollKey

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

Definition at line 101 of file SCT_ByteStreamErrorsTool.h.


The documentation for this class was generated from the following files:
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
SCT_ByteStreamErrorsTool::m_config
ToolHandle< ISCT_ConfigurationConditionsTool > m_config
Definition: SCT_ByteStreamErrorsTool.h:97
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
InDet::SiDetectorElementStatus::getElementStatus
const std::vector< bool > & getElementStatus() const
Definition: SiDetectorElementStatus.h:116
SCT_ByteStreamErrorsTool::getErrorSet
virtual std::set< IdentifierHash > getErrorSet(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 ...
Definition: SCT_ByteStreamErrorsTool.cxx:330
get_generator_info.result
result
Definition: get_generator_info.py:21
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
InDetConditions::SCT_CHIP
@ SCT_CHIP
Definition: InDetHierarchy.h:14
IDCInDetBSErrContainer
IDC like storage for BS errors, TODO, customise implementation further so that we store int rather th...
Definition: IDCInDetBSErrContainer.h:19
SCT::getChip
constexpr unsigned int getChip(unsigned int side, bool swap, unsigned int strip)
Get the physical chip ID for the given strip.
Definition: SCT_ChipUtils.h:26
skel.it
it
Definition: skel.GENtoEVGEN.py:396
SCT_ByteStreamErrorsTool::abcdErrorChips
virtual unsigned int abcdErrorChips(const Identifier &moduleId) const override
Definition: SCT_ByteStreamErrorsTool.cxx:473
SCT_ByteStreamErrorsTool::isGoodChip
bool isGoodChip(const Identifier &stripId, const EventContext &ctx) const
Definition: SCT_ByteStreamErrorsTool.cxx:267
SCT_ByteStreamErrorsTool::getChip
int getChip(const Identifier &stripId, const EventContext &ctx) const
Definition: SCT_ByteStreamErrorsTool.cxx:311
SCT_ByteStreamErrorsTool::m_sct_id
const SCT_ID * m_sct_id
Definition: SCT_ByteStreamErrorsTool.h:103
SCT_ByteStreamErrorsTool::tempMaskedChips
virtual unsigned int tempMaskedChips(const Identifier &moduleId, const EventContext &ctx) const override
Definition: SCT_ByteStreamErrorsTool.cxx:434
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SCT_ID::module_id
Identifier module_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition: SCT_ID.h:416
SCT_ByteStreamErrorsTool::canReportAbout
virtual bool canReportAbout(InDetConditions::Hierarchy h) const override
Used by ConditionsSummayTool to decide whether to call isGood() for a particular detector element.
Definition: SCT_ByteStreamErrorsTool.cxx:67
SCT_ByteStreamErrorsTool::m_badErrorMask
uint64_t m_badErrorMask
Definition: SCT_ByteStreamErrorsTool.h:105
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
TRT::Hit::side
@ side
Definition: HitInfo.h:83
SCT_ByteStreamErrorsTool::m_cntx_sct
IdContext m_cntx_sct
Definition: SCT_ByteStreamErrorsTool.h:104
SCT_ByteStreamErrorsTool::IDCCacheEntry::IDCCache
const IDCInDetBSErrContainer_Cache * IDCCache
Definition: SCT_ByteStreamErrorsTool.h:110
SCT_ByteStreamErrorsTool::isGood
virtual bool isGood(const Identifier &elementId, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override
Is the detector element good?
Definition: SCT_ByteStreamErrorsTool.cxx:261
SCT::getGeometricalFromPhysicalChipID
constexpr unsigned int getGeometricalFromPhysicalChipID(unsigned int side, bool swap, unsigned int physical_chip_id)
Get the geometrical chip ID from a physica chip ID.
Definition: SCT_ChipUtils.h:91
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SCT_ByteStreamErrorsTool::getErrorCodeWithCacheUpdate
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...
Definition: SCT_ByteStreamErrorsTool.cxx:478
InDetDD::SiDetectorElement::swapPhiReadoutDirection
bool swapPhiReadoutDirection() const
Determine if readout direction between online and offline needs swapping.
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
SCT_ByteStreamErrorsTool::IDCCacheEntry::abcdErrorChips
std::unordered_map< size_t, unsigned int > abcdErrorChips
Definition: SCT_ByteStreamErrorsTool.h:117
SCT_ByteStreamErrorsTool::N_STRIPS_PER_SIDE
@ N_STRIPS_PER_SIDE
Definition: SCT_ByteStreamErrorsTool.h:95
IDetectorElementStatusTool::getInvalidRange
static EventIDRange getInvalidRange()
Definition: IDetectorElementStatusTool.h:33
test_pyathena.parent
parent
Definition: test_pyathena.py:15
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SCT_ID::wafer_context
IdContext wafer_context(void) const
Definition: SCT_ID.h:705
SCT_ID::wafer_hash
IdentifierHash wafer_hash(const Identifier &wafer_id) const
wafer hash from id - optimized
Definition: SCT_ID.h:492
detail::ul
unsigned long ul
Definition: PrimitiveHelpers.h:46
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
IDCInDetBSErrContainer::ErrorCode
uint64_t ErrorCode
Definition: IDCInDetBSErrContainer.h:21
SCT_ByteStreamErrorsTool::getCacheEntry
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...
Definition: SCT_ByteStreamErrorsTool.cxx:94
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SCT_ByteStreamErrors::ErrorType
ErrorType
SCT byte stream error type enums used in SCT_RodDecoder, SCT_ByteStreamErrorsTool,...
Definition: SCT_ByteStreamErrors.h:178
SCT_ByteStreamErrorsTool::fillData
StatusCode fillData(const EventContext &ctx) const
Updates information per module & ABCD chip.
Definition: SCT_ByteStreamErrorsTool.cxx:362
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
SCT_ByteStreamErrorsTool::m_bsIDCErrContainerName
SG::ReadHandleKey< IDCInDetBSErrContainer > m_bsIDCErrContainerName
Definition: SCT_ByteStreamErrorsTool.h:100
SCT_ByteStreamErrorsTool::getContainer
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...
Definition: SCT_ByteStreamErrorsTool.cxx:71
SCT_ByteStreamErrorsTool::m_nRetrievalFailure
std::atomic_uint m_nRetrievalFailure
Definition: SCT_ByteStreamErrorsTool.h:142
SCT_ByteStreamErrorsTool::N_STRIPS_PER_CHIP
@ N_STRIPS_PER_CHIP
Definition: SCT_ByteStreamErrorsTool.h:95
IdentifiableValueContainer::getMask
const std::set< size_t > & getMask() const
Definition: IdentifiableValueContainer.h:79
h
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
SCT_FlaggedCondEnum::NUM_ERROR_TYPES
@ NUM_ERROR_TYPES
Definition: SCT_FlaggedCondEnum.h:28
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
InDet::SiDetectorElementStatus::getElementChipStatus
const std::vector< ChipFlags_t > & getElementChipStatus() const
Definition: SiDetectorElementStatus.h:118
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
SCT_ByteStreamErrorsTool::N_CHIPS_PER_SIDE
@ N_CHIPS_PER_SIDE
Definition: SCT_ByteStreamErrorsTool.h:95
SCT_ByteStreamErrorsTool::m_SCTDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
Definition: SCT_ByteStreamErrorsTool.h:101
LArHVGainsPredictor.error_code
error_code
Definition: LArHVGainsPredictor.py:229
SCT_ByteStreamErrorsTool::getDetectorElement
const InDetDD::SiDetectorElement * getDetectorElement(const IdentifierHash &waferHash, const EventContext &ctx) const
Definition: SCT_ByteStreamErrorsTool.cxx:508
InDet::ChipFlags_t
unsigned short ChipFlags_t
Definition: SiDetectorElementStatus.h:60
SCT_ID::side
int side(const Identifier &id) const
Definition: SCT_ID.h:752
SCT_ByteStreamErrorsTool::N_SIDES
@ N_SIDES
Definition: SCT_ByteStreamErrorsTool.h:95
merge.status
status
Definition: merge.py:17
SCT_ID::wafer_id
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int side) const
For a single side of module.
Definition: SCT_ID.h:464
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
InDetConditions::SCT_SIDE
@ SCT_SIDE
Definition: InDetHierarchy.h:14
SCT_Monitoring::badError
@ badError
Definition: SCT_MonitoringNumbers.h:63
SCT_ByteStreamErrors::makeError
IDCInDetBSErrContainer::ErrorCode makeError(ErrorType errType)
<
Definition: ISCT_ByteStreamErrorsTool.h:33
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
SG::WriteCondHandle::addDependency
void addDependency(const EventIDRange &range)
Definition: WriteCondHandle.h:275
Identifier
Definition: IdentifierFieldParser.cxx:14