Revision 090ccec988dca3bec28755dd9de8472fcbfdfb52 authored by will-cern on 28 September 2023, 12:09:24 UTC, committed by GitHub on 28 September 2023, 12:09:24 UTC
* update xRooFit to latest version

* declare ROOT::Experimental::XRooFit namespace for ROOT's copy of xRooFit

* fix namespace alias

* address PR comments

* [RF] Improvements to `xroofit` documentation structure

  * Add a new `xroofit` group to the RooFit documentation

  * Add semicolons behind the `NAMESPACE` macros. They have no effect on
    the C++ compilier, but macros without trailing semicolons confuse
    doxygen

  * Add the `xRooNode` and `xRooNLLVar` classes to the `xroofit`
    documentation group. Other xroofit classes might also go there, but
    I don't know which ones should really be public. So I only added
    these two to give and example.

  * Move RooBrowser documentation to xRooBrowser. Now that xRooFit is
    considered part as the experimental user interface, this is fine to
    do. Like this, doxygen can associate the actual xRooBrowser
    implementation with the docs.

  * Rename `RooFit::Detail::XRooFit` namespace to
    `ROOT::Experimental::XRooFit` instad of using namespace alias.
    Again, this is done to not confuse doxygen.

To build the documentation quickly, edit the
`documentation/doxygen/makeinput.sh` directory and comment out all
subdirectories except for `roofit`. Call `make` in the doxygen
directory. Type `y` if it should ask you to overwrite some files in the
end. The xRooFit documentation will end up in the
`~/rootdoc/html/group__xroofit.html` directory.

* address some typos
1 parent a345367
Raw File
df006_ranges.py
## \file
## \ingroup tutorial_dataframe
## \notebook -nodraw
## Use Range to limit the amount of data processed.
##
## This tutorial shows how to express the concept of ranges when working with the RDataFrame.
##
## \macro_code
## \macro_output
##
## \date March 2017
## \author Danilo Piparo (CERN)

import ROOT

def fill_tree(treeName, fileName):
    df = ROOT.RDataFrame(100)
    df.Define("b1", "(int) rdfentry_")\
      .Define("b2", "(float) rdfentry_ * rdfentry_").Snapshot(treeName, fileName)


# We prepare an input tree to run on
fileName = "df006_ranges_py.root"
treeName = "myTree"

fill_tree(treeName, fileName)

# We read the tree from the file and create a RDataFrame.
d = ROOT.RDataFrame(treeName, fileName)

# ## Usage of ranges
# Now we'll count some entries using ranges
c_all = d.Count()

# This is how you can express a range of the first 30 entries
d_0_30 = d.Range(30) 
c_0_30 = d_0_30.Count()

# This is how you pick all entries from 15 onwards
d_15_end = d.Range(15, 0)
c_15_end = d_15_end.Count()

# We can use a stride too, in this case we pick an event every 3 entries
d_15_end_3 = d.Range(15, 0, 3)
c_15_end_3 = d_15_end_3.Count()

# The Range here acts first on the (whole) RDataFrame graph:
# Not only actions (like Count) but also filters and new columns can be added to it.
d_0_50 = d.Range(50)
c_0_50_odd_b1 = d_0_50.Filter("1 == b1 % 2").Count()

# An important thing to notice is that the counts of a filter are relative to the
# number of entries a filter "sees". Therefore, if a Range depends on a filter,
# the Range will act on the entries passing the filter only.
c_0_3_after_even_b1 = d.Filter("0 == b1 % 2").Range(0, 3).Count()

# Ok, time to wrap up: let's print all counts!
print("Usage of ranges:")
print(" - All entries:", c_all.GetValue())
print(" - Entries from 0 to 30:", c_0_30.GetValue())
print(" - Entries from 15 onwards:", c_15_end.GetValue())
print(" - Entries from 15 onwards in steps of 3:", c_15_end_3.GetValue())
print(" - Entries from 0 to 50, odd only:", c_0_50_odd_b1.GetValue())
print(" - First three entries of all even entries:", c_0_3_after_even_b1.GetValue())
back to top