ATLAS Offline Software
Loading...
Searching...
No Matches
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
8TRTPIDNNCondAlg::TRTPIDNNCondAlg(const std::string& name
9 , ISvcLocator* pSvcLocator )
10 : ::AthCondAlgorithm(name,pSvcLocator)
11{}
13
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
25StatusCode TRTPIDNNCondAlg::execute(const EventContext& ctx) const
26{
27 ATH_MSG_DEBUG("execute " << name());
28
29 // Construct Write Cond Handle and check its validity
30
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
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
nlohmann::json json
Base class for conditions algorithms.
This class is a collection of AttributeLists where each one is associated with a channel number.
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
size_type size() const
number of Chan/AttributeList pairs
bool range(EventIDRange &r)
const std::string & key() const
const std::string & key() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
const DataObjID & fullKey() const
virtual StatusCode execute(const EventContext &ctx) const override
SG::WriteCondHandleKey< InDet::TRTPIDNN > m_writeKey
virtual ~TRTPIDNNCondAlg() override
TRTPIDNNCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize() override
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey