Contours

Hi Elizabeth,

I see that my reply yesterday to you was lost.

So, if you want to compute the combined (averaged) value of the mass and width of all your experiments what you are doing is correct. I see also the contour that you get seems to me right, why are you saying it is too small ?

Lorenzo

Hi Lorenzo,

Yes, I realised that the contours were correct in the sense that they display the correlation M vs Width (or simaM vs sigmaW) within the 68% or 95% C.L. of the fit or the 2 relevant parameters.

However this is not what I am looking for and I see I have difficulties to explain what I need. Then I will use a published exemple (attached files), where one can see directly from the plot the center of the ellipse, i.e.
fitted top mass and alphas , and the fitted 1 sigmaM and 1 sigma alpha (see table) from the dimensions of the 1 sigma ellipse; similarly for 2 sigma.
This is precisely what I would like to do for Mw and Width. This looks trivial but I have not yet found a satisfactory solution. I tried to display the fitting function but this does not give the desired result either; I would have expected a simple ellipse, but it draws different levels whatever is the draw option ( I believe I tried them all).
This is puzzling as the literature is full of this kind of plots, thus there should be a solution…

Thanks again for your kind help in finding the appropriate solution.

Elizabeth

Attachments were lost, I think. Here are they




Hi,

I understand now. As I wrote before, you want to draw the contour showing as axis the mean sigma_mass and not the sigma on the mean of the mass !
So, yes to get this, you need to draw the contour of the fitted functions from the fit.
I just realised this is not straightforward doing it with the graphics options.
I’ll try to make a code example later on showing something like the picture you have sent

Best Regards

Lorenzo

Great! Thanks!!!

.
exampleBigaus.C (2.72 KB)

So good to see it done! Many thanks, Pepe!!!
Thank you to you both for getting me through it!
Best,
Elizabeth

Yes, but I see that example from Pepe, makes the contour from the fit.
This is not what you want, as I have understood.

For reference, I have made an example that makes the contour of a 2d correlated gaussian.
I think you should use this example to draw the contours by using as parameter values for the 2d gaussian the fitted ones from your histogram.

Best Regards

Lorenzoexample2dGausContour.C (1.08 KB)

oh yes, you are right. I was so impatient to see it done that I took my desire for reality.
Thank you for the example. However I had not used bigaus but I wrote it explicitly since I can’t access bigaus, although I have TFormula in my include statements; probably I miss one include statement but was not able to find which one.
Thus I replaced bigaus by my function and got the error:
error: no member named ‘bigaussian_pdf’ in namespace ''ROOT::Math’
although I have TMath in my include statements. Am I missing any other statement?
E

I found I needed Math/PDFFuncMatCore
I get a very strange result, as the ellipse is not entered at the right place and is rather a circle, and of course there is no correlation. I have probably misunderstood something in your example.
E

Stupid me ! forgot to change set parameters! Getting tired, I guess.
E.

HI,

Yes you can replace “bigaus” with your TFormula and these 3 lines

double corr = f2->Eval(0,0)/ROOT::Math::bigaussian_pdf(0,0,1,1,0);
contours[0] = corr*ROOT::Math::bigaussian_pdf(2,2,1,1,0);                                               
contours[1] = corr*ROOT::Math::bigaussian_pdf(1,1,1,1,0);

with the 1d-gaussian since we use it with 0 correlation

double corr = f2->Eval(0,0)/(ROOT::Math::normal_pdf(0,1)*ROOT::Math::normal_pdf(0,1));
contours[0] = corr*ROOT::Math::normal_pdf(2,1)*ROOT::Math::normal_pdf(2,1);
contours[1] = corr*ROOT::Math::normal_pdf(1,1)*ROOT::Math::normal_pdf(1,1);

Here is the new corrected macro
example2dGausContour.C (1.83 KB)

Lorenzo

Elizabeth, maybe you could save your histogram (the “final” one that you then fit with “bigaus”) into a root file and attach it here.

Looks almost good now (attached file) if I comment the line fitEllipse->SetContour(2,contours) in the following code (except the red contour lines since I do not ask for only 2, but nothing is drawn when I do not comment the line, except the axes (attached file).

Very close but not yet arrived, it seems. Thanks for your continued help.

gSystem->Load("libMathCore");

TCanvas *c  = new TCanvas("c","Contours",0,0,800,700);

fitEllipse->SetFillStyle(1000);
fitEllipse->SetLineWidth(1);
fitEllipse->SetNpx(1000);
fitEllipse->SetNpy(1000);
double contours[2];

#if ROOT_VERSION_CODE >= ROOT_VERSION(6,7,6)
double corr = fitEllipse->Eval(0,0)/ROOT::Math::bigaussian_pdf(0,0,1,1,0);
contours[0] = corrROOT::Math::bigaussian_pdf(2,2,1,1,0); //0.05;
contours[1] = corr
ROOT::Math::bigaussian_pdf(1,1,1,1,0);
#else
double corr = fitEllipse->Eval(0,0)/(ROOT::Math::normal_pdf(0,1)ROOT::Math::normal_pdf(0,1));
contours[0] = corr
ROOT::Math::normal_pdf(2,1)ROOT::Math::normal_pdf(2,1);
contours[1] = corr
ROOT::Math::normal_pdf(1,1)*ROOT::Math::normal_pdf(1,1);
#endif

// fitEllipse->SetContour(2,contours);

Int_t colors[2] = {kYellow, kGreen};
gStyle->SetPalette(2,colors);

fitEllipse->Draw("cont0 z");
fitEllipse->Draw("cont3 same");

NoContour.pdf (13.9 KB)
Contours.pdf (512 KB)

Hi Pepe,
Sure, you will find it attached.
Elizabeth
hMassVsWidth.root (47 KB)