pub struct DetectorConfig {
pub tdc_frequency_hz: f64,
pub enable_missing_tdc_correction: bool,
pub chip_size_x: u16,
pub chip_size_y: u16,
pub chip_transforms: Vec<ChipTransform>,
}Expand description
Detector configuration for TPX3 processing.
Fields§
§tdc_frequency_hz: f64TDC frequency in Hz (default: 60.0 for SNS).
enable_missing_tdc_correction: boolEnable missing TDC correction.
chip_size_x: u16Chip size X in pixels (default: 256).
chip_size_y: u16Chip size Y in pixels (default: 256).
chip_transforms: Vec<ChipTransform>Per-chip affine transforms.
Implementations§
Source§impl DetectorConfig
impl DetectorConfig
Sourcepub fn venus_defaults() -> Self
pub fn venus_defaults() -> Self
Create VENUS/SNS default configuration.
Uses specific affine transforms for the 4 chips:
- Chip 0: Translation (258, 0)
- Chip 1: Rotation 180 + Translation (513, 513)
- Chip 2: Rotation 180 + Translation (255, 513)
- Chip 3: Identity (0, 0)
Sourcepub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, Box<dyn Error>>
pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, Box<dyn Error>>
Load configuration from a JSON file (C++ compatible schema).
Validates all chip transforms to ensure they produce valid coordinates.
§Errors
Returns an error if the file cannot be read or the JSON is invalid.
Sourcepub fn from_json(json: &str) -> Result<Self, Box<dyn Error>>
pub fn from_json(json: &str) -> Result<Self, Box<dyn Error>>
Load configuration from a JSON string (C++ compatible schema).
Validates all chip transforms to ensure they produce valid coordinates.
§Errors
Returns an error if the JSON is invalid.
Sourcepub fn to_json_string(&self) -> Result<String, Box<dyn Error>>
pub fn to_json_string(&self) -> Result<String, Box<dyn Error>>
Serialize configuration to a JSON string (C++ compatible schema).
§Errors
Returns an error if serialization fails.
Sourcepub fn to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), Box<dyn Error>>
pub fn to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), Box<dyn Error>>
Save configuration to a JSON file (C++ compatible schema).
§Errors
Returns an error if serialization or file I/O fails.
Sourcepub fn validate_transforms(&self) -> Result<(), Box<dyn Error>>
pub fn validate_transforms(&self) -> Result<(), Box<dyn Error>>
Validate all chip transforms produce valid u16 coordinates.
This is called automatically when loading from JSON. For programmatically created configs, call this before processing.
§Errors
Returns an error if any transform is invalid.
Sourcepub fn tdc_period_seconds(&self) -> f64
pub fn tdc_period_seconds(&self) -> f64
TDC period in seconds.
Sourcepub fn tdc_correction_25ns(&self) -> u32
pub fn tdc_correction_25ns(&self) -> u32
TDC correction value in 25ns units.
Sourcepub fn map_chip_to_global(&self, chip_id: u8, x: u16, y: u16) -> (u16, u16)
pub fn map_chip_to_global(&self, chip_id: u8, x: u16, y: u16) -> (u16, u16)
Map local chip coordinates to global detector coordinates.
Uses the configured affine transform for the given chip ID. If chip ID is out of bounds, returns local coordinates as-is (identity).
Sourcepub fn detector_dimensions(&self) -> (usize, usize)
pub fn detector_dimensions(&self) -> (usize, usize)
Calculate detector dimensions from chip layout and transforms.
Returns (width, height) in pixels sized to include all transformed
chip coordinates, preserving gaps/offsets introduced by transforms.
Trait Implementations§
Source§impl Clone for DetectorConfig
impl Clone for DetectorConfig
Source§fn clone(&self) -> DetectorConfig
fn clone(&self) -> DetectorConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more