ATLAS Offline Software
Public Types | Public Member Functions | Private Attributes | List of all members
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. More...
 

Public Member Functions

 TPrimitiveAuxBranchManager (auxid_t auxid, ::TBranch *br=0, THolder *holder=0)
 Constructor getting hold of a possible branch. More...
 
 TPrimitiveAuxBranchManager (const TPrimitiveAuxBranchManager &parent)
 Copy constructor. More...
 
 ~TPrimitiveAuxBranchManager ()
 Destructor. More...
 
TPrimitiveAuxBranchManageroperator= (const TPrimitiveAuxBranchManager &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 variable 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 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  }

◆ 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  }

◆ ~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  }

◆ 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:
xAOD::TPrimitiveAuxBranchManager::m_branch
::TBranch * m_branch
Pointer keeping track of the branch.
Definition: TPrimitiveAuxBranchManager.h:82
xAOD::TPrimitiveAuxBranchManager::m_vector
SG::IAuxTypeVector * m_vector
Dummy auxiliary variable for the empty events.
Definition: TPrimitiveAuxBranchManager.h:93
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:640
xAOD::THolder::setOwner
void setOwner(::Bool_t state=kTRUE)
Set whether the holder should own its object.
Definition: THolder.cxx:257
xAOD::TPrimitiveAuxBranchManager::m_auxId
auxid_t m_auxId
Auxiliary variable type.
Definition: TPrimitiveAuxBranchManager.h:91
xAOD::THolder::get
const void * get() const
Return a typeless const pointer to the held object.
Definition: THolder.cxx:215
xAOD::TPrimitiveAuxBranchManager::m_holder
THolder * m_holder
Holder object for the EDM object.
Definition: TPrimitiveAuxBranchManager.h:84
XAOD_MESSAGE
#define XAOD_MESSAGE(MESSAGE)
Simple macro for printing error/verbose messages.
Definition: Control/xAODRootAccess/xAODRootAccess/tools/Message.h:19
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
xAOD::TPrimitiveAuxBranchManager::m_isSet
::Bool_t m_isSet
Was the variable set for the current event?
Definition: TPrimitiveAuxBranchManager.h:88
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:818
SG::IAuxTypeVector::resize
virtual bool resize(size_t sz)=0
Change the size of the vector.
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::TPrimitiveAuxBranchManager::m_entry
::Long64_t m_entry
The last entry that was loaded for this branch.
Definition: TPrimitiveAuxBranchManager.h:86
SG::IAuxTypeVector::toPtr
virtual void * toPtr()=0
Return a pointer to the start of the vector's data.
xAOD::TPrimitiveAuxBranchManager::holder
const THolder * holder() const
Accessor to the Holder object (constant version)
Definition: TPrimitiveAuxBranchManager.cxx:94
PlotCalibFromCool.br
br
Definition: PlotCalibFromCool.py:355