# More functions with support of bin as a char\*, not an int

**URL:** <https://root-forum.cern.ch/t/more-functions-with-support-of-bin-as-a-char-not-an-int/21595>\
**Category:** Evolution Proposals, Apps & Ideas\
**Created:** [July 25, 2016, 8:15pm UTC](https://root-forum.cern.ch/t/more-functions-with-support-of-bin-as-a-char-not-an-int/21595 "2016-07-25T20:15:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yus](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/9fc348/32.png) [@yus](https://root-forum.cern.ch/u/yus)\
**Post date:** [July 25, 2016, 8:15pm UTC](https://root-forum.cern.ch/t/more-functions-with-support-of-bin-as-a-char-not-an-int/21595/1 "2016-07-25T20:15:36Z")

</div>

Hi,

I’m a big fan of alphanumeric bin labels, like for cutflows:

```auto
        TH1F* h1 = new TH1F("h1", ";X;Y", 10, 0., 10.);
        char* h1BinLabel_electronTriggerCriterion = "Electron trigger fired";
        h1->GetXaxis()->SetBinLabel(1, h1BinLabel_electronTriggerCriterion);
```

, and then using a Fill(…) function:

```auto
        h1->Fill(h1BinLabel_electronTriggerCriterion, 0.5);
```

I wish more functions knew how to handle char\* bin labels, e.g., GetBinContent(…), GetBinError(…), IsBinOverflow(…), SetBinContent(…) etc. After you reorganized bins in a cutflow, you don’t need to reorganize your Fill(…) calls, because Fill(…) takes a label as an input (which I haven’t changed), not the bin number (which I have changed). However, all GetBinContent(…) calls have to be changed accordingly, because the bins have shifted (let’s say I snuck in a new bin in place of an old first bin, thus shifting all old bins to the right), which can be painful in case of a large analysis.

Is that possible in any foreseeable future?

Thanks!

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [July 26, 2016, 7:43am UTC](https://root-forum.cern.ch/t/more-functions-with-support-of-bin-as-a-char-not-an-int/21595/2 "2016-07-26T07:43:47Z")

</div>

Hi,

I understand your request. I agree it would make sense, but can you not just use TAxis::FindFixBin(const char \* label) ?  
I don’t like very much adding dummy methods such as

```auto
 double TH1::GetBinContent(const char * label) const {  
 	return GetBinContent(GetXaxis()->FindFixBin(label)); 
 }
```

Cheers

Lorenzo

---

<div class="post-metadata">

**Author:** ![yus](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/9fc348/32.png) [@yus](https://root-forum.cern.ch/u/yus)\
**Post date:** [July 26, 2016, 10:54am UTC](https://root-forum.cern.ch/t/more-functions-with-support-of-bin-as-a-char-not-an-int/21595/3 "2016-07-26T10:54:56Z")

</div>

Hi Lorenzo,

that’s great, the TAxis::FindFixBin(const char \* label) solves my problem. I did not know this method existed. Solved.
