No ability to copy TGraph2DErrors

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

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 and [url]Object ownership by TFile and http://root.cern.ch/download/doc/8ObjectOwnership.pdf