ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetConditions
SCT_ConditionsAlgorithms
src
SCT_SensorsCondAlg.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_SensorsCondAlg.h
"
6
7
#include <memory>
8
9
SCT_SensorsCondAlg::SCT_SensorsCondAlg
(
const
std::string& name, ISvcLocator* pSvcLocator)
10
: ::
AthCondAlgorithm
(name, pSvcLocator)
11
{
12
}
13
14
StatusCode
SCT_SensorsCondAlg::initialize
()
15
{
16
ATH_MSG_DEBUG
(
"initialize "
<< name());
17
18
// Read Cond Handle
19
ATH_CHECK
(
m_readKey
.initialize());
20
21
// Write Cond Handle
22
ATH_CHECK
(
m_writeKey
.initialize());
23
24
return
StatusCode::SUCCESS;
25
}
26
27
StatusCode
SCT_SensorsCondAlg::execute
(
const
EventContext& ctx)
const
28
{
29
ATH_MSG_DEBUG
(
"execute "
<< name());
30
31
// Write Cond Handle
32
SG::WriteCondHandle<SCT_SensorsCondData>
writeHandle{
m_writeKey
, ctx};
33
34
// Do we have a valid Write Cond Handle for current time?
35
if
(writeHandle.
isValid
()) {
36
37
ATH_MSG_DEBUG
(
"CondHandle "
<< writeHandle.
fullKey
() <<
" is already valid."
38
<<
". In theory this should not be called, but may happen"
39
<<
" if multiple concurrent events are being processed out of order."
);
40
return
StatusCode::SUCCESS;
41
}
42
43
// Read Cond Handle
44
SG::ReadCondHandle<CondAttrListCollection>
readHandle{
m_readKey
, ctx};
45
const
CondAttrListCollection
* readCdo{*readHandle};
46
if
(readCdo==
nullptr
) {
47
ATH_MSG_FATAL
(
"Null pointer to the read conditions object"
);
48
return
StatusCode::FAILURE;
49
}
50
ATH_MSG_INFO
(
"Size of CondAttrListCollection readCdo->size()= "
<< readCdo->
size
());
51
52
// Add dependency
53
writeHandle.
addDependency
(readHandle);
54
55
// Construct the output Cond Object and fill it in
56
std::unique_ptr<SCT_SensorsCondData> writeCdo{std::make_unique<SCT_SensorsCondData>()};
57
58
// Fill write conditions data object
59
CondAttrListCollection::const_iterator
attrList{readCdo->
begin
()};
60
CondAttrListCollection::const_iterator
end{readCdo->
end
()};
61
// CondAttrListCollection doesnt support C++11 type loops, no generic 'begin'
62
for
(; attrList!=end; ++attrList) {
63
CondAttrListCollection::ChanNum
truncatedSerialNumber{attrList->first};
64
SCT_SensorCondData
data;
65
bool
isOK{
false
};
66
isOK |= data.setTruncatedSerialNumber(truncatedSerialNumber);
67
isOK |= data.setManufacturer(attrList->second[0].data<std::string>());
68
isOK |= data.setDepletionVoltage(
SCT_SensorCondData::SENSOR1
, attrList->second[1].data<
float
>());
69
isOK |= data.setDepletionVoltage(
SCT_SensorCondData::SENSOR2
, attrList->second[2].data<
float
>());
70
isOK |= data.setDepletionVoltage(
SCT_SensorCondData::SENSOR3
, attrList->second[3].data<
float
>());
71
isOK |= data.setDepletionVoltage(
SCT_SensorCondData::SENSOR4
, attrList->second[4].data<
float
>());
72
isOK |= data.setCrystalOrientation(
SCT_SensorCondData::SENSOR1
,
static_cast<
int
>
(attrList->second[5].data<
long
long
>()));
73
isOK |= data.setCrystalOrientation(
SCT_SensorCondData::SENSOR2
,
static_cast<
int
>
(attrList->second[6].data<
long
long
>()));
74
isOK |= data.setCrystalOrientation(
SCT_SensorCondData::SENSOR3
,
static_cast<
int
>
(attrList->second[7].data<
long
long
>()));
75
isOK |= data.setCrystalOrientation(
SCT_SensorCondData::SENSOR4
,
static_cast<
int
>
(attrList->second[8].data<
long
long
>()));
76
if
(not isOK) {
77
ATH_MSG_WARNING
(
"At least one element of SCT_SensorCondData for truncatedSerialNumber "
<< truncatedSerialNumber <<
" was not correctly stored."
);
78
}
79
(*writeCdo)[truncatedSerialNumber] = data;
80
}
81
82
// Record write conditions data object
83
if
(writeHandle.
record
(std::move(writeCdo)).isFailure()) {
84
ATH_MSG_FATAL
(
"Could not record SCT_SensorsCondData "
<< writeHandle.
key
()
85
<<
" with EventRange "
<< writeHandle.
getRange
()
86
<<
" into Conditions Store"
);
87
return
StatusCode::FAILURE;
88
}
89
ATH_MSG_INFO
(
"recorded new CDO "
<< writeHandle.
key
() <<
" with range "
<< writeHandle.
getRange
() <<
" into Conditions Store"
);
90
91
return
StatusCode::SUCCESS;
92
}
93
94
StatusCode
SCT_SensorsCondAlg::finalize
()
95
{
96
ATH_MSG_DEBUG
(
"finalize "
<< name());
97
return
StatusCode::SUCCESS;
98
}
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_SensorsCondAlg.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
SCT_SensorCondData
Class for data object used in SCT_SensorsCondAlg and SCT_SensorsTool.
Definition
SCT_SensorCondData.h:25
SCT_SensorCondData::SENSOR3
@ SENSOR3
Definition
SCT_SensorCondData.h:52
SCT_SensorCondData::SENSOR4
@ SENSOR4
Definition
SCT_SensorCondData.h:52
SCT_SensorCondData::SENSOR2
@ SENSOR2
Definition
SCT_SensorCondData.h:52
SCT_SensorCondData::SENSOR1
@ SENSOR1
Definition
SCT_SensorCondData.h:52
SCT_SensorsCondAlg::SCT_SensorsCondAlg
SCT_SensorsCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
SCT_SensorsCondAlg.cxx:9
SCT_SensorsCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition
SCT_SensorsCondAlg.cxx:27
SCT_SensorsCondAlg::finalize
virtual StatusCode finalize() override final
Definition
SCT_SensorsCondAlg.cxx:94
SCT_SensorsCondAlg::m_writeKey
SG::WriteCondHandleKey< SCT_SensorsCondData > m_writeKey
Definition
SCT_SensorsCondAlg.h:28
SCT_SensorsCondAlg::m_readKey
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
Definition
SCT_SensorsCondAlg.h:27
SCT_SensorsCondAlg::initialize
virtual StatusCode initialize() override final
Definition
SCT_SensorsCondAlg.cxx:14
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
Generated on
for ATLAS Offline Software by
1.17.0