Skip to content

Commit

Permalink
Restrict Fisher information calc. based on nuisance_morpher (#519)
Browse files Browse the repository at this point in the history
Sinclert authored Oct 16, 2022
1 parent 5d2dbcb commit 8200171
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions madminer/fisherinformation/information.py
Original file line number Diff line number Diff line change
@@ -1208,26 +1208,25 @@ def _calculate_fisher_information(
does not take into account any uncertainty on the nuisance parameter part of the Fisher information, and
correlations between events are neglected. Note that independent of sum_events, the covariance matrix is
always summed over the events.
"""

include_nuisance_parameters = include_nuisance_parameters and self.include_nuisance_parameters

# Get morphing matrices
theta_matrix = self._get_theta_benchmark_matrix(theta, zero_pad=False) # (n_benchmarks_phys,)
dtheta_matrix = self._get_dtheta_benchmark_matrix(theta, zero_pad=False) # (n_parameters, n_benchmarks_phys)

# Get differential xsec per event, and the derivative wrt to theta
sigma = mdot(theta_matrix, weights_benchmarks) # Shape (n_events,)
total_xsec = np.sum(sigma)
inv_sigma = sanitize_array(1.0 / sigma) # Shape (n_events,)
dsigma = mdot(dtheta_matrix, weights_benchmarks) # Shape (n_parameters, n_events)

# Calculate physics Fisher info for this event
fisher_info_phys = luminosity * np.einsum("n,in,jn->nij", inv_sigma, dsigma, dsigma)

if include_nuisance_parameters and self.nuisance_morpher is None:
logger.warning("Cannot include nuisance parameters as none were found in the setup file")

# Nuisance parameter Fisher info
if include_nuisance_parameters:
if include_nuisance_parameters and self.nuisance_morpher is not None:
nuisance_a = self.nuisance_morpher.calculate_a(weights_benchmarks) # Shape (n_nuisance_params, n_events)
# grad_i dsigma(x), where i is a nuisance parameter, is given by
# sigma[np.newaxis, :] * a
2 changes: 1 addition & 1 deletion madminer/sampling/sampleaugmenter.py
Original file line number Diff line number Diff line change
@@ -1734,7 +1734,7 @@ def _combine_thetas_nus(self, all_thetas, all_nus):
add_nuisance_params = True

# No nuisance params?
if not add_nuisance_params or self.nuisance_morpher is None or self.n_nuisance_parameters == 0:
if not add_nuisance_params or self.nuisance_morpher is None:
return all_thetas

all_combined = []

0 comments on commit 8200171

Please sign in to comment.