Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
RRootDS.hxx
Go to the documentation of this file.
1 // Author: Enrico Guiraud, Danilo Piparo CERN 9/2017
2 
3 /*************************************************************************
4  * Copyright (C) 1995-2018, 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_RROOTTDS
12 #define ROOT_RROOTTDS
13 
14 #include "ROOT/RDataFrame.hxx"
15 #include "ROOT/RDataSource.hxx"
16 #include <TChain.h>
17 
18 #include <memory>
19 
20 namespace ROOT {
21 
22 namespace RDF {
23 
24 class RRootDS final : public ROOT::RDF::RDataSource {
25 private:
26  unsigned int fNSlots = 0U;
27  std::string fTreeName;
28  std::string fFileNameGlob;
29  mutable TChain fModelChain; // Mutable needed for getting the column type name
30  std::vector<double *> fAddressesToFree;
31  std::vector<std::string> fListOfBranches;
32  std::vector<std::pair<ULong64_t, ULong64_t>> fEntryRanges;
33  std::vector<std::vector<void *>> fBranchAddresses; // first container-> slot, second -> column;
34  std::vector<std::unique_ptr<TChain>> fChains;
35 
36  std::vector<void *> GetColumnReadersImpl(std::string_view, const std::type_info &);
37 
38 protected:
39  std::string AsString() { return "ROOT data source"; };
40 
41 public:
42  RRootDS(std::string_view treeName, std::string_view fileNameGlob);
43  ~RRootDS();
44  std::string GetTypeName(std::string_view colName) const;
45  const std::vector<std::string> &GetColumnNames() const;
46  bool HasColumn(std::string_view colName) const;
47  void InitSlot(unsigned int slot, ULong64_t firstEntry);
48  void FinaliseSlot(unsigned int slot);
49  std::vector<std::pair<ULong64_t, ULong64_t>> GetEntryRanges();
50  bool SetEntry(unsigned int slot, ULong64_t entry);
51  void SetNSlots(unsigned int nSlots);
52  void Initialise();
53  std::string GetLabel();
54 };
55 
56 RDataFrame MakeRootDataFrame(std::string_view treeName, std::string_view fileNameGlob);
57 
58 } // ns RDF
59 
60 } // ns ROOT
61 
62 #endif