# How to show branch/ histogram entries from the command line

**URL:** <https://root-forum.cern.ch/t/how-to-show-branch-histogram-entries-from-the-command-line/64295>\
**Category:** General Chat\
**Tags:** tree, root\
**Created:** [October 8, 2025, 4:32pm UTC](https://root-forum.cern.ch/t/how-to-show-branch-histogram-entries-from-the-command-line/64295 "2025-10-08T16:32:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![4lplusMatt](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/4/b9bd4f/32.png) [@4lplusMatt](https://root-forum.cern.ch/u/4lplusMatt)\
**Post date:** [October 8, 2025, 4:32pm UTC](https://root-forum.cern.ch/t/how-to-show-branch-histogram-entries-from-the-command-line/64295/1 "2025-10-08T16:32:20Z")

</div>

Is there any command line tool to get the entries that show in a branch’s histogram?

I want to get the ‘Entries’ shown when viewing the histogram for a branch in TBrowser, e.g. the number circled here for the ` **llll\_tlv\_pt** ` branch:

 ![tbranch_hist](https://root-forum.cern.ch/uploads/default/original/3X/f/e/fe6f71c1780c7c19a84bb7ffda07695f5e39261e.png)

However, using:

`root -l my.output.root`

```bash
llllTree->GetBranch("llll_tlv_pt")->GetEntries()

```

Just prints **60,000** which is the total number of events from the dataset.

Is there any command line function to get the right entries value, or is my best bet to write a script to draw this histogram from the tree and then get the entries?

Kind regards, Matt

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [October 8, 2025, 6:10pm UTC](https://root-forum.cern.ch/t/how-to-show-branch-histogram-entries-from-the-command-line/64295/2 "2025-10-08T18:10:14Z")

</div>

Hi Matt,

Thanks for the question. You can use RDataFrame:

```auto
ROOT::RDataFrame("llllTree", "my.output.root").Count().GetValue()

```

There is potential in using RDF, since it is powerful and can be used to do much more than counting events (see e.g. [ROOT: ROOT::RDataFrame Class Reference](https://root.cern/doc/master/classROOT_1_1RDataFrame.html))

Cheers,  
D

---

<div class="post-metadata">

**Author:** ![yus](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/9fc348/32.png) [@yus](https://root-forum.cern.ch/u/yus)\
**Post date:** [October 9, 2025, 8:54am UTC](https://root-forum.cern.ch/t/how-to-show-branch-histogram-entries-from-the-command-line/64295/3 "2025-10-09T08:54:07Z")

</div>

Hi,

an old-style one-liner:

```auto
root -b my.output.root -e "llllTree->Draw(\"llll_tlv_pt\"); TH1* myH {static_cast<TH1*>(gPad->GetPrimitive(\"htemp\"))}; myH->GetEntries()" -q

```

---

<div class="post-metadata">

**Author:** ![4lplusMatt](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/4/b9bd4f/32.png) [@4lplusMatt](https://root-forum.cern.ch/u/4lplusMatt)\
**Post date:** [October 9, 2025, 1:48pm UTC](https://root-forum.cern.ch/t/how-to-show-branch-histogram-entries-from-the-command-line/64295/4 "2025-10-09T13:48:15Z")

</div>

Hi @yus ,

Thank you, this worked great! (The tree was actually inside another folder so I used

```bash
root -b test_ZdZd13TeV_20251007_02/my.output.root -e "Nominal->cd(); llllTree->Draw(\"llll_tlv_pt\"); TH1* myH {static_cast<TH1*>(gPad->GetPrimitive(\"htemp\"))}; myH->GetEntries()" -q

```

)

@Danilo the RDataFrame command printed 60,000 so it seems it’s getting total events too. However, I can see from the page that there are a lof of things I will use it for in future so thank you for the suggestion!

Cheers, Matt

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [October 9, 2025, 4:46pm UTC](https://root-forum.cern.ch/t/how-to-show-branch-histogram-entries-from-the-command-line/64295/5 "2025-10-09T16:46:32Z")

</div>

Matt, sorry for the misunderstanding. I did not understand you wanted to count collection elements “inside” the events.  
Just for completeness, here is what I should have suggested in the first place:

```auto
ROOT::RDataFrame("llllTree", "my.output.root").Histo1D("llll_tlv_pt")->GetEntries()

```

And as a one liner (thanks @yus for making TTreeDraw a oneliner!)

```auto
root -b -e "ROOT::RDataFrame(\"llllTree\", \"my.output.root\").Histo1D(\"llll_tlv_pt\")->GetEntries()"

```

Cheers,  
D

---

<div class="post-metadata">

**Author:** ![4lplusMatt](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/4/b9bd4f/32.png) [@4lplusMatt](https://root-forum.cern.ch/u/4lplusMatt)\
**Post date:** [October 13, 2025, 9:44am UTC](https://root-forum.cern.ch/t/how-to-show-branch-histogram-entries-from-the-command-line/64295/6 "2025-10-13T09:44:59Z")

</div>

Thanks a lot Danilo, these commands work great.

Just for completeness here’s the exact commands I used since my tree was inside another directory:

```auto
root -b -e "ROOT::RDataFrame(\"Nominal/llllTree\", \"my.output.root\").Histo1D(\"llll_tlv_pt\")->GetEntries()" -q

```

```auto
ROOT::RDataFrame("Nominal/llllTree", "my.output.root").Histo1D("llll_tlv_pt")->GetEntries()

```

Cheers, M

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [October 13, 2025, 10:16am UTC](https://root-forum.cern.ch/t/how-to-show-branch-histogram-entries-from-the-command-line/64295/7 "2025-10-13T10:16:56Z")

</div>

If you also want to ‘see’ the contents of a histogram in the terminal, check out [TBrowser alternative for non-X11 mode](https://root-forum.cern.ch/t/tbrowser-alternative-for-non-x11-mode/20754)
