# GetBinContent(Int\_t binx, Int\_t biny, Int\_t) in TH2

**URL:** <https://root-forum.cern.ch/t/getbincontent-int-t-binx-int-t-biny-int-t-in-th2/33566>\
**Category:** Newbie\
**Tags:** hist\
**Created:** [April 12, 2019, 11:33am UTC](https://root-forum.cern.ch/t/getbincontent-int-t-binx-int-t-biny-int-t-in-th2/33566 "2019-04-12T11:33:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Reik](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/reik/32/17302_2.png) [@Reik](https://root-forum.cern.ch/u/Reik)\
**Post date:** [April 12, 2019, 11:33am UTC](https://root-forum.cern.ch/t/getbincontent-int-t-binx-int-t-biny-int-t-in-th2/33566/1 "2019-04-12T11:33:47Z")

</div>

The prototype of method GetBinContent(Int\_t binx, Int\_t biny, Int\_t ) in TH2 - [https://root.cern.ch/doc/master/classTH2.html#a84bfa4a81446cdc420a9f000d0e89688](https://root.cern.ch/doc/master/classTH2.html#a84bfa4a81446cdc420a9f000d0e89688) specifies that the first parameter is the bin number of the x axis, the second parameter is the bin number of the y axis. What is the third parameter?

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [April 12, 2019, 11:35am UTC](https://root-forum.cern.ch/t/getbincontent-int-t-binx-int-t-biny-int-t-in-th2/33566/2 "2019-04-12T11:35:20Z")

</div>

[TH3::GetBinContent](https://root.cern.ch/doc/master/classTH3.html#a99b09d3a44d39a47c0807fe5ea4e18cb)  
[TH1::GetBinContent](https://root.cern.ch/doc/master/classTH1.html#a7dd0bc0030f5aea18574dc6a2e7814e4)

---

<div class="post-metadata">

**Author:** ![Reik](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/reik/32/17302_2.png) [@Reik](https://root-forum.cern.ch/u/Reik)\
**Post date:** [April 12, 2019, 3:11pm UTC](https://root-forum.cern.ch/t/getbincontent-int-t-binx-int-t-biny-int-t-in-th2/33566/3 "2019-04-12T15:11:31Z")

</div>

So in TH2, the third parameter is just a placeholder and doesn’t matter? (and by extension, the second and third parameter do not matter for TH1?)  
In that case, is there any reason the method with that prototype exists? (Does it have to inherit from a super class and not be implemented in the class itself)

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [April 13, 2019, 6:47am UTC](https://root-forum.cern.ch/t/getbincontent-int-t-binx-int-t-biny-int-t-in-th2/33566/4 "2019-04-13T06:47:37Z")

</div>

[TH1::GetBinContent(Int\_t bin)](https://root.cern.ch/doc/master/classTH1.html#ac70dcb4082bd510f5aa3e6efeb043f39)

---

<div class="post-metadata">

**Author:** ![Reik](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/reik/32/17302_2.png) [@Reik](https://root-forum.cern.ch/u/Reik)\
**Post date:** [April 15, 2019, 10:25am UTC](https://root-forum.cern.ch/t/getbincontent-int-t-binx-int-t-biny-int-t-in-th2/33566/5 "2019-04-15T10:25:18Z")

</div>

> [@Wile\_E\_Coyote](#):
>
> TH1::GetBinContent(Int\_t bin)

I still do not understand the utility of the 3rd parameter for TH2 and the 2nd and 3rd parameter for a TH1. Changing those does not change the global bin number.

---

<div class="post-metadata">

**Author:** ![sbinet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sbinet/32/13166_2.png) [@sbinet](https://root-forum.cern.ch/u/sbinet)\
**Post date:** [April 15, 2019, 10:37am UTC](https://root-forum.cern.ch/t/getbincontent-int-t-binx-int-t-biny-int-t-in-th2/33566/6 "2019-04-15T10:37:53Z")

</div>

they aren’t used.  
they are leftovers of a wrong design decision in how the inheritance tree bw `TH1`, `TH2` and `TH3` was setup.

---

<div class="post-metadata">

**Author:** ![Reik](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/reik/32/17302_2.png) [@Reik](https://root-forum.cern.ch/u/Reik)\
**Post date:** [April 15, 2019, 12:48pm UTC](https://root-forum.cern.ch/t/getbincontent-int-t-binx-int-t-biny-int-t-in-th2/33566/7 "2019-04-15T12:48:41Z")

</div>

Is there no way to refactor the code to fix this without changing existing functionality? (Not sure if it would even be worth the time…)
