![Logo](../../ATLAS-Logo-Square-Blue-RGB.png) |
ATLAS Offline Software
|
#include <SCT_ByteStreamErrorsTool.h>
|
| 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< 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 type of error. More...
|
|
virtual std::set< IdentifierHash > | getErrorSet (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 |
|
|
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 return nullptr. More...
|
|
IDCCacheEntry * | getCacheEntry (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::SiDetectorElement * | getDetectorElement (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...
|
|
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.
◆ N_ELEMENTS
◆ SCT_ByteStreamErrorsTool()
SCT_ByteStreamErrorsTool::SCT_ByteStreamErrorsTool |
( |
const std::string & |
type, |
|
|
const std::string & |
name, |
|
|
const IInterface * |
parent |
|
) |
| |
◆ ~SCT_ByteStreamErrorsTool()
virtual SCT_ByteStreamErrorsTool::~SCT_ByteStreamErrorsTool |
( |
| ) |
|
|
virtualdefault |
◆ abcdErrorChips() [1/2]
unsigned int SCT_ByteStreamErrorsTool::abcdErrorChips |
( |
const Identifier & |
moduleId | ) |
const |
|
overridevirtual |
◆ abcdErrorChips() [2/2]
unsigned int SCT_ByteStreamErrorsTool::abcdErrorChips |
( |
const Identifier & |
moduleId, |
|
|
const EventContext & |
ctx |
|
) |
| const |
|
overridevirtual |
Definition at line 457 of file SCT_ByteStreamErrorsTool.cxx.
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;
◆ canReportAbout()
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 363 of file SCT_ByteStreamErrorsTool.cxx.
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;
◆ finalize()
StatusCode SCT_ByteStreamErrorsTool::finalize |
( |
| ) |
|
|
overridevirtual |
◆ getCacheEntry()
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.
95 IDCCacheEntry* cacheEntry{m_eventCache.get(ctx)};
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);
◆ getChip()
int SCT_ByteStreamErrorsTool::getChip |
( |
const Identifier & |
stripId, |
|
|
const EventContext & |
ctx |
|
) |
| const |
|
private |
◆ getContainer()
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.
77 if (not idcErrCont.isValid()) {
80 ATH_MSG_INFO(
"SCT_ByteStreamErrorsTool Failed to retrieve BS error container "
82 <<
" from StoreGate.");
90 return idcErrCont.cptr();
◆ getDetectorElement()
Definition at line 509 of file SCT_ByteStreamErrorsTool.cxx.
511 if (not condData.isValid())
return nullptr;
512 return condData->getDetectorElement(waferHash);
◆ getDetectorElementStatus()
Definition at line 162 of file SCT_ByteStreamErrorsTool.cxx.
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;
◆ 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 479 of file SCT_ByteStreamErrorsTool.cxx.
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);
◆ getErrorSet() [1/2]
std::set< IdentifierHash > SCT_ByteStreamErrorsTool::getErrorSet |
( |
int |
errorType | ) |
const |
|
overridevirtual |
◆ 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 331 of file SCT_ByteStreamErrorsTool.cxx.
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);
◆ initialize()
StatusCode SCT_ByteStreamErrorsTool::initialize |
( |
| ) |
|
|
overridevirtual |
◆ isGood() [1/4]
◆ isGood() [2/4]
◆ isGood() [3/4]
◆ isGood() [4/4]
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.
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;
◆ isGoodChip()
bool SCT_ByteStreamErrorsTool::isGoodChip |
( |
const Identifier & |
stripId, |
|
|
const EventContext & |
ctx |
|
) |
| const |
|
private |
Definition at line 268 of file SCT_ByteStreamErrorsTool.cxx.
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);
◆ tempMaskedChips() [1/2]
unsigned int SCT_ByteStreamErrorsTool::tempMaskedChips |
( |
const Identifier & |
moduleId | ) |
const |
|
overridevirtual |
◆ tempMaskedChips() [2/2]
unsigned int SCT_ByteStreamErrorsTool::tempMaskedChips |
( |
const Identifier & |
moduleId, |
|
|
const EventContext & |
ctx |
|
) |
| const |
|
overridevirtual |
Definition at line 435 of file SCT_ByteStreamErrorsTool.cxx.
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;
◆ ATLAS_THREAD_SAFE [1/2]
◆ ATLAS_THREAD_SAFE [2/2]
◆ m_badErrorMask
uint64_t SCT_ByteStreamErrorsTool::m_badErrorMask {} |
|
private |
◆ m_bsIDCErrContainerName
◆ m_cntx_sct
IdContext SCT_ByteStreamErrorsTool::m_cntx_sct |
|
private |
◆ m_config
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 |
◆ m_sct_id
const SCT_ID* SCT_ByteStreamErrorsTool::m_sct_id {nullptr} |
|
private |
◆ m_SCTDetEleCollKey
The documentation for this class was generated from the following files:
def retrieve(aClass, aKey=None)
const std::vector< bool > & getElementStatus() const
IDC like storage for BS errors, TODO, customise implementation further so that we store int rather th...
constexpr unsigned int getChip(unsigned int side, bool swap, unsigned int strip)
Get the physical chip ID for the given strip.
#define ATH_MSG_VERBOSE(x)
const std::string & key() const
Return the StoreGate ID for the referenced object.
Identifier module_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
const IDCInDetBSErrContainer_Cache * IDCCache
constexpr unsigned int getGeometricalFromPhysicalChipID(unsigned int side, bool swap, unsigned int physical_chip_id)
Get the geometrical chip ID from a physica chip ID.
bool swapPhiReadoutDirection() const
Determine if readout direction between online and offline needs swapping.
::StatusCode StatusCode
StatusCode definition for legacy code.
std::unordered_map< size_t, unsigned int > abcdErrorChips
IdContext wafer_context(void) const
IdentifierHash wafer_hash(const Identifier &wafer_id) const
wafer hash from id - optimized
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
ErrorType
SCT byte stream error type enums used in SCT_RodDecoder, SCT_ByteStreamErrorsTool,...
StatusCode initialize(bool used=true)
const std::set< size_t > & getMask() const
#define ATH_MSG_WARNING(x)
const std::vector< ChipFlags_t > & getElementChipStatus() const
unsigned short ChipFlags_t
int side(const Identifier &id) const
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int side) const
For a single side of module.
void addDependency(const EventIDRange &range)