ATLAS Offline Software
SCT_RODVetoTool.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_RODVetoTool.h"
14 
15 //Athena includes
17 #include "InDetIdentifier/SCT_ID.h"
18 #include "StoreGate/DataHandle.h"
19 #include "StoreGate/ReadHandle.h"
20 
21 //STL includes
22 #include <algorithm>
23 #include <iterator>
24 #include <list>
25 #include <sstream>
26 #include <vector>
27 
28 // Constructor
29 SCT_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
37  ATH_CHECK(detStore()->retrieve(m_pHelper, "SCT_ID"));
39 
40  return StatusCode::SUCCESS;
41 }
42 
43 //Finalize
46  return StatusCode::SUCCESS;
47 }
48 
49 bool
51  return ((h==InDetConditions::DEFAULT) or
54 }
55 
56 bool
57 SCT_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 
70 bool
72  const EventContext& ctx{Gaudi::Hive::currentContext()};
73 
74  return isGood(elementId, ctx, h);
75 }
76 
77 bool
78 SCT_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 
84 bool
86  const EventContext& ctx{Gaudi::Hive::currentContext()};
87 
88  return isGood(hashId, ctx);
89 }
90 
91 void
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 
123 const IdentifierSet*
124 SCT_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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
IdentifierSet
std::set< Identifier > IdentifierSet
IdentifierSet is std::set of Identifier and used in SCT_RODVetoCondAlg and SCT_RODVetoTool....
Definition: IdentifierSet.h:18
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
get_generator_info.result
result
Definition: get_generator_info.py:21
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
SCT_RODVetoTool::SCT_RODVetoTool
SCT_RODVetoTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: SCT_RODVetoTool.cxx:29
SCT_DetectorElementStatus.h
SCT_RODVetoTool::initialize
virtual StatusCode initialize() override
Definition: SCT_RODVetoTool.cxx:36
SCT_RODVetoTool::getCondData
const IdentifierSet * getCondData(const EventContext &ctx) const
Definition: SCT_RODVetoTool.cxx:124
SCT_RODVetoTool::m_pHelper
const SCT_ID * m_pHelper
Definition: SCT_RODVetoTool.h:71
InDetConditions::Hierarchy
Hierarchy
Definition: InDetHierarchy.h:14
SCT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: SCT_ID.h:728
SCT_ID::phi_module
int phi_module(const Identifier &id) const
Definition: SCT_ID.h:740
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
DataHandle.h
SCT_RODVetoTool::canReportAbout
virtual bool canReportAbout(InDetConditions::Hierarchy h) const override
Can the service report about the given component? (chip, module...)
Definition: SCT_RODVetoTool.cxx:50
SCT_ID::module_id
Identifier module_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition: SCT_ID.h:416
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_RODVetoTool::m_badModuleIds
SG::ReadCondHandleKey< IdentifierSet > m_badModuleIds
Definition: SCT_RODVetoTool.h:69
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
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
IdentifierHash.h
SCT_ID::layer_disk
int layer_disk(const Identifier &id) const
Definition: SCT_ID.h:734
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
SiDetectorElementCollection.h
h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
SCT_ID::eta_module
int eta_module(const Identifier &id) const
Definition: SCT_ID.h:746
SCT_RODVetoTool::finalize
virtual StatusCode finalize() override
Definition: SCT_RODVetoTool.cxx:45
merge.status
status
Definition: merge.py:17
ReadHandle.h
Handle class for reading from StoreGate.
SCT_ID::wafer_id
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int side) const
For a single side of module.
Definition: SCT_ID.h:464
IdentifierHash
Definition: IdentifierHash.h:38
InDetConditions::SCT_SIDE
@ SCT_SIDE
Definition: InDetHierarchy.h:14
InDetConditions::DEFAULT
@ DEFAULT
Definition: InDetHierarchy.h:14
SCT_RODVetoTool::getDetectorElementStatus
virtual void getDetectorElementStatus(const EventContext &ctx, InDet::SiDetectorElementStatus &element_status, SG::WriteCondHandle< InDet::SiDetectorElementStatus > *whandle) const override
Definition: SCT_RODVetoTool.cxx:92
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
SCT_RODVetoTool::isGood
virtual bool isGood(const Identifier &elementId, InDetConditions::Hierarchy h=InDetConditions::DEFAULT) const override
Is the detector element good?
Definition: SCT_RODVetoTool.cxx:71
SG::WriteCondHandle::addDependency
void addDependency(const EventIDRange &range)
Definition: WriteCondHandle.h:275
SCT_RODVetoTool.h