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

Auxiliary vector type for types known to ROOT. More...

#include <TAuxVector.h>

Inheritance diagram for xAOD::TAuxVector:
Collaboration diagram for xAOD::TAuxVector:

Public Member Functions

 TAuxVector (const TAuxVectorFactory *factory, SG::auxid_t auxid, const ::TClass *cl, size_t size, size_t capacity)
 Constructor. More...
 
 TAuxVector (const TAuxVector &parent)
 Copy constructor. More...
 
 ~TAuxVector ()
 Destructor. More...
 
TAuxVectoroperator= (const TAuxVector &other)
 Assignment operator. More...
 
virtual bool setOption (const AuxDataOption &)
 Set an option for this variable. More...
 
virtual std::unique_ptr< IAuxTypeVector > toPacked ()
 Make a packed version of the variable. More...
 
virtual const std::type_info * objType () const
 Return the type of the complete object to be saved. More...
 
Function implementing the SG::IAuxTypeVector interface
virtual std::unique_ptr< SG::IAuxTypeVectorclone () const override
 Copy the managed vector. More...
 
virtual SG::auxid_t auxid () const override
 Return the auxid of the variable this vector represents. More...
 
virtual void * toPtr () override
 Return a pointer to the start of the vector's data. More...
 
virtual const void * toPtr () const override
 Return a pointer to the start of the vector's data. More...
 
virtual void * toVector () override
 Return a pointer to the STL vector itself. More...
 
virtual size_t size () const override
 Return the size of the vector. More...
 
virtual bool resize (size_t sz) override
 Change the size of the vector. More...
 
virtual void reserve (size_t sz) override
 Change the capacity of the vector. More...
 
virtual bool shift (size_t pos, ptrdiff_t offs) override
 Shift the elements of the vector. More...
 
virtual bool insertMove (size_t pos, void *beg, void *end, SG::IAuxStore &srcStore) override
 Insert a range of elements via move. More...
 

Private Member Functions

void copyRange (const void *src, void *dst, size_t n)
 Function copying the payload of a range to a new location. More...
 
void clearRange (void *dst, size_t n)
 

Private Attributes

const TAuxVectorFactorym_factory
 The parent factory object. More...
 
std::unique_ptr<::TVirtualCollectionProxy > m_proxy
 ROOT's description of the vector type Cloned from the proxy held by the TClass and permanently bound to m_vec. More...
 
void * m_vec
 Pointer to the vector object. More...
 
SG::auxid_t m_auxid
 ID of the variable we represent. More...
 

Detailed Description

Auxiliary vector type for types known to ROOT.

This class is used for types known to ROOT, which have not received a concrete auxiliary vector type yet. (By having been accessed explicitly.)

The code is pretty much a copy of what Scott wrote for RootStorageSvc for the offline code.

Author
Scott Snyder Scott.nosp@m..Sny.nosp@m.der@c.nosp@m.ern..nosp@m.ch
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 30 of file TAuxVector.h.

Constructor & Destructor Documentation

◆ TAuxVector() [1/2]

xAOD::TAuxVector::TAuxVector ( const TAuxVectorFactory factory,
SG::auxid_t  auxid,
const ::TClass *  cl,
size_t  size,
size_t  capacity 
)

Constructor.

Definition at line 20 of file TAuxVector.cxx.

23  : m_factory( factory ),
24  m_proxy( cl->GetCollectionProxy()->Generate() ), m_vec( cl->New() ),
25  m_auxid( auxid ) {
26 
27  // A little sanity check:
28  if( ! m_proxy ) {
29  ::Fatal( "xAOD::TAuxVector::TAuxVector",
30  XAOD_MESSAGE( "No collection proxy found for type %s" ),
31  cl->GetName() );
32  }
33  else {
34  m_proxy->PushProxy( m_vec );
35  }
36 
37  // Make sure the object is of the right size:
38  this->resize( size );
39  }

◆ TAuxVector() [2/2]

xAOD::TAuxVector::TAuxVector ( const TAuxVector parent)

Copy constructor.

Definition at line 41 of file TAuxVector.cxx.

42  : m_factory( parent.m_factory ), m_proxy( parent.m_proxy->Generate() ),
43  m_vec( parent.m_proxy->GetCollectionClass()->New() ),
44  m_auxid( parent.m_auxid ) {
45 
46  m_proxy->PushProxy( m_vec );
47 
48  // Check the size of the parent object:
49  const size_t size = parent.size();
50  // Check if we need to do anything:
51  if( ! size ) {
52  return;
53  }
54 
55  // First off, resize this vector:
56  this->resize( size );
57 
58  // Get a pointer to the start of the parent's payload:
59  const void* parentPtr = parent.toPtr();
60 
61  // Do the copy:
62  this->copyRange( parentPtr, this->toPtr(), size );
63  }

