|
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 456 of file SCT_ByteStreamErrorsTool.cxx.
458 std::scoped_lock<std::mutex> lock{*m_cacheMutex.get(ctx)};
460 if (cacheEntry->IDCCache ==
nullptr) {
467 ATH_MSG_ERROR(
"SCT_ByteStreamErrorsTool Failure getting ABCD chip errors");
469 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 362 of file SCT_ByteStreamErrorsTool.cxx.
366 if (idcErrCont ==
nullptr) {
368 return StatusCode::SUCCESS;
373 unsigned int idcErrCont_set_number = idcErrCont->numberSet();
375 if (cacheEntry->m_set_number == idcErrCont_set_number){
377 return StatusCode::SUCCESS;
379 cacheEntry->m_set_number = idcErrCont_set_number;
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()};
388 for (
const auto& [ hashId, errCode ] : errorcodesforView) {
392 size_t hash =
static_cast<size_t>(module_id.get_compact());
398 cacheEntry->abcdErrorChips[
hash ];
399 cacheEntry->tempMaskedChips[
hash ];
404 ATH_MSG_VERBOSE(
"SCT_ByteStreamErrorsTool filling event cache for module " << module_id <<
" ec " << errCode);
411 if (v_abcdErrorChips) {
412 v_abcdErrorChips >>= SCT_ByteStreamErrors::ABCDError_Chip0;
414 cacheEntry->abcdErrorChips[
hash] |= v_abcdErrorChips;
416 cacheEntry->abcdErrorChips[
hash] = 0;
419 if (v_tempMaskedChips) {
420 v_tempMaskedChips >>= SCT_ByteStreamErrors::TempMaskedChip0;
422 cacheEntry->tempMaskedChips[
hash] |= v_tempMaskedChips;
424 cacheEntry->tempMaskedChips[
hash] = 0;
429 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 508 of file SCT_ByteStreamErrorsTool.cxx.
510 if (not condData.isValid())
return nullptr;
511 return condData->getDetectorElement(waferHash);
◆ getDetectorElementStatus()
Definition at line 161 of file SCT_ByteStreamErrorsTool.cxx.
163 std::scoped_lock<std::mutex> lock{*m_cacheMutex.get(ctx)};
166 if (idcCachePtr ==
nullptr || !idcCachePtr->IDCCache) {
171 ATH_MSG_ERROR(
"SCT_ByteStreamErrorsTool is not for conditions objects");
182 status.resize(idcCachePtr->IDCCache->rawReadAccess().size(),
true);
185 if (not si_element_list.isValid()) {
186 std::stringstream
msg;
188 throw std::runtime_error(
msg.str());
196 if (chip_status.empty()) {
197 chip_status.resize(
status.size(), all_flags_set);
199 unsigned int element_i=0;
200 for (
const auto &
val : idcCachePtr->IDCCache->rawReadAccess()) {
203 status.at(element_i) =
status.at(element_i) & not is_bad;
212 size_t modhash =
static_cast<size_t>(module_id.get_compact());
214 unsigned int badChips{
m_config->badChips(module_id, ctx)};
215 unsigned int v_abcdErrorChips{ getValueOrZero( idcCachePtr->abcdErrorChips, modhash) };
216 unsigned int v_tempMaskedChips{ getValueOrZero( idcCachePtr->tempMaskedChips, modhash) };
218 bool allChipsBad{
true};
222 bool issueABCDError{((v_abcdErrorChips >> chip) & 0
x1) != 0};
223 bool isBadChip{((badChips >> chip) & 0
x1) != 0};
224 bool isTempMaskedChip{((v_tempMaskedChips >> chip) & 0
x1) != 0};
225 bool isBad = (issueABCDError or isBadChip or isTempMaskedChip);
227 allChipsBad &= isBad;
229 status.at(element_i) =
status.at(element_i) & not allChipsBad;
230 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 478 of file SCT_ByteStreamErrorsTool.cxx.
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);
491 cacheEntry->tempMaskedChips[modhash] = 0;
495 if (
sc.isFailure()) {
496 return std::make_pair(StatusCode::FAILURE, 0);
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);
505 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 330 of file SCT_ByteStreamErrorsTool.cxx.
332 std::set<IdentifierHash>
result;
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);
◆ 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)};
128 ATH_MSG_VERBOSE(
"SCT_ByteStreamErrorsTool Bad Error " << errorCode <<
" for ID " << elementIdHash);
136 unsigned int badChips{
m_config->badChips(module_id, ctx)};
140 bool allChipsBad{
true};
143 bool issueABCDError{((v_abcdErrorChips >> chip) & 0
x1) != 0};
144 bool isBadChip{((badChips >> chip) & 0
x1) != 0};
145 bool isTempMaskedChip{((v_tempMaskedChips >> chip) & 0
x1) != 0};
146 allChipsBad = (issueABCDError or isBadChip or isTempMaskedChip);
147 if (not allChipsBad)
break;
◆ isGoodChip()
bool SCT_ByteStreamErrorsTool::isGoodChip |
( |
const Identifier & |
stripId, |
|
|
const EventContext & |
ctx |
|
) |
| const |
|
private |
Definition at line 267 of file SCT_ByteStreamErrorsTool.cxx.
271 if (not moduleId.is_valid()) {
272 ATH_MSG_WARNING(
"moduleId obtained from stripId " << stripId <<
" is invalid.");
284 const unsigned int v_abcdErrorChips{
abcdErrorChips(moduleId, ctx)};
286 const unsigned int badChips{v_tempMaskedChips | v_abcdErrorChips};
289 if (badChips==0)
return true;
296 if ((
side==0 and (badChips & 0x3F)==0) or (
side==1 and (badChips & 0xFC0)==0))
return true;
298 int chip{
getChip(stripId, ctx)};
299 if (chip<0 or chip>=12) {
305 const bool badChip{
static_cast<bool>(badChips & (1<<chip))};
307 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 434 of file SCT_ByteStreamErrorsTool.cxx.
436 std::scoped_lock<std::mutex> lock{*m_cacheMutex.get(ctx)};
438 if (cacheEntry->IDCCache ==
nullptr) {
445 ATH_MSG_ERROR(
"SCT_ByteStreamErrorsTool Failure getting temp masked chip errors");
447 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.
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
IDCInDetBSErrContainer::ErrorCode makeError(ErrorType errType)
<
void addDependency(const EventIDRange &range)