ATLAS Offline Software
Loading...
Searching...
No Matches
PixelDCSCondStatusAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include "GaudiKernel/EventIDRange.h"
8#include <memory>
9
10PixelDCSCondStatusAlg::PixelDCSCondStatusAlg(const std::string& name, ISvcLocator* pSvcLocator):
11 ::AthCondAlgorithm(name, pSvcLocator)
12{
13}
14
16 ATH_MSG_DEBUG("PixelDCSCondStatusAlg::initialize()");
17
18 ATH_CHECK(detStore()->retrieve(m_pixelID,"PixelID"));
20 ATH_CHECK(m_writeKeyStatus.initialize());
21
22 return StatusCode::SUCCESS;
23}
24
25StatusCode PixelDCSCondStatusAlg::execute(const EventContext& ctx) const {
26 ATH_MSG_DEBUG("PixelDCSCondStatusAlg::execute()");
27
29 if (writeHandleStatus.isValid()) {
30 ATH_MSG_DEBUG("CondHandle " << writeHandleStatus.fullKey() << " is already valid.. In theory this should not be called, but may happen if multiple concurrent events are being processed out of order.");
31 return StatusCode::SUCCESS;
32 }
33
34 // Construct the output Cond Object and fill it in
35 std::unique_ptr<PixelDCSStatusData> writeCdoStatus(std::make_unique<PixelDCSStatusData>());
36
37 const EventIDBase start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0, 0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
38 const EventIDBase stop {EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
39
40 EventIDRange rangeW{start, stop};
41
42 if (!m_readKeyStatus.empty()) {
44 const CondAttrListCollection* readCdoStatus(*readHandle);
45 if (readCdoStatus==nullptr) {
46 ATH_MSG_FATAL("Null pointer to the read conditions object (state)");
47 return StatusCode::FAILURE;
48 }
49 // Get the validitiy range
50 if (not readHandle.range(rangeW)) {
51 ATH_MSG_FATAL("Failed to retrieve validity range for " << readHandle.key());
52 return StatusCode::FAILURE;
53 }
54 ATH_MSG_INFO("Size of CondAttrListCollection " << readHandle.fullKey() << " readCdo->size()= " << readCdoStatus->size());
55 ATH_MSG_INFO("Range of state input is " << rangeW);
56
57 // Read state info
58 const std::string paramStatus = "FSM_status";
59 for (const auto & readCdoStatu : *readCdoStatus) {
60 const CondAttrListCollection::ChanNum &channelNumber = readCdoStatu.first;
61 const CondAttrListCollection::AttributeList &payload = readCdoStatu.second;
62 if (payload.exists(paramStatus.c_str()) and not payload[paramStatus.c_str()].isNull()) {
63 const std::string& val = payload[paramStatus.c_str()].data<std::string>();
64 if (val=="OK") { writeCdoStatus->setModuleStatus(channelNumber,PixelDCSStatusData::DCSModuleStatus::OK); }
65 else if (val=="WARNING") { writeCdoStatus->setModuleStatus(channelNumber,PixelDCSStatusData::DCSModuleStatus::WARNING); }
66 else if (val=="ERROR") { writeCdoStatus->setModuleStatus(channelNumber,PixelDCSStatusData::DCSModuleStatus::ERROR); }
67 else if (val=="FATAL") { writeCdoStatus->setModuleStatus(channelNumber,PixelDCSStatusData::DCSModuleStatus::FATAL); }
68 }
69 else {
70 ATH_MSG_WARNING(paramStatus << " does not exist for ChanNum " << channelNumber);
71 writeCdoStatus->setModuleStatus(channelNumber,PixelDCSStatusData::DCSModuleStatus::NOSTATUS);
72 }
73 }
74 }
75 else {
76 for (int i=0; i<(int)m_pixelID->wafer_hash_max(); i++) {
77 writeCdoStatus->setModuleStatus(i,PixelDCSStatusData::DCSModuleStatus::OK);
78 }
79 }
80
81 if (writeHandleStatus.record(rangeW, std::move(writeCdoStatus)).isFailure()) {
82 ATH_MSG_FATAL("Could not record PixelDCSStatusData " << writeHandleStatus.key() << " with EventRange "
83 << writeHandleStatus.getRange() << " into Conditions Store");
84 return StatusCode::FAILURE;
85 }
86 ATH_MSG_INFO("recorded new CDO " << writeHandleStatus.key() << " with range "
87 << writeHandleStatus.getRange() << " into Conditions Store");
88
89 return StatusCode::SUCCESS;
90}
91
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
const ServiceHandle< StoreGateSvc > & detStore() const
Base class for conditions algorithms.
This class is a collection of AttributeLists where each one is associated with a channel number.
size_type size() const
number of Chan/AttributeList pairs
coral::AttributeList AttributeList
SG::WriteCondHandleKey< PixelDCSStatusData > m_writeKeyStatus
PixelDCSCondStatusAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize() override final
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyStatus
virtual StatusCode execute(const EventContext &ctx) const override final
bool range(EventIDRange &r)
const std::string & key() const
const DataObjID & fullKey() const
const std::string & key() const
const EventIDRange & getRange() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
const DataObjID & fullKey() const