Exemple #1
0
from PlottingFunctions import plot_single_resolution
from PlottingFunctions import plot_energy_slices
from PlottingFunctions import plot_distributions

plot_single_resolution(Y_energy[energy_cc],reco_energy[energy_cc],bins=100, use_fraction=fractional,\
                        save=True,savefolder=save_folder_name,\
                        variable="Energy", units = "GeV")

plot_single_resolution(Y_coszenith[energy_cc],reco_coszenith[energy_cc],bins=100, use_fraction=fractional,\
                        save=True,savefolder=save_folder_name,\
                        variable="CosZenith", units = "")

plot_energy_slices(Y_energy[energy_cc], reco_energy[energy_cc], \
                       use_fraction = fractional, \
                       bins=10,min_val=5.,max_val=100.,\
                       save=True,savefolder=save_folder_name)

plot_energy_slices(Y_coszenith[energy_cc], reco_coszenith[energy_cc], \
                       use_fraction = fractional, 
                       bins=10,min_val=-1.,max_val=1.,\
                       save=True,savefolder=save_folder_name,\
                        variable="CosZenith",units="")

plot_distributions(Y_energy[energy_cc], reco_energy[energy_cc],\
                    save=True,savefolder=save_folder_name,\
                    variable="Energy",units="GeV")

