Logo ROOT  
Reference Guide
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::GetGroupNames() const
32{
33 std::vector<std::string> groupNames;
34 groupNames.reserve(fDatasetGroups.size());
35 for (const auto &group : fDatasetGroups)
36 groupNames.emplace_back(group.GetGroupName());
37 return groupNames;
38}
39
40const std::vector<std::string> RDatasetSpec::GetTreeNames() const
41{
42 std::vector<std::string> treeNames;
43 for (const auto &group : fDatasetGroups) {
44 const auto &trees = group.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 &group : fDatasetGroups) {
54 const auto &files = group.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(fDatasetGroups.size());
64 for (const auto &group : fDatasetGroups)
65 metaDatas.emplace_back(group.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
84const std::vector<RDatasetGroup> &RDatasetSpec::GetDatasetGroups() const
85{
86 return fDatasetGroups;
87}
88
90{
91 datasetGroup.SetGroupId(fDatasetGroups.size());
92 fDatasetGroups.push_back(std::move(datasetGroup));
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
Class representing a dataset group (mapping of trees (and their fileglobs) to metadata)
A dataset specification for RDataFrame.
const std::vector< std::string > GetFileNameGlobs() const
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
ROOT::TreeUtils::RFriendInfo fFriendInfo
List of friends.
RDatasetSpec & WithGlobalRange(const RDatasetSpec::REntryRange &entryRange={})
const std::vector< std::string > GetGroupNames() const
RDatasetSpec & AddGroup(RDatasetGroup datasetGroup)
std::vector< RDatasetGroup > fDatasetGroups
List of groups.
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.
Definition: RFriendInfo.hxx:34
void AddFriend(const std::string &treeName, const std::string &fileNameGlob, const std::string &alias="")
Add information of a single friend.
Definition: RFriendInfo.cxx:21