Get the pointer of fitting pave stats

Hi,
I am trying to get the pointer of fitting result pave stats so that I can change location of the pave. However, the pointer is NULL by the way:


  gStyle->SetOptFit(1111);
  gStyle->SetOptStat("");

  TH1F * h = new TH1F("h", "Test", 100, -3, 3);
  h->FillRandom("gaus", 5000);
  h->Draw();
  h->Fit("gaus");

  gPad->Update();
  
  cout <<  gPad << endl;
  
  TPaveStats * pavestats = (TPaveStats*)gPad->FindObject("stats");
  
  pavestats->SetX1NDC(0.7);
  pavestats->SetX2NDC(0.99);
  pavestats->SetY1NDC(0.7);
  pavestats->SetY2NDC(0.99);

with the error:

So any one could help to figure out the error in the macro?

Thanks,
Zhiyi.

See the working example:
$ROOTSYS//tutorials/hist/transpad.C

Change your script in the following way (see lines with //<=====)

[code] {
gStyle->SetOptFit(1111);
gStyle->SetOptStat("");

TH1F * h = new TH1F(“h”, “Test”, 100, -3, 3);
h->FillRandom(“gaus”, 5000);
//h->Draw();
h->Fit(“gaus”);

gPad->Update();

cout << gPad << endl;

TPaveStats * pavestats = (TPaveStats*)h->FindObject(“stats”); //<=========

pavestats->SetX1NDC(0.7);
pavestats->SetX2NDC(0.99);
pavestats->SetY1NDC(0.7);
pavestats->SetY2NDC(0.99);
gPad->Modified(); //<=========
}
[/code]

Rene