# No ability to copy TGraph2DErrors

**URL:** <https://root-forum.cern.ch/t/no-ability-to-copy-tgraph2derrors/13963>\
**Category:** ROOT\
**Created:** [March 13, 2012, 1:03pm UTC](https://root-forum.cern.ch/t/no-ability-to-copy-tgraph2derrors/13963 "2012-03-13T13:03:02Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [March 13, 2012, 1:31pm UTC](https://root-forum.cern.ch/t/no-ability-to-copy-tgraph2derrors/13963/2 "2012-03-13T13:31:28Z")

</div>

Instead of:  
gr = dynamic\_cast\<TGraph2DErrors\*\>(f-\>Get(“mygraph”));  
use:  
f-\>GetObject(“mygraph”, gr);  
See [http://root.cern.ch/root/html/TDirectoryFile.html#TDirectoryFile:Get](http://root.cern.ch/root/html/TDirectoryFile.html#TDirectoryFile:Get)

Try this:

`gROOT->cd();
TGraph2DErrors *temp_gr = ((TGraph2DErrors*)(gr->Clone("temp_gr")));`  
Note that TGraph and TGraph2D are very different. TGraph2D is more akin to a histogram.  
See also [url][Moving TGraph to a new file](https://root-forum.cern.ch/t/moving-tgraph-to-a-new-file/12917/1) and [url][Object ownership by TFile](https://root-forum.cern.ch/t/object-ownership-by-tfile/13772/1) and [http://root.cern.ch/download/doc/8ObjectOwnership.pdf](http://root.cern.ch/download/doc/8ObjectOwnership.pdf)

---

_[View the full topic](https://root-forum.cern.ch/t/no-ability-to-copy-tgraph2derrors/13963)._
