33 def get_data(folder, fname, drift_margin = 0, crop = True, blur = None, white_noise = 0, coherent_noise = 0):
34 print 'Reading', fname
36 if isinstance(folder, TFile):
37 A_raw = hist2array(folder.Get(fname +
'_raw'))
38 A_deposit = hist2array(folder.Get(fname +
'_deposit'))
39 A_pdg = hist2array(folder.Get(fname +
'_pdg'))
41 A_raw = np.genfromtxt(folder+
'/'+fname +
'.raw', delimiter=
' ', dtype=np.float32)
42 A_deposit = np.genfromtxt(folder+
'/'+fname +
'.deposit', delimiter=
' ', dtype=np.float32)
43 A_pdg = np.genfromtxt(folder+
'/'+fname +
'.pdg', delimiter=
' ', dtype=np.int32)
45 print 'Bad event, return empty arrays' 46 return None,
None,
None,
None,
None 48 if A_raw.shape[0] < 8
or A_raw.shape[1] < 8:
return None,
None,
None,
None,
None 50 test_pdg = np.sum(A_pdg)
51 test_dep = np.sum(A_deposit)
52 test_raw = np.sum(A_raw)
53 if test_raw == 0.0
or test_dep == 0.0
or test_pdg == 0:
return None,
None,
None,
None,
None 55 print test_raw, test_dep, test_pdg
60 A_raw = A_raw[:,evt_start_ind:evt_stop_ind]
61 A_deposit = A_deposit[:,evt_start_ind:evt_stop_ind]
62 A_pdg = A_pdg[:,evt_start_ind:evt_stop_ind]
65 evt_stop_ind = A_raw.shape[1]
66 print evt_start_ind, evt_stop_ind
72 deposit_th_ind = A_deposit < 2.0e-5
73 A_pdg[deposit_th_ind] = 0
75 showers = A_pdg.copy()
76 tracks[(A_pdg & 0x0FFF) == 11] = 0
77 tracks[tracks > 0] = 1
78 showers[(A_pdg & 0x0FFF) != 11] = 0
79 showers[showers > 0] = 1
80 return A_raw, A_deposit, A_pdg, tracks, showers
def get_event_bounds(A, drift_margin=0)
def addWhiteNoise(a, sigma)
def addCoherentNoise(a, sigma)
def get_data(folder, fname, drift_margin=0, crop=True, blur=None, white_noise=0, coherent_noise=0)