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

Wrapper for TEvent to make it look like StoreGate. More...

#include <SgTEvent.h>

Collaboration diagram for asg::SgTEvent:

Public Member Functions

 SgTEvent (xAOD::TEvent *pevm=0, xAOD::TStore *ptds=0)
 Constructor specifying concrete TEvent and TStore objects. More...
 
xAOD::TEventevent () const
 Return the underlying event manager. More...
 
xAOD::TStoretds () const
 Return the underlying transient data store. More...
 
Functions providing access to the persistent and transient data
template<typename T >
bool contains (const std::string &name) const
 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 >
T * retrieve (const std::string &name) const
 Function retrieving a constant or non-constant object. More...
 
template<typename T >
StatusCode retrieve (T *&pobj, const std::string &name)
 Retrieve a container from memory. More...
 
template<typename T >
StatusCode retrieve (const T *&pobj, const std::string &name) const
 Retrieve a container from the input file or the memory. More...
 
template<typename T >
StatusCode record (std::unique_ptr< T > pobj, const std::string &cname)
 Record an object/container using a smart pointer for ownership. More...
 
template<typename T >
StatusCode record (T *pobj, const std::string &cname)
 Record an object/container. More...
 
template<typename T >
StatusCode overwrite (T *pobj, const std::string &name, bool allowMods, bool resetOnly=true, bool noHist=false)
 Overwrite an object/container in the transient store. More...
 
template<typename T >
void keys (std::vector< std::string > &vkeys) const
 provide list of all keys associated with an object. More...
 

Private Member Functions

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

Private Attributes

xAOD::TEventm_pevm
 Pointer to the TEvent that this object interacts with. More...
 
xAOD::TStorem_ptds
 Pointer to the TStore that this object interacts with. More...
 

Detailed Description

Wrapper for TEvent to make it look like StoreGate.

In order to be able to interact with xAOD::TEvent using the same sort of code that we use to interact with StoreGateSvc in Athena, we wrap it into such an object.

This class also takes care of placing transient objects into xAOD::TStore.

Author
David Adams dlada.nosp@m.ms@b.nosp@m.nl.go.nosp@m.v
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
669898
Date
2015-05-26 15:49:13 +0200 (Tue, 26 May 2015)

Definition at line 44 of file SgTEvent.h.

Constructor & Destructor Documentation

◆ SgTEvent()

asg::SgTEvent::SgTEvent ( xAOD::TEvent pevm = 0,
xAOD::TStore ptds = 0 
)

Constructor specifying concrete TEvent and TStore objects.

Definition at line 19 of file SgTEvent.cxx.

20  : m_pevm( pevm ), m_ptds( ptds ) {
21 
22  }

Member Function Documentation

◆ contains()

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

Check if an object is available for constant access.

◆ event()

xAOD::TEvent * asg::SgTEvent::event ( ) const

Return the underlying event manager.

Definition at line 24 of file SgTEvent.cxx.

24  {
25 
26  if( ! m_pevm ) {
27  initialize().ignore();
28  }
29 
30  return m_pevm;
31  }

◆ initialize()

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

Function initialising the object.

Definition at line 44 of file SgTEvent.cxx.

44  {
45 
46  // Return right away if we already have a pointer to both stores:
47  if( m_pevm && m_ptds ) {
48  return StatusCode::SUCCESS;
49  }
50 
51  // Look for a pointer to the active event if necessary:
52  if( ! m_pevm ) {
53  // Check if there's an active event:
55  if( ! event ) {
56  std::cout << 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_pevm = dynamic_cast< xAOD::TEvent* >( event );
63  if( ! m_pevm ) {
64  std::cout << ERROR_SOURCE << "The active event is not of type "
65  << "xAOD::TEvent?!?" << std::endl;
66  return StatusCode::FAILURE;
67  }
68  }
69 
70  // Look for a pointer to the active store if necessary:
71  if( ! m_ptds ) {
73  if( ! m_ptds ) {
74  std::cout << "asg::SgTEvent WARNING "
75  << "No xAOD::TStore object is available" << std::endl;
76  }
77  }
78 
79  // Return gracefully:
80  return StatusCode::SUCCESS;
81  }

◆ keys()

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

provide list of all keys associated with an object.

usage: store->keys(key_vector)

Parameters
avector of strings that will be filled with the list of keys

◆ overwrite()

template<typename T >
StatusCode asg::SgTEvent::overwrite ( T *  pobj,
const std::string &  name,
bool  allowMods,
bool  resetOnly = true,
bool  noHist = false 
)

Overwrite an object/container in the transient store.

◆ record() [1/2]

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

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

◆ record() [2/2]

template<typename T >
StatusCode asg::SgTEvent::record ( T *  pobj,
const std::string &  cname 
)

Record an object/container.

◆ retrieve() [1/3]

template<typename T >
T* asg::SgTEvent::retrieve ( const std::string &  name) const

Function retrieving a constant or non-constant object.

◆ retrieve() [2/3]

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

Retrieve a container from the input file or the memory.

◆ retrieve() [3/3]

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

Retrieve a container from memory.

◆ tds()

xAOD::TStore * asg::SgTEvent::tds ( ) const

Return the underlying transient data store.

Definition at line 33 of file SgTEvent.cxx.

33  {
34 
35  // I'm checking the value of m_pevm on purpose. Since m_ptds may be
36  // missing under normal circumstances as well.
37  if( ! m_pevm ) {
38  initialize().ignore();
39  }
40 
41  return m_ptds;
42  }

◆ transientContains()

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

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

Member Data Documentation

◆ m_pevm

xAOD::TEvent* asg::SgTEvent::m_pevm
mutableprivate

Pointer to the TEvent that this object interacts with.

Definition at line 105 of file SgTEvent.h.

◆ m_ptds

xAOD::TStore* asg::SgTEvent::m_ptds
mutableprivate

Pointer to the TStore that this object interacts with.

Definition at line 107 of file SgTEvent.h.


The documentation for this class was generated from the following files:
asg::SgTEvent::initialize
StatusCode initialize() const
Function initialising the object.
Definition: SgTEvent.cxx:44
xAOD::TVirtualEvent
Base interface for getting objects out of the input file.
Definition: TVirtualEvent.h:32
xAOD::TActiveStore::store
static TStore * store()
Access the currently active TStore object.
Definition: TActiveStore.cxx:16
xAOD::TActiveEvent::event
static TVirtualEvent * event()
Access the currently active TVirtualEvent object.
Definition: TActiveEvent.cxx:16
asg::SgTEvent::m_pevm
xAOD::TEvent * m_pevm
Pointer to the TEvent that this object interacts with.
Definition: SgTEvent.h:105
asg::SgTEvent::m_ptds
xAOD::TStore * m_ptds
Pointer to the TStore that this object interacts with.
Definition: SgTEvent.h:107
asg::SgTEvent::event
xAOD::TEvent * event() const
Return the underlying event manager.
Definition: SgTEvent.cxx:24
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:84