Logo ROOT  
Reference Guide
RooAbsDataHelper< DataSet_t > Class Template Reference

template<class DataSet_t>
class RooAbsDataHelper< DataSet_t >

This is a helper for an RDataFrame action, which fills RooFit data classes.

Template Parameters
DataSet_tEither RooDataSet or RooDataHist.

To construct RooDataSet / RooDataHist within RDataFrame

  • Construct one of the two action helpers RooDataSetHelper or RooDataHistHelper. Pass constructor arguments to RooAbsDataHelper::RooAbsDataHelper() as for the original classes. The arguments are forwarded to the actual data classes without any changes.
  • Book the helper as an RDataFrame action. Here, the RDataFrame column types have to be passed as template parameters.
  • Pass the column names to the Book action. These are matched by position to the variables of the dataset.

All arguments passed to are forwarded to RooDataSet::RooDataSet() / RooDataHist::RooDataHist().

Usage example:

RooRealVar x("x", "x", -5., 5.);
RooRealVar y("y", "y", -50., 50.);
auto myDataSet = rdataframe.Book<double, double>(
RooDataSetHelper{"dataset", // Name (directly forwarded to RooDataSet::RooDataSet())
"Title of dataset", // Title ( ~ " ~ )
RooArgSet(x, y) }, // Variables to create in dataset
{"x", "y"} // Column names from RDataFrame
);
double
Definition: Converters.cxx:939
This is a helper for an RDataFrame action, which fills RooFit data classes.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:35
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:39
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
Warning
Variables in the dataset and columns in RDataFrame are matched by position, not by name. This enables the easy exchanging of columns that should be filled into the dataset.

Definition at line 67 of file RooAbsDataHelper.h.

Public Types

using Result_t = DataSet_t
 

Public Member Functions

template<typename... Args_t>
 RooAbsDataHelper (Args_t &&... args)
 Construct a helper to create RooDataSet/RooDataHist. More...
 
 RooAbsDataHelper (const RooAbsDataHelper &)=delete
 Copy is discouraged. More...
 
 RooAbsDataHelper (RooAbsDataHelper &&other)
 Move constructor. It transfers ownership of the internal RooAbsData object. More...
 
template<typename... ColumnTypes>
void Exec (unsigned int slot, ColumnTypes... values)
 Method that RDataFrame calls to pass a new event. More...
 
void Finalize ()
 Empty all buffers into the dataset/hist to finish processing. More...
 
std::string GetActionName ()
 RDataFrame interface method. More...
 
std::shared_ptr< DataSet_t > GetResultPtr () const
 Return internal dataset/hist. More...
 
void Initialize ()
 RDataFrame interface method. Nothing has to be initialised. More...
 
void InitTask (TTreeReader *, unsigned int)
 RDataFrame interface method. No tasks. More...
 

Private Member Functions

void FillDataSet (const std::vector< double > &events, unsigned int eventSize)
 Append all events to the internal RooDataSet or increment the bins of a RooDataHist at the given locations. More...
 

Private Attributes

std::shared_ptr< DataSet_t > _dataset
 
std::vector< std::vector< double > > _events
 
const std::size_t _eventSize
 
std::mutex _mutex_dataset
 

#include <RooAbsDataHelper.h>

Inheritance diagram for RooAbsDataHelper< DataSet_t >:
[legend]

Member Typedef Documentation

◆ Result_t

template<class DataSet_t >
using RooAbsDataHelper< DataSet_t >::Result_t = DataSet_t

Definition at line 69 of file RooAbsDataHelper.h.

Constructor & Destructor Documentation

◆ RooAbsDataHelper() [1/3]

template<class DataSet_t >
template<typename... Args_t>
RooAbsDataHelper< DataSet_t >::RooAbsDataHelper ( Args_t &&...  args)
inline

Construct a helper to create RooDataSet/RooDataHist.

Template Parameters
Args_tParameter pack of arguments.
Parameters
argsConstructor arguments for RooDataSet::RooDataSet() or RooDataHist::RooDataHist(). All arguments will be forwarded as they are.

