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... ColTypes, std::size_t... S>
76 fLastResults[slot * RDFInternal::CacheLineStep<ret_type>()] =
77 fExpression(fValues[slot][S]->
template Get<ColTypes>(entry)...);
81 template <
typename... ColTypes, std::size_t... S>
84 fLastResults[slot * RDFInternal::CacheLineStep<ret_type>()] =
85 fExpression(slot, fValues[slot][S]->
template Get<ColTypes>(entry)...);
89 template <
typename... ColTypes, std::size_t... S>
93 fLastResults[slot * RDFInternal::CacheLineStep<ret_type>()] =
94 fExpression(slot, entry, fValues[slot][S]->
template Get<ColTypes>(entry)...);
100 const std::string &variationName =
"nominal")
101 :
RDefineBase(
name,
type, colRegister, lm, columns, variationName), fExpression(std::move(expression)),
102 fLastResults(lm.GetNSlots() *
RDFInternal::CacheLineStep<
ret_type>()), fValues(lm.GetNSlots())
104 fLoopManager->Register(
this);
115 fLastCheckedEntry[slot * RDFInternal::CacheLineStep<Long64_t>()] = -1;
121 return static_cast<void *
>(&fLastResults[slot * RDFInternal::CacheLineStep<ret_type>()]);
127 if (entry != fLastCheckedEntry[slot * RDFInternal::CacheLineStep<Long64_t>()]) {
130 fLastCheckedEntry[slot * RDFInternal::CacheLineStep<Long64_t>()] = entry;
141 fValues[slot].fill(
nullptr);
143 for (
auto &
e : fVariedDefines)
144 e.second->FinalizeSlot(slot);
150 for (
const auto &variation : variations) {
151 if (std::find(fVariationDeps.begin(), fVariationDeps.end(), variation) == fVariationDeps.end()) {
155 if (fVariedDefines.find(variation) != fVariedDefines.end())
160 auto variedDefine = std::unique_ptr<RDefineBase>(
161 new RDefine(fName, fType, fExpression, fColumnNames, fColRegister, *fLoopManager, variation));
163 fVariedDefines[variation] = std::move(variedDefine);
170 auto it = fVariedDefines.find(variationName);
171 if (it == fVariedDefines.end()) {
174 assert(std::find(fVariationDeps.begin(), fVariationDeps.end(), variationName) == fVariationDeps.end());
178 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
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.