# How to plot a particle from Particle\_PID branch?

**URL:** <https://root-forum.cern.ch/t/how-to-plot-a-particle-from-particle-pid-branch/34125>\
**Category:** Newbie\
**Created:** [May 17, 2019, 8:01pm UTC](https://root-forum.cern.ch/t/how-to-plot-a-particle-from-particle-pid-branch/34125 "2019-05-17T20:01:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![julia\_49](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/c57346/32.png) [@julia\_49](https://root-forum.cern.ch/u/julia_49)\
**Post date:** [May 17, 2019, 8:01pm UTC](https://root-forum.cern.ch/t/how-to-plot-a-particle-from-particle-pid-branch/34125/1 "2019-05-17T20:01:00Z")

</div>

Hello,

I know that this is a really simple question: I want to plot a histogram from the branch called “Particle\_PID”. I know that eg the top-quarks are the number 6 (according to the PDG IDs). Now I want to plot the histogram for Particle\_PID == 6 or at least I guess that this is how it works.  
For this I open my file, read the branch and fill the histogram with the entries, like:

```auto
TFile *file = new TFile("file.root");
TTree *tree = (TTree*)file->Get("fullset");
tree->SetBranchAddress("Particle_PID", &Particle_PID);
int entries = tree->GetEntries();
for(UInt_t i = 0; i < entries; ++i){
tree->GetEntry();
histogram->Fill(Particle_PID);
}

```

Do I fill it only with `tree->GetEntry() == 6`? Or do I need another particle branch?

---

<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:** [May 18, 2019, 6:12am UTC](https://root-forum.cern.ch/t/how-to-plot-a-particle-from-particle-pid-branch/34125/2 "2019-05-18T06:12:08Z")

</div>

Hi Julia,

I propose to use RDataFrame:

```auto
ROOT::RDataFrame rdf("fullset", "file.root");
auto h = rdf.Filter("Particle_PID = 6").Histo1D("Particle_PID");
h->Draw();

```

Cheers,  
D
