def set_title_for(ax, im): im = im.reshape([1, 56, 64]) energy, max_energy = get_energies(im), get_max_energy(im) ax.set_title("Energy: %.2f GeV\nMaximum Energy: %.2f GeV" % (energy, max_energy))
folder=None, ax=axes[func_idx], labels=["Geant4", "Im2Im"], **params) build_histogram_HTOS(true=mc_data_images_m, fake=generated_images, energy_scaler=calo_scaler, threshold=3600, real_ET=tracker_real_ET, labels=["Geant4", "Im2Im"], ax1=axes[-3], ax2=axes[-2]) axes[-1].scatter(tracker_real_ET, get_energies(mc_data_images_m), label="Geant4", alpha=0.05) axes[-1].scatter(tracker_real_ET, get_energies(generated_images), label="Im2Im", alpha=0.05) axes[-1].legend() figs.append(fig2) use_functions[get_center_of_mass_r] = {"image_shape": image_shape} for idx in range(10): print("Single images:", idx + 1, "/", 10) use_functions[get_energy_resolution] = { "real_ET": tracker_real_ET[idx],
fake=generated_images, function=func, name=colnames[func_idx], epoch="", folder=None, ax=axes[func_idx], **params) build_histogram_HTOS(true=calo_images, fake=generated_images, energy_scaler=1, threshold=3.6, real_ET=tracker_et, ax1=axes[7], ax2=axes[8]) axes[-1].scatter(tracker_et, get_energies(calo_images), label="true", alpha=0.1) axes[-1].scatter(tracker_et, get_energies(generated_images), label="fake", alpha=0.1) axes[-1].legend() axes[-1].set_xlim(0, np.max(tracker_et)) axes[-1].set_ylim(0, np.max(tracker_et)) axes[-1].set_xlabel("Tracker") axes[-1].set_ylabel("Calorimeter") figs.append(fig2) for idx in range(nr_samples): print(idx + 1, "/", nr_samples)
get_std_energy: { "energy_scaler": calo_scaler / 1000, "threshold": 5 / calo_scaler }, get_energy_resolution: { "real_ET": tracker_real_ET, "energy_scaler": calo_scaler } } gan_data_m = gan_data_m.reshape([-1, *image_shape[:-1]]) assert mc_data_images_m.shape == generated_images.shape == gan_data_m.shape, "Shape mismatch." axes[model_idx, -1].scatter(tracker_real_ET / 1000, get_energies(mc_data_images_m, energy_scaler=calo_scaler / 1000), label="Geant4", alpha=0.05) axes[model_idx, -1].scatter(tracker_real_ET / 1000, get_energies(generated_images, energy_scaler=calo_scaler / 1000), label="Im2Im", alpha=0.05) axes[model_idx, -1].scatter(tracker_real_ET / 1000, get_energies(gan_data_m, energy_scaler=calo_scaler / 1000), label="CGAN", alpha=0.05) axes[model_idx, -1].set_xlabel("Tracker [GeV]")
get_std_energy: { "energy_scaler": calo_scaler / 1000, "threshold": 5 / calo_scaler }, get_energy_resolution: { "real_ET": tracker_real_ET, "energy_scaler": calo_scaler } } assert (mc_data_images_m.shape == generated_images_from_cgan.shape == generated_images_from_tracker.shape, "Shape mismatch.") axes[model_idx, -1].scatter(tracker_real_ET / 1000, get_energies(mc_data_images_m, energy_scaler=calo_scaler / 1000), label="Geant4", alpha=0.05) axes[model_idx, -1].scatter(tracker_real_ET / 1000, get_energies(generated_images_from_cgan, energy_scaler=calo_scaler / 1000), label="CGAN", alpha=0.05) axes[model_idx, -1].scatter(tracker_real_ET / 1000, get_energies(generated_images_from_tracker, energy_scaler=calo_scaler / 1000), label="Tracker", alpha=0.05) axes[model_idx, -1].set_xlabel("Tracker [GeV]")
def set_title_for(ax, im, name): im = im.reshape([1, 64, 64]) energy, max_energy = get_energies(im), get_max_energy(im) ax.set_title("%s\nEnergy: %.2f GeV\nMaximum Energy: %.2f GeV" % (name, energy, max_energy))
folder=None, ax=axes[func_idx], use_legend=True, **params) figs.append(fig_caloStat) fig_calo_distribution, ax = plt.subplots(nrows=1, ncols=3, figsize=(12, 8), facecolor='w', edgecolor='k') fig_calo_distribution.subplots_adjust(wspace=0.2, hspace=0.05) ## Distribution total energy calo_energies = functionsOnImages.get_energies(calo_images) ax[0].hist(calo_energies, bins=20) ax[0].set_xlabel("Calorimeter energy") ax[0].set_title("Calorimeter energy density") ## Distribution resolution energy_resolution = (tracker_events["real_ET"].values - calo_energies) / tracker_events["real_ET"].values ax[1].hist(energy_resolution, bins=20) ax[1].set_xlabel("(true - reco) / true") ax[1].set_title("Calorimeter resolution") ## ECDF unique_calo_energies = np.sort(np.unique(calo_energies)) cumulative_sum = [0] * len(unique_calo_energies)
phi1 = get_phi(x=tracker["x_projections"], y=tracker["y_projections"]) phi2 = get_phi(x=tracker["momentum_px"], y=tracker["momentum_py"]) fig_phi, _ = check_angles(phi1, phi2, "Phi") figs.append(fig_phi) z = 13330 + 1220 / 2 theta1 = np.arcsin( np.sqrt(tracker["x_projections"]**2 + tracker["y_projections"]**2) / np.sqrt(tracker["x_projections"]**2 + tracker["y_projections"]**2 + z**2)) theta2 = np.arcsin(tracker["momentum_pt"] / tracker["momentum_p"]) fig_theta, _ = check_angles(theta1, theta2, "Theta") figs.append(fig_theta) tracker["CaloEnergy"] = get_energies(calo) tracker["CaloMaxEnergy"] = get_max_energy(calo) tracker["Cells"] = get_number_of_activated_cells(calo) tracker["theta"] = theta1 tracker["phi"] = phi1 + np.pi fig_scan, axs = plt.subplots(2, 4, figsize=(16, 9)) phi_range = np.linspace(0, 2 * np.pi, 5) for i in range(4): plot_in_range(tracker, calo, "phi", [phi_range[i], phi_range[i + 1]], ax=axs[0, i]) theta_range = np.linspace(min(tracker["theta"]), max(tracker["theta"]), 5) for i in range(4):