Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Root
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
为了安全,强烈建议开启2FA双因子认证:User Settings -> Account -> Enable two-factor authentication!!!
Show more breadcrumbs
cxwx
Root
Commits
81ff4a2f
Unverified
Commit
81ff4a2f
authored
7 years ago
by
Guilherme Amadio
Browse files
Options
Downloads
Patches
Plain Diff
[TDF] Update documentation
parent
51e61297
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tree/treeplayer/src/TDataFrame.cxx
+6
-5
6 additions, 5 deletions
tree/treeplayer/src/TDataFrame.cxx
with
6 additions
and
5 deletions
tree/treeplayer/src/TDataFrame.cxx
+
6
−
5
View file @
81ff4a2f
...
...
@@ -203,7 +203,7 @@ auto c = d.Filter(metCut, {"MET"}).Count();
std::cout << *c << std::endl;
~~~
An example of a more complex filter
with just in time compilation
is shown below
:
An example of a more complex filter
expressed as a string containing C++ code
is shown below
~~~{.cpp}
TDataFrame d("myTree", "file.root");
...
...
@@ -211,10 +211,11 @@ auto df = d.Define("p", "std::array<double, 4> p{px, py, pz, E}; return p;")
.Filter("double p2 = 0.0; for (auto&& x : p) p2 += x*x; return sqrt(p2) < 10.0;");
~~~
The code snippet above defines a column `p` that is a fixed-size array using the component column names, then filters
on its magnitude by looping over its elements. The good thing about using strings like this for defining new columns
is that this makes it easy to use with Python scripts, where creating a C++ callable can be an annoyance. However,
there is still a limitation that the lambda cannot capture anything. For that, a C++ lambda is the best option.
The code snippet above defines a column `p` that is a fixed-size array using the component column names and then
filters on its magnitude by looping over its elements. It must be noted that the usage of strings to define columns
like the one above is a major advantage when using PyROOT. However, only constants and data coming from other columns
in the dataset can be involved in the code passed as a string. Local variables and functions cannot be used, since
the interpreter will not know how to find them. When capturing local state is necessary, a C++ callable can be used.
More information on filters and how to use them to automatically generate cutflow reports can be found [below](#Filters).
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment