diff --git a/orcasong/io.py b/orcasong/io.py index 938139daa2070f3ef45a157cd7c215c6e100ee54..ee1e1c9f35f888b872358ca0fcbdd939037917b4 100644 --- a/orcasong/io.py +++ b/orcasong/io.py @@ -9,33 +9,9 @@ IO Code for OrcaSong. import os import errno import toml -from docopt import docopt import warnings -def parse_input(): - """ - Parses and returns all necessary input options for the make_nn_images function. - - Returns - ------- - fname : str - Full filepath to the input .h5 file. - detx_filepath : str - Full filepath to the .detx geometry file that belongs to the fname. - config_filepath : str - Full filepath to a config file. An example can be found in orcasong/default_config.toml - - """ - args = docopt(__doc__) - - fname = args['SIMFILE'] - detx_filepath = args['DETXFILE'] - config_filepath = args['CONFIGFILE'] - - return fname, detx_filepath, config_filepath - - def load_config(config_filepath): """ Loads the config from a .toml file. diff --git a/orcasong/make_nn_images.py b/orcasong/make_nn_images.py index 2c8cfeebf2ff18a968fc84de2f8d847a7bcf2453..cca183b6a4cafb0e3f889756013d5f8ef3cfeab4 100644 --- a/orcasong/make_nn_images.py +++ b/orcasong/make_nn_images.py @@ -41,16 +41,40 @@ import sys import km3pipe as kp import km3modules as km import matplotlib as mpl +from docopt import docopt mpl.use('Agg') from matplotlib.backends.backend_pdf import PdfPages from orcasong.file_to_hits import EventDataExtractor from orcasong.hits_to_histograms import HistogramMaker -from orcasong.io import parse_input, load_config, check_user_input, make_output_dirs +from orcasong.io import load_config, check_user_input, make_output_dirs from orcasong.geo_binning import calculate_bin_edges from orcasong.utils import get_file_particle_type, EventSkipper +def parse_input(): + """ + Parses and returns all necessary input options for the make_nn_images function. + + Returns + ------- + fname : str + Full filepath to the input .h5 file. + detx_filepath : str + Full filepath to the .detx geometry file that belongs to the fname. + config_filepath : str + Full filepath to a config file. An example can be found in orcasong/default_config.toml + + """ + args = docopt(__doc__) + + fname = args['SIMFILE'] + detx_filepath = args['DETXFILE'] + config_filepath = args['CONFIGFILE'] + + return fname, detx_filepath, config_filepath + + def make_nn_images(fname, detx_filepath, config): """ Main code with config parameters. Reads raw .hdf5 files and creates 2D/3D histogram projections that can be used diff --git a/orcasong/utils.py b/orcasong/utils.py index affba0ce499e9ced3c07a735988f8ab1caad4e09..871aeaa5efac3a31cc2054a0d8265143f128a332 100644 --- a/orcasong/utils.py +++ b/orcasong/utils.py @@ -87,7 +87,7 @@ def use_custom_skip_function(skip_function, event_track): continue_bool = False else: - prob_for_e_bin_arr_path = 'placeholder.npy' + prob_for_e_bin_arr_path = '/home/woody/capn/mppi033h/Code/OrcaSong/orcasong_contrib/utilities/arr_fract_for_e_bins.npy' # Fraction of tracks compared to showers (n_muon-cc / (n_e-cc + n_e-nc)) arr_fract_for_e_bins = np.load(prob_for_e_bin_arr_path) # 2d arr, one row e_bins, second row prob e_bins = arr_fract_for_e_bins[0, :] diff --git a/orcasong_contrib/utilities/get_func_for_flat_track_shower.py b/orcasong_contrib/utilities/get_func_for_flat_track_shower.py index a01f3cb86af4bc2093af737d4f147b4d194133ed..44f6240fb08c6d20c3e641737d7e8df3873a5d29 100644 --- a/orcasong_contrib/utilities/get_func_for_flat_track_shower.py +++ b/orcasong_contrib/utilities/get_func_for_flat_track_shower.py @@ -163,7 +163,12 @@ def plot_e_and_make_flat_func(energies_for_ic): pdfpages = PdfPages('./e_hist_plots.pdf') fig, ax = plt.subplots() - e_bins = 199 + e_bins_1_to_2 = np.linspace(1, 2, 3) + e_bins_2_to_25 = np.linspace(2.25, 25, 92) + e_bins_25_to_60 = np.linspace(25.5, 60, 70) + e_bins_60_to_100 = np.linspace(61, 100, 40) + + e_bins = np.concatenate([e_bins_1_to_2, e_bins_2_to_25, e_bins_25_to_60, e_bins_60_to_100], axis=0) # plot hist_muon_cc = plt.hist(energies_for_ic['muon_cc'], bins=e_bins) @@ -187,19 +192,34 @@ def plot_e_and_make_flat_func(energies_for_ic): # hist_shower[0][1] = hist_shower[0][1] / 2 # 2-3GeV track_div_shower = np.divide(hist_muon_cc[0], hist_shower[0]) - print(hist_muon_cc[0]) - print(hist_shower[0]) + # print(hist_muon_cc[0]) + # print(hist_shower[0]) bins=hist_muon_cc[1] # doesnt matter which bins to use - track_div_shower = np.append(track_div_shower, track_div_shower[-1]) - print(bins) - print(track_div_shower) - ax.step(bins, track_div_shower, linestyle='-', where='post') + track_div_shower_mpl = np.append(track_div_shower, track_div_shower[-1]) + + ax.step(bins, track_div_shower_mpl, linestyle='-', where='post') plt.title('Ratio tracks divided by showers') make_plot_options_and_save(ax, pdfpages, ylabel='Fraction') pdfpages.close() + # save e_bins and corresponding fractions + + # make e_bins with mean center + e_bins = [] + for i in range(bins.shape[0] - 1): + e_mean = (bins[i] + bins[i+1]) / 2 + e_bins.append(e_mean) + + e_bins = np.array(e_bins) + + + arr_fract_for_e_bins = np.vstack((e_bins, track_div_shower)) + print(arr_fract_for_e_bins) + + np.save('./arr_fract_for_e_bins.npy', arr_fract_for_e_bins) + def main(): dirs = { diff --git a/user/config/orca_115l_regression/conf_ORCA_115l_1-5GeV_xyz-c.toml b/user/config/orca_115l_regression/conf_ORCA_115l_1-5GeV_xyz-c.toml index 1d6272bf46970e07b8f6563c74a7db5e88279720..f8ad34c5f8a11f9e2b4b34a4e1ca5660c21f55f8 100644 --- a/user/config/orca_115l_regression/conf_ORCA_115l_1-5GeV_xyz-c.toml +++ b/user/config/orca_115l_regression/conf_ORCA_115l_1-5GeV_xyz-c.toml @@ -6,8 +6,6 @@ ###--- 1-5GeV ---### -### only take < 3GeV events, info throw away: elec-CC 0.25, muon-CC 0.25, elec-NC: 0.00 - ## XYZ-C output_dirpath = '/home/woody/capn/mppi033h' diff --git a/user/config/orca_115l_regression/conf_ORCA_115l_1-5GeV_xyz-t.toml b/user/config/orca_115l_regression/conf_ORCA_115l_1-5GeV_xyz-t.toml index ff17a477122c4152d36fdaf43e423808f25fc2e7..5b93630eda8c8995af310a09e30105a2ea74cea4 100644 --- a/user/config/orca_115l_regression/conf_ORCA_115l_1-5GeV_xyz-t.toml +++ b/user/config/orca_115l_regression/conf_ORCA_115l_1-5GeV_xyz-t.toml @@ -6,8 +6,6 @@ ###--- 1-5GeV ---### -### only take < 3GeV events, info throw away: elec-CC 0.25, muon-CC 0.25, elec-NC: 0.00 - ## XYZ-T output_dirpath = '/home/woody/capn/mppi033h' diff --git a/user/config/orca_115l_ts_classifier/conf_ORCA_115l_1-5GeV_xyz-t_tight-1.toml b/user/config/orca_115l_ts_classifier/conf_ORCA_115l_1-5GeV_xyz-t_tight-1.toml new file mode 100644 index 0000000000000000000000000000000000000000..edd80dbc6de71195eee4cbaa8ff1b8c11cba6ad1 --- /dev/null +++ b/user/config/orca_115l_ts_classifier/conf_ORCA_115l_1-5GeV_xyz-t_tight-1.toml @@ -0,0 +1,32 @@ +# A config file for OrcaSong. +# More info about the .toml format at https://github.com/toml-lang/toml + + +####----- Configuration for ORCA 115l -----#### + +###--- 1-5GeV ---### + +## XYZ-T + +output_dirpath = '/home/woody/capn/mppi033h' +chunksize = 32 +complib = 'zlib' +complevel = 1 +n_bins = [11,13,18,60] +det_geo = 'Orca_115l_23m_h_9m_v' +do2d = false +do2d_plots = false +do2d_plots_n = 10 +do3d = false +do4d = true +do4d_mode = 'time' +timecut_mode = 'trigger_cluster' +timecut_timespan = 'tight-1' +do_mc_hits = false +data_cut_triggered = false +data_cut_e_low = 'None' +data_cut_e_high = 'None' +data_cut_throw_away = 'None' +data_cut_custom_func = 'ts_e_flat' +prod_ident = 2 # for neutrinos: 1: 3-100 GeV prod, 2: 1-5 GeV prod ; mupage: 3 ; random_noise: 4 +flush_freq = 1000 \ No newline at end of file diff --git a/user/config/orca_115l_ts_classifier/conf_ORCA_115l_1-5GeV_xyz-t_tight-2.toml b/user/config/orca_115l_ts_classifier/conf_ORCA_115l_1-5GeV_xyz-t_tight-2.toml new file mode 100644 index 0000000000000000000000000000000000000000..e013c553040977e48cce7b125a160c804d7d10c4 --- /dev/null +++ b/user/config/orca_115l_ts_classifier/conf_ORCA_115l_1-5GeV_xyz-t_tight-2.toml @@ -0,0 +1,32 @@ +# A config file for OrcaSong. +# More info about the .toml format at https://github.com/toml-lang/toml + + +####----- Configuration for ORCA 115l -----#### + +###--- 1-5GeV ---### + +## XYZ-T + +output_dirpath = '/home/woody/capn/mppi033h' +chunksize = 32 +complib = 'zlib' +complevel = 1 +n_bins = [11,13,18,60] +det_geo = 'Orca_115l_23m_h_9m_v' +do2d = false +do2d_plots = false +do2d_plots_n = 10 +do3d = false +do4d = true +do4d_mode = 'time' +timecut_mode = 'trigger_cluster' +timecut_timespan = 'tight-2' +do_mc_hits = false +data_cut_triggered = false +data_cut_e_low = 'None' +data_cut_e_high = 'None' +data_cut_throw_away = 'None' +data_cut_custom_func = 'ts_e_flat' +prod_ident = 2 # for neutrinos: 1: 3-100 GeV prod, 2: 1-5 GeV prod ; mupage: 3 ; random_noise: 4 +flush_freq = 1000 \ No newline at end of file diff --git a/user/config/orca_115l_ts_classifier/conf_ORCA_115l_3-100GeV_xyz-t_tight-1.toml b/user/config/orca_115l_ts_classifier/conf_ORCA_115l_3-100GeV_xyz-t_tight-1.toml new file mode 100644 index 0000000000000000000000000000000000000000..bd5a153fa7a1321db336e7d06a8187699e8ec300 --- /dev/null +++ b/user/config/orca_115l_ts_classifier/conf_ORCA_115l_3-100GeV_xyz-t_tight-1.toml @@ -0,0 +1,32 @@ +# A config file for OrcaSong. +# More info about the .toml format at https://github.com/toml-lang/toml + + +####----- Configuration for ORCA 115l -----#### + +###--- 3-100GeV ---### + +## XYZ-T + +output_dirpath = '/home/woody/capn/mppi033h' +chunksize = 32 +complib = 'zlib' +complevel = 1 +n_bins = [11,13,18,60] +det_geo = 'Orca_115l_23m_h_9m_v' +do2d = false +do2d_plots = false +do2d_plots_n = 10 +do3d = false +do4d = true +do4d_mode = 'time' +timecut_mode = 'trigger_cluster' +timecut_timespan = 'tight-1' +do_mc_hits = false +data_cut_triggered = false +data_cut_e_low = 'None' +data_cut_e_high = 'None' +data_cut_throw_away = 'None' +data_cut_custom_func = 'ts_e_flat' +prod_ident = 1 # for neutrinos: 1: 3-100 GeV prod, 2: 1-5 GeV prod ; mupage: 3 ; random_noise: 4 +flush_freq = 1000 \ No newline at end of file diff --git a/user/config/orca_115l_ts_classifier/conf_ORCA_115l_3-100GeV_xyz-t_tight-2.toml b/user/config/orca_115l_ts_classifier/conf_ORCA_115l_3-100GeV_xyz-t_tight-2.toml new file mode 100644 index 0000000000000000000000000000000000000000..bf31746a9ccd4814b1f33fe4614f68bcdef5032d --- /dev/null +++ b/user/config/orca_115l_ts_classifier/conf_ORCA_115l_3-100GeV_xyz-t_tight-2.toml @@ -0,0 +1,32 @@ +# A config file for OrcaSong. +# More info about the .toml format at https://github.com/toml-lang/toml + + +####----- Configuration for ORCA 115l -----#### + +###--- 3-100GeV ---### + +## XYZ-T + +output_dirpath = '/home/woody/capn/mppi033h' +chunksize = 32 +complib = 'zlib' +complevel = 1 +n_bins = [11,13,18,60] +det_geo = 'Orca_115l_23m_h_9m_v' +do2d = false +do2d_plots = false +do2d_plots_n = 10 +do3d = false +do4d = true +do4d_mode = 'time' +timecut_mode = 'trigger_cluster' +timecut_timespan = 'tight-2' +do_mc_hits = false +data_cut_triggered = false +data_cut_e_low = 'None' +data_cut_e_high = 'None' +data_cut_throw_away = 'None' +data_cut_custom_func = 'ts_e_flat' +prod_ident = 1 # for neutrinos: 1: 3-100 GeV prod, 2: 1-5 GeV prod ; mupage: 3 ; random_noise: 4 +flush_freq = 1000 \ No newline at end of file