Skip to content

Commit

Permalink
Use CamelCase for base plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
HenningSE committed Feb 1, 2024
1 parent e8f2255 commit fceabff
Show file tree
Hide file tree
Showing 20 changed files with 43 additions and 83 deletions.
5 changes: 3 additions & 2 deletions fuse/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

logging.basicConfig(handlers=[logging.StreamHandler()])

class fuseBasePlugin(strax.Plugin):
class FuseBasePlugin(strax.Plugin):

"""Base plugin for fuse plugins"""

Expand All @@ -27,6 +27,7 @@ class fuseBasePlugin(strax.Plugin):
)

def setup(self):
super().setup()

log = logging.getLogger(f"{self.__class__.__name__}")

Expand All @@ -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"""

Expand Down
4 changes: 2 additions & 2 deletions fuse/plugins/detector_physics/csv_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import numpy as np

from ...common import dynamic_chunking
from ...plugin import fuseBasePlugin
from ...plugin import FuseBasePlugin

export, __all__ = strax.exporter()

logging.basicConfig(handlers=[logging.StreamHandler()])
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
Expand Down
4 changes: 2 additions & 2 deletions fuse/plugins/detector_physics/electron_drift.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import straxen
import logging

from ...plugin import fuseBasePlugin
from ...plugin import FuseBasePlugin

export, __all__ = strax.exporter()

logging.basicConfig(handlers=[logging.StreamHandler()])
log = logging.getLogger('fuse.detector_physics.electron_drift')

@export
class ElectronDrift(fuseBasePlugin):
class ElectronDrift(FuseBasePlugin):

__version__ = "0.1.4"

Expand Down
4 changes: 2 additions & 2 deletions fuse/plugins/detector_physics/electron_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import os
import logging

from ...plugin import fuseBasePlugin
from ...plugin import FuseBasePlugin

export, __all__ = strax.exporter()

logging.basicConfig(handlers=[logging.StreamHandler()])
log = logging.getLogger('fuse.detector_physics.electron_extraction')

@export
class ElectronExtraction(fuseBasePlugin):
class ElectronExtraction(FuseBasePlugin):

__version__ = "0.1.3"

Expand Down
4 changes: 2 additions & 2 deletions fuse/plugins/detector_physics/electron_timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import straxen
import logging

from ...plugin import fuseBasePlugin
from ...plugin import FuseBasePlugin

export, __all__ = strax.exporter()

logging.basicConfig(handlers=[logging.StreamHandler()])
log = logging.getLogger('fuse.detector_physics.electron_timing')

@export
class ElectronTiming(fuseBasePlugin):
class ElectronTiming(FuseBasePlugin):

__version__ = "0.1.1"

Expand Down
4 changes: 2 additions & 2 deletions fuse/plugins/detector_physics/s1_photon_hits.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
from copy import deepcopy

from ...common import pmt_gains
from ...plugin import fuseBasePlugin
from ...plugin import FuseBasePlugin

export, __all__ = strax.exporter()

logging.basicConfig(handlers=[logging.StreamHandler()])
log = logging.getLogger('fuse.detector_physics.s1_photon_hits')

@export
class S1PhotonHits(fuseBasePlugin):
class S1PhotonHits(FuseBasePlugin):

__version__ = '0.1.3'

Expand Down
4 changes: 2 additions & 2 deletions fuse/plugins/detector_physics/s1_photon_propagation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -18,7 +18,7 @@
nest_rng = nestpy.RandomGen.rndm()

@export
class S1PhotonPropagationBase(fuseBasePlugin):
class S1PhotonPropagationBase(FuseBasePlugin):

__version__ = "0.1.3"

Expand Down
4 changes: 2 additions & 2 deletions fuse/plugins/detector_physics/s2_photon_propagation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

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')

conversion_to_bar = 1/constants.elementary_charge / 1e1

@export
class S2PhotonPropagationBase(fuseBaseDownChunkingPlugin):
class S2PhotonPropagationBase(FuseBaseDownChunkingPlugin):

__version__ = "0.1.4"

Expand Down
4 changes: 2 additions & 2 deletions fuse/plugins/detector_physics/secondary_scintillation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
from immutabledict import immutabledict

from ...common import pmt_gains
from ...plugin import fuseBasePlugin
from ...plugin import FuseBasePlugin

export, __all__ = strax.exporter()

logging.basicConfig(handlers=[logging.StreamHandler()])
log = logging.getLogger('fuse.detector_physics.secondary_scintillation')

@export
class SecondaryScintillation(fuseBasePlugin):
class SecondaryScintillation(FuseBasePlugin):

__version__ = "0.1.3"

Expand Down
4 changes: 2 additions & 2 deletions fuse/plugins/micro_physics/electric_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import logging
import straxen

from ...plugin import fuseBasePlugin
from ...plugin import FuseBasePlugin

export, __all__ = strax.exporter()

logging.basicConfig(handlers=[logging.StreamHandler()])
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.
"""
Expand Down
4 changes: 2 additions & 2 deletions fuse/plugins/micro_physics/find_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions fuse/plugins/micro_physics/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions fuse/plugins/micro_physics/merge_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 0 additions & 2 deletions fuse/plugins/micro_physics/microphysics_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

export, __all__ = strax.exporter()

from ...common import FUSE_PLUGIN_TIMEOUT

@export
class MicroPhysicsSummary(strax.MergeOnlyPlugin):
"""
Expand Down
23 changes: 4 additions & 19 deletions fuse/plugins/micro_physics/wfsim_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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),
Expand All @@ -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):

Expand Down
32 changes: 4 additions & 28 deletions fuse/plugins/micro_physics/yields.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging
import pickle

from ...plugin import fuseBasePlugin
from ...plugin import FuseBasePlugin

export, __all__ = strax.exporter()

Expand All @@ -17,7 +17,7 @@
nest_rng = nestpy.RandomGen.rndm()

@export
class NestYields(fuseBasePlugin):
class NestYields(FuseBasePlugin):

__version__ = "0.1.2"

Expand Down Expand Up @@ -291,7 +291,7 @@ def get_quanta(self, energy, field):



class BBFYields(strax.Plugin):
class BBFYields(FuseBasePlugin):

__version__ = "0.1.1"

Expand All @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions fuse/plugins/pmt_and_daq/photon_pulses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions fuse/plugins/pmt_and_daq/pmt_afterpulses.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import logging

from ...common import pmt_gains
from ...plugin import fuseBasePlugin
from ...plugin import FuseBasePlugin

export, __all__ = strax.exporter()

logging.basicConfig(handlers=[logging.StreamHandler()])
log = logging.getLogger('fuse.pmt_and_daq.pmt_afterpulses')

@export
class PMTAfterPulses(fuseBasePlugin):
class PMTAfterPulses(FuseBasePlugin):

__version__ = "0.1.2"

Expand Down
Loading

0 comments on commit fceabff

Please sign in to comment.