ATLAS Offline Software
SCT_FlaggedConditionTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 // Athena
12 
13 // Constructor
14 SCT_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 
30 
31  return StatusCode::SUCCESS;
32 }
33 
34 // Finalize
36  return StatusCode::SUCCESS;
37 }
38 
39 // Detector elements that this service can report about
42 }
43 
44 // Is this element good (by Identifier)?
45 bool 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)?
58 bool 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
112 const 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 
138 const 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
145 const 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 
150 const std::string& SCT_FlaggedConditionTool::details(const Identifier& Id) const {
151  const EventContext& ctx{Gaudi::Hive::currentContext()};
152  return details(Id, ctx);
153 }
154 
155 int 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 
176 const 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 
185 const IDCInDetBSErrContainer* SCT_FlaggedConditionTool::getCondData(const EventContext& ctx) const {
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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
SCT_FlaggedConditionTool::m_sctID
const SCT_ID * m_sctID
ID helper for SCT.
Definition: SCT_FlaggedConditionTool.h:78
InDet::SiDetectorElementStatus::getElementStatus
const std::vector< bool > & getElementStatus() const
Definition: SiDetectorElementStatus.h:116
SCT_FlaggedConditionTool::m_numWarnForFailures
std::atomic_uint m_numWarnForFailures
Definition: SCT_FlaggedConditionTool.h:76
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
SCT_DetectorElementStatus.h
SCT_FlaggedConditionTool::getDetectorElementStatus
virtual void getDetectorElementStatus(const EventContext &ctx, InDet::SiDetectorElementStatus &element_status, SG::WriteCondHandle< InDet::SiDetectorElementStatus > *whandle) const override
Definition: SCT_FlaggedConditionTool.cxx:74
IDCInDetBSErrContainer
IDC like storage for BS errors, TODO, customise implementation further so that we store int rather th...
Definition: IDCInDetBSErrContainer.h:19
SCT_FlaggedConditionTool::finalize
virtual StatusCode finalize() override
Definition: SCT_FlaggedConditionTool.cxx:35
athena.value
value
Definition: athena.py:122
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
SCT_FlaggedConditionTool::isGood
virtual bool isGood(const Identifier &elementId, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override
Is the detector element good?
Definition: SCT_FlaggedConditionTool.cxx:51
SCT_FlaggedConditionTool::getCondData
const IDCInDetBSErrContainer * getCondData(const EventContext &ctx) const
Definition: SCT_FlaggedConditionTool.cxx:185
SCT_FlaggedConditionTool::m_maxNumWarnForFailures
UnsignedIntegerProperty m_maxNumWarnForFailures
Definition: SCT_FlaggedConditionTool.h:75
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
InDet::SiDetectorElementStatus
Definition: SiDetectorElementStatus.h:62
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
IDetectorElementStatusTool::getInvalidRange
static EventIDRange getInvalidRange()
Definition: IDetectorElementStatusTool.h:33
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SCT_ID::wafer_hash
IdentifierHash wafer_hash(const Identifier &wafer_id) const
wafer hash from id - optimized
Definition: SCT_ID.h:492
SCT_FlaggedConditionTool::numBadIds
virtual int numBadIds() const override
Get number flagged as bad (per event)
Definition: SCT_FlaggedConditionTool.cxx:171
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
IDCInDetBSErrContainer::ErrorCode
uint64_t ErrorCode
Definition: IDCInDetBSErrContainer.h:21
SCT_FlaggedConditionTool::initialize
virtual StatusCode initialize() override
Definition: SCT_FlaggedConditionTool.cxx:20
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
SCT_ID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: SCT_ID.cxx:639
IDetectorElementStatusTool.h
SiDetectorElementCollection.h
h
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
SCT_FlaggedConditionTool::details
virtual const std::string & details(const Identifier &id) const override
Get the reason why the wafer is bad (by Identifier)
Definition: SCT_FlaggedConditionTool.cxx:150
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
SCT_FlaggedCondEnum::NUM_ERROR_TYPES
@ NUM_ERROR_TYPES
Definition: SCT_FlaggedCondEnum.h:28
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
SCT_FlaggedConditionTool::m_badIds
SG::ReadHandleKey< IDCInDetBSErrContainer > m_badIds
Definition: SCT_FlaggedConditionTool.h:73
merge.status
status
Definition: merge.py:17
SCT_FlaggedConditionTool::SCT_FlaggedConditionTool
SCT_FlaggedConditionTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: SCT_FlaggedConditionTool.cxx:14
SCT_FlaggedConditionTool::getBadIds
virtual const IDCInDetBSErrContainer * getBadIds() const override
Get IdentifierHashs ofwafers flagged as bad + reason (per event)
Definition: SCT_FlaggedConditionTool.cxx:180
IdentifierHash
Definition: IdentifierHash.h:38
get_generator_info.error
error
Definition: get_generator_info.py:40
InDetConditions::SCT_SIDE
@ SCT_SIDE
Definition: InDetHierarchy.h:14
InDetConditions::DEFAULT
@ DEFAULT
Definition: InDetHierarchy.h:14
error
Definition: IImpactPoint3dEstimator.h:70
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
SCT_FlaggedConditionTool::canReportAbout
virtual bool canReportAbout(InDetConditions::Hierarchy h) const override
Can the tool report about the given component? (chip, module...)
Definition: SCT_FlaggedConditionTool.cxx:40
SCT_FlaggedConditionTool.h
SG::WriteCondHandle::addDependency
void addDependency(const EventIDRange &range)
Definition: WriteCondHandle.h:275