Reference
Condition
- class Condition(value)[source]
Conditions used to define criteria and cuts.
Example
>>> from pyrootplots import Condition >>> print(Condition.GREATER_THAN_OR_EQUAL_TO) <Condition.GREATER_THAN_OR_EQUAL_TO: 3> >>> print(Condition.GREATER_THAN_OR_EQUAL_TO.name) GREATER_THAN_OR_EQUAL_TO >>> print(Condition.GREATER_THAN_OR_EQUAL_TO.value) 3
- LESS_THAN = 0
- LESS_THAN_OR_EQUAL_TO = 1
- GREATER_THAN = 2
- GREATER_THAN_OR_EQUAL_TO = 3
- IN_RANGE_OPEN_OPEN = 4
- IN_RANGE_OPEN_CLOSED = 5
- IN_RANGE_CLOSED_OPEN = 6
- IN_RANGE_CLOSED_CLOSED = 7
- NOT_IN_RANGE_OPEN_OPEN = 8
- NOT_IN_RANGE_OPEN_CLOSED = 9
- NOT_IN_RANGE_CLOSED_OPEN = 10
- NOT_IN_RANGE_CLOSED_CLOSED = 11
Criterion
- class Criterion(variableName, condition, values)[source]
- Parameters
variableName (str) – Variable name.
condition (Condition) – Condition.
values (list(float)) – Values.
Example
>>> from pyrootplots import Criterion >>> from pyrootplots import Condition >>> crit = Criterion("eta", Condition.LESS_THAN_OR_EQUAL_TO, [2.5]) >>> print(crit) eta <= 2.5
Cut
- class Cut(criterion, sigEvtBefore, sigEvtAfter, bkgEvtBefore, bkgEvtAfter, sigScale=1.0, bkgScale=[1.0], scale=False)[source]
A cut is defined by a variable name (on which the cut is applied) and 1 or 2 values (defining the criterion). The number of signal and background events before and after the cut must be specified.
- Parameters
criterion (
Criterion) – Criterion defining the cut.sigEvtBefore (
float) – Number of signal events before the cut.sigEvtAfter (
float) – Number of signal events after the cut.bkgEvtBefore (
dict[str,float]) – Number of background events before the cut, for each background.bkgEvtAfter (
dict[str,float]) – Number of background events after the cut, for each background.sigScale (
float) – Scaling to luminosity factor for the signal.bkgScale (
list[float]) – Scaling to luminosity factor for each background.scale (
bool) – Whether or not the numbers displayed should be scaled to luminosity or not.
CutEffVsVal
- class CutEffVsVal(evtBefore, evtAfter, variableName, yticks=array([0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.]), xlabel='', ylabel='events(after) / events(before)')[source]
Signal or background efficiency vs. cut value/threshold.
- Parameters
evtBefore (list[float]) – Number of events before the cut, for each cut value.
evtAfter (list[float]) – Number of events after the cut, for each cut value.
variableName (str) – Name of the variable on which the cut is applied.
yticks – Y axis ticks position.
xlabel (str) – X axis label.
ylabel (str) – Y axis label.
Histogram1D
- class Histogram1D(data, weights, bins, xmin, xmax, logx, logy, stacked, density=False, style='both', color=[], label=[], legend={}, scale=[], binned=False)[source]
1D histogram.
- Parameters
data (list[pandas.DataFrame]) – List of data to fill histogram
weights (list[pandas.DataFrame]) – Multiply each bin by the value of the weighted bin. The shape of the weights list must be equal to that of the data. If no weights is needed, default is set to 1.
bins (int) – Number of bins for histogram.
binned (bool) – Set to
Trueifdatais already the population of each bin.xmin (float) – Minimum x-axis value.
xmax (float) – Maximum x-axis value.
logx (bool) – Set x-axis to log scale.
logy (bool) – Set y-axis to log scale.
stacked (bool) – Set to
Trueif one wants to stack distributions. The default is set toFalse.density (bool) – Integrates the histogram to 1: as density = counts / (sum(counts) * np.diff(bins)). By default set to False.
style (str) –
- The type of histogram to draw.
”filled” is a traditional contiguous bar-type bar histogram.
”outlined” is a lineplot.s
”both” draws a filled (contiguous bar-type) histogram with a black outline.
color (list[str]) – Color or sequence of colors, one per dataset.
label (list[str]) – Label or list of labels corresponding to the input data.
legend (dict) – Keyword arguments passed to
self.ax.legend().scale (list[float]) – List of coefficients used to scale to luminosity.
- plot(ax, title=None, titleloc='center', titlefontsize='medium', titlepad=None, xlabel=None, xlabelloc='right', ylabel=None, ylabelloc='top', overlayfirstdataset=False, overlayscale=1, overlayhatch='x', overlayalpha=0.5, xylabelfontsize='medium')[source]
- Parameters
ax –
title –
titleloc (
str) –titlefontsize (
str) –titlepad –
xlabel –
xlabelloc (
str) –ylabel –
ylabelloc (
str) –overlayfirstdataset (
bool) –overlayscale (
int) –overlayhatch (
str) –overlayalpha (
float) –xylabelfontsize (
str) –
Histogram2D
ROCCurve
- class ROCCurve(cuts, title='ROC curve', xlabel='B(after) / B(before)', ylabel='S(after) / S(before)', xticks=array([0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.]), yticks=array([0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.]), xlim=[0.0, 1.0], ylim=[0.0, 1.0], minorGrid={}, majorGrid={}, scatter={}, txt=[])[source]
Receiver operating characteristic curve.
- Parameters
cuts (list[Cut]) – List of the cuts to place on the ROC curve.
title (str) – Title of the ROC curve.
xlabel (str) – X axis label.
ylabel (str) – Y axis label.
xticks – X axis ticks position.
yticks – Y axis ticks position.
xlim (list(str)) – X axis boundaries.
ylim (list(str)) – Y axis boundaries.
minorGrid (
dict) – Parameters passed toplt.grid(which = "minor").majorGrid (
dict) – Parameters passed toplt.grid(which = "major").scatter (
dict) – Parameters passed toplt.scatter().txt (
list[str]) –
- plot(fig=None, ax=None, show=False, whichBkg='')[source]
Plots signal efficiency vs. background efficiency for each cut.
- Parameters
fig – matplotlib Figure object.
ax – matplotlib Axes object.
show (bool) –
Trueto callplt.show(),Falseotherwise.whichBkg (
str) – Name of the background.
- Returns
self