import numpy as np import matplotlib.pyplot as plt import elecLoader as el es = 3134.078 / 2.223 Edep = np.arange(0.1, 8, 0.1) Evis = [] resFit, resConstFit = [], [] resCerFit, resSctFit, resCovFit = [], [], [] resCerConstFit, resCovConstFit = [], [] for i in Edep: NPE = el.getFitNsct(i) + el.getFitNcer(i) Evis.append(NPE / es) resFit.append(el.getFitResol(Evis[-1])) resConstFit.append(el.getFitConstResol(Evis[-1])) resCerFit.append(np.sqrt(el.getFitCerSigma(Evis[-1])) / NPE) resSctFit.append(np.sqrt(el.getFitSctSigma(Evis[-1])) / NPE) resCovFit.append(np.sqrt(el.getFitCov(Evis[-1])) / NPE) resCerConstFit.append(np.sqrt(el.getFitCerSigmaConst(Evis[-1])) / NPE) resCovConstFit.append(np.sqrt(el.getFitCovConst(Evis[-1])) / NPE) #print(el.getFitResol(Evis[-1]), el.getFitCerSigma(Evis[-1]), el.getFitSctSigma(Evis[-1]), el.getFitCov(Evis[-1])) resFit = np.array(resFit) resConstFit = np.array(resConstFit) resCerFit = np.array(resCerFit) resSctFit = np.array(resSctFit)
def fitNsct(E, As, kB): if E > 15.9: return el.getFitNsct(15.9, kB, As, "Sim") / 15.9 * E else: return el.getFitNsct(E, kB, As, "Sim")
from matplotlib import gridspec import elecLoader as el es = 3134.078 / 2.223 es1 = (3134.078 - 111) / 2.223 es2 = 111 / 2.223 Edep = np.arange(0.1, 8, 0.1) Evis = np.zeros((5, len(Edep))) resFit = np.zeros((5, len(Edep))) num = 0 for kC in [0.0, 0.2, 0.5, 0.8, 1.0]: # cerPE be selected out nn = 0 for i in Edep: NPE = el.getFitNsct(i) + el.getFitNcer(i) * kC + 660.8 * 2 Evis[num, nn] = NPE / (es - kC * es2) cerSigma2 = el.getFitCerSigma(i) sctSigma2 = el.getFitSctSigma(i) cov = el.getFitCov(i) if cerSigma2 == 0 or cov == 0: resFit[num, nn] = np.sqrt(sctSigma2 + 2 * 27.07**2) / NPE print(num, nn, sctSigma2, NPE) nn += 1 continue corr = cov / np.sqrt(cerSigma2 * sctSigma2) cerSigma2 *= (1 - kC)**2
def main(): es = 3134.078 / 2.223 fig, ax = plt.subplots() value0 = integral(0.0065) ax.plot(Etrue, value0, "-", lw=2, color="royalblue", label=r"ESTAR, $kB=6.50\times10^{-3}$g/cm$^2$/MeV") #for i, j in zip(Etrue, value0): # print(i, j) E2, n2 = loadGeant4("kB65") ax.plot(E2, n2, "--", lw=2, color="royalblue", label=r"Geant4, $kB=6.50\times10^{-3}$g/cm$^2$/MeV") #value2 = integral(0.0063) #ax.plot(Etrue, value2, "-", lw=2, color="red", label=r"ESTAR, $kB=6.3\times10^{-3}$g/cm$^2$/MeV") #E4, n4 = loadGeant4("kB63") #ax.plot(E4, n4, "-.", lw=2, color="red", label=r"Geant4, $kB=6.3\times10^{-3}$g/cm$^2$/MeV") value1 = integral(0.0051) ax.plot(Etrue, value1, "-", lw=2, color="slategray", label=r"ESTAR, $kB=5.50\times10^{-3}$g/cm$^2$/MeV") E3, n3 = loadGeant4("kB51") ax.plot(E3, n3, "--", lw=2, color="slategray", label=r"Geant4, $kB=5.50\times10^{-3}$g/cm$^2$/MeV") As = 1416.1 bestFit = 5.77e-3 fitError = 0.18e-4 n4, n4min, n4max = [], [], [] for i in Etrue: n4.append(el.getFitNsct(i, bestFit, As, "Sim")) n4min.append(el.getFitNsct(i, bestFit - fitError, As, "Sim")) n4max.append(el.getFitNsct(i, bestFit + fitError, As, "Sim")) #n4 = integral(bestFit) #n4min = integral(bestFit-fitError) #n4max = integral(bestFit+fitError) n4 = np.array(n4) n4min = np.array(n4min) n4max = np.array(n4max) delmin = n4 - n4min delmax = n4max - n4 n4min = n4 - delmin * 50 n4max = n4 + delmax * 50 ax.plot(Etrue, n4 / As / Etrue, "--", lw=2, color="crimson", label=r"Geant4, $kB=5.77\times10^{-3}$g/cm$^2$/MeV") ax.fill_between(Etrue, n4min / As / Etrue, n4max / As / Etrue, color="crimson", alpha=0.3) #ax.plot(Etrue, n4, "--", lw=2, color="crimson", label=r"ESTAR, $kB=5.45\times10^{-3}$g/cm$^2$/MeV") #ax.fill_between(Etrue, n4min, n4max, color="crimson", alpha=0.3) ax.grid(True) ax.tick_params(axis='both', which='major', labelsize=14) ax.set_xlabel("Electron $E$ [MeV]", fontsize=15) ax.set_ylabel("$E_{s}$/$E$", fontsize=15) ax.legend(prop={'size': 13}) ax.semilogx() ax.set_xlim(1e-3, 15) ax.set_ylim(0.3, 1.1) plt.tight_layout() plt.savefig("Num+G4_Birk.pdf") plt.show()
def sctpe_sim(E, kB, scale): return eloader.getFitNsct(E, kB, scale, "Sim")
totpe = ff["c11"]["totpe"].array() ke = ff["c11"]["ke"].array() Y = 3134.078 / 2.223 a1, b1, c1 = 0.988, 7.89e-3, 0 a1err, b1err = 6.46e-3, 4.33e-4 p0, p1, p2, p3, p4 = 4.20, 3.64, 0.11, 405, -2.09 a2, b2, n2 = 0.939, 0.103, 1.439 a3, b3, n3 = 0.840, 0.286, 1.234 #a2, b2, n2 = 0.855, 0.262, 1.253 ### calculation Ecalc = [] for i in ke: Nsct = el.getFitNsct(i, 6.78e-3, 1417.77, "Sim") Ncer = wenNcer(i, p0, p1, p2, p3, p4) Ntot = Nsct + Ncer #k1 = ROOT.gRandom.Gaus(Ntot/Y, np.sqrt(sigma2Func(a1, b1, c1, Y, Ntot/Y))) k1 = ROOT.gRandom.Gaus(Ntot, np.sqrt(sigma2FuncNew(a2, b2, n2, Ntot))) / Y k2 = ROOT.gRandom.Gaus(Ntot, np.sqrt(sigma2FuncNew(a3, b3, n3, Ntot))) / Y E1 = ROOT.gRandom.Gaus(660.8, 27.07) / Y E2 = ROOT.gRandom.Gaus(660.8, 27.07) / Y #Ecalc.append(k) Ecalc.append(k2 + E1 + E2) fig, ax = plt.subplots() ax.hist(Ecalc, bins=100,