Dear experts,
Could you tell me why the following is happening? :
If I fill the TH1F histograms with the weights different from 1, then the Integral(0,-1) returns the value different from the sum of the weights.
here is the example script:
[code]void test(){
TH1F *h1 = new TH1F(“h1”,“h1”,8,132.5,212.5);
h1->Sumw2();
TH1F *h2 = new TH1F(“h2”,“h2”,8,132.5,212.5);
h2->Sumw2();
TRandom3 r3;
double Integral=0, Error=0;
double w[15]={0.00123, 0.0533, -1.000023, 1.20555, 0.00098007, 0.97087, 2.11193, 0.3098, 0.55, 1.10 , 0.001, 2.345555, 1.5500009, 0.011928, 2.};
//double w[15]={ 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1. };
for(int i=0; i<8000; i++ )
{
for(int j=0; j<15; j++ )
{
h1->Fill(r3.Gaus(172.7,9.8), w[j]);
h2->Fill(r3.Gaus(80.4,14.5), w[j] );
Integral+= (w[j]);
Error+= (w[j]*w[j]);
}
}
double Err1=0, Err2=0;
cout<<"h1->Integral(0,-1) = “<IntegralAndError(0,-1,Err1)<<” +/- “<<Err1<<” just sum of weights = “<<Integral<<” +/- "<<sqrt(Error)<<endl;
cout<<"h2->Integral(0,-1) = “<IntegralAndError(0,-1,Err2)<<” +/- “<<Err2<<” just sum of weights = “<<Integral<<” +/- "<<sqrt(Error)<<endl;
}
[/code]
and here is the output:
root [0]
Processing test.C...
h1->Integral(0,-1) = 89700.7 +/- 413.491 just sum of weights = 89697 +/- 413.491
h2->Integral(0,-1) = 89688.4 +/- 413.491 just sum of weights = 89697 +/- 413.491
root [1]
this script is attached.
Thanks,
Archil
test.C (943 Bytes)