gaps-online-software 0.10
online software for the TOF system for the GAPS experiment
Loading...
Searching...
No Matches
calibration.h
1#ifndef CALIBRATION_H_INCLUDED
2#define CALIBRATION_H_INCLUDED
3
4/********************************
5 * ReadoutBoard calibration:
6 * - convert adc, time bins in
7 * mV and nanoseconds.
8 *******************************/
9
10#include <vector>
11#include <string>
12#include <map>
13
14#include "tof_typedefs.h"
15#include "events.h"
16
17class RBEvent;
18
19
22void spike_cleaning_drs4(Vec<Vec<f32>> &wf, u16 tCell, i32 spikes[]);
23
25void spike_cleaning_simple(Vec<Vec<f32>> &voltages, bool calibrated = true);
26
28void spike_cleaning_all(Vec<Vec<f32>> &voltages, bool calibrated = true);
29
35 static constexpr u16 HEAD = 0xAAAA;
36 static constexpr u16 TAIL = 0x5555;
37 static bool serialize_event_data;
38
42 f32 d_v;
45 Vec<Vec<f32>> v_offsets;
46 Vec<Vec<f32>> v_dips;
47 Vec<Vec<f32>> v_incs;
48 Vec<Vec<f32>> t_bin;
49 // data used to calculate calibration constants
51 Vec<RBEvent> noi_data;
53 Vec<RBEvent> vcal_data;
55 Vec<RBEvent> tcal_data;
56
58
60 Vec<Vec<f32>> voltages (const RBEvent &event, bool spike_cleaning = false) const;
61 Vec<Vec<f32>> nanoseconds (const RBEvent &event) const;
62
63 Vec<f32> voltages (const RBEvent &event, const u8 channel) const;
64 Vec<f32> nanoseconds(const RBEvent &event, const u8 channel) const;
65
73 static auto from_bytestream(const Vec<u8> &bytestream, u64 &pos,
74 bool discard_events = true)
76
80 [[deprecated("Replaced by from_file, we will no longer write human readable calibration files")]]
81 static RBCalibration from_txtfile(const String &filename);
82
83
87 static auto from_file(const String &filename, bool discard_events = true)
90 auto to_string() const -> std::string;
91
95 static void disable_eventdata();
96
97 private:
98
100 bool channel_check(u8 channel) const;
101};
102
103// FIXME - we want to put everything in this namespace,
104// start with the new stuff
105namespace Gaps {
107 auto load_tof_calibrations(std::string const &pathname) -> std::map<u8, RBCalibration>;
108}
109
110std::ostream& operator<<(std::ostream& os, const RBCalibration& pck);
111
113typedef std::map<u8, RBCalibration> RBCalibrationMap;
114
115#endif
Definition calibration.h:105
Definition calibration.h:34
static auto from_file(const String &filename, bool discard_events=true) -> RBCalibration
auto to_string() const -> std::string
String representation for printing.
static RBCalibration from_txtfile(const String &filename)
f32 d_v
voltage difference between noi and voltage data
Definition calibration.h:42
Vec< Vec< f32 > > voltages(const RBEvent &event, bool spike_cleaning=false) const
get the voltage values for the traces of the event
static void disable_eventdata()
Vec< RBEvent > noi_data
The no-input data used to calculate the constants.
Definition calibration.h:51
Vec< RBEvent > vcal_data
The constant voltage data used to calculate the constants.
Definition calibration.h:53
static auto from_bytestream(const Vec< u8 > &bytestream, u64 &pos, bool discard_events=true) -> RBCalibration
u32 timestamp
timestamp when the calibration has been taken
Definition calibration.h:44
Vec< RBEvent > tcal_data
The timing calibration data used to calculate the constants.
Definition calibration.h:55
u8 rb_id
id of the RB this calibration belongs to
Definition calibration.h:40
Definition events.h:321