Logo ROOT  
Reference Guide
Go to the documentation of this file.
1// Author: Enrico Guiraud, Danilo Piparo CERN 9/2017
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 *************************************************************************/
14#include "ROOT/RDataFrame.hxx"
15#include "ROOT/RDataSource.hxx"
16#include <TChain.h>
18#include <memory>
20namespace ROOT {
22namespace Internal {
24namespace RDF {
26/// This class is unused and it has only been implemented as a proof of concept.
27/// It shows how to implement the RDataSource API for a complex kind of source such as TTrees.
28class RRootDS final : public ROOT::RDF::RDataSource {
30 unsigned int fNSlots = 0U;
31 std::string fTreeName;
32 std::string fFileNameGlob;
33 mutable TChain fModelChain; // Mutable needed for getting the column type name
34 std::vector<double *> fAddressesToFree;
35 std::vector<std::string> fListOfBranches;
36 std::vector<std::pair<ULong64_t, ULong64_t>> fEntryRanges;
37 std::vector<std::vector<void *>> fBranchAddresses; // first container-> slot, second -> column;
38 std::vector<std::unique_ptr<TChain>> fChains;
40 std::vector<void *> GetColumnReadersImpl(std::string_view, const std::type_info &) final;
43 std::string AsString() final { return "ROOT data source"; };
46 RRootDS(std::string_view treeName, std::string_view fileNameGlob);
47 ~RRootDS();
48 std::string GetTypeName(std::string_view colName) const final;
49 const std::vector<std::string> &GetColumnNames() const final;
50 bool HasColumn(std::string_view colName) const final;
51 void InitSlot(unsigned int slot, ULong64_t firstEntry) final;
52 void FinalizeSlot(unsigned int slot) final;
53 std::vector<std::pair<ULong64_t, ULong64_t>> GetEntryRanges() final;
54 bool SetEntry(unsigned int slot, ULong64_t entry) final;
55 void SetNSlots(unsigned int nSlots) final;
56 void Initialize() final;
57 std::string GetLabel() final;
60} // ns RDF
62} // ns Internal
64} // ns ROOT
unsigned long long ULong64_t
Definition: RtypesCore.h:81
This class is unused and it has only been implemented as a proof of concept.
Definition: RRootDS.hxx:28
std::string AsString() final
Definition: RRootDS.hxx:43
bool SetEntry(unsigned int slot, ULong64_t entry) final
Advance the "cursors" returned by GetColumnReaders to the selected entry for a particular slot.
Definition: RRootDS.cxx:127
void SetNSlots(unsigned int nSlots) final
Inform RDataSource of the number of processing slots (i.e.
Definition: RRootDS.cxx:133
const std::vector< std::string > & GetColumnNames() const final
Returns a reference to the collection of the dataset's column names.
Definition: RRootDS.cxx:80
void FinalizeSlot(unsigned int slot) final
Convenience method called at the end of the data processing associated to a slot.
Definition: RRootDS.cxx:116
std::vector< std::pair< ULong64_t, ULong64_t > > GetEntryRanges() final
Return ranges of entries to distribute to tasks.
Definition: RRootDS.cxx:121
std::string GetTypeName(std::string_view colName) const final
Type of a column as a string, e.g.
Definition: RRootDS.cxx:64
RRootDS(std::string_view treeName, std::string_view fileNameGlob)
Definition: RRootDS.cxx:45
std::vector< std::vector< void * > > fBranchAddresses
Definition: RRootDS.hxx:37
std::vector< void * > GetColumnReadersImpl(std::string_view, const std::type_info &) final
type-erased vector of pointers to pointers to column values - one per slot
Definition: RRootDS.cxx:23
std::vector< std::unique_ptr< TChain > > fChains
Definition: RRootDS.hxx:38
bool HasColumn(std::string_view colName) const final
Checks if the dataset has a certain column.
Definition: RRootDS.cxx:85
void InitSlot(unsigned int slot, ULong64_t firstEntry) final
Convenience method called at the start of the data processing associated to a slot.
Definition: RRootDS.cxx:92
std::vector< std::string > fListOfBranches
Definition: RRootDS.hxx:35
void Initialize() final
Convenience method called before starting an event-loop.
Definition: RRootDS.cxx:146
std::vector< double * > fAddressesToFree
Definition: RRootDS.hxx:34
std::string GetLabel() final
Return a string representation of the datasource type.
Definition: RRootDS.cxx:162
std::vector< std::pair< ULong64_t, ULong64_t > > fEntryRanges
Definition: RRootDS.hxx:36
RDataSource defines an API that RDataFrame can use to read arbitrary data formats.
A chain is a collection of files containing TTree objects.
Definition: TChain.h:33
basic_string_view< char > string_view
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.