Integral of a photomultiplier pulse (TGraph)

Hello everyone,

I have troubles to calculate an integral of a photomultiplier pulse I drew via TGraph.
I tried out the Integral() function of the TGraph class and I get a positive and in its absolute value too low result (order +10⁻⁸ where I would expect -10⁻⁵ from a corresponding exponential fit).
The use was in the following way (within a macro):

#include "TGraph.h"

Double_t integral = gr->Integral(startPoint, stopPoint);

where startPoint and stopPoint are the points between which the integral shall be calculated and gr is a pointer on a TGraph object containing the points of the waveform (compare attachment).

What could have gone wrong?

Cheers, Aiedala
waveform_example_fitted.pdf (64.7 KB)

I’m afraid you misinterpret the meaning if the TGraph::Integral method.

( a more readable version of the doc : … 1819cf7533)

Thanks for your replies. I don’t really understand how the polygon is drawn. If its value of area is calculated by dividing it into triangles, what does go wrong here? Is the reason for the positive result, that it really only calculates the area and therefore always positive values? And how do I know if the triangles intersect or not?
Is there any simple possibility to get a normal integral, which is more exact than an integral of a fit-function and would maybe also give a real integral, meaning a negative integral for a negative pulse etc., or do I have to write this by hand?

{ TGraph *g = new TGraph(); for (Int_t i = 0; i < 100; i++) g->SetPoint(i, i, 1.0 + TMath::Sin(TMath::TwoPi() * i / 99.0)); g->Draw("AF"); std::cout << "g->Integral() = " << g->Integral() << std::endl; }