Hi,
Sorry if this question has already been asked or seems stupid but I
really don't know what happen...
I really don't know how ROOT does to integrate TF1 and TH1...
For example, I send you a macro. If you run it, you will see (I hope
because it's what I see) that the integral of a product of a constant c
with a function f is not equal to the product of the constant c with
the integral of f.
The other problem is that the integral of the corresponding histogram
(TH1) is wrong too...
I think I probably miss something important ! But what ?
Could you explain to me why these two cases leads to wrong results ?
Why the result with a TF1 is so different from the result obtained with
a TH1, even with a big number of bins ?
Thanks a lot for your answer !
Julien.
{
gROOT->Reset();
// f1 = x**-2
TF1 *f1 = new TF1("essai1", "pow(x, -2)", 0, 1000000);
// f2 = 8.343e-7 * x**-2
TF1 *f2 = new TF1("essai2", "8.343e-7 * pow(x, -2)", 0, 1000000);
cout << 8.343e-7 * f1->Integral(0.1, 100000) << " OK" << endl;
cout << f2->Integral(0.1, 100000) << " NOK !!" << endl;
TH1D *h1 = new TH1D("essai3", "essai3", 1000000, 0, 100000);
h1->Eval(f2, "R");
Int_t imin = h1->FindBin(0.1);
Int_t imax = h1->FindBin(100000);
cout << "histo integral with \"width\" = " << h1->Integral(imin, imax,
"width") << endl;
delete h1;
}
------------------------------------------------------
Julien Bolmont
Ingénieur diplômé - doctorant
Groupe d'Astroparticules de Montpellier
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:05 MET