How to plot a particle from Particle_PID branch?

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:

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?

Hi Julia,

I propose to use RDataFrame:

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

Cheers,
D

1 Like