ATLAS Offline Software
SCT_ConditionsSummaryTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
14 
15 #include "GaudiKernel/EventContext.h"
16 #include "InDetIdentifier/SCT_ID.h"
17 
18 // Constructor
19 SCT_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
27  StatusCode sc{m_toolHandles.retrieve()};
28  if (sc.isFailure()) {
29  ATH_MSG_ERROR("Retrieval of ToolHandleArray<ISCT_ConditionsTool> failed.");
30  return sc;
31  }
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 
44 double
45 SCT_ConditionsSummaryTool::activeFraction(const IdentifierHash& elementHash, const Identifier& idStart, const Identifier& idEnd, const EventContext& ctx) const {
46  return goodFraction(elementHash, idStart, idEnd, ctx);
47 }
48 
49 bool
50 SCT_ConditionsSummaryTool::isActive(const Identifier& elementId, const InDetConditions::Hierarchy h, const EventContext& ctx) const {
51  return isGood(elementId, h, ctx);
52 }
53 
54 bool
55 SCT_ConditionsSummaryTool::isActive(const IdentifierHash& elementHash, const EventContext& ctx) const {
56  return isGood(elementHash, ctx);
57 }
58 
59 bool
60 SCT_ConditionsSummaryTool::isActive(const IdentifierHash& elementHash, const Identifier& elementId, const EventContext& ctx) const {
61  return isGood(elementHash, elementId, ctx);
62 }
63 
64 bool
65 SCT_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 
74 bool
75 SCT_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 
88 namespace {
91  if (!ret) {
92  throw std::runtime_error("Object is not of expected type InDet::SCT_DetectorElementStatus");
93  }
94  return ret;
95  }
96 }
97 std::unique_ptr<InDet::SiDetectorElementStatus>
100  std::string tool_name (name());
101  (void) tool_name;
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 
125 std::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 
152 bool
153 SCT_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 
167 double
168 SCT_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 
174 bool
175 SCT_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 
180 bool
181 SCT_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 
186 uint64_t
187 SCT_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 
192 uint64_t
193 SCT_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 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
SCT_ConditionsSummaryTool::getDetectorElementStatus
virtual std::unique_ptr< InDet::SiDetectorElementStatus > getDetectorElementStatus(const EventContext &ctx, SG::WriteCondHandle< InDet::SiDetectorElementStatus > *whandle) const override
Definition: SCT_ConditionsSummaryTool.cxx:126
SCT_ConditionsSummaryTool::m_SCTDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
Definition: SCT_ConditionsSummaryTool.h:78
InDet::SiDetectorElementStatus::getElementStatus
const std::vector< bool > & getElementStatus() const
Definition: SiDetectorElementStatus.h:116
SCT_ConditionsSummaryTool::m_SCTDetElStatusCondKey
SG::ReadCondHandleKey< InDet::SiDetectorElementStatus > m_SCTDetElStatusCondKey
Definition: SCT_ConditionsSummaryTool.h:82
get_generator_info.result
result
Definition: get_generator_info.py:21
SCT_ConditionsSummaryTool::isGood
virtual bool isGood(const Identifier &elementId, const InDetConditions::Hierarchy h, const EventContext &ctx) const override
Definition: SCT_ConditionsSummaryTool.cxx:65
InDetDD::SiDetectorElementCollection
Definition: SiDetectorElementCollection.h:30
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
InDet::SCT_DetectorElementStatus
Event data to hold the status information for SCT modules.
Definition: SCT_DetectorElementStatus.h:13
SCT_ConditionsSummaryTool::m_id_sct
const SCT_ID * m_id_sct
Handle to SCT ID helper.
Definition: SCT_ConditionsSummaryTool.h:83
ISCT_ConditionsTool.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
SCT_DetectorElementStatus.h
SCT_ConditionsSummaryTool::goodFraction
virtual double goodFraction(const IdentifierHash &elementHash, const Identifier &idStart, const Identifier &idEnd, const EventContext &ctx) const override
Definition: SCT_ConditionsSummaryTool.cxx:168
InDet::SiDetectorElementStatus::getBadCells
const std::vector< std::vector< unsigned short > > & getBadCells() const
Definition: SiDetectorElementStatus.h:120
InDetConditions::Hierarchy
Hierarchy
Definition: InDetHierarchy.h:14
SCT_ConditionsSummaryTool::getBSErrorWord
virtual uint64_t getBSErrorWord(const IdentifierHash &moduleHash, const EventContext &ctx, const IDCCacheEntry *cacheEntry=nullptr) const override
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SCT_ConditionsSummaryTool::createDetectorElementStatus
std::unique_ptr< InDet::SiDetectorElementStatus > createDetectorElementStatus(const EventContext &ctx, SG::WriteCondHandle< InDet::SiDetectorElementStatus > *whandle) const
Definition: SCT_ConditionsSummaryTool.cxx:98
SCT_ConditionsSummaryTool::isActive
virtual bool isActive(const Identifier &elementId, const InDetConditions::Hierarchy h, const EventContext &ctx) const override
Definition: SCT_ConditionsSummaryTool.cxx:50
SCT_ConditionsSummaryTool::activeFraction
virtual double activeFraction(const IdentifierHash &elementHash, const Identifier &idStart, const Identifier &idEnd, const EventContext &ctx) const override
Definition: SCT_ConditionsSummaryTool.cxx:45
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
InDetConditions::SCT_MODULE
@ SCT_MODULE
Definition: InDetHierarchy.h:14
InDet::SiDetectorElementStatus
Definition: SiDetectorElementStatus.h:62
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
vector
Definition: MultiHisto.h:13
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
test_pyathena.parent
parent
Definition: test_pyathena.py:15
SCT_ConditionsSummaryTool::SCT_ConditionsSummaryTool
SCT_ConditionsSummaryTool(const std::string &type, const std::string &name, const IInterface *parent)
Tool constructor.
Definition: SCT_ConditionsSummaryTool.cxx:19
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SCT_ConditionsSummaryTool::hasBSError
virtual bool hasBSError(const IdentifierHash &elementHash, const EventContext &ctx, const IDCCacheEntry *cacheEntry=nullptr) const override
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
SCT_ConditionsSummaryTool::getCacheEntryOut
virtual IDCCacheEntry * getCacheEntryOut(const EventContext &ctx) const override
Definition: SCT_ConditionsSummaryTool.cxx:162
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
InDet::SiDetectorElementStatus::getDetectorElements
const std::vector< InDetDD::SiDetectorElement * > & getDetectorElements() const
Definition: SiDetectorElementStatus.h:94
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
SCT_ConditionsSummaryTool::m_SCTDetElStatusEventKey
SG::ReadHandleKey< InDet::SiDetectorElementStatus > m_SCTDetElStatusEventKey
Definition: SCT_ConditionsSummaryTool.h:80
h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
SCT_ConditionsSummaryTool::m_noReports
bool m_noReports
Definition: SCT_ConditionsSummaryTool.h:86
InDet::SiDetectorElementStatus::getElementChipStatus
const std::vector< ChipFlags_t > & getElementChipStatus() const
Definition: SiDetectorElementStatus.h:118
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
SCT_ConditionsSummaryTool.h
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
InDetConditions::SCT_STRIP
@ SCT_STRIP
Definition: InDetHierarchy.h:14
InDetConditions::SCT_SIDE
@ SCT_SIDE
Definition: InDetHierarchy.h:14
SCT_ConditionsSummaryTool::initialize
virtual StatusCode initialize() override
Tool init.
Definition: SCT_ConditionsSummaryTool.cxx:26
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
SCT_ConditionsSummaryTool::m_toolHandles
ToolHandleArray< ISCT_ConditionsTool > m_toolHandles
Definition: SCT_ConditionsSummaryTool.h:76
IInDetConditionsTool::IDCCacheEntry
Definition: IInDetConditionsTool.h:33
SG::WriteCondHandle::addDependency
void addDependency(const EventIDRange &range)
Definition: WriteCondHandle.h:275
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
Identifier
Definition: IdentifierFieldParser.cxx:14