ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_ConditionsSummaryTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
10
14
15#include "GaudiKernel/EventContext.h"
17
18// Constructor
19SCT_ConditionsSummaryTool::SCT_ConditionsSummaryTool(const std::string& type, const std::string& name, const IInterface* parent) :
20 base_class(type, name, parent)
21{
22}
23
24//Initialize
25StatusCode
27 StatusCode sc{m_toolHandles.retrieve()};
28 if (sc.isFailure()) {
29 ATH_MSG_ERROR("Retrieval of ToolHandleArray<ISCT_ConditionsTool> failed.");
30 return sc;
31 }
32 ATH_CHECK( m_SCTDetEleCollKey.initialize() );
33 if (!m_SCTDetElStatusEventKey.empty() && !m_SCTDetElStatusCondKey.empty()) {
34 ATH_MSG_FATAL("The event data (SCTDetElStatusEventDataBaseKey) and cond data (SCTDetElStatusCondDataBaseKey) keys cannot be set at the same time.");
35 }
38 // Get SCT helper
39 ATH_CHECK(detStore()->retrieve(m_id_sct, "SCT_ID"));
40 m_noReports = m_toolHandles.empty();
41 return sc;
42}
43
44double
45SCT_ConditionsSummaryTool::activeFraction(const IdentifierHash& elementHash, const Identifier& idStart, const Identifier& idEnd, const EventContext& ctx) const {
46 return goodFraction(elementHash, idStart, idEnd, ctx);
47}
48
49bool
50SCT_ConditionsSummaryTool::isActive(const Identifier& elementId, const InDetConditions::Hierarchy h, const EventContext& ctx) const {
51 return isGood(elementId, h, ctx);
52}
53
54bool
55SCT_ConditionsSummaryTool::isActive(const IdentifierHash& elementHash, const EventContext& ctx) const {
56 return isGood(elementHash, ctx);
57}
58
59bool
60SCT_ConditionsSummaryTool::isActive(const IdentifierHash& elementHash, const Identifier& elementId, const EventContext& ctx) const {
61 return isGood(elementHash, elementId, ctx);
62}
63
64bool
65SCT_ConditionsSummaryTool::isGood(const Identifier& elementId, const InDetConditions::Hierarchy h, const EventContext& ctx) const {
66 if (not m_noReports) {
67 for (const ToolHandle<ISCT_ConditionsTool>& tool: m_toolHandles) {
68 if (tool->canReportAbout(h) and (not tool->isGood(elementId, ctx, h))) return false;
69 }
70 }
71 return true;
72}
73
74bool
75SCT_ConditionsSummaryTool::isGood(const IdentifierHash& elementHash, const EventContext& ctx) const {
76 if (not m_noReports) {
77 for (const ToolHandle<ISCT_ConditionsTool>& tool: m_toolHandles) {
78 if ((tool->canReportAbout(InDetConditions::SCT_SIDE) or
79 tool->canReportAbout(InDetConditions::SCT_MODULE)) and
80 (not tool->isGood(elementHash, ctx))) {
81 return false;
82 }
83 }
84 }
85 return true;
86}
87
88namespace {
89 const InDet::SCT_DetectorElementStatus *castToDerived(const InDet::SiDetectorElementStatus *input) {
90 const InDet::SCT_DetectorElementStatus *ret = dynamic_cast<const InDet::SCT_DetectorElementStatus *>(input);
91 if (!ret) {
92 throw std::runtime_error("Object is not of expected type InDet::SCT_DetectorElementStatus");
93 }
94 return ret;
95 }
96}
97std::unique_ptr<InDet::SiDetectorElementStatus>
100 std::string tool_name (name());
101 (void) tool_name;
102 if (!m_SCTDetElStatusCondKey.empty()) {
104 if (whandle) {
105 whandle->addDependency (input_element_status);
106 }
107 return std::make_unique<InDet::SCT_DetectorElementStatus>(*castToDerived(input_element_status.cptr()));
108 }
109 else if (!m_SCTDetElStatusEventKey.empty()) {
111 std::string key (m_SCTDetElStatusEventKey.key());
112 (void) key;
113 return std::make_unique<InDet::SCT_DetectorElementStatus>(*castToDerived(input_element_status.cptr()));
114 }
115 else {
117 if (whandle) {
118 whandle->addDependency (sctDetEleHandle);
119 }
120 const InDetDD::SiDetectorElementCollection* elements(*sctDetEleHandle);
121 return std::make_unique<InDet::SCT_DetectorElementStatus>(*elements);
122 }
123}
124
125std::unique_ptr<InDet::SiDetectorElementStatus>
128 std::unique_ptr<InDet::SiDetectorElementStatus>
129 element_status( createDetectorElementStatus(ctx, whandle) );
130 if (not m_noReports) {
131 for (const ToolHandle<ISCT_ConditionsTool>& tool: m_toolHandles) {
132 // @TODO also check if it can report about chips ?
133 if ((tool->canReportAbout(InDetConditions::SCT_SIDE) or
134 tool->canReportAbout(InDetConditions::SCT_MODULE) or
135 tool->canReportAbout(InDetConditions::SCT_STRIP))) {
136 tool->getDetectorElementStatus(ctx,*element_status,whandle);
137 }
138 }
139 }
140 if (element_status->getElementStatus().empty()) {
141 element_status->getElementStatus().resize( element_status->getDetectorElements().size(), true);
142 }
143 if (element_status->getElementChipStatus().empty()) {
144 element_status->getElementChipStatus().resize( element_status->getDetectorElements().size(), 0xffff);
145 }
146 if (element_status->getBadCells().empty()) {
147 element_status->getBadCells().resize( element_status->getDetectorElements().size());
148 }
149 return element_status;
150}
151
152bool
153SCT_ConditionsSummaryTool::isGood(const IdentifierHash& /*elementHash*/, const Identifier& elementId, const EventContext& ctx, const IInDetConditionsTool::IDCCacheEntry* /*cacheEntry*/) const {
154 if (not m_noReports) {
155 for (const ToolHandle<ISCT_ConditionsTool>& tool: m_toolHandles) {
156 if (tool->canReportAbout(InDetConditions::SCT_STRIP) and (not tool->isGood(elementId, ctx))) return false;
157 }
158 }
159 return true;
160}
161
163 IDCCacheEntry* vector{nullptr};
164 return vector;
165}
166
167double
168SCT_ConditionsSummaryTool::goodFraction(const IdentifierHash& /*elementHash*/, const Identifier& /*idStart*/, const Identifier& /*idEnd*/, const EventContext& /*ctx*/) const {
169 double result{1.0};
170 ATH_MSG_WARNING("goodFraction is a deprecated function always returning 1.0 ");
171 return result;
172}
173
174bool
175SCT_ConditionsSummaryTool::hasBSError(const IdentifierHash& /*elementHash*/, const EventContext& /*ctx*/, const IInDetConditionsTool::IDCCacheEntry* /*cacheEntry*/) const {
176 ATH_MSG_WARNING("hasBSError() is not implemented for SCT_ConditionsSummaryTool");
177 return true;
178}
179
180bool
181SCT_ConditionsSummaryTool::hasBSError(const IdentifierHash& /*elementHash*/, Identifier /*elementId*/, const EventContext& /*ctx*/, const IInDetConditionsTool::IDCCacheEntry* /*cacheEntry*/) const {
182 ATH_MSG_WARNING("hasBSError() is not implemented for SCT_ConditionsSummaryTool");
183 return true;
184}
185
187SCT_ConditionsSummaryTool::getBSErrorWord(const IdentifierHash& /*moduleHash*/, const EventContext& /*ctx*/, const IInDetConditionsTool::IDCCacheEntry* /*cacheEntry*/) const {
188 ATH_MSG_WARNING("getBSErrorWord() is not implemented for SCT_ConditionsSummaryTool");
189 return 0;
190}
191
193SCT_ConditionsSummaryTool::getBSErrorWord(const IdentifierHash& /*moduleHash*/, const int /*index*/, const EventContext& /*ctx*/, const IInDetConditionsTool::IDCCacheEntry* /*cacheEntry*/) const {
194 ATH_MSG_WARNING("getBSErrorWord() is not implemented for SCT_ConditionsSummaryTool");
195 return 0;
196}
197
198
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
header file for baseclass of SCT conditions tools
static Double_t sc
This is an Identifier helper class for the SCT subdetector.
Header file for AthHistogramAlgorithm.
This is a "hash" representation of an Identifier.
Class to hold the SiDetectorElement objects to be put in the detector store.
Event data to hold the status information for SCT modules.
virtual uint64_t getBSErrorWord(const IdentifierHash &moduleHash, const EventContext &ctx, const IDCCacheEntry *cacheEntry=nullptr) const override
virtual bool isActive(const Identifier &elementId, const InDetConditions::Hierarchy h, const EventContext &ctx) const override
virtual IDCCacheEntry * getCacheEntryOut(const EventContext &ctx) const override
virtual StatusCode initialize() override
Tool init.
SG::ReadCondHandleKey< InDet::SiDetectorElementStatus > m_SCTDetElStatusCondKey
ToolHandleArray< ISCT_ConditionsTool > m_toolHandles
const SCT_ID * m_id_sct
Handle to SCT ID helper.
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
virtual std::unique_ptr< InDet::SiDetectorElementStatus > getDetectorElementStatus(const EventContext &ctx, SG::WriteCondHandle< InDet::SiDetectorElementStatus > *whandle) const override
SG::ReadHandleKey< InDet::SiDetectorElementStatus > m_SCTDetElStatusEventKey
SCT_ConditionsSummaryTool(const std::string &type, const std::string &name, const IInterface *parent)
Tool constructor.
virtual double goodFraction(const IdentifierHash &elementHash, const Identifier &idStart, const Identifier &idEnd, const EventContext &ctx) const override
virtual bool hasBSError(const IdentifierHash &elementHash, const EventContext &ctx, const IDCCacheEntry *cacheEntry=nullptr) const override
virtual bool isGood(const Identifier &elementId, const InDetConditions::Hierarchy h, const EventContext &ctx) const override
std::unique_ptr< InDet::SiDetectorElementStatus > createDetectorElementStatus(const EventContext &ctx, SG::WriteCondHandle< InDet::SiDetectorElementStatus > *whandle) const
virtual double activeFraction(const IdentifierHash &elementHash, const Identifier &idStart, const Identifier &idEnd, const EventContext &ctx) const override
const_pointer_type cptr()
const_pointer_type cptr()
Dereference the pointer.
void addDependency(const EventIDRange &range)