Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S2Width Warnings Fix #114

Merged
merged 8 commits into from
Dec 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 34 additions & 24 deletions lax/lichens/sciencerun0.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ class S2Width(Lichen):
https://xe1t-wiki.lngs.infn.it/doku.php?id=xenon:xenon1t:sim:notes:tzhu:width_cut_tuning#toy_fax_simulation
Contact: Tianyu <[email protected]>, Yuehuan <[email protected]>, Jelle <[email protected]>
"""
version = 4
version = 5

diffusion_constant = 25.26 * ((units.cm)**2) / units.s
v_drift = 1.440 * (units.um) / units.ns
Expand All @@ -650,16 +650,19 @@ def s2_width_model(self, z_height):
return np.sqrt(- 2 * self.diffusion_constant * z_height / self.v_drift ** 3)

def _process(self, df):
df.loc[:, 'nElectron'] = np.clip(df['s2'], 0, 5000) / self.scg
df.loc[:, 'normWidth'] = (np.square(df['s2_range_50p_area'] / self.SigmaToR50) - np.square(self.scw)) / \
np.square(self.s2_width_model(df['z']))
df.loc[:, self.name()] = chi2.logpdf(df['normWidth'] * (df['nElectron'] - 1), df['nElectron']) > - 14
df.loc[:, self.name()] = True # Default is True
mask = df.eval('z < 0')
df.loc[mask, 'nElectron'] = np.clip(df.loc[mask, 's2'], 0, 5000) / self.scg
df.loc[mask, 'normWidth'] = (np.square(df.loc[mask, 's2_range_50p_area'] / self.SigmaToR50) -
np.square(self.scw)) / np.square(self.s2_width_model(df.loc[mask, 'z']))
df.loc[mask, self.name()] = chi2.logpdf(df.loc[mask, 'normWidth'] * (df.loc[mask, 'nElectron'] - 1),
df.loc[mask, 'nElectron']) > - 14
return df

def post(self, df):
for temp_column in ['nElectron', 'normWidth']:
if temp_column in df.columns:
return df.drop(temp_column, 1)
df.drop(temp_column, 1, inplace=True)
return df


Expand All @@ -685,14 +688,20 @@ class S1SingleScatter(Lichen):
s2width = S2Width

def _process(self, df):
df.loc[:, self.name()] = True # Default is True
mask = df.eval('alt_s1_interaction_z < 0')
alt_n_electron = np.clip(df.loc[mask, 's2'], 0, 5000) / self.s2width.scg

alt_n_electron = np.clip(df['s2'], 0, 5000) / self.s2width.scg
alt_rel_width = (np.square(df['s2_range_50p_area'] / self.s2width.SigmaToR50) - np.square(self.s2width.scw)) / \
np.square(self.s2width.s2_width_model(self.s2width, df['alt_s1_interaction_z']))
# Alternate S1 relative width
alt_rel_width = np.square(df.loc[mask,
's2_range_50p_area'] / self.s2width.SigmaToR50) - np.square(self.s2width.scw)
alt_rel_width /= np.square(self.s2width.s2_width_model(self.s2width,
df.loc[mask, 'alt_s1_interaction_z']))

alt_interaction_passes = chi2.logpdf(alt_rel_width * (alt_n_electron - 1), alt_n_electron) > - 20

df.loc[:, (self.name())] = True ^ alt_interaction_passes
df.loc[mask, (self.name())] = True ^ alt_interaction_passes

return df


Expand Down Expand Up @@ -819,7 +828,7 @@ class KryptonMisIdS1(StringLichen):
version = 0
string = "largest_other_s2 < 100 | largest_other_s2_delay_main_s1 < -3000 | largest_other_s2_delay_main_s1 > 0"


class Flash(Lichen):
"""Cuts events within a flash. This is defined as the width were the BUSY on channel is "high".
In addition an extended time-window around the flash is removed as well.
Expand All @@ -830,15 +839,15 @@ class Flash(Lichen):
"""

version = 0
def _process(self,df):
df.loc[:, self.name()]= ((df['inside_flash']== False) &
((df.nearest_flash != df.nearest_flash) |
(df['nearest_flash'] > 120e9) |
(df['nearest_flash'] < (-10e9 - df['flashing_width']*1e9))
)
)
return df

def _process(self, df):
df.loc[:, self.name()] = ((df['inside_flash'] is False) &
((df.nearest_flash != df.nearest_flash) |
(df['nearest_flash'] > 120e9) |
(df['nearest_flash'] < (-10e9 - df['flashing_width'] * 1e9))
)
)


class PosDiff(Lichen):
"""
Expand All @@ -848,10 +857,11 @@ class PosDiff(Lichen):
Contact: Yuehuan Wei <[email protected]>
"""
version = 0

def _process(self, df):
df.loc[:, self.name()] = (((df['x_observed_nn'] - df['x_observed_tpf'])**2
+ (df['y_observed_nn'] - df['y_observed_tpf'])**2 < 6)
& (df['r_observed_nn']**2 - df['r_observed_tpf']**2 > -80)
& (df['r_observed_nn']**2 - df['r_observed_tpf']**2 < 140))
df.loc[:, self.name()] = (((df['x_observed_nn'] - df['x_observed_tpf'])**2 +
(df['y_observed_nn'] - df['y_observed_tpf'])**2 < 6) &
(df['r_observed_nn']**2 - df['r_observed_tpf']**2 > -80) &
(df['r_observed_nn']**2 - df['r_observed_tpf']**2 < 140))

return df
3 changes: 2 additions & 1 deletion lax/lichens/sciencerun1.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# -*- coding: utf-8 -*-
import inspect
import os
import numpy as np
from pax import units

from lax.lichen import Lichen, ManyLichen, StringLichen
Expand Down Expand Up @@ -252,7 +253,7 @@ class S2Width(sciencerun0.S2Width):
"""S2 Width cut based on diffusion model with SR1 parameters
See sciencerun0.py for full implementation
"""
version = 4
version = 5
diffusion_constant = 29.35 * ((units.cm)**2) / units.s
v_drift = 1.335 * (units.um) / units.ns
scg = 21.3 # s2_secondary_sc_gain in pax config
Expand Down