Re: [ROOT] Fitting a TGraphErrors

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Oct 21 2002 - 10:29:28 MEST


Hi Amber,

You should not see the lines connecting the points if you do not specify
the option "L". See macro in attachement.

Concerning the crash, my guess is that you use an old version.
Move to the PRO version 3.03/09.

Rene Brun

On Mon, 21 Oct 2002 amber.jenkins@ic.ac.uk wrote:

> Hi,
> 
> - I have a root-tuple containing various TGraphErrors graphs.
> - The existing TGraphErrors have their points joined with straight lines.
> - I want to fit these graphs with exponentials.
> - I want to display the fitted curves and the points with error bars, but
> NOT the straight lines joining the points.
> - I also need to superimpose more than one fitted graph on the same axis,
> and add a legend too.
> 
> I tried fitting a graph in 2 ways:
> 
> 1. I drew the graph by clicking in the TBrowser, then fitted it. However,
> the straight lines remain on the graph.
> 
> root [0] TCanvas *c1 = new TCanvas
> root [1] TBrowser QQ
> (I drew the graph using the TBrowser)
> root [2]  TF1 *E1 = new TF1("E1","[0] + [1]*exp(-[2]*x)",20,86)
> root [3] Graph_calparton_c->Fit("E1","R")
>  **********
>  **    1 **SET ERR           1
>  **********
>  **********
>  **    5 **MIGRAD        5000   3.533e-11
>  **********
>  MIGRAD MINIMIZATION HAS CONVERGED.
>  FCN=0.923423 FROM MIGRAD    STATUS=CONVERGED     266 CALLS         267
> TOTAL
>                      EDM=1.71871e-19    STRATEGY= 1  ERROR MATRIX
> UNCERTAINTY
> 1.8 per cent
>   EXT PARAMETER                                   STEP         FIRST
>   NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE
>    1  p0           9.04319e-02   5.72987e-03   7.28854e-10   1.39468e-08
>    2  p1           1.37449e-01   1.23834e-02   1.12821e-09  -1.06242e-07
>    3  p2           3.63376e-02   6.92076e-03   9.83969e-10   1.49311e-07
>  FCN=0.923423 FROM MIGRAD    STATUS=CONVERGED     266 CALLS         267
> TOTAL
>                      EDM=1.71871e-19    STRATEGY= 1  ERROR MATRIX
> UNCERTAINTY
> 1.8 per cent
>   EXT PARAMETER                                   STEP         FIRST
>   NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE
>    1  p0           9.04319e-02   5.72987e-03   7.28854e-10   1.39468e-08
>    2  p1           1.37449e-01   1.23834e-02   1.12821e-09  -1.06242e-07
>    3  p2           3.63376e-02   6.92076e-03   9.83969e-10   1.49311e-07
> (Int_t)0
> root [4] E1->Draw("same")
> 
> -----
> 
> 2. I created some axes and drew the graph onto them. When I try to fit
> ROOT crashes:
> 
> root [0] TBrowser B
> root [1] TCanvas *c1 = new TCanvas
> root [2] htemp  = new TH2F("htemp","title",100,17,92,100,0.08,0.19)
> (class TH2F*)0x108da310
> root [3] htemp->Draw()
> root [4] TFile *f1 = new TFile("NEWzhall_5.root")
> root [5] Graph_calparton_c->Draw()
> root [6]  TF1 *E1 = new TF1("E1","[0] + [1]*exp(-[2]*x)",20,86)
> root [7] Graph_calparton_c->Fit("E1","R")
>  **********
>  **    1 **SET ERR           1
>  **********
>  **********
>  **    5 **MIGRAD        5000   3.533e-11
>  **********
>  MIGRAD MINIMIZATION HAS CONVERGED.
>  FCN=0.923423 FROM MIGRAD    STATUS=CONVERGED     266 CALLS         267
> TOTAL
>                      EDM=1.71871e-19    STRATEGY= 1  ERROR MATRIX
> UNCERTAINTY   1.8 per cent
>   EXT PARAMETER                                   STEP         FIRST
>   NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE
>    1  p0           9.04319e-02   5.72987e-03   7.28854e-10   1.39468e-08
>    2  p1           1.37449e-01   1.23834e-02   1.12821e-09  -1.06242e-07
>    3  p2           3.63376e-02   6.92076e-03   9.83969e-10   1.49311e-07
>  FCN=0.923423 FROM MIGRAD    STATUS=CONVERGED     266 CALLS         267
> TOTAL
>                      EDM=1.71871e-19    STRATEGY= 1  ERROR MATRIX
> UNCERTAINTY   1.8 per cent
>   EXT PARAMETER                                   STEP         FIRST
>   NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE
>    1  p0           9.04319e-02   5.72987e-03   7.28854e-10   1.39468e-08
>    2  p1           1.37449e-01   1.23834e-02   1.12821e-09  -1.06242e-07
>    3  p2           3.63376e-02   6.92076e-03   9.83969e-10   1.49311e-07
> (Int_t)0
> 
>  *** Break *** segmentation violation
> Root >
>  *** Break *** segmentation violation
> Root >
>  *** Break *** segmentation violation
> Root >
> 
> -----
> 
> a) How do I fit a TGraph / TGraphErrors without displaying the straight
> lines?
> 
> b) I need to create axes on which to superimpose several different graphs.
> How can I fit each graph and superimpose them?
> 
> Thanks very much for your help,
> 
>         Amber
> 





This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:15 MET