Re: TGraph2DErrors Class Troubles

From: Olivier Couet <couet_at_mail.cern.ch>
Date: Thu, 16 Jun 2005 09:40:40 +0200 (CEST)

Hi,

Can you send a running macro ?
with the one you sent I get:

root [0]
Processing primo.C...

 FCN=0 FROM MIGRAD    STATUS=CONVERGED     119 CALLS         120 TOTAL
                     EDM=0    STRATEGY= 1  ERROR MATRIX UNCERTAINTY 100.0 
per cent
  EXT PARAMETER                APPROXIMATE        STEP         FIRST
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE
   1  p0          -3.00000e-03   1.41421e+00   0.00000e+00   0.00000e+00
   2  p1           0.00000e+00   1.41421e+00   0.00000e+00   0.00000e+00
   3  p2           0.00000e+00   1.41421e+00   0.00000e+00   0.00000e+00
Error in <TGraph2DErrors::GetHistogram>: Empty TGraph2D Error: illegal pointer to class object GetXaxis() 0x0 239 FILE:primo.C LINE:72
*** Interpreter error recovered ***

Also put it in attachment, not in the body of the email. Thanks.

Cheers,

 Olivier Couet

On Wed, 15 Jun 2005, Danilo Piparo wrote:

> Hello,
> I encountered the following problems working with TGraph2DErrors class:
>
> 1.I don't know how to display points errorbars drawing a TGraph2DErrors
> object.
>
> 2.I fitted a TGraph2DErrors with a TF2 function (fit params are ok). I
> can't correctly display the function in the same Canvas where the
> TGraph2DErrors object is.
>
> Could Anyone help?
>
> -------------------------------------------------------------------------
> Here is the Code of the Macro I used:
>
>
> double getXmin(TGraph* g)
> {
> double s = g->GetN () ;
> double* asseX = new double[s] ;
> asseX = g->GetX () ;
> double minimo = asseX[0] ;
> //delete [] asseX ;
> return (minimo) ;
> }
>
> double getXmax(TGraph* g)
> {
> double s = g->GetN () ;
> double* asseX = new double[s] ;
> asseX = g->GetX () ;
> double massimo = asseX[s-1] ;
> //delete [] asseX ;
> return (massimo) ;
> }
>
> int primo()
> {
>
> TFile f ("output_gra.root") ;
> f.cd () ;
>
> TGraph2DErrors * pluto = new TGraph2DErrors () ;
> TGraph * pippo ;
> int r = 0 ;
> double * point ;
> double * epoint ;
>
> for (int phi=0 ; phi<90 ; ++phi)
> {
> char nome[80] ;
> sprintf (nome,"piccoRing_%d",phi) ;
> pippo = (TGraphErrors* ) f.Get (nome) ;
> if (pippo)
> {
> int l = pippo->GetN () ;
> point = new double[l] ;
> point = pippo->GetY () ;
> epoint = new double[l] ;
> epoint = pippo->GetEY();
>
> double min = getXmin(pippo) ;
> double max = getXmax(pippo) ;
>
>
>
> for (int eta = 0 ; eta < max-min ; ++eta)
> {
> // std::cout << "r,eta,phi,point,ep = "
> // << "r: " << r
> // << " point[" << eta << "] : " <<
> point[eta]
> // << " epoint[" << eta << "] : " <<
> epoint[eta]
> // << std::endl ;
> pluto->SetPoint (r,
> eta,phi,
> point[eta]) ;
> pluto->SetPointError (r,0,0,epoint[eta]) ;
>
> ++r;
> }
> delete [] point;
> delete [] epoint;
>
> }
> }
>
> TCanvas c1 ;
>
> TF2 *f1 = new TF2("f1","[0]+ [1]*x + [2]*y",0,35,0,40);
> f1->SetParameter(0,-0.003);
> f1->SetParameter(1,0);
> f1->SetParameter(2,0);
> pluto->Fit(f1);
>
> //D Maquillage
> pluto->GetXaxis()->SetTitle("eta");
> pluto->GetYaxis()->SetTitle("phi");
> pluto->GetZaxis()->SetTitle("peak");
> pluto->GetXaxis()->SetTitleOffset(1.45);
> pluto->GetYaxis()->SetTitleOffset(1.45);
> pluto->GetZaxis()->SetTitleOffset(1.45);
> pluto->SetTitle("Peak Vs eta-phi");
> pluto->SetMarkerStyle(6);
> pluto->SetMarkerSize(0.4);
> pluto->SetMarkerColor(46);
>
> f1->Draw("surf");
> pluto->Draw ("P0 same") ;
> c1.SetBorderMode(0);
> c1.Print ("piccoetaphi2D.eps","eps") ;
> c1.Print ("piccoetaphi2D.ps","ps") ;
> c1.Print ("piccoetaphi2D.gif","gif") ;
>
> TFile g ("piccoetaphi2D.root","RECREATE") ;
> g.cd () ;
> pluto->Write () ;
> g.Close () ;
> }
> ------------------------------------------------------------------------------
>
>
>

-- 
Org:    CERN - European Laboratory for Particle Physics.
Mail:   1211 Geneve 23 - Switzerland                     Mailbox: J25910      
E-Mail: Olivier.Couet_at_cern.ch                            Phone:   +41 22 7676522
WWW:    http://cern.ch/Olivier.Couet/                    Fax:     +41 22 7670300
Received on Thu Jun 16 2005 - 09:40:47 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:09 MET