Re: initializing TClonesArray (basic question)

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Wed, 15 Nov 2006 19:39:22 +0100


You should give a different name to each histogram.

Rene Brun

George Locke wrote:
> More simple questions. I tried duplicating what i found in the online
> TClonesArray, and i looked in the user's guide, but my code still
> won't run properly :( so i tried and RTFM...
>
> (root 5.13.04, windows 2000, compiliing with msvc 8)
>
> all i want is 8 identical histograms to fill and reference in an array.
>
> "
> TClonesArray bigArr("TH1F", 8);
>
> for (chan=0; chan<NUM_CHAN; chan++) {
> new(bigArr[chan]) TH1F(name,title,HIST_SIZE,0,HIST_SIZE);
> printf("\t after%d\n\n",chan);
> }
>
> [fill histograms, read histograms, write histograms]
> "
> this will compile but when i run it i am told "Warning in
> <th1::Build>: Replacing existing histogram: XX (potential memory
> leak)"
> this error doesn't occur the first time, but after 0,1,2,3,4,5,6 it
> occurs each time.
>
> the program doesn't crash, but when I try to fill the histograms with
> a simple parabolic pattern, every getbincontent(x) returns 0.
>
> When i try to write either the bigArr[x] or just bigArr nothing gets
> into the file that i try to write to (eg i open in Cint and do f1.ls()
> and it shows an empty file).
>
> I tried making the new commands not inside of a block (that is, i
> wrote in chan=0 new().... with no loop) to see if that would change
> anything and it didn't.
>
> I must be initializing things wrong.
>
> Thanks Again,
> George
Received on Wed Nov 15 2006 - 19:39:28 MET

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:32:02 MET