Var vs var
puma.var_vs_var.VarVsVar
#
Bases: puma.plot_base.PlotLineObject
VarVsVar class storing info about curve and allows to calculate ratio w.r.t other efficiency plots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_var
|
numpy.ndarray
|
Values for x-axis variable, e.g. bin midpoints for binned data |
required |
y_var_mean
|
numpy.ndarray
|
Mean value for y-axis variable |
required |
y_var_std
|
numpy.ndarray
|
Std value for y-axis variable |
required |
x_var_widths
|
numpy.ndarray
|
Widths for x-axis variable, e.g. bin widths for binned data |
None
|
key
|
str | None
|
Identifier for the curve e.g. tagger, by default None |
None
|
fill
|
bool
|
Defines do we need to fill box around point, by default True |
True
|
plot_y_std
|
bool
|
Defines do we need to plot y_var_std, by default True |
True
|
ratio_group
|
str | None
|
Name of the ratio group this VarVsVar is compared with. The ratio group allows you to compare different groups of VarVsVar within one plot. By default None |
None
|
**kwargs
|
typing.Any
|
Keyword arguments passed to |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If provided options are not compatible with each other |
Source code in puma/var_vs_var.py
args_to_store
property
#
Returns the arguments that need to be stored/loaded.
Returns:
| Type | Description |
|---|---|
dict[str, typing.Any]
|
Dict with the arguments |
__eq__
#
Handles a == check with the class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
puma.var_vs_var.VarVsVar
|
Other VarVsVar that this class is tested against |
required |
Returns:
| Type | Description |
|---|---|
bool
|
If this VarVsVar and the other are equal |
Source code in puma/var_vs_var.py
divide
#
Calculate ratio between two class objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
puma.var_vs_var.VarVsVar
|
Second VarVsVar object to calculate ratio with |
required |
inverse
|
bool
|
If False the ratio is calculated |
False
|
method
|
str
|
Define which method is used for ratio calculation. By default "divide". Other possibility is "root_square_diff" and "subtract". |
'divide'
|
Returns:
| Type | Description |
|---|---|
tuple[numpy.ndarray, numpy.ndarray]
|
Ratio and ratio error Ratio error |
Raises:
| Type | Description |
|---|---|
ValueError
|
If binning is not identical between 2 objects |
Source code in puma/var_vs_var.py
puma.var_vs_var.VarVsVarPlot
#
Bases: puma.plot_base.PlotBase
VarVsVar plot class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid
|
bool
|
Set the grid for the plots. |
False
|
ratio_method
|
str
|
Method for ratio calculations. Accepted values: "divide", "root_square_diff", "subtract". By default "divide" |
'divide'
|
**kwargs
|
typing.Any
|
Keyword arguments from |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If incompatible mode given or more than 1 ratio panel requested |
Source code in puma/var_vs_var.py
add
#
Adding VarVsVar object to figure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
curve
|
puma.var_vs_var.VarVsVar
|
VarVsVar curve |
required |
key
|
str | None
|
Unique identifier for VarVsVar curve, by default None |
None
|
reference
|
bool
|
If VarVsVar is used as reference for ratio calculation, by default False |
False
|
Raises:
| Type | Description |
|---|---|
KeyError
|
If unique identifier key is used twice |
Source code in puma/var_vs_var.py
draw
#
Draw figure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labelpad
|
int | None
|
Spacing in points from the axes bounding box including ticks and tick labels, by default "ratio" |
None
|
Source code in puma/var_vs_var.py
draw_hline
#
Draw hline in top plot panel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_val
|
float
|
y value of the horizontal line |
required |
Source code in puma/var_vs_var.py
get_reference_name
#
Get reference VarVsVar object from list of references.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var_object
|
puma.var_vs_var.VarVsVar
|
VarVsVar we want to calculate the ratio for |
required |
Returns:
| Name | Type | Description |
|---|---|---|
reference_name |
puma.var_vs_var.VarVsVar | None
|
Corresponding reference VarVsVar |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no reference VarVsVar was found or multiple matches. |
Source code in puma/var_vs_var.py
plot
#
Plotting curves.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
typing.Any
|
Keyword arguments passed to plt.axis.errorbar |
{}
|
Returns:
| Type | Description |
|---|---|
matplotlib.lines.Line2D
|
matplotlib Line2D object |
Source code in puma/var_vs_var.py
plot_ratios
#
Plotting ratio curves.
Raises:
| Type | Description |
|---|---|
ValueError
|
If no reference curve is defined |
Source code in puma/var_vs_var.py
set_reference
#
Setting the reference VarVsVar curves used in the ratios.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Unique identifier of roc object |
required |
Source code in puma/var_vs_var.py
puma.var_vs_eff.VarVsEff
#
Bases: puma.var_vs_var.VarVsVar
Class for efficiency vs. variable plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_var_sig
|
numpy.ndarray
|
Values for x-axis variable for signal |
required |
disc_sig
|
numpy.ndarray
|
Discriminant values for signal |
required |
weights_sig
|
numpy.ndarray | None
|
Weights for the signal. If not provided, equal weights will be used. By default None |
None
|
x_var_bkg
|
numpy.ndarray
|
Values for x-axis variable for background, by default None |
None
|
disc_bkg
|
numpy.ndarray
|
Discriminant values for background, by default None |
None
|
weights_bkg
|
numpy.ndarray | None
|
Weights for the background. If not provided, equal weights will be used. By default None |
None
|
bins
|
int | list | numpy.ndarray
|
If bins is an int, it defines the number of equal-width bins in the given range (10, by default). If bins is a sequence, it defines a monotonically increasing array of bin edges, including the rightmost edge, allowing for non-uniform bin widths, by default 10 |
10
|
working_point
|
float | list | None
|
Working point, by default None |
None
|
fixed_bkg_rej
|
float | None
|
Instead of fixing the signal efficiency (by using working_point), fix the background rejection to a certain value. By default None |
None
|
disc_cut
|
int | list | numpy.ndarray | None
|
Cut value for discriminant, if it is a sequence it has to have the same length as number of bins, by default None |
None
|
flat_per_bin
|
bool
|
If True and no |
False
|
key
|
str | None
|
Identifier for the curve e.g. tagger, by default None |
None
|
**kwargs
|
typing.Any
|
Keyword arguments passed to |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
x_var_sig and disc_sig have different lengths x_var_bkg and disc_bkg have different lengths Neither working_point nor flat_per_bin was set Both disc_cut and flat_per_bin are set working_point is not set but flat_per_bin is Using PCFT bins and flat_per_bin together Using disc_cut and working_point together disc_cut (if an array) has a different length than the number of bins given |
TypeError
|
If "working_point" is neither a list nor a float |
Source code in puma/var_vs_eff.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
args_to_store
property
#
Returns the arguments that need to be stored/loaded.
Returns:
| Type | Description |
|---|---|
dict[str, typing.Any]
|
Dict with the arguments |
bkg_eff
property
#
Calculate background efficiency per bin.
Returns:
| Type | Description |
|---|---|
numpy.ndarray
|
Efficiency |
numpy.ndarray
|
Efficiency_error |
bkg_eff_sig_err
property
#
Calculate signal efficiency per bin, assuming a flat background per bin. This results in returning the signal efficiency per bin, but the background error per bin.
bkg_rej
property
#
Calculate background rejection per bin.
Returns:
| Type | Description |
|---|---|
numpy.ndarray
|
Rejection |
numpy.ndarray
|
Rejection_error |
sig_eff
property
#
Calculate signal efficiency per bin.
Returns:
| Type | Description |
|---|---|
numpy.ndarray
|
Efficiency |
numpy.ndarray
|
Efficiency_error |
sig_rej
property
#
Calculate signal rejection per bin.
Returns:
| Type | Description |
|---|---|
numpy.ndarray
|
Rejection |
numpy.ndarray
|
Rejection_error |
efficiency
#
Calculate efficiency and the associated error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arr
|
numpy.ndarray
|
Array with discriminants |
required |
cut
|
float | numpy.ndarray
|
Cut value. If you want to use PCFT, two values are provided. The lower and the upper cut. |
required |
weights
|
numpy.ndarray | None
|
Weights to use for the array. Must be same length as arr! When None is given, equal weights are used. By default None |
None
|
Returns:
| Type | Description |
|---|---|
float | numpy.ndarray
|
Efficiency |
float | numpy.ndarray
|
Efficiency error |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the cut parameter type is not supported |
Source code in puma/var_vs_eff.py
get
#
Wrapper around rejection and efficiency functions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str
|
Can be "sig_eff", "bkg_eff", "sig_rej", "bkg_rej", or "bkg_eff_sig_err" |
required |
inverse_cut
|
bool
|
Inverts the discriminant cut, which will yield the efficiency or rejection of the jets not passing the working point, by default False |
False
|
Returns:
| Type | Description |
|---|---|
numpy.ndarray
|
Rejection or efficiency depending on |
numpy.ndarray
|
Rejection or efficiency error depending on |
Raises:
| Type | Description |
|---|---|
ValueError
|
If mode not supported |
Source code in puma/var_vs_eff.py
rejection
#
Calculate rejection and the associated error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arr
|
numpy.ndarray
|
Array with discriminants |
required |
cut
|
float | numpy.ndarray
|
Cut value used for the given working point. Ndarray when PCFT-style cuts are used |
required |
weights
|
numpy.ndarray | None
|
Weights to use for the array. Must be same length as arr! When None is given, equal weights are used. By default None |
None
|
Returns:
| Type | Description |
|---|---|
float | numpy.ndarray
|
Rejection |
float | numpy.ndarray
|
Rejection error |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the cut parameter type is not supported |
Source code in puma/var_vs_eff.py
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 | |
puma.var_vs_eff.VarVsEffPlot
#
Bases: puma.var_vs_var.VarVsVarPlot
VarVsEff plot class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str
|
Defines which quantity is plotted, the following options ar available: sig_eff - Plots signal efficiency vs. variable, with statistical error on N signal per bin bkg_eff - Plots background efficiency vs. variable, with statistical error on N background per bin sig_rej - Plots signal rejection vs. variable, with statistical error on N signal per bin bkg_rej - Plots background rejection vs. variable, with statistical error on N background per bin bkg_eff_sig_err - Plots background efficiency vs. variable, with statistical error on N signal per bin. |
required |
grid
|
bool
|
Set the grid for the plots. |
False
|
**kwargs
|
typing.Any
|
Keyword arguments from |
{}
|
Attributes:
| Name | Type | Description |
|---|---|---|
mode_options |
typing.ClassVar[list[str]]
|
List of possible modes. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If incompatible mode given or more than 1 ratio panel requested |
Source code in puma/var_vs_eff.py
apply_modified_atlas_second_tag
#
Modifies the atlas_second_tag to include info on the type of p-eff plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signal
|
ftag.labels.Label | None
|
Signal flavour that is used. By default None |
None
|
background
|
ftag.labels.Label | None
|
Background flavour that is used. By default None |
None
|
working_point
|
float | list | None
|
Working point that was used. When PCFT was used, this is a list of length 2. If disc_cut/fixed_bkg_rej is used, this needs to be None, by default None |
None
|
fixed_bkg_rej
|
float | None
|
The background rejection to which it was fixed. Must be None when working_point or disc_cut is used. By default None |
None
|
disc_cut
|
float | None
|
Discriminant cut that was used. If working_point/fixed_bkg_rej is used, this must be None. By default None |
None
|
flat_per_bin
|
bool
|
If flat_per_bin was used, by default False |
False
|
Source code in puma/var_vs_eff.py
plot
#
Plotting curves.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
typing.Any
|
Keyword arguments passed to plt.axis.errorbar |
{}
|
Returns:
| Type | Description |
|---|---|
matplotlib.lines.Line2D
|
matplotlib Line2D object |
Source code in puma/var_vs_eff.py
puma.var_vs_vtx.VarVsVtx
#
Bases: puma.var_vs_var.VarVsVar
VarVsVtx class storing info about vertexing performance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_var
|
numpy.ndarray
|
Values for x-axis variable for signal |
required |
n_match
|
numpy.ndarray
|
Values for number of correctly identified objects (where truth and reco match) |
required |
n_true
|
numpy.ndarray
|
Values for true number of objects |
required |
n_reco
|
numpy.ndarray
|
Values for reconstructed number of objects |
required |
bins
|
int | collections.abc.Sequence
|
If bins is an int, it defines the number of equal-width bins in the given range (10, by default). If bins is a sequence, it defines a monotonically increasing array of bin edges, including the rightmost edge, allowing for non-uniform bin widths, by default 10 |
10
|
key
|
str | None
|
Identifier for the curve e.g. tagger, by default None |
None
|
**kwargs
|
typing.Any
|
Keyword arguments passed to |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If provided options are not compatible with each other |
Source code in puma/var_vs_vtx.py
efficiency
property
#
Calculate vertexing efficiency per bin. Defined as number of reconstructed vertices matched to truth divided by number of total true vertices.
Returns:
| Type | Description |
|---|---|
numpy.ndarray
|
Efficiency |
numpy.ndarray
|
Efficiency error |
fakes
property
#
Calculate vertexing fake rate per bin. Defined as total number of events with reconstructed vertices where vertices are not expected.
Returns:
| Type | Description |
|---|---|
numpy.ndarray
|
Fake rate |
numpy.ndarray
|
Fake rate error |
purity
property
#
Calculate vertexing purity per bin. Defined as number of reconstructed vertices matched to truth divided by number of total reconstructed vertices.
Returns:
| Type | Description |
|---|---|
numpy.ndarray
|
Purity |
numpy.ndarray
|
Purity error |
__eq__
#
Handles a == check with the class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
puma.var_vs_vtx.VarVsVtx
|
Other VarVsVtx that this class is tested against |
required |
Returns:
| Type | Description |
|---|---|
bool
|
If this VarVsVtx and the other are equal |
Source code in puma/var_vs_vtx.py
get
#
Wrapper around rejection and efficiency functions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str
|
Can be "efficiency", "purity" or "fakes" |
required |
Returns:
| Type | Description |
|---|---|
numpy.ndarray
|
Efficiency, purity or fake rate depending on |
numpy.ndarray
|
Efficiency, purity or fake rate error depending on |
Raises:
| Type | Description |
|---|---|
ValueError
|
If mode not supported |
Source code in puma/var_vs_vtx.py
get_performance_ratio
#
Calculate performance ratio for vertexing task. Either n_matched/n_true (efficiency) or n_matched/n_reco (purity).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num
|
numpy.ndarray
|
Array with discriminants |
required |
denom
|
numpy.ndarray
|
Cut value |
required |
Returns:
| Type | Description |
|---|---|
numpy.ndarray
|
Performance ratio |
numpy.ndarray
|
Performance ratio error |
Source code in puma/var_vs_vtx.py
puma.var_vs_vtx.VarVsVtxPlot
#
Bases: puma.var_vs_var.VarVsVarPlot
var_vs_vtx plot class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str
|
Defines which quantity is plotted, the following options ar available: efficiency - Plots efficiency vs. variable for jets where vertices are expected purity - Plots purity vs. variable for jets where vertices are expected fakes - Plots fake rate vs. variable for jets where vertices are not expected |
required |
grid
|
bool
|
Set the grid for the plots. |
False
|
**kwargs
|
typing.Any
|
Keyword arguments from |
{}
|
Attributes:
| Name | Type | Description |
|---|---|---|
mode_options |
typing.ClassVar[list[str]]
|
List of possible modes. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If incompatible mode given or more than 1 ratio panel requested |
Source code in puma/var_vs_vtx.py
plot
#
Plotting curves.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
typing.Any
|
Keyword arguments passed to plt.axis.errorbar |
{}
|
Returns:
| Type | Description |
|---|---|
matplotlib.lines.Line2D
|
matplotlib Line2D object |