ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
MakeEventStreamInfo Class Reference

This class provides an algorithm to make the EventStreamInfo object and update it. More...

#include <MakeEventStreamInfo.h>

Inheritance diagram for MakeEventStreamInfo:
Collaboration diagram for MakeEventStreamInfo:

Public Member Functions

 MakeEventStreamInfo (const std::string &type, const std::string &name, const IInterface *parent)
 Standard AlgTool Constructor. More...
 
virtual ~MakeEventStreamInfo ()
 Destructor. More...
 
virtual StatusCode initialize () override
 Required of all IAthenaOutputTools: Called by AthenaOutputStream::initialize() (via ToolSvc retrieve()). More...
 
virtual StatusCode postInitialize () override
 Called at the end of AthenaOutputStream::initialize(). More...
 
virtual StatusCode preExecute () override
 Called at the beginning of AthenaOutputStream::execute(). More...
 
virtual StatusCode preStream () override
 Called before actually streaming objects. More...
 
virtual StatusCode postExecute () override
 Called at the end of AthenaOutputStream::execute(). More...
 
virtual StatusCode preFinalize () override
 Called at the beginning of AthenaOutputStream::finalize(). More...
 
virtual StatusCode finalize () override
 Called at the end of AthenaOutputStream::finalize() (via release()). More...
 

Private Attributes

StringProperty m_dataHeaderKey {this, "DataHeaderKey", "", "name of the data header key"}
 Name of DataHeader key. More...
 
StringProperty m_key {this, "Key", "", "name of the EventStreamInfo object"}
 Key, the StoreGate key for the EventStreamInfo object. More...
 
StringProperty m_eventInfoKey {this, "EventInfoKey", "EventInfo", "name of the xAOD::EventInfo"}
 Key, the StoreGate key for the xAOD::EventInfo object. More...
 
ServiceHandle< IAthMetaDataSvcm_metaDataSvc {this, "MetaDataSvc", "MetaDataSvc"}
 Pointer to the data stores. More...
 
ServiceHandle< StoreGateSvcm_eventStore {this, "StoreGateSvc", "StoreGateSvc"}
 
std::atomic< unsigned int > m_eventCounter {0}
 Counter of the events in the stream. More...
 

Detailed Description

This class provides an algorithm to make the EventStreamInfo object and update it.

Definition at line 27 of file MakeEventStreamInfo.h.

Constructor & Destructor Documentation

◆ MakeEventStreamInfo()

MakeEventStreamInfo::MakeEventStreamInfo ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Standard AlgTool Constructor.

Definition at line 20 of file MakeEventStreamInfo.cxx.

22  : base_class(type, name, parent)
23 {
24 }

◆ ~MakeEventStreamInfo()

MakeEventStreamInfo::~MakeEventStreamInfo ( )
virtual

Destructor.

Definition at line 26 of file MakeEventStreamInfo.cxx.

26  {
27 }

Member Function Documentation

◆ finalize()

StatusCode MakeEventStreamInfo::finalize ( )
overridevirtual

Called at the end of AthenaOutputStream::finalize() (via release()).

Definition at line 148 of file MakeEventStreamInfo.cxx.

148  {
149  ATH_MSG_DEBUG("in finalize()");
150  // release the MetaDataStore
151  if (!m_metaDataSvc.release().isSuccess()) {
152  ATH_MSG_WARNING("Could not release MetaDataStore");
153  }
154  if (!m_eventStore.release().isSuccess()) {
155  ATH_MSG_WARNING("Could not release EventStore");
156  }
157  return(StatusCode::SUCCESS);
158 }

◆ initialize()

StatusCode MakeEventStreamInfo::initialize ( )
overridevirtual

Required of all IAthenaOutputTools: Called by AthenaOutputStream::initialize() (via ToolSvc retrieve()).

Definition at line 29 of file MakeEventStreamInfo.cxx.

29  {
30  ATH_MSG_DEBUG("Initializing " << name());
31  // Locate the MetaDataStore
32  if (!m_metaDataSvc.retrieve().isSuccess()) {
33  ATH_MSG_FATAL("Could not find MetaDataSvc");
34  return(StatusCode::FAILURE);
35  }
36  if (!m_eventStore.retrieve().isSuccess()) {
37  ATH_MSG_FATAL("Could not find EventStore");
38  return(StatusCode::FAILURE);
39  }
40 
41  // Autoconfigure data header key
42  if (m_dataHeaderKey.empty()){
43  const IAlgorithm* parentAlg = dynamic_cast<const IAlgorithm*>(this->parent());
44  if (parentAlg == nullptr) {
45  ATH_MSG_ERROR("Unable to get parent Algorithm");
46  return(StatusCode::FAILURE);
47  }
48  m_dataHeaderKey.setValue(parentAlg->name());
49  }
50 
51  return(StatusCode::SUCCESS);
52 }

