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-2022 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, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override;
79 virtual bool isGood(const Identifier& elementId, const EventContext& ctx, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override;
80 virtual bool isGood(const IdentifierHash& elementIdHash) const override;
81 virtual bool isGood(const IdentifierHash& elementIdHash, const EventContext& ctx) const override;
82 virtual void getDetectorElementStatus(const EventContext& ctx, InDet::SiDetectorElementStatus &element_status,
84
85 virtual std::set<IdentifierHash> getErrorSet(int errorType, const EventContext& ctx) const override; // Used by SCTRawDataProviderTool and others
86 virtual std::set<IdentifierHash> getErrorSet(int errorType) const override; // Used by SCTRawDataProviderTool and others
87
88 virtual unsigned int tempMaskedChips(const Identifier& moduleId, const EventContext& ctx) const override; // Internally used
89 virtual unsigned int tempMaskedChips(const Identifier& moduleId) const override;
90 virtual unsigned int abcdErrorChips(const Identifier& moduleId) const override; // Internally used
91 virtual unsigned int abcdErrorChips(const Identifier& moduleId, const EventContext& ctx) const override; // Internally used
92
93
94private:
96
97 ToolHandle<ISCT_ConfigurationConditionsTool> m_config{this, "ConfigTool",
98 "SCT_ConfigurationConditionsTool/InDetSCT_ConfigurationConditionsTool", "Tool to retrieve SCT Configuration Tool"};
99
100 SG::ReadHandleKey<IDCInDetBSErrContainer> m_bsIDCErrContainerName{this, "IDCByteStreamErrContainer", "SCT_ByteStreamErrs", "SCT BS error key for IDC variant"};
101 SG::ReadCondHandleKey<InDetDD::SiDetectorElementCollection> m_SCTDetEleCollKey{this, "SCTDetEleCollKey", "SCT_DetectorElementCollection", "Key of SiDetectorElementCollection for SCT"};
102
103 const SCT_ID* m_sct_id{nullptr};
105 uint64_t m_badErrorMask{};
106
109 EventContext::ContextEvt_t eventId{EventContext::INVALID_CONTEXT_EVT}; // invalid event ID for the start
111 // infomations in granularity of Chips
112 // misisng value mean that the map need updating
113 // 0 as the value denotes no error
114 // 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
115 // 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
116 std::unordered_map<size_t, unsigned int> tempMaskedChips;
117 std::unordered_map<size_t, unsigned int> abcdErrorChips;
118
119
120 //Record the set number of the idcErrContainer, if the set numbers are the same, skip the fillData process to save time.
121 unsigned int m_set_number = 0;
122
123 void reset(EventContext::ContextEvt_t evtId, const IDCInDetBSErrContainer_Cache* cache) {
124 eventId = evtId;
125 IDCCache = cache;
126 m_set_number = 0;
127 tempMaskedChips.clear();
128 abcdErrorChips.clear();
129 }
130
131 bool needsUpdate(const EventContext& ctx) const {
132 return eventId != ctx.evt() or eventId == EventContext::INVALID_CONTEXT_EVT;
133 }
134
135 };
137
141 [[nodiscard]] const IDCInDetBSErrContainer* getContainer(const EventContext& ctx) const;
142 mutable std::atomic_uint m_nRetrievalFailure{0};
143
149 [[nodiscard]] IDCCacheEntry* getCacheEntry(const EventContext& ctx) const;
150
154 StatusCode fillData(const EventContext& ctx) const;
155
156 bool isGoodChip(const Identifier& stripId, const EventContext& ctx) const;
157 int getChip(const Identifier& stripId, const EventContext& ctx) const;
158
159 // For isRODSimulatedData, HVisOn and isCondensedReadout
160 const InDetDD::SiDetectorElement* getDetectorElement(const IdentifierHash& waferHash, const EventContext& ctx) const;
161
166 std::pair<StatusCode, unsigned int> getErrorCodeWithCacheUpdate(const Identifier& id, const EventContext& ctx, std::unordered_map<size_t, unsigned int>& whereExected) const;
167
168};
169
170#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
virtual bool isGood(const Identifier &elementId, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override
Is the detector element good?
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 unsigned int abcdErrorChips(const Identifier &moduleId) const override
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 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