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...
 
StringProperty m_oEventInfoKey {this, "OldEventInfoKey", "McEventInfo", "name of the legacy EventInfo"}
 Key, the StoreGate key for the old EventInfo object, ix there is no xAOD::EventInfo. More...
 
ServiceHandle< IAthMetaDataSvcm_metaDataSvc {this, "MetaDataSvc", "MetaDataSvc"}
 Pointer to the data stores. More...
 
ServiceHandle< StoreGateSvcm_eventStore {this, "StoreGateSvc", "StoreGateSvc"}
 
bool m_filledEvent {false}
 Check if the EventStreamInfo was filled with event-specific information. 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 23 of file MakeEventStreamInfo.cxx.

25  : base_class(type, name, parent)
26 {
27 }

◆ ~MakeEventStreamInfo()

MakeEventStreamInfo::~MakeEventStreamInfo ( )
virtual

Destructor.

Definition at line 29 of file MakeEventStreamInfo.cxx.

29  {
30 }

Member Function Documentation

◆ finalize()

StatusCode MakeEventStreamInfo::finalize ( )
overridevirtual

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

Definition at line 142 of file MakeEventStreamInfo.cxx.

142  {
143  ATH_MSG_DEBUG("in finalize()");
144  // release the MetaDataStore
145  if (!m_metaDataSvc.release().isSuccess()) {
146  ATH_MSG_WARNING("Could not release MetaDataStore");
147  }
148  if (!m_eventStore.release().isSuccess()) {
149  ATH_MSG_WARNING("Could not release EventStore");
150  }
151  return(StatusCode::SUCCESS);
152 }

◆ initialize()

StatusCode MakeEventStreamInfo::initialize ( )
overridevirtual

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

Definition at line 32 of file MakeEventStreamInfo.cxx.

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

◆ postExecute()

StatusCode MakeEventStreamInfo::postExecute ( )
overridevirtual

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

Definition at line 77 of file MakeEventStreamInfo.cxx.

77  {
79  if (!dataHeader.isValid()) {
80  return(StatusCode::SUCCESS);
81  }
82  // Retrieve the EventInfo object
83  EventType evtype;
84  unsigned long long runN = 0;
85  unsigned lumiN = 0;
87  if (xEventInfo.isValid()) {
88  runN = xEventInfo->runNumber();
89  lumiN = xEventInfo->lumiBlock();
90  evtype = eventTypeFromxAOD(xEventInfo.get());
91  } else {
93  if (oEventInfo.isValid()) {
94  runN = oEventInfo->event_ID()->run_number();
95  lumiN = oEventInfo->event_ID()->lumi_block();
96  evtype = *oEventInfo->event_type();
97  } else {
98  ATH_MSG_ERROR("Unable to retrieve EventInfo object");
99  return(StatusCode::FAILURE);
100  }
101  }
102 
103  EventStreamInfo* pEventStream = m_metaDataSvc->tryRetrieve<EventStreamInfo>(m_key.value());
104  if( !pEventStream ) {
105  auto esinfo_up = std::make_unique<EventStreamInfo>();
106  pEventStream = esinfo_up.get();
107  if( m_metaDataSvc->record(std::move(esinfo_up), m_key.value()).isFailure() ) {
108  ATH_MSG_ERROR("Could not register EventStreamInfo object");
109  return(StatusCode::FAILURE);
110  }
111  }
112  pEventStream->addEvent();
113  pEventStream->insertProcessingTag(dataHeader->getProcessTag());
114  pEventStream->insertLumiBlockNumber( lumiN );
115  pEventStream->insertRunNumber( runN );
116  for (const DataHeaderElement& dhe : *dataHeader) {
117  pEventStream->insertItemList(dhe.getPrimaryClassID(), dhe.getKey());
118  }
119  pEventStream->insertEventType( evtype );
120 
121  m_filledEvent = true;
122 
123  return(StatusCode::SUCCESS);
124 }

◆ postInitialize()

StatusCode MakeEventStreamInfo::postInitialize ( )
overridevirtual

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

Definition at line 59 of file MakeEventStreamInfo.cxx.

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

◆ preExecute()

StatusCode MakeEventStreamInfo::preExecute ( )
overridevirtual

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

Definition at line 69 of file MakeEventStreamInfo.cxx.

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

◆ preFinalize()

StatusCode MakeEventStreamInfo::preFinalize ( )
overridevirtual

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

Definition at line 126 of file MakeEventStreamInfo.cxx.

126  {
127  EventStreamInfo* pEventStream = m_metaDataSvc->tryRetrieve<EventStreamInfo>(m_key.value());
128  if (!pEventStream) {
129  auto esinfo_up = std::make_unique<EventStreamInfo>();
130  pEventStream = esinfo_up.get();
131  ATH_CHECK(m_metaDataSvc->record(std::move(esinfo_up), m_key.value()));
132  }
133  if (!m_filledEvent) {
134  // insert non-event information (processingTags)
135  // to EventStreamInfo if we have not processed any event
136 
137  pEventStream->insertProcessingTag(m_dataHeaderKey.value());
138  }
139  return (StatusCode::SUCCESS);
140 }

◆ preStream()

StatusCode MakeEventStreamInfo::preStream ( )
overridevirtual

Called before actually streaming objects.

Definition at line 73 of file MakeEventStreamInfo.cxx.

73  {
74  return(StatusCode::SUCCESS);
75 }

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_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 62 of file MakeEventStreamInfo.h.

◆ m_filledEvent

bool MakeEventStreamInfo::m_filledEvent {false}
private

Check if the EventStreamInfo was filled with event-specific information.

Definition at line 65 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 61 of file MakeEventStreamInfo.h.

◆ m_oEventInfoKey

StringProperty MakeEventStreamInfo::m_oEventInfoKey {this, "OldEventInfoKey", "McEventInfo", "name of the legacy EventInfo"}
private

Key, the StoreGate key for the old EventInfo object, ix there is no xAOD::EventInfo.

Definition at line 58 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:62
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
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:61
MakeEventStreamInfo::m_oEventInfoKey
StringProperty m_oEventInfoKey
Key, the StoreGate key for the old EventInfo object, ix there is no xAOD::EventInfo.
Definition: MakeEventStreamInfo.h:58
MakeEventStreamInfo::m_filledEvent
bool m_filledEvent
Check if the EventStreamInfo was filled with event-specific information.
Definition: MakeEventStreamInfo.h:65
DataHeaderElement
This class provides a persistent form for the TransientAddress.
Definition: DataHeader.h:36
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EventStreamInfo::insertRunNumber
void insertRunNumber(unsigned int run)
Insert new Run Number into a set.
Definition: EventStreamInfo.cxx:59
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:71
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
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
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
EventStreamInfo::insertItemList
void insertItemList(CLID type, const std::string &key)
Insert new ItemList Entry into a set.
Definition: EventStreamInfo.cxx:77
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:83
EventStreamInfo::insertLumiBlockNumber
void insertLumiBlockNumber(unsigned int lumiBlock)
Insert new Luminosity Block Number into a set.
Definition: EventStreamInfo.cxx:65