RE: [ROOT] TGraphErrors and Clone

From: Philippe Canal (pcanal@fnal.gov)
Date: Thu Jul 26 2001 - 18:50:08 MEST


Hi,

Currently the Clone() methods always return a TObject*.  Before using
it you sometime need to cast the result to the actual type (like in 
your case).  So you would be using:

  TGraphErrors* grmean = new TGraphErrors(nhitbins,x,y,ex,ey);
  //copy graphs to passed variables
  mean1 =  (TGraphErrors*)grmean->Clone();		<-------Line # 268

Cheers,

Philippe.

-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Shawn Kwang
Sent: Thursday, July 26, 2001 11:32 AM
To: roottalk@pcroot.cern.ch
Subject: [ROOT] TGraphErrors and Clone


I am trying to make a copy of (two) TGraphErrors using the code below:

====
void regx(..., TGraphErrors *mean1, TGraphErrors *sigma1, char *name1, char *name2)

<snip>

  TGraphErrors* grmean = new TGraphErrors(nhitbins,x,y,ex,ey);

  TGraphErrors* grsigma = new TGraphErrors(nhitbins,x,sigmay,ex,errey);

  //copy graphs to passed variables
  mean1 =  grmean->Clone();		<-------Line # 268
  mean1->SetName(name1);
  sigma1 = grsigma->Clone();
  sigma1->SetName(name2);

</snip>
====

The error I get when running the function is:
Error: Incorrect assignment to mean1, wrong type 'TObject*' 
FILE:/home/skwang/CAPR/CAPR.C LINE:268
(class TObject*)0x890a910

Is there another/better/correct way of copying a TGraphErrors?  This
function basically creates two graphs (grmean and grsigma), but I want to
"return" them to the main program by way of mean1 and sigma1, since I need
to use this function 5 times.  mean1 and sigma1 are declared in the main
program as TGraphErrors.

Thanks in advance,
Shawn Kwang

--
					skwang@wam.umd.edu
					skwang@glue.umd.edu



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:53 MET