Variable vs Variable
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.
Initialise properties of VarVsVar curve object.
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
|
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
|
**kwargs
|
puma.var_vs_var.VarVsVar(kwargs)
|
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
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
divide
#
Calculate ratio between two class objects.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
VarVsVar class
|
Second VarVsVar object to calculate ratio with |
required |
inverse
|
bool
|
If False the ratio is calculated |
False
|
Returns:
Type | Description |
---|---|
numpy.ndarray
|
Ratio |
numpy.ndarray
|
Ratio error |
Raises:
Type | Description |
---|---|
ValueError
|
If binning is not identical between 2 objects |
Source code in puma/var_vs_var.py
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 |
|
puma.var_vs_var.VarVsVarPlot
#
Bases: puma.plot_base.PlotBase
var_vs_eff plot class.
var_vs_eff plot properties.
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". |
'divide'
|
**kwargs
|
puma.var_vs_var.VarVsVarPlot(kwargs)
|
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
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 |
|
add
#
Adding VarVsVar object to figure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
curve
|
VarVsVar class
|
VarVsVar curve |
required |
key
|
str
|
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
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 |
|
draw
#
Draw figure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
labelpad
|
int
|
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
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
|
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
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 |
|
plot
#
Plotting curves.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Keyword arguments passed to plt.axis.errorbar |
{}
|
Returns:
Type | Description |
---|---|
puma.line_plot_2d.Line2D
|
matplotlib Line2D object |
Source code in puma/var_vs_var.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
|
plot_ratios
#
Plotting ratio curves.
Raises:
Type | Description |
---|---|
ValueError
|
If no reference curve is defined |
Source code in puma/var_vs_var.py
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
|
set_reference
#
Setting the reference roc 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
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
|
puma.var_vs_eff.VarVsEff
#
Bases: puma.var_vs_var.VarVsVar
Class for efficiency vs. variable plot.
Initialise properties of roc curve object.
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 |
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
|
bins
|
int or sequence of scalars
|
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
|
Working point, by default None |
None
|
disc_cut
|
float or sequence of floats
|
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
|
Identifier for the curve e.g. tagger, by default None |
None
|
**kwargs
|
puma.var_vs_eff.VarVsEff(kwargs)
|
Keyword arguments passed to |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
If provided options are not compatible with each other |
Source code in puma/var_vs_eff.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 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 |
|
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 |
_apply_binning
#
Get binned distributions for the signal and background.
Source code in puma/var_vs_eff.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
|
_get_disc_cuts
#
Retrieve cut values on discriminant. If disc_cut
is not given, retrieve
cut values from the working point.
Source code in puma/var_vs_eff.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
|
_set_bin_edges
#
Calculate bin edges, centres and width and save them as class variables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bins
|
int or sequence of scalars
|
If bins is an int, it defines the number of equal-width bins in the given range. If bins is a sequence, it defines a monotonically increasing array of bin edges, including the rightmost edge, allowing for non-uniform bin widths. |
required |
Source code in puma/var_vs_eff.py
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 |
|
efficiency
#
Calculate efficiency and the associated error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arr
|
numpy.ndarray
|
Array with discriminants |
required |
cut
|
float
|
Cut value |
required |
Returns:
Type | Description |
---|---|
float
|
Efficiency |
float
|
Efficiency error |
Source code in puma/var_vs_eff.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
|
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
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
|
rejection
#
Calculate rejection and the associated error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arr
|
numpy.ndarray
|
Array with discriminants |
required |
cut
|
float
|
Cut value |
required |
Returns:
Type | Description |
---|---|
float
|
Rejection |
float
|
Rejection error |
Source code in puma/var_vs_eff.py
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 |
|
puma.var_vs_eff.VarVsEffPlot
#
Bases: puma.var_vs_var.VarVsVarPlot
var_vs_eff plot class.
var_vs_eff plot properties.
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
|
puma.var_vs_eff.VarVsEffPlot(kwargs)
|
Keyword arguments from |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
If incompatible mode given or more than 1 ratio panel requested |
Source code in puma/var_vs_eff.py
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 |
|
apply_modified_atlas_second_tag
#
Modifies the atlas_second_tag to include info on the type of p-eff plot being displayed.
Source code in puma/var_vs_eff.py
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 |
|
plot
#
Plotting curves.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Keyword arguments passed to plt.axis.errorbar |
{}
|
Returns:
Type | Description |
---|---|
puma.line_plot_2d.Line2D
|
matplotlib Line2D object |
Source code in puma/var_vs_eff.py
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
|
puma.var_vs_vtx.VarVsVtx
#
Bases: puma.var_vs_var.VarVsVar
var_vs_vtx class storing info about vertexing performance.
Initialise properties of roc curve object.
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 or sequence of scalars
|
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
|
Identifier for the curve e.g. tagger, by default None |
None
|
**kwargs
|
puma.var_vs_vtx.VarVsVtx(kwargs)
|
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
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 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 |
|
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 |
_apply_binning
#
Get binned distributions for number of matches, truth and reco objects.
Source code in puma/var_vs_vtx.py
129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
_set_bin_edges
#
Calculate bin edges, centres and width and save them as class variables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bins
|
int or sequence of scalars
|
If bins is an int, it defines the number of equal-width bins in the given range. If bins is a sequence, it defines a monotonically increasing array of bin edges, including the rightmost edge, allowing for non-uniform bin widths. |
required |
Source code in puma/var_vs_vtx.py
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 |
|
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
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
|
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 |
---|---|---|---|
arr
|
numpy.ndarray
|
Array with discriminants |
required |
cut
|
float
|
Cut value |
required |
Returns:
Type | Description |
---|---|
float
|
Performance ratio |
float
|
Performance ratio error |
Source code in puma/var_vs_vtx.py
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 |
|
puma.var_vs_vtx.VarVsVtxPlot
#
Bases: puma.var_vs_var.VarVsVarPlot
var_vs_vtx plot properties.
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
|
puma.var_vs_vtx.VarVsVtxPlot(kwargs)
|
Keyword arguments from |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
If incompatible mode given or more than 1 ratio panel requested |
Source code in puma/var_vs_vtx.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
|
plot
#
Plotting curves.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Keyword arguments passed to plt.axis.errorbar |
{}
|
Returns:
Type | Description |
---|---|
puma.line_plot_2d.Line2D
|
matplotlib Line2D object |
Source code in puma/var_vs_vtx.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
|