Re: Selective filling of a histogram

From: Roger Mason <rmason_at_esd.mun.ca>
Date: Fri, 31 Oct 2008 14:46:29 -0230


Hello Rene,

Rene Brun <Rene.Brun_at_cern.ch> writes:

> I do not understand your problem (well, I just had a quick glance to it::)
> However, you do not need all this complexity and can divide your code
> by at least a factor 3.
> Simply use the automatic binning feature of ROOT histograming. The
> limits that will be calculated will be much nicer than what you are
> trying to do with your algorithm. To get the auto-binning, simply
> define the lower limit equal to the upper limit, eg instead of
>
> TH1D *henergy = new TH1D("energy","energy(eV)",100,min-max/10,max+max/10);
>
> Do:
>
> TH1D *henergy = new TH1D("energy","energy(eV)",100,0,0
>

Thanks, that saved some code.

Regarding the original question I find that a histogram can be filled selectively with something like this:

[snip]

     if ( energy > -2143.58 ) {
       //      cout << "Energy = " << energy << endl;
       h->Fill(energy);
     }
       else {
         h->Fill(energy,0);
     }

[snip]

I have another question about sorting a vector, which I will post seperately.

Thanks,
Roger Received on Fri Oct 31 2008 - 19:08:52 CET

This archive was generated by hypermail 2.2.0 : Fri Oct 31 2008 - 23:50:01 CET