Logo ROOT  
Reference Guide
ROOT::Internal::RDF::RColumnValue< T > Class Template Reference

template<typename T>
class ROOT::Internal::RDF::RColumnValue< T >

Helper class that updates and returns TTree branches as well as RDataFrame temporary columns.

Template Parameters
TThe type of the column

RDataFrame nodes must access two different types of values during the event loop: values of real branches, for which TTreeReader{Values,Arrays} act as proxies, or temporary columns whose values are generated on the fly. While the type of the value is known at compile time (or just-in-time), it is only at runtime that nodes can check whether a certain value is generated on the fly or not.

RColumnValue abstracts this difference by providing the same interface for both cases and handling the reading or generation of new values transparently. Only one of the two data members fReaderProxy or fValuePtr will be non-null for a given RColumnValue, depending on whether the value comes from a real TTree branch or from a temporary column respectively.

RDataFrame nodes can store tuples of RColumnValues and retrieve an updated value for the column via the Get method.

Definition at line 62 of file RColumnValue.hxx.

Public Member Functions

 RColumnValue ()
 
template<typename U = T, typename std::enable_if<!RColumnValue< U >::MustUseRVec_t::value, int >::type = 0>
T & Get (Long64_t entry)
 This overload is used to return scalar quantities (i.e. types that are not read into a RVec) More...
 
