ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_FlaggedConditionTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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
51// Is this element good (by IdentifierHash)?
52bool SCT_FlaggedConditionTool::isGood(const IdentifierHash& hashId, const EventContext& ctx) const {
53 const IDCInDetBSErrContainer* badIds{getCondData(ctx)};
54 if (badIds==nullptr) {
56 ATH_MSG_WARNING(m_badIds.key() << " cannot be retrieved. (isGood)");
59 ATH_MSG_WARNING("Disabling this type of messages from " << name());
60 }
61 }
62 return false;
63 }
64
65 return (not badIds->present(hashId));
66}
67
70 const IDCInDetBSErrContainer* badIds{getCondData(ctx)};
71 if (whandle) {
72 ATH_MSG_ERROR("SCT_FlaggedConditionTool is not for conditions objects");
74 }
75 std::vector<bool> &status = element_status.getElementStatus();
76 if (badIds==nullptr) {
78 ATH_MSG_WARNING(m_badIds.key() << " cannot be retrieved. (isGood)");
81 ATH_MSG_WARNING("Disabling this type of messages from " << name());
82 }
83 }
84 status.clear();
85 status.resize(m_sctID->wafer_hash_max(),false);
86 return;
87 }
88 if (status.empty()) {
89 status.resize(m_sctID->wafer_hash_max(),true);
90 }
91
92 for (size_t hash : badIds->getMask()) {
93 status.at(hash)=false;
94 }
95}
96
97// Retrieve the reason why the wafer is flagged as bad (by IdentifierHash)
98// If wafer is not found return a null string
99const std::string& SCT_FlaggedConditionTool::details(const IdentifierHash& hashId, const EventContext& ctx) const {
100 static const std::string nullString;
101
102 const IDCInDetBSErrContainer* badIds{getCondData(ctx)};
103 if (badIds==nullptr) {
105 ATH_MSG_WARNING(m_badIds.key() << " cannot be retrieved. (details)");
108 ATH_MSG_WARNING("Disabling this type of messages from " << name());
109 }
110 }
111 return nullString;
112 }
113
114 if (badIds->present(hashId)) {
115 const IDCInDetBSErrContainer::ErrorCode value{badIds->retrieve(hashId)};
116 if (value>0) {
118 if (value & (1 << error)) return SCT_FlaggedCondEnum::ErrorTypeDescription[error];
119 }
120 }
121 }
122 return nullString;
123}
124
125// Retrieve the reason why the wafer is flagged as bad (by Identifier)
126// If wafer is not found return a null string
127const std::string& SCT_FlaggedConditionTool::details(const Identifier& Id, const EventContext& ctx) const {
128 const IdentifierHash hashId{m_sctID->wafer_hash(Id)};
129 return details(hashId, ctx);
130}
131
132int SCT_FlaggedConditionTool::numBadIds(const EventContext& ctx) const {
133 const IDCInDetBSErrContainer* badIds{getCondData(ctx)};
134 if (badIds==nullptr) {
136 ATH_MSG_WARNING(m_badIds.key() << " cannot be retrieved. (numBadIds)");
139 ATH_MSG_WARNING("Disabling this type of messages from " << name());
140 }
141 }
142 return -1;
143 }
144
145 return static_cast<int>(badIds->numberSet());
146}
147
148const IDCInDetBSErrContainer* SCT_FlaggedConditionTool::getBadIds(const EventContext& ctx) const {
149 return getCondData(ctx);
150}
151
154 if (not condData.isValid()) {
156 ATH_MSG_WARNING("Failed to get " << m_badIds.key());
159 ATH_MSG_WARNING("Disabling this type of messages from " << name());
160 }
161 }
162 return nullptr;
163 }
164 return condData.cptr();
165}
#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 bool isGood(const Identifier &elementId, const EventContext &ctx, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override
Is the detector element good?
virtual int numBadIds(const EventContext &ctx) 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 bool canReportAbout(InDetConditions::Hierarchy h) const override
Can the tool report about the given component?
virtual void getDetectorElementStatus(const EventContext &ctx, InDet::SiDetectorElementStatus &element_status, SG::WriteCondHandle< InDet::SiDetectorElementStatus > *whandle) const override
virtual const std::string & details(const Identifier &id, const EventContext &ctx) const override
Get the reason why the wafer is bad (by Identifier).
virtual const IDCInDetBSErrContainer * getBadIds(const EventContext &ctx) const override
Get IdentifierHashs ofwafers flagged as bad + reason (per event).
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