Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 09:11:46

0001 // Author: Enrico Guiraud, Danilo Piparo CERN  9/2017
0002 
0003 /*************************************************************************
0004  * Copyright (C) 1995-2018, 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_RROOTTDS
0012 #define ROOT_RROOTTDS
0013 
0014 #include "ROOT/RDataFrame.hxx"
0015 #include "ROOT/RDataSource.hxx"
0016 #include <TChain.h>
0017 
0018 #include <memory>
0019 
0020 namespace ROOT {
0021 
0022 namespace Internal {
0023 
0024 namespace RDF {
0025 
0026 /// This class is unused and it has only been implemented as a proof of concept.
0027 /// It shows how to implement the RDataSource API for a complex kind of source such as TTrees.
0028 class RRootDS final : public ROOT::RDF::RDataSource {
0029 private:
0030    std::string fTreeName;
0031    std::string fFileNameGlob;
0032    mutable TChain fModelChain; // Mutable needed for getting the column type name
0033    std::vector<double *> fAddressesToFree;
0034    std::vector<std::string> fListOfBranches;
0035    std::vector<std::pair<ULong64_t, ULong64_t>> fEntryRanges;
0036    std::vector<std::vector<void *>> fBranchAddresses; // first container-> slot, second -> column;
0037    std::vector<std::unique_ptr<TChain>> fChains;
0038 
0039    std::vector<void *> GetColumnReadersImpl(std::string_view, const std::type_info &) final;
0040 
0041 protected:
0042    std::string AsString() final { return "ROOT data source"; };
0043 
0044 public:
0045    RRootDS(std::string_view treeName, std::string_view fileNameGlob);
0046    // Rule of five
0047    RRootDS(const RRootDS &) = delete;
0048    RRootDS &operator=(const RRootDS &) = delete;
0049    RRootDS(RRootDS &&) = delete;
0050    RRootDS &operator=(RRootDS &&) = delete;
0051    ~RRootDS() final;
0052 
0053    std::size_t GetNFiles() const final;
0054    std::string GetTypeName(std::string_view colName) const final;
0055    const std::vector<std::string> &GetColumnNames() const final;
0056    bool HasColumn(std::string_view colName) const final;
0057    void InitSlot(unsigned int slot, ULong64_t firstEntry) final;
0058    void FinalizeSlot(unsigned int slot) final;
0059    std::vector<std::pair<ULong64_t, ULong64_t>> GetEntryRanges() final;
0060    bool SetEntry(unsigned int slot, ULong64_t entry) final;
0061    void SetNSlots(unsigned int nSlots) final;
0062    void Initialize() final;
0063    std::string GetLabel() final;
0064 };
0065 
0066 } // ns RDF
0067 
0068 } // ns Internal
0069 
0070 } // ns ROOT
0071 
0072 #endif