ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetConditions
SCT_ConditionsAlgorithms
src
SCT_MajorityCondAlg.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_MajorityCondAlg.h
"
6
7
#include "
SCT_ConditionsData/SCT_ConditionsParameters.h
"
8
9
#include <memory>
10
11
SCT_MajorityCondAlg::SCT_MajorityCondAlg
(
const
std::string& name, ISvcLocator* pSvcLocator)
12
: ::
AthCondAlgorithm
(name, pSvcLocator)
13
{
14
}
15
16
StatusCode
SCT_MajorityCondAlg::initialize
()
17
{
18
ATH_MSG_DEBUG
(
"initialize "
<< name());
19
20
// Read Cond Handle
21
ATH_CHECK
(
m_readKey
.initialize());
22
23
// Write Cond Handle
24
ATH_CHECK
(
m_writeKey
.initialize());
25
26
return
StatusCode::SUCCESS;
27
}
28
29
StatusCode
SCT_MajorityCondAlg::execute
(
const
EventContext& ctx)
const
30
{
31
ATH_MSG_DEBUG
(
"execute "
<< name());
32
33
// Write Cond Handle
34
SG::WriteCondHandle<SCT_MajorityCondData>
writeHandle{
m_writeKey
, ctx};
35
36
// Do we have a valid Write Cond Handle for current time?
37
if
(writeHandle.
isValid
()) {
38
ATH_MSG_DEBUG
(
"CondHandle "
<< writeHandle.
fullKey
() <<
" is already valid."
39
<<
". In theory this should not be called, but may happen"
40
<<
" if multiple concurrent events are being processed out of order."
);
41
return
StatusCode::SUCCESS;
42
}
43
44
// Read Cond Handle
45
SG::ReadCondHandle<CondAttrListCollection>
readHandle{
m_readKey
, ctx};
46
const
CondAttrListCollection
* readCdo{*readHandle};
47
if
(readCdo==
nullptr
) {
48
ATH_MSG_FATAL
(
"Null pointer to the read conditions object"
);
49
return
StatusCode::FAILURE;
50
}
51
ATH_MSG_INFO
(
"Size of CondAttrListCollection readCdo->size()= "
<< readCdo->
size
());
52
53
// Add dependency
54
writeHandle.
addDependency
(readHandle);
55
56
int
numFilled{0};
57
58
// Construct the output Cond Object and fill it in
59
std::unique_ptr<SCT_MajorityCondData> writeCdo{std::make_unique<SCT_MajorityCondData>()};
60
61
CondAttrListCollection::const_iterator
majItr{readCdo->
begin
()};
62
CondAttrListCollection::const_iterator
majEnd{readCdo->
end
()};
63
for
(;majItr != majEnd; ++majItr) {
64
// A CondAttrListCollection is a map of ChanNum and AttributeList
65
CondAttrListCollection::ChanNum
channelNumber{(*majItr).first};
66
const
CondAttrListCollection::AttributeList
&payload{(*majItr).second};
67
// Possible components
68
if
((channelNumber ==
SCT_ConditionsData::OVERALL
) or
69
(channelNumber ==
SCT_ConditionsData::BARREL
) or
70
(channelNumber ==
SCT_ConditionsData::ECA
) or
71
(channelNumber ==
SCT_ConditionsData::ECC
)) {
72
// Reset default to true at callback
73
bool
majorityState{
true
};
74
75
// Majority state
76
if
(not payload[
SCT_ConditionsData::INDEX_MajorityState
].isNull()) {
77
ATH_MSG_DEBUG
(
"Majority state for "
<< channelNumber <<
" = "
<<
78
payload[
SCT_ConditionsData::INDEX_MajorityState
].data<int>());
79
majorityState = (payload[
SCT_ConditionsData::INDEX_MajorityState
].data<
int
>()
80
==
SCT_ConditionsData::HighAndLowVoltageOK
);
81
}
82
writeCdo->setMajorityState(channelNumber, majorityState);
83
84
// HV fraction in majority state (>50% by definition) IF majority state is HV and LV on
85
float
hvFraction{1.};
86
if
(majorityState and (not payload[
SCT_ConditionsData::INDEX_HVfraction
].isNull())) {
87
ATH_MSG_DEBUG
(
"Majority HV fraction for "
<< channelNumber <<
" = "
<<
88
payload[
SCT_ConditionsData::INDEX_HVfraction
].data<float>());
89
hvFraction = payload[
SCT_ConditionsData::INDEX_HVfraction
].data<
float
>();
90
numFilled++;
91
}
92
writeCdo->setHVFraction(channelNumber, hvFraction);
93
94
}
else
{
95
ATH_MSG_WARNING
(
"Unexpected channel number "
<< channelNumber);
96
}
97
}
98
99
// Has data been filled?
100
// Four regions (OVERALL, BARREL, ECA, ECC) are needed.
101
writeCdo->setFilled(numFilled==
SCT_ConditionsData::N_REGIONS
);
102
103
// Record the out output Cond Object
104
if
(writeHandle.
record
(std::move(writeCdo)).isFailure()) {
105
ATH_MSG_FATAL
(
"Could not record SCT_MajorityCondData "
<< writeHandle.
key
()
106
<<
" with EventRange "
<< writeHandle.
getRange
()
107
<<
" into Conditions Store"
);
108
return
StatusCode::FAILURE;
109
}
110
ATH_MSG_INFO
(
"recorded new CDO "
<< writeHandle.
key
() <<
" with range "
<< writeHandle.
getRange
() <<
" into Conditions Store"
);
111
112
return
StatusCode::SUCCESS;
113
}
114
115
StatusCode
SCT_MajorityCondAlg::finalize
()
116
{
117
ATH_MSG_DEBUG
(
"finalize "
<< name());
118
return
StatusCode::SUCCESS;
119
}
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
SCT_ConditionsParameters.h
header file containing the number of elements and enumerated type of parameters which may be retrieve...
SCT_MajorityCondAlg.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_MajorityCondAlg::m_readKey
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
Definition
SCT_MajorityCondAlg.h:27
SCT_MajorityCondAlg::m_writeKey
SG::WriteCondHandleKey< SCT_MajorityCondData > m_writeKey
Definition
SCT_MajorityCondAlg.h:28
SCT_MajorityCondAlg::SCT_MajorityCondAlg
SCT_MajorityCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
SCT_MajorityCondAlg.cxx:11
SCT_MajorityCondAlg::finalize
virtual StatusCode finalize() override final
Definition
SCT_MajorityCondAlg.cxx:115
SCT_MajorityCondAlg::initialize
virtual StatusCode initialize() override final
Definition
SCT_MajorityCondAlg.cxx:16
SCT_MajorityCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition
SCT_MajorityCondAlg.cxx:29
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
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
SCT_ConditionsData::HighAndLowVoltageOK
@ HighAndLowVoltageOK
Definition
SCT_ConditionsParameters.h:23
SCT_ConditionsData::INDEX_HVfraction
@ INDEX_HVfraction
Definition
SCT_ConditionsParameters.h:29
SCT_ConditionsData::N_REGIONS
@ N_REGIONS
Definition
SCT_ConditionsParameters.h:28
SCT_ConditionsData::INDEX_MajorityState
@ INDEX_MajorityState
Definition
SCT_ConditionsParameters.h:30
SCT_ConditionsData::ECA
@ ECA
Definition
SCT_ConditionsParameters.h:26
SCT_ConditionsData::OVERALL
@ OVERALL
Definition
SCT_ConditionsParameters.h:24
SCT_ConditionsData::ECC
@ ECC
Definition
SCT_ConditionsParameters.h:27
SCT_ConditionsData::BARREL
@ BARREL
Definition
SCT_ConditionsParameters.h:25
Generated on
for ATLAS Offline Software by
1.17.0