Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ColumnReaderUtils.hxx
Go to the documentation of this file.
1// Author: Enrico Guiraud CERN 09/2020
2
3/*************************************************************************
4 * Copyright (C) 1995-2020, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#ifndef ROOT_RDF_COLUMNREADERUTILS
12#define ROOT_RDF_COLUMNREADERUTILS
13
14#include "RColumnReaderBase.hxx"
15#include "RColumnRegister.hxx"
16#include "RDefineBase.hxx"
17#include "RDefineReader.hxx"
18#include "RDSColumnReader.hxx"
19#include "RLoopManager.hxx"
20#include "RVariationBase.hxx"
21#include "RVariationReader.hxx"
22#include <ROOT/RDF/Utils.hxx>
23
24#include <ROOT/RDataSource.hxx>
25#include <ROOT/TypeTraits.hxx>
26
27#include <array>
28#include <cassert>
29#include <map>
30#include <memory>
31#include <string>
32#include <typeinfo> // for typeid
33#include <vector>
34
35class TTreeReader;
36
37namespace ROOT {
38namespace Internal {
39namespace RDF {
40
41using namespace ROOT::TypeTraits;
43
45 RLoopManager &lm, TTreeReader *treeReader, std::string_view colName,
46 const std::type_info &ti);
47
48/// This type aggregates some of the arguments passed to GetColumnReaders.
49/// We need to pass a single RColumnReadersInfo object rather than each argument separately because with too many
50/// arguments passed, gcc 7.5.0 and cling disagree on the ABI, which leads to the last function argument being read
51/// incorrectly from a compiled GetColumnReaders symbols when invoked from a jitted symbol.
53 const std::vector<std::string> &fColNames;
55 const bool *fIsDefine;
57};
58
59/// Create a group of column readers, one per type in the parameter pack.
60template <typename... ColTypes>
61std::array<RDFDetail::RColumnReaderBase *, sizeof...(ColTypes)>
63 const std::string &variationName = "nominal")
64{
65 // see RColumnReadersInfo for why we pass these arguments like this rather than directly as function arguments
66 const auto &colNames = colInfo.fColNames;
67 auto &lm = colInfo.fLoopManager;
68 auto &colRegister = colInfo.fColRegister;
69
70 int i = -1;
71
72 std::array<RDFDetail::RColumnReaderBase *, sizeof...(ColTypes)> ret{
73 (++i, GetColumnReader(slot, colRegister.GetReader(slot, colNames[i], variationName, typeid(ColTypes)), lm,
74 treeReader, colNames[i], typeid(ColTypes)))...};
75 return ret;
76}
77
78// Shortcut overload for the case of no columns
79inline std::array<RDFDetail::RColumnReaderBase *, 0>
80GetColumnReaders(unsigned int, TTreeReader *, TypeList<>, const RColumnReadersInfo &, const std::string & = "nominal")
81{
82 return {};
83}
84
85std::vector<RDFDetail::RColumnReaderBase *>
87 ROOT::Detail::RDF::RLoopManager &lm, const std::vector<std::string> &colNames,
88 const std::vector<const std::type_info *> &colTypeIDs,
89 const std::string &variationName = "nominal");
90
91} // namespace RDF
92} // namespace Internal
93} // namespace ROOT
94
95#endif // ROOT_RDF_COLUMNREADERS
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
The head node of a RDF computation graph.
Pure virtual base class for all column reader types.
A binder for user-defined columns, variations and aliases.
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
Definition TTreeReader.h:46
RDFDetail::RColumnReaderBase * GetColumnReader(unsigned int slot, RColumnReaderBase *defineOrVariationReader, RLoopManager &lm, TTreeReader *treeReader, std::string_view colName, const std::type_info &ti)
std::vector< RDFDetail::RColumnReaderBase * > GetUntypedColumnReaders(unsigned int slot, TTreeReader *treeReader, ROOT::Internal::RDF::RColumnRegister &colRegister, ROOT::Detail::RDF::RLoopManager &lm, const std::vector< std::string > &colNames, const std::vector< const std::type_info * > &colTypeIDs, const std::string &variationName="nominal")
std::array< RDFDetail::RColumnReaderBase *, sizeof...(ColTypes)> GetColumnReaders(unsigned int slot, TTreeReader *treeReader, TypeList< ColTypes... >, const RColumnReadersInfo &colInfo, const std::string &variationName="nominal")
Create a group of column readers, one per type in the parameter pack.
ROOT type_traits extensions.
Namespace for new ROOT classes and functions.
This type aggregates some of the arguments passed to GetColumnReaders.
const std::vector< std::string > & fColNames