◆ postExecute()

StatusCode MakeEventStreamInfo::postExecute ( )
overridevirtual

Called at the end of AthenaOutputStream::execute().

Definition at line 72 of file MakeEventStreamInfo.cxx.

72  {
74  if (!dataHeader.isValid()) {
75  return(StatusCode::SUCCESS);
76  }
77  // Retrieve the EventInfo object
78  EventType evtype;
79  unsigned long long runN = 0;
80  unsigned lumiN = 0;
82  if (xEventInfo.isValid()) {
83  runN = xEventInfo->runNumber();
84  lumiN = xEventInfo->lumiBlock();
85  evtype = eventTypeFromxAOD(xEventInfo.get());
86  } else {
87  ATH_MSG_ERROR("Unable to retrieve xAOD::EventInfo object");
88  return(StatusCode::FAILURE);
89  }
90 
91  EventStreamInfo* pEventStream = m_metaDataSvc->tryRetrieve<EventStreamInfo>(m_key.value());
92  if( !pEventStream ) {
93  auto esinfo_up = std::make_unique<EventStreamInfo>();
94  pEventStream = esinfo_up.get();
95  if( m_metaDataSvc->record(std::move(esinfo_up), m_key.value()).isFailure() ) {
96  ATH_MSG_ERROR("Could not register EventStreamInfo object");
97  return(StatusCode::FAILURE);
98  }
99  }
100  static std::once_flag resetNumberOfEventsFlag;
101  std::call_once(resetNumberOfEventsFlag, [this, pEventStream]() -> void {
102  ATH_MSG_DEBUG("Resetting the EventStreamInfo payload at the first event");
103  pEventStream->reset();
104  });
105  pEventStream->addEvent();
106  pEventStream->insertProcessingTag(dataHeader->getProcessTag());
107  pEventStream->insertLumiBlockNumber( lumiN );
108  pEventStream->insertRunNumber( runN );
109  for (const DataHeaderElement& dhe : *dataHeader) {
110  pEventStream->insertItemList(dhe.getPrimaryClassID(), dhe.getKey());
111  }
112  pEventStream->insertEventType( evtype );
113 
114  m_eventCounter++;
115 
116  return(StatusCode::SUCCESS);
117 }

◆ postInitialize()

StatusCode MakeEventStreamInfo::postInitialize ( )
overridevirtual

Called at the end of AthenaOutputStream::initialize().

Definition at line 54 of file MakeEventStreamInfo.cxx.

54  {
55  // Remove EventStreamInfo with same key if it exists
56  bool ignoreIfAbsent = true;
57  if( !m_metaDataSvc->remove<EventStreamInfo>(m_key.value(), ignoreIfAbsent).isSuccess() ) {
58  ATH_MSG_ERROR("Unable to remove EventStreamInfo with key " << m_key.value());
59  return StatusCode::FAILURE;
60  }
61  return(StatusCode::SUCCESS);
62 }

◆ preExecute()

StatusCode MakeEventStreamInfo::preExecute ( )
overridevirtual

Called at the beginning of AthenaOutputStream::execute().

Definition at line 64 of file MakeEventStreamInfo.cxx.

64  {
65  return(StatusCode::SUCCESS);
66 }

◆ preFinalize()

StatusCode MakeEventStreamInfo::preFinalize ( )
overridevirtual

Called at the beginning of AthenaOutputStream::finalize().

Definition at line 119 of file MakeEventStreamInfo.cxx.

119  {
120  EventStreamInfo* pEventStream = m_metaDataSvc->tryRetrieve<EventStreamInfo>(m_key.value());
121  if (!pEventStream) {
122  auto esinfo_up = std::make_unique<EventStreamInfo>();
123  pEventStream = esinfo_up.get();
124  ATH_CHECK(m_metaDataSvc->record(std::move(esinfo_up), m_key.value()));
125  }
126  if (m_eventCounter > 0 &&
127  m_eventCounter < pEventStream->getNumberOfEvents()) {
128  // The number of events that have been processed by MakeEventStreamInfo
129  // tool is less than the number of events in already existing
130  // EventStreamInfo object. This can happen if the EventStreamInfo object was
131  // updated by CopyEventStreamInfo, for example at beginning of reading the
132  // 2nd (or next) file.
134  "Event count mismatch in EventStreamInfo (likely due to "
135  "multi-file processing). MakeEventStreamInfo processed: "
136  << m_eventCounter << " events, existing EventStreamInfo object has "
137  << pEventStream->getNumberOfEvents()
138  << " events. Setting number of events to what "
139  "MakeEventStreamInfo processed.");
140  pEventStream->setNumberOfEvents(m_eventCounter);
141  } else {
142  // Insert processing tags when no events have been processed
143  pEventStream->insertProcessingTag(m_dataHeaderKey.value());
144  }
145  return (StatusCode::SUCCESS);
146 }

