ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_RODVetoTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
10
11#include "SCT_RODVetoTool.h"
14
15//Athena includes
20
21//STL includes
22#include <algorithm>
23#include <iterator>
24#include <list>
25#include <sstream>
26#include <vector>
27
28// Constructor
29SCT_RODVetoTool::SCT_RODVetoTool(const std::string& type, const std::string& name, const IInterface* parent) :
30 base_class(type, name, parent)
31{
32}
33
34//Initialize
35StatusCode
37 ATH_CHECK(detStore()->retrieve(m_pHelper, "SCT_ID"));
38 ATH_CHECK(m_badModuleIds.initialize());
39
40 return StatusCode::SUCCESS;
41}
42
43//Finalize
44StatusCode
46 return StatusCode::SUCCESS;
47}
48
49bool
55
56bool
57SCT_RODVetoTool::isGood(const Identifier& elementId, const EventContext& ctx, InDetConditions::Hierarchy h) const {
58 if (not canReportAbout(h)) return true;
59 const IdentifierSet* badIds{getCondData(ctx)};
60 if (badIds==nullptr) {
61 ATH_MSG_ERROR("IdentifierSet cannot be retrieved in isGood. true is returned.");
62 return true;
63 }
64 const Identifier waferId{m_pHelper->wafer_id(elementId)};
65 const Identifier moduleId{m_pHelper->module_id(waferId)};
66 bool result{badIds->find(moduleId) == badIds->end()};
67 return result;
68}
69
70bool
72 const EventContext& ctx{Gaudi::Hive::currentContext()};
73
74 return isGood(elementId, ctx, h);
75}
76
77bool
78SCT_RODVetoTool::isGood(const IdentifierHash& hashId, const EventContext& ctx) const {
79 Identifier elementId{m_pHelper->wafer_id(hashId)};
80 Identifier moduleId{m_pHelper->module_id(elementId)};
81 return isGood(moduleId, ctx, InDetConditions::SCT_MODULE);
82}
83
84bool
86 const EventContext& ctx{Gaudi::Hive::currentContext()};
87
88 return isGood(hashId, ctx);
89}
90
91void
95 if (not condDataHandle.isValid() || !condDataHandle.cptr()) {
96 ATH_MSG_ERROR("Failed to get " << m_badModuleIds.key());
97 return;
98 }
99 if (whandle) {
100 whandle->addDependency (condDataHandle);
101 }
102 const IdentifierSet* badIds{ condDataHandle.cptr() };
103 if (badIds==nullptr) {
104 ATH_MSG_ERROR("IdentifierSet cannot be retrieved in isGood. true is returned.");
105 return;
106 }
107 std::vector<bool> &status = element_status.getElementStatus();
108 if (status.empty()) {
109 status.resize(m_pHelper->wafer_hash_max(),true);
110 }
111 for (const Identifier &module_id: *badIds) {
112 for (int side_i=0; side_i<2; ++side_i) {
113 Identifier wafer_id( m_pHelper->wafer_id( m_pHelper->barrel_ec(module_id),
114 m_pHelper->layer_disk(module_id),
115 m_pHelper->phi_module(module_id),
116 m_pHelper->eta_module(module_id),
117 side_i));
118 status.at( m_pHelper->wafer_hash(wafer_id) ) = false;
119 }
120 }
121}
122
123const IdentifierSet*
124SCT_RODVetoTool::getCondData(const EventContext& ctx) const {
126 if (not condData.isValid()) {
127 ATH_MSG_ERROR("Failed to get " << m_badModuleIds.key());
128 return nullptr;
129 }
130 return condData.cptr();
131}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
defines an "iterator" over instances of a given type in StoreGateSvc
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)