Definition at line 85 of file RooAbsDataHelper.h.

◆ RooAbsDataHelper() [2/3]

template<class DataSet_t >
RooAbsDataHelper< DataSet_t >::RooAbsDataHelper ( RooAbsDataHelper< DataSet_t > &&  other)
inline

Move constructor. It transfers ownership of the internal RooAbsData object.

Definition at line 95 of file RooAbsDataHelper.h.

◆ RooAbsDataHelper() [3/3]

template<class DataSet_t >
RooAbsDataHelper< DataSet_t >::RooAbsDataHelper ( const RooAbsDataHelper< DataSet_t > &  )
delete

Copy is discouraged.

Use rdataframe.Book<...>(std::move(absDataHelper), ...) instead.

Member Function Documentation

◆ Exec()

template<class DataSet_t >
template<typename... ColumnTypes>
void RooAbsDataHelper< DataSet_t >::Exec ( unsigned int  slot,
ColumnTypes...  values 
)
inline

Method that RDataFrame calls to pass a new event.

Parameters
slotWhen IMT is used, this is a number in the range [0, nSlots) to fill lock free.
valuesx, y, z, ... coordinates of the event.

Definition at line 121 of file RooAbsDataHelper.h.

◆ FillDataSet()

template<class DataSet_t >
void RooAbsDataHelper< DataSet_t >::FillDataSet ( const std::vector< double > &  events,
unsigned int  eventSize 
)
inlineprivate

Append all events to the internal RooDataSet or increment the bins of a RooDataHist at the given locations.

Parameters
eventsEvents to fill into data. The layout is assumed to be (x, y, z, ...) (x, y, z, ...), (...).
Note
The order of the variables inside events must be consistent with the order given in the constructor. No matching by name is performed.
Parameters
eventSizeSize of a single event.

Definition at line 159 of file RooAbsDataHelper.h.

◆ Finalize()

template<class DataSet_t >
void RooAbsDataHelper< DataSet_t >::Finalize ( )
inline

Empty all buffers into the dataset/hist to finish processing.

Definition at line 144 of file RooAbsDataHelper.h.

◆ GetActionName()

template<class DataSet_t >
std::string RooAbsDataHelper< DataSet_t >::GetActionName ( )
inline

RDataFrame interface method.

Definition at line 114 of file RooAbsDataHelper.h.

◆ GetResultPtr()

template<class DataSet_t >
std::shared_ptr< DataSet_t > RooAbsDataHelper< DataSet_t >::GetResultPtr ( ) const
inline

Return internal dataset/hist.

Definition at line 108 of file RooAbsDataHelper.h.

◆ Initialize()

template<class DataSet_t >
void RooAbsDataHelper< DataSet_t >::Initialize ( )
inline

RDataFrame interface method. Nothing has to be initialised.

Definition at line 110 of file RooAbsDataHelper.h.

◆ InitTask()

template<class DataSet_t >
void RooAbsDataHelper< DataSet_t >::InitTask ( TTreeReader ,
unsigned int   
)
inline

RDataFrame interface method. No tasks.

Definition at line 112 of file RooAbsDataHelper.h.

Member Data Documentation

◆ _dataset

template<class DataSet_t >
std::shared_ptr<DataSet_t> RooAbsDataHelper< DataSet_t >::_dataset
private

Definition at line 72 of file RooAbsDataHelper.h.

◆ _events

template<class DataSet_t >
std::vector<std::vector<double> > RooAbsDataHelper< DataSet_t >::_events
private

Definition at line 75 of file RooAbsDataHelper.h.

◆ _eventSize

template<class DataSet_t >
const std::size_t RooAbsDataHelper< DataSet_t >::_eventSize
private

Definition at line 76 of file RooAbsDataHelper.h.

◆ _mutex_dataset

template<class DataSet_t >
std::mutex RooAbsDataHelper< DataSet_t >::_mutex_dataset
private

Definition at line 73 of file RooAbsDataHelper.h.


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