◆ preStream()

StatusCode MakeEventStreamInfo::preStream ( )
overridevirtual

Called before actually streaming objects.

Definition at line 68 of file MakeEventStreamInfo.cxx.

68  {
69  return(StatusCode::SUCCESS);
70 }

Member Data Documentation

◆ m_dataHeaderKey

StringProperty MakeEventStreamInfo::m_dataHeaderKey {this, "DataHeaderKey", "", "name of the data header key"}
private

Name of DataHeader key.

Definition at line 51 of file MakeEventStreamInfo.h.

◆ m_eventCounter

std::atomic<unsigned int> MakeEventStreamInfo::m_eventCounter {0}
private

Counter of the events in the stream.

Definition at line 63 of file MakeEventStreamInfo.h.

◆ m_eventInfoKey

StringProperty MakeEventStreamInfo::m_eventInfoKey {this, "EventInfoKey", "EventInfo", "name of the xAOD::EventInfo"}
private

Key, the StoreGate key for the xAOD::EventInfo object.

Definition at line 56 of file MakeEventStreamInfo.h.

◆ m_eventStore

ServiceHandle<StoreGateSvc> MakeEventStreamInfo::m_eventStore {this, "StoreGateSvc", "StoreGateSvc"}
private

Definition at line 60 of file MakeEventStreamInfo.h.

◆ m_key

StringProperty MakeEventStreamInfo::m_key {this, "Key", "", "name of the EventStreamInfo object"}
private

Key, the StoreGate key for the EventStreamInfo object.

Definition at line 53 of file MakeEventStreamInfo.h.

◆ m_metaDataSvc

ServiceHandle<IAthMetaDataSvc> MakeEventStreamInfo::m_metaDataSvc {this, "MetaDataSvc", "MetaDataSvc"}
private

Pointer to the data stores.

Definition at line 59 of file MakeEventStreamInfo.h.


The documentation for this class was generated from the following files:
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
MakeEventStreamInfo::m_eventStore
ServiceHandle< StoreGateSvc > m_eventStore
Definition: MakeEventStreamInfo.h:60
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
EventType
This class represents the "type of event" where the type is given by one or more "characteristics".
Definition: EventType.h:92
MakeEventStreamInfo::m_metaDataSvc
ServiceHandle< IAthMetaDataSvc > m_metaDataSvc
Pointer to the data stores.
Definition: MakeEventStreamInfo.h:59
EventStreamInfo::reset
void reset()
Definition: EventStreamInfo.cxx:132
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
EventStreamInfo::setNumberOfEvents
void setNumberOfEvents(unsigned int number)
Set number of events.
Definition: EventStreamInfo.cxx:58
DataHeaderElement
This class provides a persistent form for the TransientAddress.
Definition: DataHeader.h:37
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
MakeEventStreamInfo::m_eventCounter
std::atomic< unsigned int > m_eventCounter
Counter of the events in the stream.
Definition: MakeEventStreamInfo.h:63
EventStreamInfo::insertRunNumber
void insertRunNumber(unsigned int run)
Insert new Run Number into a set.
Definition: EventStreamInfo.cxx:64
MakeEventStreamInfo::m_dataHeaderKey
StringProperty m_dataHeaderKey
Name of DataHeader key.
Definition: MakeEventStreamInfo.h:51
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
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
EventStreamInfo::getNumberOfEvents
unsigned int getNumberOfEvents() const
Definition: EventStreamInfo.cxx:17
MakeEventStreamInfo::m_eventInfoKey
StringProperty m_eventInfoKey
Key, the StoreGate key for the xAOD::EventInfo object.
Definition: MakeEventStreamInfo.h:56
EventStreamInfo
This class provides the summary information stored for data written as a Event Stream.
Definition: EventStreamInfo.h:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
EventStreamInfo::insertItemList
void insertItemList(CLID type, const std::string &key)
Insert new ItemList Entry into a set.
Definition: EventStreamInfo.cxx:82
eventTypeFromxAOD
EventType eventTypeFromxAOD(const xAOD::EventInfo *xaod)
Create EventType object from xAOD::EventInfo.
Definition: EventInfoFromxAOD.cxx:34
MakeEventStreamInfo::m_key
StringProperty m_key
Key, the StoreGate key for the EventStreamInfo object.
Definition: MakeEventStreamInfo.h:53
EventStreamInfo::insertEventType
void insertEventType(const EventType &event)
Insert new Event Type into a set.
Definition: EventStreamInfo.cxx:88
EventStreamInfo::insertLumiBlockNumber
void insertLumiBlockNumber(unsigned int lumiBlock)
Insert new Luminosity Block Number into a set.
Definition: EventStreamInfo.cxx:70