Re: [ROOT] TH2F - TF2

From: Michael Wiesmann (wiesmann@e18.physik.tu-muenchen.de)
Date: Mon Jun 30 2003 - 17:33:30 MEST


Rene Brun writes:
 > Michael,
 > 
 > I will investigate this problem once I will be back to CERN on Thursday.
 > Meanwhile, could you send me a running script showing the problem?
 > I have some suspicion about your  h2D->FindBin(x,y).

Hallihallo Rene!

Thanks for your answer, but you should have shouted at me much
earlier for this stupid mistake :-(

When I tried to put all things into a nice macro for better
readability, I finally got the point:

TF2::Eval(x,y) will calculate the value at EXACT (x,y)

TH2F::FindBin(x,y) will give a bin, where (x,y) is inside, but where
(x,y) is not necessarily the bin CENTRE.

The bin centre one can get with
x_=h2D->GetXaxis()->GetBinCenter( h2D->GetXaxis()->FindBin(x) );
y_=h2D->GetYaxis()->GetBinCenter( h2D->GetYaxis()->FindBin(y) );

This bin centre (x_,y_) is used  by  TH2F::Add(TF2,double):
TH2F::GetBinContent(FindBin(x,y)) - TF2::Eval(x_,y_)

Of course, root is right ...

Sorry, I knew somehow that it was a stupid mistake, but couldn't get
a grip on it last week ...

But thanks for your encouraging answer nevertheless,

Michael


> 
 > Rene Brun
 > 
 > Michael Wiesmann wrote:
 > > 
 > > Hallihallo Rooters!
 > > 
 > > I have a TH2F h2D, I check a bin content a la
 > > h2D->GetBinContent( h2D->FindBin(x,y)); //returns 17
 > > 
 > > I have a TF2 fitFcn,I check a value a la
 > > fitFcn->Eval(x,y) // returns 12.5
 > > //same with TF1::EvalPar(x,parameter)
 > > 
 > > Now I do
 > > h2D->Add(fitFcn,-1.0);
 > > h2D->GetBinContent( h2D->FindBin(x,y)); /returns 7.76
 > > 
 > > Naively I would expect 17-12.5 to be 4.5. Obviously I am too naive for
 > > this problem.
 > > 
 > > I tried to use TH1F::Eval(TF1,"A"), which gave me (17+12.5=) 26.2,
 > > which is at least consistent.
 > > 
 > > Sounds like TH2F::Add(TF1) uses another set of parameters.
 > > 
 > > Any hint what I missunderstood?
 > > 
 > > Michael
 > > 
 > > PS: I am using  root 3.03/09  on RH Linux 7.2



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET