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. If there is one more column name than variables in the dataset, the last columns values will be used as weights.

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

Usage example for a weighted RooDataSet:

RooRealVar x("x", "x", -5., 5.);
RooRealVar y("y", "y", -50., 50.);
auto myDataSet = rdataframe.Book<double, double, double>( // three template arguments for "x", "y", and "weight"
"dataset", // Name (directly forwarded to RooDataSet::RooDataSet())
"Title of dataset", // Title ( ~ " ~ )
RooArgSet(x, y), // Variables to create in dataset
RooFit::WeightVar("weight") // skip in case of RooDataHist or unweighted dataset
},
{"x", "y", "weight"} // Column names from RDataFrame
// (this example uses an additional column for the weight)
);
RooAbsDataHelper< RooDataSet > RooDataSetHelper
Helper for creating a RooDataSet inside RDataFrame.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
Variable that can be changed from the outside.
Definition RooRealVar.h:37
RooCmdArg WeightVar(const char *name="weight", bool reinterpretAsWeight=false)
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 121 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.
auto CallFinalizeTask (unsigned int slot) -> decltype(std::declval< T >().FinalizeTask(slot))
RooAbsDataHelper< DataSet_t > CallMakeNew (void *typeErasedResSharedPtr, std::string_view variation="nominal")
auto CallPartialUpdate (unsigned int slot) -> decltype(std::declval< H >().PartialUpdate(slot),(void *)(nullptr))
std::vector< double > & events (std::size_t slot)
template<typename... ColumnTypes>
void Exec (unsigned int slot, ColumnTypes... values)
 Method that RDataFrame calls to pass a new event.
void ExecImpl (std::size_t nValues, std::vector< double > &vector)
void Finalize ()
 Empty all buffers into the dataset/hist to finish processing.
DataSet_t & GetAbsData () override
std::string GetActionName ()
 RDataFrame interface method.
virtual std::unique_ptr< RMergeableValueBase > GetMergeableValue () const
std::shared_ptr< DataSet_t > GetResultPtr () const
 Return internal dataset/hist.
virtual ROOT::RDF::SampleCallback_t GetSampleCallback ()
 Override this method to register a callback that is executed before the processing a new data sample starts.
void Initialize ()
 RDataFrame interface method.
void InitTask (TTreeReader *, unsigned int)
 RDataFrame interface method. No tasks.

Protected Member Functions

