ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_TdaqEnabledTool.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_TdaqEnabledTool.h"
14
18
19// Constructor
20SCT_TdaqEnabledTool::SCT_TdaqEnabledTool(const std::string& type, const std::string& name, const IInterface* parent):
21 base_class(type, name, parent)
22{
23}
24
25//Initialize
26StatusCode
28 const std::string databaseUseString{m_useDatabase?"":"not "};
29 ATH_MSG_INFO(" Database will "<<databaseUseString<<"be used.");
30
31 ATH_CHECK(detStore()->retrieve(m_pHelper,"SCT_ID"));
32 // Read Cond Handle Key
34
35 return StatusCode::SUCCESS;
36}
37
38//Finalize
39StatusCode
41 return StatusCode::SUCCESS;
42}
43
44bool
48
49bool
50SCT_TdaqEnabledTool::isGood(const Identifier& elementId, const EventContext& ctx, InDetConditions::Hierarchy h) const {
51 if (not canReportAbout(h)) return true;
52 //turn to hash, given the identifier
53 const IdentifierHash hashId{m_pHelper->wafer_hash(elementId)};
54 return isGood(hashId, ctx);
55}
56
57bool
59 const EventContext& ctx{Gaudi::Hive::currentContext()};
60
61 return isGood(elementId, ctx, h);
62}
63
64bool
65SCT_TdaqEnabledTool::isGood(const IdentifierHash& hashId, const EventContext& ctx) const {
66 const SCT_TdaqEnabledCondData* condData{getCondData(ctx)};
67 if (condData==nullptr) return false;
68 return condData->isGood(hashId);
69}
70
71bool
73 const EventContext& ctx{Gaudi::Hive::currentContext()};
74
75 return isGood(hashId, ctx);
76}
77
78void
82 if (not condDataHandle.isValid()) {
83 ATH_MSG_ERROR("Invalid cond data handle " << m_condKey.key() );
84 return;
85 }
86 if (whandle) {
87 whandle->addDependency (condDataHandle);
88 }
89 const SCT_TdaqEnabledCondData* condData{condDataHandle.cptr()};
90 if (condData==nullptr) {
91 ATH_MSG_ERROR("Invalid TdaqEnabledCondData. Return true.");
92 return ;
93 }
94 std::vector<bool> &status = element_status.getElementStatus();
95 if (status.empty()) {
96 status.resize(m_pHelper->wafer_hash_max(),true);
97 }
98 if (not condData->isNoneBad()) {
99 std::vector<bool> tdaq_enabled;
100 tdaq_enabled.resize(m_pHelper->wafer_hash_max(),false);
101 for (const IdentifierHash &id_hash : condData->goodIdHashes() ) {
102 tdaq_enabled.at(id_hash.value())=true;
103 }
104 for (unsigned int status_i=0; status_i<status.size(); ++status_i) {
105 status[status_i] = status[status_i] && tdaq_enabled.at(status_i);
106 }
107 }
108
109}
110
112SCT_TdaqEnabledTool::getCondData(const EventContext& ctx) const {
114 return condData.retrieve();
115}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
This is an Identifier helper class for the SCT subdetector.
interface file for tool that keeps track of Tdaq enabling/disabling of SCT Rods.
Handle class for reading from StoreGate.
Header file for AthHistogramAlgorithm.
This is a "hash" representation of an Identifier.
const std::vector< bool > & getElementStatus() const
Class for data object used in SCT_TdaqEnabledCondAlg and SCT_TdaqEnabledTool.
bool isGood(const IdentifierHash &hashId) const
Check if a module is good.
bool isNoneBad() const
Get noneBad value.
const std::set< IdentifierHash > & goodIdHashes() const
SCT_TdaqEnabledTool(const std::string &type, const std::string &name, const IInterface *parent)
virtual bool canReportAbout(InDetConditions::Hierarchy h) const override
Can the service report about the given component? (TdaqEnabledSvc can answer questions about a module...
virtual void getDetectorElementStatus(const EventContext &ctx, InDet::SiDetectorElementStatus &element_status, SG::WriteCondHandle< InDet::SiDetectorElementStatus > *whandle) const override
SG::ReadCondHandleKey< SCT_TdaqEnabledCondData > m_condKey
const SCT_TdaqEnabledCondData * getCondData(const EventContext &ctx) const
virtual StatusCode initialize() override
virtual StatusCode finalize() override
virtual bool isGood(const Identifier &elementId, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override
Is the detector element good?
const_pointer_type retrieve()
const_pointer_type cptr()
void addDependency(const EventIDRange &range)