def myloglike(cube, ndim, nparams): obs,params=get_obs(cube,ndim) if obs: chi2=get_chi2(obs) #RESULT ORIENTED: for sampling set error to default if error in one of the predictors for name in ['FeynHiggs','Micromegas','BPhysics','SUSY-POPE']: if obs[(name,'error')]: chi2=default_chi obs[('tot_X2', 'all')]=chi2 else: chi2=default_chi obs=params # write everything to root files if args.root_out: rootstore.write_point_to_root(obs) if args.pickle_out: with open('{}/{}.pkl'.format(args.multinest_dir, unique_str()),'wb') as pickle_file: pickle.dump(obs,pickle_file) if 'X' in args.verbose: print("X^2={}".format(chi2)) return -chi2
#connection con=sqlite3.connect(args.input_file) #use row factory (see sqlite3 python documentation sqlite3.Row) con.row_factory=sqlite3.Row #cursor cur=con.cursor() #number of points n_points=args.n_points #open root file root.root_open(args.output_root) #get observables lookuk lookup = sql.get_observable_ids(con,cur) # lookup={col1: ( .. , .. ) , .... } #FIXME: this statement should make a sensible selection, for now just a number of points cur.execute('select * from points limit {}'.format(n_points)) for row in cur: point={ oid: row[col] for col, oid in lookup.items()} # this here is slow total, breakdown = Analyse.chi2(point,constraints) point[('tot_X2', 'all')]=total old_mc_rootstorage.write_point_to_root(point) root.root_close() # Finalise ... except sqlite3.Error as e: if con: con.rollback() print('ERROR: {}'.format(e.args[0])) sys.exit() finally: if con: con.close()
all_constraints=Constraints_list.constraints #mc8 data set data_set= [ 'Al(SLD)', 'Ab', 'Ac', 'Oh^2_mc8', 'Higgs125', 'BR(Bd->ll)', 'Gamma_Z', 'GZ_in', 'R(B->Xsll)', 'Al(P_tau)', 'MZ', 'R(D_ms)', 'MW', 'Afb_l', 'xenon100', 'DAlpha_had', 'R(Delta_mk)', 'sigma_had^0', 'Afb(c)', 'atlas5_m0_m12', 'Afb(b)', 'R(b->sg)', 'R(Dms)/R(Dmd)', 'R(B->taunu)', 'Rc', 'Rb', 'Rl', 'mc8_bsmm', 'sintheta_eff', 'Mt', 'R(K->lnu)', 'R(Kp->pinn)', 'gminus2mu', 'MATANB' ] 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) # optional printing if args.obs: bpp.pprint(combined_obs) if args.breakdown: bpp.pprint(breakdown) print('Total chi2:',total) # save to root if args.root_save: # NOTE: for old_mc_rootstorage, need X^2 combined_obs[('tot_X2','all')]=total root.root_open('temp/test.root') old_mc_rootstorage.write_point_to_root(combined_obs) root.root_close()