Re: root : strange behaviour of AddBinContent()

From: Marc Escalier <escalier_at_lal.in2p3.fr>
Date: Fri, 2 Sep 2011 19:20:11 +0200


thank you very much
Lorenzo and Axel


On Fri, 2 Sep 2011, Axel Naumann wrote:

> Hi Marc,
>
> An alternative to Lorenzo's reply is to use TParameter<int>::GetVal():
> simple int with a name, wrapped as TObject.
>
> Cheers, Axel.
>
>
> Marc Escalier wrote on 09/02/2011 04:24 PM:
>> Hello,
>>
>> it seems that there is a strange behaviour of TH1::AddBinContent()
>>
>> intuitively, i would think that adding a content to a bin would mean
>> that the number of entries should increase,
>> as it is when one does TH1::Fill(1) (apart that this last comment is
>> very slow)
>>
>> but :
>>
>> root [0] TH1F *hist_initial_events=new
>> TH1F("hist_initial_events","hist_initial_events",20,0.5,20.5);
>> root [1] hist_initial_events.GetEntries()
>> (const Double_t)0.00000000000000000e+00
>> root [3] hist_initial_events->AddBinContent(1)
>> root [4] hist_initial_events.GetEntries()
>> (const Double_t)0.00000000000000000e+00
>>
>> root [5] hist_initial_events.GetBinContent(1)
>> (const Double_t)1.00000000000000000e+00
>>
>> -->
>> *is the fact that AddBinContent() does not increase the number of
>> entries expected ?
>>
>> *On other subject, is there a way to find a much faster command that
>> TH1::Fill to add 1 to an histogram ?
>>
>> (i see that a simple counter "int" is much more faster, but i need a TH1
>> for proof, because TH1 derivates from a TObject and the fOutput needs
>> derivatives from TObject : it can not deal with common counters ; and
>> recreating a class derivated from TObject with an integer is rather
>> painful for a clean implementation)
>>
>> thanks for your help
>>
>>
>
Received on Fri Sep 02 2011 - 19:20:19 CEST

This archive was generated by hypermail 2.2.0 : Sat Sep 03 2011 - 11:50:02 CEST