ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetConditions
TRT_ConditionsNN
src
TRTPIDNNCondAlg.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 "
TRTPIDNNCondAlg.h
"
6
#include "CoolKernel/IObject.h"
7
8
TRTPIDNNCondAlg::TRTPIDNNCondAlg
(
const
std::string& name
9
, ISvcLocator* pSvcLocator )
10
: ::
AthCondAlgorithm
(name,pSvcLocator)
11
{}
12
TRTPIDNNCondAlg::~TRTPIDNNCondAlg
()=
default
;
13
14
StatusCode
TRTPIDNNCondAlg::initialize
()
15
{
16
// Read key
17
ATH_CHECK
(
m_readKey
.initialize() );
18
19
// Register write handle
20
ATH_CHECK
(
m_writeKey
.initialize() );
21
22
return
StatusCode::SUCCESS;
23
}
24
25
StatusCode
TRTPIDNNCondAlg::execute
(
const
EventContext& ctx)
const
26
{
27
ATH_MSG_DEBUG
(
"execute "
<< name());
28
29
// Construct Write Cond Handle and check its validity
30
31
SG::WriteCondHandle<InDet::TRTPIDNN>
writeHandle{
m_writeKey
, ctx};
32
33
// Do we have a valid Write Cond Handle for current time?
34
if
(writeHandle.
isValid
()) {
35
ATH_MSG_DEBUG
(
"CondHandle "
<< writeHandle.
fullKey
() <<
" is already valid."
36
<<
". In theory this should not be called, but may happen"
37
<<
" if multiple concurrent events are being processed out of order."
);
38
39
return
StatusCode::SUCCESS;
40
}
41
42
std::unique_ptr<InDet::TRTPIDNN> writeCdo{std::make_unique<InDet::TRTPIDNN>()};
43
44
// Read the NN configuration from the ReadHandle
45
SG::ReadCondHandle<CondAttrListCollection>
readHandle{
m_readKey
, ctx};
46
const
CondAttrListCollection
* attrListColl{*readHandle};
47
if
(attrListColl==
nullptr
or attrListColl->
size
() != 1) {
48
ATH_MSG_ERROR
(
" Problem reading /TRT/Calib/PID_NN cond object"
);
49
return
StatusCode::FAILURE;
50
}
51
// The NN configuration is stored as one big string in the first channel
52
const
coral::AttributeList& attrList = attrListColl->
begin
()->second;
53
const
std::string
json
= attrList[
"NN_config"
].data<cool::String16M>();
54
if
(StatusCode::SUCCESS != writeCdo->configure(
json
)) {
55
ATH_MSG_ERROR
(
"Problem setting up TRTPIDNN."
);
56
return
StatusCode::FAILURE;
57
}
58
59
// Assign range of writeCdo to that of the ReadHandle
60
EventIDRange rangeW;
61
62
if
(!readHandle.
range
(rangeW)) {
63
ATH_MSG_ERROR
(
"Failed to retrieve validity range for "
<< readHandle.
key
());
64
return
StatusCode::FAILURE;
65
}
66
67
// Record CDO
68
if
(writeHandle.
record
(rangeW,std::move(writeCdo)).isFailure()) {
69
ATH_MSG_ERROR
(
"Could not record InDet::TRTPIDNN "
<< writeHandle.
key
()
70
<<
" with EventRange "
<< rangeW
71
<<
" into Conditions Store"
);
72
return
StatusCode::FAILURE;
73
}
74
75
ATH_MSG_INFO
(
"Recorded InDet::TRTPIDNN "
<< writeHandle.
key
()
76
<<
" with EventRange "
<< rangeW
77
<<
" into Conditions Store"
);
78
79
80
return
StatusCode::SUCCESS;
81
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
json
nlohmann::json json
Definition
HistogramDef.cxx:9
TRTPIDNNCondAlg.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::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
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::WriteCondHandle
Definition
WriteCondHandle.h:26
SG::WriteCondHandle::key
const std::string & key() const
Definition
WriteCondHandle.h:44
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
TRTPIDNNCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
TRTPIDNNCondAlg.cxx:25
TRTPIDNNCondAlg::m_writeKey
SG::WriteCondHandleKey< InDet::TRTPIDNN > m_writeKey
Definition
TRTPIDNNCondAlg.h:33
TRTPIDNNCondAlg::~TRTPIDNNCondAlg
virtual ~TRTPIDNNCondAlg() override
TRTPIDNNCondAlg::TRTPIDNNCondAlg
TRTPIDNNCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
TRTPIDNNCondAlg.cxx:8
TRTPIDNNCondAlg::initialize
virtual StatusCode initialize() override
Definition
TRTPIDNNCondAlg.cxx:14
TRTPIDNNCondAlg::m_readKey
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
Definition
TRTPIDNNCondAlg.h:32
Generated on
for ATLAS Offline Software by
1.17.0