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)<<" +/- "<Integral(0,-1) = "<IntegralAndError(0,-1,Err2)<<" +/- "<