11#ifndef ROOT_RDF_RDefaultValueFor
12#define ROOT_RDF_RDefaultValueFor
47 using TypeInd_t = std::make_index_sequence<ColumnTypes_t::list_size>;
49 using ValuesPerSlot_t = std::conditional_t<std::is_same<T, bool>::value, std::deque<T>, std::vector<T>>;
58 std::unordered_map<std::string, std::unique_ptr<RDefineBase>>
fVariedDefines;
62 if (
auto *
value = fValues[slot]->
template TryGet<T>(entry))
71 RLoopManager &lm,
const std::string &variationName =
"nominal")
73 fDefaultValue(defaultValue),
74 fLastResults(lm.GetNSlots() *
RDFInternal::CacheLineStep<T>()),
75 fValues(lm.GetNSlots())
77 fLoopManager->Register(
this);
79 fLoopManager->GetSuppressErrorsForMissingBranches().push_back(fColumnNames[0]);
88 fLoopManager->Deregister(
this);
94 fValues[slot] = RDFInternal::GetColumnReader<T>(
95 slot, fColRegister.GetReader(slot, fColumnNames[0], fVariation,
typeid(T)), *fLoopManager,
r, fColumnNames[0]);
96 fLastCheckedEntry[slot * RDFInternal::CacheLineStep<Long64_t>()] = -1;
102 return static_cast<void *
>(&fLastResults[slot * RDFInternal::CacheLineStep<T>()]);
108 if (entry != fLastCheckedEntry[slot * RDFInternal::CacheLineStep<Long64_t>()]) {
110 fLastResults[slot * RDFInternal::CacheLineStep<T>()] = GetValueOrDefault(slot, entry);
111 fLastCheckedEntry[slot * RDFInternal::CacheLineStep<Long64_t>()] = entry;
117 const std::type_info &
GetTypeId() const final {
return typeid(T); }
122 fValues[slot] =
nullptr;
124 for (
auto &
e : fVariedDefines)
125 e.second->FinalizeSlot(slot);
131 for (
const auto &variation : variations) {
132 if (std::find(fVariationDeps.begin(), fVariationDeps.end(), variation) == fVariationDeps.end()) {
136 if (fVariedDefines.find(variation) != fVariedDefines.end())
141 auto variedDefine = std::unique_ptr<RDefineBase>(
142 new RDefaultValueFor(fName, fType, fDefaultValue, fColumnNames, fColRegister, *fLoopManager, variation));
143 fVariedDefines.insert({variation, std::move(variedDefine)});
150 auto it = fVariedDefines.find(variationName);
151 if (it == fVariedDefines.end()) {
154 assert(std::find(fVariationDeps.begin(), fVariationDeps.end(), variationName) == fVariationDeps.end());
158 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 value
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
The implementation of the DefaultValueFor transformation.
void * GetValuePtr(unsigned int slot) final
Return the (type-erased) address of the Define'd value for the given processing slot.
std::unordered_map< std::string, std::unique_ptr< RDefineBase > > fVariedDefines
Define objects corresponding to systematic variations other than nominal for this defined column.
RDefaultValueFor(RDefaultValueFor &&)=delete
std::vector< RColumnReaderBase * > fValues
RDefineBase & GetVariedDefine(const std::string &variationName) final
Return a clone of this Define that works with values in the variationName "universe".
void InitSlot(TTreeReader *r, unsigned int slot) final
void FinalizeSlot(unsigned int slot) final
Clean-up operations to be performed at the end of a task.
std::conditional_t< std::is_same< T, bool >::value, std::deque< T >, std::vector< T > > ValuesPerSlot_t
std::make_index_sequence< ColumnTypes_t::list_size > TypeInd_t
RDefaultValueFor & operator=(const RDefaultValueFor &)=delete
const std::type_info & GetTypeId() const final
ValuesPerSlot_t fLastResults
RDefaultValueFor(const RDefaultValueFor &)=delete
RDefaultValueFor & operator=(RDefaultValueFor &&)=delete
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.
T & GetValueOrDefault(unsigned int slot, Long64_t entry)
RDefaultValueFor(std::string_view name, std::string_view type, const T &defaultValue, const ROOT::RDF::ColumnNames_t &columns, const RDFInternal::RColumnRegister &colRegister, RLoopManager &lm, const std::string &variationName="nominal")
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...
void MakeVariations(const std::vector< std::string > &variations) final
Create clones of this Define that work with values in varied "universes".
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,...
void Erase(const T &that, std::vector< T > &v)
Erase that element from vector v
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...
Lightweight storage for a collection of types.