◆ ~TAuxVector()

xAOD::TAuxVector::~TAuxVector ( )

Destructor.

Definition at line 65 of file TAuxVector.cxx.

65  {
66 
67  m_proxy->Destructor( m_vec );
68  }

Member Function Documentation

◆ auxid()

SG::auxid_t xAOD::TAuxVector::auxid ( ) const
overridevirtual

Return the auxid of the variable this vector represents.

Implements SG::IAuxTypeVector.

Definition at line 112 of file TAuxVector.cxx.

113  {
114  return m_auxid;
115  }

◆ clearRange()

void xAOD::TAuxVector::clearRange ( void *  dst,
size_t  n 
)
private

Definition at line 238 of file TAuxVector.cxx.

238  {
239 
240  // Size of an element in the vector:
241  size_t eltsz = m_proxy->GetIncrement();
242 
243  // If the payload is a class:
244  if( m_proxy->GetValueClass() ) {
245  m_factory->clear (dst, 0, n);
246  }
247  // If the payload is an array of primitives, the cleaning is much simpler:
248  else {
249  memset( dst, 0, n * eltsz );
250  }
251 
252  return;
253  }

◆ clone()

std::unique_ptr< SG::IAuxTypeVector > xAOD::TAuxVector::clone ( ) const
overridevirtual

Copy the managed vector.

Implements SG::IAuxTypeVector.

Definition at line 106 of file TAuxVector.cxx.

106  {
107 
108  return std::make_unique< TAuxVector >( *this );
109  }

◆ copyRange()

void xAOD::TAuxVector::copyRange ( const void *  src,
void *  dst,
size_t  n 
)
private

Function copying the payload of a range to a new location.

Definition at line 227 of file TAuxVector.cxx.

227  {
228 
229  SG::AuxVectorInterface idst( m_auxid, n, dst );
231  idst, 0,
233  n );
234 
235  return;
236  }

◆ insertMove()

bool xAOD::TAuxVector::insertMove ( size_t  pos,
void *  beg,
void *  end,
SG::IAuxStore srcStore 
)
overridevirtual

Insert a range of elements via move.

Implements SG::IAuxTypeVector.

Definition at line 206 of file TAuxVector.cxx.

208  {
209  size_t eltsz = m_proxy->GetIncrement();
210  const void* orig = this->toPtr();
211 
212  char* begp = reinterpret_cast<char*> (beg);
213  char* endp = reinterpret_cast<char*> (end);
214  size_t nelt = (endp-begp) / eltsz;
215 
216  shift (pos, nelt);
217  // FIXME: want move, not copy.
218  // But i don't seem to be able to call move operations through cling,
219  // so just use copy for now.
220  copyRange (beg,
221  reinterpret_cast<char*>(this->toPtr()) + pos*eltsz,
222  nelt);
223  return this->toPtr() == orig;
224  }

◆ objType()

virtual const std::type_info* SG::IAuxTypeVector::objType ( ) const
inlinevirtualinherited

Return the type of the complete object to be saved.

For example, if the object is a std::vector, then we return the type_info of the vector. But if we're holding a PackedContainer, then we return the type_info of the PackedContainer.

Can return null if the operation is not supported. In that case, I/O will use the type found from the variable registry.

Reimplemented in SG::RootAuxVector, SG::AuxTypeVectorHolder< T, CONT >, and xAOD::AuxPersInfo< T >.

Definition at line 192 of file IAuxTypeVector.h.

192 { return 0; }

◆ operator=()

TAuxVector & xAOD::TAuxVector::operator= ( const TAuxVector other)

Assignment operator.

Definition at line 70 of file TAuxVector.cxx.

70  {
71 
72  // Check if anything needs to be done:
73  if( this == &other ) {
74  return *this;
75  }
76 
77  // Clean out the previous payload:
78  m_proxy->Destructor( m_vec );
79 
80  // Get the information from the other object:
81  m_factory = other.m_factory;
82  m_proxy.reset( other.m_proxy->Generate() );
83  m_auxid = other.m_auxid;
84 
85  // Create a new vector:
86  m_vec = m_proxy->GetCollectionClass()->New();
87  m_proxy->PushProxy( m_vec );
88 
89  // Check the size of the other object:
90  const size_t size = other.size();
91  // Check if we need to do anything:
92  if( ! size ) {
93  return *this;
94  }
95 
96  // Get a pointer to the start of the other object's payload:
97  const void* otherPtr = other.toPtr();
98 
99  // Do the copy:
100  this->copyRange( otherPtr, this->toPtr(), size );
101 
102  // Return a reference to this object:
103  return *this;
104  }

