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?
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);
//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 () ;
}
This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:09 MET