You had two problems - The double counting is for the reasons Mario
suggested.
The value 0.5 falls into the 0.50->0.51 bin, and so when you set to the range 0,0.5 you are actually taking bins 1->51. If you plot the histogram and try to scale the axis from 0 to 0.5, you will see it actually refuses to cut off a bin and so instead draws 0->0.51.
To fix this, you either want to take the range 0->0.4999...., or, perhaps better, calculate the integral on bin range ie box2 = h2->Integral(0, 50, 51, 101);
which also takes into account the overflow bins (if you wanted!).
Nick
On Jun 2, 2009 2:36pm, Anil Singh <anil79_at_fnal.gov> wrote:
> Mario,
> yeah, there was a typo actually this was just a
> dummy created to reproduce my problem. I corrected
> and had a re run:
> //-----
> Full Integral: 10000
> Box1: 2655
> Box2: 2556
> Box3: 2535
> Box4: 2439
> Sum of all Boxes: 10185
> //----
> So as you say, there still may be some double counting.
> Is there some easy way to correct this ??
> Anil
> ----- Original Message -----
> From: Mario Kadastik mario.kadastik_at_cern.ch>
> Date: Tuesday, June 2, 2009 6:59 pm
> Subject: Re: [ROOT] TH2D::Integral()
> To: Mario Kadastik mario.kadastik_at_cern.ch>
> Cc: Anil Singh anil79_at_fnal.gov>, roottalk_at_pcroot.cern.ch
> > >> // Box1
> > >> float box1=BoxIntegral(h2,0,x_cut,0,y_cut);
> > >>
> > >> //Box2
> > >> float box2=BoxIntegral(h2,0,x_cut,y_cut,1);
> > >>
> > >> //Box3
> > >> float box3=BoxIntegral(h2,x_cut,1,0,y_cut);
> > >>
> > >> //Box4
> > >> float box4=BoxIntegral(h2,x_cut,1,0,y_cut);
> > >
> > > Aren't you taking a small overlap in the region where x_cut and
> > > y_cut lines overlap? I'd guess that if you exclude the overlap
> > > region you could well end up with the right result. Though the 25%
> >
> > > increase is a bit more than I'd have expected from the overlap in
> > > case of 100 x 100 matrix.
> >
> > Ehh ... it's even simpler :) You have a typo. Your Box3 and Box4 are
> >
> > identical regions. You should be integrating from y_cut to 1 in Box4
> >
> > to cover the whole range.
> >
> > Mario
> >
Received on Tue Jun 02 2009 - 15:42:56 CEST
This archive was generated by hypermail 2.2.0 : Thu Jun 04 2009 - 17:50:01 CEST