# How too find out which bin was clicked in a TH2D histogram

**URL:** <https://root-forum.cern.ch/t/how-too-find-out-which-bin-was-clicked-in-a-th2d-histogram/7012>\
**Category:** ROOT\
**Created:** [August 20, 2008, 8:03pm UTC](https://root-forum.cern.ch/t/how-too-find-out-which-bin-was-clicked-in-a-th2d-histogram/7012 "2008-08-20T20:03:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![perthi](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/5fc32e/32.png) [@perthi](https://root-forum.cern.ch/u/perthi)\
**Post date:** [August 20, 2008, 8:03pm UTC](https://root-forum.cern.ch/t/how-too-find-out-which-bin-was-clicked-in-a-th2d-histogram/7012/1 "2008-08-20T20:03:05Z")

</div>

Hi  
Is there an easy way/way to find out  
which bin a user has clicked in a TH2D histogram ?

In particular I have 2D XY plot of the noise of our ALICE/PHOS detector  
and when the user clicks in the plot I want to display the histohram (TH1D)  
used to estimate the noise for this channel.

I have made a protoype,overloading the ExecuteEvent function and evaluate  
which bin is clicked vi the px, py arguments using hardcoded values for the  
size of the canvas. This only works of course untll the user changes  
the size of the canvas, so I need a better way.

regards  
Per Thomas Hille

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [August 20, 2008, 8:10pm UTC](https://root-forum.cern.ch/t/how-too-find-out-which-bin-was-clicked-in-a-th2d-histogram/7012/2 "2008-08-20T20:10:19Z")

</div>

Hi,

You can take a look at these tutorials: graphics/triangles.C, hist/exec2.C, hist/DynamicSlice.C and graphics/mandelbrot.C

Cheers,  
Bertrand.

---

<div class="post-metadata">

**Author:** ![perthi](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/5fc32e/32.png) [@perthi](https://root-forum.cern.ch/u/perthi)\
**Post date:** [August 20, 2008, 10:24pm UTC](https://root-forum.cern.ch/t/how-too-find-out-which-bin-was-clicked-in-a-th2d-histogram/7012/3 "2008-08-20T22:24:21Z")

</div>

Thanks 🙂
