Re: [ROOT] Arrays of 2D histograms

From: Axel Naumann (naumann@hef.kun.nl)
Date: Wed Aug 21 2002 - 21:30:20 MEST


Hi,

this should not work. Two problems: You can't declare an array of TH2Ds 
(or any class, for that matter) like this, and you should not give all 
your histograms the same name (root will replace the old one if a new 
one with the same name is created).

TH2D *same[8];
char name[2];
strcpy(name,"A");
for (Int_t iSame=0; iSame<8; iSame++){
    name[0]=iSame+'A'; // 0th one "A", 1st one "B" etc
    same[iSame]=new TH2D(name,name,50, 0., 10., 50, 0., 10.);
}

might work.
Cheers, Axel.

William Love wrote:

>Hello root
>  I want to divide track data among identical TH2D's according to
> for example, the vertex z.   This would be easiest if I could make and
> address an array of TH2D's  I tried:
>
> *** Start at Date : Wed Aug 21 14:10:58 2002
>QAInfo:You are using STAR_LEVEL : dev, ROOT_LEVEL : 3.02.07 and node :
>rcas6006.rcf.bnl.gov
>root.exe [0] TH2D Same[8]("b","b",50, 0, 10, 50, 0, 10)
>root.exe [1] Same[2].SetName("number3")
>
> *** Break *** segmentation violation
>
>  Where do I go wrong?
>                                          Bill Love
>
>
>I was up all night wondering where the sun went, then it dawned on me.
>
>
>



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:05 MET