TH2D object to NumPy with bin labels

95 Views Asked by At

I have a 2D correlation matrix between nuisance parameters that are used in a likelihood fit. I would like to translate this to NumPy to use with other vis libraries. The problem is TH2D.edges returns the bin index and I need the bin label, i.e. which bin is which nuisance parameter. The TH2D object has the following members:

['fName',
 'fTitle',
 'fLineColor',
 'fLineStyle',
 'fLineWidth',
 'fFillColor',
 'fFillStyle',
 'fMarkerColor',
 'fMarkerStyle',
 'fMarkerSize',
 'fNcells',
 'fXaxis',
 'fYaxis',
 'fZaxis',
 'fBarOffset',
 'fBarWidth',
 'fEntries',
 'fTsumw',
 'fTsumw2',
 'fTsumwx',
 'fTsumwx2',
 'fMaximum',
 'fMinimum',
 'fNormFactor',
 'fContour',
 'fSumw2',
 'fOption',
 'fFunctions',
 'fBufferSize',
 'fBuffer',
 'fBinStatErrOpt',
 'fStatOverflows',
 'fScalefactor',
 'fTsumwy',
 'fTsumwy2',
 'fTsumwxy']

Is it possible to extract the bin label for each index?

1

There are 1 best solutions below

0
On

TH2 has an axes tuple and an axis method for getting each of its two TAxis objects.

From there, TAxis has a labels method to extract the labels.

You didn't see it in the list of TH2D data members because it's in the fXaxis and fYaxis.