ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetConditions
PixelConditionsAlgorithms
src
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
"
6
#include "
Identifier/IdentifierHash.h
"
7
#include <memory>
8
9
PixelDCSCondHVAlg::PixelDCSCondHVAlg
(
const
std::string& name, ISvcLocator* pSvcLocator):
10
::
AthCondAlgorithm
(name, pSvcLocator)
11
{
12
}
13
14
StatusCode
PixelDCSCondHVAlg::initialize
() {
15
ATH_MSG_DEBUG
(
"PixelDCSCondHVAlg::initialize()"
);
16
17
ATH_CHECK
(
detStore
()->retrieve(
m_pixelID
,
"PixelID"
));
18
19
ATH_CHECK
(
m_moduleDataKey
.initialize());
20
ATH_CHECK
(
m_readKey
.initialize(
SG::AllowEmpty
));
21
ATH_CHECK
(
m_writeKey
.initialize());
22
23
return
StatusCode::SUCCESS;
24
}
25
26
StatusCode
PixelDCSCondHVAlg::execute
(
const
EventContext& ctx)
const
{
27
ATH_MSG_DEBUG
(
"PixelDCSCondHVAlg::execute()"
);
28
29
SG::WriteCondHandle<PixelDCSHVData>
writeHandle(
m_writeKey
, ctx);
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
35
SG::ReadCondHandle<PixelModuleData>
modDataHdl(
m_moduleDataKey
,ctx);
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()) {
48
SG::ReadCondHandle<CondAttrListCollection>
readHandle(
m_readKey
, ctx);
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
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
IdentifierHash.h
PixelDCSCondHVAlg.h
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthCondAlgorithm
Base class for conditions algorithms.
Definition
AthCondAlgorithm.h:22
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number.
Definition
CondAttrListCollection.h:51
CondAttrListCollection::size
size_type size() const
number of Chan/AttributeList pairs
Definition
CondAttrListCollection.h:321
CondAttrListCollection::ChanNum
unsigned int ChanNum
Definition
CondAttrListCollection.h:54
CondAttrListCollection::AttributeList
coral::AttributeList AttributeList
Definition
CondAttrListCollection.h:55
PixelDCSCondHVAlg::m_pixelID
const PixelID * m_pixelID
Definition
PixelDCSCondHVAlg.h:36
PixelDCSCondHVAlg::m_writeKey
SG::WriteCondHandleKey< PixelDCSHVData > m_writeKey
Definition
PixelDCSCondHVAlg.h:45
PixelDCSCondHVAlg::initialize
virtual StatusCode initialize() override final
Definition
PixelDCSCondHVAlg.cxx:14
PixelDCSCondHVAlg::m_moduleDataKey
SG::ReadCondHandleKey< PixelModuleData > m_moduleDataKey
Definition
PixelDCSCondHVAlg.h:39
PixelDCSCondHVAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition
PixelDCSCondHVAlg.cxx:26
PixelDCSCondHVAlg::m_readKey
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
Definition
PixelDCSCondHVAlg.h:42
PixelDCSCondHVAlg::PixelDCSCondHVAlg
PixelDCSCondHVAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
PixelDCSCondHVAlg.cxx:9
PixelModuleData
Definition
PixelModuleData.h:22
PixelModuleData::getDefaultBiasVoltage
float getDefaultBiasVoltage() const
Definition
PixelModuleData.cxx:336
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::range
bool range(EventIDRange &r)
Definition
ReadCondHandle.h:223
SG::ReadCondHandle::key
const std::string & key() const
Definition
ReadCondHandle.h:59
SG::ReadCondHandle::fullKey
const DataObjID & fullKey() const
Definition
ReadCondHandle.h:60
SG::ReadCondHandle::getRange
const EventIDRange & getRange()
Definition
ReadCondHandle.h:241
SG::WriteCondHandle
Definition
WriteCondHandle.h:26
SG::WriteCondHandle::key
const std::string & key() const
Definition
WriteCondHandle.h:44
SG::WriteCondHandle::getRange
const EventIDRange & getRange() const
Definition
WriteCondHandle.h:93
SG::WriteCondHandle::record
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Definition
WriteCondHandle.h:161
SG::WriteCondHandle::isValid
bool isValid() const
Definition
WriteCondHandle.h:252
SG::WriteCondHandle::fullKey
const DataObjID & fullKey() const
Definition
WriteCondHandle.h:45
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:27
Generated on
for ATLAS Offline Software by
1.17.0