Skip to content
Snippets Groups Projects
Commit d425858c authored by Enrico Guiraud's avatar Enrico Guiraud
Browse files

[TDF] Revert some doc-breaking clang-format fixes (NFC)

This reverts part of commit 5059f594.
parent 6948a0c4
No related branches found
No related tags found
No related merge requests found
...@@ -176,8 +176,7 @@ You can use the objects returned by actions as if they were pointers to the desi ...@@ -176,8 +176,7 @@ You can use the objects returned by actions as if they were pointers to the desi
possible [actions](#overview), and all their results are wrapped in smart pointers; we'll see why in a minute. possible [actions](#overview), and all their results are wrapped in smart pointers; we'll see why in a minute.
### Applying a filter ### Applying a filter
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 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:
it:
~~~{.cpp} ~~~{.cpp}
TDataFrame d("myTree", "file.root"); TDataFrame d("myTree", "file.root");
auto c = d.Filter("MET > 4.").Count(); auto c = d.Filter("MET > 4.").Count();
...@@ -201,8 +200,7 @@ auto metCut = [](double x) { return x > 4.; }; // a c++11 lambda function checki ...@@ -201,8 +200,7 @@ auto metCut = [](double x) { return x > 4.; }; // a c++11 lambda function checki
auto c = d.Filter(metCut, {"MET"}).Count(); auto c = d.Filter(metCut, {"MET"}).Count();
std::cout << *c << std::endl; std::cout << *c << std::endl;
~~~ ~~~
More information on filters and how to use them to automatically generate cutflow reports can be found More information on filters and how to use them to automatically generate cutflow reports can be found [below](#Filters).
[below](#Filters).
### Defining custom columns ### Defining custom columns
Let's now consider the case in which "myTree" contains two quantities "x" and "y", but our analysis relies on a derived Let's now consider the case in which "myTree" contains two quantities "x" and "y", but our analysis relies on a derived
...@@ -219,8 +217,7 @@ variables created with `Define` as if they were actual tree branches/columns, bu ...@@ -219,8 +217,7 @@ variables created with `Define` as if they were actual tree branches/columns, bu
once per event. As with filters, `Define` calls can be chained with other transformations to create multiple custom once per event. As with filters, `Define` calls can be chained with other transformations to create multiple custom
columns. `Define` and `Filter` transformations can be concatenated and intermixed at will. columns. `Define` and `Filter` transformations can be concatenated and intermixed at will.
As with filters, it is possible to specify new columns as string expressions. This snippet is analogous to the one As with filters, it is possible to specify new columns as string expressions. This snippet is analogous to the one above:
above:
~~~{.cpp} ~~~{.cpp}
TDataFrame d("myTree", "file.root"); TDataFrame d("myTree", "file.root");
auto zMean = d.Define("z", "sqrt(x*x + y*y)").Mean("z"); auto zMean = d.Define("z", "sqrt(x*x + y*y)").Mean("z");
...@@ -230,8 +227,7 @@ Again the names of the branches used in the expression and their types are infer ...@@ -230,8 +227,7 @@ Again the names of the branches used in the expression and their types are infer
valid c++ and is just-in-time compiled by the ROOT interpreter, cling -- the process has a small runtime overhead. valid c++ and is just-in-time compiled by the ROOT interpreter, cling -- the process has a small runtime overhead.
Previously, when showing the different ways a TDataFrame can be created, we showed a constructor that only takes a Previously, when showing the different ways a TDataFrame can be created, we showed a constructor that only takes a
number of entries a parameter. In the following example we show how to combine such an "empty" `TDataFrame` with number of entries a parameter. In the following example we show how to combine such an "empty" `TDataFrame` with `Define`
`Define`
transformations to create a data-set on the fly. We then save the generated data on disk using the `Snapshot` action. transformations to create a data-set on the fly. We then save the generated data on disk using the `Snapshot` action.
~~~{.cpp} ~~~{.cpp}
TDataFrame d(100); // a TDF that will generate 100 entries (currently empty) TDataFrame d(100); // a TDF that will generate 100 entries (currently empty)
...@@ -514,36 +510,24 @@ note that all actions are only executed for events that pass all preceding filte ...@@ -514,36 +510,24 @@ note that all actions are only executed for events that pass all preceding filte
| **Lazy actions** | **Description** | | **Lazy actions** | **Description** |
|------------------|-----------------| |------------------|-----------------|
| Count | Return the number of events processed. | | Count | Return the number of events processed. |
| Fill | Fill a user-defined object with the values of the specified branches, as if by calling `Obj.Fill(branch1, | Fill | Fill a user-defined object with the values of the specified branches, as if by calling `Obj.Fill(branch1, branch2, ...). |
branch2, ...). |
| Histo{1D,2D,3D} | Fill a {one,two,three}-dimensional histogram with the processed branch values. | | Histo{1D,2D,3D} | Fill a {one,two,three}-dimensional histogram with the processed branch values. |
| Max | Return the maximum of processed branch values. | | Max | Return the maximum of processed branch values. |
| Mean | Return the mean of processed branch values. | | Mean | Return the mean of processed branch values. |
| Min | Return the minimum of processed branch values. | | Min | Return the minimum of processed branch values. |
| Profile{1D,2D} | Fill a {one,two}-dimensional profile with the branch values that passed all filters. | | Profile{1D,2D} | Fill a {one,two}-dimensional profile with the branch values that passed all filters. |
| Reduce | Reduce (e.g. sum, merge) entries using the function (lambda, functor...) passed as argument. The function | Reduce | Reduce (e.g. sum, merge) entries using the function (lambda, functor...) passed as argument. The function must have signature `T(T,T)` where `T` is the type of the branch. Return the final result of the reduction operation. An optional parameter allows initialization of the result object to non-default values. |
must have signature `T(T,T)` where `T` is the type of the branch. Return the final result of the reduction operation. An
optional parameter allows initialization of the result object to non-default values. |
| Take | Build a collection of values of a branch. | | Take | Build a collection of values of a branch. |
| **Instant actions** | **Description** | | **Instant actions** | **Description** |
|---------------------|-----------------| |---------------------|-----------------|
| Foreach | Execute a user-defined function on each entry. Users are responsible for the thread-safety of this lambda | Foreach | Execute a user-defined function on each entry. Users are responsible for the thread-safety of this lambda when executing with implicit multi-threading enabled. |
when executing with implicit multi-threading enabled. | | ForeachSlot | Same as `Foreach`, but the user-defined function must take an extra `unsigned int slot` as its first parameter. `slot` will take a different value, `0` to `nThreads - 1`, for each thread of execution. This is meant as a helper in writing thread-safe `Foreach` actions when using `TDataFrame` after `ROOT::EnableImplicitMT()`. `ForeachSlot` works just as well with single-thread execution: in that case `slot` will always be `0`. |
| ForeachSlot | Same as `Foreach`, but the user-defined function must take an extra `unsigned int slot` as its first | Snapshot | Writes processed data-set to disk, in a new `TTree` and `TFile`. Custom columns can be saved as well, filtered entries are not saved. Users can specify which columns to save (default is all). Snapshot overwrites the output file if it already exists. |
parameter. `slot` will take a different value, `0` to `nThreads - 1`, for each thread of execution. This is meant as a
helper in writing thread-safe `Foreach` actions when using `TDataFrame` after `ROOT::EnableImplicitMT()`. `ForeachSlot`
works just as well with single-thread execution: in that case `slot` will always be `0`. |
| Snapshot | Writes processed data-set to disk, in a new `TTree` and `TFile`. Custom columns can be saved as well,
filtered entries are not saved. Users can specify which columns to save (default is all). Snapshot overwrites the output
file if it already exists. |
| **Queries** | **Description** | | **Queries** | **Description** |
|-----------|-----------------| |-----------|-----------------|
| Report | This is not properly an action, since when `Report` is called it does not book an operation to be performed | Report | This is not properly an action, since when `Report` is called it does not book an operation to be performed on each entry. Instead, it interrogates the data-frame directly to print a cutflow report, i.e. statistics on how many entries have been accepted and rejected by the filters. See the section on [named filters](#named-filters-and-cutflow-reports) for a more detailed explanation. |
on each entry. Instead, it interrogates the data-frame directly to print a cutflow report, i.e. statistics on how many
entries have been accepted and rejected by the filters. See the section on [named
filters](#named-filters-and-cutflow-reports) for a more detailed explanation. |
## <a name="parallel-execution"></a>Parallel execution ## <a name="parallel-execution"></a>Parallel execution
As pointed out before in this document, `TDataFrame` can transparently perform multi-threaded event loops to speed up As pointed out before in this document, `TDataFrame` can transparently perform multi-threaded event loops to speed up
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment