ATLAS Offline Software
SCT_TdaqEnabledTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
11 #include "SCT_TdaqEnabledTool.h"
14 
15 #include "InDetIdentifier/SCT_ID.h"
17 #include "StoreGate/ReadHandle.h"
18 
19 // Constructor
20 SCT_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
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
41  return StatusCode::SUCCESS;
42 }
43 
44 bool
47 }
48 
49 bool
50 SCT_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 
57 bool
59  const EventContext& ctx{Gaudi::Hive::currentContext()};
60 
61  return isGood(elementId, ctx, h);
62 }
63 
64 bool
65 SCT_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 
71 bool
73  const EventContext& ctx{Gaudi::Hive::currentContext()};
74 
75  return isGood(hashId, ctx);
76 }
77 
78 void
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 
112 SCT_TdaqEnabledTool::getCondData(const EventContext& ctx) const {
114  return condData.retrieve();
115 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
InDet::SiDetectorElementStatus::getElementStatus
const std::vector< bool > & getElementStatus() const
Definition: SiDetectorElementStatus.h:116
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SCT_DetectorElementStatus.h
SCT_TdaqEnabledTool::finalize
virtual StatusCode finalize() override
Definition: SCT_TdaqEnabledTool.cxx:40
SCT_TdaqEnabledTool::isGood
virtual bool isGood(const Identifier &elementId, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override
Is the detector element good?
Definition: SCT_TdaqEnabledTool.cxx:58
InDetConditions::Hierarchy
Hierarchy
Definition: InDetHierarchy.h:14
SCT_TdaqEnabledCondData::isGood
bool isGood(const IdentifierHash &hashId) const
Check if a module is good.
Definition: SCT_TdaqEnabledCondData.cxx:74
SCT_TdaqEnabledTool::m_condKey
SG::ReadCondHandleKey< SCT_TdaqEnabledCondData > m_condKey
Definition: SCT_TdaqEnabledTool.h:60
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SCT_TdaqEnabledTool::SCT_TdaqEnabledTool
SCT_TdaqEnabledTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: SCT_TdaqEnabledTool.cxx:20
ReadCondHandle.h
SCT_TdaqEnabledTool::m_pHelper
const SCT_ID * m_pHelper
Definition: SCT_TdaqEnabledTool.h:57
SCT_TdaqEnabledTool::m_useDatabase
bool m_useDatabase
Definition: SCT_TdaqEnabledTool.h:58
SCT_TdaqEnabledTool::getDetectorElementStatus
virtual void getDetectorElementStatus(const EventContext &ctx, InDet::SiDetectorElementStatus &element_status, SG::WriteCondHandle< InDet::SiDetectorElementStatus > *whandle) const override
Definition: SCT_TdaqEnabledTool.cxx:79
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
InDetConditions::SCT_MODULE
@ SCT_MODULE
Definition: InDetHierarchy.h:14
InDet::SiDetectorElementStatus
Definition: SiDetectorElementStatus.h:62
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SCT_ID::wafer_hash
IdentifierHash wafer_hash(const Identifier &wafer_id) const
wafer hash from id - optimized
Definition: SCT_ID.h:492
SCT_TdaqEnabledTool.h
SCT_TdaqEnabledCondData
Class for data object used in SCT_TdaqEnabledCondAlg and SCT_TdaqEnabledTool.
Definition: SCT_TdaqEnabledCondData.h:27
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
SCT_TdaqEnabledTool::initialize
virtual StatusCode initialize() override
Definition: SCT_TdaqEnabledTool.cxx:27
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SCT_ID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: SCT_ID.cxx:639
SCT_TdaqEnabledTool::canReportAbout
virtual bool canReportAbout(InDetConditions::Hierarchy h) const override
Can the service report about the given component? (TdaqEnabledSvc can answer questions about a module...
Definition: SCT_TdaqEnabledTool.cxx:45
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
SiDetectorElementCollection.h
h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
merge.status
status
Definition: merge.py:17
ReadHandle.h
Handle class for reading from StoreGate.
IdentifierHash
Definition: IdentifierHash.h:38
InDetConditions::SCT_SIDE
@ SCT_SIDE
Definition: InDetHierarchy.h:14
InDetConditions::DEFAULT
@ DEFAULT
Definition: InDetHierarchy.h:14
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
SCT_TdaqEnabledTool::getCondData
const SCT_TdaqEnabledCondData * getCondData(const EventContext &ctx) const
Definition: SCT_TdaqEnabledTool.cxx:112
SG::WriteCondHandle::addDependency
void addDependency(const EventIDRange &range)
Definition: WriteCondHandle.h:275