ATLAS Offline Software
Loading...
Searching...
No Matches
asg::SgEventMeta Class Reference

Wrapper class providing StoreGate-like access to metadata in ROOT. More...

#include <SgEventMeta.h>

Collaboration diagram for asg::SgEventMeta:

Public Types

enum  StoreType { InputStore = 0 , OutputStore = 1 }
 Type of the store that this object implements. More...

Public Member Functions

 SgEventMeta (StoreType type, xAOD::Event *event=0)
 Constructor with a type and an optional Event pointer.
 SgEventMeta (SgEventMeta &&other) noexcept
 Move constructor.
SgEventMetaoperator= (SgEventMeta &&other) noexcept
 Move assignment operator.
SgEventMetaoperator= (xAOD::Event *event)
 Assignment operator to handle direct event pointer assignment.
 SgEventMeta (const SgEventMeta &)=delete
SgEventMetaoperator= (const SgEventMeta &)=delete
Functions providing access to the metadata payload
template<typename T>
bool contains (const std::string &name)
 Check if an object is available for constant access.
template<typename T>
bool transientContains (const std::string &name) const
 Check if an object is available for non-constant access.
template<typename T>
StatusCode retrieve (T *&obj, const std::string &name)
 Retrieve a non-constant pointer to an object in the store.
template<typename T>
StatusCode retrieve (const T *&obj, const std::string &name)
 Retrieve a constant pointer to an object in the store.
template<typename T>
StatusCode record (std::unique_ptr< T > obj, const std::string &cname)
 Record an object/container using a smart pointer for ownership.
template<typename T>
StatusCode record (T *obj, const std::string &name)
 Record an object into the store.
template<typename T>
void keys (std::vector< std::string > &vkeys) const
 provide list of all keys associated with a type.

Private Member Functions

StatusCode initialize () const
 Function initialising the object.

Private Attributes

StoreType m_type
 Type of this store.
std::atomic< xAOD::Event * > m_event
 Pointer to the xAOD::Event object in use.

Detailed Description

Wrapper class providing StoreGate-like access to metadata in ROOT.

In Athena we access the input and output metadata stores with two separate StoreGateSvc instances. In ROOT the access to the metadata content of the input/output files is provided using the same xAOD::Event object that we use to access the event content of these files as well. To emulate the same pattern for the dual-use tools that Athena provides, this wrapper is used.

It behaves pretty much like SgEvent, but I didn't want to make that class even more complicated. Instead decided to implement the metadata access using this independent class.

Author
Attila Krasznahorkay Attil.nosp@m.a.Kr.nosp@m.aszna.nosp@m.hork.nosp@m.ay@ce.nosp@m.rn.c.nosp@m.h
Revision
611829
Date
2014-08-14 15:53:41 +0200 (Thu, 14 Aug 2014)

Definition at line 45 of file SgEventMeta.h.

Member Enumeration Documentation

◆ StoreType

Type of the store that this object implements.

Enumerator
InputStore 

This store is used to access the input metadata.

OutputStore 

This store is used to access the output metadata.

Definition at line 49 of file SgEventMeta.h.

49 {
50 InputStore = 0,
51 OutputStore = 1
52 }; // enum StoreType
@ InputStore
This store is used to access the input metadata.
Definition SgEventMeta.h:50
@ OutputStore
This store is used to access the output metadata.
Definition SgEventMeta.h:51

Constructor & Destructor Documentation

◆ SgEventMeta() [1/3]

asg::SgEventMeta::SgEventMeta ( StoreType type,
xAOD::Event * event = 0 )

Constructor with a type and an optional Event pointer.

Definition at line 16 of file SgEventMeta.cxx.

17 : m_type( type ) {
18 m_event.store(event);
19 }
std::atomic< xAOD::Event * > m_event
Pointer to the xAOD::Event object in use.
StoreType m_type
Type of this store.

◆ SgEventMeta() [2/3]

asg::SgEventMeta::SgEventMeta ( SgEventMeta && other)
noexcept

Move constructor.

Definition at line 21 of file SgEventMeta.cxx.

