11#ifndef ROOT_RDF_RVARIATION 
   12#define ROOT_RDF_RVARIATION 
   48bool ResultsSizeEq(
const T &results, std::size_t expected, std::size_t nColumns, std::true_type )
 
   50   assert(nColumns == 1);
 
   53   return results.size() == expected;
 
   59   return results.
size();
 
   65   results.
resize(nVariations);
 
   74   const auto nVariations = resStorage.
size(); 
 
   76   for (
auto i = 0u; i < nVariations; ++i)
 
   77      resStorage[i] = std::move(tmpResults[i]);
 
   83   return static_cast<void *
>(&
v[varIdx]);
 
   90bool ResultsSizeEq(
const T &results, std::size_t expected, std::size_t , std::false_type )
 
   92   return std::all_of(results.begin(), results.end(),
 
   93                      [expected](
const auto &inner) { return inner.size() == expected; });
 
   99   assert(!results.empty());
 
  100   return results[0].size();
 
  106   results.resize(nCols);
 
  107   for (
auto &rvecOverVariations : results)
 
  108      rvecOverVariations.resize(nVariations);
 
  115   const auto nCols = resStorage.size();
 
  116   const auto nVariations = resStorage[0].size();
 
  117   for (
auto colIdx = 0u; colIdx < nCols; ++colIdx)
 
  118      for (
auto varIdx = 0u; varIdx < nVariations; ++varIdx)
 
  119         resStorage[colIdx][varIdx] = std::move(tmpResults[colIdx][varIdx]);
 
  125   return static_cast<void *
>(&
v[colIdx][varIdx]);
 
  129template <
typename VaryExpressionRet_t, 
bool IsSingleColumn>
 
  145template <
bool IsSingleColumn, 
typename Ret_t>
 
  148template <
typename F, 
bool IsSingleColumn>
 
  151   using TypeInd_t = std::make_index_sequence<ColumnTypes_t::list_size>;
 
  154   using Result_t = std::conditional_t<IsSingleColumn, ROOT::RVec<VariedCol_t>, std::vector<ROOT::RVec<VariedCol_t>>>;
 
  161   std::vector<std::array<RColumnReaderBase *, ColumnTypes_t::list_size>> 
fValues;
 
  163   template <
