# 1D histogram for a nested data using rdataframe?

**URL:** <https://root-forum.cern.ch/t/1d-histogram-for-a-nested-data-using-rdataframe/58473>\
**Category:** Newbie\
**Created:** [March 11, 2024, 8:16am UTC](https://root-forum.cern.ch/t/1d-histogram-for-a-nested-data-using-rdataframe/58473 "2024-03-11T08:16:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![utkarsh-2000](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/u/e47774/32.png) [@utkarsh-2000](https://root-forum.cern.ch/u/utkarsh-2000)\
**Post date:** [March 11, 2024, 8:16am UTC](https://root-forum.cern.ch/t/1d-histogram-for-a-nested-data-using-rdataframe/58473/1 "2024-03-11T08:16:43Z")

</div>

Hi all,  
I am trying to plot one specific column of a TTree using RDataFrame  
The data is organised like

```auto
Entry Multplitcity Energy 
1 N {E1, E2.... EN}
2 M {E1, E2.... EM}
as shown in below figures as well

```

Multiplicities

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/3/0/305e67cab21bf90d177bb1b34f5e0e0ca125cf08.png)

Energies

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/6/f/6f879a4412d6a3858151eb78894516bdb7ede828.png)

The goal is to make a 1D Histogram of all the sub-entries within each entry as well

I would like to ask if while making a 1D histogram using RDataframe

```auto
 auto hist = rdf.Histo1D<double>("AnlEvent.pFat_QDC_E[9]");

```

Does it automatically loop into and fill all the entries and the sub-entries as well as corresponding to the energies for a given multiplicity? Or are there some other ways to achieve this task ?

Thanks a lot in advance!

---

<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:** [March 11, 2024, 8:54am UTC](https://root-forum.cern.ch/t/1d-histogram-for-a-nested-data-using-rdataframe/58473/2 "2024-03-11T08:54:57Z")

</div>

Hi,

Yes: [ROOT: ROOT::RDataFrame Class Reference](https://root.cern/doc/master/classROOT_1_1RDataFrame.html#collections)

D

---

<div class="post-metadata">

**Author:** ![utkarsh-2000](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/u/e47774/32.png) [@utkarsh-2000](https://root-forum.cern.ch/u/utkarsh-2000)\
**Post date:** [March 11, 2024, 10:38am UTC](https://root-forum.cern.ch/t/1d-histogram-for-a-nested-data-using-rdataframe/58473/3 "2024-03-11T10:38:51Z")

</div>

Hi @Danilo ,  
Going through the " Working with collections and object selections" section, I am trying to extend the same for my case.

```auto
  auto isDet2 = [](int id) { return id == 2; }; //filter for detector 2
    
     auto hist = rdf.Filter(isDet2, {"AnlEvent.pFat_QDC_ID[9]"}).Histo1D<double>({Form("pFat_QDC_E[%d]", 2), Form("hist_det%d", 2), 2000, 0, 2000}, "AnlEvent.pFat_QDC_E[9]");

```

However, I am still not sure if I understand how to “fill” all the energies or sub-entries under the column “AnlEvent.pFat\_QDC\_ID[9]” to a histogram.  
Can you please help in this regard?  
Thanks a lot.
