ATLAS Offline Software
SgTEvent.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // System include(s):
6 #include <iostream>
7 
8 // Local include(s):
9 #include "AsgTools/SgTEvent.h"
10 
11 // RootCore include(s):
12 #ifdef XAOD_STANDALONE
15 #endif // XAOD_STANDALONE
16 
17 namespace asg {
18 
20  : m_pevm( pevm ), m_ptds( ptds ) {
21 
22  }
23 
25 
26  if( ! m_pevm ) {
27  initialize().ignore();
28  }
29 
30  return m_pevm;
31  }
32 
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  }
43 
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  }
82 
83 } // namespace asg
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
asg::SgTEvent::tds
xAOD::TStore * tds() const
Return the underlying transient data store.
Definition: SgTEvent.cxx:33
asg
Definition: DataHandleTestTool.h:28
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
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
TActiveEvent.h
asg::SgTEvent::SgTEvent
SgTEvent(xAOD::TEvent *pevm=0, xAOD::TStore *ptds=0)
Constructor specifying concrete TEvent and TStore objects.
Definition: SgTEvent.cxx:19
xAOD::TStore
A relatively simple transient store for objects created in analysis.
Definition: TStore.h:44
asg::SgTEvent::event
xAOD::TEvent * event() const
Return the underlying event manager.
Definition: SgTEvent.cxx:24
TActiveStore.h
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:84
SgTEvent.h