Area under curve?

Hi ROOTers,

How can I calculate area under curve?
I have attached file for which I want to calculate area under curve.

Thanks,
Summit
y.root (41.3 KB)

[quote=“Summit”]Hi ROOTers,

How can I calculate area under curve?

Thanks,
Summit[/quote]

Integral?

Hi
Thanks for reply.

How can I get x-coordinate for particular y-coordinate and vice-versa?

Thanks,
Summit.

[quote=“Summit”]Hi
Thanks for reply.

How can I get x-coordinate for particular y-coordinate and vice-versa?

Thanks,
Summit.[/quote]

Well, do you want to calculate it manually? You can call TH1::Integral (see documentation about parameters).
In your case, for example:

root[0] h1->Integral(1, 2000)
(const Double_t)1.97221210454999993e+05

About coordinates … do you want to work with histogram?
You have bin content == y and bin lower/upper edges/ bin center. I think, you can not calculate x from y :slight_smile: - you can have several bins with the same y. Y from X is int bin = h1->FindBin(x); double y = h1->GetBinContent(bin);

Hi

Thanks for reply,

I have done what you told me before to do integral.
Is it possible to find the value of x-coordinate for particular y? Let, if i want to know the value of x-coordinate where y is maximum ???

Thanks,
Summit

[quote=“Summit”]Hi

Thanks for reply,

I have done what you told me before to do integral.
Is it possible to find the value of x-coordinate for particular y? Let, if i want to know the value of x-coordinate where y is maximum ???

Thanks,
Summit[/quote]

For maximum - yes, though, it’s not straightforward: hist->GetMaximumBin() will give you number of bin, containing the maximum, and for this bin you can ask for center, lower edge, upper edge.
Except maximum, such a search has no sense: you can have several bins with the same y.
If you want, you can iterate on bins looking at contents and asking (if you find) correspondent X.

Hi,

For any given y you can use TH1::GetBinWithContent().

Cheers, Axel.

hello

I am confused in getting y coordinates with reference to x-coordinates.
How can I use h1->GetBinWithContent() ?

In GetBinWithContent() function, what does Double_t “c” represents?
I need small description of that.

thanks
with regards,

[quote]I am confused in getting y coordinates with reference to x-coordinates.[/quote]I think you actually want to use the function GetBinContent (in GetBinWithContent the ‘c’ represent the value/content of the bin … i.e. the y axis value).

Cheers,
Philippe.

Hello

As I asked above, I would like to know how can I get the x-coordinates for particular y-coordinates and the value of x coordinate for which y is maximum for the root file attached here with?

thanks in advance,

Summit
t1.root (44.6 KB)

Hi Summit,

[quote] I would like to know how can I get the x-coordinates for particular y-coordinates [/quote]See TH1::GetBinWithContent.

See h->GetBinCenter(h->GetMaximumBin())

Philippe.