Skip to content

Commit 91763ad

Browse files
committed
[skip-ci][df] Swap all RDataFrame to ROOT::RDataFrame in docs to avoid confusion.
1 parent 12b3eb5 commit 91763ad

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

tree/dataframe/src/RDataFrame.cxx

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -290,25 +290,25 @@ operations should work with. Here are the most common methods to construct an RD
290290
TFile *f = TFile::Open("file.root");
291291
TTree *t = f.Get<TTree>("treeName");
292292
293-
RDataFrame d1("treeName", "file.root");
294-
RDataFrame d2("treeName", f); // same as TTreeReader
295-
RDataFrame d3(*t);
293+
ROOT::RDataFrame d1("treeName", "file.root");
294+
ROOT::RDataFrame d2("treeName", f); // same as TTreeReader
295+
ROOT::RDataFrame d3(*t);
296296
297297
// multiple files -- all constructors are equivalent
298298
TChain chain("myTree");
299299
chain.Add("file1.root");
300300
chain.Add("file2.root");
301301
302-
RDataFrame d4("myTree", {"file1.root", "file2.root"});
302+
ROOT::RDataFrame d4("myTree", {"file1.root", "file2.root"});
303303
std::vector<std::string> files = {"file1.root", "file2.root"};
304-
RDataFrame d5("myTree", files);
305-
RDataFrame d6("myTree", "file*.root"); // the glob is passed as-is to TChain's constructor
306-
RDataFrame d7(chain);
304+
ROOT::RDataFrame d5("myTree", files);
305+
ROOT::RDataFrame d6("myTree", "file*.root"); // the glob is passed as-is to TChain's constructor
306+
ROOT::RDataFrame d7(chain);
307307
~~~
308308
Additionally, users can construct an RDataFrame with no data source by passing an integer number. This is the number of rows that
309309
will be generated by this RDataFrame.
310310
~~~{.cpp}
311-
RDataFrame d(10); // a RDF with 10 entries (and no columns/branches, for now)
311+
ROOT::RDataFrame d(10); // a RDF with 10 entries (and no columns/branches, for now)
312312
d.Foreach([] { static int i = 0; std::cout << i++ << std::endl; }); // silly example usage: count to ten
313313
~~~
314314
This is useful to generate simple datasets on the fly: the contents of each event can be specified with Define() (explained below). For example, we have used this method to generate [Pythia](https://pythia.org/) events and write them to disk in parallel (with the Snapshot action).
@@ -324,7 +324,7 @@ auto df = ROOT::RDF::FromCSV("input.csv");
324324
Let's now tackle a very common task, filling a histogram:
325325
~~~{.cpp}
326326
// Fill a TH1D with the "MET" branch
327-
RDataFrame d("myTree", "file.root");
327+
ROOT::RDataFrame d("myTree", "file.root");
328328
auto h = d.Histo1D("MET");
329329
h->Draw();
330330
~~~
@@ -340,7 +340,7 @@ possible [actions](\ref cheatsheet), and all their results are wrapped in smart
340340
### Applying a filter
341341
Let's say we want to cut over the value of branch "MET" and count how many events pass this cut. This is one way to do it:
342342
~~~{.cpp}
343-
RDataFrame d("myTree", "file.root");
343+
ROOT::RDataFrame d("myTree", "file.root");
344344
auto c = d.Filter("MET > 4.").Count(); // computations booked, not run
345345
std::cout << *c << std::endl; // computations run here, upon first access to the result
346346
~~~
@@ -358,7 +358,7 @@ runtime performance is very important, a C++ callable can be specified instead (
358358
but it can be any kind of function or even a functor class), together with a list of column names.
359359
This snippet is analogous to the one above:
360360
~~~{.cpp}
361-
RDataFrame d("myTree", "file.root");
361+
ROOT::RDataFrame d("myTree", "file.root");
362362
auto metCut = [](double x) { return x > 4.; }; // a C++11 lambda function checking "x > 4"
363363
auto c = d.Filter(metCut, {"MET"}).Count();
364364
std::cout << *c << std::endl;
@@ -367,7 +367,7 @@ std::cout << *c << std::endl;
367367
An example of a more complex filter expressed as a string containing C++ code is shown below
368368
369369
~~~{.cpp}
370-
RDataFrame d("myTree", "file.root");
370+
ROOT::RDataFrame d("myTree", "file.root");
371371
auto df = d.Define("p", "std::array<double, 4> p{px, py, pz}; return p;")
372372
.Filter("double p2 = 0.0; for (auto&& x : p) p2 += x*x; return sqrt(p2) < 10.0;");
373373
~~~
@@ -386,7 +386,7 @@ Let's now consider the case in which "myTree" contains two quantities "x" and "y
386386
quantity `z = sqrt(x*x + y*y)`. Using the Define() transformation, we can create a new column in the dataset containing
387387
the variable "z":
388388
~~~{.cpp}
389-
RDataFrame d("myTree", "file.root");
389+
ROOT::RDataFrame d("myTree", "file.root");
390390
auto sqrtSum = [](double x, double y) { return sqrt(x*x + y*y); };
391391
auto zMean = d.Define("z", sqrtSum, {"x","y"}).Mean("z");
392392
std::cout << *zMean << std::endl;
@@ -398,7 +398,7 @@ columns. Define() and Filter() transformations can be concatenated and intermixe
398398
399399
As with filters, it is possible to specify new columns as string expressions. This snippet is analogous to the one above:
400400
~~~{.cpp}
401-
RDataFrame d("myTree", "file.root");
401+
ROOT::RDataFrame d("myTree", "file.root");
402402
auto zMean = d.Define("z", "sqrt(x*x + y*y)").Mean("z");
403403
std::cout << *zMean << std::endl;
404404
~~~
@@ -412,8 +412,7 @@ transformations to create a dataset on the fly. We then save the generated data
412412
~~~{.cpp}
413413
ROOT::RDataFrame d(100); // an RDF that will generate 100 entries (currently empty)
414414
int x = -1;
415-
auto d_with_columns = d.Define("x", []()->int { return ++x; })
416-
.Define("xx", []()->int { return x*x; });
415+
auto d_with_columns = d.Define("x", []()->int { return ++x; }).Define("xx", []()->int { return x*x; });
417416
d_with_columns.Snapshot("myNewTree", "newfile.root");
418417
~~~
419418
This example is slightly more advanced than what we have seen so far. First, it makes use of lambda captures (a
@@ -434,7 +433,7 @@ actions can be concatenated to and intermixed with Range()s. If a range is speci
434433
exclusively on the entries passing the filter -- it will not even count the other entries! The same goes for a Range()
435434
hanging from another Range(). Here are some commented examples:
436435
~~~{.cpp}
437-
RDataFrame d("myTree", "file.root");
436+
ROOT::RDataFrame d("myTree", "file.root");
438437
// Here we store a dataframe that loops over only the first 30 entries in a variable
439438
auto d30 = d.Range(30);
440439
// This is how you pick all entries from 15 onwards
@@ -1331,12 +1330,12 @@ whenever a list specific to the transformation/action is not present. RDataFrame
13311330
needed, ignoring trailing extra names if present.
13321331
~~~{.cpp}
13331332
// use "b1" and "b2" as default columns
1334-
RDataFrame d1("myTree", "file.root", {"b1","b2"});
1333+
ROOT::RDataFrame d1("myTree", "file.root", {"b1","b2"});
13351334
auto h = d1.Filter([](int b1, int b2) { return b1 > b2; }) // will act on "b1" and "b2"
13361335
.Histo1D(); // will act on "b1"
13371336
13381337
// just one default column this time
1339-
RDataFrame d2("myTree", "file.root", {"b1"});
1338+
ROOT::RDataFrame d2("myTree", "file.root", {"b1"});
13401339
auto d2f = d2.Filter([](double b2) { return b2 > 0; }, {"b2"}) // we can still specify non-default column lists
13411340
auto min = d2f.Min(); // returns the minimum value of "b1" for the filtered entries
13421341
auto vals = d2f.Take<double>(); // return the values for all entries passing the selection as a vector

0 commit comments

Comments
 (0)