|
1 | 1 | /** |
2 | 2 | * @file sbnobj/SBND/Timing/FrameShiftInfo.hh |
3 | | - * @brief Defines data structures for SBND Frame Shift products (docdb#43090). |
| 3 | + * @brief Defines data structures for SBND Frame Shift products |
4 | 4 | * @author Vu Chi Lan Nguyen |
5 | | - * @date August 29, 2025 |
6 | 5 | * |
7 | 6 | */ |
8 | 7 |
|
|
12 | 11 | #include <stdint.h> |
13 | 12 | #include <limits> |
14 | 13 |
|
| 14 | +#include "sbnobj/SBND/Timing/TimingInfo.hh" |
| 15 | + |
15 | 16 | namespace sbnd::timing { |
16 | 17 |
|
17 | 18 | /** |
18 | | - * @brief A class to store the shifts across different time reference frames in SBND Data |
| 19 | + * @brief A class to store reference frames in SBND Data |
| 20 | + * |
| 21 | + * Each reference frame is in UNIX timestamp format [ns] |
| 22 | + * Store duplicated information from TimingInfo.hh for easier access at downstream modules. |
| 23 | + * |
| 24 | + * Reference frames included: |
| 25 | + * |
| 26 | + * CRT T1 signal frame: |
| 27 | + * - Either from TDC or PTB HLT, TDC has higher priority if both are available |
| 28 | + * - If selected, TDC CRT T1 frame is shifted to agree with HLT CRT T1 frame |
| 29 | + * - Both unshifted TDC CRT T1 and HLT CRT T1 timestamps are saved in TimingInfo |
| 30 | + * |
| 31 | + * Beam Gate frame: differs between beam vs offbeam stream |
| 32 | + * - Beam stream: |
| 33 | + * - Either from TDC RWM or PTB HLT Gate, TDC RWM has higher priority if both are available |
| 34 | + * - If selected, TDC RWM is shifted to agree with HLT Beam Gate frame |
| 35 | + * - Both unshifted TDC RWM and HLT Beam Gate timestamps are saved in TimingInfo |
| 36 | + * - Offbeam stream: |
| 37 | + * - From PTB HLT Gate only |
| 38 | + * - Saved in TimingInfo |
| 39 | + * |
| 40 | + * ETRIG frame: |
| 41 | + * - Either from TDC or PTB HLT, TDC has higher priority if both are available |
| 42 | + * - If selected, TDC ETRIG frame is shifted to agree with HLT ETRIG frame |
| 43 | + * - Both unshifted TDC ETRIG and HLT ETRIG timestamps are saved in TimingInfo |
| 44 | + * |
| 45 | + * Default frame: depends on the stream type |
| 46 | + * - Beam stream: use Beam Gate frame |
| 47 | + * - Offbeam stream: use Beam Gate frame |
| 48 | + * - Xmuon stream: use ETRIG frame |
19 | 49 | * |
20 | | - * Each shift is in [ns] |
21 | | - * |
| 50 | + * Timing Type indicates which source the frame is derived from: |
| 51 | + * 0 - SPEC TDC |
| 52 | + * 1 - PTB HLT |
| 53 | + * 2 - No frame found |
| 54 | + * std::numeric_limits<uint16_t>::max() - Not initialized |
| 55 | + * |
| 56 | + * Timing Channel incicates which channel the frame is derived from: |
| 57 | + * SPEC TDC: indicates which input channel 0 to 4 |
| 58 | + * PTB: indicates the High Level Trigger (HLT) type |
| 59 | + * |
22 | 60 | * For more information, see |
23 | | - * [SBN DocDB 43090](https://sbn-docdb.fnal.gov/cgi-bin/sso/ShowDocument?docid=43090). |
| 61 | + * [SBN DocDB 46654](https://sbn-docdb.fnal.gov/cgi-bin/sso/ShowDocument?docid=46654). |
24 | 62 | */ |
25 | 63 |
|
| 64 | + enum TimingType : uint16_t { |
| 65 | + kSPECTDCType, |
| 66 | + kPTBHLTType, |
| 67 | + kNoShiftType, |
| 68 | + kInvalidType = std::numeric_limits<uint16_t>::max() |
| 69 | + }; |
| 70 | + |
| 71 | + static constexpr uint16_t kInvalidChannel = std::numeric_limits<uint16_t>::max(); |
| 72 | + |
26 | 73 | class FrameShiftInfo { |
27 | | - |
28 | | - public: |
29 | | - static constexpr uint16_t InvalidTimingType = 99; ///< Invalid timing type for decoded frame |
30 | | - static constexpr uint64_t NoShift = 0; ///< No shift. |
31 | 74 |
|
32 | | - private: |
| 75 | + uint64_t fFrameCrtt1 = kInvalidTimestamp; ///< Frame for CRT T1 signal [ns] |
| 76 | + uint16_t fTimingTypeCrtt1 = kInvalidType; ///< Types of CRT T1 frame |
| 77 | + uint16_t fTimingChannelCrtt1 = kInvalidChannel; ///< Channel of CRT T1 frame |
| 78 | + |
| 79 | + uint64_t fFrameBeamGate = kInvalidTimestamp; ///< Frame for Beam Gate [ns] |
| 80 | + uint16_t fTimingTypeBeamGate = kInvalidType; ///< Types of Beam Gate frame |
| 81 | + uint16_t fTimingChannelBeamGate = kInvalidChannel; ///< Channel of Beam Gate frame |
| 82 | + |
| 83 | + uint64_t fFrameEtrig = kInvalidTimestamp; ///< Frame for ETRIG [ns] |
| 84 | + uint16_t fTimingTypeEtrig = kInvalidType; ///< Types of ETRIG frame |
| 85 | + uint16_t fTimingChannelEtrig = kInvalidChannel; ///< Channel of ETRIG frame |
33 | 86 |
|
34 | | - uint16_t fTimingType = InvalidTimingType; ///< Types of decoded frames: 0 - SPEC TDC ETRIG, 1 - HLT ETRIG, 2 - Do Nothing |
35 | | - double fFrameTdcCrtt1 = NoShift; ///< Shift from decoded frame to SPEC-TDC CRT T1 [ns] |
36 | | - double fFrameTdcBes = NoShift; ///< Shift from decoded frame to SPEC-TDC BES [ns] |
37 | | - double fFrameTdcRwm = NoShift; ///< Shift from decoded frame to SPEC-TDC RWM [ns] |
38 | | - double fFrameHltCrtt1 = NoShift; ///< Shift from decoded frame to HLT CRT T1 [ns] |
39 | | - double fFrameHltBeamGate = NoShift; ///< Shift from decoded frame to HLT Beam Gate [ns] |
40 | | - double fFrameApplyAtCaf = NoShift; ///< Frame to shift to when running at CAF stage |
| 87 | + uint64_t fFrameDefault = kInvalidTimestamp; ///< Default frame depending on the stream type [ns] |
| 88 | + uint16_t fTimingTypeDefault = kInvalidType; ///< Types of default frame |
| 89 | + uint16_t fTimingChannelDefault = kInvalidChannel; ///< Channel of default frame |
41 | 90 |
|
42 | 91 | public: |
43 | 92 |
|
44 | 93 | /** |
45 | | - * Default constructor. |
| 94 | + * @brief Default constructor. |
46 | 95 | */ |
47 | 96 | FrameShiftInfo() = default; |
48 | 97 |
|
49 | 98 | /** |
50 | | - * Constructor to set all frames |
| 99 | + * @brief Constructs the object with all frame timestamps and metadata. |
| 100 | + * |
| 101 | + * @param[in] frameCrtt1 Frame for CRT T1 [ns]. |
| 102 | + * @param[in] timingTypeCrtt1 Timing type for CRT T1 frame. |
| 103 | + * @param[in] timingChannelCrtt1 Timing channel for CRT T1 frame. |
| 104 | + * |
| 105 | + * @param[in] frameBeamGate Frame for Beam Gate [ns]. |
| 106 | + * @param[in] timingTypeBeamGate Timing type for Beam Gate frame. |
| 107 | + * @param[in] timingChannelBeamGate Timing channel for Beam Gate frame. |
| 108 | + * |
| 109 | + * @param[in] frameEtrig Frame for ETRIG [ns]. |
| 110 | + * @param[in] timingTypeEtrig Timing type for ETRIG frame. |
| 111 | + * @param[in] timingChannelEtrig Timing channel for ETRIG frame. |
| 112 | + * |
| 113 | + * @param[in] frameDefault Default frame depending on the stream [ns]. |
| 114 | + * @param[in] timingTypeDefault Timing type for default frame. |
| 115 | + * @param[in] timingChannelDefault Timing channel for default frame. |
51 | 116 | * |
52 | | - * @param timingType Types of decoded frames |
53 | | - * @param frameTdcCrtt1 Shift from decoded frame to SPEC-TDC CRT T1 [ns] |
54 | | - * @param frameTdcBes Shift from decoded frame to SPEC-TDC BES [ns] |
55 | | - * @param frameTdcRwm Shift from decoded frame to SPEC-TDC RWM [ns] |
56 | | - * @param frameHltCrtt1 Shift from decoded frame to HLT CRT T1 [ns] |
57 | | - * @param frameHltBeamGate Shift from decoded frame to HLT Beam Gate [ns] |
58 | | - * @param frameApplyAtCaf Frame to shift to when running at CAF stage |
59 | 117 | */ |
60 | | - FrameShiftInfo(uint16_t timingType, double frameTdcCrtt1, double frameTdcBes, double frameTdcRwm, double frameHltCrtt1, double frameHltBeamGate, double frameApplyAtCaf); |
| 118 | + FrameShiftInfo(uint64_t frameCrtt1, uint16_t timingTypeCrtt1, uint16_t timingChannelCrtt1, |
| 119 | + uint64_t frameBeamGate, uint16_t timingTypeBeamGate, uint16_t timingChannelBeamGate, |
| 120 | + uint64_t frameEtrig, uint16_t timingTypeEtrig, uint16_t timingChannelEtrig, |
| 121 | + uint64_t frameDefault, uint16_t timingTypeDefault, uint16_t timingChannelDefault); |
61 | 122 |
|
62 | 123 | /// @name Getters |
63 | 124 | /// @{ |
64 | | - uint16_t TimingType() const { return fTimingType; } |
65 | | - double FrameTdcCrtt1() const { return fFrameTdcCrtt1; } |
66 | | - double FrameTdcBes() const { return fFrameTdcBes; } |
67 | | - double FrameTdcRwm() const { return fFrameTdcRwm; } |
68 | | - double FrameHltCrtt1() const { return fFrameHltCrtt1;} |
69 | | - double FrameHltBeamGate() const { return fFrameHltBeamGate; } |
70 | | - double FrameApplyAtCaf() const { return fFrameApplyAtCaf; } |
| 125 | + /// @brief Returns the CRT T1 reference frame timestamp [ns]. |
| 126 | + uint64_t FrameCrtt1() const { return fFrameCrtt1; } |
| 127 | + /// @brief Returns the timing source type for the CRT T1 frame. |
| 128 | + uint16_t TimingTypeCrtt1() const { return fTimingTypeCrtt1; } |
| 129 | + /// @brief Returns the timing source channel for the CRT T1 frame. |
| 130 | + uint16_t TimingChannelCrtt1() const { return fTimingChannelCrtt1; } |
| 131 | + |
| 132 | + /// @brief Returns the Beam Gate reference frame timestamp [ns]. |
| 133 | + uint64_t FrameBeamGate() const { return fFrameBeamGate; } |
| 134 | + /// @brief Returns the timing source type for the Beam Gate frame. |
| 135 | + uint16_t TimingTypeBeamGate() const { return fTimingTypeBeamGate; } |
| 136 | + /// @brief Returns the timing source channel for the Beam Gate frame. |
| 137 | + uint16_t TimingChannelBeamGate() const { return fTimingChannelBeamGate; } |
| 138 | + |
| 139 | + /// @brief Returns the ETRIG reference frame timestamp [ns]. |
| 140 | + uint64_t FrameEtrig() const { return fFrameEtrig; } |
| 141 | + /// @brief Returns the timing source type for the ETRIG frame. |
| 142 | + uint16_t TimingTypeEtrig() const { return fTimingTypeEtrig; } |
| 143 | + /// @brief Returns the timing source channel for the ETRIG frame. |
| 144 | + uint16_t TimingChannelEtrig() const { return fTimingChannelEtrig; } |
| 145 | + |
| 146 | + /// @brief Returns the default reference frame timestamp [ns]. |
| 147 | + uint64_t FrameDefault() const { return fFrameDefault; } |
| 148 | + /// @brief Returns the timing source type for the default frame. |
| 149 | + uint16_t TimingTypeDefault() const { return fTimingTypeDefault; } |
| 150 | + /// @brief Returns the timing source channel for the default frame. |
| 151 | + uint16_t TimingChannelDefault() const { return fTimingChannelDefault; } |
71 | 152 | /// @} |
72 | 153 |
|
73 | 154 | /// @name Setters |
74 | 155 | /// @{ |
75 | | - void SetTimingType(uint16_t type){ fTimingType = type; } |
76 | | - void SetFrameTdcCrtt1(double frame){ fFrameTdcCrtt1 = frame; } |
77 | | - void SetFrameTdcBes(double frame){ fFrameTdcBes = frame; } |
78 | | - void SetFrameTdcRwm(double frame){ fFrameTdcRwm = frame; } |
79 | | - void SetFrameHltCrtt1(double frame){ fFrameHltCrtt1 = frame; } |
80 | | - void SetFrameHltBeamGate(double frame){ fFrameHltBeamGate = frame; } |
81 | | - void SetFrameApplyAtCaf(double frame){ fFrameApplyAtCaf = frame; } |
| 156 | + /// @brief Sets the CRT T1 reference frame timestamp [ns]. |
| 157 | + /// @param[in] frame CRT T1 frame timestamp. |
| 158 | + void SetFrameCrtt1(uint64_t frame){ fFrameCrtt1 = frame; } |
| 159 | + /// @brief Sets the timing source type for the CRT T1 frame. |
| 160 | + /// @param[in] type Timing type value. |
| 161 | + void SetTimingTypeCrtt1(uint16_t type){ fTimingTypeCrtt1 = type; } |
| 162 | + /// @brief Sets the timing source channel for the CRT T1 frame. |
| 163 | + /// @param[in] channel Timing channel value. |
| 164 | + void SetTimingChannelCrtt1(uint16_t channel){ fTimingChannelCrtt1 = channel; } |
| 165 | + |
| 166 | + /// @brief Sets the Beam Gate reference frame timestamp [ns]. |
| 167 | + /// @param[in] frame Beam Gate frame timestamp. |
| 168 | + void SetFrameBeamGate(uint64_t frame){ fFrameBeamGate = frame; } |
| 169 | + /// @brief Sets the timing source type for the Beam Gate frame. |
| 170 | + /// @param[in] type Timing type value. |
| 171 | + void SetTimingTypeBeamGate(uint16_t type){ fTimingTypeBeamGate = type; } |
| 172 | + /// @brief Sets the timing source channel for the Beam Gate frame. |
| 173 | + /// @param[in] channel Timing channel value. |
| 174 | + void SetTimingChannelBeamGate(uint16_t channel){ fTimingChannelBeamGate = channel; } |
| 175 | + |
| 176 | + /// @brief Sets the ETRIG reference frame timestamp [ns]. |
| 177 | + /// @param[in] frame ETRIG frame timestamp. |
| 178 | + void SetFrameEtrig(uint64_t frame){ fFrameEtrig = frame; } |
| 179 | + /// @brief Sets the timing source type for the ETRIG frame. |
| 180 | + /// @param[in] type Timing type value. |
| 181 | + void SetTimingTypeEtrig(uint16_t type){ fTimingTypeEtrig = type; } |
| 182 | + /// @brief Sets the timing source channel for the ETRIG frame. |
| 183 | + /// @param[in] channel Timing channel value. |
| 184 | + void SetTimingChannelEtrig(uint16_t channel){ fTimingChannelEtrig = channel; } |
| 185 | + |
| 186 | + /// @brief Sets the default reference frame timestamp [ns]. |
| 187 | + /// @param[in] frame Default frame timestamp. |
| 188 | + void SetFrameDefault(uint64_t frame){ fFrameDefault = frame; } |
| 189 | + /// @brief Sets the timing source type for the default frame. |
| 190 | + /// @param[in] type Timing type value. |
| 191 | + void SetTimingTypeDefault(uint16_t type){ fTimingTypeDefault = type; } |
| 192 | + /// @brief Sets the timing source channel for the default frame. |
| 193 | + /// @param[in] channel Timing channel value. |
| 194 | + void SetTimingChannelDefault(uint16_t channel){ fTimingChannelDefault = channel; } |
82 | 195 | /// @} |
83 | 196 | }; |
84 | 197 | } |
|
0 commit comments