# RDataFrame & RNTuple: Why are multiple 1D histograms much slower than two 2D histograms?

**URL:** <https://root-forum.cern.ch/t/rdataframe-rntuple-why-are-multiple-1d-histograms-much-slower-than-two-2d-histograms/65066>\
**Category:** ROOT\
**Tags:** rdataframe\
**Created:** [November 25, 2026, 8:38am UTC](https://root-forum.cern.ch/t/rdataframe-rntuple-why-are-multiple-1d-histograms-much-slower-than-two-2d-histograms/65066 "2026-11-25T08:38:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeWhoo](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/e8c25b/32.png) [@LeWhoo](https://root-forum.cern.ch/u/LeWhoo)\
**Post date:** [November 25, 2026, 8:38am UTC](https://root-forum.cern.ch/t/rdataframe-rntuple-why-are-multiple-1d-histograms-much-slower-than-two-2d-histograms/65066/1 "2026-11-25T08:38:28Z")

</div>

I’m analyzing a relatively large RNTuple (~7.1 GB, the corresponding TTree was 16 GB and almost 10 times slower to fill!), written using Uproot with ZSTD(3) compression. It contains scalar trigger parameters and two variable-length fields, `snr` and `failed_reason`, holding per-antenna values.

I’m using PyROOT with `ROOT.EnableImplicitMT()` enabled.

I want to calculate trigger efficiency versus SNR for ten different values of a parameter called `TCmax`. For each TCmax value, I need a histogram of all antenna SNRs and another histogram containing only antennas with `failed_reason == 0`.

I initially used separate `Histo1D()` actions:

```python
cut = "T1==60 && T2==35 && Tprev==500 && Tper==500 && NCmin==3 && NCmax==8"
df = df.Filter(cut).Define("SNR", "snr/100.0").Define("SNR_pass", "SNR[failed_reason == 0]")

for tcmax in range(5, 51, 5):
    dff = df.Filter(f"TCmax=={tcmax}")
    htotal[tcmax] = dff.Histo1D((f"htotal_{tcmax}", "", 70, 0, 70), "SNR")
    hpass[tcmax] = dff.Histo1D((f"hpass_{tcmax}", "", 70, 0, 70), "SNR_pass")

```

All actions are booked before calling `GetPtr()`, so the entire calculation executes in a single RDataFrame event loop (`df.GetNRuns() == 1`).

**This takes approximately 204 seconds.**

I then replaced the 20 individual histograms with two `Histo2D()` actions:

```python
df = df.Define("TCmax_all", "ROOT::VecOps::RVec<double>(SNR.size(), double(TCmax))")
df = df.Define("TCmax_pass", "ROOT::VecOps::RVec<double>(SNR_pass.size(), double(TCmax))")

h2total = df.Histo2D(("h2total", "", 51, -0.5, 50.5, 70, 0, 70), "TCmax_all", "SNR")
h2pass = df.Histo2D(("h2pass", "", 51, -0.5, 50.5, 70, 0, 70), "TCmax_pass", "SNR_pass")

```

I then use `ProjectionY()` to obtain the individual SNR histograms for each TCmax.

**This takes only approximately 60 seconds** , a factor of 3.4 faster.

For comparison, using the same common selection:

- `Count()` alone: ~38 seconds

- A single SNR `Histo1D()`: ~43 seconds

- A single SNR histogram with `failed_reason == 0`: ~42 seconds

- Ten pairs of 1D histograms: ~204 seconds

- Two 2D histograms: ~60 seconds

An earlier implementation, with the common selection repeated separately in each branch, took approximately 515 seconds.

My questions are:

1. Is such a large performance difference between multiple `Histo1D()` actions and two `Histo2D()` actions expected?

2. Does RDataFrame incur substantial overhead when filling many histogram actions, even when they share the same upstream filters and execute in a single event loop?

3. Is the 2D histogram approach generally recommended for this kind of analysis, or is there a better way to organize the computation?

The RNTuple structure:

```auto
root [1] nt->PrintInfo();
************************************NTUPLE************************************
* N-Tuple : events *
* Entries : 3124224000 *
********************************************************************************
* Field 1 : NCmax (std::uint8_t) *
* Field 2 : NCmin (std::uint8_t) *
* Field 3 : Qmax (std::uint8_t) *
* Field 4 : Qmin (std::uint8_t) *
* Field 5 : T1 (std::uint8_t) *
* Field 6 : T2 (std::uint8_t) *
* Field 7 : TCmax (std::uint8_t) *
* Field 8 : Tper (std::uint16_t) *
* Field 9 : Tprev (std::uint16_t) *
* Field 10 : energy_em (float) *
* Field 11 : event_number (std::int64_t) *
* Field 12 : failed_reason (std::vector<std::uint8_t>) *
* Field 12.1 : _0 (std::uint8_t) *
* Field 13 : passed (bool) *
* Field 14 : passed_du_cnt (std::uint16_t) *
* Field 15 : snr (std::vector<std::uint16_t>) *
* Field 15.1 : _0 (std::uint16_t) *
* Field 16 : xmax (float) *
* Field 17 : zenith (float) *
********************************************************************************

```

**Environment:** ROOT 6.38, Uproot 5.7.7, Fedora 43, implicit multithreading enabled

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [November 25, 2026, 9:17am UTC](https://root-forum.cern.ch/t/rdataframe-rntuple-why-are-multiple-1d-histograms-much-slower-than-two-2d-histograms/65066/2 "2026-11-25T09:17:16Z")

</div>

I think @vpadulan can help
