Re: [ROOT] TF2 ctor doest work in the interpreter.

From: Aihong Tang (aihong@cnr.physics.kent.edu)
Date: Fri Apr 28 2000 - 22:00:22 MEST


Hi, Rene:

After a little more play, I find that the TF2::Draw("ASAME") can find the
x and y axis on an existing 3D box, but it just ignores the z axis of the
existing graph and draw by its own scale. (or I did sth. wrong?)

In the following file, I have two gauss, one should have height 10, the
other should have height 1.  but the graph shows they are at the same
height. 

the file drawSurf.cxx
====================
#include "TF2.h"

Double_t gausxy( Double_t* x, Double_t* par ) {

  Double_t dxds= (x[0]-par[0])/par[2];
  Double_t dyds= (x[1]-par[1])/par[3];
  Double_t rho= par[4];
  return par[5]*exp( -0.5*( dxds*dxds + dyds*dyds 
                     - 2.0*dxds*dyds*rho )/( 1.0-rho*rho) );

}

void drawSurf(){

  TF2* f2= new TF2( "myfunc2", gausxy, -10, 10, -10, 10, 6 );
  f2->SetParameter( 0, -4.0 );
  f2->SetParameter( 1, -4.0 );
  f2->SetParameter( 2, 2.0 );
  f2->SetParameter( 3, 2.0 );
  f2->SetParameter( 4, 0.1 );
  f2->SetParameter( 5, 10.0 ); //height 10
  f2->SetLineColor(2);
  f2->Draw("surf");

  TF2* f3= new TF2( "myfunc2", gausxy, -10, 10, -10, 10, 6 );
  f3->SetParameter( 0, 4.0 );
  f3->SetParameter( 1, 4.0 );
  f3->SetParameter( 2, 2.0 );
  f3->SetParameter( 3, 2.0 );
  f3->SetParameter( 4, 0.1 );
  f3->SetParameter( 5, 1.0 ); //height 1
  f3->SetLineColor(3);
  f3->Draw("surfASAME");

}


Another issue is, if you change the option"surf" to "surf1" in the
example above and draw the two functions, then when you try to rotate 3D
box, you will find the surface of the second function honestly cover the
first function, which make the base of the first gauss not visable. Is
there a way to make the surface "transparant"?


Again I am running ROOT 2.24  on Linux.


Best Regards.

Aihong



On Fri, 28 Apr 2000, Rene Brun wrote:

> Hi Aihong,
> 
> This problem is due to a change in CINT in the member function overload
> resolution in version 2.24. I hope this can be changed by Masa before
> we release this version. Meanwhile, you can work around this problem
> in the way indicated in your original code below.
> 
> Rene Brun
> 
> Aihong Tang wrote:
> > 
> > Hi,
> > 
> > I have a drawSurf3.cxx which is copied from roottalk digest,
> > I assume it should work in both session:
> > 
> > First interactive session
> > =========================
> > Root > .L drawSurf.cxx
> > Root > drawSurf()
> > 
> > Second interactive session
> > ==========================
> > Root > .L drawSurf.cxx++
> > Root > .drawSurf()
> > 
> > The Second one works, but the first session gives the following message:
> > 
> > root4star [0] .L drawSurf.cxx
> > root4star [1] drawSurf()
> > Error: Ambiguous overload resolution (10400,2) FILE:drawSurf.cxx LINE:19
> > Calling : TF2::TF2(char*,char*,int,int,int,int,int);
> > Match rank: file     line  signature
> >   ffffffff (compiled)   0 TF2 TF2::TF2(const TF2&);
> > *    10400 (compiled)   0 TF2 TF2::TF2(const char*,Double_t (*)(Double_t*,
> > Double_t*),Float_t,Float_t,Float_t,Float_t,Int_t);
> > *    10400 (compiled)   0 TF2 TF2::TF2(const
> > char*,void*,Float_t,Float_t,Float_t,Float_t,Int_t);
> >   ffffffff (compiled)   0 TF2 TF2::TF2(const char*,const
> > char*,Float_t,Float_t,Float_t,Float_t);
> >   ffffffff (compiled)   0 TF2 TF2::TF2();
> > *** Interpreter error recovered ***
> > 
> > The file drawSurf.cxx
> > =====================
> > #include "TF2.h"
> > 
> > Double_t gausxy( Double_t* x, Double_t* par ) {
> > 
> >   Double_t dxds= (x[0]-par[0])/par[2];
> >   Double_t dyds= (x[1]-par[1])/par[3];
> >   Double_t rho= par[4];
> >   return exp( -0.5*( dxds*dxds + dyds*dyds
> >                      - 2.0*dxds*dyds*rho )/( 1.0-rho*rho) );
> > 
> > }
> > 
> > void drawSurf(){
> > 
> #ifdef __CINT__
>    TF2* f2= new TF2( "myfunc2", (void*)gausxy, -10, 10, -10, 10, 5 );
> #else
>   TF2* f2= new TF2( "myfunc2", gausxy, -10, 10, -10, 10, 5 );
> #endif
> >   f2->SetParameter( 0, 0.0 );
> >   f2->SetParameter( 1, 0.0 );
> >   f2->SetParameter( 2, 2.0 );
> >   f2->SetParameter( 3, 2.0 );
> >   f2->SetParameter( 4, 0.1 );
> >   f2->Draw("surf");
> > 
> > }
> > 
> > I am running root 2.24 on  Linux.
> > 
> > Thanks!
> > 
> > Aihong
> 



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:24 MET