Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:29:47

0001 // Author: Enrico Guiraud CERN 09/2020
0002 
0003 /*************************************************************************
0004  * Copyright (C) 1995-2020, Rene Brun and Fons Rademakers.               *
0005  * All rights reserved.                                                  *
0006  *                                                                       *
0007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0009  *************************************************************************/
0010 
0011 #ifndef ROOT_RDF_COLUMNREADERUTILS
0012 #define ROOT_RDF_COLUMNREADERUTILS
0013 
0014 #include "RColumnReaderBase.hxx"
0015 #include "RColumnRegister.hxx"
0016 #include "RDefineBase.hxx"
0017 #include "RDefineReader.hxx"
0018 #include "RDSColumnReader.hxx"
0019 #include "RLoopManager.hxx"
0020 #include "RVariationBase.hxx"
0021 #include "RVariationReader.hxx"
0022 #include <ROOT/RDF/Utils.hxx>
0023 
0024 #include <ROOT/RDataSource.hxx>
0025 #include <ROOT/TypeTraits.hxx>
0026 
0027 #include <array>
0028 #include <cassert>
0029 #include <map>
0030 #include <memory>
0031 #include <string>
0032 #include <typeinfo> // for typeid
0033 #include <vector>
0034 
0035 class TTreeReader;
0036 
0037 namespace ROOT {
0038 namespace Internal {
0039 namespace RDF {
0040 
0041 using namespace ROOT::TypeTraits;
0042 namespace RDFDetail = ROOT::Detail::RDF;
0043 
0044 RDFDetail::RColumnReaderBase *GetColumnReader(unsigned int slot, RColumnReaderBase *defineOrVariationReader,
0045                                               RLoopManager &lm, TTreeReader *treeReader, std::string_view colName,
0046                                               const std::type_info &ti);
0047 
0048 /// This type aggregates some of the arguments passed to GetColumnReaders.
0049 /// We need to pass a single RColumnReadersInfo object rather than each argument separately because with too many
0050 /// arguments passed, gcc 7.5.0 and cling disagree on the ABI, which leads to the last function argument being read
0051 /// incorrectly from a compiled GetColumnReaders symbols when invoked from a jitted symbol.
0052 struct RColumnReadersInfo {
0053    const std::vector<std::string> &fColNames;
0054    RColumnRegister &fColRegister;
0055    const bool *fIsDefine;
0056    RLoopManager &fLoopManager;
0057 };
0058 
0059 /// Create a group of column readers, one per type in the parameter pack.
0060 template <typename... ColTypes>
0061 std::array<RDFDetail::RColumnReaderBase *, sizeof...(ColTypes)>
0062 GetColumnReaders(unsigned int slot, TTreeReader *treeReader, TypeList<ColTypes...>, const RColumnReadersInfo &colInfo,
0063                  const std::string &variationName = "nominal")
0064 {
0065    // see RColumnReadersInfo for why we pass these arguments like this rather than directly as function arguments
0066    const auto &colNames = colInfo.fColNames;
0067    auto &lm = colInfo.fLoopManager;
0068    auto &colRegister = colInfo.fColRegister;
0069 
0070    int i = -1;
0071 
0072    std::array<RDFDetail::RColumnReaderBase *, sizeof...(ColTypes)> ret{
0073       (++i, GetColumnReader(slot, colRegister.GetReader(slot, colNames[i], variationName, typeid(ColTypes)), lm,
0074                             treeReader, colNames[i], typeid(ColTypes)))...};
0075    return ret;
0076 }
0077 
0078 // Shortcut overload for the case of no columns
0079 inline std::array<RDFDetail::RColumnReaderBase *, 0>
0080 GetColumnReaders(unsigned int, TTreeReader *, TypeList<>, const RColumnReadersInfo &, const std::string & = "nominal")
0081 {
0082    return {};
0083 }
0084 
0085 std::vector<RDFDetail::RColumnReaderBase *>
0086 GetUntypedColumnReaders(unsigned int slot, TTreeReader *treeReader, ROOT::Internal::RDF::RColumnRegister &colRegister,
0087                         ROOT::Detail::RDF::RLoopManager &lm, const std::vector<std::string> &colNames,
0088                         const std::vector<const std::type_info *> &colTypeIDs,
0089                         const std::string &variationName = "nominal");
0090 
0091 } // namespace RDF
0092 } // namespace Internal
0093 } // namespace ROOT
0094 
0095 #endif // ROOT_RDF_COLUMNREADERS