Hi,
I have a problem concerning TCanvas and the batch mode (-b) running. Here’s a small program that creates a canvas and retrieves the size parameters before and after it is written to an output file. As will be seen, the value of some parameters are not kept when including the -b option.
[code]void test(){
TFile *f = new TFile(“test.root”,“RECREATE”);
TCanvas *c = new TCanvas(“c”,“c”,0,0,100,600);
TH1D *h = new TH1D(“h”,“h”,10,0,10);
h->Fill(3);
h->Draw();
cout<<"BEFORE WRITING THE CANVAS "<<endl;
cout<< "window width = " << c->GetWindowWidth()<<endl;
cout<< “window height =”<< c->GetWindowHeight()<<endl;
cout<< "window top X = "<< c->GetWindowTopX()<<endl;
cout<< "window topy = "<< c->GetWindowTopY()<<endl;
cout<< "window Ww = "<< c->GetWw()<<endl;
cout<< "Window Wh = "<< c->GetWh()<<endl;
c->Write(“testCanvas”);
gDirectory->ls();
TCanvas* myC = (TCanvas*)(gDirectory->GetKey(“testCanvas”))->ReadObj();
//PARAMETERS OF THE WRITTEN CANVAS
cout<<" AFTER WRITING THE CANVAS" <<endl;
cout<< "window width = " << myC->GetWindowWidth()<<endl;
cout<< "window height = "<< myC->GetWindowHeight()<<endl;
cout<< "window top X = "<< myC->GetWindowTopX()<<endl;
cout<< "window topy = "<< myC->GetWindowTopY()<<endl;
cout<< "window Ww = "<< myC->GetWw()<<endl;
cout<< "Window Wh = "<< myC->GetWh()<<endl;
}[/code]
When I run root -l test.C++ what I get is:
BEFORE WRITING THE CANVAS
window width = 100
window height =600
window top X = 1
window topy = 29
window Ww = 96
Window Wh = 572
TFile** test.root
TFile* test.root
OBJ: TH1D h h : 0 at: 0x1465c1f0
KEY: TCanvas testCanvas;1 c
AFTER WRITING THE CANVAS
window width = 100
window height = 600
window top X = 1
window topy = 29
window Ww = 96
Window Wh = 572
The canvas parameters are kept in the file. But when I run with root -l -b test.C++ I get:
BEFORE WRITING THE CANVAS
window width = 100
window height =600
window top X = 0
window topy = 0
window Ww = 96
Window Wh = 572
TFile** test.root
TFile* test.root
OBJ: TH1D h h : 0 at: 0xfbfa140
KEY: TCanvas testCanvas;1 c
AFTER WRITING THE CANVAS
window width = 0
window height = 0
window top X = 0
window topy = 0
window Ww = 96
Window Wh = 572
and the canvas looks now different. Specifically, the window width and height are not saved. What am I missing?
Thanks a lot.