-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_get_flat_data.py
42 lines (31 loc) · 1.2 KB
/
example_get_flat_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# first neural network with keras tutorial
import pickle
import time
import os
from sys import platform
import numpy as np
import matplotlib.pyplot as plt
from geant3_parser import Geant3DataFile
from geant3_parser import build_train_set_xy
file_name = os.path.join('data', 'shower_geant3_new.dat')
# file_name = 'sample_data.txt'
data_file = Geant3DataFile(file_name, skip_lines=3)
# split into input (X) and output (y) variables
parse_start = time.time()
print(f"Start preparing events...")
cells, true_values = build_train_set_xy(data_file, 5000, normalize=True)
parse_end = time.time()
print(f"Total events prepare time = {parse_end - parse_start}")
print(f"max hit value = {np.max(cells)}")
print(f"max e = {np.max(true_values[:,0])}")
energies = true_values[:, 0] # True energy of the particle
cell_sums = true_values[:, 1] # Sum of all cells (you don't need it)
incident_x = true_values[:, 2] # X of incidence inside the cell
incident_y = true_values[:, 3] # Y
for i in range(2):
print(f"Event #{i}")
print(f" energy {energies[i]}")
print(f" cell_sum {cell_sums[i]}")
print(f" incident_x {incident_x[i]}")
print(f" incident_y {incident_y[i]}")
print(cells[i])