![]() |
ROOT 6.14/05 Reference Guide |
A "std::vector"-like collection of values implementing handy operation to analyse them.
T | The type of the contained objects |
A RVec is a container designed to make analysis of values' collections fast and easy. Its storage is contiguous in memory and its interface is designed such to resemble to the one of the stl vector. In addition the interface features methods and external functions to ease the manipulation and analysis of the data in the RVec.
Suppose to have an event featuring a collection of muons with a certain pseudorapidity, momentum and charge, e.g.:
Suppose you want to extract the transverse momenta of the muons satisfying certain criteria, for example consider only negatively charged muons with a pseudorapidity smaller or equal to 2 and with a transverse momentum greater than 10 GeV. Such a selection would require, among the other things, the management of an explicit loop, for example:
These operations become straightforward with RVec - we just need to write what we mean:
Now the clean collection of transverse momenta can be used within the rest of the data analysis, for example to fill a histogram.
RVec has contiguous memory associated to it. It can own it or simply adopt it. In the latter case, it can be constructed with the address of the memory associated to it and its lenght. For example:
In this case, the memory associated to myStlVec and myRVec is the same, myRVec simply "adopted it". If any method which implies a re-allocation is called, e.g. emplace_back or resize, the adopted memory is released and new one is allocated. The previous content is copied in the new memory and preserved.
TDataFrame leverages internally RVecs. Suppose to have a dataset stored in a TTree which holds these columns (here we choose C arrays to represent the collections, they could be as well std::vector instances):
Suppose you'd like to plot in a histogram the transverse momenta of all particles for which the energy is greater than 200 MeV. The code required would just be:
And if you'd like to express your selection as a string:
Public Types | |
using | const_iterator = typename Impl_t::const_iterator |
using | const_pointer = typename Impl_t::const_pointer |
using | const_reference = typename Impl_t::const_reference |
using | const_reverse_iterator = typename Impl_t::const_reverse_iterator |
using | difference_type = typename Impl_t::difference_type |
using | Impl_t = typename std::vector< T, ::ROOT::Detail::VecOps::RAdoptAllocator< T > > |
using | iterator = typename Impl_t::iterator |
using | pointer = typename Impl_t::pointer |
using | reference = typename Impl_t::reference |
using | reverse_iterator = typename Impl_t::reverse_iterator |
using | size_type = typename Impl_t::size_type |
using | value_type = typename Impl_t::value_type |
Public Member Functions | |
RVec () | |
RVec (size_type count) | |
RVec (size_type count, const T &value) | |
RVec (const RVec< T > &v) | |
RVec (RVec< T > &&v) | |
RVec (const std::vector< T > &v) | |
RVec (pointer p, size_type n) | |
template<class InputIt > | |
RVec (InputIt first, InputIt last) | |
RVec (std::initializer_list< T > init) | |
reference | at (size_type pos) |
const_reference | at (size_type pos) const |
reference | back () |
const_reference | back () const |
iterator | begin () noexcept |
const_iterator | begin () const noexcept |
size_type | capacity () const noexcept |
const_iterator | cbegin () const noexcept |
const_iterator | cend () const noexcept |
void | clear () noexcept |
const_reverse_iterator | crbegin () const noexcept |
const_reverse_iterator | crend () const noexcept |
T * | data () noexcept |
const T * | data () const noexcept |
template<typename U = T, typename std::enable_if< std::is_arithmetic< U >::value, int > * = nullptr> | |
iterator | emplace (const_iterator pos, U value) |
This method is intended only for arithmetic types unlike the std::vector corresponding one which is generic. More... | |
template<class... Args> | |
reference | emplace_back (Args &&... args) |
bool | empty () const noexcept |
iterator | end () noexcept |
const_iterator | end () const noexcept |
iterator | erase (iterator pos) |
iterator | erase (iterator first, iterator last) |
reference | front () |
const_reference | front () const |
size_type | max_size () const noexcept |
template<typename U , typename = std::enable_if<std::is_convertible<T, U>::value>> | |
operator RVec< U > () const | |
RVec< T > & | operator= (const RVec< T > &v) |
RVec< T > & | operator= (RVec< T > &&v) |
RVec< T > & | operator= (std::initializer_list< T > ilist) |
reference | operator[] (size_type pos) |
const_reference | operator[] (size_type pos) const |
template<typename V , typename = std::enable_if<std::is_convertible<V, bool>::value>> | |
RVec | operator[] (const RVec< V > &conds) const |
void | pop_back () |
void | push_back (T &&value) |
reverse_iterator | rbegin () noexcept |
const_reverse_iterator | rbegin () const noexcept |
reverse_iterator | rend () noexcept |
const_reverse_iterator | rend () const noexcept |
void | reserve (size_type new_cap) |
void | resize (size_type count) |
void | resize (size_type count, const value_type &value) |
void | shrink_to_fit () |
size_type | size () const noexcept |
void | swap (RVec< T > &other) |
Private Attributes | |
Impl_t | fData |
#include <ROOT/RVec.hxx>
using ROOT::VecOps::RVec< T >::const_iterator = typename Impl_t::const_iterator |
using ROOT::VecOps::RVec< T >::const_pointer = typename Impl_t::const_pointer |
using ROOT::VecOps::RVec< T >::const_reference = typename Impl_t::const_reference |
using ROOT::VecOps::RVec< T >::const_reverse_iterator = typename Impl_t::const_reverse_iterator |
using ROOT::VecOps::RVec< T >::difference_type = typename Impl_t::difference_type |
using ROOT::VecOps::RVec< T >::Impl_t = typename std::vector<T, ::ROOT::Detail::VecOps::RAdoptAllocator<T> > |
using ROOT::VecOps::RVec< T >::iterator = typename Impl_t::iterator |
using ROOT::VecOps::RVec< T >::pointer = typename Impl_t::pointer |
using ROOT::VecOps::RVec< T >::reference = typename Impl_t::reference |
using ROOT::VecOps::RVec< T >::reverse_iterator = typename Impl_t::reverse_iterator |
using ROOT::VecOps::RVec< T >::size_type = typename Impl_t::size_type |
using ROOT::VecOps::RVec< T >::value_type = typename Impl_t::value_type |
|
inline |
|
inlineexplicit |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
|
inline |
|
private |