Skip to content

Commit

Permalink
Add function to calculate window from drift velo.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwm17 committed Dec 18, 2024
1 parent c6e9571 commit fa5a074
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/spyral/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
GetParameters,
FribParameters,
DetectorParameters,
calculate_window_time,
ClusterParameters,
OverlapJoinParameters,
ContinuityJoinParameters,
Expand Down Expand Up @@ -65,4 +66,5 @@
"INTERP_SOLVER_SCHEMA",
"TraceReader",
"create_reader",
"calculate_window_time",
]
38 changes: 34 additions & 4 deletions src/spyral/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ class PadParameters:
----------
pad_geometry_path: Path
Path to the csv file containing the pad geometry. If set to DEFAULT_MAP
or DEFAULT_LEGACY_MAP uses the packaged maps.
uses the packaged maps.
pad_gain_path: Path
Path to the csv file containing the relative pad gains. If set to DEFAULT_MAP
or DEFAULT_LEGACY_MAP uses the packaged maps.
uses the packaged maps.
pad_time_path: Path
Path to the csv file containing the pad time corrections. If set to DEFAULT_MAP
or DEFAULT_LEGACY_MAP uses the packaged maps.
uses the packaged maps.
pad_electronics_path: Path
Path to the csv file containing the pad electronics ids. If set to DEFAULT_MAP
or DEFAULT_LEGACY_MAP uses the packaged maps.
uses the packaged maps.
"""

pad_geometry_path: Path
Expand Down Expand Up @@ -66,6 +66,36 @@ class DetectorParameters:
do_garfield_correction: bool


def calculate_window_time(
micromegas_time_bucket: float,
drift_velocity: float,
detector_length: float,
get_frequency: float,
) -> float:
"""Calculate the window time from a drift velocity
Given a known micromegas time, drift velocity, detector length, and GET sampling frequency
calculate the expected window time.
Parameters
----------
micromegas_time_bucket: float
The micromegas time in GET Time Buckets
drift_velocity: float
The electron drift velocity in mm/us
detector_length: float
The detector length in mm
get_frequency: float
The GET electronics sampling frequency
Returns
-------
float
The window time in GET time buckets
"""
return (detector_length / drift_velocity) * get_frequency + micromegas_time_bucket


@dataclass
class GetParameters:
"""Parameters for GET trace signal analysis
Expand Down
7 changes: 4 additions & 3 deletions src/spyral/core/point_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,11 @@ def calibrate_point_cloud_z(
detector_params: DetectorParameters,
efield_correction: ElectronCorrector | None = None,
):
"""Calibrate the cloud z-position from the micromegas and window time references
"""Calibrate the cloud z-position
Also applies the ion chamber time correction and electric field correction if given
Any points which were invalidated (NaN'ed) by this operation are removed.
Uses two time references, the micromegas and window. Also applies
the electric field correction if given. Any points which were invalidated
(NaN'ed) by this operation are removed.
WARNING: This modifies the point cloud data, including removing points from the
point cloud which were invalidated (NaN'ed).
Expand Down

0 comments on commit fa5a074

Please sign in to comment.