22 : m_type(other.m_type) {
23 m_event.store(other.m_event.load());
24 }

◆ SgEventMeta() [3/3]

asg::SgEventMeta::SgEventMeta ( const SgEventMeta & )
delete

Member Function Documentation

◆ contains()

template<typename T>
bool asg::SgEventMeta::contains ( const std::string & name)

Check if an object is available for constant access.

◆ initialize()

StatusCode asg::SgEventMeta::initialize ( ) const
private

Function initialising the object.

This function is used by the template functions to try to retrieve a valid pointer to the active Event object, if one is not available yet.

Returns
StatusCode::FAILURE if Event can't be found, StatusCode::SUCCESS otherwise

Definition at line 46 of file SgEventMeta.cxx.

46 {
47
48 // Return right away if we already have a non-null pointer:
49 if (m_event && m_event.load()) {
50 return StatusCode::SUCCESS;
51 }
52
53 // Check if there's an active event:
54 xAOD::TVirtualEvent* event = xAOD::TActiveEvent::event();
55 if( ! event ) {
56 std::cout << META_ERROR_SRC << "Couldn't find an active event in "
57 << "the job" << std::endl;
58 return StatusCode::FAILURE;
59 }
60
61 // This should actually be a Event:
62 m_event.store(dynamic_cast< xAOD::Event* >( event ));
63 if( !m_event || !m_event.load() ) {
64 std::cout << META_ERROR_SRC << "The active event is not of type "
65 << "xAOD::Event?!?" << std::endl;
66 return StatusCode::FAILURE;
67 }
68
69 // We succeeded:
70 return StatusCode::SUCCESS;
71 }
static TVirtualEvent * event()
Access the currently active TVirtualEvent object.

◆ keys()

template<typename T>
void asg::SgEventMeta::keys ( std::vector< std::string > & vkeys) const

provide list of all keys associated with a type.

usage: store->keys< type >(vector_to_fill)

Parameters
vkeyswill be filled with list of keys (may be empty)

◆ operator=() [1/3]

SgEventMeta & asg::SgEventMeta::operator= ( const SgEventMeta & )
delete

◆ operator=() [2/3]

SgEventMeta & asg::SgEventMeta::operator= ( SgEventMeta && other)
noexcept

Move assignment operator.

Definition at line 26 of file SgEventMeta.cxx.

26 {
27 if (this != &other) {
28 m_type = other.m_type;
29 m_event.store(other.m_event.load());
30 }
31 return *this;
32 }

◆ operator=() [3/3]

SgEventMeta & asg::SgEventMeta::operator= ( xAOD::Event * event)

Assignment operator to handle direct event pointer assignment.

Definition at line 34 of file SgEventMeta.cxx.

34 {
35 m_event.store(event);
36 return *this;
37 }

◆ record() [1/2]

template<typename T>
StatusCode asg::SgEventMeta::record ( std::unique_ptr< T > obj,
const std::string & cname )

Record an object/container using a smart pointer for ownership.

◆ record() [2/2]

template<typename T>
StatusCode asg::SgEventMeta::record ( T * obj,
const std::string & name )

Record an object into the store.

◆ retrieve() [1/2]

template<typename T>
StatusCode asg::SgEventMeta::retrieve ( const T *& obj,
const std::string & name )

Retrieve a constant pointer to an object in the store.

◆ retrieve() [2/2]

template<typename T>
StatusCode asg::SgEventMeta::retrieve ( T *& obj,
const std::string & name )

Retrieve a non-constant pointer to an object in the store.

◆ transientContains()

template<typename T>
bool asg::SgEventMeta::transientContains ( const std::string & name) const

Check if an object is available for non-constant access.

Member Data Documentation

◆ m_event

std::atomic<xAOD::Event*> asg::SgEventMeta::m_event
mutableprivate

Pointer to the xAOD::Event object in use.

Definition at line 110 of file SgEventMeta.h.

◆ m_type

StoreType asg::SgEventMeta::m_type
private

Type of this store.

Definition at line 108 of file SgEventMeta.h.


The documentation for this class was generated from the following files: