11#ifndef ROOT_RDF_RDEFINE
12#define ROOT_RDF_RDEFINE
38namespace CustomColExtraArgs {
45template <
typename F,
typename ExtraArgsTag = CustomColExtraArgs::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<std::unique_ptr<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)...);
83 template <
typename... ColTypes, std::size_t... S>
86 fLastResults[slot * RDFInternal::CacheLineStep<ret_type>()] =
87 fExpression(slot, fValues[slot][S]->
template Get<ColTypes>(entry)...);
93 template <
typename... ColTypes, std::size_t... S>
97 fLastResults[slot * RDFInternal::CacheLineStep<ret_type>()] =
98 fExpression(slot, entry, fValues[slot][S]->
template Get<ColTypes>(entry)...);
107 const std::string &variationName =
"nominal")
108 :
RDefineBase(
name,
type, colRegister, lm, columns, variationName), fExpression(std::move(expression)),
109 fLastResults(lm.GetNSlots() *
RDFInternal::CacheLineStep<
ret_type>()), fValues(lm.GetNSlots())
111 fLoopManager->Book(
this);
121 fLoopManager->GetDataSource()};
123 fLastCheckedEntry[slot * RDFInternal::CacheLineStep<Long64_t>()] = -1;
125 for (
auto &
e : fVariedDefines)
126 e.second->InitSlot(
r, slot);
132 return static_cast<void *
>(&fLastResults[slot * RDFInternal::CacheLineStep<ret_type>()]);
138 if (entry != fLastCheckedEntry[slot * RDFInternal::CacheLineStep<Long64_t>()]) {
141 fLastCheckedEntry[slot * RDFInternal::CacheLineStep<Long64_t>()] = entry;
152 for (
auto &
v : fValues[slot])
155 for (
auto &
e : fVariedDefines)
156 e.second->FinaliseSlot(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);
typedef void(GLAPIENTRYP _GLUfuncptr)(void)
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.
std::vector< std::array< std::unique_ptr< RColumnReaderBase >, ColumnTypes_t::list_size > > fValues
Column readers per slot and per input column.
void InitSlot(TTreeReader *r, unsigned int slot) final
const std::type_info & GetTypeId() const
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
RDefine & operator=(const RDefine &)=delete
typename CallableTraits< F >::arg_types FunParamTypes_t
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 FinaliseSlot(unsigned int slot) final
Clean-up operations to be performed at the end of a task.
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::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 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< std::unique_ptr< RDFDetail::RColumnReaderBase >, sizeof...(ColTypes)> MakeColumnReaders(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 MakeColumnReaders.
Lightweight storage for a collection of types.