ATLAS Offline Software
SgTEvent.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ASGTOOLS_SGTEVENT_H
6 #define ASGTOOLS_SGTEVENT_H
7 
8 // System include(s):
9 #include <memory>
10 #include <string>
11 #include <vector>
12 
13 // Local include(s):
15 
16 // Complain if we try using this header in Athena:
17 #if !defined(XAOD_STANDALONE) && !defined(__CPPCHECK__)
18 # error( "This header should only be used for standalone ASG" )
19 #endif
20 
21 // Forward declaration(s):
22 namespace xAOD {
23  class TEvent;
24  class TStore;
25 } // namespace xAOD
26 
27 namespace asg {
28 
44  class SgTEvent {
45 
46  public:
48  SgTEvent( xAOD::TEvent* pevm = 0, xAOD::TStore* ptds = 0 );
49 
51  xAOD::TEvent* event() const;
52 
54  xAOD::TStore* tds() const;
55 
58 
60  template< typename T >
61  bool contains( const std::string& name ) const;
63  template< typename T >
64  bool transientContains( const std::string& name ) const;
65 
67  template< typename T >
68  T* retrieve( const std::string& name ) const;
69 
71  template< typename T >
72  StatusCode retrieve( T*& pobj, const std::string& name );
74  template< typename T >
75  StatusCode retrieve( const T*& pobj, const std::string& name ) const;
76 
78  template< typename T >
79  StatusCode record( std::unique_ptr<T> pobj, const std::string& cname );
80 
82  template< typename T >
83  StatusCode record( T* pobj, const std::string& cname );
84 
86  template< typename T >
87  StatusCode overwrite( T* pobj, const std::string& name,
88  bool allowMods, bool resetOnly = true,
89  bool noHist = false );
90 
95  template< typename T >
96  void keys( std::vector< std::string >& vkeys ) const;
97 
99 
100  private:
102  StatusCode initialize() const;
103 
108 
109  }; // class SgTEvent
110 
111 } // namespace asg
112 
113 // Include the template implementation:
114 #include "AsgTools/SgTEvent.icc"
115 
116 #endif // ASGTOOLS_SGTEVENT_H
asg::SgTEvent::initialize
StatusCode initialize() const
Function initialising the object.
Definition: SgTEvent.cxx:44
asg::SgTEvent::contains
bool contains(const std::string &name) const
Check if an object is available for constant access.
asg::SgTEvent::retrieve
StatusCode retrieve(T *&pobj, const std::string &name)
Retrieve a container from memory.
asg::SgTEvent::record
StatusCode record(std::unique_ptr< T > pobj, const std::string &cname)
Record an object/container using a smart pointer for ownership.
asg::SgTEvent::tds
xAOD::TStore * tds() const
Return the underlying transient data store.
Definition: SgTEvent.cxx:33
asg
Definition: DataHandleTestTool.h:28
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
asg::SgTEvent::transientContains
bool transientContains(const std::string &name) const
Check if an object is available for non-constant access.
asg::SgTEvent::retrieve
T * retrieve(const std::string &name) const
Function retrieving a constant or non-constant object.
asg::SgTEvent::overwrite
StatusCode overwrite(T *pobj, const std::string &name, bool allowMods, bool resetOnly=true, bool noHist=false)
Overwrite an object/container in the transient store.
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
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
StatusCode.h
asg::SgTEvent::SgTEvent
SgTEvent(xAOD::TEvent *pevm=0, xAOD::TStore *ptds=0)
Constructor specifying concrete TEvent and TStore objects.
Definition: SgTEvent.cxx:19
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
SgTEvent.icc
asg::SgTEvent
Wrapper for TEvent to make it look like StoreGate.
Definition: SgTEvent.h:44
xAOD::TStore
A relatively simple transient store for objects created in analysis.
Definition: TStore.h:44
asg::SgTEvent::record
StatusCode record(T *pobj, const std::string &cname)
Record an object/container.
asg::SgTEvent::event
xAOD::TEvent * event() const
Return the underlying event manager.
Definition: SgTEvent.cxx:24
asg::SgTEvent::retrieve
StatusCode retrieve(const T *&pobj, const std::string &name) const
Retrieve a container from the input file or the memory.
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:84
asg::SgTEvent::keys
void keys(std::vector< std::string > &vkeys) const
provide list of all keys associated with an object.