Skip to content

A two-dimensional histogram

rf.plot2d fills a 2D histogram of one sample; both variables must have the same structure (both per-event here). logz and cmap control the colour scale.

import rootfig as rf

style = rf.Style()

p = rf.plot2d(
    signal,
    rf.Variable("sum(Jet_pt)", bins=(40, 0, 800), label=r"$H_T$", unit="GeV"),
    met,
    selection="nJet >= 2",
    logz=True,
    cmap="magma",
    style=style,
)
p.fig.axes[-1].set_ylabel("")  # Omit the colour-bar title in this gallery layout.
import rootfig as rf

style = rf.Style(experiment="ATLAS", status="Internal", lumi=140, com=13.6)

p = rf.plot2d(
    signal,
    rf.Variable("sum(Jet_pt)", bins=(40, 0, 800), label=r"$H_T$", unit="GeV"),
    met,
    selection="nJet >= 2",
    logz=True,
    cmap="magma",
    style=style,
)
p.fig.axes[-1].set_ylabel("")  # Omit the colour-bar title in this gallery layout.
import rootfig as rf

style = rf.Style(experiment="CMS", status="Preliminary", lumi=138, com=13.6)

p = rf.plot2d(
    signal,
    rf.Variable("sum(Jet_pt)", bins=(40, 0, 800), label=r"$H_T$", unit="GeV"),
    met,
    selection="nJet >= 2",
    logz=True,
    cmap="magma",
    style=style,
)
p.fig.axes[-1].set_ylabel("")  # Omit the colour-bar title in this gallery layout.
import rootfig as rf

style = rf.Style(experiment="LHCb", status="Preliminary", lumi=9, com=13.6)

p = rf.plot2d(
    signal,
    rf.Variable("sum(Jet_pt)", bins=(40, 0, 800), label=r"$H_T$", unit="GeV"),
    met,
    selection="nJet >= 2",
    logz=True,
    cmap="magma",
    style=style,
)
p.fig.axes[-1].set_ylabel("")  # Omit the colour-bar title in this gallery layout.
import rootfig as rf

style = rf.Style(experiment="ALICE", status="Preliminary")

p = rf.plot2d(
    signal,
    rf.Variable("sum(Jet_pt)", bins=(40, 0, 800), label=r"$H_T$", unit="GeV"),
    met,
    selection="nJet >= 2",
    logz=True,
    cmap="magma",
    style=style,
)
p.fig.axes[-1].set_ylabel("")  # Omit the colour-bar title in this gallery layout.
import rootfig as rf

style = rf.Style(experiment="DUNE", status="Preliminary")

p = rf.plot2d(
    signal,
    rf.Variable("sum(Jet_pt)", bins=(40, 0, 800), label=r"$H_T$", unit="GeV"),
    met,
    selection="nJet >= 2",
    logz=True,
    cmap="magma",
    style=style,
)
p.fig.axes[-1].set_ylabel("")  # Omit the colour-bar title in this gallery layout.
Setup

The code reads the toy dataset. In a checkout of rootfig, python examples/gallery writes it to examples/out/ in a few seconds; run the code inside that directory.

It uses these samples and variables, shared by the gallery examples (see Samples, variables, cuts and styles):

signal = rf.Sample("signal.root", tree="events", label="Signal", weight="weight", scale=0.03)
zjets = rf.Sample("background.root", tree="events", label="Z + jets", weight="weight")
diboson = rf.Sample("diboson.root", tree="events", label="Diboson", weight="weight", scale=0.15)
data = rf.Sample("data.root", tree="events", label="Data", is_data=True)
mc = [zjets, diboson, signal]  # stacked bottom to top

pt = rf.Variable("Muon_pt", bins=(30, 0, 300), label=r"$p_T^{\mu}$", unit="GeV")
mll = rf.Variable("m_ll", bins=(70, 50, 260), label=r"$m_{\ell\ell}$", unit="GeV")
met = rf.Variable("MET", bins=(40, 0, 400), label=r"$E_T^{miss}$", unit="GeV")