ATLAS Offline Software
Loading...
Searching...
No Matches
xAOD::TPrimitiveAuxBranchManager Class Reference

Manager for primitive auxiliary branches created dynamically. More...

#include <TPrimitiveAuxBranchManager.h>

Inheritance diagram for xAOD::TPrimitiveAuxBranchManager:
Collaboration diagram for xAOD::TPrimitiveAuxBranchManager:

Public Types

typedef SG::auxid_t auxid_t
 Definition of the auxiliary ID type.

Public Member Functions

 TPrimitiveAuxBranchManager (auxid_t auxid, ::TBranch *br=0, THolder *holder=0)
 Constructor getting hold of a possible branch.
 TPrimitiveAuxBranchManager (const TPrimitiveAuxBranchManager &parent)
 Copy constructor.
 ~TPrimitiveAuxBranchManager ()
 Destructor.
TPrimitiveAuxBranchManageroperator= (const TPrimitiveAuxBranchManager &rhs)
 Assignment operator.
::TBranch * branch ()
 Accessor to the branch.
::TBranch ** branchPtr ()
 Pointer to the branch's pointer.
const THolderholder () const
 Accessor to the Holder object (constant version)
THolderholder ()
 Accessor to the Holder object.
virtual::Int_t getEntry (::Int_t getall=0) override
 Function for updating the object in memory if needed.
virtual const void * object () const override
 Function getting a const pointer to the object being handled.
virtual void * object () override
 Function getting a pointer to the object being handled.
virtual void setObject (void *obj) override
 Function replacing the object being handled.
virtual::Bool_t create () override
 Create the object for the current event.
virtual::Bool_t isSet () const override
 Check if the object was set for the current event.
virtual void reset () override
 Reset the object at the end of processing of an event.

Private Attributes

::TBranch * m_branch
 Pointer keeping track of the branch.
THolderm_holder
 Holder object for the EDM object.
::Long64_t m_entry
 The last entry that was loaded for this branch.
::Bool_t m_isSet
 Was the variable set for the current event?
auxid_t m_auxId
 Auxiliary variable type.
SG::IAuxTypeVectorm_vector
 Dummy auxiliary variable for the empty events.

Detailed Description

Manager for primitive auxiliary branches created dynamically.

One has to treat std::vector<T> and primitive auxiliary branches differently, because TTree handles these things very differently. This class manages auxiliary branches created from primitive variables.

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 35 of file TPrimitiveAuxBranchManager.h.

Member Typedef Documentation

◆ auxid_t

Definition of the auxiliary ID type.

Definition at line 39 of file TPrimitiveAuxBranchManager.h.

Constructor & Destructor Documentation

◆ TPrimitiveAuxBranchManager() [1/2]

xAOD::TPrimitiveAuxBranchManager::TPrimitiveAuxBranchManager ( auxid_t auxid,
::TBranch * br = 0,
THolder * holder = 0 )

Constructor getting hold of a possible branch.

Definition at line 21 of file TPrimitiveAuxBranchManager.cxx.

24 : m_branch( br ), m_holder( holder ), m_entry( -1 ),
25 m_isSet( kTRUE ), m_auxId( auxid ), m_vector( 0 ) {
26 }
SG::IAuxTypeVector * m_vector
Dummy auxiliary variable for the empty events.
::Long64_t m_entry
The last entry that was loaded for this branch.
const THolder * holder() const
Accessor to the Holder object (constant version)
::Bool_t m_isSet
Was the variable set for the current event?
::TBranch * m_branch
Pointer keeping track of the branch.
THolder * m_holder
Holder object for the EDM object.
auxid_t m_auxId
Auxiliary variable type.

◆ TPrimitiveAuxBranchManager() [2/2]

xAOD::TPrimitiveAuxBranchManager::TPrimitiveAuxBranchManager ( const TPrimitiveAuxBranchManager & parent)

Copy constructor.

Definition at line 28 of file TPrimitiveAuxBranchManager.cxx.

30 : TVirtualManager(), m_branch( parent.m_branch ), m_holder( 0 ),
31 m_entry( parent.m_entry ), m_isSet( parent.m_isSet ),
32 m_auxId( parent.m_auxId ), m_vector( 0 ) {
33
34 if( parent.m_holder ) {
35 m_holder = new THolder( *parent.m_holder );
36 }
37 if( parent.m_vector ) {
38 m_vector = SG::AuxTypeRegistry::instance().makeVector( m_auxId, (size_t)0, (size_t)0 ).release();
39 m_vector->resize( 1 );
40 }
41 }
static AuxTypeRegistry & instance()
Return the singleton registry instance.
std::unique_ptr< IAuxTypeVector > makeVector(SG::auxid_t auxid, size_t size, size_t capacity) const
Construct a new vector to hold an aux item.

