ATLAS Offline Software
Loading...
Searching...
No Matches
ToolConstantsCondAlg.cxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration.
3 */
10
11
14
19{
20 if (!m_coolFolderKey.empty()) {
21 if (!m_detStoreKey.empty()) {
22 ATH_MSG_ERROR( "Configuration error: both COOL folder and det store key specified." );
23 return StatusCode::FAILURE;
24 }
25 ATH_CHECK( m_blobTool.retrieve() );
26 ATH_CHECK( m_coolFolderKey.initialize() );
27 }
28 else if (m_detStoreKey.empty()) {
29 ATH_MSG_ERROR( "Configuration error: neither COOL folder nor det store key specified." );
30 return StatusCode::FAILURE;
31 }
32
33 ATH_CHECK( m_toolConstantsKey.initialize() );
34
35 return StatusCode::SUCCESS;
36}
37
38
43StatusCode ToolConstantsCondAlg::execute (const EventContext& ctx) const
44{
46 (m_toolConstantsKey, ctx);
47
48 auto tc = std::make_unique<CaloRec::ToolConstants>();
49
50 if (!m_coolFolderKey.empty()) {
52
53 const std::string key = m_toolConstantsKey.key();
54
55 const unsigned chNbr = m_blobTool->nameToChannelNumber (key);
56 // Check that this channel actually exits
57 const std::string& chanName = coolFolder->chanName (chNbr);
58 if (!chanName.empty() && key!=chanName) {
59 ATH_MSG_ERROR( "Channel name does not match! Expected " << key << " found " << chanName );
60 return StatusCode::FAILURE;
61 }
62 else {
63 ATH_MSG_DEBUG( "Found channel number " << chNbr << " named " << key );
64 }
65
66 const coral::AttributeList& attrList = coolFolder->attributeList (chNbr);
67 ATH_CHECK( m_blobTool->AttrListToToolConstants (attrList, *tc) );
68
69 toolConstants.addDependency (coolFolder);
70 }
71 else if (!m_detStoreKey.empty()) {
72 const CaloRec::ToolConstants* tc_in = nullptr;
73 ATH_CHECK( detStore()->retrieve (tc_in, m_detStoreKey) );
74 *tc = *tc_in;
75
76 const EventIDRange fullRange=IOVInfiniteRange::infiniteRunLB();
77 toolConstants.addDependency (fullRange);
78 }
79 else {
80 ATH_MSG_ERROR( "Bad configuration." );
81 return StatusCode::FAILURE;
82 }
83
84 ATH_CHECK( toolConstants.record (std::move (tc)) );
85 return StatusCode::SUCCESS;
86}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
static Double_t tc
const ServiceHandle< StoreGateSvc > & detStore() const
Container for the tool constants managed by ToolWithConstants.
static EventIDRange infiniteRunLB()
Produces an EventIDRange that is infinite in RunLumi and invalid in Time.
void addDependency(const EventIDRange &range)
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
StatusCode execute(const EventContext &ctx) const override
Gaudi execute method.
SG::WriteCondHandleKey< CaloRec::ToolConstants > m_toolConstantsKey
ToolHandle< Blob2ToolConstants > m_blobTool
virtual StatusCode initialize() override
Gaudi initialize method.
SG::ReadCondHandleKey< CondAttrListCollection > m_coolFolderKey