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
71 const EventContext& ctx{Gaudi::Hive::currentContext()};
72
73 return isGood(elementId, ctx, h);
74}
75
76bool
77SCT_RODVetoTool::isGood(const IdentifierHash& hashId, const EventContext& ctx) const {
78 Identifier elementId{m_pHelper->wafer_id(hashId)};
79 Identifier moduleId{m_pHelper->module_id(elementId)};
80 return isGood(moduleId, ctx, InDetConditions::SCT_MODULE);
81}
82
83bool
85 const EventContext& ctx{Gaudi::Hive::currentContext()};
86
87 return isGood(hashId, ctx);
88}
89
90void
94 if (not condDataHandle.isValid() || !condDataHandle.cptr()) {
95 ATH_MSG_ERROR("Failed to get " << m_badModuleIds.key());
96 return;
97 }
98 if (whandle) {
99 whandle->addDependency (condDataHandle);
100 }
101 const IdentifierSet* badIds{ condDataHandle.cptr() };
102 if (badIds==nullptr) {
103 ATH_MSG_ERROR("IdentifierSet cannot be retrieved in isGood. true is returned.");
104 return;
105 }
106 std::vector<bool> &status = element_status.getElementStatus();
107 if (status.empty()) {
108 status.resize(m_pHelper->wafer_hash_max(),true);
109 }
110 for (const Identifier &module_id: *badIds) {
111 for (int side_i=0; side_i<2; ++side_i) {
112 Identifier wafer_id( m_pHelper->wafer_id( m_pHelper->barrel_ec(module_id),
113 m_pHelper->layer_disk(module_id),
114 m_pHelper->phi_module(module_id),
115 m_pHelper->eta_module(module_id),
116 side_i));
117 status.at( m_pHelper->wafer_hash(wafer_id) ) = false;
118 }
119 }
120}
121
122const IdentifierSet*
123SCT_RODVetoTool::getCondData(const EventContext& ctx) const {
125 if (not condData.isValid()) {
126 ATH_MSG_ERROR("Failed to get " << m_badModuleIds.key());
127 return nullptr;
128 }
129 return condData.cptr();
130}
#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
virtual bool isGood(const Identifier &elementId, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override
Is the detector element good?
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 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)