◆ ~TPrimitiveAuxBranchManager()

xAOD::TPrimitiveAuxBranchManager::~TPrimitiveAuxBranchManager ( )

Destructor.

Definition at line 43 of file TPrimitiveAuxBranchManager.cxx.

43 {
44
45 if( m_holder ) {
46 delete m_holder;
47 }
48 if( m_vector ) {
49 delete m_vector;
50 }
51 }

Member Function Documentation

◆ branch()

TBranch * xAOD::TPrimitiveAuxBranchManager::branch ( )

Accessor to the branch.

Definition at line 84 of file TPrimitiveAuxBranchManager.cxx.

84 {
85
86 return m_branch;
87 }

◆ branchPtr()

TBranch ** xAOD::TPrimitiveAuxBranchManager::branchPtr ( )

Pointer to the branch's pointer.

Definition at line 89 of file TPrimitiveAuxBranchManager.cxx.

89 {
90
91 return &m_branch;
92 }

◆ create()

Bool_t xAOD::TPrimitiveAuxBranchManager::create ( )
overridevirtual

Create the object for the current event.

Implements xAOD::TVirtualManager.

Definition at line 177 of file TPrimitiveAuxBranchManager.cxx.

177 {
178
179 // If we already have it set, let's stop here:
180 if( m_isSet ) return kTRUE;
181
182 // Otherwise let's create a default object:
183 m_isSet = kTRUE;
184 if( ! m_vector ) {
185 m_vector = SG::AuxTypeRegistry::instance().makeVector( m_auxId, (size_t)0, (size_t)0 ).release();
186 m_vector->resize( 1 );
187 }
188 // ...and use it to fill the current event:
189 m_holder->setOwner( kFALSE );
190 m_holder->set( m_vector->toPtr() );
191
192 // And update the branch to use this address:
193 m_branch->SetAddress( m_holder->get() );
194
195 // We are now "set":
196 return kTRUE;
197 }

◆ getEntry()

Int_t xAOD::TPrimitiveAuxBranchManager::getEntry ( ::Int_t getall = 0)
overridevirtual

Function for updating the object in memory if needed.

Implements xAOD::TVirtualManager.

Definition at line 104 of file TPrimitiveAuxBranchManager.cxx.

104 {
105
106 // Make sure that the branch is associated to a tree
107 // as the entry to be read is retrieved from the tree
108 if (!m_branch->GetTree()){
109 Error("xAOD::TPrimitiveAuxBranchManager::getEntry",
110 XAOD_MESSAGE("Branch=%s is not associated to any tree while reading of branches within this class relies on that"),
111 m_branch->GetName());
112 return -1;
113 }
114
115 // Get the entry that should be read
116 // The entry to be read is set with TTree::LoadTree()
117 // NB: for a branch from a friend tree and if the friend tree has an index built,
118 // then the entry to read is found when calling the TTree::LoadTree() function
119 // that matches the major and minor values between the main tree and the friend tree
120 ::Long64_t entry = m_branch->GetTree()->GetReadEntry();
121
122 if ( entry < 0 ){
123 // Raise error as it implies
124 // either that the TTree::LoadTree() function has not been called
125 // or
126 // the entry requested to be read by the user
127 // is not corresponding to any entry for the friend tree
128 Error("xAOD::TPrimitiveAuxBranchManager::getEntry",
129 XAOD_MESSAGE( "Entry to read is not set for branch=%s from tree=%s. "
130 "It is either because TTree::LoadTree(entry) was not called "
131 "beforehand in the TEvent class OR "
132 "the entry requested to be read for the main tree is not corresponding to an event for the friend tree" ),
133 m_branch->GetName(),
134 m_branch->GetTree()->GetName());
135 return -1;
136 }
137
138 // Check if anything needs to be done:
139 if( entry == m_entry ) return 0;
140
141 // Load the entry.
142 const ::Int_t nbytes = m_branch->GetEntry( entry, getall );
143
144 // If the load was successful, remember that we loaded this entry.
145 if( nbytes >= 0 ) {
146 m_entry = entry;
147 }
148
149 return nbytes;
150 }
#define XAOD_MESSAGE(MESSAGE)
Simple macro for printing error/verbose messages.
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition Error.h:16

◆ holder() [1/2]

THolder * xAOD::TPrimitiveAuxBranchManager::holder ( )

Accessor to the Holder object.

Definition at line 99 of file TPrimitiveAuxBranchManager.cxx.

99 {
100
101 return m_holder;
102 }

◆ holder() [2/2]

const THolder * xAOD::TPrimitiveAuxBranchManager::holder ( ) const

