Re: TH3 constructors with both constant and variable bin widths...

From: Pierre-Luc Drouin <pldrouin_at_physics.carleton.ca>
Date: Thu, 17 Jul 2008 11:00:40 -0400


Thanks!

Rene Brun wrote:
> Pierre-Luc,
>
> I was wrong, what you propose with a subsequent call to TAxis::Set
> should work.
>
> Rene Brun
>
> Pierre-Luc Drouin wrote:
>> I'm not sure to understand why this wouldn't work... I looked at the
>> different constructors and the only difference I see is through the
>> calls of TAxis::Set. TAxis seems to distinguish between constant bin
>> width and variable binwidth though TArrayD.fN, which is set to a
>> non-zero value only by TAxis::Set(Int_t, Double_t*). The following
>> example seems also to produce the right result:
>>
>> Double_t bins[]={0,1,2.5,3,4,5,6,7,8,9,10};
>> Int_t nbins=10; TH2F
>> th("th","th",10,0,10,10,0,10);
>> th.GetXaxis()->Set(nbins,bins) th.Fill(2.25,1.5);
>> th.Draw();
>>
>> Thank you!
>> Pierre-Luc Drouin
>>
>> Rene Brun wrote:
>>> No, this cannot work (see possible constructors in TH3.h).
>>> I can only repeat my previous suggestion to use THnSparse if you
>>> want variable bin width only on one or two axes.
>>>
>>> Rene
>>>
>>> Pierre-Luc Drouin wrote:
>>>> I think I might have found a solution. If I want to define a TH3D
>>>> having only variable bin width for the x axis, could I simply do
>>>> the following?
>>>>
>>>> Double_t nbins=10;
>>>> Double_t bins[]={0,1,2,3,4,5,6,7,8,9,10};
>>>> TH3F th("th","th",nbins,bins[0],bins[nbins],10,0,10,10,0,10);
>>>> th.GetXaxis()->Set(nbins,bins);
>>>>
>>>> Thank you!
>>>> Pierre-Luc Drouin
>>>>
>>>> Rene Brun wrote:
>>>>> Pierre-Luc,
>>>>>
>>>>> I suggest to use THnSparse instead of TH3
>>>>>
>>>>> Rene Brun
>>>>>
>>>>> Pierre-Luc Drouin wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I would like to know if there is a particular reason why there is
>>>>>> no TH3 constructor having both constant and variable bin widths.
>>>>>> This would be nice to be able avoiding binary searches for TH3*
>>>>>> objects like it is the case for TH2*, when only some of the axes
>>>>>> have a variable bin width...
>>>>>>
>>>>>> Thank you!
>>>>>> Pierre-Luc Drouin
>>>>>>
>>>>>
>>>>
>>>
>>
>
Received on Thu Jul 17 2008 - 17:00:54 CEST

This archive was generated by hypermail 2.2.0 : Fri Jul 18 2008 - 05:50:03 CEST