(Fwd) Re: How to get coordinate information of a histogram

From: Valery Fine (fine@bnl.gov)
Date: Tue Aug 04 1998 - 23:18:29 MEST


------- Forwarded Message Follows -------
On  4 Aug 98 at 18:34, Wei Xie wrote:


> The class defination "test.h" and its implementation "test.c" is
> followed. The running is like
> 
> *      aa = new test();
> *      aa->Draw();
> 
> 
> In the code, the implentation "Draw()" is like: 
> 
>         void test::Draw()
>         {
>            fpx->Draw(); //fpx is a TH1 object
>         }
> 
> When running like:
> 
>       aa = new test();
>       aa->Draw();
> 
> It will produce a Canvas with a histogram in it. After selecting the
> option "Event Status" in TCanvas, I can find three objects:
> 
>         c1   --> default Canvas
>         fpx   -->the TH1 object.
>         TFrame  --> Frame that contains the "fpx"
> 
> But can not find "aa". Deleting "aa" will have no effect on the
> existing TCanvas and Histograms.  It seems to say that "aa" is not
> in the Canvas.        


  Everything is Ok.

  I found no code to attach very object of "test" to Canvas.
  test::Draw() does include the object fpx into TCanvas. But that is
not "test" at all but TH1. And TCanvas calls

       fpx->DistansetoPrimitive 
 and 
       fpx->ExecuteEvent()

 not your "test::aa" but those from TH1::fpx. That's by your desing.
Why did you mix things I mean test and TH1 (the last is a kind of
abstract class thought).
  To add very test to TPad you should call

         void test::Draw()
         {
            TObject::Draw();
            fpx->Draw(); //fpx is a TH1 object
         }

  But again I can not find any reason to put
 
            fpx->Draw(); //fpx is a TH1 object

  into test::Draw(). This way both objects will be added to TPad 
namely your "aa" as well as "fpx" and the methods of the both classes 
will be called too. Namely TPad will call

    fpx->DistancetoPrimitive( ... )
AND
    &aa->DistancetoPrimitive( ... )

 and occasionally TPad may select either object.

             Hope this helps
                                        Valery



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