madminer.analysis package

Submodules

madminer.analysis.dataanalyzer module

class madminer.analysis.dataanalyzer.DataAnalyzer(filename, disable_morphing=False, include_nuisance_parameters=True)[source]

Bases: object

Collects common functionality that is used when analysing data in the MadMiner file.

Parameters
filenamestr

Path to MadMiner file (for instance the output of madminer.delphes.DelphesProcessor.save()).

disable_morphingbool, optional

If True, the morphing setup is not loaded from the file. Default value: False.

include_nuisance_parametersbool, optional

If True, nuisance parameters are taken into account. Default value: True.

Methods

event_loader([start, end, batch_size, ...])

Yields batches of events in the MadMiner file.

weighted_events([theta, nu, start_event, ...])

Returns all events together with the benchmark weights (if theta is None) or weights for a given theta.

xsec_gradients(thetas[, nus, partition, ...])

Returns the gradient of total cross sections with respect to parameters.

xsecs([thetas, nus, partition, test_split, ...])

Returns the total cross sections for benchmarks or parameter points.

event_loader(start=0, end=None, batch_size=100000, include_nuisance_parameters=None, generated_close_to=None, return_sampling_ids=False)[source]

Yields batches of events in the MadMiner file.

Parameters
startint, optional

First event index to load

endint or None, optional

Last event index to load

batch_sizeint, optional

Batch size

include_nuisance_parametersbool, optional

Whether nuisance parameter benchmarks are included in the returned data

generated_close_toNone or ndarray, optional

If None, this function yields all events. Otherwise, it just yields just the events that were generated at the closest benchmark point to a given parameter point.

return_sampling_idsbool, optional

If True, the iterator returns the sampling IDs in addition to observables and weights.

Yields
observationsndarray

Event data

weightsndarray

Event weights

sampling_idsint

Sampling IDs (benchmark used for sampling for signal events, -1 for background events). Only returned if return_sampling_ids = True was set.

weighted_events(theta=None, nu=None, start_event=None, end_event=None, derivative=False, generated_close_to=None, n_draws=None)[source]

Returns all events together with the benchmark weights (if theta is None) or weights for a given theta.

Parameters
thetaNone or ndarray or str, optional

If None, the function returns all benchmark weights. If str, the function returns the weights for a given benchmark name. If ndarray, it uses morphing to calculate the weights for this value of theta. Default value: None.

nuNone or ndarray, optional

If None, the nuisance parameters are set to their nominal values. Otherwise, and if theta is an ndarray, sets the values of the nuisance parameters.

start_eventint

Index (in the MadMiner file) of the first event to consider.

end_eventint

Index (in the MadMiner file) of the last unweighted event to consider.

derivativebool, optional

If True and if theta is not None, the derivative of the weights with respect to theta are returned. Default value: False.

generated_close_toNone or int, optional

Only returns benchmarks generated from this benchmark (and background events). Default value: None.

n_drawsNone or int, optional

If not None, returns only this number of events, drawn randomly.

Returns
xndarray

Observables with shape (n_unweighted_samples, n_observables).

weightsndarray

If theta is None and derivative is False, benchmark weights with shape (n_unweighted_samples, n_benchmarks) in pb. If theta is not None and derivative is True, the gradient of the weight for the given parameter with respect to theta with shape (n_unweighted_samples, n_gradients) in pb. Otherwise, weights for the given parameter theta with shape (n_unweighted_samples,) in pb.

xsec_gradients(thetas, nus=None, partition='all', test_split=0.2, validation_split=0.2, gradients='all', batch_size=100000, generated_close_to=None)[source]

Returns the gradient of total cross sections with respect to parameters.

Parameters
thetaslist of (ndarray or str), optional

If None, the function returns all benchmark cross sections. Otherwise, it returns the cross sections for a series of parameter points that are either given by their benchmark name (as a str), their benchmark index (as an int), or their parameter value (as an ndarray, using morphing). Default value: None.

nusNone or list of (None or ndarray), optional

If None, the nuisance parameters are set to their nominal values (0), i.e. no systematics are taken into account. Otherwise, the list has to have the same number of elements as thetas, and each entry can specify nuisance parameters at nominal value (None) or a value of the nuisance parameters (ndarray).

partition{“train”, “test”, “validation”, “all”}, optional

Which events to use. Default: “all”.

test_splitfloat, optional

Fraction of events reserved for testing. Default value: 0.2.

validation_splitfloat, optional

Fraction of weighted events reserved for validation. Default value: 0.2.

gradients{“all”, “theta”, “nu”}, optional

Which gradients to calculate. Default value: “all”.

batch_sizeint, optional

Size of the batches of events that are loaded into memory at the same time. Default value: 100000.

generated_close_toNone or ndarray, optional

If not None, only events originally generated from the closest benchmark to this parameter point will be used. Default value : None.

Returns
xsecs_gradientsndarray

Calculated cross section gradients in pb with shape (n_gradients,).

xsecs(thetas=None, nus=None, partition='all', test_split=0.2, validation_split=0.2, include_nuisance_benchmarks=True, batch_size=100000, generated_close_to=None)[source]

Returns the total cross sections for benchmarks or parameter points.

Parameters
thetasNone or list of (ndarray or str), optional

If None, the function returns all benchmark cross sections. Otherwise, it returns the cross sections for a series of parameter points that are either given by their benchmark name (as a str), their benchmark index (as an int), or their parameter value (as an ndarray, using morphing). Default value: None.

nusNone or list of (None or ndarray), optional

If None, the nuisance parameters are set to their nominal values (0), i.e. no systematics are taken into account. Otherwise, the list has to have the same number of elements as thetas, and each entry can specify nuisance parameters at nominal value (None) or a value of the nuisance parameters (ndarray).

partition{“train”, “test”, “validation”, “all”}, optional

Which event partition to use. Default: “all”.

test_splitfloat, optional

Fraction of events reserved for testing. Default value: 0.2.

validation_splitfloat, optional

Fraction of weighted events reserved for validation. Default value: 0.2.

include_nuisance_benchmarksbool, optional

Whether to include nuisance benchmarks if thetas is None. Default value: True.

batch_sizeint, optional

Size of the batches of events that are loaded into memory at the same time. Default value: 100000.

generated_close_toNone or ndarray, optional

If not None, only events originally generated from the closest benchmark to this parameter point will be used. Default value : None.

Returns
xsecsndarray

Calculated cross sections in pb.

xsec_uncertaintiesndarray

Cross-section uncertainties in pb. Basically calculated as sum(weights**2)**0.5.

Module contents