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


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

        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:

        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?



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

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



Hi Lorenzo,

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