Hi
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] = 10sin(x[i]+0.2);
}
//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
outputfile.Write();
[/code]
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