diff --git a/appletree/maps/_gas_gain.json b/appletree/maps/_gas_gain.json new file mode 100644 index 00000000..bd113f7b --- /dev/null +++ b/appletree/maps/_gas_gain.json @@ -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]]} \ No newline at end of file diff --git a/appletree/parameters/er.json b/appletree/parameters/er.json index 45f666b8..9e74f917 100644 --- a/appletree/parameters/er.json +++ b/appletree/parameters/er.json @@ -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": { diff --git a/appletree/parameters/nr_low.json b/appletree/parameters/nr_low.json index f6219d75..f061a685 100644 --- a/appletree/parameters/nr_low.json +++ b/appletree/parameters/nr_low.json @@ -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": { diff --git a/appletree/plugins/detector.py b/appletree/plugins/detector.py index d8bf8766..f9dadefa 100644 --- a/appletree/plugins/detector.py +++ b/appletree/plugins/detector.py @@ -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