Skip to content

Commit f7317fb

Browse files
committed
[Tests] new tests for noise
1 parent 7530bef commit f7317fb

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

tests/qualification.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def exp(x, a, b):
4747
nXtDel += debug.nDXt
4848
nAp += debug.nAp
4949

50-
dcrDelays = np.diff(dcrDelays)
50+
dcrDelays = np.diff(np.sort(dcrDelays)) * 1e-9
5151

5252
dcr = nDcr / (1e-9 * N * sensor.properties().signalLength())
5353
xt = nXt / nPe
@@ -64,25 +64,25 @@ def exp(x, a, b):
6464

6565
print(tabulate(tableData, headers="keys", floatfmt=".2f"))
6666

67-
cost = ExtendedUnbinnedNLL(dcrDelays, exp)
68-
fit = Minuit(cost, a=sensor.properties().dcr(), b=sensor.properties().dcr())
67+
cost = UnbinnedNLL(dcrDelays, exp)
68+
fit = Minuit(cost, a=1/np.mean(dcrDelays))
6969
fit.migrad()
7070
fit.minos()
7171

7272
print(fit)
7373

74-
plt.figure()
75-
h = np.histogram(
76-
dcrTimes,
77-
np.arange(
78-
0,
79-
sensor.properties().signalLength() + 10,
80-
10,
81-
),
82-
)
83-
mplhep.histplot(h, label="Time distribution of DCR")
84-
plt.xlabel("Time [ns]")
85-
plt.legend(frameon=False)
74+
fig, ax = plt.subplots(2, 1)
75+
h = np.histogram(dcrTimes, 300)
76+
mplhep.histplot(h, label="Time distribution of DCR", ax=ax[0])
77+
ax[0].set_xlabel("Time [ns]")
78+
ax[0].legend(frameon=False)
79+
80+
h = np.histogram(dcrDelays, 300, density=True)
81+
mplhep.histplot(h, label="Inter-arriving time distribution of DCR", ax=ax[1])
82+
x=np.linspace(0,dcrDelays.max(),100)
83+
ax[1].plot(x,exp(x,*fit.values), label="Exponential fit")
84+
ax[1].set_xlabel("Time [s]")
85+
ax[1].legend(frameon=False)
8686
plt.show()
8787

8888
tableData = {

0 commit comments

Comments
 (0)