Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 09:08:22

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 
0023 #include <ROOT/RDataSource.hxx>
0024 #include <ROOT/TypeTraits.hxx>
0025 
0026 #include <array>
0027 #include <cassert>
0028 #include <map>
0029 #include <memory>
0030 #include <string>
0031 #include <typeinfo> // for typeid
0032 #include <vector>
0033 
0034 class TTreeReader;
0035 
0036 namespace ROOT {
0037 namespace Internal {
0038 namespace RDF {
0039 
0040 using namespace ROOT::TypeTraits;
0041 namespace RDFDetail = ROOT::Detail::RDF;
0042 
0043 RDFDetail::RColumnReaderBase *GetColumnReader(unsigned int slot, RColumnReaderBase *defineOrVariationReader,
0044                                               RLoopManager &lm, TTreeReader *treeReader, std::string_view colName,
0045                                               const std::type_info &ti);
0046 
0047 /// This type aggregates some of the arguments passed to GetColumnReaders.
0048 /// We need to pass a single RColumnReadersInfo object rather than each argument separately because with too many
0049 /// arguments passed, gcc 7.5.0 and cling disagree on the ABI, which leads to the last function argument being read
0050 /// incorrectly from a compiled GetColumnReaders symbols when invoked from a jitted symbol.
0051 struct RColumnReadersInfo {
0052    const std::vector<std::string> &fColNames;
0053    RColumnRegister &fColRegister;
0054    const bool *fIsDefine;
0055    RLoopManager &fLoopManager;
0056 };
0057 
0058 /// Create a group of column readers, one per type in the parameter pack.
0059 template <typename... ColTypes>
0060 std::array<RDFDetail::RColumnReaderBase *, sizeof...(ColTypes)>
0061 GetColumnReaders(unsigned int slot, TTreeReader *treeReader, TypeList<ColTypes...>, const RColumnReadersInfo &colInfo,
0062                  const std::string &variationName = "nominal")
0063 {
0064    // see RColumnReadersInfo for why we pass these arguments like this rather than directly as function arguments
0065    const auto &colNames = colInfo.fColNames;
0066    auto &lm = colInfo.fLoopManager;
0067    auto &colRegister = colInfo.fColRegister;
0068 
0069    int i = -1;
0070 
0071    std::array<RDFDetail::RColumnReaderBase *, sizeof...(ColTypes)> ret{
0072       (++i, GetColumnReader(slot, colRegister.GetReader(slot, colNames[i], variationName, typeid(ColTypes)), lm,
0073                             treeReader, colNames[i], typeid(ColTypes)))...};
0074    return ret;
0075 }
0076 
0077 // Shortcut overload for the case of no columns
0078 inline std::array<RDFDetail::RColumnReaderBase *, 0>
0079 GetColumnReaders(unsigned int, TTreeReader *, TypeList<>, const RColumnReadersInfo &, const std::string & = "nominal")
0080 {
0081    return {};
0082 }
0083 
0084 } // namespace RDF
0085 } // namespace Internal
0086 } // namespace ROOT
0087 
0088 #endif // ROOT_RDF_COLUMNREADERS