Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RSample.hxx
Go to the documentation of this file.
1// Author: Ivan Kabadzhov CERN 11/2022
2
3/*************************************************************************
4 * Copyright (C) 1995-2022, 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_RDF_RSAMPLE
12#define ROOT_RDF_RSAMPLE
13
15
16#include <string>
17#include <vector>
18
19namespace ROOT {
20namespace RDF {
21namespace Experimental {
22
23/**
24\ingroup dataframe
25\brief Class representing a sample which is a grouping of trees and their fileglobs, and, optionally, the sample's
26metadata information via the RMetaData object.
27
28 The class is passed to an RDatasetSpec object in order to build an RDataFrame.
29
30 For example, an RSample object can be built as follows:
31 ~~~{.cpp}
32 // First, create the RMetaData object (to, optionally, add to the sample)
33 ROOT::RDF::Experimental::RMetaData meta;
34 meta.Add("sample_name", "name"");
35 // Create an RSample with metadata information
36 ROOT::RDF::Experimental::RSample mySample("mySampleName", "outputTree1", "outputFile.root", meta);
37 ~~~
38*/
39class RSample {
40 /// Name of the sample.
41 std::string fSampleName;
42 /**
43 * A list of names of trees.
44 * This list should go in lockstep with fFileNameGlobs, only in case this dataset is a TChain where each file
45 * contains its own tree with a different name from the global name of the dataset.
46 * Otherwise, fTreeNames contains 1 treename, that is common for all file globs.
47 */
48 std::vector<std::string> fTreeNames;
49 /**
50 * A list of file names.
51 * They can contain the globbing characters supported by TChain. See TChain::Add for more information.
52 */
53 std::vector<std::string> fFileNameGlobs;
54 /// An instance of the RMetaData class.
56
57 /// Global sample index, set inside of the RDatasetSpec.
58 unsigned int fSampleId{0};
59
60public:
61 RSample(RSample &&) = default;
62 RSample &operator=(RSample &&) = default;
63 RSample(const RSample &) = default;
64 RSample &operator=(const RSample &) = default;
65 RSample() = delete;
66
67 RSample(const std::string &sampleName, const std::string &treeName, const std::string &fileNameGlob,
68 const RMetaData &metaData = {});
69
70 RSample(const std::string &sampleName, const std::string &treeName, const std::vector<std::string> &fileNameGlobs,
71 const RMetaData &metaData = {});
72
73 RSample(const std::string &sampleName, const std::vector<std::pair<std::string, std::string>> &treeAndFileNameGlobs,
74 const RMetaData &metaData = {});
75
76 RSample(const std::string &sampleName, const std::vector<std::string> &treeNames,
77 const std::vector<std::string> &fileNameGlobs, const RMetaData &metaData = {});
78
79 const std::string &GetSampleName() const;
80 const std::vector<std::string> &GetTreeNames() const;
81 const std::vector<std::string> &GetFileNameGlobs() const;
82 const RMetaData &GetMetaData() const;
83
84 /// \cond HIDDEN_SYMBOLS
85 unsigned int GetSampleId() const; // intended to be used only after the RDataSpec is build, otherwise is 0
86 void SetSampleId(unsigned int id);
87 /// \endcond
88};
89
90} // namespace Experimental
91} // namespace RDF
92} // namespace ROOT
93
94#endif // ROOT_RDF_RSAMPLE
Class behaving as a heterogenuous dictionary to store the metadata of a dataset.
Definition RMetaData.hxx:50
Class representing a sample which is a grouping of trees and their fileglobs, and,...
Definition RSample.hxx:39
const std::string & GetSampleName() const
Get the name of the sample (RSample object).
Definition RSample.cxx:75
const std::vector< std::string > & GetFileNameGlobs() const
Get the collection of the filename globs associated with the sample.
Definition RSample.cxx:87
RMetaData fMetaData
An instance of the RMetaData class.
Definition RSample.hxx:55
std::vector< std::string > fFileNameGlobs
A list of file names.
Definition RSample.hxx:53
const std::vector< std::string > & GetTreeNames() const
Get the collection of the tree names associated with the sample.
Definition RSample.cxx:81
RSample & operator=(const RSample &)=default
RSample(const RSample &)=default
unsigned int fSampleId
Global sample index, set inside of the RDatasetSpec.
Definition RSample.hxx:58
std::string fSampleName
Name of the sample.
Definition RSample.hxx:41
RSample & operator=(RSample &&)=default
const RMetaData & GetMetaData() const
Get an instance of the RMetaData class.
Definition RSample.cxx:99
std::vector< std::string > fTreeNames
A list of names of trees.
Definition RSample.hxx:48
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...