Problem with TGraph persistency

I have a problem with trying to save objects to an output root file - I am trying to save a TGraph object to a file. In my macro I do

[code]TFile outputfile(rootname,“RECREATE”,“ROOT file with histograms”);
TGraph *gr = new TGraph(nCat,xGraph,yGraphMistag);

const Int_t n = 20;
Float_t x[n], y[n];
for (Int_t i=0;i<n;i++)
x[i] = i0.1;
y[i] = 10
//testgr = new TGraph(n,x,y);
TGraph *testgr = new TGraph(n,x,y);

TH1F *rec_mass_untag = new TH1F(“rec_mass_untag”,“rec Bmass_untag”,1000,4,6);

// Save all objects in this file
then when I open the .root file, the histogram is there but not either TGraph.:

root [3] TFile *runData = TFile::Open("DsPi/runData.root") root [4] runData->ls() TFile** DsPi/runData.root ROOT file with histograms TFile* DsPi/runData.root ROOT file with histograms KEY: TH1F rec_mass_untag;1 rec Bmass_untag

I’m surely missing something obvious… any help would be appreciated

You must write the TGraph object explictly to the file.
Only objects TH1, TF1, TTree (and derivatives) are automatically
registered to the file, ie after the line
TGraph *testgr = new TGraph(n,x,y);