ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_RODVetoTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
10
11#include "SCT_RODVetoTool.h"
14
15//Athena includes
19
20//STL includes
21#include <algorithm>
22#include <iterator>
23#include <list>
24#include <sstream>
25#include <vector>
26
27// Constructor
28SCT_RODVetoTool::SCT_RODVetoTool(const std::string& type, const std::string& name, const IInterface* parent) :
29 base_class(type, name, parent)
30{
31}
32
33//Initialize
34StatusCode
36 ATH_CHECK(detStore()->retrieve(m_pHelper, "SCT_ID"));
37 ATH_CHECK(m_badModuleIds.initialize());
38
39 return StatusCode::SUCCESS;
40}
41
42//Finalize
43StatusCode
45 return StatusCode::SUCCESS;
46}
47
48bool
54
55bool
56SCT_RODVetoTool::isGood(const Identifier& elementId, const EventContext& ctx, InDetConditions::Hierarchy h) const {
57 if (not canReportAbout(h)) return true;
58 const IdentifierSet* badIds{getCondData(ctx)};
59 if (badIds==nullptr) {
60 ATH_MSG_ERROR("IdentifierSet cannot be retrieved in isGood. true is returned.");
61 return true;
62 }
63 const Identifier waferId{m_pHelper->wafer_id(elementId)};
64 const Identifier moduleId{m_pHelper->module_id(waferId)};
65 bool result{badIds->find(moduleId) == badIds->end()};
66 return result;
67}
68
69bool
70SCT_RODVetoTool::isGood(const IdentifierHash& hashId, const EventContext& ctx) const {
71 Identifier elementId{m_pHelper->wafer_id(hashId)};
72 Identifier moduleId{m_pHelper->module_id(elementId)};
73 return isGood(moduleId, ctx, InDetConditions::SCT_MODULE);
74}
75
76void
80 if (not condDataHandle.isValid() || !condDataHandle.cptr()) {
81 ATH_MSG_ERROR("Failed to get " << m_badModuleIds.key());
82 return;
83 }
84 if (whandle) {
85 whandle->addDependency (condDataHandle);
86 }
87 const IdentifierSet* badIds{ condDataHandle.cptr() };
88 if (badIds==nullptr) {
89 ATH_MSG_ERROR("IdentifierSet cannot be retrieved in isGood. true is returned.");
90 return;
91 }
92 std::vector<bool> &status = element_status.getElementStatus();
93 if (status.empty()) {
94 status.resize(m_pHelper->wafer_hash_max(),true);
95 }
96 for (const Identifier &module_id: *badIds) {
97 for (int side_i=0; side_i<2; ++side_i) {
98 Identifier wafer_id( m_pHelper->wafer_id( m_pHelper->barrel_ec(module_id),
99 m_pHelper->layer_disk(module_id),
100 m_pHelper->phi_module(module_id),
101 m_pHelper->eta_module(module_id),
102 side_i));
103 status.at( m_pHelper->wafer_hash(wafer_id) ) = false;
104 }
105 }
106}
107
108const IdentifierSet*
109SCT_RODVetoTool::getCondData(const EventContext& ctx) const {
111 if (not condData.isValid()) {
112 ATH_MSG_ERROR("Failed to get " << m_badModuleIds.key());
113 return nullptr;
114 }
115 return condData.cptr();
116}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
std::set< Identifier > IdentifierSet
IdentifierSet is std::set of Identifier and used in SCT_RODVetoCondAlg and SCT_RODVetoTool.
This is an Identifier helper class for the SCT subdetector.
header file for tool allowing one to declare modules as bad
Handle class for reading from StoreGate.
Header file for AthHistogramAlgorithm.
This is a "hash" representation of an Identifier.
const std::vector< bool > & getElementStatus() const
const IdentifierSet * getCondData(const EventContext &ctx) const
virtual StatusCode initialize() override
virtual bool canReportAbout(InDetConditions::Hierarchy h) const override
Can the service report about the given component? (chip, module...).
virtual bool isGood(const Identifier &elementId, const EventContext &ctx, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override
Is the detector element good?
virtual StatusCode finalize() override
SG::ReadCondHandleKey< IdentifierSet > m_badModuleIds
const SCT_ID * m_pHelper
virtual void getDetectorElementStatus(const EventContext &ctx, InDet::SiDetectorElementStatus &element_status, SG::WriteCondHandle< InDet::SiDetectorElementStatus > *whandle) const override
SCT_RODVetoTool(const std::string &type, const std::string &name, const IInterface *parent)
const_pointer_type cptr()
void addDependency(const EventIDRange &range)