Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
PeakOTron
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
UHHDetLab
SiPM
PeakOTron
Commits
ad2f7d87
Commit
ad2f7d87
authored
2 years ago
by
Jack Christopher Hutchinson Rolph
Browse files
Options
Downloads
Patches
Plain Diff
Update example.py
parent
c056edeb
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
example.py
+34
-9
34 additions, 9 deletions
example.py
with
34 additions
and
9 deletions
example.py
+
34
−
9
View file @
ad2f7d87
import
os
import
sys
import
numpy
as
np
...
...
@@ -7,6 +6,24 @@ from PeakOTron import PeakOTron
from
joblib
import
dump
import
time
C_tau
=
lambda
V
,
V_bd
,
V_0
:
(
V
-
V_bd
)
/
V_0
f_tau
=
lambda
V
,
V_bd
,
V_0
:
-
1
/
np
.
log
((
1
-
np
.
exp
(
C_tau
(
V
,
V_bd
,
V_0
)
*
np
.
exp
(
-
1
)))
/
(
1
-
np
.
exp
(
C_tau
(
V
,
V_bd
,
V_0
))))
V_bd_hmt
=
51.570574
+
0.307
V_0_hmt
=
2.906
tau
=
21.953
##SLOW COMPONENT OF SIPM PULSE
t_0
=
100.0
## PRE-INTEGRATION TIME
t_gate
=
104.0
## GATE LENGTH
bin_0
=-
100.0
## SELECT FIRST BIN OF SPECTRUM (CAN BE AUTOMATIC)
truncate_nsigma0_up
=
2.0
## SCAN SPECTRUM FROM Q < Q_0 - 4 sigma_0
truncate_nsigma0_do
=
2.0
## EVALUATE SPECTRUM CHI2 IN Q_0 - x*sigma_0 < Q < Q_0 + 2*sigma_0
prefit_only
=
False
## FIT THE WHOLE SPECTRUM
print
(
"
--------------------
"
)
print
(
'
EXAMPLE SIPM CALIBRATION RUN
'
)
print
(
"
--------------------
"
)
...
...
@@ -16,7 +33,7 @@ out_dict = {}
files_to_fit
=
[]
## Find all histograms in directory
for
root
,
dirs
,
files
in
os
.
walk
(
"
./data/hamamatsu_pcb6/Light
"
):
for
root
,
dirs
,
files
in
os
.
walk
(
"
./data
_paper
/hamamatsu_pcb6/Light
"
):
for
file
in
files
:
...
...
@@ -40,6 +57,9 @@ for i, (file, path) in enumerate(files_to_fit):
V
=
float
(
items
[
2
].
replace
(
'
V
'
,
''
).
replace
(
'
p
'
,
'
.
'
))
f_tau_hmt
=
f_tau
(
V
,
V_bd_hmt
,
V_0_hmt
)
print
(
"
\n\n
"
)
print
(
"
===============================================================
"
)
print
(
"
FIT {:d} - {:s}
"
.
format
(
i
,
file
))
...
...
@@ -51,18 +71,23 @@ for i, (file, path) in enumerate(files_to_fit):
data
=
np
.
loadtxt
(
path
,
skiprows
=
8
)
## Create a PeakOTron Fit Object.
f_data
=
PeakOTron
(
verbose
=
Tru
e
)
f_data
=
PeakOTron
(
verbose
=
Fals
e
)
## Perform fit.
f_data
.
Fit
(
data
,
tau
=
21.953
,
#SLOW PULSE COMPONENT TIME CONSTANT (ns)
t_gate
=
104
,
#GATE LENGTH (ns)
t_0
=
64
,
#INTEGRATION TIME BEFORE GATE (ns)
tau_R
=
21.953
tau
=
tau
,
#SLOW PULSE COMPONENT TIME CONSTANT (ns)
t_gate
=
t_gate
,
#GATE LENGTH (ns)
t_0
=
t_0
,
#INTEGRATION TIME BEFORE GATE (ns)
tau_R
=
f_tau_hmt
*
tau
,
bin_0
=
bin_0
,
truncate_nsigma0_up
=
truncate_nsigma0_up
,
truncate_nsigma0_do
=
truncate_nsigma0_do
)
#BINNING RULE "knuth", "freedman", "scott" - use bw= #### to override. it is still required for DCR calculation.
f_data
.
PlotFit
(
xlabel
=
"
ADC
"
,
display
=
False
,
save_directory
=
"
./Results/{0}_fit.png
"
.
format
(
os
.
path
.
splitext
(
file
)[
0
]))
f_data
.
PlotFit
(
plot_in_bins
=
True
,
display
=
False
,
save_directory
=
"
./Results/{0}_fit.png
"
.
format
(
os
.
path
.
splitext
(
file
)[
0
]))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment