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:

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", "weight"} // Column names from RDataFrame
// (this example uses an additional column for the weight)
);
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
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 54 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.
 
template<typename... ColumnTypes>
void Exec (unsigned int slot, ColumnTypes... values)
 Method that RDataFrame calls to pass a new event.
 
RooAbsDataGetAbsData () override
 
std::shared_ptr< DataSet_t > GetResultPtr () const
 Return internal dataset/hist.
 
- Public Member Functions inherited from RooFit::Detail::RooAbsDataFiller
 RooAbsDataFiller ()
 
 RooAbsDataFiller (const RooAbsDataFiller &)=delete
 Copy is discouraged.
 
 RooAbsDataFiller (RooAbsDataFiller &&other)
 Move constructor. It transfers ownership of the internal RooAbsData object.
 
void ExecImpl (std::size_t nValues, std::vector< double > &vector)
 
void Finalize ()
 Empty all buffers into the dataset/hist to finish processing.
 
std::string GetActionName ()
 RDataFrame interface method.
 
void Initialize ()
 RDataFrame interface method.
 
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 Attributes

std::shared_ptr< DataSet_t > _dataset
 

Additional Inherited Members

- Protected Member Functions inherited from RooFit::Detail::RooAbsDataFiller
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 inherited from RooFit::Detail::RooAbsDataFiller
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
 

#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 57 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 64 of file RooAbsDataHelper.h.

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

◆ GetAbsData()

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

Implements RooFit::Detail::RooAbsDataFiller.

Definition at line 86 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 69 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 89 of file RooAbsDataHelper.h.

  • roofit/RDataFrameHelpers/inc/RooAbsDataHelper.h