ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_TdaqEnabledTool.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_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
58SCT_TdaqEnabledTool::isGood(const IdentifierHash& hashId, const EventContext& ctx) const {
59 const SCT_TdaqEnabledCondData* condData{getCondData(ctx)};
60 if (condData==nullptr) return false;
61 return condData->isGood(hashId);
62}
63
64void
68 if (not condDataHandle.isValid()) {
69 ATH_MSG_ERROR("Invalid cond data handle " << m_condKey.key() );
70 return;
71 }
72 if (whandle) {
73 whandle->addDependency (condDataHandle);
74 }
75 const SCT_TdaqEnabledCondData* condData{condDataHandle.cptr()};
76 if (condData==nullptr) {
77 ATH_MSG_ERROR("Invalid TdaqEnabledCondData. Return true.");
78 return ;
79 }
80 std::vector<bool> &status = element_status.getElementStatus();
81 if (status.empty()) {
82 status.resize(m_pHelper->wafer_hash_max(),true);
83 }
84 if (not condData->isNoneBad()) {
85 std::vector<bool> tdaq_enabled;
86 tdaq_enabled.resize(m_pHelper->wafer_hash_max(),false);
87 for (const IdentifierHash &id_hash : condData->goodIdHashes() ) {
88 tdaq_enabled.at(id_hash.value())=true;
89 }
90 for (unsigned int status_i=0; status_i<status.size(); ++status_i) {
91 status[status_i] = status[status_i] && tdaq_enabled.at(status_i);
92 }
93 }
94
95}
96
98SCT_TdaqEnabledTool::getCondData(const EventContext& ctx) const {
100 return condData.retrieve();
101}
#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
virtual bool isGood(const Identifier &elementId, const EventContext &ctx, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override
Is the detector element good?
const SCT_TdaqEnabledCondData * getCondData(const EventContext &ctx) const
virtual StatusCode initialize() override
virtual StatusCode finalize() override
const_pointer_type retrieve()
const_pointer_type cptr()
void addDependency(const EventIDRange &range)