Closed gipert closed 3 years ago
In Uproot 3, check all of the attributes that start with _f
in dir(histogram)
.
In Uproot 4 (which wouldn't be using uproot3-methods), look in histogram.all_members
(a dict).
There are no convenience methods for accessing these bits (because no one has asked before). uproot3-methods and Uproot 4 behaviors provide convenience methods for the data that are in the _f
attributes or all_members
.
kIsAverage
might be in something named "flags".
Uhm I cannot find anything meaningful:
>>> h._
h._arraymethods h._fContour h._fMinimum h._fXaxis h._methods
h._bases h._fEntries h._fName h._fYaxis h._postprocess(
h._classname h._fFillColor h._fNcells h._fZaxis h._pycode
h._classversion h._fFillStyle h._fNormFactor h._fields h._readinto(
h._copycontext h._fFunctions h._fOption h._format h._recarray(
h._dtype h._fLineColor h._fStatOverflows h._format1 h._recarray_dtype(
h._dtype1 h._fLineStyle h._fSumw2 h._format2 h._trymemo(
h._fBarOffset h._fLineWidth h._fTitle h._format3 h._versions
h._fBarWidth h._fMarkerColor h._fTsumw h._format4
h._fBinStatErrOpt h._fMarkerSize h._fTsumw2 h._hasreadobjany
h._fBuffer h._fMarkerStyle h._fTsumwx h._int32
h._fBufferSize h._fMaximum h._fTsumwx2 h._members(
I'm not sure I completely understand how these bits are managed in ROOT, are them a more general TObject
property?
Is it a bit of _fOption
or is it in the axis (_fXaxis
)?
Reading this:
https://root.cern.ch/doc/master/classTH1.html#operations-on-histograms
it appears that the kIsAverage
is assigned with SetBit
, which is a TObject
method (not a histogram-specific thing, as I had supposed). That's the fBits
member of TObject
, and I just checked, Uproot 3 doesn't save these anywhere (never knew that they were used for anything):
In Uproot 4, the fBits
would be in the all_members
dict with key name "@fBits"
(the @
is used to skip it when presenting it in pretty-prints).
>>> import uproot # Uproot 4
>>> f = uproot.open("histograms.root")
>>> f.classnames()
{'one;1': 'TH1F', 'two;1': 'TH1F', 'three;1': 'TH1F'}
>>> f["one"]
<TH1F (version 2) at 0x7fd7d1e632e0>
>>> f["one"].all_members["@fBits"]
50331656
>>> f["one"].member("@fBits")
50331656
>>> f["one"].member("@fBits") & (2**18) # my histogram is not an average, apparently
0
where kIsAverage
is defined as BIT(18)
:
So it would be possible to get this information in Uproot 4, but it is impossible to get it in Uproot 3. (Uproot 4's approach is more inclusive, less hacky, so I didn't just drop data I didn't know what to do with.)
Great, thanks a lot for looking into this!
Hi! I was wondering if there is there any way to get status bits for a
TH1
? I'm particularly interested in the value ofkIsAverage
. Thanks!