ATLAS Offline Software
SCT_LinkMaskingTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "SCT_LinkMaskingTool.h"
7 
8 // Athena includes
10 
11 // Constructor
12 SCT_LinkMaskingTool::SCT_LinkMaskingTool(const std::string& type, const std::string& name, const IInterface* parent) :
13  base_class(type, name, parent)
14 {
15 }
16 
17 // Initialize
19  ATH_MSG_DEBUG("Initializing configuration");
20 
21  // Retrieve SCT ID helper
22  if (detStore()->retrieve(m_sctHelper, "SCT_ID").isFailure()) {
23  ATH_MSG_FATAL("Could not get SCT ID helper");
24  return StatusCode::FAILURE;
25  }
26 
27  // Read Cond Handle
29 
30  return StatusCode::SUCCESS;
31 }
32 
33 // What level of element can this service report about
36 }
37 
38 // Is an element with this Identifier and hierachy good?
39 bool SCT_LinkMaskingTool::isGood(const Identifier& elementId, const EventContext& ctx, InDetConditions::Hierarchy h) const {
40  if (not canReportAbout(h)) return true;
41 
42  const SCT_ModuleVetoCondData* condData{getCondData(ctx)};
43  // If database cannot be retrieved, all wafer IDs are good.
44  if (condData==nullptr) return true;
45 
46  // Return the result of database
47  return (not condData->isBadWaferId(elementId));
48 }
49 
51  const EventContext& ctx{Gaudi::Hive::currentContext()};
52 
53  return isGood(elementId, ctx, h);
54 }
55 
56 // Is a wafer with this IdentifierHash good?
57 bool SCT_LinkMaskingTool::isGood(const IdentifierHash& hashId, const EventContext& ctx) const {
58  Identifier elementId{m_sctHelper->wafer_id(hashId)};
59  return isGood(elementId, ctx, InDetConditions::SCT_SIDE);
60 }
61 
62 bool SCT_LinkMaskingTool::isGood(const IdentifierHash& hashId) const {
63  const EventContext& ctx{Gaudi::Hive::currentContext()};
64 
65  return isGood(hashId, ctx);
66 }
67 
71  if (not condDataHandle.isValid()) {
72  ATH_MSG_ERROR("Failed to get " << m_condKey.key());
73  return;
74  }
75  const SCT_ModuleVetoCondData* condData{condDataHandle.cptr()};
76  if (whandle) {
77  whandle->addDependency (condDataHandle);
78  }
79  if (condData) {
80  std::vector<bool> &status = element_status.getElementStatus();
81  if (status.empty()) {
82  status.resize(m_sctHelper->wafer_hash_max(),true);
83  }
84  for (const Identifier &wafer_id: condData->badWaferIds()) {
85  status.at( m_sctHelper->wafer_hash(wafer_id) ) = false;
86  }
87  }
88 }
89 
91 SCT_LinkMaskingTool::getCondData(const EventContext& ctx) const {
93  return condData.retrieve();
94 }
SCT_LinkMaskingTool::m_sctHelper
const SCT_ID * m_sctHelper
ID helper for SCT.
Definition: SCT_LinkMaskingTool.h:57
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...
InDet::SiDetectorElementStatus::getElementStatus
const std::vector< bool > & getElementStatus() const
Definition: SiDetectorElementStatus.h:116
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
SCT_LinkMaskingTool::SCT_LinkMaskingTool
SCT_LinkMaskingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: SCT_LinkMaskingTool.cxx:12
SCT_LinkMaskingTool::isGood
virtual bool isGood(const Identifier &elementId, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override
Is the detector element good?
Definition: SCT_LinkMaskingTool.cxx:50
SCT_DetectorElementStatus.h
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_LinkMaskingTool::m_condKey
SG::ReadCondHandleKey< SCT_ModuleVetoCondData > m_condKey
Definition: SCT_LinkMaskingTool.h:60
SCT_ModuleVetoCondData
Class for data object used in SCT_ModuleVetoCondAlg, SCT_LinkMaskingCondAlg, SCT_ModuleVetoTool,...
Definition: SCT_ModuleVetoCondData.h:27
SCT_LinkMaskingTool::initialize
virtual StatusCode initialize() override
Definition: SCT_LinkMaskingTool.cxx:18
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
InDet::SiDetectorElementStatus
Definition: SiDetectorElementStatus.h:62
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
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
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SCT_ID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: SCT_ID.cxx:645
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
h
SCT_LinkMaskingTool::getCondData
const SCT_ModuleVetoCondData * getCondData(const EventContext &ctx) const
Definition: SCT_LinkMaskingTool.cxx:91
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
merge.status
status
Definition: merge.py:17
SCT_ID::wafer_id
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int side) const
For a single side of module.
Definition: SCT_ID.h:464
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_SIDE
@ SCT_SIDE
Definition: InDetHierarchy.h:14
InDetConditions::DEFAULT
@ DEFAULT
Definition: InDetHierarchy.h:14
SCT_LinkMaskingTool::getDetectorElementStatus
virtual void getDetectorElementStatus(const EventContext &ctx, InDet::SiDetectorElementStatus &element_status, SG::WriteCondHandle< InDet::SiDetectorElementStatus > *whandle) const override
Definition: SCT_LinkMaskingTool.cxx:68
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
SCT_LinkMaskingTool.h
SCT_LinkMaskingTool::canReportAbout
virtual bool canReportAbout(InDetConditions::Hierarchy h) const override
Can the service report about the given component? (chip, module...)
Definition: SCT_LinkMaskingTool.cxx:34
SG::WriteCondHandle::addDependency
void addDependency(const EventIDRange &range)
Definition: WriteCondHandle.h:275
Identifier
Definition: IdentifierFieldParser.cxx:14