Skip to content
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

Corrections override #269

Merged
merged 5 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions fuse/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@
fuse.truth_information.ClusterTagging,
]

# Plugins to override the default processing plugins in straxen
processing_plugins = [
fuse.processing.CorrectedAreasMC,
]


def microphysics_context(
output_folder="./fuse_data", simulation_config_file="fuse_config_nt_sr1_dev.json"
Expand Down Expand Up @@ -130,6 +135,9 @@ def full_chain_context(
):
"""Function to create a fuse full chain simulation context."""

# Lets go for info level logging when working with fuse
log.setLevel("INFO")

if corrections_run_id is None:
raise ValueError("Specify a corrections_run_id to load the corrections")
if (corrections_version is None) & (not run_without_proper_corrections):
Expand Down Expand Up @@ -194,6 +202,12 @@ def full_chain_context(
for plugin in truth_information_plugins:
st.register(plugin)

# Register processing plugins
log.info("Overriding processing plugins:")
for plugin in processing_plugins:
log.info(f"Registering {plugin}")
st.register(plugin)

if corrections_version is not None:
st.apply_xedocs_configs(version=corrections_version)

Expand Down Expand Up @@ -221,6 +235,9 @@ def full_chain_context(
# Deregister plugins with missing dependencies
st.deregister_plugins_with_missing_dependencies()

# Purge unused configs
st.purge_unused_configs()

return st


Expand Down
3 changes: 3 additions & 0 deletions fuse/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@

from . import truth_information
from .truth_information import *

from . import processing
from .processing import *
2 changes: 2 additions & 0 deletions fuse/plugins/processing/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import corrected_areas
from .corrected_areas import *
32 changes: 32 additions & 0 deletions fuse/plugins/processing/corrected_areas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import strax
import straxen

export, __all__ = strax.exporter()


@export
class CorrectedAreasMC(straxen.CorrectedAreas):
"""Corrected areas plugin for MC data.

This plugin overwrites the (alt_)cs1 and (alt_)cs2 fields with the
not-time- corrected values as the effects of time dependent single-
electron gain, extraction efficiency and photo ionization are not
simulated in fuse.

Applying corrections for these effects to simulated data would lead
to incorrect results. This plugins should only be used for simulated
data!
"""

__version__ = "0.0.1"
child_plugin = True

def compute(self, events):
result = super().compute(events)
result["cs1"] = result["cs1_wo_timecorr"]
result["cs2"] = result["cs2_wo_timecorr"]

result["alt_cs1"] = result["alt_cs1_wo_timecorr"]
result["alt_cs2"] = result["alt_cs2_wo_timecorr"]

return result
Loading