Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RDatasetSpec.cxx
Go to the documentation of this file.
1// Author: Vincenzo Eduardo Padulano CERN/UPV, Ivan Kabadzhov CERN 06/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
12#include <stdexcept> // std::logic_error
13
14namespace ROOT {
15
16namespace RDF {
17
18namespace Experimental {
19
21
23
24RDatasetSpec::REntryRange::REntryRange(Long64_t begin, Long64_t end) : fBegin(begin), fEnd(end)
25{
26 if (fBegin > fEnd)
27 throw std::logic_error("The starting entry cannot be larger than the ending entry in the "
28 "creation of a dataset specification.");
29}
30
31const std::vector<std::string> RDatasetSpec::GetSampleNames() const
32{
33 std::vector<std::string> sampleNames;
34 sampleNames.reserve(fSamples.size());
35 for (const auto &sample : fSamples)
36 sampleNames.emplace_back(sample.GetSampleName());
37 return sampleNames;
38}
39
40const std::vector<std::string> RDatasetSpec::GetTreeNames() const
41{
42 std::vector<std::string> treeNames;
43 for (const auto &sample : fSamples) {
44 const auto &trees = sample.GetTreeNames();
45 treeNames.insert(std::end(treeNames), std::begin(trees), std::end(trees));
46 }
47 return treeNames;
48}
49
50const std::vector<std::string> RDatasetSpec::GetFileNameGlobs() const
51{
52 std::vector<std::string> fileNames;
53 for (const auto &sample : fSamples) {
54 const auto &files = sample.GetFileNameGlobs();
55 fileNames.insert(std::end(fileNames), std::begin(files), std::end(files));
56 }
57 return fileNames;
58}
59
60const std::vector<RMetaData> RDatasetSpec::GetMetaData() const
61{
62 std::vector<RMetaData> metaDatas;
63 metaDatas.reserve(fSamples.size());
64 for (const auto &sample : fSamples)
65 metaDatas.emplace_back(sample.GetMetaData());
66 return metaDatas;
67}
68
70{
71 return fFriendInfo;
72}
73
75{
76 return fEntryRange.fBegin;
77}
78
80{
81 return fEntryRange.fEnd;
82}
83
84std::vector<RSample> RDatasetSpec::MoveOutSamples()
85{
86 return std::move(fSamples);
87}
88
90{
91 sample.SetSampleId(fSamples.size());
92 fSamples.push_back(std::move(sample));
93 return *this;
94}
95
97RDatasetSpec::WithGlobalFriends(const std::string &treeName, const std::string &fileNameGlob, const std::string &alias)
98{
99 fFriendInfo.AddFriend(treeName, fileNameGlob, alias);
100 return *this;
101}
102
104 const std::vector<std::string> &fileNameGlobs, const std::string &alias)
105{
106 fFriendInfo.AddFriend(treeName, fileNameGlobs, alias);
107 return *this;
108}
109
111RDatasetSpec::WithGlobalFriends(const std::vector<std::pair<std::string, std::string>> &treeAndFileNameGlobs,
112 const std::string &alias)
113{
114 fFriendInfo.AddFriend(treeAndFileNameGlobs, alias);
115 return *this;
116}
117
119{
120 fEntryRange = entryRange;
121 return *this;
122}
123
124RDatasetSpec &RDatasetSpec::WithGlobalFriends(const std::vector<std::string> &treeNames,
125 const std::vector<std::string> &fileNameGlobs, const std::string &alias)
126{
127 if (treeNames.size() != 1 && treeNames.size() != fileNameGlobs.size())
128 throw std::logic_error("Mismatch between number of trees and file globs.");
129 std::vector<std::pair<std::string, std::string>> target;
130 target.reserve(fileNameGlobs.size());
131 for (auto i = 0u; i < fileNameGlobs.size(); ++i)
132 target.emplace_back(std::make_pair((treeNames.size() == 1u ? treeNames[0] : treeNames[i]), fileNameGlobs[i]));
134 return *this;
135}
136
137} // namespace Experimental
138} // namespace RDF
139} // namespace ROOT
long long Long64_t
Definition RtypesCore.h:80
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
A dataset specification for RDataFrame.
const std::vector< std::string > GetFileNameGlobs() const
std::vector< RSample > MoveOutSamples()
REntryRange fEntryRange
Start (inclusive) and end (exclusive) entry for the dataset processing.
RDatasetSpec & WithGlobalFriends(const std::string &treeName, const std::string &fileNameGlob, const std::string &alias="")
const std::vector< std::string > GetTreeNames() const
const ROOT::TreeUtils::RFriendInfo & GetFriendInfo() const
const std::vector< RMetaData > GetMetaData() const
RDatasetSpec & AddSample(RSample sample)
ROOT::TreeUtils::RFriendInfo fFriendInfo
List of friends.
RDatasetSpec & WithGlobalRange(const RDatasetSpec::REntryRange &entryRange={})
std::vector< RSample > fSamples
List of samples.
const std::vector< std::string > GetSampleNames() const
Class representing a sample (grouping of trees (and their fileglobs) and (optional) metadata)
Definition RSample.hxx:29
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
Information about friend trees of a certain TTree or TChain object.
void AddFriend(const std::string &treeName, const std::string &fileNameGlob, const std::string &alias="", std::int64_t nEntries=std::numeric_limits< std::int64_t >::max(), TVirtualIndex *indexInfo=nullptr)
Add information of a single friend.