ATLAS Offline Software
PixelActiveDetectorElementStatusTool.cxx
Go to the documentation of this file.
2 #include <unordered_map>
3 
5 {
8 
10  for (unsigned int istatus=0; istatus<m_isActiveStatus.size(); istatus++) {
11  unsigned int active_status=0;
12  if (m_isActiveStatus[istatus]=="OK") { active_status = PixelDCSStatusData::DCSModuleStatus::OK; }
13  else if (m_isActiveStatus[istatus]=="WARNING") { active_status = PixelDCSStatusData::DCSModuleStatus::WARNING; }
14  else if (m_isActiveStatus[istatus]=="ERROR") { active_status = PixelDCSStatusData::DCSModuleStatus::ERROR; }
15  else if (m_isActiveStatus[istatus]=="FATAL") { active_status = PixelDCSStatusData::DCSModuleStatus::FATAL; }
16  else if (m_isActiveStatus[istatus]=="NOSTATUS") { active_status = PixelDCSStatusData::DCSModuleStatus::NOSTATUS; }
17  else {
18  ATH_MSG_ERROR("No matching DCS status " << m_isActiveStatus[istatus] << " in DCSModuleStatus");
19  return StatusCode::FAILURE;
20  }
21  if (active_status>31) {
22  ATH_MSG_FATAL("Logic error: status id too large. Cannot be represented by a bit");
23  return StatusCode::FAILURE;
24  }
25  m_activeStatusMask |= (1u<<active_status);
26  }
27  return StatusCode::SUCCESS;
28 }
29 
30 namespace {
31  inline void andStatus(const std::unordered_map<int, int> &status_map, unsigned int status_mask, std::vector<bool> &module_status) {
32  for (const std::pair<const int, int> &elm : status_map ) {
33  // set modules good if the module status passes the mask.
34  module_status.at(elm.first) = module_status.at(elm.first) && (status_mask & (1<<elm.second));
35  }
36  }
37 }
38 
39 std::unique_ptr<InDet::SiDetectorElementStatus>
42  std::unique_ptr<InDet::SiDetectorElementStatus> element_status( createDetectorElementStatus(ctx, whandle));
43  std::vector<bool> &status=element_status->getElementStatus();
44  if (status.empty()) {
46  true // default value of PixelDCSStateData is 0
47  );
48  }
49  std::vector<InDet::ChipFlags_t> &chip_status=element_status->getElementChipStatus();
50  if (chip_status.empty()) {
51  chip_status.resize(status.size(),0xffff); // Should set this to the correct number of chips
52  }
53 
55  andStatus(dcs_status_handle->moduleStatusMap(), m_activeStatusMask, status);
56  if (whandle) {
57  whandle->addDependency (dcs_status_handle);
58  }
59 
60  return element_status;
61 }
PixelDCSStatusData::moduleStatusMap
const IntConditions & moduleStatusMap() const
Definition: PixelDCSStatusData.h:25
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
InDet::SiDetectorElementStatus::getElementStatus
const std::vector< bool > & getElementStatus() const
Definition: SiDetectorElementStatus.h:116
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
PixelDetectorElementStatusToolBase::m_pixelID
const PixelID * m_pixelID
Definition: PixelDetectorElementStatusToolBase.h:39
python.Constants.ERROR
int ERROR
Definition: Control/AthenaCommon/python/Constants.py:18
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
PixelActiveDetectorElementStatusTool::m_condDCSStatusKey
SG::ReadCondHandleKey< PixelDCSStatusData > m_condDCSStatusKey
Definition: PixelActiveDetectorElementStatusTool.h:35
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
PixelActiveDetectorElementStatusTool::m_isActiveStatus
Gaudi::Property< std::vector< std::string > > m_isActiveStatus
Definition: PixelActiveDetectorElementStatusTool.h:37
PixelDetectorElementStatusToolBase::createDetectorElementStatus
std::unique_ptr< InDet::SiDetectorElementStatus > createDetectorElementStatus(const EventContext &ctx, SG::WriteCondHandle< InDet::SiDetectorElementStatus > *whandle) const
Create a new detector element status element container.
Definition: PixelDetectorElementStatusToolBase.cxx:34
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
PixelActiveDetectorElementStatusTool.h
python.Constants.WARNING
int WARNING
Definition: Control/AthenaCommon/python/Constants.py:17
PixelActiveDetectorElementStatusTool::initialize
virtual StatusCode initialize() override
Definition: PixelActiveDetectorElementStatusTool.cxx:4
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
PixelID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: PixelID.cxx:907
InDet::SiDetectorElementStatus::getElementChipStatus
const std::vector< ChipFlags_t > & getElementChipStatus() const
Definition: SiDetectorElementStatus.h:118
PixelActiveDetectorElementStatusTool::getDetectorElementStatus
virtual std::unique_ptr< InDet::SiDetectorElementStatus > getDetectorElementStatus(const EventContext &ctx, SG::WriteCondHandle< InDet::SiDetectorElementStatus > *whandle) const override
Definition: PixelActiveDetectorElementStatusTool.cxx:40
merge.status
status
Definition: merge.py:17
PixelActiveDetectorElementStatusTool::m_activeStatusMask
unsigned int m_activeStatusMask
mask in which each status is represented by a bit and for status values which are cnsidered active th...
Definition: PixelActiveDetectorElementStatusTool.h:39
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
PixelDetectorElementStatusToolBase::initialize
virtual StatusCode initialize() override
Definition: PixelDetectorElementStatusToolBase.cxx:15
SG::WriteCondHandle::addDependency
void addDependency(const EventIDRange &range)
Definition: WriteCondHandle.h:275