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  return element_status;
141 }
142 
143 bool
144 SCT_ConditionsSummaryTool::isGood(const IdentifierHash& /*elementHash*/, const Identifier& elementId, const EventContext& ctx) const {
145  if (not m_noReports) {
146  for (const ToolHandle<ISCT_ConditionsTool>& tool: m_toolHandles) {
147  if (tool->canReportAbout(InDetConditions::SCT_STRIP) and (not tool->isGood(elementId, ctx))) return false;
148  }
149  }
150  return true;
151 }
152 
153 double
154 SCT_ConditionsSummaryTool::goodFraction(const IdentifierHash& /*elementHash*/, const Identifier& /*idStart*/, const Identifier& /*idEnd*/, const EventContext& /*ctx*/) const {
155  double result{1.0};
156  ATH_MSG_WARNING("goodFraction is a deprecated function always returning 1.0 ");
157  return result;
158 }
159 
160 bool
161 SCT_ConditionsSummaryTool::hasBSError(const IdentifierHash& /*elementHash*/, const EventContext& /*ctx*/) const {
162  ATH_MSG_WARNING("hasBSError() is not implemented for SCT_ConditionsSummaryTool");
163  return true;
164 }
165 
166 bool
167 SCT_ConditionsSummaryTool::hasBSError(const IdentifierHash& /*elementHash*/, Identifier /*elementId*/, const EventContext& /*ctx*/) const {
168  ATH_MSG_WARNING("hasBSError() is not implemented for SCT_ConditionsSummaryTool");
169  return true;
170 }
171 
172 uint64_t
173 SCT_ConditionsSummaryTool::getBSErrorWord(const IdentifierHash& /*moduleHash*/, const EventContext& /*ctx*/) const {
174  ATH_MSG_WARNING("getBSErrorWord() is not implemented for SCT_ConditionsSummaryTool");
175  return 0;
176 }
177 
178 uint64_t
179 SCT_ConditionsSummaryTool::getBSErrorWord(const IdentifierHash& /*moduleHash*/, const int /*index*/, const EventContext& /*ctx*/) const {
180  ATH_MSG_WARNING("getBSErrorWord() is not implemented for SCT_ConditionsSummaryTool");
181  return 0;
182 }
183 
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:76
SCT_ConditionsSummaryTool::m_SCTDetElStatusCondKey
SG::ReadCondHandleKey< InDet::SiDetectorElementStatus > m_SCTDetElStatusCondKey
Definition: SCT_ConditionsSummaryTool.h:80
get_generator_info.result
result
Definition: get_generator_info.py:21
SCT_ConditionsSummaryTool::hasBSError
virtual bool hasBSError(const IdentifierHash &elementHash, const EventContext &ctx) const override
Definition: SCT_ConditionsSummaryTool.cxx:161
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:81
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:154
InDetConditions::Hierarchy
Hierarchy
Definition: InDetHierarchy.h:14
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
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
ret
T ret(T t)
Definition: rootspy.cxx:260
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
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
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
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
SCT_ConditionsSummaryTool::m_SCTDetElStatusEventKey
SG::ReadHandleKey< InDet::SiDetectorElementStatus > m_SCTDetElStatusEventKey
Definition: SCT_ConditionsSummaryTool.h:78
h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
SCT_ConditionsSummaryTool::m_noReports
bool m_noReports
Definition: SCT_ConditionsSummaryTool.h:84
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
SCT_ConditionsSummaryTool.h
SCT_ConditionsSummaryTool::getBSErrorWord
virtual uint64_t getBSErrorWord(const IdentifierHash &moduleHash, const EventContext &ctx) const override
Definition: SCT_ConditionsSummaryTool.cxx:173
IdentifierHash
Definition: IdentifierHash.h:38
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:74
SG::WriteCondHandle::addDependency
void addDependency(const EventIDRange &range)
Definition: WriteCondHandle.h:275
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37