ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
asg::SgTEventMeta Class Reference

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

#include <SgTEventMeta.h>

Collaboration diagram for asg::SgTEventMeta:

Public Types

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

Public Member Functions

 SgTEventMeta (StoreType type, xAOD::TEvent *event=0)
 Constructor with a type and an optional TEvent pointer. More...
 
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. More...
 
template<typename T >
bool transientContains (const std::string &name) const
 Check if an object is available for non-constant access. More...
 
template<typename T >
StatusCode retrieve (T *&obj, const std::string &name)
 Retrieve a non-constant pointer to an object in the store. More...
 
template<typename T >
StatusCode retrieve (const T *&obj, const std::string &name)
 Retrieve a constant pointer to an object in the store. More...
 
template<typename T >
StatusCode record (std::unique_ptr< T > obj, const std::string &cname)
 Record an object/container using a smart pointer for ownership. More...
 
template<typename T >
StatusCode record (T *obj, const std::string &name)
 Record an object into the store. More...
 
template<typename T >
void keys (std::vector< std::string > &vkeys) const
 provide list of all keys associated with a type. More...
 

Private Member Functions

StatusCode initialize () const
 Function initialising the object. More...
 

Private Attributes

StoreType m_type
 Type of this store. More...
 
xAOD::TEventm_event
 Pointer to the xAOD::TEvent object in use. More...
 

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::TEvent 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 SgTEvent, 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 44 of file SgTEventMeta.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 48 of file SgTEventMeta.h.

48  {
49  InputStore = 0,
50  OutputStore = 1
51  }; // enum StoreType

Constructor & Destructor Documentation

◆ SgTEventMeta()

asg::SgTEventMeta::SgTEventMeta ( StoreType  type,
xAOD::TEvent event = 0 
)

Constructor with a type and an optional TEvent pointer.

Definition at line 16 of file SgTEventMeta.cxx.

17  : m_type( type ), m_event( event ) {
18 
19  }

Member Function Documentation

◆ contains()

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

Check if an object is available for constant access.

◆ initialize()

StatusCode asg::SgTEventMeta::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 TEvent object, if one is not available yet.

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

Definition at line 28 of file SgTEventMeta.cxx.

28  {
29 
30  // Return right away if we already have a non-null pointer:
31  if( m_event ) {
32  return StatusCode::SUCCESS;
33  }
34 
35  // Check if there's an active event:
37  if( ! event ) {
38  std::cout << META_ERROR_SOURCE << "Couldn't find an active event in "
39  << "the job" << std::endl;
40  return StatusCode::FAILURE;
41  }
42 
43  // This should actually be a TEvent:
44  m_event = dynamic_cast< xAOD::TEvent* >( event );
45  if( ! m_event ) {
46  std::cout << META_ERROR_SOURCE << "The active event is not of type "
47  << "xAOD::TEvent?!?" << std::endl;
48  return StatusCode::FAILURE;
49  }
50 
51  // We succeeded:
52  return StatusCode::SUCCESS;
53  }

◆ keys()

template<typename T >
void asg::SgTEventMeta::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)

◆ record() [1/2]

template<typename T >
StatusCode asg::SgTEventMeta::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::SgTEventMeta::record ( T *  obj,
const std::string &  name 
)

Record an object into the store.

◆ retrieve() [1/2]

template<typename T >
StatusCode asg::SgTEventMeta::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::SgTEventMeta::retrieve ( T *&  obj,
const std::string &  name 
)

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

◆ transientContains()

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

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

Member Data Documentation

◆ m_event

xAOD::TEvent* asg::SgTEventMeta::m_event
mutableprivate

Pointer to the xAOD::TEvent object in use.

Definition at line 96 of file SgTEventMeta.h.

◆ m_type

StoreType asg::SgTEventMeta::m_type
private

Type of this store.

Definition at line 94 of file SgTEventMeta.h.


The documentation for this class was generated from the following files:
xAOD::TVirtualEvent
Base interface for getting objects out of the input file.
Definition: TVirtualEvent.h:32
asg::SgTEventMeta::OutputStore
@ OutputStore
This store is used to access the output metadata.
Definition: SgTEventMeta.h:50
xAOD::TActiveEvent::event
static TVirtualEvent * event()
Access the currently active TVirtualEvent object.
Definition: TActiveEvent.cxx:16
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
asg::SgTEventMeta::m_event
xAOD::TEvent * m_event
Pointer to the xAOD::TEvent object in use.
Definition: SgTEventMeta.h:96
asg::SgTEventMeta::m_type
StoreType m_type
Type of this store.
Definition: SgTEventMeta.h:94
asg::SgTEventMeta::InputStore
@ InputStore
This store is used to access the input metadata.
Definition: SgTEventMeta.h:49
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:81