ATLAS Offline Software
Loading...
Searching...
No Matches
PixelActiveDetectorElementStatusTool.cxx
Go to the documentation of this file.
2#include <unordered_map>
3
5{
7 ATH_CHECK(m_condDCSStatusKey.initialize());
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
30namespace {
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
39std::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()) {
45 status.resize(m_pixelID->wafer_hash_max(),
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
SG::ReadCondHandleKey< PixelDCSStatusData > m_condDCSStatusKey
virtual std::unique_ptr< InDet::SiDetectorElementStatus > getDetectorElementStatus(const EventContext &ctx, SG::WriteCondHandle< InDet::SiDetectorElementStatus > *whandle) const override
unsigned int m_activeStatusMask
mask in which each status is represented by a bit and for status values which are cnsidered active th...
Gaudi::Property< std::vector< std::string > > m_isActiveStatus
std::unique_ptr< InDet::SiDetectorElementStatus > createDetectorElementStatus(const EventContext &ctx, SG::WriteCondHandle< InDet::SiDetectorElementStatus > *whandle) const
Create a new detector element status element container.
void addDependency(const EventIDRange &range)