How to Get the Value of the Width of the Error Band from VisualizeError

I use the following code to draw the error band of a fitting curve:

RooRealVar x("x", "x", pd[i], pu[i]);
RooDataHist data("data", "data", x, hvar[i]);
RooRealVar mg1("mg1", "mg1", pmean[i], pd[i], pu[i]);
RooRealVar sg1("sg1", "sg1", insg1[i], lsg1[i], hsg1[i]);
RooGaussian gauss1("gauss1","gauss1", x, mg1, sg1);
RooRealVar mg2("mg2", "mg2", pmean[i], pd[i], pu[i]);
RooRealVar sg2("sg2", "sg2", insg2[i], lsg2[i], hsg2[i]);
RooGaussian gauss2("gauss2","gauss2", x, mg2, sg2 );
RooRealVar frac("frac","frac",infrac[i],lfrac[i],hfrac[i]);
x.setRange("mini", pd[i], pu[i]);
RooAddPdf gauss("gauss","gauss",RooArgList(gauss1,gauss2),RooArgList(frac));

RooRealVar co1("co1","coefficienct #1", inco1[i], dco1[i], uco1[i]);
RooRealVar co2("co2","coefficienct #2", inco2[i], dco2[i], uco2[i]);
RooChebychev  poly("poly", "poly PDF", x, RooArgList(co1,co2));
RooRealVar f1("Sig", "fra1", innsig[i], lnsig[i], hnsig[i]);
RooRealVar f2("Bkg", "fra2", innbkg[i], lnbkg[i], hnbkg[i]);
RooAddPdf sum("sum", "sig+bak", RooArgList(gauss,poly), RooArgList(f1,f2));
RooFitResult *fitresult;
RooPlot *xframe=x.frame();
data.plotOn(xframe);
sum.plotOn(xframe);
sum.plotOn(xframe, VisualizeError(*fitresult), Components("poly"), FillColor(kSpring+10));
sum.plotOn(xframe, VisualizeError(*fitresult), Components("gauss1"), FillColor(kRed-9));

However, the error band seems abnormal. I want to obtain the width of the error band.

Would you like to add more details or context to this? For example, any specific issues you’re encountering or the expected output?

@moneta

Hi,

I am sorry to read you are encountering this issue.
Since you already pinged @moneta , I allow myself to ask @couet if he sees an obvious issue with the graphics settings.

Cheers,
D

Hi, do you have some minimal C++ macro reprducing the problem you are experimenting ?

fithp1.cxx (15.1 KB)

I think another file is required:

Processing fithp1.cxx...
In file included from input_line_9:1:
/Users/couet/Downloads/fithp1.cxx:1:10: fatal error: '/Volumes/D/Work/BESIII/bes3plotstyle.c' file not found
#include "/Volumes/D/Work/BESIII/bes3plotstyle.c"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

cms.txt (565 Bytes)
fith.txt (162 Bytes)
bes3plotstyle.c (12.2 KB)
bes3plotstyle.h (5.9 KB)
mc_2232S_02a.root (11.4 KB)

Thanks. Now I get this:

root [0] 
Processing fithp1.cxx...
Error in <TFile::TFile>: file /Users/couet/Downloads/mc_S_02.root does not exist

PID1.zip (1.4 MB)
Please use fithp1.cxx

same thing:

root [0] .x fithp1.cxx
Processing fitp.cxx...
Error in <TFile::TFile>: file /Users/couet/Downloads/PID1/mc_S_02.root does not exist

What does Line127 shows?

PID1.zip (1.5 MB)

Hi, the script runs now. However, I had to modify the first two lines of the script to find the included files.

When I run your macro, several EPS and PDF files are generated. They look like the following picture (if I understand correctly, the first plot you posted is a close-up zoom on the top of the peak). What’s wrong with this picture?

Please zoom in. I want read the value of the width of the red error band. This plot just an example.
image

The width is defined in pixels in the PDF file, and the PDF viewer renders the line accordingly. I’m not sure what value you aim to achieve with this significant zoom-in. It doesn’t seem to make much sense to me to zoom in so much.

I you want to make a zoom you should make in at the C level not in the pdf file.

Hi

This error band is from VisualizeError
I just wish to know how to draw the errorband from VisualizeError(*fitresult), not means this plot have problem.

Cheers

The error bands in ROOT are drawn using the option E3. I guess (but I’m not sure) it is the same in RooPlot? (@moneta?)

This error bands is from Rootfit
sum.plotOn(xframe, VisualizeError(*fitresult), Components(“gauss1”), FillColor(kRed-9));
But I cannot read the value.

The error bands are drawn by connecting the extremities of the error bars. So, at a given point (x,y), the top of the band is equal to y + erry and the bottom is y - erry.