Skip to content

Commit

Permalink
Area correction override (#269)
Browse files Browse the repository at this point in the history
* Draft for processing override

* Set logging to info when setting up the context

* Add alt fields and extend the docstring.

---------

Co-authored-by: Diego Ramírez García <[email protected]>
  • Loading branch information
HenningSE and ramirezdiego authored Oct 16, 2024
1 parent fd40b75 commit 205afa5
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
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

0 comments on commit 205afa5

Please sign in to comment.