11#ifndef ROOT_RDF_RDEFINE
12#define ROOT_RDF_RDEFINE
38namespace ExtraArgsForDefine {
45template <
typename F,
typename ExtraArgsTag = ExtraArgsForDefine::None>
57 using TypeInd_t = std::make_index_sequence<ColumnTypes_t::list_size>;
61 std::conditional_t<std::is_same<ret_type, bool>::value, std::deque<ret_type>, std::vector<ret_type>>;
67 std::vector<std::array<RColumnReaderBase *, ColumnTypes_t::list_size>>
fValues;
71 std::unordered_map<std::string, std::unique_ptr<RDefineBase>>
fVariedDefines;
73 template <
typename ColType>
76 if (
auto *val = fValues[slot][readerIdx]->
template TryGet<ColType>(entry))
79 throw std::out_of_range{
"RDataFrame: Define could not retrieve value for column '" + fColumnNames[readerIdx] +
80 "' for entry " + std::to_string(entry) +
81 ". You can use the DefaultValueFor operation to provide a default value, or "
82 "FilterAvailable/FilterMissing to discard/keep entries with missing values instead."};
85 template <
typename... ColTypes, std::size_t... S>
88 fLastResults[slot * RDFInternal::CacheLineStep<ret_type>()] =
89 fExpression(GetValueChecked<ColTypes>(slot, S, entry)...);
93 template <
typename... ColTypes, std::size_t... S>
96 fLastResults[slot * RDFInternal::CacheLineStep<ret_type>()] =
97 fExpression(slot, GetValueChecked<ColTypes>(slot, S, entry)...);
101 template <
typename... ColTypes, std::size_t... S>
105 fLastResults[slot * RDFInternal::CacheLineStep<ret_type>()] =
106 fExpression(slot, entry, GetValueChecked<ColTypes>(slot, S, entry)...);
112 const std::string &variationName =
"nominal")
113 :
RDefineBase(
name,
type, colRegister, lm, columns, variationName), fExpression(std::move(expression)),
114 fLastResults(lm.GetNSlots() *
RDFInternal::CacheLineStep<
ret_type>()), fValues(lm.GetNSlots())
116 fLoopManager->Register(
this);
127 fLastCheckedEntry[slot * RDFInternal::CacheLineStep<Long64_t>()] = -1;
133 return static_cast<void *
>(&fLastResults[slot * RDFInternal::CacheLineStep<ret_type>()]);
139 if (entry != fLastCheckedEntry[slot * RDFInternal::CacheLineStep<Long64_t>()]) {
142 fLastCheckedEntry[slot * RDFInternal::CacheLineStep<Long64_t>()] = entry;
153 fValues[slot].fill(
nullptr);
155 for (
auto &
e : fVariedDefines)
156 e.second->FinalizeSlot(slot);
162 for (
const auto &variation : variations) {
163 if (std::find(fVariationDeps.begin(), fVariationDeps.end(), variation) == fVariationDeps.end()) {
167 if (fVariedDefines.find(variation) != fVariedDefines.end())
172 auto variedDefine = std::unique_ptr<RDefineBase>(
173 new RDefine(fName, fType, fExpression, fColumnNames, fColRegister, *fLoopManager, variation));
175 fVariedDefines[variation] = std::move(variedDefine);
182 auto it = fVariedDefines.find(variationName);
183 if (it == fVariedDefines.end()) {
186 assert(std::find(fVariationDeps.begin(), fVariationDeps.end(), variationName) == fVariationDeps.end());
190 return *(it->second);
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
auto GetValueChecked(unsigned int slot, std::size_t readerIdx, Long64_t entry) -> ColType &
std::conditional_t< std::is_same< ret_type, bool >::value, std::deque< ret_type >, std::vector< ret_type > > ValuesPerSlot_t
RDFInternal::RemoveFirstParameterIf_t< std::is_same< ExtraArgsTag, SlotTag >::value, FunParamTypes_t > ColumnTypesTmp_t
RDefine(const RDefine &)=delete
void UpdateHelper(unsigned int slot, Long64_t entry, TypeList< ColTypes... >, std::index_sequence< S... >, SlotAndEntryTag)
void * GetValuePtr(unsigned int slot) final
Return the (type-erased) address of the Define'd value for the given processing slot.
void InitSlot(TTreeReader *r, unsigned int slot) final
void MakeVariations(const std::vector< std::string > &variations) final
Create clones of this Define that work with values in varied "universes".
RDefineBase & GetVariedDefine(const std::string &variationName) final
Return a clone of this Define that works with values in the variationName "universe".
ValuesPerSlot_t fLastResults
RDefine(std::string_view name, std::string_view type, F expression, const ROOT::RDF::ColumnNames_t &columns, const RDFInternal::RColumnRegister &colRegister, RLoopManager &lm, const std::string &variationName="nominal")
typename CallableTraits< F >::ret_type ret_type
std::make_index_sequence< ColumnTypes_t::list_size > TypeInd_t
const std::type_info & GetTypeId() const final
RDefine & operator=(const RDefine &)=delete
typename CallableTraits< F >::arg_types FunParamTypes_t
void FinalizeSlot(unsigned int slot) final
Clean-up operations to be performed at the end of a task.
void Update(unsigned int, const ROOT::RDF::RSampleInfo &) final
Update function to be called once per sample, used if the derived type is a RDefinePerSample.
void UpdateHelper(unsigned int slot, Long64_t entry, TypeList< ColTypes... >, std::index_sequence< S... >, SlotTag)
void Update(unsigned int slot, Long64_t entry) final
Update the value at the address returned by GetValuePtr with the content corresponding to the given e...
RDFInternal::RemoveFirstTwoParametersIf_t< std::is_same< ExtraArgsTag, SlotAndEntryTag >::value, ColumnTypesTmp_t > ColumnTypes_t
std::vector< std::array< RColumnReaderBase *, ColumnTypes_t::list_size > > fValues
Column readers per slot and per input column.
std::unordered_map< std::string, std::unique_ptr< RDefineBase > > fVariedDefines
Define objects corresponding to systematic variations other than nominal for this defined column.
void UpdateHelper(unsigned int slot, Long64_t entry, TypeList< ColTypes... >, std::index_sequence< S... >, NoneTag)
The head node of a RDF computation graph.
A binder for user-defined columns, variations and aliases.
This type represents a sample identifier, to be used in conjunction with RDataFrame features such as ...
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
typename RemoveFirstParameterIf< MustRemove, TypeList >::type RemoveFirstParameterIf_t
std::array< RDFDetail::RColumnReaderBase *, sizeof...(ColTypes)> GetColumnReaders(unsigned int slot, TTreeReader *r, TypeList< ColTypes... >, const RColumnReadersInfo &colInfo, const std::string &variationName="nominal")
Create a group of column readers, one per type in the parameter pack.
typename RemoveFirstTwoParametersIf< MustRemove, TypeList >::type RemoveFirstTwoParametersIf_t
std::vector< std::string > ColumnNames_t
ROOT type_traits extensions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Extract types from the signature of a callable object. See CallableTraits.
This type aggregates some of the arguments passed to GetColumnReaders.
Lightweight storage for a collection of types.