Hi Andreas, There is no problem in the generating macro if you write the histo + canvas names without spaces. Best regards, Ilka Andreas Zoglauer wrote: > Hello! > > When I try to save a canvas as a macro (SaveAs --> *.C or the > SaveSource() function) then the interpreter can not read the file due to > several "problems". > > Let's look at an example: > > //------------------------------------------------------------------- > void Bug() > { > float x, y; > > TH2D* Hist = > new TH2D("MyHistogram", "A 2D Histogram", 3, -5, 5, 3, -5, 5); > <==== no spaces in histo name > > int c = 0; > const int MaxCounter = 10000; > for (c = 0; c < MaxCounter; ++c) { > gRandom->Rannor(x, y); > Hist->Fill(x, y); > } > > TCanvas* Canvas = new TCanvas("MyCanvas"); <==== no spaces in canvas > name > Hist->Draw("CONT4"); > Canvas->Update(); > Canvas->SaveSource("Bug_saved.C"); > } > //------------------------------------------------------------------ > > This macro generates another macro out of a canvas: > > The resulting macro Bug_saved.C looks like this: > > { > //=========Macro generated from canvas: My Canvas/ > //========= (Mon Jul 28 11:14:14 2003) by ROOT version3.05/07 > TCanvas *My Canvas = new TCanvas("My Canvas", "",8,8,699,499); > My->Range(-0.721689,-0.721815,0.721689,0.721815); > TView *view = new TView(1); > view->SetRange(-5,-5,0,5,5,9073.63); > My->SetBorderSize(2); > My->SetFrameFillColor(0); > > TH1 *A 2D Histogram = new TH2D("A 2D Histogram","A 2D > Histogram",3,-5,5,3,-5,5); > A 2D Histogram->SetEntries(10000); > A 2D Histogram->SetBinContent(6,20); > A 2D Histogram->SetBinContent(7,466); > // .... > > Obviously it has several problems: > > 1. The histogram name and the canvas contains spaces: > TCanvas *My Canvas = new TCanvas("My Canvas", "",8,8,699,499); > TH1 *A 2D Histogram = ... > That's obviouly a bug! > During the name generation, they should be replaced by e.g. > underscores. > 2. Not covered by the above example is another problem: > It is not checked whether or not the canvas and histogram have the > same name! > > Andreas
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:14 MET