# RooFit in root 6.28.04

**URL:** <https://root-forum.cern.ch/t/roofit-in-root-6-28-04/55267>\
**Category:** Roofit and RooStats\
**Tags:** roofit\
**Created:** [June 12, 2023, 3:40pm UTC](https://root-forum.cern.ch/t/roofit-in-root-6-28-04/55267 "2023-06-12T15:40:32Z")\
**Posts on this page:** 1\
**Showing post:** 6

<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:** [June 15, 2023, 2:12pm UTC](https://root-forum.cern.ch/t/roofit-in-root-6-28-04/55267/6 "2023-06-15T14:12:49Z")

</div>

I’m aware of the general problem, but I didn’t expect it to look _that_ bad!

In this line:

```c++
Curves->fitTo(values,Range(LowRange, HighestVal(RealHist)));

```

What is the result of `HighestVal(RealHist)`? Is it the upper limit of the mass variable in RooFit, or higher? If it’s larger, then it would explain why the plotting goes that bad. I think if the fit range would be larger than the variable range, it messes up the sampling algorithm for making the plot and that’s why you get what you get. Maybe not including this `Range()` option in `fitTo()` does help? Or at least if you include it, make sure that the range is not larger than the range of x. If this doesn’t make things look better, I can try to think of other workarounds.

I also have created a GitHub issue to remind myself also to fix the underlying issue for the next ROOT release: [[RF] Plotting shifted RooHistPdfs doesn't go well · Issue #13030 · root-project/root · GitHub](https://github.com/root-project/root/issues/13030)

However, what I can’t see is that any of this worked in ROOT 6.24.06. Maybe my reproducer linked on GitHub is still different from your workflow in some important way?

PS: I see that we have already discussed about this some months ago, sorry that I forgot about the problem in the meantime. With the GitHub issue I opened now, I should not forget it again.

> [@How to implement a horizontal shift for RooHistPdf](https://root-forum.cern.ch/t/how-to-implement-a-horizontal-shift-for-roohistpdf/16787/6):
>
> Hi @RENATO_QUAGLIANI, thanks for your post! Indeed it would be better to use a RooFormulaVar, because the RooLinearVar is not battle-tested so much. I just thought that it’s not possible to use non-fundamental variables in the specific case of the RooHistPdf. But I remember now that this is not true! There is a [RooHistPdf constructor](https://root.cern.ch/doc/master/classRooHistPdf.html#a99fbb46807505e28d99e161298a42de1) that allows you to specify PDF variables and RooDataHist variables separately, so you should use that one. The code would look somewhat like this: // Helper func…

---

_[View the full topic](https://root-forum.cern.ch/t/roofit-in-root-6-28-04/55267)._
