Be aware that the TGraph::Integral name is extremely misleading.
It calculates the “pseudo-integral” of a closed polygon, NOT the “integral” of the function.
Try this: {
TGraph *g = new TGraph();
g->SetPoint(0, 1.0, 1.0);
g->SetPoint(1, 2.0, 0.0);
g->SetPoint(2, 3.0, 2.0);
g->SetPoint(3, 4.0, 1.0);
g->Draw("AL*");
std::cout << "ROOT's pseudo-integral = " << g->Integral(0, 3) << std::endl;
}
1 Like