Re: Bin edge 0. in array for TH1F initialization

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Mon, 27 Sep 2010 09:57:32 +0200


  Adam,

Read carefully the doc of TH1 constructor with an array of bin sizes. Your array must be nbins_eEta+1

Rene Brun

On 27/09/2010 09:29, Adam Roe wrote:
> Hi,
> I'm seeing strange (i.e. bad) behavior when using an array to pass to
> the TH1F constructor.
>
> If I do the following:
>
> const int nbins_eEta=3;
> float eEta[nbins_eEta]={-5.0,-2.5,-0.1};
>
> TH1F* histo = new TH1F("h_ElectronEta_","ElectronEta_"),nbins_eEta,eEta);
>
> I get no error, but I do notice that the histogram ends at 0, i.e. the
> last bin is [-0.1,0]. Otherwise it works.
>
> If I try to go positive, i.e.
>
> const int nbins_eEta=4;
> float eEta[nbins_eEta]={-5.0,-2.5,-0.1,0.1};
>
> I get the following errors:
> init histosError in <TAxis::TAxis::Set>: bins must be in
> increasing order
> Error in <TAxis::TAxis::Set>: bins must be in increasing order
>
> I suppose I'm doing something wrong in the initialization. Any ideas?
>
> Thanks,
> Adam
>
Received on Mon Sep 27 2010 - 09:57:37 CEST

This archive was generated by hypermail 2.2.0 : Mon Sep 27 2010 - 11:50:01 CEST