From a9e0df8144fed4bad6d22387a9845168b070da6d Mon Sep 17 00:00:00 2001 From: Zihao Xu Date: Fri, 22 Mar 2024 06:19:27 +0800 Subject: [PATCH 1/9] separate above and below gate drift --- .../detector_physics/electron_drift.py | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/fuse/plugins/detector_physics/electron_drift.py b/fuse/plugins/detector_physics/electron_drift.py index 7287b949..641ab74e 100644 --- a/fuse/plugins/detector_physics/electron_drift.py +++ b/fuse/plugins/detector_physics/electron_drift.py @@ -168,6 +168,15 @@ class ElectronDrift(FuseBasePlugin): help="Field distortion map used in fuse (Check if we can remove _fuse from the name)", ) + liquid_level = straxen.URLConfig( + default="take://resource://" + "SIMULATION_CONFIG_FILE.json?&fmt=json" + "&take=liquid_level", + cache=True, + help="Distance between the liquid level and gate in cm", + ) + + def setup(self): super().setup() @@ -327,7 +336,8 @@ def get_s2_drift_time_params(self, xy_int, z_int): Returns: returns two arrays of floats (mean drift time, drift time spread) """ - drift_velocity_liquid = self.get_avg_drift_velocity(z_int, xy_int) + drift_velocity_below_gate = self.get_avg_drift_velocity(z_int, xy_int) + drift_velocity_above_gate = self.liquid_level / self.drift_time_gate if self.enable_diffusion_longitudinal_map: diffusion_constant_longitudinal = self.diffusion_longitudinal_map( z_int, xy_int @@ -335,10 +345,16 @@ def get_s2_drift_time_params(self, xy_int, z_int): else: diffusion_constant_longitudinal = self.diffusion_constant_longitudinal - drift_time_mean = -z_int / drift_velocity_liquid + self.drift_time_gate + drift_time_below_gate = -z_int / drift_velocity_below_gate + drift_time_above_gate = self.drift_time_gate + + drift_time_mean = drift_time_below_gate + drift_time_above_gate drift_time_mean = np.clip(drift_time_mean, 0, np.inf) - drift_time_spread = np.sqrt(2 * diffusion_constant_longitudinal * drift_time_mean) - drift_time_spread /= drift_velocity_liquid + + drift_time_spread2 = 2 * diffusion_constant_longitudinal * drift_time_below_gate / drift_velocity_below_gate**2 + drift_time_spread2 += 2 * diffusion_constant_longitudinal * drift_time_above_gate / drift_velocity_above_gate**2 + drift_time_spread = np.sqrt(drift_time_spread2) + return drift_time_mean, drift_time_spread def get_avg_drift_velocity(self, z, xy): From e176632a57cbca353bebc016abb0a50b378d14c5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 21 Mar 2024 22:21:18 +0000 Subject: [PATCH 2/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../detector_physics/electron_drift.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/fuse/plugins/detector_physics/electron_drift.py b/fuse/plugins/detector_physics/electron_drift.py index 641ab74e..a254e96f 100644 --- a/fuse/plugins/detector_physics/electron_drift.py +++ b/fuse/plugins/detector_physics/electron_drift.py @@ -169,14 +169,11 @@ class ElectronDrift(FuseBasePlugin): ) liquid_level = straxen.URLConfig( - default="take://resource://" - "SIMULATION_CONFIG_FILE.json?&fmt=json" - "&take=liquid_level", + default="take://resource://" "SIMULATION_CONFIG_FILE.json?&fmt=json" "&take=liquid_level", cache=True, help="Distance between the liquid level and gate in cm", ) - def setup(self): super().setup() @@ -351,8 +348,18 @@ def get_s2_drift_time_params(self, xy_int, z_int): drift_time_mean = drift_time_below_gate + drift_time_above_gate drift_time_mean = np.clip(drift_time_mean, 0, np.inf) - drift_time_spread2 = 2 * diffusion_constant_longitudinal * drift_time_below_gate / drift_velocity_below_gate**2 - drift_time_spread2 += 2 * diffusion_constant_longitudinal * drift_time_above_gate / drift_velocity_above_gate**2 + drift_time_spread2 = ( + 2 + * diffusion_constant_longitudinal + * drift_time_below_gate + / drift_velocity_below_gate**2 + ) + drift_time_spread2 += ( + 2 + * diffusion_constant_longitudinal + * drift_time_above_gate + / drift_velocity_above_gate**2 + ) drift_time_spread = np.sqrt(drift_time_spread2) return drift_time_mean, drift_time_spread From 82d28e8532ab65fd850e21a2ed9bef4d072a7ca2 Mon Sep 17 00:00:00 2001 From: Zihao Xu Date: Fri, 5 Apr 2024 01:38:26 +0800 Subject: [PATCH 3/9] rm quote --- fuse/plugins/detector_physics/electron_drift.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fuse/plugins/detector_physics/electron_drift.py b/fuse/plugins/detector_physics/electron_drift.py index a254e96f..801b7239 100644 --- a/fuse/plugins/detector_physics/electron_drift.py +++ b/fuse/plugins/detector_physics/electron_drift.py @@ -169,7 +169,7 @@ class ElectronDrift(FuseBasePlugin): ) liquid_level = straxen.URLConfig( - default="take://resource://" "SIMULATION_CONFIG_FILE.json?&fmt=json" "&take=liquid_level", + default="take://resource://SIMULATION_CONFIG_FILE.json?&fmt=json&take=liquid_level", cache=True, help="Distance between the liquid level and gate in cm", ) From ebf31d86027f59544004334b0ef0d5f51822f185 Mon Sep 17 00:00:00 2001 From: Zihao Xu Date: Fri, 5 Apr 2024 01:41:50 +0800 Subject: [PATCH 4/9] bump plugin version and update doc --- docs/source/plugins/detector_physics/ElectronDrift.rst | 6 +++++- fuse/plugins/detector_physics/electron_drift.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/source/plugins/detector_physics/ElectronDrift.rst b/docs/source/plugins/detector_physics/ElectronDrift.rst index 6bfe8ecb..db89c484 100644 --- a/docs/source/plugins/detector_physics/ElectronDrift.rst +++ b/docs/source/plugins/detector_physics/ElectronDrift.rst @@ -20,7 +20,7 @@ Technical Details depends_on = ("microphysics_summary") provides = "drifted_electrons" data_kind = "interactions_in_roi" - __version__ = "0.2.0" + __version__ = "0.3.0" Provided Columns ================ @@ -117,3 +117,7 @@ Config Options - - True - Field distortion map used in fuse (Check if we can remove _fuse from the name) + * - liquid_level + - + - True + - Distance between the liquid level and gate in cm diff --git a/fuse/plugins/detector_physics/electron_drift.py b/fuse/plugins/detector_physics/electron_drift.py index 801b7239..d1c16d41 100644 --- a/fuse/plugins/detector_physics/electron_drift.py +++ b/fuse/plugins/detector_physics/electron_drift.py @@ -22,7 +22,7 @@ class ElectronDrift(FuseBasePlugin): time and observed position is calculated. """ - __version__ = "0.2.0" + __version__ = "0.3.0" depends_on = "microphysics_summary" provides = "drifted_electrons" From be37ddfe171a7da305876d3345a6a7a75c0056d2 Mon Sep 17 00:00:00 2001 From: Zihao Xu Date: Fri, 5 Apr 2024 01:44:47 +0800 Subject: [PATCH 5/9] rename varibales --- fuse/plugins/detector_physics/electron_drift.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fuse/plugins/detector_physics/electron_drift.py b/fuse/plugins/detector_physics/electron_drift.py index d1c16d41..e4238c76 100644 --- a/fuse/plugins/detector_physics/electron_drift.py +++ b/fuse/plugins/detector_physics/electron_drift.py @@ -348,19 +348,22 @@ def get_s2_drift_time_params(self, xy_int, z_int): drift_time_mean = drift_time_below_gate + drift_time_above_gate drift_time_mean = np.clip(drift_time_mean, 0, np.inf) - drift_time_spread2 = ( + drift_time_spread_below_gate_squared = ( 2 * diffusion_constant_longitudinal * drift_time_below_gate / drift_velocity_below_gate**2 ) - drift_time_spread2 += ( + drift_time_spread_above_gate_squared = ( 2 * diffusion_constant_longitudinal * drift_time_above_gate / drift_velocity_above_gate**2 ) - drift_time_spread = np.sqrt(drift_time_spread2) + drift_time_spread = np.sqrt( + drift_time_spread_below_gate_squared + + drift_time_spread_above_gate_squared + ) return drift_time_mean, drift_time_spread From af32d1f47f15ac371d9da916fd49a6d8894e158a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 4 Apr 2024 17:45:12 +0000 Subject: [PATCH 6/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- fuse/plugins/detector_physics/electron_drift.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fuse/plugins/detector_physics/electron_drift.py b/fuse/plugins/detector_physics/electron_drift.py index e4238c76..126ce2e0 100644 --- a/fuse/plugins/detector_physics/electron_drift.py +++ b/fuse/plugins/detector_physics/electron_drift.py @@ -361,8 +361,7 @@ def get_s2_drift_time_params(self, xy_int, z_int): / drift_velocity_above_gate**2 ) drift_time_spread = np.sqrt( - drift_time_spread_below_gate_squared - + drift_time_spread_above_gate_squared + drift_time_spread_below_gate_squared + drift_time_spread_above_gate_squared ) return drift_time_mean, drift_time_spread From fd26168be86bd3ca8c5da973cded9af180e799c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henning=20Schulze=20Ei=C3=9Fing?= Date: Mon, 8 Apr 2024 04:15:51 -0500 Subject: [PATCH 7/9] make pre-commit happy --- docs/source/plugins/detector_physics/ElectronDrift.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/plugins/detector_physics/ElectronDrift.rst b/docs/source/plugins/detector_physics/ElectronDrift.rst index db89c484..49d715e0 100644 --- a/docs/source/plugins/detector_physics/ElectronDrift.rst +++ b/docs/source/plugins/detector_physics/ElectronDrift.rst @@ -118,6 +118,6 @@ Config Options - True - Field distortion map used in fuse (Check if we can remove _fuse from the name) * - liquid_level - - - - True - - Distance between the liquid level and gate in cm + - + - True + - Distance between the liquid level and gate in cm From 5214aed73b120753d5d06d8c4f62e392495a6adc Mon Sep 17 00:00:00 2001 From: Zihao Xu Date: Wed, 10 Apr 2024 03:02:47 +0800 Subject: [PATCH 8/9] get liquid level from gate_to_anode_distance and elr_gas_gap_length --- fuse/plugins/detector_physics/electron_drift.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/fuse/plugins/detector_physics/electron_drift.py b/fuse/plugins/detector_physics/electron_drift.py index 126ce2e0..0e66bed8 100644 --- a/fuse/plugins/detector_physics/electron_drift.py +++ b/fuse/plugins/detector_physics/electron_drift.py @@ -168,10 +168,16 @@ class ElectronDrift(FuseBasePlugin): help="Field distortion map used in fuse (Check if we can remove _fuse from the name)", ) - liquid_level = straxen.URLConfig( - default="take://resource://SIMULATION_CONFIG_FILE.json?&fmt=json&take=liquid_level", + gate_to_anode_distance = straxen.URLConfig( + default="take://resource://SIMULATION_CONFIG_FILE.json?&fmt=json&take=gate_to_anode_distance", cache=True, - help="Distance between the liquid level and gate in cm", + help="Distance between the liquid surface and anode in cm", + ) + + elr_gas_gap_length = straxen.URLConfig( + default="take://resource://SIMULATION_CONFIG_FILE.json?&fmt=json&take=elr_gas_gap_length", + cache=True, + help="Distance between the gate and anode in cm", ) def setup(self): @@ -333,8 +339,9 @@ def get_s2_drift_time_params(self, xy_int, z_int): Returns: returns two arrays of floats (mean drift time, drift time spread) """ + liquid_level = self.gate_to_anode_distance - self.elr_gas_gap_length drift_velocity_below_gate = self.get_avg_drift_velocity(z_int, xy_int) - drift_velocity_above_gate = self.liquid_level / self.drift_time_gate + drift_velocity_above_gate = liquid_level / self.drift_time_gate if self.enable_diffusion_longitudinal_map: diffusion_constant_longitudinal = self.diffusion_longitudinal_map( z_int, xy_int From 14e75ea71c9d424828b9a1ecbc79ca0f43115482 Mon Sep 17 00:00:00 2001 From: Zihao Xu Date: Wed, 10 Apr 2024 03:32:04 +0800 Subject: [PATCH 9/9] code style --- fuse/plugins/detector_physics/electron_drift.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fuse/plugins/detector_physics/electron_drift.py b/fuse/plugins/detector_physics/electron_drift.py index 0e66bed8..82c6dfa8 100644 --- a/fuse/plugins/detector_physics/electron_drift.py +++ b/fuse/plugins/detector_physics/electron_drift.py @@ -169,13 +169,19 @@ class ElectronDrift(FuseBasePlugin): ) gate_to_anode_distance = straxen.URLConfig( - default="take://resource://SIMULATION_CONFIG_FILE.json?&fmt=json&take=gate_to_anode_distance", + default="take://resource://" + "SIMULATION_CONFIG_FILE.json?" + "&fmt=json" + "&take=gate_to_anode_distance", cache=True, help="Distance between the liquid surface and anode in cm", ) elr_gas_gap_length = straxen.URLConfig( - default="take://resource://SIMULATION_CONFIG_FILE.json?&fmt=json&take=elr_gas_gap_length", + default="take://resource://" + "SIMULATION_CONFIG_FILE.json?" + "&fmt=json" + "&take=elr_gas_gap_length", cache=True, help="Distance between the gate and anode in cm", )