Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OrcaSong
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Machine Learning
OrcaSong
Commits
4689f043
Commit
4689f043
authored
5 years ago
by
Nicole Geisselbrecht
Browse files
Options
Downloads
Patches
Plain Diff
Added charge as weights for histogram.
parent
4c3328fb
No related branches found
No related tags found
1 merge request
!7
Resolve "Add charge as weights for histogram"
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
orcasong/core.py
+8
-2
8 additions, 2 deletions
orcasong/core.py
orcasong/modules.py
+9
-1
9 additions, 1 deletion
orcasong/modules.py
with
17 additions
and
3 deletions
orcasong/core.py
+
8
−
2
View file @
4689f043
...
...
@@ -56,7 +56,8 @@ class FileBinner:
chunksize
=
32
,
keep_event_info
=
True
,
keep_mc_tracks
=
False
,
add_t0
=
False
,):
add_t0
=
False
,
use_charge_as_weights
=
False
):
"""
Parameters
----------
...
...
@@ -97,6 +98,8 @@ class FileBinner:
add_t0 : bool
If true, add t0 to the time of hits. If using a det_file,
this will already have been done automatically [default: False].
use_charge_as_weights : bool
If true, uses blob[
"
Hits
"
][
"
charge
"
] as weights for histogram. [default: False]
"""
self
.
bin_edges_list
=
bin_edges_list
...
...
@@ -121,6 +124,8 @@ class FileBinner:
self
.
complevel
=
1
self
.
flush_frequency
=
1000
self
.
use_charge_as_weights
=
use_charge_as_weights
def
run
(
self
,
infile
,
outfile
=
None
,
save_plot
=
False
):
"""
Generate images from the infile, and save them as the outfile.
...
...
@@ -261,7 +266,8 @@ class FileBinner:
pipe
.
attach
(
modules
.
ImageMaker
,
bin_edges_list
=
self
.
bin_edges_list
,
store_as
=
name_histogram
)
store_as
=
name_histogram
,
use_charge_as_weights
=
self
.
use_charge_as_weights
)
if
self
.
mc_info_extr
is
not
None
:
if
isinstance
(
self
.
mc_info_extr
,
str
):
...
...
This diff is collapsed.
Click to expand it.
orcasong/modules.py
+
9
−
1
View file @
4689f043
...
...
@@ -117,12 +117,15 @@ class ImageMaker(kp.Module):
including the left- and right-most bin edge.
store_as : str
Store the images with this name in the blob.
use_charge_as_weights : bool
If true, uses blob[
"
Hits
"
][
"
charge
"
] as weights for histogram.
"""
def
configure
(
self
):
self
.
bin_edges_list
=
self
.
require
(
'
bin_edges_list
'
)
self
.
store_as
=
self
.
require
(
'
store_as
'
)
self
.
use_charge_as_weights
=
self
.
get
(
'
use_charge_as_weights
'
)
def
process
(
self
,
blob
):
data
,
bins
,
name
=
[],
[],
""
...
...
@@ -132,7 +135,12 @@ class ImageMaker(kp.Module):
bins
.
append
(
bin_edges
)
name
+=
bin_name
+
"
_
"
histogram
=
np
.
histogramdd
(
data
,
bins
=
bins
)[
0
]
if
self
.
use_charge_as_weights
:
weights
=
blob
[
"
Hits
"
][
"
charge
"
]
else
:
weights
=
None
histogram
=
np
.
histogramdd
(
data
,
bins
=
bins
,
weights
=
weights
)[
0
]
title
=
name
+
"
event_images
"
hist_one_event
=
histogram
[
np
.
newaxis
,
...].
astype
(
np
.
uint8
)
...
...
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