ATLAS Offline Software
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 
10 #include "CopyEventStreamInfo.h"
11 
13 #include "StoreGate/StoreGateSvc.h"
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  // Ignore versioned container
51  if (key.substr(0, 1) == ";" && key.substr(3, 1) == ";") {
52  ATH_MSG_VERBOSE( "Ignore versioned container: " << key );
53  continue;
54  }
55  std::list<SG::ObjectWithVersion<EventStreamInfo> > allVersions;
56  ATH_CHECK( m_inputMetaDataStore->retrieveAllVersions(allVersions, key) );
57 
58  EventStreamInfo* evtStrInfo_out = 0;
59  for (SG::ObjectWithVersion<EventStreamInfo>& obj : allVersions) {
60  const EventStreamInfo* evtStrInfo_in = obj.dataObject.cptr();
61  evtStrInfo_out = m_metaDataSvc->tryRetrieve<EventStreamInfo>(key);
62  if( !evtStrInfo_out ) {
63  auto esinfo_up = std::make_unique<EventStreamInfo>(*evtStrInfo_in);
64  ATH_CHECK( m_metaDataSvc->record( std::move(esinfo_up), key ) );
65  } else {
66  evtStrInfo_out->addEvent(evtStrInfo_in->getNumberOfEvents());
67  for (const auto& elem : evtStrInfo_in->getRunNumbers()) {
68  evtStrInfo_out->insertRunNumber(elem);
69  }
70  for (const auto& elem : evtStrInfo_in->getLumiBlockNumbers()) {
71  evtStrInfo_out->insertLumiBlockNumber(elem);
72  }
73  for (const auto& elem : evtStrInfo_in->getProcessingTags()) {
74  evtStrInfo_out->insertProcessingTag(elem);
75  }
76  for (const auto& [classId, key] : evtStrInfo_in->getItemList()) {
77  evtStrInfo_out->insertItemList(classId, key);
78  }
79  for (const auto& elem : evtStrInfo_in->getEventTypes()) {
80  evtStrInfo_out->insertEventType(elem);
81  }
82  }
83  }
84  }
85  return StatusCode::SUCCESS;
86 }
88 {
89  return StatusCode::SUCCESS;
90 }
92 {
93  return StatusCode::SUCCESS;
94 }
CopyEventStreamInfo::metaDataStop
virtual StatusCode metaDataStop() override final
Function called when the tool should write out its metadata.
Definition: CopyEventStreamInfo.cxx:91
CopyEventStreamInfo.h
This file contains the class definition for the CopyEventStreamInfo class.
CopyEventStreamInfo::initialize
virtual StatusCode initialize() override final
AthAlgTool Interface method implementations:
Definition: CopyEventStreamInfo.cxx:23
EventStreamInfo::getRunNumbers
const std::set< unsigned int > & getRunNumbers() const
Definition: EventStreamInfo.cxx:23
EventStreamInfo::getProcessingTags
const std::set< std::string > & getProcessingTags() const
Definition: EventStreamInfo.cxx:35
CopyEventStreamInfo::m_inputMetaDataStore
ServiceHandle< StoreGateSvc > m_inputMetaDataStore
MetaDataStore for input.
Definition: CopyEventStreamInfo.h:55
EventStreamInfo::getEventTypes
const std::set< EventType > & getEventTypes() const
Definition: EventStreamInfo.cxx:47
python.getProblemFolderFromLogs.elem
elem
Definition: getProblemFolderFromLogs.py:90
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
CopyEventStreamInfo::m_keys
Gaudi::Property< std::vector< std::string > > m_keys
(optional) list of keys to copy, all if empty, default: empty
Definition: CopyEventStreamInfo.h:49
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
EventStreamInfo.h
This file contains the class definition for the EventStreamInfo class.
EventStreamInfo::getLumiBlockNumbers
const std::set< unsigned int > & getLumiBlockNumbers() const
Definition: EventStreamInfo.cxx:29
EventStreamInfo::insertRunNumber
void insertRunNumber(unsigned int run)
Insert new Run Number into a set.
Definition: EventStreamInfo.cxx:64
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
EventStreamInfo::addEvent
void addEvent(unsigned int number=1)
Increase Event Counter.
Definition: EventStreamInfo.cxx:53
EventStreamInfo::insertProcessingTag
void insertProcessingTag(const std::string &process)
Insert new Processing Tag into a set.
Definition: EventStreamInfo.cxx:76
CopyEventStreamInfo::m_metaDataSvc
ServiceHandle< IAthMetaDataSvc > m_metaDataSvc
Access to output MetaDataStore through MetaDataSvc (using MetaContainers)
Definition: CopyEventStreamInfo.h:53
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
EventStreamInfo::getNumberOfEvents
unsigned int getNumberOfEvents() const
Definition: EventStreamInfo.cxx:17
EventStreamInfo::getItemList
const std::set< std::pair< CLID, std::string > > & getItemList() const
Definition: EventStreamInfo.cxx:41
CopyEventStreamInfo::CopyEventStreamInfo
CopyEventStreamInfo(const std::string &type, const std::string &name, const IInterface *parent)
Standard AlgTool Constructor.
Definition: CopyEventStreamInfo.cxx:17
EventStreamInfo
This class provides the summary information stored for data written as a Event Stream.
Definition: EventStreamInfo.h:28
CopyEventStreamInfo::endInputFile
virtual StatusCode endInputFile(const SG::SourceID &="Serial") override final
Function called when the currently open input file got completely processed.
Definition: CopyEventStreamInfo.cxx:87
SG::SourceID
std::string SourceID
Definition: AthenaKernel/AthenaKernel/SourceID.h:25
EventStreamInfo::insertItemList
void insertItemList(CLID type, const std::string &key)
Insert new ItemList Entry into a set.
Definition: EventStreamInfo.cxx:82
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:801
SG::ObjectWithVersion
associate a data object with its VersionedKey The object is held by a ReadHandle to delay its retriev...
Definition: SGVersionedKey.h:17
python.PyAthena.obj
obj
Definition: PyAthena.py:132
StoreGateSvc.h
EventStreamInfo::insertEventType
void insertEventType(const EventType &event)
Insert new Event Type into a set.
Definition: EventStreamInfo.cxx:88
CopyEventStreamInfo::beginInputFile
virtual StatusCode beginInputFile(const SG::SourceID &="Serial") override final
Function called when a new input file is opened.
Definition: CopyEventStreamInfo.cxx:33
EventStreamInfo::insertLumiBlockNumber
void insertLumiBlockNumber(unsigned int lumiBlock)
Insert new Luminosity Block Number into a set.
Definition: EventStreamInfo.cxx:70
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37