Skip to content

Commit 9dd3168

Browse files
committed
[Examples] Update examples
1 parent 964885d commit 9dd3168

File tree

5 files changed

+28
-85
lines changed

5 files changed

+28
-85
lines changed

examples/afterpulse.py

-63
This file was deleted.

examples/mulptiphoton.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
11
import SiPM
22
import numpy as np
33
import matplotlib.pyplot as plt
4+
import mplhep
45

56
rng = SiPM.SiPMRandom()
7+
prop = SiPM.SiPMProperties()
8+
prop.setSampling(1)
9+
sensor = SiPM.SiPMSensor(prop)
610

7-
sensor = SiPM.SiPMSensor()
8-
9-
N = 100000
11+
N = 50000
1012

1113
integral = np.empty(N, dtype=np.float64)
1214

1315
for i in range(N):
1416
sensor.resetState()
15-
nphe = rng.randPoisson(5)
17+
nphe = rng.randPoisson(10)
1618
if nphe > 0:
1719
times = rng.randGaussian(25,0.1,nphe)
1820
sensor.addPhotons(times)
1921
sensor.runEvent()
20-
2122
integral[i] = sensor.signal().integral(20,250,0.0)
2223

24+
integral[integral == np.inf] = 0
25+
2326
fig,ax = plt.subplots()
24-
plt.hist(integral, 500, color="k")
27+
plt.hist(integral,int(2*N**0.5), color="k")
2528
plt.xlabel("Integral [A.U.]")
26-
ax.set_yscale("log")
2729
plt.show()
2830

examples/noise.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
sensor = SiPM.SiPMSensor()
88

9-
sensor.setProperty("SignalLength",5000)
9+
sensor.setProperty("SignalLength",1000)
1010
sensor.setProperty("FallTimeFast",20)
1111
sensor.setProperty("Dcr",5e6)
1212
sensor.setProperty("Xt",0.5)
@@ -20,20 +20,23 @@
2020

2121
signal = np.array(sensor.signal().waveform())
2222
hits = sensor.hits()
23+
hitsGraph = sensor.hitsGraph()
2324
x = np.arange(0,sensor.properties().signalLength(),sensor.properties().sampling())
2425

2526
fig,ax = plt.subplots()
26-
ax.plot(x,signal,"k",lw=1)
27+
maximum = signal.max()
2728

28-
for h in hits:
29+
30+
for i,h in enumerate(hits):
2931
if h.hitType() == SiPM.SiPMHit.HitType.kDarkCount:
30-
plt.plot(h.time(), h.amplitude(), "or", ms=10)
31-
if h.hitType() == SiPM.SiPMHit.HitType.kPhotoelectron:
32-
plt.plot(h.time(), h.amplitude(), ".k", ms=10)
32+
plt.vlines(h.time(),0, maximum, 'r')
33+
plt.plot(h.time(),0,'^r',ms=8)
3334
if (h.hitType() == SiPM.SiPMHit.HitType.kDelayedOpticalCrosstalk) | (h.hitType() == SiPM.SiPMHit.HitType.kOpticalCrosstalk):
34-
plt.plot(h.time(), h.amplitude(), "vg", ms=10)
35+
plt.vlines(h.time(),0, maximum, 'g')
36+
plt.plot(h.time(),0,'^g',ms=8)
3537
if (h.hitType() == SiPM.SiPMHit.HitType.kFastAfterPulse) | (h.hitType() == SiPM.SiPMHit.HitType.kSlowAfterPulse):
36-
plt.plot(h.time(), h.amplitude(), "^b", ms=10)
37-
ax.grid()
38+
plt.vlines(h.time(),0, maximum, 'b')
39+
plt.plot(h.time(),0,'^b',ms=8)
40+
ax.plot(x,signal,"k",lw=2)
3841
plt.legend(["Signal","Dcr","Xt","Ap"])
3942
plt.show()

examples/signals.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
sensor3.setProperty("SlowComponentFraction",0.10)
2525
sensor3.setProperty("FallTimeFast",5)
26-
sensor3.setProperty("FallTimeSlow",50)
26+
sensor3.setProperty("FallTimeSlow",80)
2727
sensor3.properties().setSlowComponentOn()
2828

2929
sensor1.setProperty("Snr",30)

examples/staircase.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from scipy.signal import savgol_filter
88
plt.style.use(mplhep.style.ATLAS)
99

10-
dcr = 300
10+
dcr = 100
1111
xt = 0.10
1212
sensor = SiPM.SiPMSensor()
1313
sensor.setProperty("Dcr",dcr*1000)
@@ -26,15 +26,16 @@ def fitFun(x,
2626

2727
start = 0
2828
end = 4.0
29-
step = 0.05
29+
step = 0.1
3030
window = 250
3131
N = 25000
32+
n = 100
3233

3334
threshold = np.arange(start,end,step)
3435
nstep = threshold.size
35-
counts = np.zeros((nstep,25))
36+
counts = np.zeros((nstep,n))
3637

37-
for j in range(25):
38+
for j in range(n):
3839
peaks = np.zeros(N)
3940
for i in range(N):
4041
sensor.resetState()
@@ -58,7 +59,7 @@ def fitFun(x,
5859
fig,ax = plt.subplots()
5960
ax.plot(threshold, rate, ".k")
6061
diffRate = -savgol_filter(rate,5,2,1)
61-
ax.plot(threshold, diffRate)
62+
ax.plot(threshold, diffRate,'b')
6263
ax.fill_between(threshold, rate+raterr, rate-raterr, color="r",alpha=0.25)
6364
ax.plot(np.linspace(0,4.0,1000), fitFun(np.linspace(0,4.0,1000),*par), "--g")
6465
ax.set_yscale("log")

0 commit comments

Comments
 (0)