Re: pointer to function

From: Masaharu Goto (gotom@hpyiddq.jpn.hp.com)
Date: Thu Jun 12 1997 - 03:03:23 MEST


Victor,

 I couldn't collerate the error here and the other one.  I have something
 in my mind for the other error, the static variable problem. I changed
 the scheme a couple of monthes ago.  It is understandable this change
 caused the problem.

 Will you send me the source code and surrounding part of the previous
 'fgIsA' problem. I have a feeling that I can fix it quickly with your
 help.

 For the following myh1/2.C, I saw different error at 'main->Fill(xmain)'.

Masaharu Goto

> 
> Dear Masaharu 
> 
> >  This must be a bug. Maybe it happens only when pointer to function, bytecode
> >  compilation and static variable are used at the same time. 
> >  I need complete set of source code to fully understand the problem.
> 
> I have feeling that this problem with something else.
> I have an example which does not work too, but there is no pointer 
> to function but still has the pointers. But this example actually not pure
> CINT but ROOT. But I think problem here is CINT.
> 
> In ROOT
> 
> .L myh2.C
> .x myh1.C
> 
> I can not show the result, I am at home now and my MAC is bad for ROOT.
> 
> File myh2.c
> 
> 
> void myh2(void *ptr)
> 
> {
> //
> // To see the output of this macro, click begin_html <a href="gif/hsum.gif" >here</a> end_html
> //    Simple example illustrating how to use the C++ interpreter	
> //    to fill histograms in a loop and show the graphics results
> //
> 
> void **V;
> TCanvas *c1,*c2;
> TH1F *total,*main,*s1,*s2;
> 
> V = (void**)ptr;
> 
>  c1 =  (TCanvas*)V[1] ;
>  c2 =  (TCanvas*)V[2] ;
>  total = (TH1F*)V[3] ;
>  main =  (TH1F*)V[4] ;
>  s1 =  (TH1F*)V[5] ;
>  s2 =  (TH1F*)V[6] ;
> 
> 
> 
> 
> // Fill histograms randomly
>   gRandom->SetSeed();
>   const Int_t kUPDATE = 100;
>   Float_t xs1, xs2, xmain;
>   for ( Int_t i=0; i<=10000; i++) {
>      xmain = gRandom->Gaus(-1,1.5);
>      xs1   = gRandom->Gaus(-0.5,0.5);
>      xs2   = gRandom->Gaus(1,0.3);
>      main->Fill(xmain);
>      s1->Fill(xs1,0.3);
>      s2->Fill(xs2,0.2);
>      total->Fill(xmain);
>      total->Fill(xs1,0.3);
>      total->Fill(xs2,0.2);
>      if (!i%kUPDATE) {
>         if (i == kUPDATE) {
>            c1->cd();
>            total->Draw("e1p");
>            c2->cd();
>            total->Draw("e1p");
>            main->Draw("same");
>            s1->Draw("same");
>            s2->Draw("same");
>         }
>         c1->Modified();
>         c1->Update();
>         c2->Modified();
>         c2->Update();
>      }
>   }
>   c1->Modified();
>   c2->Modified();
> }
> 
> And file myh1.C
> 
> 
> {
> //  gROOT->Reset();
> 
>   void* V[200];
> 
>   c1 = new TCanvas("c1","The HSUM example",600,400);
>   c1->SetGrid();
>   c2 = new TCanvas("c2","The 2222 example",600,400);
>   c2->SetGrid();
> 
> 
> //  gBenchmark->Start("hsum");
> 
> // Create some histograms.
>   total  = new TH1F("total","This is the total distribution",100,-4,4);
>   main   = new TH1F("main","Main contributor",100,-4,4);
>   s1     = new TH1F("s1","This is the first signal",100,-4,4);
>   s2     = new TH1F("s2","This is the second signal",100,-4,4);
>   total->Sumw2();   // this makes sure that the sum of squares of weights will be stored
>   total->SetMarkerStyle(21);
>   total->SetMarkerSize(0.7);
>   main->SetFillColor(16);
>   s1->SetFillColor(42);
>   s2->SetFillColor(46);
> 
>   V[1] = c1;
>   V[2] = c2;
>   V[3] = total;
>   V[4] = main;
>   V[5] = s1;
>   V[6] = s2;
> 
> //.L myh2.C
> myh2(V);
> 
> //  th = new TThread(myh2,(void*)V);
> }
> 
> 



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