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
068539d7
Commit
068539d7
authored
7 months ago
by
Antonello, Dr. Massimiliano
Browse files
Options
Downloads
Patches
Plain Diff
add supprot for sumlab
parent
78a6f783
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Results/dummy
+0
-1
0 additions, 1 deletion
Results/dummy
user/example.py
+2
-2
2 additions, 2 deletions
user/example.py
user/sumlab_auto.py
+113
-0
113 additions, 0 deletions
user/sumlab_auto.py
with
115 additions
and
3 deletions
Results/dummy
deleted
100644 → 0
+
0
−
1
View file @
78a6f783
This diff is collapsed.
Click to expand it.
user/example.py
+
2
−
2
View file @
068539d7
...
@@ -18,7 +18,7 @@ parser.add_argument('-bin_0', type=float, default=-100.0, help='SELECT FIRST BIN
...
@@ -18,7 +18,7 @@ parser.add_argument('-bin_0', type=float, default=-100.0, help='SELECT FIRST BIN
parser
.
add_argument
(
'
-truncate_nsigma0_up
'
,
type
=
float
,
default
=
2.0
,
help
=
'
SCAN SPECTRUM FROM Q < Q_0 - 4 sigma_0
'
)
parser
.
add_argument
(
'
-truncate_nsigma0_up
'
,
type
=
float
,
default
=
2.0
,
help
=
'
SCAN SPECTRUM FROM Q < Q_0 - 4 sigma_0
'
)
parser
.
add_argument
(
'
-truncate_nsigma0_do
'
,
type
=
float
,
default
=
2.0
,
help
=
'
EVALUATE SPECTRUM CHI2 IN Q_0 - x*sigma_0 < Q < Q_0 + 2*sigma_0
'
)
parser
.
add_argument
(
'
-truncate_nsigma0_do
'
,
type
=
float
,
default
=
2.0
,
help
=
'
EVALUATE SPECTRUM CHI2 IN Q_0 - x*sigma_0 < Q < Q_0 + 2*sigma_0
'
)
parser
.
add_argument
(
'
-prefit_only
'
,
action
=
'
store_true
'
,
help
=
'
FIT THE WHOLE SPECTRUM
'
)
parser
.
add_argument
(
'
-prefit_only
'
,
action
=
'
store_true
'
,
help
=
'
FIT THE WHOLE SPECTRUM
'
)
parser
.
add_argument
(
'
-folder
'
,
type
=
str
,
default
=
'
data/hamamatsu_pcb6
'
,
help
=
'
Directory containing the data files
'
)
parser
.
add_argument
(
'
-folder
'
,
type
=
str
,
default
=
'
data/hamamatsu_pcb6
/trial
'
,
help
=
'
Directory containing the data files
'
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
...
@@ -71,7 +71,7 @@ for i, (file, path) in enumerate(files_to_fit):
...
@@ -71,7 +71,7 @@ for i, (file, path) in enumerate(files_to_fit):
items
=
file
.
split
(
'
_
'
)
items
=
file
.
split
(
'
_
'
)
V
=
float
(
items
[
2
].
replace
(
'
V
'
,
''
).
replace
(
'
p
'
,
'
.
'
))
V
=
float
(
items
[
2
].
replace
(
'
V
'
,
''
).
replace
(
'
p
'
,
'
.
'
))
print
(
V
)
f_tau_hmt
=
f_tau
(
V
,
V_bd_hmt
,
V_0_hmt
)
f_tau_hmt
=
f_tau
(
V
,
V_bd_hmt
,
V_0_hmt
)
...
...
This diff is collapsed.
Click to expand it.
user/sumlab_auto.py
0 → 100644
+
113
−
0
View file @
068539d7
import
sys
import
os
sys
.
path
.
append
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))))
from
PeakOTron
import
PeakOTron
import
pandas
as
pd
import
numpy
as
np
import
argparse
def
float_or_none
(
value
):
return
None
if
value
.
lower
()
==
'
none
'
else
float
(
value
)
parser
=
argparse
.
ArgumentParser
(
description
=
'
Fit SiPM data
'
)
parser
.
add_argument
(
'
-V_bd_hmt
'
,
type
=
float
,
default
=
26.1
,
help
=
'
V_bd_hmt value
'
)
parser
.
add_argument
(
'
-V_0_hmt
'
,
type
=
float
,
default
=
1.4
,
help
=
'
V_0_hmt value
'
)
parser
.
add_argument
(
'
-tau
'
,
type
=
float
,
default
=
20.0
,
help
=
'
SLOW COMPONENT OF SIPM PULSE
'
)
parser
.
add_argument
(
'
-t_0
'
,
type
=
float
,
default
=
100.0
,
help
=
'
PRE-INTEGRATION TIME
'
)
parser
.
add_argument
(
'
-t_gate
'
,
type
=
float
,
default
=
100.0
,
help
=
'
GATE LENGTH
'
)
parser
.
add_argument
(
'
-bin_0
'
,
type
=
float_or_none
,
default
=-
100.0
,
help
=
'
SELECT FIRST BIN OF SPECTRUM
'
)
parser
.
add_argument
(
'
-truncate_nsigma0_up
'
,
type
=
float_or_none
,
default
=
2.0
,
help
=
'
SCAN SPECTRUM FROM Q < Q_0 - 4 sigma_0
'
)
parser
.
add_argument
(
'
-truncate_nsigma0_do
'
,
type
=
float_or_none
,
default
=
2.0
,
help
=
'
EVALUATE SPECTRUM CHI2 IN Q_0 - x*sigma_0 < Q < Q_0 + 2*sigma_0
'
)
parser
.
add_argument
(
'
-prefit_only
'
,
action
=
'
store_true
'
,
help
=
'
FIT THE WHOLE SPECTRUM
'
)
parser
.
add_argument
(
'
-folder
'
,
type
=
str
,
default
=
'
data/sumlab
'
,
help
=
'
Directory containing the data files
'
)
args
=
parser
.
parse_args
()
def
C_tau
(
V
,
V_bd
,
V_0
):
return
(
V
-
V_bd
)
/
V_0
def
f_tau
(
V
,
V_bd
,
V_0
):
return
-
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
=
args
.
V_bd_hmt
V_0_hmt
=
args
.
V_0_hmt
tau
=
args
.
tau
# SLOW COMPONENT OF SIPM PULSE
t_0
=
args
.
t_0
# PRE-INTEGRATION TIME
t_gate
=
args
.
t_gate
# GATE LENGTH
bin_0
=
args
.
bin_0
# SELECT FIRST BIN OF SPECTRUM (CAN BE AUTOMATIC)
# SCAN SPECTRUM FROM Q < Q_0 - 4 sigma_0
truncate_nsigma0_up
=
args
.
truncate_nsigma0_up
# EVALUATE SPECTRUM CHI2 IN Q_0 - x*sigma_0 < Q < Q_0 + 2*sigma_0
truncate_nsigma0_do
=
args
.
truncate_nsigma0_do
prefit_only
=
args
.
prefit_only
# FIT THE WHOLE SPECTRUM
out_dict
=
{}
files_to_fit
=
[]
# Find all histograms in directory
folder
=
args
.
folder
for
root
,
dirs
,
files
in
os
.
walk
(
folder
):
for
file
in
files
:
if
file
.
endswith
(
"
.txt
"
):
files_to_fit
.
append
([
file
,
os
.
path
.
join
(
root
,
file
)])
print
(
"
\033
[95m
\n
=======================================
"
)
print
(
"
PeakOTron
"
)
print
(
"
=======================================
\033
[0m
"
)
# Loop thorough files
for
i
,
(
file
,
path
)
in
enumerate
(
files_to_fit
):
print
(
"
\033
[95mFitting: {:s}
\033
[0m
"
.
format
(
file
))
V
=
float
(
file
.
split
(
'
deg
'
)[
1
].
split
(
'
V
'
)[
0
].
replace
(
'
_
'
,
'
.
'
))
f_tau_hmt
=
f_tau
(
V
,
V_bd_hmt
,
V_0_hmt
)
# Load files.
data
=
np
.
loadtxt
(
path
,
skiprows
=
0
)
# Create a PeakOTron Fit Object.
f_data
=
PeakOTron
(
verbose
=
False
)
# Perform fit.
f_data
.
Fit
(
data
,
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
)
f_data
.
PlotFit
(
plot_in_bins
=
True
,
display
=
False
,
save_directory
=
f
"
{
folder
}
/
{
file
[
:
-
4
]
}
_fit.png
"
)
fit_out
=
{}
prefit_val
,
prefit_err
=
f_data
.
GetPrefitResults
(
bin_units
=
False
)
print
(
"
\033
[95m
"
+
rf
"
Prefit: G =
{
prefit_val
.
get
(
'
G
'
)
}
d_G =
{
prefit_err
.
get
(
'
G
'
)
}
"
+
"
\033
[0m
"
)
for
key
,
value
in
prefit_val
.
items
():
fit_out
[
"
prefit_{:s}
"
.
format
(
key
)]
=
value
for
key
,
value
in
prefit_err
.
items
():
fit_out
[
"
prefit_d_{:s}
"
.
format
(
key
)]
=
value
#if not prefit_only:
fit_val
,
fit_err
=
f_data
.
GetFitResults
(
bin_units
=
False
)
print
(
"
\033
[95m
"
+
rf
"
Fit: G =
{
fit_val
.
get
(
'
G
'
)
}
d_G =
{
fit_err
.
get
(
'
G
'
)
}
"
+
"
\033
[0m
"
)
for
key
,
value
in
fit_val
.
items
():
fit_out
[
"
{:s}
"
.
format
(
key
)]
=
value
for
key
,
value
in
fit_err
.
items
():
fit_out
[
"
d_{:s}
"
.
format
(
key
)]
=
value
df
=
pd
.
DataFrame
.
from_dict
([
fit_out
])
df
.
to_csv
(
"
{}/fit_results_{:s}.csv
"
.
format
(
folder
,
file
[:
-
4
]))
print
(
"
\033
[95m=======================================
\033
[0m
"
)
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