Dear all,
I have a histogram with 2 “named” bins
TH1F h("adsf", "asdf", 2, 0, 1)
// Some kind of initialisation
h->Fill("PHYSICS", 0)
h->Fill("CALIBRATION", 0)
// (...)
// later on, fill depending on what you encounter
h->Fill("PHYSICS", 1)
// Retrieve the content of bin "PHYSICS"
h->GetBinContent(1)
First, I want to be sure that I have those two bins correctly labelled even if I fill only one of the two. The (bad) way I do it, is by filling both bins with a zero at startup.
What is the proper way of doing it ?
How can I have the plot show two bins, with proper names, even without actually filling them ?
Second, how to retrieve the bin content for, let’s say, “PHYSICS” ?
I can do
h->GetBinContent(1)
but I actually don’t know if it is 0 or 1. I would rather imagine something like :
h->GetBinContent("PHYSICS")
Unfortunately the latter doesn’t exist. What is the correct way of doing this ? How can I know that “PHYSICS” is the nth bin ?
Thanks in advance for your help,
Barth