# SAVING print(save_folder_name) if save == True: if os.path.isdir(save_folder_name) != True: os.mkdir(save_folder_name) from PlottingFunctions import plot_2D_prediction from PlottingFunctions import plot_distributions_CCNC from PlottingFunctions import plot_resolution_CCNC from PlottingFunctions import plot_single_resolution from PlottingFunctions import plot_compare_resolution from PlottingFunctions import plot_systematic_slices from PlottingFunctions import plot_energy_slices plot_2D_prediction(Y_test_energy['file_0'], Y_test_predicted_energy['file_0'],\ save=save,savefolder=save_folder_name) plot_distributions_CCNC(Y_test['file_0'],Y_test_energy['file_0'], Y_test_predicted_energy['file_0'],\ save=save,savefolder=save_folder_name) plot_resolution_CCNC(Y_test['file_0'],Y_test_energy['file_0'], Y_test_predicted_energy['file_0'],\ save=save,savefolder=save_folder_name) plot_single_resolution(Y_test_energy['file_0'], Y_test_predicted_energy['file_0'],\ save=save,savefolder=save_folder_name) plot_single_resolution(Y_test_energy['file_0'], Y_test_predicted_energy['file_0'],\ use_old_reco=True, old_reco=Y_test_energy_reco['file_0'],\ save=save,savefolder=save_folder_name) plot_compare_resolution(Y_test_energy, Y_test_predicted_energy,namelist=namelist,num_namelist=num_namelist,\ save=save,savefolder=save_folder_name) plot_systematic_slices(Y_test_energy, Y_test_predicted_energy,num_namelist,\ save=save,savefolder=save_folder_name) plot_energy_slices(Y_test_energy['file_0'], Y_test_predicted_energy['file_0'],\ use_old_reco=True, old_reco=Y_test_energy_reco['file_0'],\
true_index = first_var_index name_index = first_var_index plot_name = plots_names[name_index] plot_units = plots_units[name_index] maxabs_factor = maxabs_factors[name_index] maxval = maxvals[name_index] minval = minvals[name_index] use_frac = use_fractions[name_index] bins = bins_array[name_index] print( "Plotting %s at position %i in true test output and %i in NN test output" % (plot_name, true_index, NN_index)) plot_2D_prediction(Y_test_use[:,true_index]*maxabs_factor,\ Y_test_predicted[:,NN_index]*maxabs_factor,\ save,save_folder_name,bins=bins,\ minval=minval,maxval=maxval,cut_truth=True,axis_square=True,\ variable=plot_name,units=plot_units) plot_2D_prediction(Y_test_use[:,true_index]*maxabs_factor, Y_test_predicted[:,NN_index]*maxabs_factor,\ save,save_folder_name,bins=bins,\ minval=None,maxval=None,\ variable=plot_name,units=plot_units) plot_single_resolution(Y_test_use[:,true_index]*maxabs_factor,\ Y_test_predicted[:,NN_index]*maxabs_factor,\ minaxis=-maxval,maxaxis=maxval,bins=bins, save=save,savefolder=save_folder_name,\ variable=plot_name,units=plot_units) plot_bin_slices(Y_test_use[:,true_index]*maxabs_factor, Y_test_predicted[:,NN_index]*maxabs_factor,\ use_fraction = False,\ bins=10,min_val=minval,max_val=maxval,\ save=True,savefolder=save_folder_name,\
if input_file2 is not None: plot_distributions(true2_value_fullAnalysis, old_reco=reco2_value_fullAnalysis, weights=weights2_value_fullAnalysis, save=save, savefolder=save_folder_name, reco_name = name2, variable=plot_name, units= plot_units, minval=minval,maxval=maxval, bins=bins,true_name=energy_type) if make_2d_hist: switch = False plot_2D_prediction(true1_value, reco1_value, weights=weights1_value,\ save=save, savefolder=save_folder_name, bins=bins, switch_axis=switch, variable=plot_name, units=plot_units, reco_name=name1, flavor=flavor,sample=sample,variable_type=energy_type) plot_2D_prediction(true1_value, reco1_value, weights=weights1_value,\ save=save, savefolder=save_folder_name, bins=bins,switch_axis=switch,\ minval=minval, maxval=maxval, axis_square=True,\ variable=plot_name, units=plot_units, reco_name=name1, flavor=flavor,sample=sample,variable_type=energy_type) if input_file2 is not None: plot_2D_prediction(true2_value, reco2_value, weights=weights2_value,
reco_name = reco_name, variable=plot_name, units= plot_units, minval=min(true_val), maxval=max(true_val)) if plot_others: plot_distributions(true_r[cuts], reco_r[cuts],\ save=save, savefolder=save_folder_name, weights=true_weights,\ cnn_name = reco_name, variable="Radial Vertex", units= "(m)",log=True) plot_distributions(true_z[cuts], reco_z[cuts],\ save=save, savefolder=save_folder_name, weights=true_weights,cnn_name = reco_name, variable="Z Vertex", units= "(m)",log=True) if plot_main: switch = False plot_2D_prediction(true_val, cnn_val,weights=true_weights,\ save=save, savefolder=save_folder_name, bins=bins, switch_axis=switch, variable=plot_name, units=plot_units, reco_name="CNN",flavor=nu_type,sample=sample_name) plot_2D_prediction(true_val, cnn_val,weights=true_weights,\ save=save, savefolder=save_folder_name, bins=bins,switch_axis=switch,\ minval=minval, maxval=maxval, cut_truth=True, axis_square=True,\ variable=plot_name, units=plot_units,\ reco_name="CNN",flavor=nu_type,sample=sample_name) if retro_val is not None: plot_2D_prediction(retro_true_val, retro_val, weights=retro_weights, save=save, savefolder=save_folder_name, bins=bins,switch_axis=switch,\ variable=plot_name, units=plot_units, reco_name=reco_name,flavor=nu_type,sample=sample_name)
save=save, savefolder=save_folder_name, weights=weights_plot,\ reco_name = "Retro", variable=plot_name, units= plot_units, minval=minval,maxval=maxval,bins=bins) plot_distributions(truth, cnn, old_reco=old_reco,\ save=save, savefolder=save_folder_name, weights=weights_plot,\ reco_name = "Retro", variable=plot_name, units= plot_units) if reco is not None: plot_distributions(true_r[cuts], reco_r[cuts],\ save=save, savefolder=save_folder_name, weights=weights_plot,\ cnn_name = "Retro", variable="Radial Vertex", units= "(m)",log=True) plot_distributions(true_z[cuts], reco_z[cuts],\ save=save, savefolder=save_folder_name, weights=weights_plot,\ cnn_name = "Retro", variable="Z Vertex", units= "(m)",log=True) plot_2D_prediction(truth, cnn,weights=weights_plot,\ save=save, savefolder=save_folder_name,bins=bins, variable=plot_name, units=plot_units, reco_name="CNN") plot_2D_prediction(truth, cnn,weights=weights_plot,\ save=save, savefolder=save_folder_name,bins=bins, minval=minval, maxval=maxval, cut_truth=True, axis_square=True,\ variable=plot_name, units=plot_units, reco_name="CNN") if reco is not None: plot_2D_prediction(truth, retro_energy[cuts], weights=weights_plot, save=save, savefolder=save_folder_name,bins=bins,\ variable=plot_name, units=plot_units, reco_name="Retro") plot_2D_prediction(truth, retro_energy[cuts], weights=weights_plot, save=save, savefolder=save_folder_name,bins=bins,\ minval=minval, maxval=maxval, cut_truth=True, axis_square=True,\ variable=plot_name, units=plot_units, reco_name="Retro") plot_single_resolution(truth, cnn, weights=weights_plot,\
true_weights = weights[cuts] print(true_energy[cuts][:10], cnn_energy[cuts][:10]) plot_distributions(true_energy[cuts],cnn_energy[cuts] weights=true_weights save=save, savefolder=save_folder_name, cnn_name = "CNN", variable=plot_name, units= plot_units, minval=minval,maxval=maxval, bins=bins) plot_2D_prediction(true_energy[cuts], cnn_energy[cuts], weights=true_weights,bins=bins, save=save, savefolder=save_folder_name, variable=plot_name, units=plot_units, reco_name="CNN") plot_single_resolution(true_energy[cuts], cnn_energy[cuts], weights=true_weights, use_old_reco = False, minaxis=-2, maxaxis=2, bins=bins, use_fraction=True,\ save=save, savefolder=save_folder_name,\ variable=plot_name, units=plot_units, reco_name="CNN") plot_bin_slices(true_energy[cuts], cnn_energy[cuts], weights=true_weights, use_fraction = True, bins=syst_bin,
true_index = first_var_index name_index = first_var_index plot_name = plots_names[name_index] plot_units = plots_units[name_index] maxabs_factor = maxabs_factors[name_index] maxval = maxvals[name_index] minval = minvals[name_index] use_frac = use_fractions[name_index] bins = bins_array[name_index] print( "Plotting %s at position %i in true test output and %i in NN test output" % (plot_name, true_index, NN_index)) plot_2D_prediction(Y_test_use[:,true_index]*maxabs_factor,\ Y_test_predicted[:,NN_index]*maxabs_factor,\ save,save_folder_name,bins=bins,\ minval=minval,maxval=maxval,\ variable=plot_name,units=plot_units, epochs=epoch) plot_2D_prediction(Y_test_use[:,true_index]*maxabs_factor, Y_test_predicted[:,NN_index]*maxabs_factor,\ save,save_folder_name,bins=bins,\ minval=None,maxval=None,\ variable=plot_name,units=plot_units, epochs = epoch) plot_single_resolution(Y_test_use[:,true_index]*maxabs_factor,\ Y_test_predicted[:,NN_index]*maxabs_factor,\ minaxis=-2*maxval,maxaxis=maxval*2, save=save,savefolder=save_folder_name,\ variable=plot_name,units=plot_units, epochs = epoch) plot_bin_slices(Y_test_use[:,true_index]*maxabs_factor, Y_test_predicted[:,NN_index]*maxabs_factor,\ use_fraction = False,\ bins=10,min_val=minval,max_val=maxval,\ save=True,savefolder=save_folder_name,\