Pasha, Thanks a lot for the advice, now it works. One more question: do you know if it is possible to get the entries from a TObjArray with the proper type? I mean, in my case they are all TH1D* histograms, but when I do: Histo_List[0] I get a TObject* and not a TH1D*. Then, for instance, if I want to plot one of the histograms I have to use: ((TH1D*) Histo_List[0])->Draw() to convert the "output" to the correct type and then draw it. It is possible to do it some other way? Thanks a lot, Henrique **************************************** State University at Campinas - BRASIL "Gleb Wathagin" Physics Institute Department of Cosmic Rays and Chronology Henrique Barbosa The Pierre Auger PhD Student Observatory **************************************** > 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