ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_ByteStreamErrorsTool.h
Go to the documentation of this file.
1// -*- C++ -*-
2
3/*
4 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5*/
6
12
13#ifndef SCT_ByteStreamErrorsTool_h
14#define SCT_ByteStreamErrorsTool_h
15
19
22#include "Identifier/Identifier.h"
30
32#include "GaudiKernel/EventContext.h"
33#include "GaudiKernel/EventIDBase.h"
34
36#include <array>
37#include <atomic>
38#include <functional>
39#include <unordered_map>
40#include <vector>
41
43class SCT_ID;
44
63
64class SCT_ByteStreamErrorsTool: public extends<AthAlgTool, ISCT_ByteStreamErrorsTool> {
65
66public:
67 //@name Tool methods
69 SCT_ByteStreamErrorsTool(const std::string& type, const std::string& name, const IInterface* parent);
70 virtual ~SCT_ByteStreamErrorsTool() = default;
71 virtual StatusCode initialize() override;
72 virtual StatusCode finalize() override;
74
75 virtual bool canReportAbout(InDetConditions::Hierarchy h) const override;
76
78 virtual bool isGood(const Identifier& elementId, const EventContext& ctx, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override;
79 virtual bool isGood(const IdentifierHash& elementIdHash, const EventContext& ctx) const override;
80 virtual void getDetectorElementStatus(const EventContext& ctx, InDet::SiDetectorElementStatus &element_status,
82
83 virtual std::set<IdentifierHash> getErrorSet(int errorType, const EventContext& ctx) const override; // Used by SCTRawDataProviderTool and others
84
85 virtual unsigned int tempMaskedChips(const Identifier& moduleId, const EventContext& ctx) const override; // Internally used
86 virtual unsigned int abcdErrorChips(const Identifier& moduleId, const EventContext& ctx) const override; // Internally used
87
88
89private:
91
92 ToolHandle<ISCT_ConfigurationConditionsTool> m_config{this, "ConfigTool",
93 "SCT_ConfigurationConditionsTool/InDetSCT_ConfigurationConditionsTool", "Tool to retrieve SCT Configuration Tool"};
94
95 SG::ReadHandleKey<IDCInDetBSErrContainer> m_bsIDCErrContainerName{this, "IDCByteStreamErrContainer", "SCT_ByteStreamErrs", "SCT BS error key for IDC variant"};
96 SG::ReadCondHandleKey<InDetDD::SiDetectorElementCollection> m_SCTDetEleCollKey{this, "SCTDetEleCollKey", "SCT_DetectorElementCollection", "Key of SiDetectorElementCollection for SCT"};
97
98 const SCT_ID* m_sct_id{nullptr};
100 uint64_t m_badErrorMask{};
101
104 EventContext::ContextEvt_t eventId{EventContext::INVALID_CONTEXT_EVT}; // invalid event ID for the start
106 // infomations in granularity of Chips
107 // misisng value mean that the map need updating
108 // 0 as the value denotes no error
109 // error encoding is as follows: pattern for a module has length of 6 bits, side 0 is encoded in bits 0-5, side 1 in bits 6-11
110 // so 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
111 std::unordered_map<size_t, unsigned int> tempMaskedChips;
112 std::unordered_map<size_t, unsigned int> abcdErrorChips;
113
114
115 //Record the set number of the idcErrContainer, if the set numbers are the same, skip the fillData process to save time.
116 unsigned int m_set_number = 0;
117
118 void reset(EventContext::ContextEvt_t evtId, const IDCInDetBSErrContainer_Cache* cache) {
119 eventId = evtId;
120 IDCCache = cache;
121 m_set_number = 0;
122 tempMaskedChips.clear();
123 abcdErrorChips.clear();
124 }
125
126 bool needsUpdate(const EventContext& ctx) const {
127 return eventId != ctx.evt() or eventId == EventContext::INVALID_CONTEXT_EVT;
128 }
129
130 };
132
136 [[nodiscard]] const IDCInDetBSErrContainer* getContainer(const EventContext& ctx) const;
137 mutable std::atomic_uint m_nRetrievalFailure{0};
138
144 [[nodiscard]] IDCCacheEntry* getCacheEntry(const EventContext& ctx) const;
145
149 StatusCode fillData(const EventContext& ctx) const;
150
151 bool isGoodChip(const Identifier& stripId, const EventContext& ctx) const;
152 int getChip(const Identifier& stripId, const EventContext& ctx) const;
153
154 // For isRODSimulatedData, HVisOn and isCondensedReadout
155 const InDetDD::SiDetectorElement* getDetectorElement(const IdentifierHash& waferHash, const EventContext& ctx) const;
156
161 std::pair<StatusCode, unsigned int> getErrorCodeWithCacheUpdate(const Identifier& id, const EventContext& ctx, std::unordered_map<size_t, unsigned int>& whereExected) const;
162
163};
164
165#endif // SCT_ByteStreamErrorsTool_h
Maintain a set of objects, one per slot.
IdentifiableValueCache< IDCInDetBSErrContainer::ErrorCode > IDCInDetBSErrContainer_Cache
interface file for tool that keeps track of errors in the bytestream.
interface file for service that keeps track of configuration conditions
Header containing the InDetHierarchy enum, to avoid pulling in a class every time it is needed and na...
Property holding a SG store/key/clid from which a ReadHandle is made.
Header file for AthHistogramAlgorithm.
IDC like storage for BS errors, TODO, customise implementation further so that we store int rather th...
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
This is a "hash" representation of an Identifier.
Class to hold geometrical description of a silicon detector element.
int getChip(const Identifier &stripId, const EventContext &ctx) const
SG::ReadHandleKey< IDCInDetBSErrContainer > m_bsIDCErrContainerName
const InDetDD::SiDetectorElement * getDetectorElement(const IdentifierHash &waferHash, const EventContext &ctx) const
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
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...
virtual StatusCode initialize() override
Initialize.
virtual ~SCT_ByteStreamErrorsTool()=default
virtual StatusCode finalize() override
Finalize.
StatusCode fillData(const EventContext &ctx) const
Updates information per module & ABCD chip.
ToolHandle< ISCT_ConfigurationConditionsTool > m_config
SCT_ByteStreamErrorsTool(const std::string &type, const std::string &name, const IInterface *parent)
header file for this class.
virtual bool isGood(const Identifier &elementId, const EventContext &ctx, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override
Is the detector element good?
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...
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 ...
virtual bool canReportAbout(InDetConditions::Hierarchy h) const override
Used by ConditionsSummayTool to decide whether to call isGood() for a particular detector element.
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...
bool isGoodChip(const Identifier &stripId, const EventContext &ctx) const
virtual void getDetectorElementStatus(const EventContext &ctx, InDet::SiDetectorElementStatus &element_status, SG::WriteCondHandle< InDet::SiDetectorElementStatus > *whandle) const override
SG::SlotSpecificObj< std::mutex > m_cacheMutex ATLAS_THREAD_SAFE
virtual unsigned int abcdErrorChips(const Identifier &moduleId, const EventContext &ctx) const override
virtual unsigned int tempMaskedChips(const Identifier &moduleId, const EventContext &ctx) const override
This is an Identifier helper class for the SCT subdetector.
Definition SCT_ID.h:68
Property holding a SG store/key/clid from which a ReadHandle is made.
Maintain a set of objects, one per slot.
void reset(EventContext::ContextEvt_t evtId, const IDCInDetBSErrContainer_Cache *cache)
std::unordered_map< size_t, unsigned int > abcdErrorChips
std::unordered_map< size_t, unsigned int > tempMaskedChips
bool needsUpdate(const EventContext &ctx) const
const IDCInDetBSErrContainer_Cache * IDCCache