Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# TODO: get n_top_pmts from config...
area_top = (p['area_per_channel'][:, :127]
* to_pe[:127].reshape(1, -1)).sum(axis=1)
# Negative-area peaks get 0 AFT - TODO why not NaN?
m = p['area'] > 0
r['area_fraction_top'][m] = area_top[m]/p['area'][m]
return r
@export
@strax.takes_config(
strax.Option(
'nn_architecture',
help='Path to JSON of neural net architecture',
default_by_run=[
(0, pax_file('XENON1T_tensorflow_nn_pos_20171217_sr0.json')),
(first_sr1_run, pax_file('XENON1T_tensorflow_nn_pos_20171217_sr1.json'))]), # noqa
strax.Option(
'nn_weights',
help='Path to HDF5 of neural net weights',
default_by_run=[
(0, pax_file('XENON1T_tensorflow_nn_pos_weights_20171217_sr0.h5')),
(first_sr1_run, pax_file('XENON1T_tensorflow_nn_pos_weights_20171217_sr1.h5'))]), # noqa
strax.Option('min_reconstruction_area',
help='Skip reconstruction if area (PE) is less than this',
default=10)
)
class PeakPositions(strax.Plugin):
dtype = [('x', np.float32,
'Reconstructed S2 X position (cm), uncorrected'),
with np.errstate(invalid='ignore'):
z_cor = -(z_obs ** 2 - delta_r ** 2) ** 0.5
invalid = np.abs(z_obs) < np.abs(delta_r) # Why??
z_cor[invalid] = z_obs[invalid]
result['z'] = z_cor
return result
@strax.takes_config(
strax.Option(
's1_relative_lce_map',
help="S1 relative LCE(x,y,z) map",
default_by_run=[
(0, pax_file('XENON1T_s1_xyz_lce_true_kr83m_SR0_pax-680_fdc-3d_v0.json')), # noqa
(first_sr1_run, pax_file('XENON1T_s1_xyz_lce_true_kr83m_SR1_pax-680_fdc-3d_v0.json'))]), # noqa
strax.Option(
's2_relative_lce_map',
help="S2 relative LCE(x, y) map",
default_by_run=[
(0, pax_file('XENON1T_s2_xy_ly_SR0_24Feb2017.json')),
(170118_1327, pax_file('XENON1T_s2_xy_ly_SR1_v2.2.json'))]),
strax.Option(
'electron_lifetime',
help="Electron lifetime (ns)",
default_by_run=get_elife)
)
class CorrectedAreas(strax.Plugin):
depends_on = ['event_basics', 'event_positions']
dtype = [('cs1', np.float32, 'Corrected S1 area (PE)'),
('cs2', np.float32, 'Corrected S2 area (PE)')]
with np.errstate(invalid='ignore'):
z_cor = -(z_obs ** 2 - delta_r ** 2) ** 0.5
invalid = np.abs(z_obs) < np.abs(delta_r) # Why??
z_cor[invalid] = z_obs[invalid]
result['z'] = z_cor
return result
@strax.takes_config(
strax.Option(
's1_relative_lce_map',
help="S1 relative LCE(x,y,z) map",
default_by_run=[
(0, pax_file('XENON1T_s1_xyz_lce_true_kr83m_SR0_pax-680_fdc-3d_v0.json')), # noqa
(first_sr1_run, pax_file('XENON1T_s1_xyz_lce_true_kr83m_SR1_pax-680_fdc-3d_v0.json'))]), # noqa
strax.Option(
's2_relative_lce_map',
help="S2 relative LCE(x, y) map",
default_by_run=[
(0, pax_file('XENON1T_s2_xy_ly_SR0_24Feb2017.json')),
(170118_1327, pax_file('XENON1T_s2_xy_ly_SR1_v2.2.json'))]),
strax.Option(
'electron_lifetime',
help="Electron lifetime (ns)",
default_by_run=get_elife)
)
class CorrectedAreas(strax.Plugin):
depends_on = ['event_basics', 'event_positions']
dtype = [('cs1', np.float32, 'Corrected S1 area (PE)'),
('cs2', np.float32, 'Corrected S2 area (PE)')]
@export
@strax.takes_config(
strax.Option(
name='electron_drift_velocity',
help='Vertical electron drift velocity in cm/ns (1e4 m/ms)',
default=1.3325e-4
),
strax.Option(
'fdc_map',
help='3D field distortion correction map path',
default_by_run=[
(0, pax_file('XENON1T_FDC_SR0_data_driven_3d_correction_tf_nn_v0.json.gz')), # noqa
(first_sr1_run, pax_file('XENON1T_FDC_SR1_data_driven_time_dependent_3d_correction_tf_nn_part1_v1.json.gz')), # noqa
(170411_0611, pax_file('XENON1T_FDC_SR1_data_driven_time_dependent_3d_correction_tf_nn_part2_v1.json.gz')), # noqa
(170704_0556, pax_file('XENON1T_FDC_SR1_data_driven_time_dependent_3d_correction_tf_nn_part3_v1.json.gz')), # noqa
(170925_0622, pax_file('XENON1T_FDC_SR1_data_driven_time_dependent_3d_correction_tf_nn_part4_v1.json.gz'))]), # noqa
)
class EventPositions(strax.Plugin):
depends_on = ('event_basics',)
dtype = [
('x', np.float32,
'Interaction x-position, field-distortion corrected (cm)'),
('y', np.float32,
'Interaction y-position, field-distortion corrected (cm)'),
('z', np.float32,
'Interaction z-position, field-distortion corrected (cm)'),
('r', np.float32,
'Interaction radial position, field-distortion corrected (cm)'),
('z_naive', np.float32,
'Interaction z-position using mean drift velocity only (cm)'),
('r_naive', np.float32,
'Interaction r-position using observed S2 positions directly (cm)'),
@export
@strax.takes_config(
strax.Option(
'nn_architecture',
help='Path to JSON of neural net architecture',
default_by_run=[
(0, pax_file('XENON1T_tensorflow_nn_pos_20171217_sr0.json')),
(first_sr1_run, pax_file('XENON1T_tensorflow_nn_pos_20171217_sr1.json'))]), # noqa
strax.Option(
'nn_weights',
help='Path to HDF5 of neural net weights',
default_by_run=[
(0, pax_file('XENON1T_tensorflow_nn_pos_weights_20171217_sr0.h5')),
(first_sr1_run, pax_file('XENON1T_tensorflow_nn_pos_weights_20171217_sr1.h5'))]), # noqa
strax.Option('min_reconstruction_area',
help='Skip reconstruction if area (PE) is less than this',
default=10)
)
class PeakPositions(strax.Plugin):
dtype = [('x', np.float32,
'Reconstructed S2 X position (cm), uncorrected'),
('y', np.float32,
'Reconstructed S2 Y position (cm), uncorrected')]
depends_on = ('peaks',)
# TODO
# Parallelization doesn't seem to make it go faster
# Is there much pure-python stuff in tensorflow?
# Process-level paralellization might work, but you'd have to do setup
return result
@strax.takes_config(
strax.Option(
's1_relative_lce_map',
help="S1 relative LCE(x,y,z) map",
default_by_run=[
(0, pax_file('XENON1T_s1_xyz_lce_true_kr83m_SR0_pax-680_fdc-3d_v0.json')), # noqa
(first_sr1_run, pax_file('XENON1T_s1_xyz_lce_true_kr83m_SR1_pax-680_fdc-3d_v0.json'))]), # noqa
strax.Option(
's2_relative_lce_map',
help="S2 relative LCE(x, y) map",
default_by_run=[
(0, pax_file('XENON1T_s2_xy_ly_SR0_24Feb2017.json')),
(170118_1327, pax_file('XENON1T_s2_xy_ly_SR1_v2.2.json'))]),
strax.Option(
'electron_lifetime',
help="Electron lifetime (ns)",
default_by_run=get_elife)
)
class CorrectedAreas(strax.Plugin):
depends_on = ['event_basics', 'event_positions']
dtype = [('cs1', np.float32, 'Corrected S1 area (PE)'),
('cs2', np.float32, 'Corrected S2 area (PE)')]
def setup(self):
from .itp_map import InterpolatingMap
self.s1_map = InterpolatingMap(
get_resource(self.config['s1_relative_lce_map']))
self.s2_map = InterpolatingMap(
get_resource(self.config['s2_relative_lce_map']))
@export
@strax.takes_config(
strax.Option(
'nn_architecture',
help='Path to JSON of neural net architecture',
default_by_run=[
(0, pax_file('XENON1T_tensorflow_nn_pos_20171217_sr0.json')),
(first_sr1_run, pax_file('XENON1T_tensorflow_nn_pos_20171217_sr1.json'))]), # noqa
strax.Option(
'nn_weights',
help='Path to HDF5 of neural net weights',
default_by_run=[
(0, pax_file('XENON1T_tensorflow_nn_pos_weights_20171217_sr0.h5')),
(first_sr1_run, pax_file('XENON1T_tensorflow_nn_pos_weights_20171217_sr1.h5'))]), # noqa
strax.Option('min_reconstruction_area',
help='Skip reconstruction if area (PE) is less than this',
default=10)
)
class PeakPositions(strax.Plugin):
dtype = [('x', np.float32,
'Reconstructed S2 X position (cm), uncorrected'),
('y', np.float32,
'Reconstructed S2 Y position (cm), uncorrected')]
depends_on = ('peaks',)
# TODO
# Parallelization doesn't seem to make it go faster
# Is there much pure-python stuff in tensorflow?
area_top = (p['area_per_channel'][:, :127]
* to_pe[:127].reshape(1, -1)).sum(axis=1)
# Negative-area peaks get 0 AFT - TODO why not NaN?
m = p['area'] > 0
r['area_fraction_top'][m] = area_top[m]/p['area'][m]
return r
@export
@strax.takes_config(
strax.Option(
'nn_architecture',
help='Path to JSON of neural net architecture',
default_by_run=[
(0, pax_file('XENON1T_tensorflow_nn_pos_20171217_sr0.json')),
(first_sr1_run, pax_file('XENON1T_tensorflow_nn_pos_20171217_sr1.json'))]), # noqa
strax.Option(
'nn_weights',
help='Path to HDF5 of neural net weights',
default_by_run=[
(0, pax_file('XENON1T_tensorflow_nn_pos_weights_20171217_sr0.h5')),
(first_sr1_run, pax_file('XENON1T_tensorflow_nn_pos_weights_20171217_sr1.h5'))]), # noqa
strax.Option('min_reconstruction_area',
help='Skip reconstruction if area (PE) is less than this',
default=10)
)
class PeakPositions(strax.Plugin):
dtype = [('x', np.float32,
'Reconstructed S2 X position (cm), uncorrected'),
('y', np.float32,
@export
@strax.takes_config(
strax.Option(
name='electron_drift_velocity',
help='Vertical electron drift velocity in cm/ns (1e4 m/ms)',
default=1.3325e-4
),
strax.Option(
'fdc_map',
help='3D field distortion correction map path',
default_by_run=[
(0, pax_file('XENON1T_FDC_SR0_data_driven_3d_correction_tf_nn_v0.json.gz')), # noqa
(first_sr1_run, pax_file('XENON1T_FDC_SR1_data_driven_time_dependent_3d_correction_tf_nn_part1_v1.json.gz')), # noqa
(170411_0611, pax_file('XENON1T_FDC_SR1_data_driven_time_dependent_3d_correction_tf_nn_part2_v1.json.gz')), # noqa
(170704_0556, pax_file('XENON1T_FDC_SR1_data_driven_time_dependent_3d_correction_tf_nn_part3_v1.json.gz')), # noqa
(170925_0622, pax_file('XENON1T_FDC_SR1_data_driven_time_dependent_3d_correction_tf_nn_part4_v1.json.gz'))]), # noqa
)
class EventPositions(strax.Plugin):
depends_on = ('event_basics',)
dtype = [
('x', np.float32,
'Interaction x-position, field-distortion corrected (cm)'),
('y', np.float32,
'Interaction y-position, field-distortion corrected (cm)'),
('z', np.float32,
'Interaction z-position, field-distortion corrected (cm)'),
('r', np.float32,
'Interaction radial position, field-distortion corrected (cm)'),
('z_naive', np.float32,
'Interaction z-position using mean drift velocity only (cm)'),
('r_naive', np.float32,
return result
@strax.takes_config(
strax.Option(
's1_relative_lce_map',
help="S1 relative LCE(x,y,z) map",
default_by_run=[
(0, pax_file('XENON1T_s1_xyz_lce_true_kr83m_SR0_pax-680_fdc-3d_v0.json')), # noqa
(first_sr1_run, pax_file('XENON1T_s1_xyz_lce_true_kr83m_SR1_pax-680_fdc-3d_v0.json'))]), # noqa
strax.Option(
's2_relative_lce_map',
help="S2 relative LCE(x, y) map",
default_by_run=[
(0, pax_file('XENON1T_s2_xy_ly_SR0_24Feb2017.json')),
(170118_1327, pax_file('XENON1T_s2_xy_ly_SR1_v2.2.json'))]),
strax.Option(
'electron_lifetime',
help="Electron lifetime (ns)",
default_by_run=get_elife)
)
class CorrectedAreas(strax.Plugin):
depends_on = ['event_basics', 'event_positions']
dtype = [('cs1', np.float32, 'Corrected S1 area (PE)'),
('cs2', np.float32, 'Corrected S2 area (PE)')]
def setup(self):
from .itp_map import InterpolatingMap
self.s1_map = InterpolatingMap(
get_resource(self.config['s1_relative_lce_map']))
self.s2_map = InterpolatingMap(