コード例 #1
0
    filename = "calibrations/KNNGaussianFitDirect_162Kpart_ecal_train_ecal_neq_0_min_0.292026728392_hcal_train_ecal_eq_0_min_1.00043606758_hcal_train_ecal_neq_0_min_1.00002634525_lim_150_n_neighbors_ecal_eq_0_2000_n_neighbors_ecal_neq_0_250.calibration"
    KNNGFD = importCalib(filename)
except FileNotFoundError:
    # We create the calibration
    KNNGFD = data1.KNNGaussianFitDirect(
        n_neighbors_ecal_eq_0=n_neighbors_ecal_eq_0,
        n_neighbors_ecal_neq_0=n_neighbors_ecal_neq_0,
        lim=lim)
    KNNGFD.saveCalib()

classname = KNNGFD.classname
#plot 3D Training points
fig = plt.figure(1, figsize=(5, 4))
usplt.plot3D_training(data1)
#plt.show()
savefig(fig, directory, classname + "_plot3D_training.png")
plt.close()

#plot 3D surface calibration
fig = plt.figure(1, figsize=(5, 4))
usplt.plot3D_surf(KNNGFD)
#plt.show()
savefig(fig, directory, classname + "_plot3D_surf.png")
plt.close()

#courbe de calibration pour ecal = 0
fig = plt.figure(figsize=(10, 4))
usplt.plotCalibrationCurve(KNNGFD)
#plt.show()
savefig(fig, directory, classname + "_calibration.png")
plt.close()
コード例 #2
0
#ecalib/etrue pour ecal = 0
h = data2.hcal[np.logical_and(data2.ecal == 0,data2.ecal+data2.hcal < lim)]
t = data2.true[np.logical_and(data2.ecal == 0,data2.ecal+data2.hcal < lim)]
e = np.zeros(len(h))
c = KNNGF.predict(e,h)
r = c/t

energy, means, mean_gaussianfit, sigma_gaussianfit, reducedChi2 = getMeans(t,r)
fig = plt.figure(figsize=(10,5))
plt.plot(t,r,'.',markersize=1)
plt.axis([0,200,0,2])
plt.plot(energy,mean_gaussianfit,lw=3)
plt.xlabel(r"$e_{true}$",fontsize=15)
plt.ylabel(r"$e_{calib}/e_{true}$",fontsize=15)
plt.title(r"$e_{calib}/e_{true}$ for $e_{cal} = 0$",fontsize=15)
savefig(fig,directory,"ecalib_over_etrue.png")

#histogram of hcal
fig = plt.figure(figsize=(10,5))
bw = binwidth_array(h)
entries, bins, other = plt.hist(h,bw)
plt.xlabel(r"$h_{cal}$",fontsize=15)
plt.title(r"$h_{cal}$ for $e_{cal} = 0$",fontsize=15)
plt.show()
savefig(fig,directory,"histograms_hcal.png")

#histogram of ecalib
fig = plt.figure(figsize=(10,5))
#bw = binwidth_array(c)
bw = binwidth_array(c,0.01)
entries, bins, other = plt.hist(c,bw)