plot_distributions(Y_coszenith[energy_cc], reco_coszenith[energy_cc],\
                    save=True,savefolder=save_folder_name,\
                    variable="CozZenith",units="")
                 weights=weights2_value,alpha=0.5)
        plt.xscale('log')
        plt.title("Energy Distribution Weighted for %s events"%len(true2_value),fontsize=25)
        plt.xlabel("Energy (GeV)",fontsize=20)
        plt.xticks(fontsize=15)
        plt.yticks(fontsize=15)
        plt.axvline(5,linewidth=3,linestyle="--",color='k',label="Cut at 5 GeV")
        plt.legend(loc='upper left',fontsize=15)
        plt.savefig("%s/%sLogEnergyDist_ZoomInLE.png"%(save_folder_name,name2.replace(" ","")))
        """

        if make_distributions:
            plot_distributions(true1_value_fullAnalysis,
                            reco1_value_fullAnalysis,
                            weights=weights1_value_fullAnalysis,
                            save=save, savefolder=save_folder_name,
                            cnn_name = name1, variable=plot_name,
                            units= plot_units,
                            minval=minval,maxval=maxval,
                            bins=bins,true_name=energy_type)

            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:
Exemple #3
0
                        old_reco = retro_energy[cuts],\
                        use_fraction = True, bins=syst_bin, min_val=minval, max_val=maxval,\
                        save=save, savefolder=save_folder_name,\
                        variable=plot_name, units=plot_units, reco_name="Retro")

    plot_vertex(true_r[cuts],true_z[cuts])

    plot_bin_slices(true_energy[cuts], cnn_energy[cuts], old_reco = retro_energy[cuts],\
                    weights=weights[cuts],energy_truth=true_r[cuts],\
                    xvariable="Starting Vertex R Position",xunits="(m)",
                    use_fraction = True, bins=syst_bin, min_val=0, max_val=maxval*3,\
                    save=save, savefolder=save_folder_name,\
                    variable=plot_name, units=plot_units, reco_name="Retro")
   
"""
"""
plot_distributions(true_energy,cnn_energy,save=save,savefolder=save_folder_name,old_reco=retro_energy)
plot_distributions(true_energy,cnn_energy,save=save,savefolder=save_folder_name,old_reco=retro_energy,minval=1,maxval=150,bins=150)
plot_2D_prediction(true_energy, cnn_energy, save, save_folder_name,bins=bins,\
                        minval=minval, maxval=maxval, cut_truth=True, axis_square=True,\
                        variable=plot_name, units=plot_units, reco_name="CNN")
plot_2D_prediction(true_energy, retro_energy, save, 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(true_energy, cnn_energy, use_old_reco = True, old_reco = retro_energy,\
                   minaxis=-maxval, maxaxis=maxval, bins=bins,\
                   save=save, savefolder=save_folder_name,\
                   variable=plot_name, units=plot_units, reco_name="Retro")
plot_bin_slices(true_energy, cnn_energy, old_reco = retro_energy,\
                    use_fraction = True, bins=15, min_val=minval, max_val=maxval,\
                    save=save, savefolder=save_folder_name,\
        #print(plot_name, plot_units, minval, maxval, syst_bin, bins)
        #print(max(true_val), max(cnn_val), max(retro_val))
        #print(true_val[:10], cnn_val[:10], retro_val[:10])
        if nu_type == "NuMu" or nu_type == "numu":
            dist_title = r'$\nu_\mu$ '
        elif nu_type == "NuE" or nu_type == "nue":
            dist_title = r'for $\nu_e$ '
        else:
            dist_title += nu_type
        dist_title += sample_name

        if plot_main:
            plot_distributions(true_val, cnn_val,
                                old_reco=retro_val,old_reco_weights=retro_weights,\
                                save=save, savefolder=save_folder_name, weights=true_weights,\
                                reco_name = reco_name, variable=plot_name, units= plot_units,
                                minval=minval,maxval=maxval,bins=bins)
            plot_distributions(true_val, cnn_val,
                                old_reco=retro_val,old_reco_weights=retro_weights,\
                                save=save, savefolder=save_folder_name, weights=true_weights,\
                                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,
    else:
        weights_plot =  weights[cuts]

    print("Working on %s"%folder_name)

    save_folder_name = save_base_name + "/%s/"%folder_name
    if os.path.isdir(save_folder_name) != True:
        os.mkdir(save_folder_name)


    print(truth[:10], cnn[:10])
    #plot_NDOMS(true_ndoms[cuts],true_r[cuts])
    #plot_NDOMS(true_ndoms[cuts],true_r[cuts],cut=0)
    
    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,
                                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")
    else:
        reco_class = retro_PID_full

    print("Working on %s" % folder_name)

    save_folder_name = save_base_name + "/%s/" % folder_name
    if os.path.isdir(save_folder_name) != True:
        os.mkdir(save_folder_name)

    print(true_energy[cuts][:10], cnn_energy[cuts][:10])

    #plot_NDOMS(true_ndoms[cuts],true_r[cuts])
    #plot_NDOMS(true_ndoms[cuts],true_r[cuts],cut=0)

    plot_distributions(true_energy[cuts], cnn_energy[cuts], old_reco=retro_energy[cuts],\
                                save=save, savefolder=save_folder_name, weights=true_weights,\
                                reco_name = "Retro", variable=plot_name, units= plot_units,
                                minval=minval,maxval=maxval,bins=bins)
    #plot_distributions(true_energy[cuts], cnn_energy[cuts], old_reco=retro_energy[cuts],\
    #                            save=save, savefolder=save_folder_name, weights=true_weights,\
    #                            reco_name = "Retro", variable=plot_name, units= plot_units)
    #plot_distributions(true_r[cuts], reco_r[cuts],\
    #                            save=save, savefolder=save_folder_name, weights=true_weights,\
    #                            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=true_weights,\
                                cnn_name = "Retro", variable="Z Vertex", units= "(m)",log=True)
    switch = False
    plot_2D_prediction(true_energy[cuts], cnn_energy[cuts],weights=true_weights,\
                            save=save, savefolder=save_folder_name,bins=bins, switch_axis=switch,
                            variable=plot_name, units=plot_units, reco_name="CNN")
    plot_2D_prediction(true_energy[cuts], retro_energy[cuts], weights=true_weights,
 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)
 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=-2*maxval,maxaxis=maxval*2,
                save=save,savefolder=save_folder_name,\
                variable=plot_name,units=plot_units)
 plot_distributions(Y_test_use[:,true_index]*maxabs_factor, Y_test_predicted[:,NN_index]*maxabs_factor,\
                 save,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 = use_frac,\
                 bins=10,min_val=minval,max_val=maxval,\
                save=True,savefolder=save_folder_name,\
                variable=plot_name,units=plot_units)
 if first_var == "energy" and num ==0:
     plot_2D_prediction_fraction(Y_test_use[:,true_index]*maxabs_factor,\
                     Y_test_predicted[:,NN_index]*maxabs_factor,\
                     save,save_folder_name,bins=bins,\
                     minval=0,maxval=2,\
                     variable=plot_name,units=plot_units)
 if num > 0 or first_var == "zenith":
     plot_bin_slices(Y_test_use[:,true_index], Y_test_predicted[:,NN_index], \
                    min_energy = min_energy, max_energy=max_energy, true_energy=Y_test_use[:,0]*max_energy, \