gondola_core/io/data_source.rs
1//! Generic approach to read all kinds of data within the GAPS wider
2//! ecosystem.
3//!
4//! We have:
5//! * binary data (typically with the ending .bin) - telemetered data
6//! * tof data which is written to the TOF CPU disks
7//! * Caraspace data - this is merged TOF CPU and binary data. This is
8//! currently used in L0 data.
9//! * data in a customized, special root format as it is created by
10//! SimpleDet
11// This file is part of gaps-online-software and published
12// under the GPLv3 license
13
14use crate::prelude::*;
15
16/// A generic data source which can digest all
17/// kinds of GAPS input data
18///
19/// The Datasource can combine all necessary
20/// meta information, such as information about
21/// paddles as well as calibration data for
22/// tracker and TOF.
23pub struct DataSource<T>
24 where T: Default + Serialization {
25 pub kind : DataSourceKind,
26 #[cfg(feature="database")]
27 pub paddles : HashMap<u8,TofPaddle>,
28 #[cfg(feature="database")]
29 pub strips : HashMap<u32, TrackerStrip>,
30 pub rb_calibrations : HashMap<u8,RBCalibrations>,
31 //pub strips : HashMap<u8,TrackerStrip>,
32 pub reader : dyn DataReader<T>,
33}
34
35impl<T> DataSource<T>
36 where T: Default + Serialization {
37 //pub fn new(source : &str, pattern : Option<&str>) -> Self {
38 // // at this point, source can be anything. Either a filename,
39 // // directory or a stream address.
40 // let data_kind : DataSourceKind;
41 // let regex_pattern : Regex;
42 // match list_path_contents_sorted(source, Some(regex_pattern)) {
43 // Err(err) => (),
44 // Ok(foo) => ()
45 // }
46 //}
47}
48
49/// A generic data source which can read all data
50/// used within gaps and is also able to connect
51/// to any network socket streaming packets
52///
53/// See also the DataSourceKind enum for types of
54/// data the source is compatible with
55#[cfg(feature="pybindings")]
56#[pyclass]
57#[pyo3(name="DataSource")]
58pub struct DataSourcePy {
59 // the idea here is to have a reader for everything
60 // and then select the right one base on context
61 // This is admittedly a bit of a kludge, but python
62 // does not support templating, so that's what we are going with
63 //tofreader : Arc<DataSource<TofPacket>>,
64 //telreader : Arc<DataSource<TelemetryPacket>>,
65 //crreader : Arc<DataSource<CRFrame>>,
66 pub tof_paddles : Arc<HashMap<u8,TofPaddle>>,
67 /// Geometry of each tracker strip
68 pub trk_strips : Arc<HashMap<u32, TrackerStrip>>,
69 /// Mask tracker strips
70 pub trk_masks : Arc<HashMap<u32, TrackerStripMask>>,
71 /// Tracker pedestal values
72 pub trk_ped : Arc<HashMap<u32, TrackerStripPedestal>>,
73 /// Transfer functions for tracker (adc -> energy)
74 pub trk_tf : Arc<HashMap<u32, TrackerStripTransferFunction>>,
75 /// Common noise data for tracker
76 pub trk_cmn : Arc<HashMap<u32, TrackerStripCmnNoise>>,
77}
78
79
80//#[cfg(feature="pybindings")]
81//#[pyclass]
82//struct TofEventIterator {
83//}
84//
85//#[cfg(feature="pybindings")]
86//#[pyclass]
87//struct TupleIterator {
88//}
89
90//// We introduce a series of iterators, which will allow fast unpacking for a dedicated
91//// data type
92//#[pyfunction]
93//fn create_iterator<'_py>(py: Python<'_py>, source: &DataSourcePy, tof_packet_type : Option<TofPacketType> , telemetry_packet_type : Option<TelemetryPacketType>) -> PyResult<Option<Bound<'_py,PyAny>>> {
94// return Ok(None);
95//}