ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetConditions
SCT_ConditionsAlgorithms
src
SCT_DCSConditionsStatCondAlg.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 "
SCT_DCSConditionsStatCondAlg.h
"
6
7
#include "
Identifier/IdentifierHash.h
"
8
9
#include <memory>
10
11
SCT_DCSConditionsStatCondAlg::SCT_DCSConditionsStatCondAlg
(
const
std::string& name, ISvcLocator* pSvcLocator)
12
: ::
AthCondAlgorithm
(name, pSvcLocator)
13
{
14
}
15
16
StatusCode
SCT_DCSConditionsStatCondAlg::initialize
() {
17
ATH_MSG_DEBUG
(
"initialize "
<< name());
18
19
m_doState
= ((
m_readAllDBFolders
and
m_returnHVTemp
) or (not
m_readAllDBFolders
and not
m_returnHVTemp
));
20
21
// Read Cond Handle (HV)
22
ATH_CHECK
(
m_readKeyHV
.initialize(
m_returnHVTemp
));
23
24
// Read Cond Handle (state)
25
ATH_CHECK
(
m_readKeyState
.initialize(
m_doState
));
26
// Write Cond Handle
27
ATH_CHECK
(
m_writeKeyState
.initialize(
m_doState
));
28
29
if
(
m_useDefaultHV
) {
30
m_hvLowLimit
=
m_useHVLowLimit
;
31
m_hvUpLimit
=
m_useHVUpLimit
;
32
m_chanstatCut
=
m_useHVChanCut
;
33
ATH_MSG_INFO
(
"Using HV and Chanstat"
<<
m_chanstatCut
<<
" for marking modules bad. >=Hvlow: "
34
<<
m_hvLowLimit
<<
" and <=Hv Up: "
<<
m_hvUpLimit
<<
35
". Note: UseHV Overrides hv limit and chanstat values in joboptions!!"
);
36
}
37
38
return
StatusCode::SUCCESS;
39
}
40
41
StatusCode
SCT_DCSConditionsStatCondAlg::execute
(
const
EventContext& ctx)
const
{
42
ATH_MSG_DEBUG
(
"execute "
<< name());
43
44
if
(not
m_doState
) {
45
return
StatusCode::SUCCESS;
46
}
47
48
// Write Cond Handle (state)
49
SG::WriteCondHandle<SCT_DCSStatCondData>
writeHandle{
m_writeKeyState
, ctx};
50
// Do we have a valid Write Cond Handle for current time?
51
if
(writeHandle.
isValid
()) {
52
ATH_MSG_DEBUG
(
"CondHandle "
<< writeHandle.
fullKey
() <<
" is already valid."
53
<<
". In theory this should not be called, but may happen"
54
<<
" if multiple concurrent events are being processed out of order."
);
55
return
StatusCode::SUCCESS;
56
}
57
58
// Read Cond Handle (state)
59
SG::ReadCondHandle<CondAttrListCollection>
readHandleState{
m_readKeyState
, ctx};
60
const
CondAttrListCollection
* readCdoState{*readHandleState};
61
if
(readCdoState==
nullptr
) {
62
ATH_MSG_FATAL
(
"Null pointer to the read conditions object (state)"
);
63
return
StatusCode::FAILURE;
64
}
65
// Add dependency
66
writeHandle.
addDependency
(readHandleState);
67
ATH_MSG_INFO
(
"Size of CondAttrListCollection "
<< readHandleState.
fullKey
() <<
" readCdo->size()= "
<< readCdoState->
size
());
68
ATH_MSG_INFO
(
"Range of state input is "
<< readHandleState.
getRange
());
69
70
// Construct the output Cond Object and fill it in
71
std::unique_ptr<SCT_DCSStatCondData> writeCdoState{std::make_unique<SCT_DCSStatCondData>()};
72
73
// Read state info
74
// Meaning of state word is found at
75
// https://twiki.cern.ch/twiki/bin/view/Atlas/SctDCSSoftware#Decoding_Status_words
76
std::string paramState{
"STATE"
};
77
CondAttrListCollection::const_iterator
attrListState{readCdoState->
begin
()};
78
CondAttrListCollection::const_iterator
endState{readCdoState->
end
()};
79
// CondAttrListCollection doesn't support C++11 type loops, no generic 'begin'
80
for
(; attrListState!=endState; ++attrListState) {
81
// A CondAttrListCollection is a map of ChanNum and AttributeList
82
CondAttrListCollection::ChanNum
channelNumber{attrListState->first};
83
const
CondAttrListCollection::AttributeList
&payload{attrListState->second};
84
if
(payload.exists(paramState) and not payload[paramState].isNull()) {
85
unsigned
int
val{payload[paramState].data<
unsigned
int
>()};
86
unsigned
int
hvstate{(val >> 4) & 0xF};
87
unsigned
int
lvstate{ val & 0xF};
88
if
( ((
m_chanstatCut
==
"NORM"
)
89
and not ((hvstate==
ON
or hvstate==
MANUAL
)
90
and (lvstate==
ON
or lvstate==
MANUAL
)))
91
or ((
m_chanstatCut
==
"NSTBY"
)
92
and not ((hvstate==
ON
or hvstate==
MANUAL
or hvstate==
STANDBY
)
93
and (lvstate==
ON
or lvstate==
MANUAL
or lvstate==
STANDBY
)))
94
or ((
m_chanstatCut
==
"LOOSE"
)
95
and not ((hvstate==
ON
or hvstate==
MANUAL
or hvstate==
STANDBY
or hvstate==
RAMPING
)
96
and (lvstate==
ON
or lvstate==
MANUAL
or lvstate==
STANDBY
or lvstate==
RAMPING
)))) {
97
writeCdoState->fill(channelNumber, paramState);
98
}
else
{
99
writeCdoState->remove(channelNumber, paramState);
100
}
101
}
else
{
102
ATH_MSG_WARNING
(paramState <<
" does not exist for ChanNum "
<< channelNumber);
103
}
104
}
105
106
if
(
m_returnHVTemp
) {
107
// Read Cond Handle
108
SG::ReadCondHandle<CondAttrListCollection>
readHandleHV{
m_readKeyHV
, ctx};
109
const
CondAttrListCollection
* readCdoHV{*readHandleHV};
110
if
(readCdoHV==
nullptr
) {
111
ATH_MSG_FATAL
(
"Null pointer to the read conditions object (HV)"
);
112
return
StatusCode::FAILURE;
113
}
114
// Add dependency
115
writeHandle.
addDependency
(readHandleHV);
116
ATH_MSG_INFO
(
"Size of CondAttrListCollection "
<< readHandleHV.
fullKey
() <<
" readCdo->size()= "
<< readCdoHV->
size
());
117
ATH_MSG_INFO
(
"Range of HV input is "
<< readHandleHV.
getRange
());
118
119
std::string paramHV{
"HVCHVOLT_RECV"
};
120
CondAttrListCollection::const_iterator
attrListHV{readCdoHV->
begin
()};
121
CondAttrListCollection::const_iterator
endHV{readCdoHV->
end
()};
122
// CondAttrListCollection doesn't support C++11 type loops, no generic 'begin'
123
for
(; attrListHV!=endHV; ++attrListHV) {
124
// A CondAttrListCollection is a map of ChanNum and AttributeList
125
CondAttrListCollection::ChanNum
channelNumber{attrListHV->first};
126
const
CondAttrListCollection::AttributeList
&payload{attrListHV->second};
127
if
(payload.exists(paramHV) and not payload[paramHV].isNull()) {
128
float
hvval{payload[paramHV].data<
float
>()};
129
if
((hvval<
m_hvLowLimit
) or (hvval>
m_hvUpLimit
)) {
130
writeCdoState->fill(channelNumber, paramHV);
131
}
else
{
132
writeCdoState->remove(channelNumber, paramHV);
133
}
134
}
else
{
135
ATH_MSG_WARNING
(paramHV <<
" does not exist for ChanNum "
<< channelNumber);
136
}
137
}
138
}
139
140
// Record the output cond object
141
if
(writeHandle.
record
(std::move(writeCdoState)).isFailure()) {
142
ATH_MSG_FATAL
(
"Could not record SCT_DCSStatCondData "
<< writeHandle.
key
()
143
<<
" with EventRange "
<< writeHandle.
getRange
()
144
<<
" into Conditions Store"
);
145
return
StatusCode::FAILURE;
146
}
147
ATH_MSG_INFO
(
"recorded new CDO "
<< writeHandle.
key
() <<
" with range "
<< writeHandle.
getRange
() <<
" into Conditions Store"
);
148
149
return
StatusCode::SUCCESS;
150
}
151
152
StatusCode
SCT_DCSConditionsStatCondAlg::finalize
()
153
{
154
ATH_MSG_DEBUG
(
"finalize "
<< name());
155
return
StatusCode::SUCCESS;
156
}
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
SCT_DCSConditionsStatCondAlg.h
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::end
const_iterator end() const
Definition
CondAttrListCollection.h:314
CondAttrListCollection::begin
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
Definition
CondAttrListCollection.h:308
CondAttrListCollection::size
size_type size() const
number of Chan/AttributeList pairs
Definition
CondAttrListCollection.h:321
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition
CondAttrListCollection.h:62
CondAttrListCollection::ChanNum
unsigned int ChanNum
Definition
CondAttrListCollection.h:54
CondAttrListCollection::AttributeList
coral::AttributeList AttributeList
Definition
CondAttrListCollection.h:55
SCT_DCSConditionsStatCondAlg::m_readKeyState
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyState
Definition
SCT_DCSConditionsStatCondAlg.h:50
SCT_DCSConditionsStatCondAlg::m_chanstatCut
StringProperty m_chanstatCut
Definition
SCT_DCSConditionsStatCondAlg.h:56
SCT_DCSConditionsStatCondAlg::m_doState
bool m_doState
Definition
SCT_DCSConditionsStatCondAlg.h:53
SCT_DCSConditionsStatCondAlg::m_useHVLowLimit
FloatProperty m_useHVLowLimit
Definition
SCT_DCSConditionsStatCondAlg.h:60
SCT_DCSConditionsStatCondAlg::m_readKeyHV
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyHV
Definition
SCT_DCSConditionsStatCondAlg.h:49
SCT_DCSConditionsStatCondAlg::m_useDefaultHV
BooleanProperty m_useDefaultHV
Definition
SCT_DCSConditionsStatCondAlg.h:59
SCT_DCSConditionsStatCondAlg::SCT_DCSConditionsStatCondAlg
SCT_DCSConditionsStatCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
SCT_DCSConditionsStatCondAlg.cxx:11
SCT_DCSConditionsStatCondAlg::m_writeKeyState
SG::WriteCondHandleKey< SCT_DCSStatCondData > m_writeKeyState
Definition
SCT_DCSConditionsStatCondAlg.h:51
SCT_DCSConditionsStatCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition
SCT_DCSConditionsStatCondAlg.cxx:41
SCT_DCSConditionsStatCondAlg::m_returnHVTemp
BooleanProperty m_returnHVTemp
Definition
SCT_DCSConditionsStatCondAlg.h:55
SCT_DCSConditionsStatCondAlg::finalize
virtual StatusCode finalize() override final
Definition
SCT_DCSConditionsStatCondAlg.cxx:152
SCT_DCSConditionsStatCondAlg::m_readAllDBFolders
BooleanProperty m_readAllDBFolders
Definition
SCT_DCSConditionsStatCondAlg.h:54
SCT_DCSConditionsStatCondAlg::m_useHVChanCut
StringProperty m_useHVChanCut
Definition
SCT_DCSConditionsStatCondAlg.h:62
SCT_DCSConditionsStatCondAlg::m_hvUpLimit
FloatProperty m_hvUpLimit
Definition
SCT_DCSConditionsStatCondAlg.h:58
SCT_DCSConditionsStatCondAlg::initialize
virtual StatusCode initialize() override final
Definition
SCT_DCSConditionsStatCondAlg.cxx:16
SCT_DCSConditionsStatCondAlg::RAMPING
@ RAMPING
Definition
SCT_DCSConditionsStatCondAlg.h:40
SCT_DCSConditionsStatCondAlg::ON
@ ON
Definition
SCT_DCSConditionsStatCondAlg.h:33
SCT_DCSConditionsStatCondAlg::STANDBY
@ STANDBY
Definition
SCT_DCSConditionsStatCondAlg.h:34
SCT_DCSConditionsStatCondAlg::MANUAL
@ MANUAL
Definition
SCT_DCSConditionsStatCondAlg.h:35
SCT_DCSConditionsStatCondAlg::m_hvLowLimit
FloatProperty m_hvLowLimit
Definition
SCT_DCSConditionsStatCondAlg.h:57
SCT_DCSConditionsStatCondAlg::m_useHVUpLimit
FloatProperty m_useHVUpLimit
Definition
SCT_DCSConditionsStatCondAlg.h:61
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
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::addDependency
void addDependency(const EventIDRange &range)
Definition
WriteCondHandle.h:279
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
Generated on
for ATLAS Offline Software by
1.17.0