Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 38 additions & 14 deletions analysis_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ def __init__(self):
self.ped_amp_thr = [2,2,3] # RMS amplitude threshold
self.ped_dt_thr = 100 # trigger window duration in which a signal is looked for
self.ped_zero_cross_thr = 15 # minimal number of samples after downward zero-crossing to look for upward zero-crossing
self.ped_debug = 0 # show mask waveform-wise after refinment step


self.noise_coh_group = [32] # coherent noise channel grouping
self.noise_fft_store = 0 # store FFT spectrum (large file!!)
self.noise_fft_freq = -1 # specific frequency removal (-1 is none)
self.noise_fft_lcut = 0.6 # low-pass filter frequency cut

Expand All @@ -37,14 +39,24 @@ def __init__(self):
self.trk3D_len_min = 2. #min trk length to be considered in matching
self.trk3D_dtol = 0.5 #distance tolerance to detector boundaries for timing computation

self.plt_noise_show = 0
self.plt_noise_show = 0 # 0: do not plot - 1 plot before/after CNR - 2 before CNR - 3 after CNR
self.plt_corr_daq_show = 0
self.plt_corr_glb_show = 0
self.plt_evt_disp_daq_show = 0
self.plt_evt_disp_vch_show = 0

self.plt_noise_zrange= [0,900] # color scale for noise plots
self.plt_evt_disp_daq_zrange = [-1000,1000] # color scale for DAQ channels event display plots
self.plt_evt_disp_vch_ind_zrange = [-100,100] # color scale for induction view event display plots
self.plt_evt_disp_vch_col_zrange = [-50,50] # color scale for collection view event display plots
self.plt_evt_disp_vch_show = 0 # 0: do not plot - 1 plot before/after CNR - 2 before CNR - 3 after CNR
self.plt_2dh_show = 0
self.plt_2dt_show = 0
self.plt_3d_show = 0

self.plt_noise_zrange = [0,900] # color scale for noise plots
self.plt_corr_daq_zrange = [-1,1] # color scale daq-wise correlation plot
self.plt_corr_glb_zrange = [-1,1] # color scale view-wise correlation plot
self.plt_evt_disp_daq_xrange = [-1,-1] # chan scale for DAQ channels event display plots
self.plt_evt_disp_daq_yrange = [-1,-1] # time scale for DAQ channels event display plots
self.plt_evt_disp_daq_zrange = [-1000,1000] # color scale for DAQ channels event display plots
self.plt_evt_disp_vch_yrange = [-1,-1] # time scale for view event display plots
self.plt_evt_disp_vch_ind_zrange = [-100,100] # color scale for induction view event display plots
self.plt_evt_disp_vch_col_zrange = [-50,50] # color scale for collection view event display plots

def read(self,elec="top",config="1"):
with open('settings/analysis_parameters.json','r') as f:
Expand All @@ -62,8 +74,10 @@ def read(self,elec="top",config="1"):
self.ped_amp_thr = data[config][elec]['pedestal']['amp_thr']
self.ped_dt_thr = data[config][elec]['pedestal']['dt_thr']
self.ped_zero_cross_thr = data[config][elec]['pedestal']['zero_cross_thr']
self.ped_debug = data[config][elec]['pedestal']['debug']

self.noise_coh_group = data[config][elec]['noise']['coherent']['groupings']
self.noise_fft_store = data[config][elec]['noise']['fft']['store']
self.noise_fft_freq = data[config][elec]['noise']['fft']['freq']
self.noise_fft_lcut = data[config][elec]['noise']['fft']['low_cut']

Expand All @@ -88,13 +102,23 @@ def read(self,elec="top",config="1"):
self.trk3D_dtol = data[config][elec]['track_3d']['d_tol']


self.plt_noise_show = data[config][elec]['plot']['noise']['show']
self.plt_noise_zrange = data[config][elec]['plot']['noise']['zrange']
self.plt_evt_disp_daq_show = data[config][elec]['plot']['evt_display']['daqch']['show']
self.plt_evt_disp_daq_zrange = data[config][elec]['plot']['evt_display']['daqch']['zrange']
self.plt_evt_disp_vch_show = data[config][elec]['plot']['evt_display']['viewch']['show']
self.plt_evt_disp_vch_ind_zrange = data[config][elec]['plot']['evt_display']['viewch']['ind_zrange']
self.plt_evt_disp_vch_col_zrange = data[config][elec]['plot']['evt_display']['viewch']['col_zrange']
self.plt_noise_show = data[config]['plot']['noise']['show']
self.plt_noise_zrange = data[config]['plot']['noise']['zrange']
self.plt_corr_daq_show = data[config]['plot']['corr']['daq']['show']
self.plt_corr_daq_zrange = data[config]['plot']['corr']['daq']['zrange']
self.plt_corr_glb_show = data[config]['plot']['corr']['glb']['show']
self.plt_corr_glb_zrange = data[config]['plot']['corr']['glb']['zrange']
self.plt_evt_disp_daq_show = data[config]['plot']['evt_display']['daqch']['show']
self.plt_evt_disp_daq_xrange = data[config]['plot']['evt_display']['daqch']['xrange']
self.plt_evt_disp_daq_yrange = data[config]['plot']['evt_display']['daqch']['yrange']
self.plt_evt_disp_daq_zrange = data[config]['plot']['evt_display']['daqch']['zrange']
self.plt_evt_disp_vch_show = data[config]['plot']['evt_display']['viewch']['show']
self.plt_evt_disp_vch_yrange = data[config]['plot']['evt_display']['viewch']['yrange']
self.plt_evt_disp_vch_ind_zrange = data[config]['plot']['evt_display']['viewch']['ind_zrange']
self.plt_evt_disp_vch_col_zrange = data[config]['plot']['evt_display']['viewch']['col_zrange']
self.plt_2dh_show = data[config]['plot']['2d_hits']['show']
self.plt_2dt_show = data[config]['plot']['2d_tracks']['show']
self.plt_3d_show = data[config]['plot']['3d']['show']

# setters and getters (potentially not useful now)
def set_ped_amp_sig_fst(self,value):
Expand Down
42 changes: 27 additions & 15 deletions lardon.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,33 +117,34 @@
""" compute the raw pedestal """
ped.compute_pedestal(noise_type='raw', pars=pars)


#plot.plot_noise_vch(noise_type='raw', vrange=pars.plt_noise_zrange,to_be_shown=True)
#plot.event_display_per_daqch(pars.plt_evt_disp_daqch_zrange,option='raw',to_be_shown=False)
if(pars.plt_noise_show == 1 or pars.plt_noise_show == 2):
plot.plot_noise_vch(noise_type='raw', vrange=pars.plt_noise_zrange,to_be_shown=True)
if(pars.plt_evt_disp_daq_show == 1 or pars.plt_evt_disp_daq_show == 2):
plot.event_display_per_daqch(pars.plt_evt_disp_daq_yrange,pars.plt_evt_disp_daq_zrange,option='raw',to_be_shown=True)



tcoh = time.time()
noise.coherent_noise_per_view(pars.noise_coh_group)
# noise.coherent_noise_per_view(pars.noise_coh_group)
noise.coherent_noise(pars.noise_coh_group)
print("coherent noise : ", time.time()-tcoh)


ped.compute_pedestal(noise_type='filt')
#tp = time.time()
#ped.refine_mask(pars)
ped.update_mask(pars.ped_amp_sig_oth)


cmap.arange_in_view_channels()
#plot.event_display_per_view(pars.plt_evt_disp_vch_ind_zrange,pars.plt_evt_disp_vch_col_zrange,option='coh', to_be_shown=True)
if(pars.plt_evt_disp_vch_show == 1 or pars.plt_evt_disp_vch_show == 2):
plot.event_display_per_view(pars.plt_evt_disp_vch_ind_zrange,pars.plt_evt_disp_vch_col_zrange,option='coh', to_be_shown=True)


tf = time.time()
ps = noise.FFT_low_pass(pars.noise_fft_lcut,pars.noise_fft_freq)


""" DO NOT STORE ALL FFT PS !! """
#store.store_fft(output, ps)
if(pars.noise_fft_store == 1): store.store_fft(output, ps)



Expand All @@ -153,10 +154,20 @@


#cmap.arange_in_view_channels()
#plot.event_display_per_view(pars.plt_evt_disp_vch_ind_zrange,pars.plt_evt_disp_vch_col_zrange,option='fft', option='fitlered', to_be_shown=False)
if(pars.plt_evt_disp_vch_show == 1 or pars.plt_evt_disp_vch_show == 3):
plot.event_display_per_view(time_range=pars.plt_evt_disp_vch_yrange,
adc_ind=pars.plt_evt_disp_vch_ind_zrange,
adc_coll=pars.plt_evt_disp_vch_col_zrange,
option='filtered', to_be_shown=True)
if(pars.plt_evt_disp_daq_show == 1 or pars.plt_evt_disp_daq_show == 3):
plot.event_display_per_daqch(ch_range=pars.plt_evt_disp_daq_xrange,
time_range=pars.plt_evt_disp_daq_yrange,
adc_range=pars.plt_evt_disp_daq_zrange,
option='filtered',to_be_shown=True)


#plot.plot_correlation_daqch(option='filtered',to_be_shown=True)
#plot.plot_correlation_globch(option='filtered', to_be_shown=False)
if(pars.plt_corr_daq_show == 1): plot.plot_correlation_daqch(option='filtered',colorscale=pars.plt_corr_daq_zrange,to_be_shown=True)
if(pars.plt_corr_glb_show == 1): plot.plot_correlation_globch(option='filtered',colorscale=pars.plt_corr_daq_zrange, to_be_shown=True)



Expand All @@ -165,7 +176,8 @@
#noise.coherent_noise(pars.noise_coh_group)
#print("coherent time took ", time.time()-tcoh)

#plot.plot_noise_vch(noise_type='filt', vrange=pars.plt_noise_zrange,option='coherent',to_be_shown=False)
if(pars.plt_noise_show == 1 or pars.plt_noise_show == 3):
plot.plot_noise_vch(noise_type='filt', vrange=pars.plt_noise_zrange,option='coherent',to_be_shown=True)



Expand All @@ -180,7 +192,7 @@

print("hit %.2f s"%(time.time()-th))
print("Number Of Hits found : ", dc.evt_list[-1].n_hits)
#plot.plot_2dview_hits(to_be_shown=True)
if(pars.plt_2dh_show == 1): plot.plot_2dview_hits(to_be_shown=True)



Expand All @@ -196,15 +208,15 @@

[t.mini_dump() for t in dc.tracks2D_list]

#plot.plot_2dview_2dtracks(to_be_shown=True)
if(pars.plt_2dt_show == 1): plot.plot_2dview_2dtracks(to_be_shown=True)


trk3d.find_tracks_rtree(pars.trk3D_ztol,
pars.trk3D_qfrac,
pars.trk3D_len_min,
pars.trk3D_dtol)

#plot.plot_3d(to_be_shown=True)
if(pars.plt_3d_show == 1): plot.plot_3d(to_be_shown=True)
print("Number of 3D tracks found : ", len(dc.tracks3D_list))

print(' %.2f s to process '%(time.time()-t0))
Expand Down
15 changes: 8 additions & 7 deletions pedestals.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def update_mask_inputs(thresh, mean, rms):
np.logical_and(dc.mask_daq, dc.alive_chan)


def refine_mask(pars, debug=False):
if(debug == True): import matplotlib.pyplot as plt
def refine_mask(pars):
if(pars.ped_debug > 0): import matplotlib.pyplot as plt

for ch in range(cf.n_tot_channels):

Expand Down Expand Up @@ -112,19 +112,20 @@ def refine_mask(pars, debug=False):
pars.ped_dt_thr,
pars.ped_zero_cross_thr)

if(debug==True and ch > 1 and (ch % 50) == 0):
if(pars.ped_debug > 0 and ch > 1 and (ch % 50) == 0):
nrows, ncols = 10, 5
fig = plt.figure()
for it,channel in enumerate(range(ch-50,ch)):
title = 'v'+str(view)+'-ch'+str(channel)
ax = fig.add_subplot(nrows, ncols, it+1)
ax.set_title(title)
ax.plot(dc.data_daq[channel],'o',markersize=0.2)
ax.axhline(y=dc.evt_list[-1].noise_filt.ped_rms[channel]*pars.ped_amp_thr[dc.chmap[channel].view], color='gray')
ax.axhline(y=0, color='lightgray')
ax.axhline(y=-dc.evt_list[-1].noise_filt.ped_rms[channel]*pars.ped_amp_thr[dc.chmap[channel].view], color='gray')
ax.plot(np.max(dc.data_daq[channel, :])*dc.mask_daq[channel,:],linestyle='-',linewidth=1,color='r')
ax.axhline(y=dc.evt_list[-1].noise_filt.ped_rms[channel]*pars.ped_amp_thr[dc.chmap[channel].view], color='gray',linewidth=0.1)
ax.axhline(y=0, color='lightgray',linewidth=0.1)
ax.axhline(y=-dc.evt_list[-1].noise_filt.ped_rms[channel]*pars.ped_amp_thr[dc.chmap[channel].view], color='gray',linewidth=0.1)
if(pars.ped_debug==1): ax.plot(np.max(dc.data_daq[channel, :])*dc.mask_daq[channel,:],linestyle='-',linewidth=1,color='r')
ax.set(xlabel=None,ylabel=None)
ax.set_xlim(500,2000)
ax.axis('off')
plt.subplots_adjust(left=0.01, bottom=0.01, right=0.99, top=0.95, wspace=0.05, hspace=1)
plt.show()
Expand Down
22 changes: 17 additions & 5 deletions plotting/event_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
cmap_ed_ind = cc.cm.diverging_tritanopic_cwr_75_98_c20


def draw(view, ax, adc_min, adc_max):
def draw(view, ax, t_min, t_max, adc_min, adc_max):
ax = plt.gca() if ax is None else ax
cmap = cmap_ed_coll if(cf.view_type[view] == 'Collection') else cmap_ed_ind

Expand All @@ -24,10 +24,13 @@ def draw(view, ax, adc_min, adc_max):
cmap = cmap,
vmin = adc_min,
vmax = adc_max)
# custom time map limit for controlled zoom
if(t_min >=0 and t_max>=0):
ax.set_ylim(t_min,t_max)

return ax

def event_display_per_view(adc_ind=[-10,10], adc_coll=[-5,30], option=None, to_be_shown=False):
def event_display_per_view(time_range=[-1,-1],adc_ind=[-10,10], adc_coll=[-5,30], option=None, to_be_shown=False):
fig = plt.figure(figsize=(10,5))

gs = gridspec.GridSpec(nrows=2,
Expand All @@ -46,10 +49,10 @@ def event_display_per_view(adc_ind=[-10,10], adc_coll=[-5,30], option=None, to_b

if(cf.view_type[iv] == 'Induction'):

axs[iv] = draw(iv, axs[iv], adc_ind[0], adc_ind[1])
axs[iv] = draw(iv, axs[iv], time_range[0], time_range[1], adc_ind[0], adc_ind[1])
vname = 'Ind.'
else:
axs[iv] = draw(iv, axs[iv], adc_coll[0], adc_coll[1])
axs[iv] = draw(iv, axs[iv], time_range[0], time_range[1], adc_coll[0], adc_coll[1])
vname = 'Coll.'

axs[iv].set_title('View '+str(iv)+'/'+cf.view_name[iv]+' ('+vname+')')
Expand Down Expand Up @@ -98,7 +101,7 @@ def event_display_per_view(adc_ind=[-10,10], adc_coll=[-5,30], option=None, to_b



def event_display_per_daqch(adc_range=[-10,10], option=None, to_be_shown=False):
def event_display_per_daqch(ch_range=[-1,-1],time_range=[-1,-1],adc_range=[-10,10], option=None, to_be_shown=False):
fig = plt.figure(figsize=(9,4))

gs = gridspec.GridSpec(nrows=2,
Expand All @@ -116,6 +119,15 @@ def event_display_per_daqch(adc_range=[-10,10], option=None, to_be_shown=False):
vmin = adc_range[0],
vmax = adc_range[1])

# custom (x,y) map limits for controlled zoom
if(ch_range[0] >=0 and ch_range[1]>=0):
ax.set_xlim(ch_range[0], ch_range[1])

if(time_range[0] >=0 and time_range[1]>=0):
ax.set_ylim(time_range[0], time_range[1])

for i in range(int(len(dc.data_daq)/32.)):
ax.axvline(x=i*32-0.5)

ax.set_xlabel('DAQ Channel Number')

Expand Down
8 changes: 4 additions & 4 deletions plotting/noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def plot_FFT_vch(ps, option=None, to_be_shown=False):



def plot_correlation_globch(option=None, to_be_shown=False):
def plot_correlation_globch(option=None, colorscale=[-1,1],to_be_shown=False):
data_globch = np.zeros(dc.data_daq.shape)
for i in range(cf.n_tot_channels):
gch = dc.chmap[i].globch
Expand All @@ -343,12 +343,12 @@ def plot_correlation_globch(option=None, to_be_shown=False):
plot_correlation(np.corrcoef(data_globch),"glob",option,to_be_shown)


def plot_correlation_daqch(option=None, to_be_shown=False):
def plot_correlation_daqch(option=None, colorscale=[-1,1],to_be_shown=False):
plot_correlation(np.corrcoef(dc.data_daq),"daq",option,to_be_shown)



def plot_correlation(corr,corr_type,option,to_be_shown):
def plot_correlation(corr,corr_type,colorscale,option,to_be_shown):
fig = plt.figure(figsize=(8,8))
gs = gridspec.GridSpec(nrows=2,
ncols=1,
Expand All @@ -363,7 +363,7 @@ def plot_correlation(corr,corr_type,option,to_be_shown):
interpolation='none',
cmap = cmap_corr,
extent=[0, cf.n_tot_channels, 0., cf.n_tot_channels],
vmin=-1, vmax=1)
vmin=colorscale[0], vmax=colorscale[1])

if(corr_type=='daq'):
title = 'DAQ Channels'
Expand Down
Loading