mattiasoldani / succobt

A set of useful tools for the INSULAb beamtests
MIT License
0 stars 0 forks source link

wf_analysis_preliminary: update 2d beam profile histogram #5

Open mattiasoldani opened 11 months ago

mattiasoldani commented 11 months ago

It should be something like

# 2d-histogram with beam spot
fig2 = plt.figure(figsize=(10, 5))
phasePol = 1 if wf_info[var0]["polPos"] else -1
sel_num = (np.amax(data["wave"+str(ind_wave[var0+"_BaseSub"])], axis=1)>(sigCutSpot*phasePol))
num = (np.array(data["x%s0" % var0])[sel_num], np.array(data["x%s1" % var0])[sel_num])
den = (np.array(data["x%s0" % var0]), np.array(data["x%s1" % var0]))

i.e. the selection on PH should depend on the waveform polarity (because negative waveforms are simply transformed with a minus sign).

mattiasoldani commented 11 months ago

Update: the polarity-dependent factor is not needed since all the waveforms are turned positive beforehand. However, since the selection on the PH really makes sense only after the baseline subtraction, currently not considered here, this modification is still needed:

# 2d-histogram with beam spot
fig2 = plt.figure(figsize=(10, 5))
sel_num = (np.amax(data["wave"+str(ind_wave[var0+"_BaseSub"])], axis=1)>sigCutSpot)
num = (np.array(data["x%s0" % var0])[sel_num], np.array(data["x%s1" % var0])[sel_num])
den = (np.array(data["x%s0" % var0]), np.array(data["x%s1" % var0]))
mattiasoldani commented 11 months ago

Another thing: it is worth it to modify this part by adding the last 2 lines:

ax2 = fig2.add_subplot(122)
ax2.set_title("detector efficiency spot, signal > %d" % sigCutSpot)
sl.hist2dRatio(num[0], num[1], den[0], den[1], bins=(xplot2, xplot2), ax=ax2, cmap="viridis") ;
ax2.plot(
    (fidcut[0][0], fidcut[0][1], fidcut[0][1], fidcut[0][0], fidcut[0][0]),
    (fidcut[1][0], fidcut[1][0], fidcut[1][1], fidcut[1][1], fidcut[1][0]),
    color="red", ls="--"
)
ax2.grid(True)
ax2.set_xlim((xplot2[0], xplot2[-1]))
ax2.set_ylim((xplot2[0], xplot2[-1]))

This determines that the plot axis limits are set according to the user's preference rather than imposed by the fiducial cut box.