ATLAS Offline Software
Public Types | Public Member Functions | Private Attributes | List of all members
xAOD::TAuxBranchManager Class Reference

Manager for auxiliary branches created dynamically. More...

#include <TAuxBranchManager.h>

Inheritance diagram for xAOD::TAuxBranchManager:
Collaboration diagram for xAOD::TAuxBranchManager:

Public Types

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

Public Member Functions

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

Private Attributes

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

Detailed Description

Manager for auxiliary branches created dynamically.

This manager class is meant to deal with "simple" auxiliary branches in the xAOD files.

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 34 of file TAuxBranchManager.h.

Member Typedef Documentation

◆ auxid_t

Definition of the auxiliary ID type.

Definition at line 38 of file TAuxBranchManager.h.

Constructor & Destructor Documentation

◆ TAuxBranchManager() [1/2]

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

Constructor getting hold of a possible branch.

Definition at line 18 of file TAuxBranchManager.cxx.

20  : m_branch( br ), m_holder( holder ), m_entry( -1 ),
21  m_isSet( kTRUE ), m_auxId( auxid ), m_vector( nullptr ) {
22  }

◆ TAuxBranchManager() [2/2]

xAOD::TAuxBranchManager::TAuxBranchManager ( const TAuxBranchManager parent)

Copy constructor.

Definition at line 24 of file TAuxBranchManager.cxx.

25  : TVirtualManager(), m_branch( parent.m_branch ), m_holder( nullptr ),
26  m_entry( parent.m_entry ), m_isSet( parent.m_isSet ),
27  m_auxId( parent.m_auxId ), m_vector( nullptr ) {
28 
29  if( parent.m_holder ) {
30  m_holder = new THolder( *parent.m_holder );
31  }
32  if( parent.m_vector ) {
33  m_vector =
35  ( size_t ) 0,
36  ( size_t ) 0 ).release();
37  }
38  }

◆ ~TAuxBranchManager()

xAOD::TAuxBranchManager::~TAuxBranchManager ( )

Destructor.

Definition at line 40 of file TAuxBranchManager.cxx.

40  {
41 
42  if( m_holder ) {
43  delete m_holder;
44  }
45  if( m_vector ) {
46  delete m_vector;
47  }
48  }

Member Function Documentation

◆ branch()

TBranch * xAOD::TAuxBranchManager::branch ( )

Accessor to the branch.

Definition at line 82 of file TAuxBranchManager.cxx.

82  {
83 
84  return m_branch;
85  }

◆ branchPtr()

TBranch ** xAOD::TAuxBranchManager::branchPtr ( )

Pointer to the branch's pointer.

Definition at line 87 of file TAuxBranchManager.cxx.

87  {
88 
89  return &m_branch;
90  }

◆ create()

Bool_t xAOD::TAuxBranchManager::create ( )
overridevirtual

Create the object for the current event.

Implements xAOD::TVirtualManager.

Definition at line 168 of file TAuxBranchManager.cxx.

168  {
169 
170  // If we already have it set, let's stop here:
171  if( m_isSet ) return kTRUE;
172 
173  // Otherwise let's create a default object:
174  m_isSet = kTRUE;
175  if( ! m_vector ) {
176  m_vector =
178  ( size_t ) 0,
179  ( size_t ) 0 ).release();
180  }
181  // ...and use it to fill the current event:
182  m_holder->setOwner( kFALSE );
183  m_holder->set( m_vector->toVector() );
184 
185  // We are now "set":
186  return kTRUE;
187  }

◆ getEntry()

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

Function for updating the object in memory if needed.

Implements xAOD::TVirtualManager.

Definition at line 102 of file TAuxBranchManager.cxx.

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

◆ holder() [1/2]

THolder * xAOD::TAuxBranchManager::holder ( )

Accessor to the Holder object.

Definition at line 97 of file TAuxBranchManager.cxx.

97  {
98 
99  return m_holder;
100  }

◆ holder() [2/2]

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

Accessor to the Holder object (constant version)

Definition at line 92 of file TAuxBranchManager.cxx.

92  {
93 
94  return m_holder;
95  }

◆ isSet()

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

Check if the object was set for the current event.

Implements xAOD::TVirtualManager.

Definition at line 189 of file TAuxBranchManager.cxx.

189  {
190  return m_isSet;
191  }

◆ object() [1/2]

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

Function getting a const pointer to the object being handled.

Implements xAOD::TVirtualManager.

Definition at line 150 of file TAuxBranchManager.cxx.

