Skip to content

Commit

Permalink
Add gas gain (x,y) dependence when simulating S2PE
Browse files Browse the repository at this point in the history
  • Loading branch information
mhliu0001 committed Nov 30, 2023
1 parent 7da3302 commit 9a050cf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 28 deletions.
1 change: 1 addition & 0 deletions appletree/maps/_gas_gain.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"coordinate_lowers": [-70, -70], "coordinate_uppers": [70, 70], "coordinate_type": "regbin", "coordinate_name": ["x", "y"], "map": [[31.3, 31.3, 31.3, 31.3, 31.3], [31.3, 31.3, 31.3, 31.3, 31.3], [31.3, 31.3, 31.3, 31.3, 31.3], [31.3, 31.3, 31.3, 31.3, 31.3], [31.3, 31.3, 31.3, 31.3, 31.3]]}
11 changes: 0 additions & 11 deletions appletree/parameters/er.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@
"unit": "1",
"doc": "Fano factor which describes the fluctuation of num of quanta"
},
"gas_gain": {
"prior_type": "fixed",
"prior_args": {
"val": 31.3
},
"allowed_range": null,
"init_mean": null,
"init_std": null,
"unit": "PE/electron",
"doc": "Gas gain"
},
"drift_velocity": {
"prior_type": "fixed",
"prior_args": {
Expand Down
11 changes: 0 additions & 11 deletions appletree/parameters/nr_low.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
{
"gas_gain": {
"prior_type": "fixed",
"prior_args": {
"val": 31.3
},
"allowed_range": null,
"init_mean": null,
"init_std": null,
"unit": "PE/electron",
"doc": "Gas gain"
},
"drift_velocity": {
"prior_type": "fixed",
"prior_args": {
Expand Down
15 changes: 9 additions & 6 deletions appletree/plugins/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,24 @@ def simulate(self, key, parameters, num_electron, drift_survive_prob):
return key, num_electron_drifted


@takes_config(
Map(name="gas_gain", default="_gas_gain.json", help="Gas gain (x,y) dependence"),
)
@export
class S2PE(Plugin):
depends_on = ["num_electron_drifted", "s2_correction_true"]
depends_on = ["num_electron_drifted", "s2_correction_true", "x", "y"]
provides = ["num_s2_pe"]
parameters = ("g2", "gas_gain")

@partial(jit, static_argnums=(0,))
def simulate(self, key, parameters, num_electron_drifted, s2_correction_true):
extraction_eff = parameters["g2"] / parameters["gas_gain"]
g2_true = parameters["g2"] * s2_correction_true
gas_gain_true = g2_true / extraction_eff
def simulate(self, key, parameters, num_electron_drifted, s2_correction_true, x, y):
pos_true = jnp.stack([x, y]).T
gas_gain = self.gas_gain.apply((pos_true))
extraction_eff = parameters["g2"] * s2_correction_true / gas_gain

key, num_electron_extracted = randgen.binomial(key, extraction_eff, num_electron_drifted)

mean_s2_pe = num_electron_extracted * gas_gain_true
mean_s2_pe = num_electron_extracted * gas_gain
key, num_s2_pe = randgen.truncate_normal(key, mean_s2_pe, jnp.sqrt(mean_s2_pe), vmin=0)

return key, num_s2_pe

0 comments on commit 9a050cf

Please sign in to comment.