Filling `TEfficiency` with multiple events

Hello,

I am looking at some aggregate data and I am building a TEfficiency out of it. Is it possible to add some number of passed and total events in a bin?

Workarounds that come to my mind:

  1. declare manually the total and passed histograms, and then make a TEfficiency, for example:
TH1F* totalHisto = new TH1F("total", "", 10, 0, 10);
TH1F* passedHisto = new TH1F("passed", "", 10, 0, 10);

// add 10 events, of which 5 passed, to bin number 4:
totalHisto->AddBinContent(4, 10);
passedHisto->AddBinContent(4, 5);

TEfficiency(*totalHisto, *passedHisto);
  1. Fill the TEfficiency multiple times via a loop:
TEfficiency eff = new TEfficiency("eff", "", 10, 0, 10);
for (int i = 0; i < 10; i++)
  eff->Fill(i < 5, 3);

(Incidentally, I am under the impression that there is a difference between filling histograms multiple times like this, and using AddBinContent, but I’m not sure what that is for the user.)

Is there any cleaner way?

Thank you!

I think @moneta can help you.