diff --git a/fuse/context.py b/fuse/context.py index 765a8580..17097053 100644 --- a/fuse/context.py +++ b/fuse/context.py @@ -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" @@ -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): @@ -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) @@ -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 diff --git a/fuse/plugins/__init__.py b/fuse/plugins/__init__.py index cc298898..bebf6792 100644 --- a/fuse/plugins/__init__.py +++ b/fuse/plugins/__init__.py @@ -9,3 +9,6 @@ from . import truth_information from .truth_information import * + +from . import processing +from .processing import * diff --git a/fuse/plugins/processing/__init__.py b/fuse/plugins/processing/__init__.py new file mode 100644 index 00000000..40e00983 --- /dev/null +++ b/fuse/plugins/processing/__init__.py @@ -0,0 +1,2 @@ +from . import corrected_areas +from .corrected_areas import * diff --git a/fuse/plugins/processing/corrected_areas.py b/fuse/plugins/processing/corrected_areas.py new file mode 100644 index 00000000..4fae1ba5 --- /dev/null +++ b/fuse/plugins/processing/corrected_areas.py @@ -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