Hi,
I am trying to write a TGraphError object to an existing file. It puts something into the
file but the contents seems empty. I can’t figure out what I am doing wrong …
TFile* f = TFile::Open(inFilename.c_str(),“UPDATE”);
f->cd(“to some dir”); // to retrieve histos to have info for the TGraphErrors
…
TGraphErrors * krms_z_vs_ntrk = new TGraphErrors(… some filled arrays …);
krms_z_vs_ntrk->GetYaxis()->SetTitle(“some title”);
krms_z_vs_ntrk->GetXaxis()->SetTitle(“some label”);
krms_z_vs_ntrk->SetTitle(“some other title”);
krms_z_vs_ntrk->SetName(“SomeUniqueName”);
krms_z_vs_ntrk->GetXaxis()->SetRangeUser(0.,100.); // only relevant for plotting?
krms_z_vs_ntrk->Print(); // looks fine
krms_z_vs_ntrk->Write();
//krms_z_vs_ntrk->Write("", TObject::kOverwrite);
//f->Write(); // not needed (will write all histos in memory?)
f->Close();
I end up with a root file with object “SomeUniqueName” but when I plot it (with e.g. TBrowser) I get an empty canvas. I also add histograms to the root file and there it is no problem. I never plot the TGraph but I know it’s filled. There is also no TApplication involved (in case it matter).
Thanks for any hints.
Cheers
Andi