150  {
151 
152  return std::as_const(*m_holder).get();
153  }

◆ object() [2/2]

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

Function getting a pointer to the object being handled.

Implements xAOD::TVirtualManager.

Definition at line 155 of file TAuxBranchManager.cxx.

155  {
156 
157  return m_holder->get();
158  }

◆ operator=()

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

Assignment operator.

Definition at line 51 of file TAuxBranchManager.cxx.

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

◆ reset()

void xAOD::TAuxBranchManager::reset ( )
overridevirtual

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

Implements xAOD::TVirtualManager.

Definition at line 193 of file TAuxBranchManager.cxx.

193  {
194 
195  m_isSet = kFALSE;
196  return;
197  }

◆ setObject()

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

Function replacing the object being handled.

Implements xAOD::TVirtualManager.

Definition at line 160 of file TAuxBranchManager.cxx.

160  {
161 
162  m_holder->setOwner( kFALSE );
163  m_holder->set( obj );
164  m_isSet = kTRUE;
165  return;
166  }

Member Data Documentation

◆ m_auxId

auxid_t xAOD::TAuxBranchManager::m_auxId
private

Auxiliary variable type.

Definition at line 88 of file TAuxBranchManager.h.

◆ m_branch

::TBranch* xAOD::TAuxBranchManager::m_branch
private

Pointer keeping track of the branch.

Definition at line 79 of file TAuxBranchManager.h.

◆ m_entry

::Long64_t xAOD::TAuxBranchManager::m_entry
private

The last entry that was loaded for this branch.

Definition at line 83 of file TAuxBranchManager.h.

◆ m_holder

THolder* xAOD::TAuxBranchManager::m_holder
private

Holder object for the EDM object.

Definition at line 81 of file TAuxBranchManager.h.

◆ m_isSet

::Bool_t xAOD::TAuxBranchManager::m_isSet
private

Was the object set for the current event?

Definition at line 85 of file TAuxBranchManager.h.

◆ m_vector

SG::IAuxTypeVector* xAOD::TAuxBranchManager::m_vector
private

Dummy auxiliary variable for the empty events.

Definition at line 90 of file TAuxBranchManager.h.


The documentation for this class was generated from the following files:
xAOD::TAuxBranchManager::m_isSet
::Bool_t m_isSet
Was the object set for the current event?
Definition: TAuxBranchManager.h:85
xAOD::TAuxBranchManager::m_holder
THolder * m_holder
Holder object for the EDM object.
Definition: TAuxBranchManager.h:81
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:639
xAOD::THolder::setOwner
void setOwner(::Bool_t state=kTRUE)
Set whether the holder should own its object.
Definition: THolder.cxx:257
xAOD::THolder::get
const void * get() const
Return a typeless const pointer to the held object.
Definition: THolder.cxx:215
XAOD_MESSAGE
#define XAOD_MESSAGE(MESSAGE)
Simple macro for printing error/verbose messages.
Definition: Control/xAODRootAccess/xAODRootAccess/tools/Message.h:19
xAOD::TAuxBranchManager::m_entry
::Long64_t m_entry
The last entry that was loaded for this branch.
Definition: TAuxBranchManager.h:83
xAOD::THolder::set
virtual void set(void *obj)
Replace the managed object.
Definition: THolder.cxx:230
test_pyathena.parent
parent
Definition: test_pyathena.py:15
SG::IAuxTypeVector::toVector
virtual void * toVector()=0
Return a pointer to the STL vector itself.
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
SG::AuxTypeRegistry::makeVector
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.
Definition: AuxTypeRegistry.cxx:817
xAOD::TAuxBranchManager::m_auxId
auxid_t m_auxId
Auxiliary variable type.
Definition: TAuxBranchManager.h:88
xAOD::TAuxBranchManager::m_vector
SG::IAuxTypeVector * m_vector
Dummy auxiliary variable for the empty events.
Definition: TAuxBranchManager.h:90
xAOD::TAuxBranchManager::m_branch
::TBranch * m_branch
Pointer keeping track of the branch.
Definition: TAuxBranchManager.h:79
L1Topo::Error
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition: Error.h:16
python.PyAthena.obj
obj
Definition: PyAthena.py:132
xAOD::TAuxBranchManager::holder
const THolder * holder() const
Accessor to the Holder object (constant version)
Definition: TAuxBranchManager.cxx:92
PlotCalibFromCool.br
br
Definition: PlotCalibFromCool.py:355