Drawing non-scaled TF2 on top of TH2

The thing is really simple, but I cannot find the answer in the documentation or here, on RootTalk…

I want to draw a TF2 function on top of the TH2, with for example, Draw(“SURFSAME”). But this causes the function to be rescaled to the histogram size, thus not displaying proper values.

Is it possible to draw over the histogram, but without rescaling?

Please send a small example showing what you do.

OK, I coded something like that:

[code]TH2D *hist = new TH2D(“hist”, “hist”, 20, 0, 20, 20, 0, 20);
for(int x=0; x<20; x++) for(int y=0; y<20; y++)
hist->SetBinContent(x, y, 0);

hist->SetBinContent(9, 9, 0.5);
hist->SetBinContent(9, 11, 0.5);
hist->SetBinContent(11, 9, 0.5);
hist->SetBinContent(11, 11, 0.5);
hist->SetBinContent(10, 10, 1);


TF2 *pol2_2d = new TF2(“pol2_2d”, “1-((x-10)^2+(y-10)^2)”, 0, 20, 0, 20);
TF2 pol2_2d_1 = new TF2(“pol2_2d_1”, "1-0.001((x-10)^2+(y-10)^2)", 0, 20, 0, 20);




pol2_2d and pol2_2d_1 exactly overlap… How do I make them display real values?

Ok I see what you mean. The SAME option deos not work in 3D like in 2D. 3D surfaces and legos are drawn in some normalized space. That is why you get this effect. In 3D (with LEGO and SURF options) SAME works properly only if the plots you superimpose have the same range.

So I have a simple question…

I would like to fit my TF2 f1 only to the center part of the histogram than see the fit results drawn. Thus as far as I know, I have to define small ranges of TF2 f1, to get the proper fit. But than I cannot properly draw the TF2 on my TH2.

I guess I could define another TF2 f2 with same ranges as TH2 and get the fit results from the fitted TF2 f1, than draw the f2 on the histogram… But maybe there is a more common way?

that’ s a completly different issue… may be do an an other post … that will be less confusing.