diff --git a/eos-toys/make_toys.py b/eos-toys/make_toys.py new file mode 100644 index 0000000..1df02ed --- /dev/null +++ b/eos-toys/make_toys.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# @Author: Elena Graverini +# @Date: 2017-03-16 15:22:00 +# @Last Modified by: Elena Graverini +# @Last Modified time: 2017-03-17 16:42:38 +import os +# import subprocess + +chunk_size = 100000 +chunks = 100 +leptons = ['mu', 'tau'] +commands = [] +seed = 12345 +form_factors = "BBGIOvD2017" +signal_pdf = "Lambda_b->Lambda_c(2625)lnu::dGamma" +model = "SM" +prerun_min = 500000 +prerun_update = 2000 +kin_limits = { + 'mu': (0.011163612964000001, 8.947815864099999), + 'tau': (3.1570893124, 8.947815864099999), +} + +commands = [] +for l in leptons: + commands.append(['eos-sample-events-mcmc', + # ' --kinematics \"s\" %s %s' % kin_limits[l], + ' --global-option \"form-factors\" \"%s\"' % form_factors, + ' --signal-pdf \"%s,l=%s,model=%s\"' % (signal_pdf, l, model), + ' --seed %s' % seed, + ' --output mcmc_samples-%s.hdf5' % l, + ' --prerun-min %s' % prerun_min, + ' --prerun-update %s' % prerun_update, + ' --chunk-size %s' % chunk_size, + ' --chunks %s' % chunks, + ]) + +for c in commands: + print(' '.join(c)) + # subprocess.call(c) + os.system(' '.join(c)) diff --git a/eos-toys/plot-sample.py b/eos-toys/plot-sample.py new file mode 100644 index 0000000..bf979bc --- /dev/null +++ b/eos-toys/plot-sample.py @@ -0,0 +1,82 @@ +# -*- coding: utf-8 -*- +# @Author: Elena Graverini +# @Date: 2017-03-16 11:20:45 +# @Last Modified by: Elena Graverini +# @Last Modified time: 2017-03-21 11:38:40 +# import matplotlib +from __future__ import division +import sys, os, gc +import matplotlib.pyplot as plt +from eosdata import MCMCDataFile # , Plotter1D +import pickle + + +def main(): + input_file = "constantFF/samples-mu-2.hdf5" + save_name = 'test-output.pdf' + if len(sys.argv) > 1: + input_file = str(sys.argv[1]) + else: + print('Warning: no input / output file names specified.\nUsing %s and %s.' % (input_file, save_name)) + if len(sys.argv) > 2: + save_name = str(sys.argv[2]) + pklfilename = save_name.replace('.pdf', '.pkl') + suffix = 'prescaled_10' + if not os.path.isfile(pklfilename): + datafile = MCMCDataFile(input_file) + # print(datafile.parameters[0]) + gc.collect() + data = datafile.data()[:, 0] + d = {} + reduced_data = data[::10] + d['reduced_data'] = reduced_data + n, bins, patches = plt.hist(reduced_data, bins=100, normed=True, alpha=0.3) + bin_centers = (bins[:-1] + bins[1:]) / 2 + d['bin_contents'] = n + d['bin_centers'] = bin_centers + pickle.dump(d, open(pklfilename, 'wb')) + else: + d = pickle.load(open(pklfilename, 'rb')) + plt.scatter(d['bin_centers'], d['bin_contents']) + suffix += '_scatter' + plt.savefig(save_name.replace('.pdf', '_%s.pdf' % suffix)) + # # plt.figure() + # p1d = Plotter1D(datafile, save_name) + # p1d.histogram(0, xmin=None, xmax=None, kde=None) + + +def superimpose(files, labels, outname): + colors = ['#0078FF', '#FF6600', '#0AAFB6', '#FF3333', '#0000FF', '#00CC00', '#BF8040', '#FF33CC', '#FF7733'] + ds = [] + for f in files: + ds.append(pickle.load(open(f, 'rb'))) + for i in range(len(files)): + plt.plot(ds[i]['bin_centers'], ds[i]['bin_contents'], label=labels[i], color=colors[i], linewidth=2.0) + plt.legend(loc='best') + plt.savefig(outname) + plt.close("all") + + +def makeFileFromMarzia(x, y, fname): + ds = { + 'bin_centers': x, + 'bin_contents': y, + } + if not os.path.isfile(fname): + os.system('mkdir -p %s' % os.path.dirname(fname)) + pickle.dump(ds, open(fname, 'wb')) + + +if __name__ == '__main__': + # main() + marzia_f = 'Marzia/Marzia_constantFF.pkl' + mx = [0.2, 0.4, 0.80, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5] + my = [0.0102553, 0.0110076, 0.0123026, 0.0128953, 0.0142323, 0.015366, 0.0162975, 0.0170258, 0.0175493, 0.0178644, 0.0179659, 0.0178455, 0.017491, 0.016884, 0.0159959, 0.0147803, 0.0131556, 0.0109562, 0.00773188] + makeFileFromMarzia(mx, my, marzia_f) + files_mu = ['constantFF/mcmc_gamma_muons.pkl', '1pole/mcmc_gamma_muons_1pole.pkl', '1pole_x_sqrtlambda/mcmc_gamma_muonss_1pole_x_sqrtlambda.pkl', marzia_f] + out_mu = 'comparison_mu.pdf' + files_tau = ['constantFF/mcmc_gamma_taus.pkl', '1pole/mcmc_gamma_taus_1pole.pkl', '1pole_x_sqrtlambda/mcmc_gamma_taus_1pole_x_sqrtlambda.pkl'] + out_tau = 'comparison_tau.pdf' + labels = ['Constant FF', 'One pole', r'One pole $\times\; \sqrt{\lambda}$', 'MB: constant FF'] + superimpose(files_mu, labels, out_mu) + superimpose(files_tau, labels, out_tau) diff --git a/eos-toys/run.sh b/eos-toys/run.sh new file mode 100644 index 0000000..cf0b843 --- /dev/null +++ b/eos-toys/run.sh @@ -0,0 +1,11 @@ +# @Author: Elena Graverini +# @Date: 2017-03-21 14:08:36 +# @Last Modified by: Elena Graverini +# @Last Modified time: 2017-03-21 14:10:49 +#!/bin/bash +python make_toys.py +# TODO: +# ...Move outputs to appropriate folder according to +# their parametrization and then go on... +python plot-sample.py +bash send_to_zurich.sh diff --git a/eos-toys/send_to_zurich.sh b/eos-toys/send_to_zurich.sh new file mode 100755 index 0000000..9aebbc7 --- /dev/null +++ b/eos-toys/send_to_zurich.sh @@ -0,0 +1,11 @@ +# @Author: Elena Graverini +# @Date: 2017-03-21 13:55:51 +# @Last Modified by: Elena Graverini +# @Last Modified time: 2017-03-21 16:22:06 +#!/bin/bash +mkdir -p /home/elena/Desktop/PhD_Work/zurich-cluster +sshfs egraveri@grid-ui.physik.uzh.ch: /home/elena/Desktop/PhD_Work/zurich-cluster +cd .. +rsync -rd eos-toys /home/elena/Desktop/PhD_Work/zurich-cluster/Public/eos-toys +cd eos-toys +fusermount -u /home/elena/Desktop/PhD_Work/zurich-cluster || sudo umount -l /home/elena/Documents/University/PhD/UZH/zurich-cluster diff --git a/make_toys.py b/make_toys.py deleted file mode 100644 index 1df02ed..0000000 --- a/make_toys.py +++ /dev/null @@ -1,41 +0,0 @@ -# -*- coding: utf-8 -*- -# @Author: Elena Graverini -# @Date: 2017-03-16 15:22:00 -# @Last Modified by: Elena Graverini -# @Last Modified time: 2017-03-17 16:42:38 -import os -# import subprocess - -chunk_size = 100000 -chunks = 100 -leptons = ['mu', 'tau'] -commands = [] -seed = 12345 -form_factors = "BBGIOvD2017" -signal_pdf = "Lambda_b->Lambda_c(2625)lnu::dGamma" -model = "SM" -prerun_min = 500000 -prerun_update = 2000 -kin_limits = { - 'mu': (0.011163612964000001, 8.947815864099999), - 'tau': (3.1570893124, 8.947815864099999), -} - -commands = [] -for l in leptons: - commands.append(['eos-sample-events-mcmc', - # ' --kinematics \"s\" %s %s' % kin_limits[l], - ' --global-option \"form-factors\" \"%s\"' % form_factors, - ' --signal-pdf \"%s,l=%s,model=%s\"' % (signal_pdf, l, model), - ' --seed %s' % seed, - ' --output mcmc_samples-%s.hdf5' % l, - ' --prerun-min %s' % prerun_min, - ' --prerun-update %s' % prerun_update, - ' --chunk-size %s' % chunk_size, - ' --chunks %s' % chunks, - ]) - -for c in commands: - print(' '.join(c)) - # subprocess.call(c) - os.system(' '.join(c)) diff --git a/plot-sample.py b/plot-sample.py deleted file mode 100644 index bf979bc..0000000 --- a/plot-sample.py +++ /dev/null @@ -1,82 +0,0 @@ -# -*- coding: utf-8 -*- -# @Author: Elena Graverini -# @Date: 2017-03-16 11:20:45 -# @Last Modified by: Elena Graverini -# @Last Modified time: 2017-03-21 11:38:40 -# import matplotlib -from __future__ import division -import sys, os, gc -import matplotlib.pyplot as plt -from eosdata import MCMCDataFile # , Plotter1D -import pickle - - -def main(): - input_file = "constantFF/samples-mu-2.hdf5" - save_name = 'test-output.pdf' - if len(sys.argv) > 1: - input_file = str(sys.argv[1]) - else: - print('Warning: no input / output file names specified.\nUsing %s and %s.' % (input_file, save_name)) - if len(sys.argv) > 2: - save_name = str(sys.argv[2]) - pklfilename = save_name.replace('.pdf', '.pkl') - suffix = 'prescaled_10' - if not os.path.isfile(pklfilename): - datafile = MCMCDataFile(input_file) - # print(datafile.parameters[0]) - gc.collect() - data = datafile.data()[:, 0] - d = {} - reduced_data = data[::10] - d['reduced_data'] = reduced_data - n, bins, patches = plt.hist(reduced_data, bins=100, normed=True, alpha=0.3) - bin_centers = (bins[:-1] + bins[1:]) / 2 - d['bin_contents'] = n - d['bin_centers'] = bin_centers - pickle.dump(d, open(pklfilename, 'wb')) - else: - d = pickle.load(open(pklfilename, 'rb')) - plt.scatter(d['bin_centers'], d['bin_contents']) - suffix += '_scatter' - plt.savefig(save_name.replace('.pdf', '_%s.pdf' % suffix)) - # # plt.figure() - # p1d = Plotter1D(datafile, save_name) - # p1d.histogram(0, xmin=None, xmax=None, kde=None) - - -def superimpose(files, labels, outname): - colors = ['#0078FF', '#FF6600', '#0AAFB6', '#FF3333', '#0000FF', '#00CC00', '#BF8040', '#FF33CC', '#FF7733'] - ds = [] - for f in files: - ds.append(pickle.load(open(f, 'rb'))) - for i in range(len(files)): - plt.plot(ds[i]['bin_centers'], ds[i]['bin_contents'], label=labels[i], color=colors[i], linewidth=2.0) - plt.legend(loc='best') - plt.savefig(outname) - plt.close("all") - - -def makeFileFromMarzia(x, y, fname): - ds = { - 'bin_centers': x, - 'bin_contents': y, - } - if not os.path.isfile(fname): - os.system('mkdir -p %s' % os.path.dirname(fname)) - pickle.dump(ds, open(fname, 'wb')) - - -if __name__ == '__main__': - # main() - marzia_f = 'Marzia/Marzia_constantFF.pkl' - mx = [0.2, 0.4, 0.80, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5] - my = [0.0102553, 0.0110076, 0.0123026, 0.0128953, 0.0142323, 0.015366, 0.0162975, 0.0170258, 0.0175493, 0.0178644, 0.0179659, 0.0178455, 0.017491, 0.016884, 0.0159959, 0.0147803, 0.0131556, 0.0109562, 0.00773188] - makeFileFromMarzia(mx, my, marzia_f) - files_mu = ['constantFF/mcmc_gamma_muons.pkl', '1pole/mcmc_gamma_muons_1pole.pkl', '1pole_x_sqrtlambda/mcmc_gamma_muonss_1pole_x_sqrtlambda.pkl', marzia_f] - out_mu = 'comparison_mu.pdf' - files_tau = ['constantFF/mcmc_gamma_taus.pkl', '1pole/mcmc_gamma_taus_1pole.pkl', '1pole_x_sqrtlambda/mcmc_gamma_taus_1pole_x_sqrtlambda.pkl'] - out_tau = 'comparison_tau.pdf' - labels = ['Constant FF', 'One pole', r'One pole $\times\; \sqrt{\lambda}$', 'MB: constant FF'] - superimpose(files_mu, labels, out_mu) - superimpose(files_tau, labels, out_tau) diff --git a/run.sh b/run.sh deleted file mode 100644 index cf0b843..0000000 --- a/run.sh +++ /dev/null @@ -1,11 +0,0 @@ -# @Author: Elena Graverini -# @Date: 2017-03-21 14:08:36 -# @Last Modified by: Elena Graverini -# @Last Modified time: 2017-03-21 14:10:49 -#!/bin/bash -python make_toys.py -# TODO: -# ...Move outputs to appropriate folder according to -# their parametrization and then go on... -python plot-sample.py -bash send_to_zurich.sh diff --git a/send_to_zurich.sh b/send_to_zurich.sh deleted file mode 100755 index ef4522a..0000000 --- a/send_to_zurich.sh +++ /dev/null @@ -1,11 +0,0 @@ -# @Author: Elena Graverini -# @Date: 2017-03-21 13:55:51 -# @Last Modified by: Elena Graverini -# @Last Modified time: 2017-03-21 14:01:52 -#!/bin/bash -mkdir -p /home/elena/Desktop/PhD_Work/zurich-cluster -sshfs egraveri@grid-ui.physik.uzh.ch: /home/elena/Desktop/PhD_Work/zurich-cluster -cd .. -rsync -rd LbLcsFFAnalysis /home/elena/Desktop/PhD_Work/zurich-cluster/Public/LbLcsFFAnalysis -cd LbLcsFFAnalysis -fusermount -u /home/elena/Desktop/PhD_Work/zurich-cluster || sudo umount -l /home/elena/Documents/University/PhD/UZH/zurich-cluster