Can you fill a histogram twice?

Dear ROOT users,
I would like to ask if filling a histogram twice is possible, for example in a event loop, I put a if statement for muon events and then use h1->Fill(events), and then use another if statement for anti-muon events and follow that with h1->Fill(events)

Would h1 be filled with both events or just the most recent if statement?

Thanks

Hi,

I think what you’re asking is: what are histograms? See e.g. the CSC lecture at root.cern.ch/drupal/content/tuto … nd-courses That will tell you how the filling works: you fill the x value, and the histogram counts how often a certain x range was filled.

Cheers, Axel.

[quote=“pmasterkim”] . . .
I would like to ask if filling a histogram twice is possible, for example in a event loop, I put a if statement for muon events and then use h1->Fill(events), and then use another if statement for anti-muon events and follow that with h1->Fill(events)

Would h1 be filled with both events or just the most recent if statement?

[/quote]The method TH1::Fill does not fill the histogram with “many events” at all. It adds ONE :bulb: value (as Axel said above) to the existing histogram object.