-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added peak tagging plugin #487
Conversation
straxen/plugins/peak_processing.py
Outdated
|
||
|
||
class PeakVetoTagging(strax.Plugin): | ||
"""Plugin which tags S1 peaks according to the muon and neutron-veto. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D204 1 blank line required after class docstring
straxen/plugins/peak_processing.py
Outdated
|
||
|
||
class PeakVetoTagging(strax.Plugin): | ||
"""Plugin which tags S1 peaks according to the muon and neutron-veto. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D208 Docstring is over-indented
def tag_peaks(tags, touching_windows, tag_number): | ||
pre_tags = np.zeros(len(tags), dtype=np.int8) | ||
for start, end in touching_windows: | ||
pre_tags[start:end] = tag_number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
WPS362 Found assignment to a subscript slice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought you requested my review but it appears to be still a draft. Here some minor comments/suggestions but I'll re-review after it's undrafted
""" | ||
depends_on = ['events', | ||
'event_basics', | ||
'event_positions', | ||
'corrected_areas', | ||
'energy_estimates', | ||
# 'event_pattern_fit', <- this will be added soon | ||
] | ||
save_when = strax.SaveWhen.ALWAYS | ||
provides = 'event_info' | ||
__version__ = '0.0.1' | ||
|
||
def compute(self, **kwargs): | ||
event_info_function = self.config['event_info_function'] | ||
event_info = super().compute(**kwargs) | ||
if event_info_function != 'disabled': | ||
event_info = pre_apply_function(event_info, | ||
self.run_id, | ||
self.provides, | ||
event_info_function, | ||
) | ||
return event_info | ||
|
||
|
||
@export | ||
class EventInfo1T(strax.MergeOnlyPlugin): | ||
""" | ||
Plugin which merges the information of all event data_kinds into a | ||
single data_type. | ||
|
||
This only uses 1T data-types as several event-plugins are nT only | ||
""" | ||
depends_on = ['events', | ||
'event_basics', | ||
'event_positions', | ||
'corrected_areas', | ||
'energy_estimates'] | ||
provides = 'event_info' | ||
save_when = strax.SaveWhen.ALWAYS | ||
__version__ = '0.0.0' | ||
import strax | ||
from straxen import pre_apply_function | ||
|
||
import numpy as np | ||
import numba | ||
export, __all__ = strax.exporter() | ||
|
||
|
||
@export | ||
@strax.takes_config( | ||
strax.Option( | ||
name='event_info_function', | ||
default='pre_apply_function', | ||
help="Function that must be applied to all event_info data. Do not change.", | ||
) | ||
) | ||
class EventInfo(strax.MergeOnlyPlugin): | ||
""" | ||
Plugin which merges the information of all event data_kinds into a | ||
single data_type. | ||
""" | ||
depends_on = ['events', | ||
'event_basics', | ||
'event_positions', | ||
'corrected_areas', | ||
'energy_estimates', | ||
# 'event_pattern_fit', <- this will be added soon | ||
] | ||
save_when = strax.SaveWhen.ALWAYS | ||
provides = 'event_info' | ||
__version__ = '0.0.1' | ||
|
||
def compute(self, **kwargs): | ||
event_info_function = self.config['event_info_function'] | ||
event_info = super().compute(**kwargs) | ||
if event_info_function != 'disabled': | ||
event_info = pre_apply_function(event_info, | ||
self.run_id, | ||
self.provides, | ||
event_info_function, | ||
) | ||
return event_info | ||
|
||
|
||
@export | ||
class EventInfo1T(strax.MergeOnlyPlugin): | ||
""" | ||
Plugin which merges the information of all event data_kinds into a | ||
single data_type. | ||
|
||
This only uses 1T data-types as several event-plugins are nT only | ||
""" | ||
depends_on = ['events', | ||
'event_basics', | ||
'event_positions', | ||
'corrected_areas', | ||
'energy_estimates'] | ||
provides = 'event_info' | ||
save_when = strax.SaveWhen.ALWAYS | ||
__version__ = '0.0.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to revert this to conserve the git history?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ups yes, for sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm somehow it is not revertible. I guess I will have to make a new branch....
""" | ||
vetos = np.zeros(len(veto_intervals)+2, np.int64) | ||
vetos[1:-1] = veto_intervals['time'] | ||
vetos[-1] = 9223372036854775807 # 64 bit infinity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps we could re-use https://github.com/XENONnT/straxen/blob/master/straxen/plugins/acqmon_processing.py#L10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but I would put also "infinity" there. @AlexElykov do you see any problem if we replace the 1h in T_NO_VETO_FOUND
by a 64 bit infinity? 1 h is a bit arbitrary.
Co-authored-by: Joran Angevaare <jorana@nikhef.nl>
Co-authored-by: Joran Angevaare <jorana@nikhef.nl>
Co-authored-by: Joran Angevaare <jorana@nikhef.nl>
This reverts commit 4f09bdf.
* Modificatons of nT simulation context * Throwing some whitespae bones to the doggy * some changes to make Daniel a bit happier, but still leeping shorter lines * Changes to error and docstring * actually, there should be break here * Small modification in the loop * Empty line to redo codefactor * Hopefully, this is the correct way to fix codefactor complain Co-authored-by: Daniel Wenz <43881800+WenzDaniel@users.noreply.github.com>
* Increase buffer size * Please review dog Co-authored-by: Joran Angevaare <jorana@nikhef.nl>
Bumps [tqdm](https://github.com/tqdm/tqdm) from 4.61.1 to 4.62.0. - [Release notes](https://github.com/tqdm/tqdm/releases) - [Commits](tqdm/tqdm@v4.61.1...v4.62.0) --- updated-dependencies: - dependency-name: tqdm dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [utilix](https://github.com/XENONnT/utilix) from 0.6.0 to 0.6.1. - [Release notes](https://github.com/XENONnT/utilix/releases) - [Changelog](https://github.com/XENONnT/utilix/blob/master/HISTORY.md) - [Commits](XENONnT/utilix@v0.6.0...v0.6.1) --- updated-dependencies: - dependency-name: utilix dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Joran Angevaare <jorana@nikhef.nl>
Bumps [coveralls](https://github.com/TheKevJames/coveralls-python) from 3.1.0 to 3.2.0. - [Release notes](https://github.com/TheKevJames/coveralls-python/releases) - [Changelog](https://github.com/TheKevJames/coveralls-python/blob/master/CHANGELOG.md) - [Commits](TheKevJames/coveralls-python@3.1.0...3.2.0) --- updated-dependencies: - dependency-name: coveralls dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Joran Angevaare <jorana@nikhef.nl>
Bumps [holoviews](https://github.com/holoviz/holoviews) from 1.14.4 to 1.14.5. - [Release notes](https://github.com/holoviz/holoviews/releases) - [Changelog](https://github.com/holoviz/holoviews/blob/master/CHANGELOG.md) - [Commits](holoviz/holoviews@v1.14.4...v1.14.5) --- updated-dependencies: - dependency-name: holoviews dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Joran Angevaare <jorana@nikhef.nl>
…nts (#609) Updates the requirements on [dask](https://github.com/dask/dask) to permit the latest version. - [Release notes](https://github.com/dask/dask/releases) - [Changelog](https://github.com/dask/dask/blob/main/docs/release-procedure.md) - [Commits](dask/dask@2021.06.0...2021.07.2) --- updated-dependencies: - dependency-name: dask dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Joran Angevaare <jorana@nikhef.nl>
Bumps [hypothesis](https://github.com/HypothesisWorks/hypothesis) from 6.14.0 to 6.14.5. - [Release notes](https://github.com/HypothesisWorks/hypothesis/releases) - [Commits](HypothesisWorks/hypothesis@hypothesis-python-6.14.0...hypothesis-python-6.14.5) --- updated-dependencies: - dependency-name: hypothesis dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Joran Angevaare <jorana@nikhef.nl>
* Bump xarray from 0.16.2 to 0.19.0 in /extra_requirements Bumps [xarray](https://github.com/pydata/xarray) from 0.16.2 to 0.19.0. - [Release notes](https://github.com/pydata/xarray/releases) - [Changelog](https://github.com/pydata/xarray/blob/main/HOW_TO_RELEASE.md) - [Commits](pydata/xarray@v0.16.2...v0.19.0) --- updated-dependencies: - dependency-name: xarray dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update requirements-tests.txt Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Joran Angevaare <jorana@nikhef.nl>
) Bumps [importlib-metadata](https://github.com/python/importlib_metadata) from 4.6.0 to 4.6.3. - [Release notes](https://github.com/python/importlib_metadata/releases) - [Changelog](https://github.com/python/importlib_metadata/blob/main/CHANGES.rst) - [Commits](python/importlib_metadata@v4.6.0...v4.6.3) --- updated-dependencies: - dependency-name: importlib-metadata dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Joran Angevaare <jorana@nikhef.nl>
Co-authored-by: Joran Angevaare <jorana@nikhef.nl>
Co-authored-by: Joran Angevaare <jorana@nikhef.nl>
Co-authored-by: Joran Angevaare <jorana@nikhef.nl>
This reverts commit 4f09bdf.
Somehow it is not possible to clean the git history. I made a new branch. See #618 |
What is the problem / what does the code in this PR do
In this PR we add the Peak counterpart for the veto regions plugins which are added in #465. The working principle is simple. We tag all S1 peaks which touch one of the veto regions. The tag is cumulative in case both veto systems issued a veto signal. In addition we are computing the time difference to the closest veto interval.
Proposed Dependency structure:
To minimize the interference with TPC processing two new data_types are introduced. One at the peak level and one above event_info. They are shown in the subsequent figure.
In this way we can process the TPC up to event_info without the need of having the data of the vetos already processed. Both data types are only save when asked, e.g. for dedicated studies about the optimization of the veto interval length. Computational wise are both plugins very light weighted.