Re: [ROOT] TGraph to file

From: Jacek M. Holeczek (holeczek@us.edu.pl)
Date: Mon May 27 2002 - 13:34:02 MEST


Hi,
I think I would like to warn you about the "gDirectory->Append(MyGraph)"
solution that Rene proposed. Stay away of it.
The problem is that ... usually as soon as you "Draw" your graph, it will
be replaced by an automatically generated histogram.
The solution that I have found is (with help from Rene, some time ago) :
	MyGraph = new TGraph( ... );
	MyGraph->SetName("MyName");
	MyGraph->SetTitle("MyTitle");
	gROOT->GetListOfSpecials()->Add(MyGraph);
In other words, you should NOT add the graph to gDirectory, but to any
other collection (for example, to the existing folder "Specials").
Later, you can find your graph, in the "Specials" folder, using simply :
	MyGraph = (TGraph *)gROOT->FindObject("MyName");
You can save (to a file) the whole contents of the folder using :
	TFolder *MyFolder = (TFolder *)gROOT->GetRootFolder()->GetListOfFolders()->FindObject("Specials");
	if (MyFolder) MyFolder->SaveAs("Specials.root");
Hope this helps,
Best regards,
Jacek.



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:54 MET