Skip to content

Commit

Permalink
for z: replaced chebyshev with linear correction
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdenhollander committed Oct 16, 2024
1 parent ed40f1a commit b2bbedf
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions amstrax/plugins/events/event_positions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@
strax.Option('default_reconstruction_algorithm',
default=DEFAULT_POSREC_ALGO,
help="default reconstruction algorithm that provides (x,y)"),
strax.Option('chebyshev_coefficients',
default=[-20.610498575132848, -25.011741532892245, 1.5014394901565762, -1.9897069599813497, 0.9003989634988041, -0.9360882311673664, 0.3205446171520987, -0.31507601715307304, -0.11157849428915143, 0.06805340886247688, -0.29731923422516193, 0.20130571476398995, -0.27433679192849914, 0.14124101107660128, -0.1423385040662297, 0.02543495639467936, -0.003942936477649859, -0.06027758452189014, 0.06644908962655806, -0.07892464092207617, 0.06395035504495723, -0.03346169811390071, 0.015301990300138332, 0.02074806803955231, -0.023897590505947888, 0.05290043645359529, -0.04171261919713702, 0.04635244560925833, -0.023740447547251964, 0.017317746198669496, 0.008129269124318644, -0.015813652571722153, 0.03280797293563488, -0.0319597933948091, 0.033244932242107145, -0.02499733182975444, 0.01804703343996559, -0.003734756903266918, -0.010310284576649408, 0.014162576952560277, -0.02107880499178727, 0.02353782385611963, -0.023161397137303634, 0.01638318547950904, -0.009949657230580528, 0.0028289370052051086, 0.00819342916648231, -0.010233170352421222, 0.01760163054647025, -0.01272257423130424, 0.014630281086449799],
help="coefficients for the drift time to z fit"),
strax.Option('chebyshev_interval',
default=[1219.0999755859375, 39380.8984375],
help="interval of the chebyshev fit"),
strax.Option('drift_time_gate',
default=3000,
help='Drift time belonging to the gate in ns'),
strax.Option('drift_time_cathode',
default=39500,
help='Drift time belonging to the cathode in ns'),
strax.Option('gate_cathode_distance',
default=505,
help='Distance between gate and cathode in mm'),
)

class EventPositions(strax.Plugin):
Expand All @@ -39,7 +42,7 @@ class EventPositions(strax.Plugin):

depends_on = ('event_basics',)

__version__ = '1.1.16'
__version__ = '1.1.20'


def infer_dtype(self):
Expand All @@ -62,8 +65,9 @@ def setup(self):
self.electron_drift_velocity = self.config['electron_drift_velocity']
self.electron_drift_time_gate = self.config['electron_drift_time_gate']
self.default_reconstruction_algorithm = self.config['default_reconstruction_algorithm']
self.chebyshev_coefficients = np.array(self.config['chebyshev_coefficients'])
self.chebyshev_interval = self.config['chebyshev_interval']
self.drift_time_gate = self.config['drift_time_gate']
self.drift_time_cathode = self.config['drift_time_cathode']
self.gate_cathode_distance = self.config['gate_cathode_distance']

self.coordinate_scales = [1., 1., - self.electron_drift_velocity]
# self.map = self.fdc_map
Expand All @@ -86,12 +90,7 @@ def compute(self, events):
result['r'] = np.sqrt(result['x'] ** 2 + result['y'] ** 2)
result['alt_s2_r'] = np.sqrt(result['alt_s2_x'] ** 2 + result['alt_s2_y'] ** 2)

# determine z using a chebyshev polynomial fit
p = np.polynomial.chebyshev.Chebyshev(self.chebyshev_coefficients)

# normalize drift times such that the interval is [-1, 1]
drift_times_normalized = 2 * (events['drift_time'] - self.chebyshev_interval[0]) / (self.config['chebyshev_interval'][1] - self.chebyshev_interval[0]) - 1

result['z'] = p(drift_times_normalized)
slope = -self.gate_cathode_distance / (self.drift_time_cathode - self.drift_time_gate)
result['z'] = slope * (events['drift_time'] - self.drift_time_gate)

return result

0 comments on commit b2bbedf

Please sign in to comment.