RE: Contour

From: Manuel Mussini <Manuel.Mussini_at_bo.infn.it>
Date: Tue, 4 Mar 2008 08:08:33 +0100


This is what I tried!
But I'm getting this error (I attached my files):

root [0] .x Chi2Test.C

 FCN=14.4504 FROM MIGRAD    STATUS=CONVERGED    1542 CALLS        1543 TOTAL
                     EDM=9.27102e-009    STRATEGY= 1      ERROR MATRIX ACCURATE
  EXT PARAMETER                                   STEP         FIRST
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE
   1  p0          1.27296e+000  8.83337e-002  4.95446e-005 -6.27209e-004
   2  p1          3.11769e+003  1.01222e+003  1.30115e-001 -1.20084e-006
   3  p2         -1.01643e+001  5.47604e-001  7.09960e-005 -1.93891e-003
   4  p3         -1.45784e-001  6.88482e-003  1.01713e-006  1.55440e-001
   5  p4          3.65077e-001  1.32114e-002  1.70301e-006  7.56256e-002
   6  p5         -9.97595e+000  2.18777e+000  2.06114e-004  3.91486e-005
   7  p6          2.07909e+001  4.54802e+000  4.26765e-004  1.35532e-005
Error: illegal pointer to class object chi2PlotMc2 0x0 628 C:\root\ManuC\Chi2Test.C(44)
*** Interpreter error recovered ***
root [1]

Bye...

> -----Original Message-----
> From: Rene Brun [mailto:Rene.Brun_at_cern.ch]
> Sent: Monday, March 03, 2008 22:12
> To: Manuel Mussini
> Cc: roottalk_at_lxbuild091.cern.ch
> Subject: Re: [ROOT] Contour
>
> Yes, you can get the contour for any user defined TF1. See the fitcont.C
> example modified below
>
> Rene Brun
>
>
> double myfunc(double* x, double* par) {
> return par[0]*TMath::Gaus(x[0],par[1],par[2]);
> }
> void fitcont()
> {
> // Example illustrating how to draw the n-sigma contour of a Minuit fit.
> // To get the n-sigma contour the ERRDEF parameter in Minuit has to set
> // to n^2. The fcn function has to be set before the routine is called.
> //
> // WARNING!!! This test works only with TMinuit
> //
> // The TGraph object is created via the interpreter. The user must cast it
> // to a TGraph*
> // Author: Rene Brun
>
> TCanvas *c1 = new TCanvas("c1");
> TH1F *h = new TH1F("h","My histogram",100,-3,3);
> h->FillRandom("gaus",6000);
> TF1 *f1 = new TF1("f1",myfunc,-3,3,3);
> f1->SetParameters(100.,0.,1.);
> h->Fit(f1);
> c1->Update();
>
> TCanvas *c2 = new TCanvas("c2","contours",10,10,600,800);
> c2->Divide(1,2);
> c2->cd(1);
> //get first contour for parameter 1 versus parameter 2
> TGraph *gr12 = (TGraph*)gMinuit->Contour(40,1,2);
> gr12->Draw("alp");
> c2->cd(2);
> //Get contour for parameter 0 versus parameter 2 for ERRDEF=2
> gMinuit->SetErrorDef(4); //note 4 and not 2!
> TGraph *gr2 = (TGraph*)gMinuit->Contour(80,0,2);
> gr2->SetFillColor(42);
> gr2->Draw("alf");
> //Get contour for parameter 0 versus parameter 2 for ERRDEF=1
> gMinuit->SetErrorDef(1);
> TGraph *gr1 = (TGraph*)gMinuit->Contour(80,0,2);
> gr1->SetFillColor(38);
> gr1->Draw("lf");
> }
>
>
>
> Manuel Mussini wrote:
> >
> > Hi,
> >
> > I'm trying to plot a chi2 contour as described here:
> >
> > http://root.cern.ch/root/html/TMinuit.html#TMinuit:Contour
> >
> > the example fitcont.C works perfectly; is it possible to do the same
> > thing using a user defined TF1 as fitting function?
> >
> > Is there an example to follow as tutorial?
> >
> > Thanks!
> >
> > Bye.
> >

Received on Tue Mar 04 2008 - 08:09:16 CET

This archive was generated by hypermail 2.2.0 : Tue Mar 04 2008 - 11:50:01 CET