Logo ROOT   6.14/05
Reference Guide
RRootDS.hxx
Go to the documentation of this file.
1 // Author: Enrico Guiraud, Danilo Piparo CERN 9/2017
2 
3 /*************************************************************************
4  * Copyright (C) 1995-2016, 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 public:
39  RRootDS(std::string_view treeName, std::string_view fileNameGlob);
40  ~RRootDS();
41  std::string GetTypeName(std::string_view colName) const;
42  const std::vector<std::string> &GetColumnNames() const;
43  bool HasColumn(std::string_view colName) const;
44  void InitSlot(unsigned int slot, ULong64_t firstEntry);
45  void FinaliseSlot(unsigned int slot);
46  std::vector<std::pair<ULong64_t, ULong64_t>> GetEntryRanges();
47  bool SetEntry(unsigned int slot, ULong64_t entry);
48  void SetNSlots(unsigned int nSlots);
49  void Initialise();
50 };
51 
53 
54 } // ns RDF
55 
56 } // ns ROOT
57 
58 #endif
RRootDS(std::string_view treeName, std::string_view fileNameGlob)
Definition: RRootDS.cxx:38
bool SetEntry(unsigned int slot, ULong64_t entry)
Advance the "cursors" returned by GetColumnReaders to the selected entry for a particular slot...
Definition: RRootDS.cxx:122
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
const std::vector< std::string > & GetColumnNames() const
Returns a reference to the collection of the dataset&#39;s column names.
Definition: RRootDS.cxx:74
RDataFrame MakeRootDataFrame(std::string_view treeName, std::string_view fileNameGlob)
Definition: RRootDS.cxx:157
std::vector< double * > fAddressesToFree
Definition: RRootDS.hxx:30
std::vector< std::vector< void * > > fBranchAddresses
Definition: RRootDS.hxx:33
std::vector< std::string > fListOfBranches
Definition: RRootDS.hxx:31
bool HasColumn(std::string_view colName) const
Checks if the dataset has a certain column.
Definition: RRootDS.cxx:79
TChain fModelChain
Definition: RRootDS.hxx:29
std::string fTreeName
Definition: RRootDS.hxx:27
std::string GetTypeName(std::string_view colName) const
Type of a column as a string, e.g.
Definition: RRootDS.cxx:57
ROOT&#39;s RDataFrame offers a high level interface for analyses of data stored in TTrees, CSV&#39;s and other data formats.
Definition: RDataFrame.hxx:42
std::vector< std::pair< ULong64_t, ULong64_t > > GetEntryRanges()
Return ranges of entries to distribute to tasks.
Definition: RRootDS.cxx:116
std::string fFileNameGlob
Definition: RRootDS.hxx:28
unsigned long long ULong64_t
Definition: RtypesCore.h:70
basic_string_view< char > string_view
Definition: RStringView.hxx:35
void Initialise()
Convenience method called before starting an event-loop.
Definition: RRootDS.cxx:141
unsigned int fNSlots
Definition: RRootDS.hxx:26
A chain is a collection of files containing TTree objects.
Definition: TChain.h:33
void InitSlot(unsigned int slot, ULong64_t firstEntry)
Convenience method called at the start of the data processing associated to a slot.
Definition: RRootDS.cxx:86
std::vector< std::pair< ULong64_t, ULong64_t > > fEntryRanges
Definition: RRootDS.hxx:32
void SetNSlots(unsigned int nSlots)
Inform RDataSource of the number of processing slots (i.e.
Definition: RRootDS.cxx:128
RDataSource defines an API that RDataFrame can use to read arbitrary data formats.
Definition: RDataSource.hxx:91
std::vector< std::unique_ptr< TChain > > fChains
Definition: RRootDS.hxx:34
std::vector< void * > GetColumnReadersImpl(std::string_view, const std::type_info &)
type-erased vector of pointers to pointers to column values - one per slot
Definition: RRootDS.cxx:16
void FinaliseSlot(unsigned int slot)
Convenience method called at the end of the data processing associated to a slot. ...
Definition: RRootDS.cxx:111