2 questions about TH1 class

From: Diego Casadei (Diego.Casadei@bo.infn.it)
Date: Sat May 30 1998 - 22:06:33 MEST


Hello Rooters,
I'd like to have a 2-index array of pointers to TH1 objects.

I write:

  static TH1* (histvec[12][6]);

  for(int i=0;i<6;i++){// don't worry about the sprintf: it does work
    sprintf(string,"h%d",startvec[i]+30*(ilay-1)+ibar-1+14*isid);
    histvec[max%12][i]=new TH1*((TH1*)gAMSDisplay->GetRootFile()->Get(string));
    if(histvec[max%12][i]){
      // do something
    }
  }

but I get an error:

cxx: Error: AMSTOFHist.cxx, line 667: In this statement, the referenced
type of the pointer value
"new TH1 ...((TH1 ...)gAMSDisplay->GetRootFile()->Get(string))" is
"pointer to TH1", which is not compatible with "TH1".
    histvec[max%12][i]=new
TH1*((TH1*)gAMSDisplay->GetRootFile()->Get(string));
----^


Another question.
If I understand, each TH1 object has a unique string identifier.
I create with "new" many TH1 objects, within different calls of a static
function.  I guess that if I create an object of TH1 with the same name
(string) as an existing one, I will not allocate additional space with
"new" but I will overwrite the existing one.  At least I hope... if not my
application will use more and more memory...


Thanks

	Diego Casadei
		casadei@bo.infn.it
		casadei@cern.ch
	AMS-BO lab: tel. +39 51 630 5044
	            fax  +39 51 630 5040



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:33 MET