Skip to content
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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ n_processes = 4
pad_params = PadParameters(
pad_geometry_path=DEFAULT_MAP,
pad_time_path=DEFAULT_MAP,
pad_electronics_path=DEFAULT_MAP,
pad_scale_path=DEFAULT_MAP,
)

Expand Down
5 changes: 0 additions & 5 deletions docs/user_guide/config/pad.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ The AT-TPC Pad Plane mapping of electronics channel to physical pad is controlle
pad_params = PadParameters(
pad_geometry_path=DEFAULT_MAP,
pad_time_path=DEFAULT_MAP,
pad_electronics_path=DEFAULT_MAP,
pad_scale_path=DEFAULT_MAP,
)
```
Expand All @@ -21,10 +20,6 @@ This is the path to a `.csv` file containing the mapping of pad number to X-Y co

This is the path to a `.csv` file containing the mapping of pad number to a time offset. This corrects for small jitters in the timestamp on a channel by channel basis. This is parameter is currently under investigation for it's impact.

## pad_electronics_path

This is the path to a `.csv` file containing the mapping of pad number to electronics hardware. This file is more of a utility for validating checking data and uses in plotting.

## pad_scale_path

This is the path to a `.csv` file containing the mapping of pad number to scale relative to a Big Pad. This information is used to estimate relative positional errors.
1 change: 0 additions & 1 deletion docs/user_guide/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ n_processes = 4
pad_params = PadParameters(
pad_geometry_path=DEFAULT_MAP,
pad_time_path=DEFAULT_MAP,
pad_electronics_path=DEFAULT_MAP,
pad_scale_path=DEFAULT_MAP,
)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "attpc_spyral"
version = "0.18.0"
version = "1.0.0rc0"
description = "AT-TPC analysis pipeline"
authors = [
{name = "gwm17", email = "gordonmccann215@gmail.com"},
Expand Down
4 changes: 0 additions & 4 deletions src/spyral/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@ class PadParameters:
pad_time_path: Path
Path to the csv file containing the pad time corrections. If set to DEFAULT_MAP
uses the packaged maps.
pad_electronics_path: Path
Path to the csv file containing the pad electronics ids. If set to DEFAULT_MAP
uses the packaged maps.
"""

pad_geometry_path: Path
pad_time_path: Path
pad_electronics_path: Path
pad_scale_path: Path


Expand Down
77 changes: 5 additions & 72 deletions src/spyral/core/pad_map.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from .constants import INVALID_PAD_ID
from .hardware_id import HardwareID, generate_electronics_id
from .config import PadParameters, DEFAULT_MAP
from dataclasses import dataclass, field
from dataclasses import dataclass
from importlib import resources

from .legacy_beam_pads import LEGACY_BEAM_PADS
Expand All @@ -23,16 +22,13 @@ class PadData:
The pad time offset due to GET electronics
scale: float
The pad scale (big pad or small pad)
hardware: HardwareID
The pad HardwareID
"""

x: float = 0.0
y: float = 0.0
gain: float = 1.0
time_offset: float = 0.0
scale: float = 0.0
hardware: HardwareID = field(default_factory=HardwareID)


class PadMap:
Expand All @@ -47,25 +43,19 @@ class PadMap:
----------
map: dict[int, PadData]
The forward map (pad number -> PadData)
elec_map: dict[int -> int]
Essentially a reverse map of HardwareID -> pad number

Methods
-------
PadMap(geometry_path: Path, gain_path: Path, time_correction_path: Path, electronics_path: Path, scale_path: Path)
PadMap(params)
Construct the PadMap
load(geometry_path: Path, gain_path: Path, time_correction_path: Path, electronics_path: Path, scale_path: Path)
load the map data
get_pad_data(pad_number: int) -> PadData | None
get_pad_data(pad_number)
Get the PadData for a given pad. Returns None if the pad does not exist
get_pad_from_hardware(hardware: HardwareID) -> int | None
Get the pad number for a given HardwareID. Returns None if the HardwareID is invalid

is_beam_pad(pad_number)
Check if a pad is a beam pad (returns True if beam, False otherwise)
"""

def __init__(self, params: PadParameters):
self.map: dict[int, PadData] = {}
self.elec_map: dict[int, int] = {}
self.is_valid = False
self.load(params)

Expand Down Expand Up @@ -122,41 +112,6 @@ def load(self, params: PadParameters):
entries = line.split(",")
self.map[pad_number].time_offset = float(entries[0])

# Electronics
if params.pad_electronics_path == DEFAULT_MAP:
elec_handle = directory.joinpath("pad_electronics.csv")
with resources.as_file(elec_handle) as elecpath:
elecfile = open(elecpath, "r")
elecfile.readline()
lines = elecfile.readlines()
for line in lines:
entries = line.split(",")
hardware = HardwareID(
int(entries[4]),
int(entries[0]),
int(entries[1]),
int(entries[2]),
int(entries[3]),
)
self.map[hardware.pad_id].hardware = hardware
self.elec_map[generate_electronics_id(hardware)] = hardware.pad_id
elecfile.close()
else:
with open(params.pad_electronics_path, "r") as elecfile:
elecfile.readline()
lines = elecfile.readlines()
for line in lines:
entries = line.split(",")
hardware = HardwareID(
int(entries[4]),
int(entries[0]),
int(entries[1]),
int(entries[2]),
int(entries[3]),
)
self.map[hardware.pad_id].hardware = hardware
self.elec_map[generate_electronics_id(hardware)] = hardware.pad_id

# Scale
if params.pad_scale_path == DEFAULT_MAP:
scale_handle = directory.joinpath("pad_scale.csv")
Expand Down Expand Up @@ -199,28 +154,6 @@ def get_pad_data(self, pad_number: int) -> PadData | None:

return self.map[pad_number]

def get_pad_from_hardware(self, hardware: HardwareID) -> int | None:
"""Get the pad number associated with a HardwareID

Returns None if the HardwareID is invalid

Parameters
----------
hardware: HardwareID
A HardwareID

Returns
-------
int | None
The associated pad number, or None if the HardwareID is invalid

"""
key = generate_electronics_id(hardware)
if key in self.elec_map.keys():
return self.elec_map[generate_electronics_id(hardware)]

return None

def is_beam_pad(self, pad_id: int) -> bool:
"""Check if a pad is a Beam Pad (TM)

Expand Down
17 changes: 2 additions & 15 deletions src/spyral/core/point_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from .config import DetectorParameters
from ..correction import ElectronCorrector
from ..trace.get_event import GetEvent
from .spy_log import spyral_warn
from dataclasses import dataclass
import numpy as np

Expand Down Expand Up @@ -65,20 +64,8 @@ def point_cloud_from_get(event: GetEvent, pad_map: PadMap) -> PointCloud:
continue

pid = trace.hw_id.pad_id
check = pad_map.get_pad_from_hardware(trace.hw_id)
if check is None:
spyral_warn(
__name__,
f"When checking pad number of hardware: {trace.hw_id}, recieved None!",
)
continue
if (
check != pid
): # This is dangerous! We trust the pad map over the merged data!
pid = check

pad = pad_map.get_pad_data(check)
if pad is None or pad_map.is_beam_pad(check):
pad = pad_map.get_pad_data(pid)
if pad is None or pad_map.is_beam_pad(pid):
continue
for peak in trace.get_peaks():
cloud_matrix[idx, 0] = pad.x # X-coordinate, geometry
Expand Down
Loading