Re: Is it a bug or a feature

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Jan 18 1999 - 09:03:22 MET


Marek Kowalski wrote:
> 
> I am afraid my mail have been cut. I am sending it once more.
> 
> Dear Rooters,
> 
> I have found the following problem. I work with several histograms and to be
> able to keep them for a while on the display I use the fake reading of a single
> character.
> 
> Below is a part of the function I call.
> 
> void r_macro(Float_t gain, Int_t row, Int_t zero, Float_t noise)
> {
>  char *s = new char[1];
>  gSystem->Load("resolution/resolution.sl");
>  resolution(gain,row,zero,noise);
>  TH1F *h1 = (TH1F*)gROOT->FindObject("resy");
>  TH1F *h2 = (TH1F*)gROOT->FindObject("resz");
>  TH1F *h3 = (TH1F*)gROOT->FindObject("cluy");
>  TH1F *h4 = (TH1F*)gROOT->FindObject("cluz");
> 
>   h1->Draw();
>  h1->Fit("gaus");
> 
> 
>  gets(s);
> 
>  h2->Draw();
>  h2->Fit("gaus");
> 
> 
>  gets(s);
> 
>  ................}
> 
> 
> 
>  The result is:
> 
> 
>  1. the canvas for h1 is opened, but nothing is drawn
>  2. h1 is fitted, the parameters are printed, nothing is drawn
>  3. after entering the character "s" h2 is fitted and drawn.
> 
> 
>  So I have modified my function in the following way, forcing the canvas
>  update
> 
> 
>  void r_macro(Float_t gain, Int_t row, Int_t zero, Float_t noise)
> {
>  char *s = new char[1];
>  gSystem->Load("resolution/resolution.sl");
>  resolution(gain,row,zero,noise);
>  TH1F *h1 = (TH1F*)gROOT->FindObject("resy");
>  TH1F *h2 = (TH1F*)gROOT->FindObject("resz");
>  TH1F *h3 = (TH1F*)gROOT->FindObject("cluy");
>  TH1F *h4 = (TH1F*)gROOT->FindObject("cluz");
> 
> TCanvas *c = new TCanvas("c","histograms");
>  c->cd();
>  h1->Draw();
>  h1->Fit("gaus");
>  c->Update();
> 
>  gets(s);
> 
>  h2->Draw();
>  h2->Fit("gaus");
>  c->Update();
> 
>  gets(s);
> 
>  ...............}
> 
> 
>  Now it works fine. Is it a bug or I just have to like it?
> 
>  Regards, Marek Kowalski
> 

No, this is not a bug. In a macro producing several pictures,
you must force the canvas Update.
As already suggested several times, we could introduce
   gSystem->Wait(Float_t seconds=5)  or gROOT->Wait

In your macro, instead of teh 2 statements
   gets(s);
   c1->Update();
You can define a small function
 void Wait() {
   gets(s);
   c1->Update();
 }

Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:28 MET