Skip to content
Snippets Groups Projects
Commit 1f14ee38 authored by Rene Brun's avatar Rene Brun
Browse files

Fix a sign problem in the algorithm of TGraph::Integral.

parent 9a9c7ed2
No related branches found
No related tags found
No related merge requests found
...@@ -1656,12 +1656,16 @@ Double_t TGraph::Integral(Int_t first, Int_t last) const ...@@ -1656,12 +1656,16 @@ Double_t TGraph::Integral(Int_t first, Int_t last) const
if (first >= last) return 0; if (first >= last) return 0;
Int_t np = last-first+1; Int_t np = last-first+1;
Double_t sum = 0.0; Double_t sum = 0.0;
//for(Int_t i=first;i<=last;i++) {
// Int_t j = first + (i-first+1)%np;
// sum += TMath::Abs(fX[i]*fY[j]);
// sum -= TMath::Abs(fY[i]*fX[j]);
//}
for(Int_t i=first;i<=last;i++) { for(Int_t i=first;i<=last;i++) {
Int_t j = first + (i-first+1)%np; Int_t j = first + (i-first+1)%np;
sum += TMath::Abs(fX[i]*fY[j]); sum += (fY[i]+fY[j])*(fX[j]-fX[i]);
sum -= TMath::Abs(fY[i]*fX[j]);
} }
return 0.5*sum; return 0.5*TMath::Abs(sum);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment