Hi Henrique, you can use TObjArray of histograms. -best, Pasha
"Henrique de M. J. Barbosa - mestrado" wrote:
>
> Dear Root Masters,
>
> I have the following problem: I want to build an array of histograms and
> use this array as a parameter of a function. Well, if I fix the size of
> the array before passing it to the function:
>
> void main(void) {
> TH1F **histo; // I know this can be done
> histo = malloc(sizeof(TH1F*)*Size); // just by TH1F *histo[Size]
>
> my_fill(histo);
> }
>
> my_fill(TH1F** htemp) {
> for (int i=0; i<Size; i++)
> htemp = new TH1F();
> }
>
> Then it works perfectly. But my problem is that I want my subroutine to
> allocate the memory because only within the subroutine I will know what
> "Size" show be.
>
> I tried to do the following:
>
> void main(void) {
> TH1F **histo;
>
> my_fill(histo);
> }
>
> my_fill(TH1F** htemp) {
> htemp = malloc(sizeof(TH1F*)*Size);
> for (int i=0; i<Size; i++)
> htemp = new TH1F();
> }
>
> But it doesn't work. Any tips of how to do this? I have tried to do
> some simple tests and I found out that the root behaviour is diferent from
> the standard c++, maybe this is the problem, I don't know:
>
> root [0] double x = 3
> root [1] &x
> Error: reference type x with no initialization FILE:/tmp/fileVv6eIH_cint LINE:1
> Error: x already declared as different type FILE:/tmp/fileVv6eIH_cint LINE:1
> *** Interpreter error recovered ***
> root [2]
>
> Shouldn't I've got the address of "x" in the code above?
>
> []'s
>
> Henrique
> ****************************************
> State University at Campinas - BRASIL
> "Gleb Wathagin" Physics Institute
> Department of Cosmic Rays and Chronology
>
> Henrique Barbosa The Pierre Auger
> PhD Student Observatory
> ****************************************
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:21 MET