Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
);
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:55
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:37
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 68 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.
 
 RooAbsDataHelper (const RooAbsDataHelper &)=delete
 Copy is discouraged.
 
 RooAbsDataHelper (RooAbsDataHelper &&other)
 Move constructor. It transfers ownership of the internal RooAbsData object.
 
template<typename... ColumnTypes>
void Exec (unsigned int slot, ColumnTypes... values)
 Method that RDataFrame calls to pass a new event.
 
void Finalize ()
 Empty all buffers into the dataset/hist to finish processing.
 
std::string GetActionName ()
 RDataFrame interface method.
 
std::shared_ptr< DataSet_t > GetResultPtr () const
 Return internal dataset/hist.
 
void Initialize ()
 RDataFrame interface method. Nothing has to be initialised.
 
void InitTask (TTreeReader *, unsigned int)
 RDataFrame interface method. No tasks.
 
- Public Member Functions inherited from ROOT::Detail::RDF::RActionImpl< RooAbsDataHelper< DataSet_t > >
virtual ~RActionImpl ()=default
 
auto CallFinalizeTask (unsigned int slot) -> decltype(std::declval< T >().FinalizeTask(slot))
 
void CallFinalizeTask (unsigned int, Args...)
 
RooAbsDataHelper< DataSet_t > CallMakeNew (void *, Args...)
 
auto CallMakeNew (void *typeErasedResSharedPtr) -> decltype(std::declval< T >().MakeNew(typeErasedResSharedPtr))
 
void * CallPartialUpdate (...)
 
auto CallPartialUpdate (unsigned int slot) -> decltype(std::declval< H >().PartialUpdate(slot),(void *)(nullptr))
 
virtual std::unique_ptr< RMergeableValueBaseGetMergeableValue () const
 
virtual ROOT::RDF::SampleCallback_t GetSampleCallback ()
 Override this method to register a callback that is executed before the processing a new data sample starts.
 

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.
 

Private Attributes

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

#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 70 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 87 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 97 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 123 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 166 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 146 of file RooAbsDataHelper.h.

◆ GetActionName()

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

RDataFrame interface method.

Definition at line 116 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 110 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 112 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 114 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 73 of file RooAbsDataHelper.h.

◆ _events

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

Definition at line 77 of file RooAbsDataHelper.h.

◆ _eventSize

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

Definition at line 78 of file RooAbsDataHelper.h.

◆ _mutex_dataset

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

Definition at line 74 of file RooAbsDataHelper.h.

◆ _numInvalid

template<class DataSet_t >
std::size_t RooAbsDataHelper< DataSet_t >::_numInvalid = 0
private

Definition at line 75 of file RooAbsDataHelper.h.

  • roofit/RDataFrameHelpers/inc/RooAbsDataHelper.h