Skip to content

Commit

Permalink
Added kappa lambda likelihood
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaMantani committed Feb 6, 2025
1 parent 89a4bb4 commit 1b5deac
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions external_chi2/kappa_lambda/chi2_kappa_lambda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import jax.numpy as jnp
import numpy as np
from pathlib import Path
import pickle

# Get the directory of the current file
current_dir = Path(__file__).parent


class HLLHC_kappa_lambda_chi2:
def __init__(self, coefficients, rgemat=None):
self.wc = [
"Op",
]
self.rgemat = rgemat
self.chi2_path = current_dir / "kappa_lambda_HL-LHC_likelihood.pkl"

# coefficients is a list with the names of the coefficients. We need to create a projection matrix
# that projects the coefficients to the basis of the observables
self.project = np.zeros((len(self.wc), coefficients.size))
for i, op in enumerate(self.wc):
if op in coefficients.name:
self.project[i, np.argwhere(coefficients.name == op)[0, 0]] = 1

if self.rgemat is not None:
self.project = jnp.einsum("ij,jk->ik", self.project, self.rgemat)

# load pickle file
with open(self.chi2_path, "rb") as f:
self.chi2 = pickle.load(f)

def compute_chi2(self, coefficient_values):
coeffs_vals = jnp.dot(self.project, coefficient_values)
# now we have to transform cphi in klambda
klambda = 1 - 0.47 * coeffs_vals

chi2_value = self.chi2(klambda).squeeze()

return chi2_value
Binary file not shown.

0 comments on commit 1b5deac

Please sign in to comment.