# Filling \`TEfficiency\` with multiple events

**URL:** <https://root-forum.cern.ch/t/filling-tefficiency-with-multiple-events/47817>\
**Category:** Newbie\
**Created:** [November 25, 2021, 11:47am UTC](https://root-forum.cern.ch/t/filling-tefficiency-with-multiple-events/47817 "2021-11-25T11:47:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![renyhp](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/e68b1a/32.png) [@renyhp](https://root-forum.cern.ch/u/renyhp)\
**Post date:** [November 25, 2021, 11:47am UTC](https://root-forum.cern.ch/t/filling-tefficiency-with-multiple-events/47817/1 "2021-11-25T11:47:40Z")

</div>

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:

```cpp
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:

```cpp
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!

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [November 25, 2021, 11:48am UTC](https://root-forum.cern.ch/t/filling-tefficiency-with-multiple-events/47817/2 "2021-11-25T11:48:11Z")

</div>

I think @moneta can help you.