Accessor to the Holder object (constant version)

Definition at line 94 of file TPrimitiveAuxBranchManager.cxx.

94 {
95
96 return m_holder;
97 }

◆ isSet()

Bool_t xAOD::TPrimitiveAuxBranchManager::isSet ( ) const
overridevirtual

Check if the object was set for the current event.

Implements xAOD::TVirtualManager.

Definition at line 199 of file TPrimitiveAuxBranchManager.cxx.

199 {
200
201 return m_isSet;
202 }

◆ object() [1/2]

const void * xAOD::TPrimitiveAuxBranchManager::object ( ) const
overridevirtual

Function getting a const pointer to the object being handled.

Implements xAOD::TVirtualManager.

Definition at line 152 of file TPrimitiveAuxBranchManager.cxx.

152 {
153
154 return std::as_const(*m_holder).get();
155 }

◆ object() [2/2]

void * xAOD::TPrimitiveAuxBranchManager::object ( )
overridevirtual

Function getting a pointer to the object being handled.

Implements xAOD::TVirtualManager.

Definition at line 157 of file TPrimitiveAuxBranchManager.cxx.

157 {
158
159 return m_holder->get();
160 }

◆ operator=()

TPrimitiveAuxBranchManager & xAOD::TPrimitiveAuxBranchManager::operator= ( const TPrimitiveAuxBranchManager & rhs)

Assignment operator.

Definition at line 54 of file TPrimitiveAuxBranchManager.cxx.

55 {
56
57 // Check if anything needs to be done:
58 if( this == &rhs ) {
59 return *this;
60 }
61
62 m_branch = rhs.m_branch;
63 if( m_holder ) delete m_holder;
64 if( rhs.m_holder ) {
65 m_holder = new THolder( *rhs.m_holder );
66 } else {
67 m_holder = 0;
68 }
69 m_entry = rhs.m_entry;
70 m_isSet = rhs.m_isSet;
71 m_auxId = rhs.m_auxId;
72 if( m_vector ) delete m_vector;
73 if( rhs.m_vector ) {
74 m_vector = SG::AuxTypeRegistry::instance().makeVector( m_auxId, (size_t)0, (size_t)0 ).release();
75 m_vector->resize( 1 );
76 } else {
77 m_vector = 0;
78 }
79
80 // Return this same object:
81 return *this;
82 }

◆ reset()

void xAOD::TPrimitiveAuxBranchManager::reset ( )
overridevirtual

Reset the object at the end of processing of an event.

Implements xAOD::TVirtualManager.

Definition at line 204 of file TPrimitiveAuxBranchManager.cxx.

204 {
205
206 m_isSet = kFALSE;
207 return;
208 }

◆ setObject()

void xAOD::TPrimitiveAuxBranchManager::setObject ( void * obj)
overridevirtual

Function replacing the object being handled.

Implements xAOD::TVirtualManager.

Definition at line 162 of file TPrimitiveAuxBranchManager.cxx.

162 {
163
164 // Make the holder forget about the previous variable, and get hold
165 // of this new one:
166 m_holder->setOwner( kFALSE );
167 m_holder->set( obj );
168
169 // Update the address of the branch:
170 m_branch->SetAddress( m_holder->get() );
171
172 // We are now "set":
173 m_isSet = kTRUE;
174 return;
175 }

Member Data Documentation

◆ m_auxId

auxid_t xAOD::TPrimitiveAuxBranchManager::m_auxId
private

Auxiliary variable type.

Definition at line 91 of file TPrimitiveAuxBranchManager.h.

◆ m_branch

::TBranch* xAOD::TPrimitiveAuxBranchManager::m_branch
private

Pointer keeping track of the branch.

Definition at line 82 of file TPrimitiveAuxBranchManager.h.

◆ m_entry

::Long64_t xAOD::TPrimitiveAuxBranchManager::m_entry
private

The last entry that was loaded for this branch.

Definition at line 86 of file TPrimitiveAuxBranchManager.h.

◆ m_holder

THolder* xAOD::TPrimitiveAuxBranchManager::m_holder
private

Holder object for the EDM object.

Definition at line 84 of file TPrimitiveAuxBranchManager.h.

◆ m_isSet

::Bool_t xAOD::TPrimitiveAuxBranchManager::m_isSet
private

Was the variable set for the current event?

Definition at line 88 of file TPrimitiveAuxBranchManager.h.

◆ m_vector

SG::IAuxTypeVector* xAOD::TPrimitiveAuxBranchManager::m_vector
private

Dummy auxiliary variable for the empty events.

Definition at line 93 of file TPrimitiveAuxBranchManager.h.


The documentation for this class was generated from the following files: