Re: [ROOT] Project an histo using a certain bin definition

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Jul 09 2001 - 17:53:14 MEST


Hi Georges,

The only thing that I can suggest is the following:
  - Assuming that TH1F *hold is a pointer to your old histogram with the
    bad binning.
  - Create a new histogram, 
       TH1F *hnew = new TH1F("hnew","..",nbins,xmin,xmax); //your own binning

  - Fill hnew with a loop like
    Int_t nbinsold = hold->GetXaxis()->GetNbins();
    for (Int_t bin=1;bin<=nbinsold;bin++) {
       Double_t w = hold->GetBinContent(bin);
       Double_t x = hold->GetXaxis()->GetBinCenter(bin);
       hnew->Fill(x,w);
    }

Rene Brun

Georges Lobo wrote:
> 
> Maybe I can explain my problem a little bit. I have to divide 2 histograms
> to compute a cross section. The problem is that the binnings are
> differents (bins limits don't match). I was thinking about a simple
> algorithm using only the bin width. Of course this method is valid with a
> flat distribution but in my case I have a lot of bins and the variations
> from bin to bin are quite small. But it is possible I think also that the
> algorithm can do it in the right way using derivatives ?
> 
> lobo@irmm.jrc.be
> 
> > Hi Georges,
> >
> > Did you look in TH1::Rebin ? This function accepts only rebinning 2, 3, etc bins
> > into one bin. Rebinning with a specified bin size is only possible if you can
> > make some assumptions on the original histogram (flat distribution inside one
> > bin). I never had requests for this mode so far.
> >
> > Rene Brun
> >
> > Georges Lobo wrote:
> > >
> > > Hello all,
> > > I was wondering if there was a macro ready-to-use to rebin an histogram
> > > using a defined bin definition, which could imply to deal with frctions of
> > > bins.
> > > Thanks in advance
> > >         Georges Lobo
> >



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:51 MET