◆ reserve()

void xAOD::TAuxVector::reserve ( size_t  sz)
overridevirtual

Change the capacity of the vector.

Implements SG::IAuxTypeVector.

Definition at line 145 of file TAuxVector.cxx.

145  {
146 
147  return;
148  }

◆ resize()

bool xAOD::TAuxVector::resize ( size_t  sz)
overridevirtual

Change the size of the vector.

Implements SG::IAuxTypeVector.

Definition at line 138 of file TAuxVector.cxx.

138  {
139 
140  const void* orig = toPtr();
141  m_proxy->Allocate( sz, false );
142  return toPtr() == orig;
143  }

◆ setOption()

virtual bool SG::IAuxTypeVector::setOption ( const AuxDataOption )
inlinevirtualinherited

Set an option for this variable.

Parameters
optionThe option to set.

The interpretation of the option depends on the particular representation of the variable provided by the concrete class.

Returns true if the option setting was successful; false otherwise.

Reimplemented in SG::AuxTypeVectorHolder< T, CONT >, and SG::AuxTypeVectorHolder< T, std::vector< T > >.

Definition at line 162 of file IAuxTypeVector.h.

163  { return false; }

◆ shift()

bool xAOD::TAuxVector::shift ( size_t  pos,
ptrdiff_t  offs 
)
overridevirtual

Shift the elements of the vector.

Parameters
posThe starting index for the shift.
offsThe (signed) amount of the shift.

This operation shifts the elements in the vectors for all aux data items, to implement an insertion or deletion. offs may be either positive or negative.

If offs is positive, then the container is growing. The container size should be increased by offs, the element at pos moved to pos + offs, and similarly for following elements. The elements between pos and pos + offs should be default-initialized.

If offs is negative, then the container is shrinking. The element at pos should be moved to pos + offs, and similarly for following elements. The container should then be shrunk by -offs elements (running destructors as appropriate).

Returns true if it is known that iterators have not been invalidated; false otherwise. (Will always return false when increasing the size of an empty container.)

Implements SG::IAuxTypeVector.

Definition at line 176 of file TAuxVector.cxx.

176  {
177 
178  size_t eltsz = m_proxy->GetIncrement();
179  if( offs < 0 ) {
180 
181  if( -offs > static_cast< ptrdiff_t >( pos ) ) {
182  offs = -pos;
183  }
184  char* beg = reinterpret_cast< char* >( m_proxy->At( 0 ) );
185  copyRange( beg + eltsz * pos,
186  beg + eltsz * ( pos + offs ),
187  m_proxy->Size() - pos );
188  m_proxy->Allocate( m_proxy->Size() + offs, false );
189  return true;
190 
191  } else if( offs > 0 ) {
192 
193  size_t oldsz = m_proxy->Size();
194  m_proxy->Allocate( oldsz + offs, false );
195  char* beg = reinterpret_cast< char* >( m_proxy->At( 0 ) );
196  copyRange( beg + eltsz * pos,
197  beg + eltsz * ( pos + offs ),
198  m_proxy->Size() - pos - offs);
199  clearRange( beg + eltsz * pos, offs );
200  return false;
201  }
202 
203  return true;
204  }

◆ size()

size_t xAOD::TAuxVector::size ( ) const
overridevirtual

Return the size of the vector.

Implements SG::IAuxTypeVector.

Definition at line 133 of file TAuxVector.cxx.

133  {
134 
135  return m_proxy->Size();
136  }

◆ toPacked()

virtual std::unique_ptr<IAuxTypeVector> SG::IAuxTypeVector::toPacked ( )
inlinevirtualinherited

Make a packed version of the variable.

If possible, return a new vector object that stores the data in a PackedContainer. The data itself should be moved to the new container (so that this vector becomes empty). This ensures that pointers to the data are preserved.