template<typename U = T, typename std::enable_if< RColumnValue< U >::MustUseRVec_t::value &&!std::is_same< U, RVec< bool > >::value, int >::type = 0>
T & Get (Long64_t entry)
 This overload is used to return arrays (i.e. More...
 
template<typename U = T, typename std::enable_if< RColumnValue< U >::MustUseRVec_t::value &&std::is_same< U, RVec< bool > >::value, int >::type = 0>
T & Get (Long64_t entry)
 This overload covers the RVec<bool> case. More...
 
void MakeProxy (TTreeReader *r, const std::string &bn)
 
void Reset ()
 
void SetTmpColumn (unsigned int slot, RCustomColumnBase *customColumn)
 

Private Types

using ColumnValue_t = typename std::conditional< MustUseRVec_t::value, TakeFirstParameter_t< T >, T >::type
 
enum class  EColumnKind { kTree , kCustomColumn , kDataSource , kInvalid }
 RColumnValue has a slightly different behaviour whether the column comes from a TTreeReader, a RDataFrame Define or a RDataSource. More...
 
enum class  EStorageType : char { kContiguous , kUnknown , kSparse }
 Enumerator for the different properties of the branch storage in memory. More...
 
using MustUseRVec_t = IsRVec_t< T >
 
using TreeReader_t = typename std::conditional< MustUseRVec_t::value, TTreeReaderArray< ColumnValue_t >, TTreeReaderValue< ColumnValue_t > >::type
 

Private Attributes

EColumnKind fColumnKind = EColumnKind::kInvalid
 
bool fCopyWarningPrinted = false
 
RCustomColumnBasefCustomColumn
 Non-owning ptrs to the node responsible for the custom column. Needed when querying custom values. More...
 
T * fCustomValuePtr
 Non-owning ptrs to the value of a custom column. More...
 
T ** fDSValuePtr
 Non-owning ptrs to the value of a data-source column. More...
 
RVec< ColumnValue_tfRVec
 If MustUseRVec, i.e. we are reading an array, we return a reference to this RVec to clients. More...
 
unsigned int fSlot = std::numeric_limits<unsigned int>::max()
 The slot this value belongs to. Only needed when querying custom column values, it is set in SetTmpColumn. More...
 
EStorageType fStorageType = EStorageType::kUnknown
 Signal whether we ever checked that the branch we are reading with a TTreeReaderArray stores array elements in contiguous memory. More...
 
std::unique_ptr< TreeReader_tfTreeReader
 Owning ptrs to a TTreeReaderValue or TTreeReaderArray. Only used for Tree columns. More...
 

#include <ROOT/RDF/RColumnValue.hxx>

Member Typedef Documentation

◆ ColumnValue_t

template<typename T >
using ROOT::Internal::RDF::RColumnValue< T >::ColumnValue_t = typename std::conditional<MustUseRVec_t::value, TakeFirstParameter_t<T>, T>::type
private

Definition at line 68 of file RColumnValue.hxx.

◆ MustUseRVec_t

template<typename T >
using ROOT::Internal::RDF::RColumnValue< T >::MustUseRVec_t = IsRVec_t<T>
private

Definition at line 65 of file RColumnValue.hxx.

◆ TreeReader_t

template<typename T >
using ROOT::Internal::RDF::RColumnValue< T >::TreeReader_t = typename std::conditional<MustUseRVec_t::value, TTreeReaderArray<ColumnValue_t>, TTreeReaderValue<ColumnValue_t> >::type
private

Definition at line 69 of file RColumnValue.hxx.

Member Enumeration Documentation

◆ EColumnKind

template<typename T >
enum class ROOT::Internal::RDF::RColumnValue::EColumnKind
strongprivate

RColumnValue has a slightly different behaviour whether the column comes from a TTreeReader, a RDataFrame Define or a RDataSource.

It stores which it is as an enum.

Enumerator
kTree 
kCustomColumn 
kDataSource 
kInvalid 

Definition at line 74 of file RColumnValue.hxx.

◆ EStorageType

template<typename T >
enum class ROOT::Internal::RDF::RColumnValue::EStorageType : char
strongprivate

Enumerator for the different properties of the branch storage in memory.

Enumerator
kContiguous 
kUnknown 
kSparse 

Definition at line 94 of file RColumnValue.hxx.

Constructor & Destructor Documentation

◆ RColumnValue()

template<typename T >
ROOT::Internal::RDF::RColumnValue< T >::RColumnValue ( )
inline

Definition at line 103 of file RColumnValue.hxx.

Member Function Documentation

◆ Get() [1/3]

template<typename T >
template<typename U = T, typename std::enable_if<!RColumnValue< U >::MustUseRVec_t::value, int >::type = 0>
T & ROOT::Internal::RDF::RColumnValue< T >::Get ( Long64_t  entry)
inline

This overload is used to return scalar quantities (i.e. types that are not read into a RVec)

Definition at line 159 of file RColumnValue.hxx.

◆ Get() [2/3]

template<typename T >
template<typename U = T, typename std::enable_if< RColumnValue< U >::MustUseRVec_t::value &&!std::is_same< U, RVec< bool > >::value, int >::type = 0>
T & ROOT::Internal::RDF::RColumnValue< T >::Get ( Long64_t  entry)
inline

This overload is used to return arrays (i.e.

types that are read into a RVec). In this case the returned T is always a RVec<ColumnValue_t>. RVec<bool> is treated differently, in a separate overload.

Definition at line 175 of file RColumnValue.hxx.

◆ Get() [3/3]

template<typename T >
template<typename U = T, typename std::enable_if< RColumnValue< U >::MustUseRVec_t::value &&std::is_same< U, RVec< bool > >::value, int >::type = 0>
T & ROOT::Internal::RDF::RColumnValue< T >::Get ( Long64_t  entry)
inline

This overload covers the RVec<bool> case.

In this case we always copy the contents of TTreeReaderArray<bool> into RVec<bool> (never take a view into the memory buffer) because the underlying memory buffer might be the one of a std::vector<bool>, which is not a contiguous slab of bool values. Note that this also penalizes the case in which the column type is actually bool[], but the possible performance gains in this edge case is probably not worth the extra complication required to differentiate the two cases.

Definition at line 248 of file RColumnValue.hxx.

◆ MakeProxy()

template<typename T >
void ROOT::Internal::RDF::RColumnValue< T >::MakeProxy ( TTreeReader r,
const std::string &  bn 
)
inline

Definition at line 148 of file RColumnValue.hxx.

◆ Reset()

template<typename T >
void ROOT::Internal::RDF::RColumnValue< T >::Reset ( void  )
inline

Definition at line 269 of file RColumnValue.hxx.

◆ SetTmpColumn()

template<typename T >
void ROOT::Internal::RDF::RColumnValue< T >::SetTmpColumn ( unsigned int  slot,
RCustomColumnBase customColumn 
)
inline

Definition at line 105 of file RColumnValue.hxx.

Member Data Documentation

◆ fColumnKind

template<typename T >
EColumnKind ROOT::Internal::RDF::RColumnValue< T >::fColumnKind = EColumnKind::kInvalid
private

Definition at line 76 of file RColumnValue.hxx.

◆ fCopyWarningPrinted

template<typename T >
bool ROOT::Internal::RDF::RColumnValue< T >::fCopyWarningPrinted = false
private

Definition at line 100 of file RColumnValue.hxx.

◆ fCustomColumn

template<typename T >
RCustomColumnBase* ROOT::Internal::RDF::RColumnValue< T >::fCustomColumn
private

Non-owning ptrs to the node responsible for the custom column. Needed when querying custom values.

Definition at line 92 of file RColumnValue.hxx.

◆ fCustomValuePtr

template<typename T >
T* ROOT::Internal::RDF::RColumnValue< T >::fCustomValuePtr
private

Non-owning ptrs to the value of a custom column.

Definition at line 88 of file RColumnValue.hxx.

◆ fDSValuePtr

template<typename T >
T** ROOT::Internal::RDF::RColumnValue< T >::fDSValuePtr
private

Non-owning ptrs to the value of a data-source column.

Definition at line 90 of file RColumnValue.hxx.

◆ fRVec

template<typename T >
RVec<ColumnValue_t> ROOT::Internal::RDF::RColumnValue< T >::fRVec
private

If MustUseRVec, i.e. we are reading an array, we return a reference to this RVec to clients.

Definition at line 99 of file RColumnValue.hxx.

◆ fSlot

template<typename T >
unsigned int ROOT::Internal::RDF::RColumnValue< T >::fSlot = std::numeric_limits<unsigned int>::max()
private

The slot this value belongs to. Only needed when querying custom column values, it is set in SetTmpColumn.

Definition at line 78 of file RColumnValue.hxx.

◆ fStorageType

template<typename T >
EStorageType ROOT::Internal::RDF::RColumnValue< T >::fStorageType = EStorageType::kUnknown
private

Signal whether we ever checked that the branch we are reading with a TTreeReaderArray stores array elements in contiguous memory.

Only used when T == RVec.

Definition at line 97 of file RColumnValue.hxx.

◆ fTreeReader

template<typename T >
std::unique_ptr<TreeReader_t> ROOT::Internal::RDF::RColumnValue< T >::fTreeReader
private

Owning ptrs to a TTreeReaderValue or TTreeReaderArray. Only used for Tree columns.

Definition at line 86 of file RColumnValue.hxx.


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