Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:22:39

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    unsigned int fNSlots = 0U;
0031    std::string fTreeName;
0032    std::string fFileNameGlob;
0033    mutable TChain fModelChain; // Mutable needed for getting the column type name
0034    std::vector<double *> fAddressesToFree;
0035    std::vector<std::string> fListOfBranches;
0036    std::vector<std::pair<ULong64_t, ULong64_t>> fEntryRanges;
0037    std::vector<std::vector<void *>> fBranchAddresses; // first container-> slot, second -> column;
0038    std::vector<std::unique_ptr<TChain>> fChains;
0039 
0040    std::vector<void *> GetColumnReadersImpl(std::string_view, const std::type_info &) final;
0041 
0042 protected:
0043    std::string AsString() final { return "ROOT data source"; };
0044 
0045 public:
0046    RRootDS(std::string_view treeName, std::string_view fileNameGlob);
0047    ~RRootDS();
0048    std::string GetTypeName(std::string_view colName) const final;
0049    const std::vector<std::string> &GetColumnNames() const final;
0050    bool HasColumn(std::string_view colName) const final;
0051    void InitSlot(unsigned int slot, ULong64_t firstEntry) final;
0052    void FinalizeSlot(unsigned int slot) final;
0053    std::vector<std::pair<ULong64_t, ULong64_t>> GetEntryRanges() final;
0054    bool SetEntry(unsigned int slot, ULong64_t entry) final;
0055    void SetNSlots(unsigned int nSlots) final;
0056    void Initialize() final;
0057    std::string GetLabel() final;
0058 };
0059 
0060 } // ns RDF
0061 
0062 } // ns Internal
0063 
0064 } // ns ROOT
0065 
0066 #endif