Is there a way to use Eval() for a histogram?

Hello Experts,
I have an efficiency histogram. I want to divide an energy histogram with the efficiency and used this -
However, this is not working since the binning for both is different. Is there a way to use something like
Eval() for the histogram directly without fitting so that I can read the values from h1 and divide the corresponding values of h2?
I am sure there is a simple way. Can anyone please help with any suggestions?

Please help! Thank you for your time!

ROOT Version: 6.18/04
Platform: C++
Compiler: Visual Studio Code

Maybe @moneta knows a simple way

1 Like

I think there is nothing like Eval for histograms, but you can try to do something like


this should work.


1 Like

You could convert your efficiency histogram to a TGraph first.

Then, you go to your energy histogram and bin by bin, you divide the bin content by gr->Eval(h->GetXaxis()->GetBinCenter(i))

Thank you for getting back @Dilicus and @ferhue. Both of your suggestions worked like a charm. However, I ended up using @ferhue’s suggestion which was exactly what I was looking for.
Thank you for your time and help!

1 Like