Logo ROOT  
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-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 RDF {
23
24class RRootDS final : public ROOT::RDF::RDataSource {
25private:
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
38protected:
39 std::string AsString() { return "ROOT data source"; };
40
41public:
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
57
58} // ns RDF
59
60} // ns ROOT
61
62#endif
unsigned long long ULong64_t
Definition: RtypesCore.h:70
RDataSource defines an API that RDataFrame can use to read arbitrary data formats.
std::vector< std::pair< ULong64_t, ULong64_t > > GetEntryRanges()
Return ranges of entries to distribute to tasks.
Definition: RRootDS.cxx:117
std::vector< std::unique_ptr< TChain > > fChains
Definition: RRootDS.hxx:34
const std::vector< std::string > & GetColumnNames() const
Returns a reference to the collection of the dataset's column names.
Definition: RRootDS.cxx:75
std::vector< std::pair< ULong64_t, ULong64_t > > fEntryRanges
Definition: RRootDS.hxx:32
std::string fFileNameGlob
Definition: RRootDS.hxx:28
bool HasColumn(std::string_view colName) const
Checks if the dataset has a certain column.
Definition: RRootDS.cxx:80
unsigned int fNSlots
Definition: RRootDS.hxx:26
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:17
RRootDS(std::string_view treeName, std::string_view fileNameGlob)
Definition: RRootDS.cxx:39
std::vector< std::vector< void * > > fBranchAddresses
Definition: RRootDS.hxx:33
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:123
void Initialise()
Convenience method called before starting an event-loop.
Definition: RRootDS.cxx:142
void SetNSlots(unsigned int nSlots)
Inform RDataSource of the number of processing slots (i.e.
Definition: RRootDS.cxx:129
std::string fTreeName
Definition: RRootDS.hxx:27
void FinaliseSlot(unsigned int slot)
Convenience method called at the end of the data processing associated to a slot.
Definition: RRootDS.cxx:112
std::vector< std::string > fListOfBranches
Definition: RRootDS.hxx:31
TChain fModelChain
Definition: RRootDS.hxx:29
std::string AsString()
Definition: RRootDS.hxx:39
std::string GetLabel()
Return a string representation of the datasource type.
Definition: RRootDS.cxx:158
std::vector< double * > fAddressesToFree
Definition: RRootDS.hxx:30
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:87
std::string GetTypeName(std::string_view colName) const
Type of a column as a string, e.g.
Definition: RRootDS.cxx:58
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTrees,...
Definition: RDataFrame.hxx:42
A chain is a collection of files containing TTree objects.
Definition: TChain.h:34
basic_string_view< char > string_view
RDataFrame MakeRootDataFrame(std::string_view treeName, std::string_view fileNameGlob)
Definition: RRootDS.cxx:163
VSD Structures.
Definition: StringConv.hxx:21