def main(): np.set_printoptions(edgeitems=3) np.core.arrayprint._line_width = 120 eft = EftPredictions(wilson_coefficients, MG_SM, sig_SM) xs_limit = 0.0177 + sig_SM / 1000. min_val, max_val = -15., 15 marginalized_step = 3 wilson_of_interest_step = 0.1 marginal_min_wilson = +100000000. marginal_max_wilson = -100000000. total = ((max_val - min_val) / marginalized_step)**4 * ( max_val - min_val) / wilson_of_interest_step print "Total number of evaluations: {}".format(total) i = 0 for C1 in np.arange(min_val, max_val, marginalized_step): for C2 in np.arange(min_val, max_val, marginalized_step): for C3 in np.arange(min_val, max_val, marginalized_step): for C4 in np.arange(min_val, max_val, marginalized_step): progress(i, total, 'Progress') i += ((max_val - min_val) / wilson_of_interest_step) for C5 in np.arange(min_val, max_val, wilson_of_interest_step): xs = eft.gen_eft_xs([C5, C1, C2, C3, C4]) if xs < xs_limit: if xs > marginal_max_wilson: marginal_max_wilson = xs if xs < marginal_min_wilson: marginal_min_wilson = xs print '\nMarginal limits: [{}; {}]'.format(marginal_min_wilson, marginal_max_wilson)
def __init__(self, configuration): from eft_coefficients import EftPredictions from mg_calculations import wilson_coefficients, MG_SM, sig_SM self._configuration = configuration self._objects = {} self._independent_limits = {} self._marginal_limits = {} self._annotation = 'Performance comparision of different MVA discriminants' self._eft = EftPredictions(wilson_coefficients, MG_SM, sig_SM) self._combine_limits = None with open(self._configuration['combine_asymptotic_limits_json'], 'r') as combine_json_file_handle: self._combine_limits = json.load(combine_json_file_handle) if 'annotation' in self._configuration: self._annotation = self._configuration['annotation'] self.Initialize()
def main(): np.set_printoptions(edgeitems=3) np.core.arrayprint._line_width = 120 eft = EftPredictions(wilson_coefficients, MG_SM, sig_SM) #Plots with limit contours make_plot1d(eft.S) # make_plot2dC1C2(eft.S) # make_plot2dC0C1(eft.S) # make_plot3d(eft.S) print eft.S
import numpy as np from mg_calculations import * from eft_coefficients import EftPredictions # see http://www.am.ub.edu/~robert/Documents/quadric.pdf eft = EftPredictions(wilson_coefficients, MG_SM, sig_SM) S = eft.S list_reference_wilson_coefs = [1.0]*5 np_reference_wilson_coefs = np.array(list_reference_wilson_coefs) print "Reference cross section: ", eft.gen_eft_xs(list_reference_wilson_coefs) mat_result = np.dot( np_reference_wilson_coefs.T, np.dot(eft.Sigma2_matr, np_reference_wilson_coefs)) + 2.0*np.dot(eft.Sigma1_vec.T,np_reference_wilson_coefs) + eft.sig_sm print "Matrix form result: ", mat_result upper_limit_50 = 2.0312 Ak_matrices = [] Zk_vectors = [] Ck_vectors = [] Dk_vectors = [] Ek_vectors = [] p2,p1,p0 = [],[],[] # independent_coef = 4 # eft.Sigma1_vec = eft.Sigma1_vec[np.ix_([independent_coef])] # eft.Sigma2_matr = eft.Sigma2_matr[np.ix_([independent_coef],[independent_coef])] # print eft.Sigma1_vec
class Model(object): def __init__(self, configuration): from eft_coefficients import EftPredictions from mg_calculations import wilson_coefficients, MG_SM, sig_SM self._configuration = configuration self._objects = {} self._independent_limits = {} self._marginal_limits = {} self._annotation = 'Performance comparision of different MVA discriminants' self._eft = EftPredictions(wilson_coefficients, MG_SM, sig_SM) self._combine_limits = None with open(self._configuration['combine_asymptotic_limits_json'], 'r') as combine_json_file_handle: self._combine_limits = json.load(combine_json_file_handle) if 'annotation' in self._configuration: self._annotation = self._configuration['annotation'] self.Initialize() @log_with() def Initialize(self): pass @log_with() def get(self, name): """ Factory method """ if name in self._objects: return self._objects[name] else: self._objects[name] = Limit() return self._objects[name] def get_independent_limit(self, name): from mg_calculations import sig_SM if name in self._independent_limits: return self._independent_limits[name] else: self._independent_limits[name] = None # Solve for independent limits coefs = None if name == 'O_R': coefs = self._eft.O_R_independent_polynomial_coefficients() if name == 'O_L^1': coefs = self._eft.O_L1_independent_polynomial_coefficients() if name == 'O_L^8': coefs = self._eft.O_L8_independent_polynomial_coefficients() if name == 'O_B^1': coefs = self._eft.O_B1_independent_polynomial_coefficients() if name == 'O_B^8': coefs = self._eft.O_B8_independent_polynomial_coefficients() if name == 'O_L^1+O_L^8': coefs = self._eft.O_L1L8_independent_polynomial_coefficients() expected_coefs = coefs[:] expected_coefs[-1] = expected_coefs[ -1] - self._combine_limits['exp_50.0'] * sig_SM expected_interval = np.roots(expected_coefs) logging.info("Independent Expected limits for {}: {}".format( name, expected_interval)) expected_68up_coefs = coefs[:] expected_68up_coefs[-1] = expected_68up_coefs[ -1] - self._combine_limits['exp_84.0'] * sig_SM expected_68up_interval = np.roots(expected_68up_coefs) logging.info( "Independent Expected 68% Up limits for {}: {}".format( name, expected_68up_interval)) expected_95up_coefs = coefs[:] expected_95up_coefs[-1] = expected_95up_coefs[ -1] - self._combine_limits['exp_97.5'] * sig_SM expected_95up_interval = np.roots(expected_95up_coefs) logging.info( "Independent Expected 95% Up limits for {}: {}".format( name, expected_95up_interval)) observed_coefs = coefs[:] observed_coefs[ -1] = observed_coefs[-1] - self._combine_limits['obs'] * sig_SM observed_interval = np.roots(observed_coefs) # logging.info("Independent Expected 68% Down limits for {}: {}".format(name, expected_68down_interval)) self._independent_limits[name] = Limit( exp_min=round(expected_interval[0], 1), exp_max=round(expected_interval[1], 1), exp_min68=round(expected_68up_interval[0], 1), exp_max68=round(expected_68up_interval[1], 1), exp_min95=round(expected_95up_interval[0], 1), exp_max95=round(expected_95up_interval[1], 1), obs_min=round(observed_interval[0], 1), obs_max=round(observed_interval[1], 1)) return self._independent_limits[name] def get_marginal_limit(self, name, excluded_operators=None): from mg_calculations import sig_SM # compute marginalized projections # see http://www.am.ub.edu/~robert/Documents/quadric.pdf if excluded_operators is not None and name in excluded_operators: raise RuntimeError( "Requested operator {} is in the list of excluded:{}".format( name, excluded_operators)) if name in self._marginal_limits: return self._marginal_limits[name] else: excluded_indices = [ self._eft.name_index_map[op_name] for op_name in excluded_operators ] k = self._eft.name_index_map[name] self._marginal_limits[name] = None Ak_mat = self._eft.Sigma2_matr.copy() Zk_vec = -self._eft.Sigma2_matr.copy()[:, k] Ck_vec = -self._eft.Sigma1_vec.copy() eliminatedSigma2_matr = self._eft.Sigma2_matr.copy() eliminatedSigma1_vec = self._eft.Sigma1_vec.copy() print '#' * 50 print Ak_mat print Zk_vec print Ck_vec print '*' * 50 # Remove excluded directions for i in range(self._eft.N_wilsons): if i in excluded_indices: eliminatedSigma2_matr = np.delete(eliminatedSigma2_matr, (i), axis=0) eliminatedSigma2_matr = np.delete(eliminatedSigma2_matr, (i), axis=1) eliminatedSigma1_vec = np.delete(eliminatedSigma1_vec, (i), axis=0) Ak_mat = np.delete(Ak_mat, (i), axis=0) Ak_mat = np.delete(Ak_mat, (i), axis=1) Zk_vec = np.delete(Zk_vec, (i), axis=0) Ck_vec = np.delete(Ck_vec, (i), axis=0) if k > i: k -= 1 print Ak_mat print Zk_vec print Ck_vec print '-' * 50 # Calculate projections of tangent planes for i in range(self._eft.N_wilsons - len(excluded_indices)): for j in range(self._eft.N_wilsons - len(excluded_indices)): if i == k: Ak_mat[i, j] = 0 if j == k: Ak_mat[i, j] = 0 Ak_mat[k, k] = 1 Zk_vec[k] = 1 Ck_vec[k] = 0 print Ak_mat print Zk_vec print Ck_vec Dk_vec = np.linalg.inv(Ak_mat).dot(Zk_vec) Ek_vec = np.linalg.inv(Ak_mat).dot(Ck_vec) p2 = eliminatedSigma2_matr[k, :].dot(Dk_vec) p1 = eliminatedSigma2_matr[k, :].dot( Ek_vec) + eliminatedSigma1_vec.dot( Dk_vec) + eliminatedSigma1_vec[k] p0 = eliminatedSigma1_vec.dot(Ek_vec) + sig_SM expected_interval = np.roots( [p2, p1, p0 - self._combine_limits['exp_50.0'] * sig_SM]) expected_68up_interval = np.roots( [p2, p1, p0 - self._combine_limits['exp_84.0'] * sig_SM]) expected_95up_interval = np.roots( [p2, p1, p0 - self._combine_limits['exp_97.5'] * sig_SM]) observed_interval = np.roots( [p2, p1, p0 - self._combine_limits['obs'] * sig_SM]) self._marginal_limits[name] = Limit( exp_min=round(expected_interval[0], 1), exp_max=round(expected_interval[1], 1), exp_min68=round(expected_68up_interval[0], 1), exp_max68=round(expected_68up_interval[1], 1), exp_min95=round(expected_95up_interval[0], 1), exp_max95=round(expected_95up_interval[1], 1), obs_min=round(observed_interval[0], 1), obs_max=round(observed_interval[1], 1)) return self._marginal_limits[name]
def Initialize(self): self._eft = EftPredictions(wilson_coefficients, MG_SM, sig_SM) pass
import sympy as sp from mg_calculations import * from eft_coefficients import EftPredictions eft = EftPredictions(wilson_coefficients, MG_SM, sig_SM) S = eft.S print(S) sig_sm_tttt, C0, C1, C2, C3, C4 = sp.symbols("sigma_sm_tttt C0 C1 C2 C3 C4") S0, S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, S11, S12, S13, S14, S15, S16, S17, S18, S19 = sp.symbols( "S0 S1 S2 S3 S4 S5 S6 S7 S8 S9 S10 S11 S12 S13 S14 S15 S16 S17 S18 S19") xs_eq = sig_sm_tttt + C0 * S0 + C1 * S1 + C2 * S2 + C3 * S3 + C4 * S4 + \ (C0 ** 2.) * S5 + (C1 ** 2.) * S6 + (C2 ** 2.) * S7 + (C3 ** 2.) * S8 + (C4 ** 2.) * S9 + \ 2. * C0 * C1 * S10 + 2. * C0 * C2 * S11 + 2. * C0 * C3 * S12 + 2. * C0 * C4 * S13 + \ 2. * C1 * C2 * S14 + 2. * C1 * C3 * S15 + 2. * C1 * C4 * S16 + \ 2. * C2 * C3 * S17 + 2. * C2 * C4 * S18 + \ 2. * C3 * C4 * S19 # print(xs_eq) print( 'Analytic equation after substitution:', xs_eq.evalf( subs={ sig_sm_tttt: sig_SM, C0: 2., C1: 2., C2: 2., C3: 2., C4: 2., S0: S[0], S1: S[1],
thresholdval1=[0.30,(0.43+0.39)/2.] thresholdval2=[0.09,(0.28+0.24)/2.] thresholdval3=[0.01] number_of_points_in_direction = [100,100] #max_range = [ 4.0*np.pi, 4.0*np.pi ] #min_range = [ -4.0*np.pi, -4.0*np.pi ] scale=1.0 rt.gStyle.SetOptStat(0) myfunc=rt.TF1("myfunc","[0]*x*x+[1]*x+[2]",-4.0*np.pi, 4.0*np.pi) eft13 = EftPredictions(wilson_coefficients, MG_SM, sig_SM) eft14 = EftPredictions(wilson_coefficients, MG_SM_14TeV, sig_SM_14TeV) eft27 = EftPredictions(wilson_coefficients, MG_SM_27TeV, sig_SM_27TeV) # 1D first if do1d : for iwilson in range(0,5): if iwilson == 2: continue number_of_points_in_direction = 10000 max_range = 4.0*np.pi min_range = -4.0*np.pi step_size = (max_range - min_range)/number_of_points_in_direction histo1d13 = rt.TGraph(number_of_points_in_direction+1) histo1d13.SetName("13 TeV") histo1d14 = rt.TGraph(number_of_points_in_direction+1)