Well, I set the target of this constraint to 20 or so, so the minimum will move in the direction of what the constraint tells it to.
Oh, there are two more problems.
- You are creating two frames that have different y axes. You have to delete
frame2 entirely, and only plot on
- I would advise to use the RooAddPdf in extend mode instead of extending manually. That makes a difference when different ranges are entering the game (here, it’s presumably the fit range from 0 to 200, but the plot range from 0, 100).
Here’s the updated extension:
RooRealVar ngauss ("ngauss", "ngauss", 100, 0, 100);
RooRealVar npoly ("npoly", "npoly", 100, 0, 200);
RooAddPdf model("model","model", RooArgSet(gauss,poly), RooArgSet(ngauss,npoly));
Here it looks much more like what you expect, namely
- The red curve has a sharper minimum.
- The minimum is around 20, as I set it.