ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_FlaggedConditionTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7// Athena
12
13// Constructor
14SCT_FlaggedConditionTool::SCT_FlaggedConditionTool(const std::string& type, const std::string& name, const IInterface* parent):
15 base_class(type, name, parent)
16{
17}
18
19// Initialize
21 ATH_MSG_INFO("SCT_FlaggedConditionTool::initialize()");
22
23 // Retrieve SCT helper
24 if (detStore()->retrieve(m_sctID, "SCT_ID").isFailure()) {
25 ATH_MSG_ERROR("SCT helper failed to retrieve");
26 return StatusCode::FAILURE;
27 }
28
29 ATH_CHECK(m_badIds.initialize());
30
31 return StatusCode::SUCCESS;
32}
33
34// Finalize
36 return StatusCode::SUCCESS;
37}
38
39// Detector elements that this service can report about
43
44// Is this element good (by Identifier)?
45bool SCT_FlaggedConditionTool::isGood(const Identifier& elementId, const EventContext& ctx, InDetConditions::Hierarchy h) const {
46 if (not canReportAbout(h)) return true;
47 const IdentifierHash hashId{m_sctID->wafer_hash(elementId)};
48 return isGood(hashId, ctx);
49}
50
52 const EventContext& ctx{Gaudi::Hive::currentContext()};
53
54 return isGood(elementId, ctx, h);
55}
56
57// Is this element good (by IdentifierHash)?
58bool SCT_FlaggedConditionTool::isGood(const IdentifierHash& hashId, const EventContext& ctx) const {
59 const IDCInDetBSErrContainer* badIds{getCondData(ctx)};
60 if (badIds==nullptr) {
62 ATH_MSG_WARNING(m_badIds.key() << " cannot be retrieved. (isGood)");
65 ATH_MSG_WARNING("Disabling this type of messages from " << name());
66 }
67 }
68 return false;
69 }
70
71 return (not badIds->present(hashId));
72}
73
76 const IDCInDetBSErrContainer* badIds{getCondData(ctx)};
77 if (whandle) {
78 ATH_MSG_ERROR("SCT_FlaggedConditionTool is not for conditions objects");
80 }
81 std::vector<bool> &status = element_status.getElementStatus();
82 if (badIds==nullptr) {
84 ATH_MSG_WARNING(m_badIds.key() << " cannot be retrieved. (isGood)");
87 ATH_MSG_WARNING("Disabling this type of messages from " << name());
88 }
89 }
90 status.clear();
91 status.resize(m_sctID->wafer_hash_max(),false);
92 return;
93 }
94 if (status.empty()) {
95 status.resize(m_sctID->wafer_hash_max(),true);
96 }
97
98 for (size_t hash : badIds->getMask()) {
99 status.at(hash)=false;
100 }
101}
102
103
105 const EventContext& ctx{Gaudi::Hive::currentContext()};
106
107 return isGood(hashId, ctx);
108}
109
110// Retrieve the reason why the wafer is flagged as bad (by IdentifierHash)
111// If wafer is not found return a null string
112const std::string& SCT_FlaggedConditionTool::details(const IdentifierHash& hashId, const EventContext& ctx) const {
113 static const std::string nullString;
114
115 const IDCInDetBSErrContainer* badIds{getCondData(ctx)};
116 if (badIds==nullptr) {
118 ATH_MSG_WARNING(m_badIds.key() << " cannot be retrieved. (details)");
121 ATH_MSG_WARNING("Disabling this type of messages from " << name());
122 }
123 }
124 return nullString;
125 }
126
127 if (badIds->present(hashId)) {
128 const IDCInDetBSErrContainer::ErrorCode value{badIds->retrieve(hashId)};
129 if (value>0) {
131 if (value & (1 << error)) return SCT_FlaggedCondEnum::ErrorTypeDescription[error];
132 }
133 }
134 }
135 return nullString;
136}
137
138const std::string& SCT_FlaggedConditionTool::details(const IdentifierHash& hashId) const {
139 const EventContext& ctx{Gaudi::Hive::currentContext()};
140 return details(hashId, ctx);
141}
142
143// Retrieve the reason why the wafer is flagged as bad (by Identifier)
144// If wafer is not found return a null string
145const std::string& SCT_FlaggedConditionTool::details(const Identifier& Id, const EventContext& ctx) const {
146 const IdentifierHash hashId{m_sctID->wafer_hash(Id)};
147 return details(hashId, ctx);
148}
149
150const std::string& SCT_FlaggedConditionTool::details(const Identifier& Id) const {
151 const EventContext& ctx{Gaudi::Hive::currentContext()};
152 return details(Id, ctx);
153}
154
155int SCT_FlaggedConditionTool::numBadIds(const EventContext& ctx) const {
156 const IDCInDetBSErrContainer* badIds{getCondData(ctx)};
157 if (badIds==nullptr) {
159 ATH_MSG_WARNING(m_badIds.key() << " cannot be retrieved. (numBadIds)");
162 ATH_MSG_WARNING("Disabling this type of messages from " << name());
163 }
164 }
165 return -1;
166 }
167
168 return static_cast<int>(badIds->numberSet());
169}
170
172 const EventContext& ctx{Gaudi::Hive::currentContext()};
173 return numBadIds(ctx);
174}
175
176const IDCInDetBSErrContainer* SCT_FlaggedConditionTool::getBadIds(const EventContext& ctx) const {
177 return getCondData(ctx);
178}
179
181 const EventContext& ctx{Gaudi::Hive::currentContext()};
182 return getBadIds(ctx);
183}
184
187 if (not condData.isValid()) {
189 ATH_MSG_WARNING("Failed to get " << m_badIds.key());
192 ATH_MSG_WARNING("Disabling this type of messages from " << name());
193 }
194 }
195 return nullptr;
196 }
197 return condData.cptr();
198}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
This is an Identifier helper class for the SCT subdetector.
Header file for AthHistogramAlgorithm.
IDC like storage for BS errors, TODO, customise implementation further so that we store int rather th...
bool present(size_t i) const
Is the value for this has set and also accepted in the mask.
T retrieve(size_t i) const
Retrieve the value of the hash, if accessible according to the mask.
const std::set< size_t > & getMask() const
size_t numberSet() const
Return the number of entries set and accessible according to the mask.
This is a "hash" representation of an Identifier.
const std::vector< bool > & getElementStatus() const
SG::ReadHandleKey< IDCInDetBSErrContainer > m_badIds
virtual StatusCode initialize() override
UnsignedIntegerProperty m_maxNumWarnForFailures
virtual StatusCode finalize() override
virtual int numBadIds() const override
Get number flagged as bad (per event)
SCT_FlaggedConditionTool(const std::string &type, const std::string &name, const IInterface *parent)
const IDCInDetBSErrContainer * getCondData(const EventContext &ctx) const
virtual const std::string & details(const Identifier &id) const override
Get the reason why the wafer is bad (by Identifier)
virtual bool isGood(const Identifier &elementId, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override
Is the detector element good?
virtual bool canReportAbout(InDetConditions::Hierarchy h) const override
Can the tool report about the given component?
virtual const IDCInDetBSErrContainer * getBadIds() const override
Get IdentifierHashs ofwafers flagged as bad + reason (per event)
virtual void getDetectorElementStatus(const EventContext &ctx, InDet::SiDetectorElementStatus &element_status, SG::WriteCondHandle< InDet::SiDetectorElementStatus > *whandle) const override
const SCT_ID * m_sctID
ID helper for SCT.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
void addDependency(const EventIDRange &range)
static const std::vector< std::string > ErrorTypeDescription