ATLAS Offline Software
Loading...
Searching...
No Matches
MetaDataToCondAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
9
10#include "MetaDataToCondAlg.h"
11
17
19 ATH_MSG_DEBUG("Initializing MetaDataToCondAlg for folder " << m_folderName.value());
20
21 if (m_folderName.value().empty()) {
22 ATH_MSG_ERROR("FolderName property must be set");
23 return StatusCode::FAILURE;
24 }
25
26 // Use folder name as output key if not explicitly set
27 if (m_outputKey.key().empty()) {
28 m_outputKey = m_folderName.value();
29 }
30
31 ATH_CHECK(m_outputKey.initialize());
32 ATH_CHECK(m_metaDataStore.retrieve());
33
34 return StatusCode::SUCCESS;
35}
36
37StatusCode MetaDataToCondAlg::execute(const EventContext& ctx) const {
39
40 if (writeHandle.isValid()) {
41 ATH_MSG_DEBUG("CondHandle " << m_outputKey.fullKey() << " is already valid");
42 return StatusCode::SUCCESS;
43 }
44
45 // Read from MetaDataStore
46 const IOVMetaDataContainer* metaContainer = nullptr;
47 if (!m_metaDataStore->retrieve(metaContainer, m_folderName.value()).isSuccess()) {
48 ATH_MSG_ERROR("Could not retrieve IOVMetaDataContainer for folder " << m_folderName.value()
49 << " from MetaDataStore");
50 return StatusCode::FAILURE;
51 }
52
53 const IOVPayloadContainer* payloadContainer = metaContainer->payloadContainer();
54 if (!payloadContainer || payloadContainer->size() == 0) {
55 ATH_MSG_ERROR("No payloads in IOVMetaDataContainer for folder " << m_folderName.value());
56 return StatusCode::FAILURE;
57 }
58
59 // Get the first payload (parameter folders should have only one)
60 const CondAttrListCollection* coll = *(payloadContainer->begin());
61 if (!coll) {
62 ATH_MSG_ERROR("Could not get CondAttrListCollection from payload container");
63 return StatusCode::FAILURE;
64 }
65
66 // Extract AthenaAttributeList from the first channel
67 auto itr = coll->begin();
68 if (itr == coll->end()) {
69 ATH_MSG_ERROR("CondAttrListCollection is empty");
70 return StatusCode::FAILURE;
71 }
72
73 const coral::AttributeList& attrList = itr->second;
74 auto athAttrList = std::make_unique<AthenaAttributeList>(attrList);
75
76 ATH_MSG_DEBUG("Read " << athAttrList->size() << " attributes from folder " << m_folderName.value());
77
78 // Use infinite range - the metadata is valid for the entire job
80
81 ATH_CHECK(writeHandle.record(std::move(athAttrList)));
82
83 ATH_MSG_DEBUG("Recorded AthenaAttributeList for " << m_outputKey.fullKey());
84
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)
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
This class is a container for conditions data.
Condition algorithm to populate ConditionStore from MetaDataStore.
This class is a collection of AttributeLists where each one is associated with a channel number.
const_iterator end() const
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
static EventIDRange infiniteRunLB()
Produces an EventIDRange that is infinite in RunLumi and invalid in Time.
This class is a container for conditions data.
const IOVPayloadContainer * payloadContainer() const
Access to payload container.
This class is a container for the payload of conditions data.
size_type size() const
size of payload vector
const_iterator begin() const
Begin of payload vector.
ServiceHandle< StoreGateSvc > m_metaDataStore
Handle to MetaDataStore.
virtual StatusCode execute(const EventContext &ctx) const override
SG::WriteCondHandleKey< AthenaAttributeList > m_outputKey
Output condition key.
virtual StatusCode initialize() override
Gaudi::Property< std::string > m_folderName
Folder name to read from MetaDataStore.
void addDependency(const EventIDRange &range)
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED