ATLAS Offline Software
Loading...
Searching...
No Matches
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.
virtual::Int_t GetEntry (::Long64_t entry, ::Int_t getall)
 Function getting the current entry for this branch.
virtual::TClass * IsA () const
 Function returning the type of ::TBranchObject.

Private Attributes

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

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 static constexpr bool SILENT = false;
53 static constexpr bool METADATA = false;
54 m_object = m_event->getInputObject( GetName(), *m_ti, SILENT, METADATA );
55 if( ! m_object ) {
56 Error( "GetEntry",
57 XAOD_MESSAGE( "Failed to read variable of type \"%s\" with "
58 "key \"%s\"" ),
59 GetClassName(), GetName() );
60 return -1;
61 }
62
63 // We were successful:
64 fReadEntry = entry;
65 return 1;
66}
#define XAOD_MESSAGE(MESSAGE)
Simple macro for printing error/verbose messages.
const std::type_info * m_ti
The type of the object that needs to be read.
const void * m_object
Pointer to the object read in using TEvent.
xAOD::TEvent * m_event
Pointer to the TEvent object reading the persistent tree.
@ SILENT
don't print anything and return success
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition Error.h:16

◆ 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 75 of file xAODTEventBranch.cxx.

75 {
76
77 return ::TBranchObject::IsA();
78}

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: