ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
xAODTEventBranch Class Reference

Specialised class for browsing xAOD event interface objects in ROOT. More...

#include <xAODTEventBranch.h>

Inheritance diagram for xAODTEventBranch:
Collaboration diagram for xAODTEventBranch:

Public Member Functions

 xAODTEventBranch (::TTree &parent, xAOD::TEvent &event, const std::type_info &ti, const char *brName, const char *brType)
 Constructor with all the needed parameters. More...
 
virtual ::Int_t GetEntry (::Long64_t entry, ::Int_t getall)
 Function getting the current entry for this branch. More...
 
virtual ::TClass * IsA () const
 Function returning the type of ::TBranchObject. More...
 

Private Attributes

xAOD::TEventm_event
 Pointer to the TEvent object reading the persistent tree. More...
 
const std::type_info * m_ti
 The type of the object that needs to be read. More...
 
const void * m_object
 Pointer to the object read in using TEvent. More...
 

Detailed Description

Specialised class for browsing xAOD event interface objects in ROOT.

In order to read xAOD interface objects/containers correctly, one needs to use the xAOD::TEvent class. Since the regular ROOT classes can't be taught how to use an external object for reading information, we need to do it using inheritance.

The design was pretty much stolen from the AthenaROOTAccess code. Luckily in this case the code can be a lot easier. Here we just need to ask the TEvent object for the correct pointer, and we're done.

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

Definition at line 32 of file xAODTEventBranch.h.

Constructor & Destructor Documentation

◆ xAODTEventBranch()

xAODTEventBranch::xAODTEventBranch ( ::TTree &  parent,
xAOD::TEvent event,
const std::type_info &  ti,
const char *  brName,
const char *  brType 
)

Constructor with all the needed parameters.

Member Function Documentation

◆ GetEntry()

Int_t xAODTEventBranch::GetEntry ( ::Long64_t  entry,
::Int_t  getall 
)

Function getting the current entry for this branch.

This is the function doing the heavy lifting.

It loads the interface object for the current entry requested. Only doing some minimal overhead in the meanwhile.

Parameters
entryThe entry to be read for this object
getallWhen set to 1, read all information about the branch (Not used.)
Returns
The number of bytes read, or a negative number if not successful

Definition at line 32 of file xAODTEventBranch.cxx.

32  {
33 
34  // Check if the branch is active:
35  if( TestBit( kDoNotProcess ) ) {
36  return 0;
37  }
38 
39  // Check whether we already have the requested entry:
40  if( fReadEntry == entry ) {
41  return 1;
42  }
43 
44  // Load the requested entry:
45  if( m_event->getEntry( entry ) < 0 ) {
46  Error( "GetEntry",
47  XAOD_MESSAGE( "Problems with loading entry %lld" ), entry );
48  return -1;
49  }
50 
51  // Update the internal pointer:
52  m_object = m_event->getInputObject( GetName(), *m_ti );
53  if( ! m_object ) {
54  Error( "GetEntry",
55  XAOD_MESSAGE( "Failed to read variable of type \"%s\" with "
56  "key \"%s\"" ),
57  GetClassName(), GetName() );
58  return -1;
59  }
60 
61  // We were successful:
62  fReadEntry = entry;
63  return 1;
64 }

◆ IsA()

TClass * xAODTEventBranch::IsA ( ) const

Function returning the type of ::TBranchObject.

I took this from the ARA code directly.

Apparenly TTree would not know how to handle this object if it reported its actual type. So we pretend that this is a TBranchObject object. That way TBrowser shows its contents nicely.

Returns
The class for TBranchObject

Definition at line 73 of file xAODTEventBranch.cxx.

73  {
74 
76 }

Member Data Documentation

◆ m_event

xAOD::TEvent* xAODTEventBranch::m_event
private

Pointer to the TEvent object reading the persistent tree.

Definition at line 52 of file xAODTEventBranch.h.

◆ m_object

const void* xAODTEventBranch::m_object
private

Pointer to the object read in using TEvent.

Definition at line 56 of file xAODTEventBranch.h.

◆ m_ti

const std::type_info* xAODTEventBranch::m_ti
private

The type of the object that needs to be read.

Definition at line 54 of file xAODTEventBranch.h.


The documentation for this class was generated from the following files:
IsA
#define IsA
Declare the TObject style functions.
Definition: xAODTEventBranch.h:59
xAOD::TEvent::getInputObject
const void * getInputObject(SG::sgkey_t key, const std::type_info &ti, bool silent=false) override
Function for retrieving an input object in a non-template way.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:1939
xAODTEventBranch::m_event
xAOD::TEvent * m_event
Pointer to the TEvent object reading the persistent tree.
Definition: xAODTEventBranch.h:52
XAOD_MESSAGE
#define XAOD_MESSAGE(MESSAGE)
Simple macro for printing error/verbose messages.
Definition: Control/xAODRootAccess/xAODRootAccess/tools/Message.h:19
xAODTEventBranch::m_object
const void * m_object
Pointer to the object read in using TEvent.
Definition: xAODTEventBranch.h:56
xAODTEventBranch::m_ti
const std::type_info * m_ti
The type of the object that needs to be read.
Definition: xAODTEventBranch.h:54
xAOD::TEvent::getEntry
::Int_t getEntry(::Long64_t entry, ::Int_t getall=0)
Function loading a given entry of the input TTree.
Definition: Control/xAODRootAccess/Root/TEvent.cxx:1325
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
L1Topo::Error
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition: Error.h:16