Hi experts on RooFit,
I have recently upgraded my root to version 6.28.04 in the hope to get rid of some problems in RooFit. However, the opposite seems to be the problem. Two strange things now happen with my code that used to run (acceptably) smoothly on root 6.24.06. First of all, a canvas appears that has never been there before (it shows some of my data and tries to fit to it, but I have not even a clue why it appears). Secondly, when plotting the components of a
RooAddPdf object they appear very weird (see picture). Yet the whole fit together looks normal.
On a side note I would like to mentioned that I had problems installing root 6.28.04 and had to run cmake build with
-Druntime_cxxmodules=OFF. I do not know if that could influence the result.
ExampleOfProblem.pdf (21.6 KB)
Hi experts on RooFit,
thanks for posting about this!
I don’t know how this could happen with the Canvas, maybe it’s not related to RooFit.
For the plot: it looks like a problem that is only related to RooFit plotting, not the model itself. Do you have the same problem when you try ROOT 6.26.10? And can you provide me with the files to reproduce the problem (at least the model definition)? Otherwise I’m afraid it’s hard to understand what is going on here.
Hi @jonas ,
thank you for your answer! I have tried the same with the current home-brew distributed version (6.26.06) as I did not have 6.26.10 installed. The result is quite bad (the picture is attached). I will give you examples of my code, as the code itself is quite long.
First I define the shifts I later use:
RooRealVar shiftSigStar("shiftSigStar","Shift of SigStar",StartShiftSigStar,MinShift,MaxShift); RooFormulaVar MassShiftedSigStar("MassShiftSigStar","Mass - shiftSigStar",RooArgSet(mass,shiftSigStar));
Then a scaling number for the components:
I convert my histograms to a RooDataHist (ListHist is a vector of TH1*):
RooDataHist *Sim1405 = new RooDataHist("Sim1405","Simulation of 1405",mass,ListHist);
I make Pdfs from them:
RooHistPdf Curve1405("Curve1405","Kurve 1405",MassShifted1405,mass,*Sim1405,0);
I plot the data I want to fit to on a RooPlot frame:
RooDataHist values("values","values",mass, Import(*RealHist)); values.plotOn(Massframe);
Then I define my whole Pdf:
Curves = new RooAddPdf("Curves", "Kurven", RooArgList(Curve1405, Curve1520, CurveLam, CurveSigStar, CurveSig0, CurveLam0Pi0, *CurveBKG), RooArgList(Var1405, Var1520, VarLam, VarSigStar, VarSig0, VarLamPi, VarBack));
Then I fit to the data (The values in Range make sense, I checked that):
Afterwards I set the shift to a multiple of the BinWidth of the Histos, as otherwise it would look very bad and the shift should be discrete:
Lastly I plot the fit and the components like:
Curves->plotOn(Massframe, Range(0., 2000)); Curves->plotOn(Massframe,Name("Lam1520"),Components(Curve1520),LineStyle(kDashed),LineColor(kRed));
I hope this helps debugging the code. Please let me know, if you need any more information!
On a side note: In root 6.24 it worked, but I do not have it installed anymore and sadly did not save the plot. However, there it looked fine.
ExampleProblem626.pdf (33.3 KB)
Maybe it has something to do with Draw Options? I just realized that the RooCurve inherits from TGraph and has therefor Draw Options. So maybe the default Draw Options have changed with the root versions?
@Jonas sorry to ask again, but have there been any news on this?
I’m aware of the general problem, but I didn’t expect it to look that bad!
In this line:
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
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.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.