void FillAbsData (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.

Protected Attributes

std::vector< std::vector< double > > _events
std::size_t _eventSize
bool _isDataHist = false
bool _isWeighted = false
std::mutex _mutexDataset
std::size_t _numInvalid = 0
std::size_t _nValues

Private Attributes

std::shared_ptr< DataSet_t > _dataset

#include <RooAbsDataHelper.h>

Inheritance diagram for RooAbsDataHelper< DataSet_t >:
RooFit::Detail::RooAbsDataFiller ROOT::Detail::RDF::RActionImpl< RooAbsDataHelper< DataSet_t > >

Member Typedef Documentation

◆ Result_t

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

Definition at line 124 of file RooAbsDataHelper.h.

Constructor & Destructor Documentation

◆ RooAbsDataHelper()

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 131 of file RooAbsDataHelper.h.

Member Function Documentation

◆ CallFinalizeTask()

auto ROOT::Detail::RDF::RActionImpl< RooAbsDataHelper< DataSet_t > >::CallFinalizeTask ( unsigned int slot) -> decltype(std::declval< T >().FinalizeTask(slot))
inlineinherited

Definition at line 44 of file RActionImpl.hxx.

◆ CallMakeNew()

RooAbsDataHelper< DataSet_t > ROOT::Detail::RDF::RActionImpl< RooAbsDataHelper< DataSet_t > >::CallMakeNew ( void * typeErasedResSharedPtr,
std::string_view variation = "nominal" )
inlineinherited

Definition at line 64 of file RActionImpl.hxx.

◆ CallPartialUpdate()

auto ROOT::Detail::RDF::RActionImpl< RooAbsDataHelper< DataSet_t > >::CallPartialUpdate ( unsigned int slot) -> decltype(std::declval< H >().PartialUpdate(slot),(void *)(nullptr))
inlineinherited

Definition at line 53 of file RActionImpl.hxx.

◆ events()

std::vector< double > & RooFit::Detail::RooAbsDataFiller::events ( std::size_t slot)
inlineinherited

Definition at line 58 of file RooAbsDataHelper.h.

◆ 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 143 of file RooAbsDataHelper.h.

◆ ExecImpl()

void RooFit::Detail::RooAbsDataFiller::ExecImpl ( std::size_t nValues,
std::vector< double > & vector )
inherited

Definition at line 122 of file RooAbsDataHelper.cxx.

◆ FillAbsData()

void RooFit::Detail::RooAbsDataFiller::FillAbsData ( const std::vector< double > & events,
unsigned int eventSize )
protectedinherited

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 47 of file RooAbsDataHelper.cxx.

◆ Finalize()

void RooFit::Detail::RooAbsDataFiller::Finalize ( )
inherited

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

Definition at line 107 of file RooAbsDataHelper.cxx.

◆ GetAbsData()

template<class DataSet_t>
DataSet_t & RooAbsDataHelper< DataSet_t >::GetAbsData ( )
inlineoverridevirtual

Implements RooFit::Detail::RooAbsDataFiller.

Definition at line 153 of file RooAbsDataHelper.h.

◆ GetActionName()

std::string RooFit::Detail::RooAbsDataFiller::GetActionName ( )
inlineinherited

RDataFrame interface method.

Definition at line 51 of file RooAbsDataHelper.h.

◆ GetMergeableValue()

virtual std::unique_ptr< RMergeableValueBase > ROOT::Detail::RDF::RActionImpl< RooAbsDataHelper< DataSet_t > >::GetMergeableValue ( ) const
inlinevirtualinherited

Definition at line 79 of file RActionImpl.hxx.

◆ GetResultPtr()

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

Return internal dataset/hist.

Definition at line 136 of file RooAbsDataHelper.h.

◆ GetSampleCallback()

virtual ROOT::RDF::SampleCallback_t ROOT::Detail::RDF::RActionImpl< RooAbsDataHelper< DataSet_t > >::GetSampleCallback ( )
inlinevirtualinherited

Override this method to register a callback that is executed before the processing a new data sample starts.

The callback will be invoked in the same conditions as with DefinePerSample().

Definition at line 86 of file RActionImpl.hxx.

◆ Initialize()

void RooFit::Detail::RooAbsDataFiller::Initialize ( )
inherited

RDataFrame interface method.

Definition at line 32 of file RooAbsDataHelper.cxx.

◆ InitTask()

void RooFit::Detail::RooAbsDataFiller::InitTask ( TTreeReader * ,
unsigned int  )
inlineinherited

RDataFrame interface method. No tasks.

Definition at line 49 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 156 of file RooAbsDataHelper.h.

◆ _events

std::vector<std::vector<double> > RooFit::Detail::RooAbsDataFiller::_events
protectedinherited

Definition at line 66 of file RooAbsDataHelper.h.

◆ _eventSize

std::size_t RooFit::Detail::RooAbsDataFiller::_eventSize
protectedinherited

Definition at line 67 of file RooAbsDataHelper.h.

◆ _isDataHist

bool RooFit::Detail::RooAbsDataFiller::_isDataHist = false
protectedinherited

Definition at line 71 of file RooAbsDataHelper.h.

◆ _isWeighted

bool RooFit::Detail::RooAbsDataFiller::_isWeighted = false
protectedinherited

Definition at line 70 of file RooAbsDataHelper.h.

◆ _mutexDataset

std::mutex RooFit::Detail::RooAbsDataFiller::_mutexDataset
protectedinherited

Definition at line 63 of file RooAbsDataHelper.h.

◆ _numInvalid

std::size_t RooFit::Detail::RooAbsDataFiller::_numInvalid = 0
protectedinherited

Definition at line 64 of file RooAbsDataHelper.h.

◆ _nValues

std::size_t RooFit::Detail::RooAbsDataFiller::_nValues
protectedinherited

Definition at line 68 of file RooAbsDataHelper.h.


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