If successful, a newly-allocated object is returned. A null pointer is returned on failure (operation not supported, type can't be packed, type is already packed).

Reimplemented in SG::AuxTypeVectorHolder< T, CONT >, and SG::AuxTypeVectorHolder< T, std::vector< T > >.

Definition at line 178 of file IAuxTypeVector.h.

178 { return 0; }

◆ toPtr() [1/2]

const void * xAOD::TAuxVector::toPtr ( ) const
overridevirtual

Return a pointer to the start of the vector's data.

Implements SG::IAuxTypeVector.

Definition at line 123 of file TAuxVector.cxx.

123  {
124 
125  return m_proxy->At( 0 );
126  }

◆ toPtr() [2/2]

void * xAOD::TAuxVector::toPtr ( )
overridevirtual

Return a pointer to the start of the vector's data.

Implements SG::IAuxTypeVector.

Definition at line 118 of file TAuxVector.cxx.

118  {
119 
120  return m_proxy->At( 0 );
121  }

◆ toVector()

void * xAOD::TAuxVector::toVector ( )
overridevirtual

Return a pointer to the STL vector itself.

Implements SG::IAuxTypeVector.

Definition at line 128 of file TAuxVector.cxx.

128  {
129 
130  return m_vec;
131  }

Member Data Documentation

◆ m_auxid

SG::auxid_t xAOD::TAuxVector::m_auxid
private

ID of the variable we represent.

Definition at line 90 of file TAuxVector.h.

◆ m_factory

const TAuxVectorFactory* xAOD::TAuxVector::m_factory
private

The parent factory object.

Definition at line 81 of file TAuxVector.h.

◆ m_proxy

std::unique_ptr<::TVirtualCollectionProxy> xAOD::TAuxVector::m_proxy
private

ROOT's description of the vector type Cloned from the proxy held by the TClass and permanently bound to m_vec.

That makes things a bit more efficient, and prevents potential thread-safety problems.

Definition at line 86 of file TAuxVector.h.

◆ m_vec

void* xAOD::TAuxVector::m_vec
private

Pointer to the vector object.

Definition at line 88 of file TAuxVector.h.


The documentation for this class was generated from the following files:
xAOD::TAuxVectorFactory::copy
virtual void copy(SG::auxid_t auxid, SG::AuxVectorData &dst, size_t dst_index, const SG::AuxVectorData &src, size_t src_index, size_t n) const override
Copy elements from one location to another.
Definition: TAuxVectorFactory.cxx:76
beamspotPlotBcids.sz
sz
Definition: beamspotPlotBcids.py:521
xAOD::TAuxVector::m_auxid
SG::auxid_t m_auxid
ID of the variable we represent.
Definition: TAuxVector.h:90
WriteCellNoiseToCool.src
src
Definition: WriteCellNoiseToCool.py:513
xAOD::TAuxVector::m_proxy
std::unique_ptr<::TVirtualCollectionProxy > m_proxy
ROOT's description of the vector type Cloned from the proxy held by the TClass and permanently bound ...
Definition: TAuxVector.h:86
xAOD::other
@ other
Definition: TrackingPrimitives.h:509
xAOD::TAuxVectorFactory::clear
void clear(void *dst, size_t dst_index, size_t n) const
Clear the payload of a given range inside a vector.
Definition: TAuxVectorFactory.cxx:195
XAOD_MESSAGE
#define XAOD_MESSAGE(MESSAGE)
Simple macro for printing error/verbose messages.
Definition: Control/xAODRootAccess/xAODRootAccess/tools/Message.h:19
atn_test_sgProducerConsumerDataPool_jobOptions.end
end
Definition: atn_test_sgProducerConsumerDataPool_jobOptions.py:25
xAOD::TAuxVector::toPtr
virtual void * toPtr() override
Return a pointer to the start of the vector's data.
Definition: TAuxVector.cxx:118
beamspotman.n
n
Definition: beamspotman.py:731
test_pyathena.parent
parent
Definition: test_pyathena.py:15
xAOD::TAuxVector::size
virtual size_t size() const override
Return the size of the vector.
Definition: TAuxVector.cxx:133
xAOD::TAuxVector::resize
virtual bool resize(size_t sz) override
Change the size of the vector.
Definition: TAuxVector.cxx:138
WriteBchToCool.beg
beg
Definition: WriteBchToCool.py:69
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
SG::AuxVectorInterface
Make an AuxVectorData object from either a raw array or an aux store.
Definition: AuxVectorInterface.h:33
xAOD::TAuxVector::shift
virtual bool shift(size_t pos, ptrdiff_t offs) override
Shift the elements of the vector.
Definition: TAuxVector.cxx:176
xAOD::TAuxVector::clearRange
void clearRange(void *dst, size_t n)
Definition: TAuxVector.cxx:238
xAOD::TAuxVector::auxid
virtual SG::auxid_t auxid() const override
Return the auxid of the variable this vector represents.
Definition: TAuxVector.cxx:112
xAOD::TAuxVector::m_vec
void * m_vec
Pointer to the vector object.
Definition: TAuxVector.h:88
xAOD::TAuxVector::copyRange
void copyRange(const void *src, void *dst, size_t n)
Function copying the payload of a range to a new location.
Definition: TAuxVector.cxx:227
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
xAOD::TAuxVector::m_factory
const TAuxVectorFactory * m_factory
The parent factory object.
Definition: TAuxVector.h:81