# 2D plot in a circular domain?

Hi,

Is there a way to restrain the TF2::Draw to a circular domain (in place of a rectangular one) ?
I haven’t seen such a feature that could be very usefull in some cases (e.g. the Mexican-Hat function 1-x^2-y^2+(x^2+y^2)^2) where the values is very large in the corners.

Best,
Christophe.

Christophe,

Yes, this is implemented in ROOT via a TCutG. In the example below I create a circular cut.

Rene

{
double range = 3;
const Int_t n = 30;
Double_t x[n+1],y[n+1];
Double_t rcut = 0.85range;
Double_t dphi = TMath::TwoPi()/n;
for (Int_t i=0;i<n;i++) {
x[i] = rcut
TMath::Cos(idphi);
y[i] = rcut
TMath::Sin(i*dphi);
}
x[n] = x[0]; y[n] = y[0];
TCutG *mycut = new TCutG(“mycut”,n+1,x,y);
TF2 *f2 = new TF2(“f2”,“1-x^2-y^2+(x^2+y^2)^2”,-range,range,-range,range);
f2->Draw(“surf1 [mycut]”);
}

Thanks a lot, it gives very good results.
I just changed a bit the function to limit the value in the hidden region, since the z axis ranged is computed ignoring the TCutG:

TF2 f2 = new TF2(“TexMex”,"TMath::Min([0]-[1](x^2+y^2)+[2](x^2+y^2)^2,[3][0])",-range,range,-range,range);
f2->SetParameters(1,1.6,1,2);

Christophe.

Christophe,

Yes, your parameters make a nice mexican hat :

In my previous mail, I forgot to mention that you can define multiple cuts
when calling Draw with
"surf1 [mycut1,mycut2]"

Rene