Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
20namespace ROOT {
21
22namespace Internal {
23
24namespace RDF {
25
26class RRootDS final : public ROOT::RDF::RDataSource {
27private:
28 unsigned int fNSlots = 0U;
29 std::string fTreeName;
30 std::string fFileNameGlob;
31 mutable TChain fModelChain; // Mutable needed for getting the column type name
32 std::vector<double *> fAddressesToFree;
33 std::vector<std::string> fListOfBranches;
34 std::vector<std::pair<ULong64_t, ULong64_t>> fEntryRanges;
35 std::vector<std::vector<void *>> fBranchAddresses; // first container-> slot, second -> column;
36 std::vector<std::unique_ptr<TChain>> fChains;
37
38 std::vector<void *> GetColumnReadersImpl(std::string_view, const std::type_info &);
39
40protected:
41 std::string AsString() { return "ROOT data source"; };
42
43public:
44 RRootDS(std::string_view treeName, std::string_view fileNameGlob);
45 ~RRootDS();
46 std::string GetTypeName(std::string_view colName) const;
47 const std::vector<std::string> &GetColumnNames() const;
48 bool HasColumn(std::string_view colName) const;
49 void InitSlot(unsigned int slot, ULong64_t firstEntry);
50 void FinaliseSlot(unsigned int slot);
51 std::vector<std::pair<ULong64_t, ULong64_t>> GetEntryRanges();
52 bool SetEntry(unsigned int slot, ULong64_t entry);
53 void SetNSlots(unsigned int nSlots);
54 void Initialise();
55 std::string GetLabel();
56};
57
58RDataFrame MakeRootDataFrame(std::string_view treeName, std::string_view fileNameGlob);
59
60} // ns RDF
61
62} // ns Internal
63
64} // ns ROOT
65
66#endif
unsigned long long ULong64_t
Definition RtypesCore.h:74
void FinaliseSlot(unsigned int slot)
Convenience method called at the end of the data processing associated to a slot.
Definition RRootDS.cxx:113
void Initialise()
Convenience method called before starting an event-loop.
Definition RRootDS.cxx:143
bool HasColumn(std::string_view colName) const
Checks if the dataset has a certain column.
Definition RRootDS.cxx:81
const std::vector< std::string > & GetColumnNames() const
Returns a reference to the collection of the dataset's column names.
Definition RRootDS.cxx:76
std::string GetLabel()
Return a string representation of the datasource type.
Definition RRootDS.cxx:159
std::string GetTypeName(std::string_view colName) const
Type of a column as a string, e.g.
Definition RRootDS.cxx:60
std::vector< std::vector< void * > > fBranchAddresses
Definition RRootDS.hxx:35
std::vector< std::unique_ptr< TChain > > fChains
Definition RRootDS.hxx:36
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:19
void SetNSlots(unsigned int nSlots)
Inform RDataSource of the number of processing slots (i.e.
Definition RRootDS.cxx:130
std::vector< std::string > fListOfBranches
Definition RRootDS.hxx:33
std::vector< double * > fAddressesToFree
Definition RRootDS.hxx:32
std::vector< std::pair< ULong64_t, ULong64_t > > GetEntryRanges()
Return ranges of entries to distribute to tasks.
Definition RRootDS.cxx:118
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:88
std::vector< std::pair< ULong64_t, ULong64_t > > fEntryRanges
Definition RRootDS.hxx:34
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:124
RDataSource defines an API that RDataFrame can use to read arbitrary data formats.
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTrees,...
A chain is a collection of files containing TTree objects.
Definition TChain.h:33
RDataFrame MakeRootDataFrame(std::string_view treeName, std::string_view fileNameGlob)
Definition RRootDS.cxx:164
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...