# RooCurve::average(Model) invalid range

**URL:** <https://root-forum.cern.ch/t/roocurve-average-model-invalid-range/59223>\
**Category:** Roofit and RooStats\
**Created:** [May 5, 2024, 10:46am UTC](https://root-forum.cern.ch/t/roocurve-average-model-invalid-range/59223 "2024-05-05T10:46:47Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![jonas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jonas/32/24756_2.png) [@jonas](https://root-forum.cern.ch/u/jonas)\
**Post date:** [May 17, 2024, 11:43am UTC](https://root-forum.cern.ch/t/roocurve-average-model-invalid-range/59223/7 "2024-05-17T11:43:33Z")

</div>

Hi @Natilus!

Thanks for sharing parts of your code. I can’t run it though, which is a problem for fully understanding it, as I can’t experiment with it. The header and main function is missing. It would have helped also to add the terminal output and resulting plot.

But just from reading it: I have a few suggestions to address your issues.

1. About the large chi2: it seems that you’re using `RooCurve::chiSquare()`. I would not recommend this, for reasons I have explained in this post:  
[How to correctly extract the chi2, ndf, p-value of a RooFitResult - #3 by astauffe](https://root-forum.cern.ch/t/how-to-correctly-extract-the-chi2-ndf-p-value-of-a-roofitresult/45956/3)  
Can you try with [RooAbsPdf::createChi2()](https://root.cern.ch/doc/master/classRooAbsReal.html#af37545641fa66582c23f34fb6416e32a)?

2. It’s true, when you call `RooAddPdf::getVal(normSet)` you’ll get the normalized value, which is not matching with your unnormalized histograms. You can use [RooAddPdf::expectedEvents()](https://root.cern.ch/doc/master/classRooAbsPdf.html#a2debaf3731b6d5f6027ee1ede917af01) to get the post-fit value of the total yield, which would be this scaling factor.

Does this help? Sorry for the long latency in replies. We’re wrapping up the next ROOT release, so the forum is falling a bit behind ☹

Cheers,  
Jonas

---

_[View the full topic](https://root-forum.cern.ch/t/roocurve-average-model-invalid-range/59223)._
