Re: rebin

From: suvayu ali <fatkasuvayu_at_gmail.com>
Date: Tue, 9 Nov 2010 10:15:32 -0800


Hi Jerome,

On 9 November 2010 09:16, Jerome Samarati <Jerome.Samarati_at_cern.ch> wrote:
> Hi rooters,
>
> I have a very naive question : i have a TH1D histo which has 250001 bins
> from -0.5 to 250000.5 keV.
> I would like to rebin it in order to get the same histo from -0.5 to 250.5
> MeV.
> I tried to use the rebin method but it does not work and moreover i do not
> understand what the variable called ngroups ??
> Is someone has an idea ??

Do you really mean rebin, or do you want to change the scale of the histogram from keV to MeV? If its the later, you can use something like this,

void rescale(TH1 *h, double factor)
{
  // change X scale
  double xmin = h->GetXaxis()->GetXmin();   double xmax = h->GetXaxis()->GetXmax();   h->GetXaxis()->SetLimits(xmin*factor,xmax*factor); }

Thanks to Rene for this. :)

If you are trying to do something else, sorry for the noise.

-- 
Suvayu

Open source is the future. It sets us free.
Received on Tue Nov 09 2010 - 19:15:58 CET

This archive was generated by hypermail 2.2.0 : Wed Nov 10 2010 - 11:50:02 CET