ATLAS Offline Software
Loading...
Searching...
No Matches
PixelDCSCondHVAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "PixelDCSCondHVAlg.h"
7#include <memory>
8
9PixelDCSCondHVAlg::PixelDCSCondHVAlg(const std::string& name, ISvcLocator* pSvcLocator):
10 ::AthCondAlgorithm(name, pSvcLocator)
11{
12}
13
15 ATH_MSG_DEBUG("PixelDCSCondHVAlg::initialize()");
16
17 ATH_CHECK(detStore()->retrieve(m_pixelID,"PixelID"));
18
19 ATH_CHECK(m_moduleDataKey.initialize());
21 ATH_CHECK(m_writeKey.initialize());
22
23 return StatusCode::SUCCESS;
24}
25
26StatusCode PixelDCSCondHVAlg::execute(const EventContext& ctx) const {
27 ATH_MSG_DEBUG("PixelDCSCondHVAlg::execute()");
28
30 if (writeHandle.isValid()) {
31 ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid.. In theory this should not be called, but may happen if multiple concurrent events are being processed out of order.");
32 return StatusCode::SUCCESS;
33 }
34
36 const PixelModuleData* modData=(*modDataHdl);
37 ATH_MSG_INFO("Range of input PixelModule data is " << modDataHdl.getRange());
38
39 // Construct the output Cond Object and fill it in
40 std::unique_ptr<PixelDCSHVData> writeCdo(std::make_unique<PixelDCSHVData>());
41
42 const EventIDBase start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0, 0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
43 const EventIDBase stop {EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
44
45 EventIDRange rangeW{start, stop};
46
47 if (!m_readKey.empty()) {
49 const CondAttrListCollection* readCdo = *readHandle;
50 if (readCdo==nullptr) {
51 ATH_MSG_FATAL("Null pointer to the read conditions object");
52 return StatusCode::FAILURE;
53 }
54 // Get the validitiy range
55 if (not readHandle.range(rangeW)) {
56 ATH_MSG_FATAL("Failed to retrieve validity range for " << readHandle.key());
57 return StatusCode::FAILURE;
58 }
59 ATH_MSG_INFO("Size of CondAttrListCollection " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size());
60 ATH_MSG_INFO("Range of DCS input is " << rangeW);
61
62 // Read HV info
63 std::string param("HV");
64 writeCdo -> defaultVoltage(modData->getDefaultBiasVoltage());
65 for (const auto & attrList : *readCdo) {
66 const CondAttrListCollection::ChanNum &channelNumber = attrList.first;
67 const CondAttrListCollection::AttributeList &payload = attrList.second;
68 if (payload.exists(param) and not payload[param].isNull()) {
69 float val = payload[param].data<float>();
70 writeCdo -> setBiasVoltage((int)channelNumber, val);
71 } else {
72 ATH_MSG_WARNING(param << " does not exist for ChanNum " << channelNumber);
73 writeCdo -> setChannelToDefault((int)channelNumber);
74 }
75 }
76 } else {
77 writeCdo -> useDefault(true);
78 }
79
80 if (writeHandle.record(rangeW, std::move(writeCdo)).isFailure()) {
81 ATH_MSG_FATAL("Could not record PixelDCSHVData " << writeHandle.key() << " with EventRange "
82 << writeHandle.getRange() << " into Conditions Store");
83 return StatusCode::FAILURE;
84 }
85 ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << writeHandle.getRange()
86 << " into Conditions Store");
87
88 return StatusCode::SUCCESS;
89}
90
#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
const PixelID * m_pixelID
SG::WriteCondHandleKey< PixelDCSHVData > m_writeKey
virtual StatusCode initialize() override final
SG::ReadCondHandleKey< PixelModuleData > m_moduleDataKey
virtual StatusCode execute(const EventContext &ctx) const override final
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
PixelDCSCondHVAlg(const std::string &name, ISvcLocator *pSvcLocator)
float getDefaultBiasVoltage() const
bool range(EventIDRange &r)
const std::string & key() const
const DataObjID & fullKey() const
const EventIDRange & getRange()
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