# Doubts on histogram sum

**URL:** <https://root-forum.cern.ch/t/doubts-on-histogram-sum/53314>\
**Category:** ROOT\
**Created:** [January 28, 2023, 3:25pm UTC](https://root-forum.cern.ch/t/doubts-on-histogram-sum/53314 "2023-01-28T15:25:58Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [January 31, 2023, 6:55pm UTC](https://root-forum.cern.ch/t/doubts-on-histogram-sum/53314/12 "2023-01-31T18:55:59Z")

</div>

This looks strange in your case:

```cpp
fit->Constrain(1,0.0,1.0); // constrain fraction 1 to be between 0 and 1
fit->SetRangeX(1,15); // use only the first 15 bins in the fit

```

Another approach (not using the [TFractionFitter](https://root.cern/doc/master/classTFractionFitter.html)) has been proposed in:

> [@Newbie Fit/RooFit Question](https://root-forum.cern.ch/t/newbie-fit-roofit-question/53334):
>
> Hi, I’m pretty new to Fit/RooFit, and I need some help to get started with my current project. My goal is to find the best-fit parameters to weigh histograms into the desired shape. This means I have three TH1s (mc1, mc2, data); I want to give mc1 and mc2 different weights to make them fit the shape of data (sth like par[0]\*mc1+par[1]\*mc2=data maybe by minimizing chi2 between the weighted MC and Data). Since par[0]+par[1] !=1, TFractionFitter does not work for me. Is there any way I can achiev…

---

_[View the full topic](https://root-forum.cern.ch/t/doubts-on-histogram-sum/53314)._
