Re: Frequency in Histos

From: Jacques Goldberg <Jacques.Goldberg_at_cern.ch>
Date: Tue, 13 Apr 2010 13:29:38 +0300


In your macro you fill h1 with weight 1 and h2,h3,h4 with weights different from 1.

GetBinContent will return the number of events in the selected bin for your h1, not for the others.

To get the contents in the case of h2 h3 h4 , define histograms for example 102 103 104 and fill them as you filled h2 h3 h4 but with the first argument only as you did for h1. Then get the contents of 102 when you want the contents of 2, etc...

BUT FIRST, read
http://qaix.com/cpp-programming/335-343-root-reading-histogram-contents-read.shtml

to see how to correctly use GetBinContents in a script (I mean using haccpt).

Jacques

xsatya wrote:

> Hello,
>
> Thanks for reply. Probably I couldn't get you. Here I am attaching a
> small macro with different histograms. Please check.
>
> With regards,
> S
>
> On Tue, Apr 13, 2010 at 1:45 PM, Jacques Goldberg
> <Jacques.Goldberg_at_cern.ch <mailto:Jacques.Goldberg_at_cern.ch>> wrote:
>
> If the weight of each entry is set to 1 (which is the default),
> the contents of a bin has the same value as the number of events.
> If you want weights different from 1, then just add a second
> histogram with weight set to 1. and use that one to get the
> numbers of entries in each bin.
>
> There may be fancier solutions, but this one quickly gives the result.
>
> Jacques
>
>
> xsatya wrote:
>
> Hi,
>
> Is there any way to find the frequency of each bin of any
> Histos? (TH1F, TH2F). GetBinContent(bin) gives only the
> contenct value, but waht I want is no of Entries in that bin.
> Could you please let me know if any ways.
>
> S
> --
> ---------------
> Research Student,
> High Energy Physics, India.
>
>
>
>
>
> --
> ---------------
> Research Student,
> High Energy Physics, India.
Received on Tue Apr 13 2010 - 12:29:43 CEST

This archive was generated by hypermail 2.2.0 : Tue Apr 13 2010 - 17:50:01 CEST