professor is hosted by Hepforge, IPPP Durham

professor.histo

This module contains simple containers for histograms (Histo) and bins (Bin) and a parser for rivet’s plot info files (PlotParser).

class professor.histo.Histo

Bases: object

Simple container for histograms storing a list of Bin instances.

Histogram trees can be read in from AIDA and flat format files with fromAIDA() and fromFlat(). These methods produce dictionaries mapping histogram paths to histograms. For string representations for AIDA and flat output asFlat() and asAIDA() can be used.

Two different paths for histograms exist:

histopath
The path of the histogram.
fullpath
The full path of the histogram including “/REF” for reference histograms.

Looping over the bins in a histogram can be simply done by:

>>> for b in myhisto:
...     # do stuff with Bin b

Methods

addAnnotation(aname, aval)
addBin(bin)
area()
asAIDA()
asFlat()
asGnuplot()
bins
chop(*xranges)

Return a chopped histogram.

The kept bins are defined by (xstart, xstop) pairs. The first xstart and last xstop can be None meaning that all is included from the first or up to the last bin respectively. Example:

>>> hist.chop((2.5, 5.5), (7.5, None))
classmethod fromAIDA(path)

Load all histograms in file ‘path’ into a histo-path=>histo dict.

The keys of the dictionary are the full paths of the histogram, i.e. AnalysisID/HistoID, a leading “/REF” is stripped from the keys.

TODO: /REF stripping should really happen in user code...

classmethod fromDPS(dps)

Build a histogram from a xml dataPointSet.

classmethod fromFlat(path)

Load all histograms in file ‘path’ into a histo-path=>histo dict.

The keys of the dictionary are the full paths of the histogram, i.e. AnalysisID/HistoID, a leading “/REF” is stripped from the keys.

classmethod fromFlatHisto(stringbuf)

Build a histogram from its flat text representation.

fullPath()
fullpath

Full AIDA path including leading ‘/REF’ and histogram name

getAnnotation(aname)
getArea()
getBin(index)
getBins()
header()
histoPath()
histopath

AIDA path but without a leading ‘/REF’

numBins()
renormalise(newarea)

Renormalise histo to newarea

setBins(bins)
class professor.histo.Bin(xlow=None, xhigh=None, val=0, errplus=0, errminus=0, focus=None, ylow=None, yhigh=None)

Bases: object

A simple container for a binned value with an error.

Methods

area()
asAIDA()

Return this bin as AIDA formatted string.

asFlat()
asGnuplot()
err

Get mean of +ve and -ve y-errors.

errminus
errplus
focus

Mean x-value of the bin.

getArea()
getBinCenter()

Geometric middle of the bin range.

getErr()

Get mean of +ve and -ve y-errors.

getFocus()

Mean x-value of the bin.

getVal()

Y-value of the bin.

getXRange()
getYRange()
setErr(err)

Set both +ve and -ve y-errors simultaneously.

setXRange(xlow, xhigh)
setYRange(ylow, yhigh)
val
xhigh
xlow
yhigh
ylow
class professor.histo.PlotParser(plotpaths=None)

Bases: object

Parser for Rivet’s .plot plot info files.

Methods

Parameters :

plotpaths : list of str, optional

The directories to search for .plot files. The default is to call rivet-config –datadir to get the directory where the .plot files can be found.

Raises :

ValueError :

If plotpaths is not specified and calling rivet-config fails.

Methods

getHeaders(hpath)

Get the plot headers for histogram hpath.

This returns the PLOT section.

Parameters :

hpath : str

The histogram path, i.e. /AnalysisID/HistogramID .

Returns :

plot_section : dict

The dictionary usually contains the ‘Title’, ‘XLabel’ and ‘YLabel’ properties of the respective plot.

See also

getSection()

getHistogramOptions(hpath)

Get a HISTOGRAM section for histogram hpath.

The HISTOGRAM section is only available in a few analyses.

Parameters :

hpath : str

Histogram path. Must have the form /AnalysisID/HistogramID .

See also

getSection()

getSection(section, hpath)

Get a section for a histogram from a .plot file.

Parameters :

section : (‘PLOT’|’SPECIAL’|’HISTOGRAM’)

The section that should be extracted.

hpath : str

The histogram path, i.e. /AnaylsisID/HistogramID .

getSpecial(hpath)

Get a SPECIAL section for histogram hpath.

The SPECIAL section is only available in a few analyses.

Parameters :

hpath : str

Histogram path. Must have the form /AnalysisID/HistogramID .

See also

getSection()

isComment(line)
isEndMarker(line, blockname)
updateHistoHeaders(hist)

Previous topic

professor.minimize

Next topic

professor.tools

This Page