Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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...
 
 SgTEventMeta (SgTEventMeta &&other) noexcept
 Move constructor. More...
 
SgTEventMetaoperator= (SgTEventMeta &&other) noexcept
 Move assignment operator. More...
 
SgTEventMetaoperator= (xAOD::TEvent *event)
 Assignment operator to handle direct event pointer assignment. More...
 
 SgTEventMeta (const SgTEventMeta &)=delete
 
SgTEventMetaoperator= (const SgTEventMeta &)=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. 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...
 
std::atomic< xAOD::TEvent * > m_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 45 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 49 of file SgTEventMeta.h.

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

Constructor & Destructor Documentation

◆ SgTEventMeta() [1/3]

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 ) {
18  m_event.store(event);
19  }

◆ SgTEventMeta() [2/3]

asg::SgTEventMeta::SgTEventMeta ( SgTEventMeta &&  other)
noexcept

Move constructor.

Definition at line 21 of file SgTEventMeta.cxx.

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

◆ SgTEventMeta() [3/3]

asg::SgTEventMeta::SgTEventMeta ( const SgTEventMeta )
delete

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 46 of file SgTEventMeta.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:
55  if( ! event ) {
56  std::cout << META_ERROR_SOURCE << "Couldn't find an active event in "
57  << "the job" << std::endl;
58  return StatusCode::FAILURE;
59  }
60 
61  // This should actually be a TEvent:
62  m_event.store(dynamic_cast< xAOD::TEvent* >( event ));
63  if( !m_event || !m_event.load() ) {
64  std::cout << META_ERROR_SOURCE << "The active event is not of type "
65  << "xAOD::TEvent?!?" << std::endl;
66  return StatusCode::FAILURE;
67  }
68 
69  // We succeeded:
70  return StatusCode::SUCCESS;
71  }

◆ 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)

◆ operator=() [1/3]

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

◆ operator=() [2/3]

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

Move assignment operator.

Definition at line 26 of file SgTEventMeta.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]

SgTEventMeta & asg::SgTEventMeta::operator= ( xAOD::TEvent event)

Assignment operator to handle direct event pointer assignment.

Definition at line 34 of file SgTEventMeta.cxx.

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

◆ 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

std::atomic<xAOD::TEvent*> asg::SgTEventMeta::m_event
mutableprivate

Pointer to the xAOD::TEvent object in use.

Definition at line 110 of file SgTEventMeta.h.

◆ m_type

StoreType asg::SgTEventMeta::m_type
private

Type of this store.

Definition at line 108 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:51
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
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_type
StoreType m_type
Type of this store.
Definition: SgTEventMeta.h:108
asg::SgTEventMeta::InputStore
@ InputStore
This store is used to access the input metadata.
Definition: SgTEventMeta.h:50
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
asg::SgTEventMeta::m_event
std::atomic< xAOD::TEvent * > m_event
Pointer to the xAOD::TEvent object in use.
Definition: SgTEventMeta.h:110
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:85