def get_obs(cube,ndim): model='cMSSM' m0=cube[0] m12=cube[1] A0=cube[2] tanb=cube[3] mt=cube[4] mz=cube[5] Delta_alpha_had=cube[6] model = 'cMSSM' all_params={ 'SoftSUSY':{ ('MINPAR', 'M0'): m0, ('MINPAR', 'M12'): m12, ('MINPAR', 'TB'): tanb, ('MINPAR', 'A'): A0, ('SMINPUTS', 'Mt') : mt, }, 'mc_slha_update':{ ('SMINPUTS','MZ') : mz, }, 'SUSY-POPE':{ 'non_slha_inputs':{ 'DeltaAlfa5had' : Delta_alpha_had, } } } if 'parameters' in args.verbose : print(all_params) if args.tmp_dir: all_params.update({'tmp_dir':args.tmp_dir}) all_params['lookup']=lookup all_params['verbose']=args.verbose try: slha_obj, combined_obs, stdouts = point.run_point(model=model, **all_params) except TypeError: return None #WARNING: this if for debugging: # give parameters to the place where a problem occurs and trow it in stderr del all_params['lookup'] del all_params['verbose'] if ('errors' in args.verbose) : any_error=False if not combined_obs: print("ERROR: in Spectrum Calculator",file=sys.stderr) any_error=True else: for name in ['FeynHiggs','Micromegas','BPhysics','SUSY-POPE']: if combined_obs[(name,'error')]: print('ERROR: in {}'.format(name),file=sys.stderr) any_error=True if any_error: print('\nParameters are: {}\n'.format(all_params),file=sys.stderr) return combined_obs, all_params
def get_obs(cube,ndim): #make a python list out of the cube parameters=[cube[i] for i in range(ndim)] # start from clean directory as input for run_point all_params={} all_params.update(predictor_modules) # add predictors # Get formatted input. See what is looks like with option "-v inputs" if args.model == 'cMSSM': all_params.update( inputs.get_mc_cmssm_inputs(*parameters)) if args.model == 'neg-mu-cMSSM': all_params.update( inputs.get_mc_neg_mu_cmssm_inputs(*parameters)) if args.model == 'NUHM1': all_params.update( inputs.get_mc_nuhm1_inputs(*parameters)) if args.model == 'neg-mu-NUHM1': all_params.update( inputs.get_mc_neg_mu_nuhm1_inputs(*parameters)) if args.model == 'pMSSM8': all_params.update( inputs.get_mc_pmssm8_inputs(*parameters)) if args.model == 'pMSSM10': all_params.update( inputs.get_mc_pmssm10_inputs(*parameters)) if 'parameters' in args.verbose: print(*parameters) if 'inputs' in args.verbose : print(all_params) if args.tmp_dir: all_params.update({'tmp_dir':args.tmp_dir}) all_params['lookup']=lookup all_params['verbose']=args.verbose try: slha_obj, combined_obs, stdouts = point.run_point( **all_params) except TypeError: return None #WARNING: this if for debugging: # give parameters to the place where a problem occurs and trow it in stderr del all_params['lookup'] del all_params['verbose'] if ('errors' in args.verbose) : if not combined_obs: print("ERROR: in Spectrum Calculator",file=sys.stderr) else: for name in ['FeynHiggs','Micromegas','BPhysics','SUSY-POPE']: if combined_obs[(name,'error')]: print('ERROR: in {}'.format(name),file=sys.stderr) return combined_obs, all_params
def get_obs(cube, ndim): # FIXME: m0 = cube[0] m12 = cube[1] A0 = cube[2] tanb = cube[3] mt = cube[4] mz = cube[5] Delta_alpha_had = cube[6] if args.model == "NUHM1": mh2 = cube[7] # Get formatted input, Feel free to have a look !!! if args.model == "cMSSM": all_params = inputs.get_mc_cmssm_inputs(m0, m12, tanb, A0, mt, mz, Delta_alpha_had) if args.model == "NUHM1": all_params = inputs.get_mc_nuhm1_inputs(m0, m12, tanb, A0, mh2, mt, mz, Delta_alpha_had) if "parameters" in args.verbose: print(all_params) if args.tmp_dir: all_params.update({"tmp_dir": args.tmp_dir}) all_params["lookup"] = lookup all_params["verbose"] = args.verbose try: slha_obj, combined_obs, stdouts = point.run_point(**all_params) except TypeError: return None # WARNING: this if for debugging: # give parameters to the place where a problem occurs and trow it in stderr del all_params["lookup"] del all_params["verbose"] if "errors" in args.verbose: any_error = False if not combined_obs: print("ERROR: in Spectrum Calculator", file=sys.stderr) any_error = True else: for name in ["FeynHiggs", "Micromegas", "BPhysics", "SUSY-POPE"]: if combined_obs[(name, "error")]: print("ERROR: in {}".format(name), file=sys.stderr) any_error = True if any_error: print("\nParameters are: {}\n".format(all_params), file=sys.stderr) return combined_obs, all_params
def get_obs(cube,ndim): model='cMSSM' m0=cube[0] m12=cube[1] input_vars = { 'm0': m0, 'm12': m12, 'A0': -1323.97 , 'tanb': 16.26, 'sgnMu': 1 #MC8 bf } other_vars = { 'mt': 173.2, 'mgut': {'cMSSM': 2e16, 'pMSSM': 1.0e3}[model] } m_vars = dict(list(input_vars.items()) + list(other_vars.items())) input_pars={'SoftSUSY':m_vars} slha_file, observations , stdouts = point.run_point(model=model, **input_pars) combined_obs = dict(list(slha_file.items()) + list(observations.items())) return combined_obs
'mtauL': 2.50e+03, 'meR': 2.50e+03, 'mmuR': 2.50e+03, 'mtauR': 2.50e+03, 'mqL1': 3.60e+02, 'mqL2': 3.60e+02, 'mqL3': 2.50e+03, 'muR': 3.60e+02, 'mcR': 3.60e+02, 'mtR': 2.50e+03, 'mdR': 3.60e+02, 'msR': 3.60e+02, 'mbR': 2.50e+03 }, }[model] other_vars = { 'mt': 173.2, 'mgut': {'cMSSM': 2e16, 'pMSSM': 1.0e3}[model] } m_vars = dict(list(input_vars.items()) + list(other_vars.items())) all_params={'SoftSUSY':m_vars} slha_file, observations,stdouts = point.run_point(model=model, **all_params) combined_obs = dict(list(slha_file.items()) + list(observations.items())) # I think this is the way to do it: # initialise all constraints all_constraints=Constraints_list.constraints # make a dictionary that only contains the constraints you want (e.g. just define on the spot, or read in from a file) data_set=['xenon100'] constraints={name: all_constraints[name] for name in data_set} #pass this constraints list to the chi2 function total, breakdown = Analyse.chi2(combined_obs,constraints) bpp = pprint.PrettyPrinter(indent=4, depth=3) # bpp.pprint(combined_obs) bpp.pprint(breakdown)
def main(args): #Start with clean set of parameters all_params={} #get predictor modules predictors=User.predictors.get(args.predictors) predictor_modules=import_predictor_modules(predictors) all_params.update(predictor_modules) #FIXME: need to come up with generalised parsing of options to the predictors #get versions versions=User.versions.get(args.versions) for predictor , versions in versions.items(): if predictor==predictors['spectrum_generator']: try: all_params[predictor]['version']=versions except KeyError: all_params[predictor]={'version':versions} else: try: all_params[predictor]['versions']=versions except KeyError: all_params[predictor]={'versions':versions} #this is afterburner style if args.mc_cmssm : all_params.update(inputs.get_mc_cmssm_inputs(*(args.mc_cmssm))) elif args.mc_cmssm_default: all_params.update(inputs.get_mc_cmssm_inputs(271.378279475, 920.368119935, 14.4499538001, -1193.57068242, 173.474173, 91.1877452551, 0.0274821578423)) elif args.mc_neg_mu_cmssm : all_params.update(inputs.get_mc_neg_mu_cmssm_inputs(*(args.mc_neg_mu_cmssm))) elif args.mc_nuhm1 : all_params.update(inputs.get_mc_nuhm1_inputs(*(args.mc_nuhm1))) elif args.mc_neg_mu_nuhm1 : all_params.update(inputs.get_mc_neg_mu_nuhm1_inputs(*(args.mc_neg_mu_nuhm1))) elif args.mc_nuhm1_default : all_params.update(inputs.get_mc_nuhm1_inputs(237.467776964, 968.808711245, 15.649644, -1858.78698798, -6499529.79661, 173.385870186, 91.1875000682, 0.0274949856504)) elif args.mc_pmssm8 : all_params.update(inputs.get_mc_pmssm8_inputs(*(args.mc_pmssm8))) elif args.mc_pmssm10 : all_params.update(inputs.get_mc_pmssm10_inputs(*(args.mc_pmssm10))) elif args.mc_pmssm10_default : all_params.update(inputs.get_mc_pmssm10_inputs(1663.99,1671.75,414.131,294.935,311.199,1712.73, 1841.21,718.489,43.4923,775.09,173.233,91.1874,0.0275018)) elif args.run_softsusy_input_slha: all_params.update({'SoftSUSY':{'file':args.run_softsusy_input_slha}}) elif args.run_spectrum: all_params.update({'spectrumfile':args.run_spectrum}) #check for command line input parameters if args.input_pars is not None: command_line_dict=eval(args.input_pars) for key, value in command_line_dict.items(): # if input_pars.get(key) is None: # input_pars.update if isinstance(value,dict) and (all_params.get(key) is not None): all_params[key].update(value) else: all_params[key]=value #check for tmp_dir if args.tmp_dir: all_params.update({'tmp_dir':args.tmp_dir}) #print inputs like if 'inputs' in args.verbose: print(all_params) #check verbosity if args.verbose: all_params['verbose']=args.verbose try: slha_obj, point ,stdouts = POINT.run_point(**all_params) except TypeError: print("ERROR: Point failed to run") exit() if __name__=="__main__" and slha_obj is None: print('ERROR: Point fails\nExiting') exit() if not args.suppress_chi2_calc: all_constraints=Constraints_list.constraints #mc8 data set try: data_set=data_sets[args.data_set] except KeyError: print("WARNING: \"{}\" invalid data set. No X^2 is calculated".format(args.data_set)) data_set=[] if not args.suppress_chi2_calc: constraints={name: all_constraints[name] for name in data_set} #FIXME: this should become a separate file #pass this constraints list to the chi2 function if not args.suppress_chi2_calc: total, breakdown = Analyse.chi2(point,constraints) # optional printing if args.obs: pp.pprint(point) if args.breakdown: Analyse.print_chi2_breakdown(point, constraints,data_set) # save to root if args.root_save: # NOTE: for old_mc_rootstorage, need X^2 point[('tot_X2','all')]=total root.root_open(args.root_save) VARS=old_mc_rootstorage.get_VARS(point,point[('m','in_o')]) root.root_write(VARS) root.root_close() if args.json_breakdown: l=[] for d in data_set: l.append([d,breakdown[d]]) with open(args.json_breakdown,'w') as f: json.dump(l,f) # print only observable keys if args.observable_keys: pp.pprint([key for key in point.keys()]) # store observables to piclked file if args.store_pickle: with open(args.store_pickle,'wb') as pickle_file: pickle.dump(point,pickle_file) #create json file with [('oid1','oid2',array_id), ... ] for storage array ids if args.create_storage_dict: point=OrderedDict([(('tot_X2', 'all'),0)]+list(point.items())) l=[] i=0 #make list for key,val in point.items(): oid1,oid2=key l.append([oid1,oid2,i]) i+=1 #store as json file with open(args.create_storage_dict,'w') as f: json.dump(l,f,indent=3) if args.numpy_out : if args.storage_dict: with open(args.storage_dict, 'r') as f: l=json.load(f) d={(oid1,oid2):array_id for oid1,oid2, array_id in l} #start with list of None's vars=[None]*len(d) #Fill with values for oids, val in point.items(): vars[d[oids]]=val dt=numpy.dtype(len(vars)*[('','f')]) vars=numpy.array(tuple(vars),dtype=dt) try: a=numpy.load(args.numpy_out) print(args.numpy_out,'exists. Appending') a=numpy.append(a,vars) except FileNotFoundError: print('creating: ', args.numpy_out) a=vars numpy.save(args.numpy_out,a) #FIXME: we may want a better way of doing this return slha_obj, point ,stdouts
'MW-mc-old','Bsmumu','R(Delta_md)','D_0(K*g)','mc-old-bsmm'] constraints={name: all_constraints[name] for name in data_set} bpp = pprint.PrettyPrinter(indent=4, depth=3) for count, spec in enumerate(args.input_spectrum): if args.nmax and count>=args.nmax: break all_params['spectrumfile']=spec #the input for DeltaAlfa5had has to be hard-coded like in SUSY-POPE all_params['SUSY-POPE']={'non_slha_inputs':{'DeltaAlfa5had': 0.02758}} #check verbosity if args.verbose: all_params['verbose']=args.verbose try: slha_obj, combined_obs, stdouts = point.run_point(model='dummy', **all_params) except TypeError: print("ERROR: Point failed to run") continue #pass this constraints list to the chi2 function total, breakdown = Analyse.chi2(combined_obs,constraints) # optional printing if args.obs: bpp.pprint(combined_obs) if args.breakdown: bpp.pprint(breakdown) print('Total chi2:',total)
def pmssm10_chi2(msq12,msq3,msl, M1,M2,M3, A, MA,tanb,mu,mt,mz,Delta_alpha_had): input_pars=inputs.get_mc_pmssm10_inputs(msq12,msq3,msl, M1,M2,M3, A, MA,tanb,mu,mt,mz,Delta_alpha_had) slha_obj, observables ,stdouts= point.run_point(**input_pars) #pass this constraints list to the chi2 function total, breakdown = Analyse.chi2(observables,constraints) return total
def cmssm_chi2(m0,m12,c,d,e,f,g): input_pars=inputs.get_mc_cmssm_inputs(m0,m12,c,d,e,f,g) slha_obj, observables ,stdouts= point.run_point(**input_pars) #pass this constraints list to the chi2 function total, breakdown = Analyse.chi2(observables,constraints) return total