On 4 Aug 98 at 17:15, you wrote:
>
> > > In TCanvas "option" menu, if "Event Status" is selected, coordinate
> > > information can be shown at the bottom of the Canvas. It's
> > > something like
> > > the following exmple:
> > >
> > > Pad example TFrame 122,333, x=1.97,y=3.06
> > >
> > > In above example, "x" and "y" give the position of your mouse in a
> > > TFrame that contains the histogram. Could you tell me how to get the
> > > value of "x" and "y" in my code.
>
>
> Concerning above question, I made the following code to see how to
> get x and y, but it does not work. The reason seems that I can not
> find the object of my class in TCanvas. Could you give me a little
> more guidance ?
This class definition is OK unless one wants to use it somehow.
>
I have a look at your code more carefully and it seems I didn't
provide a good advice so far.
You code will work (likely ) inder Windows but will not work under
any UNIX.
The problem is that the ROOT for UNIX is a single thread
application. For your case this means while you are running
your loop:
> Int_t num=0;
> while (num<1000)
> {
> num++;
> gRandom->Rannor(px,py); //px and py will be two gaussian
> random numbers fHpx->Fill(px);
> }
> }
No
// Fill histograms till user clicks "Stop Filling" button.
happens concurrently at the same time. Of course may be I
misunderstood your intentions. Please send me the piece
of your code not just a class definition. This way I may provide
further guidiance.
I didn't try but under Window I hope you will see you ExecuteEvent
print out and the progress of the filling your hist simultaneously
Valery
> %%%%%%%%%
> test.h
> %%%%%%%%%%
>
> #ifndef _test_
> #define _test_
>
> #include <stdlib.h>
>
> #include <TROOT.h>
> #include <TApplication.h>
> #include <TObject.h>
> #include <TCanvas.h>
> #include <TH1.h>
> #include <TRandom.h>
>
> class test:public TH1 {
>
> private:
> TH1F *fHpx;
> public:
> test();
> Int_t DistancetoPrimitive(Int_t px, Int_t py);
> void ExecuteEvent(Int_t event, Int_t px, Int_t py);
> void Draw();
>
>
> ClassDef(test,0)
> };
>
> #endif
>
>
> %%%%%%%%%%
> test.c
> %%%%%%%%%
> #include "test.h"
>
> ClassImp(test)
>
> test::test(): TH1()
> {
> // Fill histograms till user clicks "Stop Filling" button.
>
> static int cnt;
>
> if (!fHpx) {
> fHpx = new TH1F("hpx","",100,-4,4);
> fHpx->SetFillColor(kRed);
> cnt = 0;
> }
>
> int kUPDATE = 1000;
> float px, py;
>
> Int_t num=0;
> while (num<1000)
> {
> num++;
> gRandom->Rannor(px,py); //px and py will be two gaussian
> random numbers fHpx->Fill(px);
> }
> }
>
> Int_t test::DistancetoPrimitive(Int_t px, Int_t py)
> {
> return TH1::DistancetoPrimitive(px, py);
> }
>
> void test::ExecuteEvent(Int_t event, Int_t px, Int_t py)
> {
> Float_t x,y;
>
> switch (event)
> {
> case kMouseMotion:
> x = gPad->AbsPixeltoX(px);
> y = gPad->AbsPixeltoY(py);
> printf("x=%.3g, y=%.3g",gPad->PadtoX(x),gPad->PadtoY(y));
> break;
> }
>
> }
>
> void test::Draw()
> {
> fHpx->Draw();
> }
>
>
>
>
=================================================================
Dr. Valeri Faine (Fine)
------------------- Phone: +1 516 344 7806
Brookhaven National Laboratory FAX : +1 516 344 4206
Bldg. 510A /STAR mailto:fine@bnl.gov
Upton, New York, 11973-5000 http://nicewww.cern.ch/~fine
USA
Dr. Valery Fine Telex : 911621 dubna su
-----------
LCTA/Joint Inst.for Nuclear Res. Phone : +7 09621 6 40 80
141980 Dubna, Moscow region Fax : +7 09621 6 51 45
Russia mailto:fine@main1.jinr.dubna.su