Pls in getting a count under a particular peak I usually use something like this
energy->Integral(20,50)
and it gives me the integral in that region of the x-axis.
But my peak does not start from zero on the y-axis want to know if there is a way to get an integral starting for instance from 100 on the y-axis and 20-50 on the x-axis.
Thanks
How should I write it pls
The documentation provided is pretty clear:
An example:
{
TH2D *h = new TH2D("h","",200,0,250,200,-150,150);
for (int i=0;i<5000;i++) {
double x = gRandom->Uniform(0,250);
double y = gRandom->Uniform(-150,150);
h->Fill(x,y);
}
//Integrate from bin (10,10) to bin (30,30)
std::cout << h->Integral(10, 30, 10, 30) << "\n";
//Integrate roughly from the point (10,10) to the point (30,30)
int firstxbin = h->GetXaxis()->FindBin(10);
int lastxbin = h->GetXaxis()->FindBin(30);
int firstybin = h->GetYaxis()->FindBin(10);
int lastybin = h->GetYaxis()->FindBin(30);
std::cout << h->Integral(firstxbin, lastxbin, firstybin, lastybin) << "\n";
}
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.