From fceabff7b3cfe54e00f9e89b0d3a018b5b1e8904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henning=20Schulze=20Ei=C3=9Fing?= Date: Thu, 1 Feb 2024 09:37:51 +0100 Subject: [PATCH] Use CamelCase for base plugins --- fuse/plugin.py | 5 +-- fuse/plugins/detector_physics/csv_input.py | 4 +-- .../detector_physics/electron_drift.py | 4 +-- .../detector_physics/electron_extraction.py | 4 +-- .../detector_physics/electron_timing.py | 4 +-- .../detector_physics/s1_photon_hits.py | 4 +-- .../detector_physics/s1_photon_propagation.py | 4 +-- .../detector_physics/s2_photon_propagation.py | 4 +-- .../secondary_scintillation.py | 4 +-- fuse/plugins/micro_physics/electric_field.py | 4 +-- fuse/plugins/micro_physics/find_cluster.py | 4 +-- fuse/plugins/micro_physics/input.py | 4 +-- fuse/plugins/micro_physics/merge_cluster.py | 4 +-- .../micro_physics/microphysics_summary.py | 2 -- .../plugins/micro_physics/wfsim_connection.py | 23 +++---------- fuse/plugins/micro_physics/yields.py | 32 +++---------------- fuse/plugins/pmt_and_daq/photon_pulses.py | 4 +-- fuse/plugins/pmt_and_daq/pmt_afterpulses.py | 4 +-- .../pmt_and_daq/pmt_response_and_daq.py | 4 +-- fuse/vertical_merger_plugin.py | 4 +-- 20 files changed, 43 insertions(+), 83 deletions(-) diff --git a/fuse/plugin.py b/fuse/plugin.py index ef471b78..21ad72b0 100644 --- a/fuse/plugin.py +++ b/fuse/plugin.py @@ -5,7 +5,7 @@ logging.basicConfig(handlers=[logging.StreamHandler()]) -class fuseBasePlugin(strax.Plugin): +class FuseBasePlugin(strax.Plugin): """Base plugin for fuse plugins""" @@ -27,6 +27,7 @@ class fuseBasePlugin(strax.Plugin): ) def setup(self): + super().setup() log = logging.getLogger(f"{self.__class__.__name__}") @@ -45,7 +46,7 @@ def setup(self): self.rng = np.random.default_rng() log.debug(f"Generating random numbers with seed pulled from OS") -class fuseBaseDownChunkingPlugin(strax.DownChunkingPlugin): +class FuseBaseDownChunkingPlugin(strax.DownChunkingPlugin): """Base plugin for fuse DownChunkingPlugins""" diff --git a/fuse/plugins/detector_physics/csv_input.py b/fuse/plugins/detector_physics/csv_input.py index 53a2c4d5..0e3fd6a0 100644 --- a/fuse/plugins/detector_physics/csv_input.py +++ b/fuse/plugins/detector_physics/csv_input.py @@ -6,7 +6,7 @@ import numpy as np from ...common import dynamic_chunking -from ...plugin import fuseBasePlugin +from ...plugin import FuseBasePlugin export, __all__ = strax.exporter() @@ -14,7 +14,7 @@ log = logging.getLogger('fuse.detector_physics.csv_input') @export -class ChunkCsvInput(fuseBasePlugin): +class ChunkCsvInput(FuseBasePlugin): """ Plugin which reads a CSV file containing instructions for the detector physics simulation and returns the data in chunks diff --git a/fuse/plugins/detector_physics/electron_drift.py b/fuse/plugins/detector_physics/electron_drift.py index 3bbc5ef4..6813145a 100644 --- a/fuse/plugins/detector_physics/electron_drift.py +++ b/fuse/plugins/detector_physics/electron_drift.py @@ -3,7 +3,7 @@ import straxen import logging -from ...plugin import fuseBasePlugin +from ...plugin import FuseBasePlugin export, __all__ = strax.exporter() @@ -11,7 +11,7 @@ log = logging.getLogger('fuse.detector_physics.electron_drift') @export -class ElectronDrift(fuseBasePlugin): +class ElectronDrift(FuseBasePlugin): __version__ = "0.1.4" diff --git a/fuse/plugins/detector_physics/electron_extraction.py b/fuse/plugins/detector_physics/electron_extraction.py index 00f3ab00..c083bd9d 100644 --- a/fuse/plugins/detector_physics/electron_extraction.py +++ b/fuse/plugins/detector_physics/electron_extraction.py @@ -4,7 +4,7 @@ import os import logging -from ...plugin import fuseBasePlugin +from ...plugin import FuseBasePlugin export, __all__ = strax.exporter() @@ -12,7 +12,7 @@ log = logging.getLogger('fuse.detector_physics.electron_extraction') @export -class ElectronExtraction(fuseBasePlugin): +class ElectronExtraction(FuseBasePlugin): __version__ = "0.1.3" diff --git a/fuse/plugins/detector_physics/electron_timing.py b/fuse/plugins/detector_physics/electron_timing.py index 0d895484..6219a9d5 100644 --- a/fuse/plugins/detector_physics/electron_timing.py +++ b/fuse/plugins/detector_physics/electron_timing.py @@ -3,7 +3,7 @@ import straxen import logging -from ...plugin import fuseBasePlugin +from ...plugin import FuseBasePlugin export, __all__ = strax.exporter() @@ -11,7 +11,7 @@ log = logging.getLogger('fuse.detector_physics.electron_timing') @export -class ElectronTiming(fuseBasePlugin): +class ElectronTiming(FuseBasePlugin): __version__ = "0.1.1" diff --git a/fuse/plugins/detector_physics/s1_photon_hits.py b/fuse/plugins/detector_physics/s1_photon_hits.py index 804e1b36..48d04f92 100644 --- a/fuse/plugins/detector_physics/s1_photon_hits.py +++ b/fuse/plugins/detector_physics/s1_photon_hits.py @@ -6,7 +6,7 @@ from copy import deepcopy from ...common import pmt_gains -from ...plugin import fuseBasePlugin +from ...plugin import FuseBasePlugin export, __all__ = strax.exporter() @@ -14,7 +14,7 @@ log = logging.getLogger('fuse.detector_physics.s1_photon_hits') @export -class S1PhotonHits(fuseBasePlugin): +class S1PhotonHits(FuseBasePlugin): __version__ = '0.1.3' diff --git a/fuse/plugins/detector_physics/s1_photon_propagation.py b/fuse/plugins/detector_physics/s1_photon_propagation.py index 47447999..875521fc 100644 --- a/fuse/plugins/detector_physics/s1_photon_propagation.py +++ b/fuse/plugins/detector_physics/s1_photon_propagation.py @@ -6,7 +6,7 @@ from ...common import pmt_gains, build_photon_propagation_output from ...common import init_spe_scaling_factor_distributions, pmt_transit_time_spread, photon_gain_calculation -from ...plugin import fuseBasePlugin +from ...plugin import FuseBasePlugin export, __all__ = strax.exporter() @@ -18,7 +18,7 @@ nest_rng = nestpy.RandomGen.rndm() @export -class S1PhotonPropagationBase(fuseBasePlugin): +class S1PhotonPropagationBase(FuseBasePlugin): __version__ = "0.1.3" diff --git a/fuse/plugins/detector_physics/s2_photon_propagation.py b/fuse/plugins/detector_physics/s2_photon_propagation.py index 4fcbd03b..9bb7d542 100644 --- a/fuse/plugins/detector_physics/s2_photon_propagation.py +++ b/fuse/plugins/detector_physics/s2_photon_propagation.py @@ -11,7 +11,7 @@ from ...common import pmt_gains, build_photon_propagation_output from ...common import init_spe_scaling_factor_distributions, pmt_transit_time_spread, photon_gain_calculation -from ...plugin import fuseBaseDownChunkingPlugin +from ...plugin import FuseBaseDownChunkingPlugin logging.basicConfig(handlers=[logging.StreamHandler()]) log = logging.getLogger('fuse.detector_physics.s2_photon_propagation') @@ -19,7 +19,7 @@ conversion_to_bar = 1/constants.elementary_charge / 1e1 @export -class S2PhotonPropagationBase(fuseBaseDownChunkingPlugin): +class S2PhotonPropagationBase(FuseBaseDownChunkingPlugin): __version__ = "0.1.4" diff --git a/fuse/plugins/detector_physics/secondary_scintillation.py b/fuse/plugins/detector_physics/secondary_scintillation.py index cf3f0b3b..5d11f8b7 100644 --- a/fuse/plugins/detector_physics/secondary_scintillation.py +++ b/fuse/plugins/detector_physics/secondary_scintillation.py @@ -5,7 +5,7 @@ from immutabledict import immutabledict from ...common import pmt_gains -from ...plugin import fuseBasePlugin +from ...plugin import FuseBasePlugin export, __all__ = strax.exporter() @@ -13,7 +13,7 @@ log = logging.getLogger('fuse.detector_physics.secondary_scintillation') @export -class SecondaryScintillation(fuseBasePlugin): +class SecondaryScintillation(FuseBasePlugin): __version__ = "0.1.3" diff --git a/fuse/plugins/micro_physics/electric_field.py b/fuse/plugins/micro_physics/electric_field.py index d500428d..9f0981be 100644 --- a/fuse/plugins/micro_physics/electric_field.py +++ b/fuse/plugins/micro_physics/electric_field.py @@ -3,7 +3,7 @@ import logging import straxen -from ...plugin import fuseBasePlugin +from ...plugin import FuseBasePlugin export, __all__ = strax.exporter() @@ -11,7 +11,7 @@ log = logging.getLogger('fuse.micro_physics.electric_field') @export -class ElectricField(fuseBasePlugin): +class ElectricField(FuseBasePlugin): """ Plugin that calculates the electric field values for the cluster position. """ diff --git a/fuse/plugins/micro_physics/find_cluster.py b/fuse/plugins/micro_physics/find_cluster.py index c44dbfa5..76855e0f 100644 --- a/fuse/plugins/micro_physics/find_cluster.py +++ b/fuse/plugins/micro_physics/find_cluster.py @@ -9,13 +9,13 @@ export, __all__ = strax.exporter() -from ...plugin import fuseBasePlugin +from ...plugin import FuseBasePlugin logging.basicConfig(handlers=[logging.StreamHandler()]) log = logging.getLogger('fuse.micro_physics.find_cluster') @export -class FindCluster(fuseBasePlugin): +class FindCluster(FuseBasePlugin): __version__ = "0.1.1" diff --git a/fuse/plugins/micro_physics/input.py b/fuse/plugins/micro_physics/input.py index 0e2241d6..64244072 100644 --- a/fuse/plugins/micro_physics/input.py +++ b/fuse/plugins/micro_physics/input.py @@ -11,14 +11,14 @@ export, __all__ = strax.exporter() from ...common import full_array_to_numpy, reshape_awkward, dynamic_chunking -from ...plugin import fuseBasePlugin +from ...plugin import FuseBasePlugin logging.basicConfig(handlers=[logging.StreamHandler()]) log = logging.getLogger('fuse.micro_physics.input') #Remove the path and file name option from the config and do this with the run_number?? @export -class ChunkInput(fuseBasePlugin): +class ChunkInput(FuseBasePlugin): __version__ = "0.1.2" diff --git a/fuse/plugins/micro_physics/merge_cluster.py b/fuse/plugins/micro_physics/merge_cluster.py index 130dd176..fac85e11 100644 --- a/fuse/plugins/micro_physics/merge_cluster.py +++ b/fuse/plugins/micro_physics/merge_cluster.py @@ -6,13 +6,13 @@ export, __all__ = strax.exporter() -from ...plugin import fuseBasePlugin +from ...plugin import FuseBasePlugin logging.basicConfig(handlers=[logging.StreamHandler()]) log = logging.getLogger('fuse.micro_physics.merge_cluster') @export -class MergeCluster(fuseBasePlugin): +class MergeCluster(FuseBasePlugin): __version__ = "0.1.1" diff --git a/fuse/plugins/micro_physics/microphysics_summary.py b/fuse/plugins/micro_physics/microphysics_summary.py index 7c09882a..77993ac9 100644 --- a/fuse/plugins/micro_physics/microphysics_summary.py +++ b/fuse/plugins/micro_physics/microphysics_summary.py @@ -2,8 +2,6 @@ export, __all__ = strax.exporter() -from ...common import FUSE_PLUGIN_TIMEOUT - @export class MicroPhysicsSummary(strax.MergeOnlyPlugin): """ diff --git a/fuse/plugins/micro_physics/wfsim_connection.py b/fuse/plugins/micro_physics/wfsim_connection.py index e673e457..ad989fed 100644 --- a/fuse/plugins/micro_physics/wfsim_connection.py +++ b/fuse/plugins/micro_physics/wfsim_connection.py @@ -9,13 +9,14 @@ export, __all__ = strax.exporter() -from ...common import offset_range, reshape_awkward, FUSE_PLUGIN_TIMEOUT +from ...common import offset_range, reshape_awkward +from ...plugin import FuseBasePlugin logging.basicConfig(handlers=[logging.StreamHandler()]) log = logging.getLogger('fuse.micro_physics.output') @export -class output_plugin(strax.Plugin): +class output_plugin(FuseBasePlugin): __version__ = "0.1.0" @@ -24,12 +25,7 @@ class output_plugin(strax.Plugin): provides = "wfsim_instructions" data_kind = 'wfsim_instructions' - #Forbid rechunking - rechunk_on_save = False - save_when = strax.SaveWhen.TARGET - - input_timeout = FUSE_PLUGIN_TIMEOUT dtype = [(('Waveform simulator event number.', 'event_number'), np.int32), (('Quanta type (S1 photons or S2 electrons)', 'type'), np.int8), @@ -50,19 +46,8 @@ class output_plugin(strax.Plugin): (('Z position of the primary particle [cm]', 'z_pri'), np.float32), ] - #Config options - debug = straxen.URLConfig( - default=False, type=bool,track=False, - help='Show debug informations', - ) - def setup(self): - - if self.debug: - log.setLevel('DEBUG') - log.debug(f"Running output_plugin version {self.__version__} in debug mode") - else: - log.setLevel('INFO') + super().setup() def compute(self, interactions_in_roi): diff --git a/fuse/plugins/micro_physics/yields.py b/fuse/plugins/micro_physics/yields.py index 5c32550f..ca50c0b1 100644 --- a/fuse/plugins/micro_physics/yields.py +++ b/fuse/plugins/micro_physics/yields.py @@ -5,7 +5,7 @@ import logging import pickle -from ...plugin import fuseBasePlugin +from ...plugin import FuseBasePlugin export, __all__ = strax.exporter() @@ -17,7 +17,7 @@ nest_rng = nestpy.RandomGen.rndm() @export -class NestYields(fuseBasePlugin): +class NestYields(FuseBasePlugin): __version__ = "0.1.2" @@ -291,7 +291,7 @@ def get_quanta(self, energy, field): -class BBFYields(strax.Plugin): +class BBFYields(FuseBasePlugin): __version__ = "0.1.1" @@ -305,33 +305,9 @@ class BBFYields(strax.Plugin): dtype = dtype + strax.time_fields - #Config options - debug = straxen.URLConfig( - default=False, type=bool, - help='Show debug informations', - ) - - deterministic_seed = straxen.URLConfig( - default=True, type=bool, - help='Set the random seed from lineage and run_id, or pull the seed from the OS.', - ) - def setup(self): - if self.debug: - log.setLevel("DEBUG") - log.debug(f"Running BBFYields version {self.__version__} in debug mode") - else: - log.setLevel('WARNING') - - if self.deterministic_seed: - hash_string = strax.deterministic_hash((self.run_id, self.lineage)) - seed = int(hash_string.encode().hex(), 16) - self.rng = np.random.default_rng(seed = seed) - log.debug(f"Generating random numbers from seed {seed}") - else: - self.rng = np.random.default_rng() - log.debug(f"Generating random numbers with seed pulled from OS") + super().setup() self.bbfyields = BBF_quanta_generator(self.rng) diff --git a/fuse/plugins/pmt_and_daq/photon_pulses.py b/fuse/plugins/pmt_and_daq/photon_pulses.py index 42631931..b311a5a5 100644 --- a/fuse/plugins/pmt_and_daq/photon_pulses.py +++ b/fuse/plugins/pmt_and_daq/photon_pulses.py @@ -6,13 +6,13 @@ export, __all__ = strax.exporter() -from ...plugin import fuseBasePlugin +from ...plugin import FuseBasePlugin logging.basicConfig(handlers=[logging.StreamHandler()]) log = logging.getLogger('fuse.pmt_and_daq.photon_pulses') @export -class PulseWindow(fuseBasePlugin): +class PulseWindow(FuseBasePlugin): __version__ = "0.1.2" diff --git a/fuse/plugins/pmt_and_daq/pmt_afterpulses.py b/fuse/plugins/pmt_and_daq/pmt_afterpulses.py index 745a8f57..323100e4 100644 --- a/fuse/plugins/pmt_and_daq/pmt_afterpulses.py +++ b/fuse/plugins/pmt_and_daq/pmt_afterpulses.py @@ -4,7 +4,7 @@ import logging from ...common import pmt_gains -from ...plugin import fuseBasePlugin +from ...plugin import FuseBasePlugin export, __all__ = strax.exporter() @@ -12,7 +12,7 @@ log = logging.getLogger('fuse.pmt_and_daq.pmt_afterpulses') @export -class PMTAfterPulses(fuseBasePlugin): +class PMTAfterPulses(FuseBasePlugin): __version__ = "0.1.2" diff --git a/fuse/plugins/pmt_and_daq/pmt_response_and_daq.py b/fuse/plugins/pmt_and_daq/pmt_response_and_daq.py index 1d10546e..5fe8f032 100644 --- a/fuse/plugins/pmt_and_daq/pmt_response_and_daq.py +++ b/fuse/plugins/pmt_and_daq/pmt_response_and_daq.py @@ -9,13 +9,13 @@ export, __all__ = strax.exporter() -from ...plugin import fuseBaseDownChunkingPlugin +from ...plugin import FuseBaseDownChunkingPlugin logging.basicConfig(handlers=[logging.StreamHandler()]) log = logging.getLogger('fuse.pmt_and_daq.pmt_response_and_daq') @export -class PMTResponseAndDAQ(fuseBaseDownChunkingPlugin): +class PMTResponseAndDAQ(FuseBaseDownChunkingPlugin): __version__ = "0.1.3" diff --git a/fuse/vertical_merger_plugin.py b/fuse/vertical_merger_plugin.py index f1014388..f5d02e2a 100644 --- a/fuse/vertical_merger_plugin.py +++ b/fuse/vertical_merger_plugin.py @@ -3,9 +3,9 @@ import numpy as np from itertools import groupby -from .plugin import fuseBasePlugin +from .plugin import FuseBasePlugin -class VerticalMergerPlugin(fuseBasePlugin): +class VerticalMergerPlugin(FuseBasePlugin): "Plugin that concatenates data from the dependencies along the fist axis" save_when = strax.SaveWhen.TARGET