# CreateIntegral giving wrong results

**URL:** <https://root-forum.cern.ch/t/createintegral-giving-wrong-results/43508>\
**Category:** Roofit and RooStats\
**Created:** [February 11, 2021, 4:35pm UTC](https://root-forum.cern.ch/t/createintegral-giving-wrong-results/43508 "2021-02-11T16:35:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![quantiser](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/q/73ab20/32.png) [@quantiser](https://root-forum.cern.ch/u/quantiser)\
**Post date:** [February 11, 2021, 4:35pm UTC](https://root-forum.cern.ch/t/createintegral-giving-wrong-results/43508/1 "2021-02-11T16:35:59Z")

</div>

I am trying to create the integral of the signal component of RooSumPdf in the Barlow-Beeston example given in root tutorials ([here](https://root.cern/doc/v622/rf709__BarlowBeeston_8C.html)).

I create two ranges “window” (-20 to 20) and “window1” (-5 to 0) and the results of the signal integral are identical.

 ![test](https://root-forum.cern.ch/uploads/default/original/3X/2/1/21004e411bab600926899787a7f8b421a4b6319d.png)

> x.setRange(“window”,-20,20);  
> RooAbsReal \* integral\_sig1 = p\_ph\_sig1.createIntegral(RooArgSet(x), RooArgSet(x), “window”);  
> Double\_t Asig1val = Asig1.getVal();  
> Double\_t Asig1val\_err = Asig1.getError();  
> Double\_t integval\_sig = integral\_sig1-\>getVal();  
> Double\_t dintegval\_sig = integral\_sig1-\>getPropagatedError(\*result1, RooArgSet(x));  
> cout \<\< "Asig1 : " \<\< Asig1val \<\< " +/- " \<\< Asig1val\_err \<\< endl;  
> cout \<\< "Signal Integral in window: " \<\< integval\_sig \<\< " +/- " \<\< dintegval\_sig \<\< endl;
> 
> x.setRange(“window1”,-5,0);  
> RooAbsReal \* integral\_sig2 = p\_ph\_sig1.createIntegral(RooArgSet(x), RooArgSet(x), “window1”);  
> integval\_sig = integral\_sig2-\>getVal();  
> dintegval\_sig = integral\_sig2-\>getPropagatedError(\*result1, RooArgSet(x));  
> cout \<\< "Signal Integral in window1: " \<\< integval\_sig \<\< " +/- " \<\< dintegval\_sig \<\< endl;

Root output:

> Asig1 : 0.850507 +/- 0.235778  
> Signal Integral in window: 80.026 +/- 11.3836  
> [#1] INFO:Eval – RooRealVar::setRange(x) new range named ‘window1’ created with bounds [-5,0]  
> Signal Integral in window1: 80.026 +/- 11.3836

What am I doing wrong here?

Thanks.

[https://root.cern/doc/v622/rf709\_\_BarlowBeeston\_8C.html](https://root.cern/doc/v622/rf709__BarlowBeeston_8C.html)

[test.C](https://root-forum.cern.ch/uploads/short-url/kTZiuPMzAEly12x29u5jwXKobrf.C) (4.0 KB)

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [February 11, 2021, 6:26pm UTC](https://root-forum.cern.ch/t/createintegral-giving-wrong-results/43508/2 "2021-02-11T18:26:14Z")

</div>

Hi @quantiser ,  
this is one for @moneta I think.

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [February 11, 2021, 8:28pm UTC](https://root-forum.cern.ch/t/createintegral-giving-wrong-results/43508/3 "2021-02-11T20:28:55Z")

</div>

Hi,  
The problem is in the integration of the RooParamHIstFunc class.  
When computing the integral (see [ROOT: roofit/roofit/src/RooParamHistFunc.cxx Source File](https://root.cern/doc/master/RooParamHistFunc_8cxx_source.html#l00247) ) the range is not considered.  
I will open a github issue.

Cheers

Lorenzo

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [February 25, 2021, 8:29pm UTC](https://root-forum.cern.ch/t/createintegral-giving-wrong-results/43508/4 "2021-02-25T20:29:11Z")

</div>

Closed on February 25, 2021, 8:29pm UTC

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