I cannot reproduce your problem.
Plesae indicate which version you use.
Rene Brun
On Thu, 16 Aug 2001, Mike Kordosky wrote:
> Hi Rene,
>
> On Thu, 16 Aug 2001, Rene Brun wrote:
>
> I don't care about seeing those histograms after the function is done. I
> understand that they go out of scope. This is sample code designed to
> illustrate a problem that I do not understand. My question has to do with
> the continue statement. If I leave it in, CINT complains:
>
> Error: non class,struct,union object $gPad used with . or ->
> FILE:TestBug.C LINE:24
> *** Interpreter error recovered ***
>
> Commenting out the continue statement I see that the histograms are filled
> 1000 times and the screen updates once every 10 fills. Yes, at the end of
> the function call everything disappears.
>
> mike
>
>
> > Mike,
> > You have many scoping problems in your macro. You should create
> > your objects in the heap if you want to still see them once
> > the macro has finished.
> > You will find below a simplification of your macro:
> >
> > Rene Brun
> >
> >
> > void test_bug(){
> > TH1F *h1 = new TH1F("h1", "h1", 100, 1, 100);
> > TH1F *h2 = new TH1F("h2", "h2", 100, 100, 200);
> > TCanvas *can = new TCanvas("can", "can", 600, 800);
> > can->Divide(1,2);
> > can->cd(1);
> > TPad *pad1 = (TPad*)gPad;
> > h1->Draw();
> > can->cd(2);
> > TPad *pad2 = (TPad*)gPad;
> > h2->Draw();
> > Double_t result = 0;
> > Int_t i = 0;
> > while(i<1000){
> > result = gRandom->Gaus(50, 5);
> > if(result < 50){
> > i++;
> > continue;
> > }
> > h1->Fill(result);
> > h2->Fill(result*2);
> > if(i%10 == 0){
> > pad1->Modified();
> > pad2->Modified();
> > can->Update();
> > }
> > i++;
> > }
> > }
> >
> >
> > On Thu, 16 Aug 2001, Mike Kordosky wrote:
> >
> > > Hi,
> > >
> > > I have the following macro. The macro works as expected if I comment out
> > > the continue statement. When I leave continue in, CINT complains:
> > >
> > > root [1] test_bug();
> > > Error: non class,struct,union object $gPad used with . or ->
> > > FILE:TestBug.C LINE:24
> > >
> > > void test_bug(){
> > > TH1F h1("h1", "h1", 100, 1, 100);
> > > TH1F h2("h2", "h2", 100, 100, 200);
> > > TCanvas can("can", "can", 1000, 1000);
> > > can.Divide(1,2);
> > > can.cd(1);
> > > h1.Draw();
> > > can.cd(2);
> > > h2.Draw();
> > > Double_t result = 0;
> > > Int_t i = 0;
> > > // for(Int_t i = 0; i<1000; i++){
> > > while(i<1000){
> > > result = gRandom->Gaus(50, 5);
> > > if(result < 50){
> > > i++;
> > > continue;
> > > }
> > > h1.Fill(result);
> > > h2.Fill(result*2);
> > > if(i%10 == 0){
> > > can.cd(1);
> > > h1.Draw();
> > > gPad->Update();
> > > can.cd(2);
> > > h2.Draw();
> > > gPad->Update();
> > > }
> > > i++;
> > > }
> > > }
> > >
> > >
> > > Is this a bug, or am I missing something?
> > >
> > > Mike Kordosky
> > >
> > > --
> > > Graduate Research Assistant // High Energy Physics Lab
> > > kordosky@hep.utexas.edu // University of Texas at Austin
> > > kordosky@fnal.gov //
> > > ph: (512) 471-8426 (RLM Lab, Office)
> > > (512) 475-8673 (ENS Lab)
> > >
> > >
> > >
> > >
> >
>
> --
> Graduate Research Assistant // High Energy Physics Lab
> kordosky@hep.utexas.edu // University of Texas at Austin
> kordosky@fnal.gov //
> ph: (512) 471-8426 (RLM Lab, Office)
> (512) 475-8673 (ENS Lab)
>
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:57 MET