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
58076663
Commit
58076663
authored
7 months ago
by
Antonello, Dr. Massimiliano
Browse files
Options
Downloads
Patches
Plain Diff
Add argparse and user folder to run and change from command line the parameters
parent
01b3ec0a
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
requirements.txt
+2
-1
2 additions, 1 deletion
requirements.txt
user/KETEK-PM1150-EB.py
+27
-15
27 additions, 15 deletions
user/KETEK-PM1150-EB.py
user/example.py
+26
-11
26 additions, 11 deletions
user/example.py
with
55 additions
and
27 deletions
requirements.txt
+
2
−
1
View file @
58076663
...
@@ -6,3 +6,4 @@ numba
...
@@ -6,3 +6,4 @@ numba
numpy
numpy
pandas
pandas
scipy
scipy
argparse
\ No newline at end of file
This diff is collapsed.
Click to expand it.
user/KETEK-PM1150-EB.py
+
27
−
15
View file @
58076663
import
os
import
os
import
sys
sys
.
path
.
append
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))))
import
numpy
as
np
import
numpy
as
np
import
pandas
as
pd
import
pandas
as
pd
import
argparse
from
PeakOTron
import
PeakOTron
from
PeakOTron
import
PeakOTron
import
re
import
re
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
=
146.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
,
default
=-
100.0
,
help
=
'
SELECT FIRST BIN OF SPECTRUM
'
)
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
(
'
-prefit_only
'
,
action
=
'
store_true
'
,
help
=
'
FIT THE WHOLE SPECTRUM
'
)
parser
.
add_argument
(
'
-folder
'
,
type
=
str
,
default
=
'
data/ketek
'
,
help
=
'
Directory containing the data files
'
)
args
=
parser
.
parse_args
()
C_tau
=
lambda
V
,
V_bd
,
V_0
:
(
V
-
V_bd
)
/
V_0
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
))))
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
=
26.1
V_bd_hmt
=
args
.
V_bd_hmt
V_0_hmt
=
1.4
V_0_hmt
=
args
.
V_0_hmt
tau
=
args
.
tau
##SLOW COMPONENT OF SIPM PULSE
tau
=
146.0
##SLOW COMPONENT OF SIPM PULSE
t_0
=
args
.
t_0
## PRE-INTEGRATION TIME
t_0
=
100.0
## PRE-INTEGRATION TIME
t_gate
=
args
.
t_gate
## GATE LENGTH
t_gate
=
100.0
## GATE LENGTH
bin_0
=
args
.
bin_0
## SELECT FIRST BIN OF SPECTRUM (CAN BE AUTOMATIC)
bin_0
=-
100.0
## SELECT FIRST BIN OF SPECTRUM (CAN BE AUTOMATIC)
truncate_nsigma0_up
=
args
.
truncate_nsigma0_up
## SCAN SPECTRUM FROM Q < Q_0 - 4 sigma_0
truncate_nsigma0_up
=
2.0
## SCAN SPECTRUM FROM Q < Q_0 - 4 sigma_0
truncate_nsigma0_do
=
args
.
truncate_nsigma0_do
## EVALUATE SPECTRUM CHI2 IN Q_0 - x*sigma_0 < Q < Q_0 + 2*sigma_0
truncate_nsigma0_do
=
2.0
## EVALUATE SPECTRUM CHI2 IN Q_0 - x*sigma_0 < Q < Q_0 + 2*sigma_0
prefit_only
=
args
.
prefit_only
## FIT THE WHOLE SPECTRUM
prefit_only
=
False
## FIT THE WHOLE SPECTRUM
out_dict
=
{}
out_dict
=
{}
files_to_fit
=
[]
files_to_fit
=
[]
## Find all histograms in directory
## Find all histograms in directory
folder
=
'
./data/ketek
'
folder
=
args
.
folder
for
root
,
dirs
,
files
in
os
.
walk
(
folder
):
for
root
,
dirs
,
files
in
os
.
walk
(
folder
):
for
file
in
files
:
for
file
in
files
:
if
file
.
endswith
(
"
.Wfm.csv
"
):
if
file
.
endswith
(
"
.Wfm.csv
"
):
...
@@ -99,7 +115,3 @@ for i, (file, path) in enumerate(files_to_fit):
...
@@ -99,7 +115,3 @@ for i, (file, path) in enumerate(files_to_fit):
# dump(f_data, "{}/dump_{}.csv".format(folder,file))
# dump(f_data, "{}/dump_{}.csv".format(folder,file))
# break
# break
This diff is collapsed.
Click to expand it.
example.py
→
user/
example.py
+
26
−
11
View file @
58076663
import
os
import
os
import
sys
import
sys
sys
.
path
.
append
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))))
import
numpy
as
np
import
numpy
as
np
import
pandas
as
pd
import
pandas
as
pd
import
argparse
from
PeakOTron
import
PeakOTron
from
PeakOTron
import
PeakOTron
from
joblib
import
dump
from
joblib
import
dump
import
time
import
time
parser
=
argparse
.
ArgumentParser
(
description
=
'
Fit SiPM data
'
)
parser
.
add_argument
(
'
-V_bd_hmt
'
,
type
=
float
,
default
=
51.570574
+
0.307
,
help
=
'
V_bd_hmt value
'
)
parser
.
add_argument
(
'
-V_0_hmt
'
,
type
=
float
,
default
=
2.906
,
help
=
'
V_0_hmt value
'
)
parser
.
add_argument
(
'
-tau
'
,
type
=
float
,
default
=
21.953
,
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
=
104.0
,
help
=
'
GATE LENGTH
'
)
parser
.
add_argument
(
'
-bin_0
'
,
type
=
float
,
default
=-
100.0
,
help
=
'
SELECT FIRST BIN OF SPECTRUM
'
)
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
(
'
-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
'
)
args
=
parser
.
parse_args
()
C_tau
=
lambda
V
,
V_bd
,
V_0
:
(
V
-
V_bd
)
/
V_0
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
))))
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_bd_hmt
=
args
.
V_bd_hmt
V_0_hmt
=
2.906
V_0_hmt
=
args
.
V_0_hmt
tau
=
args
.
tau
##SLOW COMPONENT OF SIPM PULSE
tau
=
21.953
##SLOW COMPONENT OF SIPM PULSE
t_0
=
args
.
t_0
## PRE-INTEGRATION TIME
t_0
=
100.0
## PRE-INTEGRATION TIME
t_gate
=
args
.
t_gate
## GATE LENGTH
t_gate
=
104.0
## GATE LENGTH
bin_0
=
args
.
bin_0
## SELECT FIRST BIN OF SPECTRUM (CAN BE AUTOMATIC)
bin_0
=-
100.0
## SELECT FIRST BIN OF SPECTRUM (CAN BE AUTOMATIC)
truncate_nsigma0_up
=
args
.
truncate_nsigma0_up
## SCAN SPECTRUM FROM Q < Q_0 - 4 sigma_0
truncate_nsigma0_up
=
2.0
## SCAN SPECTRUM FROM Q < Q_0 - 4 sigma_0
truncate_nsigma0_do
=
args
.
truncate_nsigma0_do
## EVALUATE SPECTRUM CHI2 IN Q_0 - x*sigma_0 < Q < Q_0 + 2*sigma_0
truncate_nsigma0_do
=
2.0
## EVALUATE SPECTRUM CHI2 IN Q_0 - x*sigma_0 < Q < Q_0 + 2*sigma_0
prefit_only
=
args
.
prefit_only
## FIT THE WHOLE SPECTRUM
prefit_only
=
False
## FIT THE WHOLE SPECTRUM
...
@@ -33,7 +47,8 @@ out_dict = {}
...
@@ -33,7 +47,8 @@ out_dict = {}
files_to_fit
=
[]
files_to_fit
=
[]
## Find all histograms in directory
## Find all histograms in directory
for
root
,
dirs
,
files
in
os
.
walk
(
"
./data/hamamatsu_pcb6/Light
"
):
folder
=
args
.
folder
for
root
,
dirs
,
files
in
os
.
walk
(
folder
):
for
file
in
files
:
for
file
in
files
:
...
...
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