Skip to main content

DetectorConfig

Struct DetectorConfig 

Source
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: f64

TDC frequency in Hz (default: 60.0 for SNS).

§enable_missing_tdc_correction: bool

Enable missing TDC correction.

§chip_size_x: u16

Chip size X in pixels (default: 256).

§chip_size_y: u16

Chip size Y in pixels (default: 256).

§chip_transforms: Vec<ChipTransform>

Per-chip affine transforms.

Implementations§

Source§

impl DetectorConfig

Source

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)
Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn tdc_period_seconds(&self) -> f64

TDC period in seconds.

Source

pub fn tdc_correction_25ns(&self) -> u32

TDC correction value in 25ns units.

Source

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).

Source

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

Source§

fn clone(&self) -> DetectorConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DetectorConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DetectorConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for DetectorConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for DetectorConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,