# Number of Signal and Background events

**URL:** <https://root-forum.cern.ch/t/number-of-signal-and-background-events/32981>\
**Category:** Newbie\
**Created:** [March 1, 2019, 4:50pm UTC](https://root-forum.cern.ch/t/number-of-signal-and-background-events/32981 "2019-03-01T16:50:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Debajyoti\_Sengupta](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/90db22/32.png) [@Debajyoti\_Sengupta](https://root-forum.cern.ch/u/Debajyoti_Sengupta)\
**Post date:** [March 1, 2019, 4:50pm UTC](https://root-forum.cern.ch/t/number-of-signal-and-background-events/32981/1 "2019-03-01T16:50:12Z")

</div>

Hello all,

I have a histogram which I am trying to fit with a sum of two RooPDFs, and I define

```auto
RooRealVar b("b", "Number of background events", 0, 5000);
RooRealVar s("s", "Number of signal events", 0, 500);

```

How does one make an educated guess about the number of background and signal events in general?

For example, for the given histogram

 ![Capture](https://root-forum.cern.ch/uploads/default/original/3X/7/a/7ac3395a1acac7f25861694c86a007fe41d3de0b.jpeg)

---

<div class="post-metadata">

**Author:** ![StephanH](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@StephanH](https://root-forum.cern.ch/u/StephanH)\
**Post date:** [March 4, 2019, 11:08am UTC](https://root-forum.cern.ch/t/number-of-signal-and-background-events/32981/2 "2019-03-04T11:08:41Z")

</div>

The best guess is to integrate the function. For a binned distribution, this is just summing the entries in the bins. Fortunately, ROOT prints in the top corner that the number of entries is 7039.

---

<div class="post-metadata">

**Author:** ![RongkunWang](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/rongkunwang/32/36036_2.png) [@RongkunWang](https://root-forum.cern.ch/u/RongkunWang)\
**Post date:** [March 5, 2019, 12:10am UTC](https://root-forum.cern.ch/t/number-of-signal-and-background-events/32981/3 "2019-03-05T00:10:15Z")

</div>

If you have a extended RooAddPdf, you can use [expectedEvents](https://root.cern.ch/doc/v608/classRooAddPdf.html#a1fda9c52c34dbc4fadddd631957fb316) for each of the component of the two pdfs. Or you can specify the normalization coefficients you have defined with the constructor

[RooAddPdf](https://root.cern.ch/doc/v608/classRooAddPdf.html#acafcca576f7839c046bea7c9edf31c22) (const char \*name, const char \*title, const RooArgList &pdfList, const RooArgList &coefList, Bool\_t recursiveFraction=kFALSE).

---

<div class="post-metadata">

**Author:** ![Debajyoti\_Sengupta](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/90db22/32.png) [@Debajyoti\_Sengupta](https://root-forum.cern.ch/u/Debajyoti_Sengupta)\
**Post date:** [March 5, 2019, 3:55am UTC](https://root-forum.cern.ch/t/number-of-signal-and-background-events/32981/4 "2019-03-05T03:55:49Z")

</div>

> [@RongkunWang](#):
>
> [RooAddPdf](https://root.cern.ch/doc/v608/classRooAddPdf.html#acafcca576f7839c046bea7c9edf31c22) (const char \*name, const char \*title, const RooArgList &pdfList, const RooArgList &coefList, Bool\_t recursiveFraction=kFALSE).

Hello @RongkunWang,  
Could you explain why you use recursiveFraction(s?) with the RooAddPdf? At any rate, I get an error when I add this to my code.

```auto
error: use of undeclared identifier 'recursiveFractions'
  ...RooAddPdf fullModel("fullModel", "CxB + bg_bern", RooArgList(c_BW, bg_bern), RooArgList(s, b), recursiveFraction...

```

---

<div class="post-metadata">

**Author:** ![RongkunWang](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/rongkunwang/32/36036_2.png) [@RongkunWang](https://root-forum.cern.ch/u/RongkunWang)\
**Post date:** [March 5, 2019, 8:22am UTC](https://root-forum.cern.ch/t/number-of-signal-and-background-events/32981/5 "2019-03-05T08:22:13Z")

</div>

Hi, I’m just copying the function form, the parameter name, etc. You can leave the recursiveFraction argument as blank, i.e. it will take kFALSE, the default value.

However, your error is due to that you didn’t define `recursiveFractions`. c++ is different from python in that when calling function, the name of parameters are not specified.
