TEfficiency: access x value for a particular y value

I have a TEfficiency object showing efficiency versus jet pT. Is there a way to access the x value (jet pT) for a particular y value (say 90% efficiency point)? For a TH object, I use GetBinWithContent.

Did you try to search the forum? I found this topic for example. Otherwise @moneta can most probably give some hints


There is no such method in TEfficiency. The simplest solution is probably to convert TEfficiency in a TH1 and call afterwards TH1::GetBinWithContent.
Here is some code example (eff is a pointer to a TEfficiency object)

auto h1 = eff->GetTotalHistogram();
for (int i = 1; i <= h1->GetNbinsX(); i++) {
  h1->SetBinContent(i, eff->GetEfficiency(i));
int binX = 0;
double effValue = 0.9; 
eff->GetBinWithContent(effValue, binX);
// binX has now the x value corresponding to an efficiency of effValue

Thanks, appreciate the help! This looked like it would work but on trying, if I understand correctly, it seems that GetTotalHistogram returns a const pointer to the histogram and so I’m not able to use Reset or SetBinContent. So I get this error: candidate function not viable: ‘this’ argument has type ‘const TH1’, but method is not marked const

Any suggestions of a way around this?



sorry, yes you ned to copy the return histogram. The first line should be:

auto h1 = new TH1D(*eff->GetTotalHistogram());


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.