exec1.C

Go to the documentation of this file.
00001 // echo object at mouse position
00002 void exec1()
00003 {
00004    //example of macro called when a pad is redrawn
00005    //one must create a TExec object in the following way
00006    // TExec ex("ex",".x exec1.C");
00007    // ex.Draw();
00008    // this macro prints the bin number and the bin content when one clicks
00009    //on the histogram contour of any histogram in a pad
00010    //Author: Rene Brun
00011    
00012    int event = gPad->GetEvent();
00013    if (event != 11) return;
00014    int px = gPad->GetEventX();
00015    TObject *select = gPad->GetSelected();
00016    if (!select) return;
00017    if (select->InheritsFrom(TH1::Class())) {
00018       TH1 *h = (TH1*)select;
00019       Float_t xx = gPad->AbsPixeltoX(px);
00020       Float_t x  = gPad->PadtoX(xx);
00021       Int_t binx = h->GetXaxis()->FindBin(x);
00022       printf("event=%d, hist:%s, bin=%d, content=%f\n",event,h->GetName(),binx,h->GetBinContent(binx));
00023    }
00024 }
00025 

Generated on Tue Jul 5 15:44:26 2011 for ROOT_528-00b_version by  doxygen 1.5.1