typename... ColTypes, std::size_t... S>
 
  167      auto &&results = fExpression(fValues[slot][S]->
template Get<ColTypes>(entry)...);
 
  170      if (!
ResultsSizeEq(results, fVariationNames.size(), fColNames.size(),
 
  171                         std::integral_constant<bool, IsSingleColumn>{})) {
 
  172         std::string variationName = fVariationNames[0].substr(0, fVariationNames[0].find_first_of(
':'));
 
  173         throw std::runtime_error(
"The evaluation of the expression for variation \"" + variationName +
 
  174                                  "\" resulted in " + std::to_string(
GetNVariations(results)) + 
" values, but " +
 
  175                                  std::to_string(fVariationNames.size()) + 
" were expected.");
 
  178      AssignResults(fLastResults[slot * CacheLineStep<Result_t>()], std::move(results));
 
  182   RVariation(
const std::vector<std::string> &colNames, std::string_view variationName, 
F expression,
 
  183              const std::vector<std::string> &variationTags, std::string_view 
type, 
const RColumnRegister &defines,
 
  185      : 
RVariationBase(colNames, variationName, variationTags, 
type, defines, lm, inputColNames),
 
  189      fLoopManager->Register(
this);
 
  191      for (
auto i = 0u; i < lm.
GetNSlots(); ++i)
 
  192         ResizeResults(fLastResults[i * RDFInternal::CacheLineStep<Result_t>()], colNames.size(), variationTags.size());
 
  201      RColumnReadersInfo info{fInputColumns, fColumnRegister, fIsDefine.data(), *fLoopManager};
 
  203      fLastCheckedEntry[slot * CacheLineStep<Long64_t>()] = -1;
 
  207   void *
GetValuePtr(
unsigned int slot, 
const std::string &column, 
const std::string &variation) 
final 
  209      const auto colIt = std::find(fColNames.begin(), fColNames.end(), column);
 
  210      assert(colIt != fColNames.end());
 
  211      const auto colIdx = std::distance(fColNames.begin(), colIt);
 
  213      const auto varIt = std::find(fVariationNames.begin(), fVariationNames.end(), variation);
 
  214      assert(varIt != fVariationNames.end());
 
  215      const auto varIdx = std::distance(fVariationNames.begin(), varIt);
 
  217      return GetValuePtrHelper(fLastResults[slot * CacheLineStep<Result_t>()], colIdx, varIdx);
 
  223      if (entry != fLastCheckedEntry[slot * CacheLineStep<Long64_t>()]) {
 
  226         fLastCheckedEntry[slot * CacheLineStep<Long64_t>()] = entry;
 
  233   void FinalizeSlot(
unsigned int slot) 
final { fValues[slot].fill(
nullptr); }
 
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
 
The head node of a RDF computation graph.
 
unsigned int GetNSlots() const
 
A binder for user-defined columns, variations and aliases.
 
This type includes all parts of RVariation that do not depend on the callable signature.
 
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...
 
std::conditional_t< IsSingleColumn, ROOT::RVec< VariedCol_t >, std::vector< ROOT::RVec< VariedCol_t > > > Result_t
 
const std::type_info & GetTypeId() const final
 
void FinalizeSlot(unsigned int slot) final
Clean-up operations to be performed at the end of a task.
 
void * GetValuePtr(unsigned int slot, const std::string &column, const std::string &variation) final
Return the (type-erased) address of the value for the given processing slot.
 
std::make_index_sequence< ColumnTypes_t::list_size > TypeInd_t
 
ColumnType_t< IsSingleColumn, Ret_t > VariedCol_t
 
RVariation(const std::vector< std::string > &colNames, std::string_view variationName, F expression, const std::vector< std::string > &variationTags, std::string_view type, const RColumnRegister &defines, RLoopManager &lm, const ColumnNames_t &inputColNames)
 
void InitSlot(TTreeReader *r, unsigned int slot) final
 
RVariation & operator=(const RVariation &)=delete
 
typename CallableTraits< F >::ret_type Ret_t
 
std::vector< std::array< RColumnReaderBase *, ColumnTypes_t::list_size > > fValues
Column readers per slot and per input column.
 
void UpdateHelper(unsigned int slot, Long64_t entry, TypeList< ColTypes... >, std::index_sequence< S... >)
 
typename CallableTraits< F >::arg_types ColumnTypes_t
 
std::vector< Result_t > fLastResults
Per-slot storage for varied column values (for one or multiple columns depending on IsSingleColumn).
 
RVariation(const RVariation &)=delete
 
A "std::vector"-like collection of values implementing handy operation to analyse them.
 
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
 
typename ColumnType< Ret_t, IsSingleColumn >::type ColumnType_t
When varying a single column, Ret_t is RVec<T> and ColumnType_t is T.
 
std::size_t GetNVariations(const RVec< T > &results)
 
void ResizeResults(ROOT::RVec< T > &results, std::size_t, std::size_t nVariations)
 
void * GetValuePtrHelper(ROOT::RVec< T > &v, std::size_t, std::size_t varIdx)
 
constexpr std::size_t CacheLineStep()
Stepping through CacheLineStep<T> values in a vector<T> brings you to a new cache line.
 
void AssignResults(ROOT::RVec< T > &resStorage, ROOT::RVec< T > &&tmpResults)
Assign into fLastResults[slot] without changing the addresses of its elements (we gave those addresse...
 
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.
 
bool ResultsSizeEq(const T &results, std::size_t expected, std::size_t nColumns, std::true_type)
 
std::vector< std::string > ColumnNames_t
 
ROOT type_traits extensions.
 
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
 
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.