ATLAS Offline Software
Loading...
Searching...
No Matches
CopyEventStreamInfo.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
9
10#include "CopyEventStreamInfo.h"
11
14#include <algorithm>
15
16//___________________________________________________________________________
18 const std::string& name,
19 const IInterface* parent) :
20 base_class(type, name, parent) {
21}
22//___________________________________________________________________________
24 ATH_MSG_DEBUG("Initializing " << name());
25 // Locate the MetaDataSvc and InputMetaDataStore
26 ATH_CHECK( m_metaDataSvc.retrieve() );
27 ATH_CHECK( m_inputMetaDataStore.retrieve() );
28
29 return StatusCode::SUCCESS;
30}
31
32
34{
35 std::vector<std::string> keys = m_keys;
36 if (keys.empty()) {
38 } else {
39 // remove keys not in the InputMetaDataStore
40 std::erase_if(keys, [this](const std::string& key) {
41 return !m_inputMetaDataStore->contains<EventStreamInfo>(key);
42 });
43 }
44
45 // If the input file doesn't have any event stream info metadata,
46 // then finish right away:
47 if (keys.empty()) return StatusCode::SUCCESS;
48
49 for (const auto &key : keys) {
50 const EventStreamInfo* evtStrInfo_in = nullptr;
51 ATH_CHECK( m_inputMetaDataStore->retrieve(evtStrInfo_in, key) );
52
53 EventStreamInfo* evtStrInfo_out = m_metaDataSvc->tryRetrieve<EventStreamInfo>(key);
54 if( !evtStrInfo_out ) {
55 auto esinfo_up = std::make_unique<EventStreamInfo>(*evtStrInfo_in);
56 ATH_CHECK( m_metaDataSvc->record( std::move(esinfo_up), key ) );
57 } else {
58 evtStrInfo_out->addEvent(evtStrInfo_in->getNumberOfEvents());
59 for (const auto& elem : evtStrInfo_in->getRunNumbers()) {
60 evtStrInfo_out->insertRunNumber(elem);
61 }
62 for (const auto& elem : evtStrInfo_in->getLumiBlockNumbers()) {
63 evtStrInfo_out->insertLumiBlockNumber(elem);
64 }
65 for (const auto& elem : evtStrInfo_in->getProcessingTags()) {
66 evtStrInfo_out->insertProcessingTag(elem);
67 }
68 for (const auto& [classId, key] : evtStrInfo_in->getItemList()) {
69 evtStrInfo_out->insertItemList(classId, key);
70 }
71 for (const auto& elem : evtStrInfo_in->getEventTypes()) {
72 evtStrInfo_out->insertEventType(elem);
73 }
74 }
75 }
76 return StatusCode::SUCCESS;
77}
79{
80 return StatusCode::SUCCESS;
81}
83{
84 return StatusCode::SUCCESS;
85}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
This file contains the class definition for the CopyEventStreamInfo class.
This file contains the class definition for the EventStreamInfo class.
CopyEventStreamInfo(const std::string &type, const std::string &name, const IInterface *parent)
Standard AlgTool Constructor.
Gaudi::Property< std::vector< std::string > > m_keys
(optional) list of keys to copy, all if empty, default: empty
virtual StatusCode metaDataStop() override final
Function called when the tool should write out its metadata.
ServiceHandle< StoreGateSvc > m_inputMetaDataStore
MetaDataStore for input.
virtual StatusCode initialize() override final
AthAlgTool Interface method implementations:
virtual StatusCode endInputFile(const SG::SourceID &="Serial") override final
Function called when the currently open input file got completely processed.
virtual StatusCode beginInputFile(const SG::SourceID &="Serial") override final
Function called when a new input file is opened.
ServiceHandle< IAthMetaDataSvc > m_metaDataSvc
Access to output MetaDataStore through MetaDataSvc (using MetaContainers).
This class provides the summary information stored for data written as a Event Stream.
const std::set< std::string > & getProcessingTags() const
const std::set< unsigned int > & getLumiBlockNumbers() const
void insertEventType(const EventType &event)
Insert new Event Type into a set.
void insertLumiBlockNumber(unsigned int lumiBlock)
Insert new Luminosity Block Number into a set.
const std::set< unsigned int > & getRunNumbers() const
void insertRunNumber(unsigned int run)
Insert new Run Number into a set.
void addEvent(unsigned int number=1)
Increase Event Counter.
const std::set< EventType > & getEventTypes() const
void insertProcessingTag(const std::string &process)
Insert new Processing Tag into a set.
const std::set< std::pair< CLID, std::string > > & getItemList() const
void insertItemList(CLID type, const std::string &key)
Insert new ItemList Entry into a set.
unsigned int getNumberOfEvents() const
std::size_t erase_if(T_container &container, T_Func pred)