Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fadc_decoder
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zhiwen Zhao
fadc_decoder
Commits
5b7cc571
Commit
5b7cc571
authored
5 years ago
by
Chao Peng
Browse files
Options
Downloads
Patches
Plain Diff
update analysis script
parent
6f5f1730
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/analyze_waveform.py
+4
-15
4 additions, 15 deletions
scripts/analyze_waveform.py
with
4 additions
and
15 deletions
scripts/analyze_waveform.py
+
4
−
15
View file @
5b7cc571
...
@@ -58,9 +58,8 @@ f = ROOT.TFile.Open(args.root_file, 'read')
...
@@ -58,9 +58,8 @@ f = ROOT.TFile.Open(args.root_file, 'read')
tree
=
f
.
EvTree
tree
=
f
.
EvTree
trg_ch
=
np
.
ndarray
(
shape
=
(
tree
.
GetEntries
(),
),
dtype
=
object
)
trg_ch
=
np
.
ndarray
(
shape
=
(
tree
.
GetEntries
(),
),
dtype
=
object
)
trg_val
=
np
.
ndarray
(
shape
=
(
tree
.
GetEntries
(),
2
),
dtype
=
'
float64
'
)
trg_val
=
np
.
ndarray
(
shape
=
(
tree
.
GetEntries
(),
3
),
dtype
=
'
float64
'
)
ch_val
=
np
.
ndarray
(
shape
=
(
tree
.
GetEntries
(),
len
(
ch
)
*
2
),
dtype
=
'
float64
'
)
ch_val
=
np
.
ndarray
(
shape
=
(
tree
.
GetEntries
(),
len
(
ch
)
*
2
),
dtype
=
'
float64
'
)
props
=
{
c
:
[
np
.
array
([]),
np
.
array
([])]
for
c
in
ch
}
for
iev
in
np
.
arange
(
0
,
tree
.
GetEntries
()):
for
iev
in
np
.
arange
(
0
,
tree
.
GetEntries
()):
tree
.
GetEntry
(
iev
)
tree
.
GetEntry
(
iev
)
...
@@ -87,20 +86,18 @@ for iev in np.arange(0, tree.GetEntries()):
...
@@ -87,20 +86,18 @@ for iev in np.arange(0, tree.GetEntries()):
# get the maximum peak from all trigger channels
# get the maximum peak from all trigger channels
ich
=
np
.
argmax
(
ev_trg_peaks
)
ich
=
np
.
argmax
(
ev_trg_peaks
)
trg_ch
[
iev
]
=
tr
[
ich
]
trg_ch
[
iev
]
=
tr
[
ich
]
trg_val
[
iev
]
=
(
ev_trg_peaks
[
ich
],
ev_trg_poses
[
ich
])
trg_val
[
iev
]
=
(
ev_trg_peaks
[
ich
],
ev_trg_poses
[
ich
]
,
len
(
ev_trg_peaks
)
)
# channels
# channels
for
i
,
c
in
enumerate
(
ch
):
for
i
,
c
in
enumerate
(
ch
):
peaks
=
branch_to_array1d
(
tree
.
__getattr__
(
c
+
'
_Ppeak
'
),
np
.
float32
)
peaks
=
branch_to_array1d
(
tree
.
__getattr__
(
c
+
'
_Ppeak
'
),
np
.
float32
)
poses
=
branch_to_array1d
(
tree
.
__getattr__
(
c
+
'
_Ptime
'
),
np
.
float32
)
poses
=
branch_to_array1d
(
tree
.
__getattr__
(
c
+
'
_Ptime
'
),
np
.
float32
)
props
[
c
][
0
]
=
np
.
concatenate
((
props
[
c
][
0
],
peaks
))
props
[
c
][
1
]
=
np
.
concatenate
((
props
[
c
][
1
],
poses
-
ev_trg_poses
[
ich
]))
# check timing
# check timing
cpeak
,
cpos
=
0
,
0
cpeak
,
cpos
=
0
,
0
for
peak
,
pos
in
zip
(
peaks
,
poses
):
for
peak
,
pos
in
zip
(
peaks
,
poses
):
pos
-=
ev_trg_poses
[
ich
]
pos
-=
ev_trg_poses
[
ich
]
if
pos
<=
ch_pos
[
i
]
+
pos_width
and
pos
>=
ch_pos
[
i
]
-
pos_width
and
peak
>
cpeak
:
if
pos
<=
(
ch_pos
[
i
]
+
pos_width
)
and
pos
>=
(
ch_pos
[
i
]
-
pos_width
)
and
peak
>
cpeak
:
cpeak
=
peak
cpeak
=
peak
cpos
=
pos
cpos
=
pos
ch_val
[
iev
][[
i
,
len
(
ch
)
+
i
]]
=
(
cpeak
,
cpos
)
ch_val
[
iev
][[
i
,
len
(
ch
)
+
i
]]
=
(
cpeak
,
cpos
)
...
@@ -109,16 +106,8 @@ print('processed {}'.format(iev))
...
@@ -109,16 +106,8 @@ print('processed {}'.format(iev))
result
=
pd
.
DataFrame
(
index
=
np
.
arange
(
0
,
tree
.
GetEntries
()),
result
=
pd
.
DataFrame
(
index
=
np
.
arange
(
0
,
tree
.
GetEntries
()),
columns
=
[
'
trg_peak
'
,
'
trg_pos
'
]
+
[
c
+
'
_peak
'
for
c
in
ch
]
+
[
c
+
'
_pos
'
for
c
in
ch
],
columns
=
[
'
trg_peak
'
,
'
trg_pos
'
,
'
trg_nhits
'
]
+
[
c
+
'
_peak
'
for
c
in
ch
]
+
[
c
+
'
_pos
'
for
c
in
ch
],
data
=
np
.
concatenate
((
trg_val
,
ch_val
),
axis
=
1
))
data
=
np
.
concatenate
((
trg_val
,
ch_val
),
axis
=
1
))
result
.
loc
[:,
'
trg_ch
'
]
=
trg_ch
result
.
loc
[:,
'
trg_ch
'
]
=
trg_ch
result
.
to_csv
(
args
.
output
)
result
.
to_csv
(
args
.
output
)
bins
=
np
.
arange
(
0
,
5000
,
step
=
1
)
indices
=
(
bins
[
1
:]
+
bins
[:
-
1
])
/
2.
pd
.
DataFrame
(
index
=
indices
,
data
=
{
c
:
np
.
histogram
(
prop
[
0
],
bins
)[
0
]
for
c
,
prop
in
props
.
items
()}).
to_csv
(
'
peaks.csv
'
)
bins
=
np
.
arange
(
-
64
,
64
,
step
=
1
)
indices
=
(
bins
[
1
:]
+
bins
[:
-
1
])
/
2.
pd
.
DataFrame
(
index
=
indices
,
data
=
{
c
:
np
.
histogram
(
prop
[
1
],
bins
)[
0
]
for
c
,
prop
in
props
.
items
()}).
to_csv
(
'
timings.csv
'
)
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