libtcspc C++ API
Streaming TCSPC and time tag data processing
Loading...
Searching...
No Matches
time_tagged_events.hpp
1/*
2 * This file is part of libtcspc
3 * Copyright 2019-2026 Board of Regents of the University of Wisconsin System
4 * SPDX-License-Identifier: MIT
5 */
6
7#pragma once
8
9#include "data_types.hpp"
10
11#include <array>
12#include <ostream>
13#include <type_traits>
14
15namespace tcspc {
16
41template <typename DataTypes = default_data_types> struct time_reached_event {
43 typename DataTypes::abstime_type abstime;
44 static_assert(std::is_integral_v<decltype(abstime)>);
45
47 friend auto operator==(time_reached_event const &lhs,
48 time_reached_event const &rhs) noexcept
49 -> bool = default;
50
52 friend auto operator<<(std::ostream &s, time_reached_event const &e)
53 -> std::ostream & {
54 return s << "time_reached(" << e.abstime << ')';
55 }
56};
57
76template <typename DataTypes = default_data_types> struct data_lost_event {
78 typename DataTypes::abstime_type abstime;
79 static_assert(std::is_integral_v<decltype(abstime)>);
80
82 friend auto operator==(data_lost_event const &lhs,
83 data_lost_event const &rhs) noexcept
84 -> bool = default;
85
87 friend auto operator<<(std::ostream &s, data_lost_event const &e)
88 -> std::ostream & {
89 return s << "data_lost(" << e.abstime << ')';
90 }
91};
92
109template <typename DataTypes = default_data_types>
112 typename DataTypes::abstime_type abstime;
113 static_assert(std::is_integral_v<decltype(abstime)>);
114
116 friend auto operator==(begin_lost_interval_event const &lhs,
117 begin_lost_interval_event const &rhs) noexcept
118 -> bool = default;
119
121 friend auto operator<<(std::ostream &s, begin_lost_interval_event const &e)
122 -> std::ostream & {
123 (void)e;
124 return s << "begin_lost_interval()";
125 }
126};
127
135template <typename DataTypes = default_data_types>
138 typename DataTypes::abstime_type abstime;
139 static_assert(std::is_integral_v<decltype(abstime)>);
140
142 friend auto operator==(end_lost_interval_event const &lhs,
143 end_lost_interval_event const &rhs) noexcept
144 -> bool = default;
145
147 friend auto operator<<(std::ostream &s, end_lost_interval_event const &e)
148 -> std::ostream & {
149 (void)e;
150 return s << "end_lost_interval()";
151 }
152};
153
164template <typename DataTypes = default_data_types> struct lost_counts_event {
166 typename DataTypes::abstime_type abstime;
167 static_assert(std::is_integral_v<decltype(abstime)>);
168
170 typename DataTypes::channel_type channel;
171 static_assert(std::is_integral_v<decltype(channel)>);
172
176 typename DataTypes::count_type count;
177 static_assert(std::is_integral_v<decltype(count)>);
178
180 friend auto operator==(lost_counts_event const &lhs,
181 lost_counts_event const &rhs) noexcept
182 -> bool = default;
183
185 friend auto operator<<(std::ostream &s, lost_counts_event const &e)
186 -> std::ostream & {
187 return s << "lost_counts(" << e.abstime << ", " << e.channel << ", "
188 << e.count << ')';
189 }
190};
191
203template <typename DataTypes = default_data_types> struct bulk_counts_event {
205 typename DataTypes::abstime_type abstime;
206 static_assert(std::is_integral_v<decltype(abstime)>);
207
209 typename DataTypes::channel_type channel;
210 static_assert(std::is_integral_v<decltype(channel)>);
211
213 typename DataTypes::count_type count;
214 static_assert(std::is_integral_v<decltype(count)>);
215
217 friend auto operator==(bulk_counts_event const &lhs,
218 bulk_counts_event const &rhs) noexcept
219 -> bool = default;
220
222 friend auto operator<<(std::ostream &s, bulk_counts_event const &e)
223 -> std::ostream & {
224 return s << "bulk_counts(" << e.abstime << ", " << e.channel << ", "
225 << e.count << ')';
226 }
227};
228
236template <typename DataTypes = default_data_types> struct detection_event {
238 typename DataTypes::abstime_type abstime;
239 static_assert(std::is_integral_v<decltype(abstime)>);
240
242 typename DataTypes::channel_type channel;
243 static_assert(std::is_integral_v<decltype(channel)>);
244
246 friend auto operator==(detection_event const &lhs,
247 detection_event const &rhs) noexcept
248 -> bool = default;
249
251 friend auto operator<<(std::ostream &s, detection_event const &e)
252 -> std::ostream & {
253 return s << "detection(" << e.abstime << ", " << e.channel << ')';
254 }
255};
256
266template <typename DataTypes = default_data_types>
269 typename DataTypes::abstime_type abstime;
270 static_assert(std::is_integral_v<decltype(abstime)>);
271
273 typename DataTypes::channel_type channel;
274 static_assert(std::is_integral_v<decltype(channel)>);
275
280 typename DataTypes::difftime_type difftime;
281 static_assert(std::is_integral_v<decltype(difftime)>);
282
285 time_correlated_detection_event const &rhs) noexcept
286 -> bool = default;
287
289 friend auto operator<<(std::ostream &s,
291 -> std::ostream & {
292 return s << "time_correlated_detection(" << e.abstime << ", "
293 << e.channel << ", " << e.difftime << ')';
294 }
295};
296
320template <typename DataTypes = default_data_types> struct marker_event {
322 typename DataTypes::abstime_type abstime;
323 static_assert(std::is_integral_v<decltype(abstime)>);
324
326 typename DataTypes::channel_type channel;
327 static_assert(std::is_integral_v<decltype(channel)>);
328
330 friend auto operator==(marker_event const &lhs,
331 marker_event const &rhs) noexcept -> bool = default;
332
334 friend auto operator<<(std::ostream &s, marker_event const &e)
335 -> std::ostream & {
336 return s << "marker(" << e.abstime << ", " << e.channel << ')';
337 }
338};
339
348template <typename DataTypes>
349auto operator<<(std::ostream &s,
350 std::array<detection_event<DataTypes>, 2> const &e)
351 -> std::ostream & {
352 return s << "[" << e[0] << ", " << e[1] << ']';
353}
354
355} // namespace tcspc
libtcspc namespace.
Definition acquire.hpp:29
Event indicating beginning of interval in which counts were lost.
Definition time_tagged_events.hpp:110
friend auto operator<<(std::ostream &s, begin_lost_interval_event const &e) -> std::ostream &
Stream insertion operator.
Definition time_tagged_events.hpp:121
friend auto operator==(begin_lost_interval_event const &lhs, begin_lost_interval_event const &rhs) noexcept -> bool=default
Equality comparison operator.
DataTypes::abstime_type abstime
The absolute time (a.k.a. macrotime) of this event.
Definition time_tagged_events.hpp:112
Event indicating number of detections from a non-time-tagging device.
Definition time_tagged_events.hpp:203
DataTypes::abstime_type abstime
The absolute time (a.k.a. macrotime) of this event.
Definition time_tagged_events.hpp:205
DataTypes::count_type count
Number of non-time-tagged counts detected.
Definition time_tagged_events.hpp:213
friend auto operator==(bulk_counts_event const &lhs, bulk_counts_event const &rhs) noexcept -> bool=default
Equality comparison operator.
friend auto operator<<(std::ostream &s, bulk_counts_event const &e) -> std::ostream &
Stream insertion operator.
Definition time_tagged_events.hpp:222
DataTypes::channel_type channel
The channel on which this event occurred.
Definition time_tagged_events.hpp:209
Event indicating loss of data due to buffer overflow.
Definition time_tagged_events.hpp:76
DataTypes::abstime_type abstime
The absolute time (a.k.a. macrotime) of this event.
Definition time_tagged_events.hpp:78
friend auto operator==(data_lost_event const &lhs, data_lost_event const &rhs) noexcept -> bool=default
Equality comparison operator.
friend auto operator<<(std::ostream &s, data_lost_event const &e) -> std::ostream &
Stream insertion operator.
Definition time_tagged_events.hpp:87
Event indicating a detected count.
Definition time_tagged_events.hpp:236
friend auto operator==(detection_event const &lhs, detection_event const &rhs) noexcept -> bool=default
Equality comparison operator.
DataTypes::abstime_type abstime
The absolute time (a.k.a. macrotime) of this event.
Definition time_tagged_events.hpp:238
DataTypes::channel_type channel
The channel on which this event occurred.
Definition time_tagged_events.hpp:242
friend auto operator<<(std::ostream &s, detection_event const &e) -> std::ostream &
Stream insertion operator.
Definition time_tagged_events.hpp:251
Event indicating end of interval in which counts were lost.
Definition time_tagged_events.hpp:136
DataTypes::abstime_type abstime
The absolute time (a.k.a. macrotime) of this event.
Definition time_tagged_events.hpp:138
friend auto operator<<(std::ostream &s, end_lost_interval_event const &e) -> std::ostream &
Stream insertion operator.
Definition time_tagged_events.hpp:147
friend auto operator==(end_lost_interval_event const &lhs, end_lost_interval_event const &rhs) noexcept -> bool=default
Equality comparison operator.
Event indicating number of counts that could not be time-tagged.
Definition time_tagged_events.hpp:164
DataTypes::channel_type channel
The channel on which this event occurred.
Definition time_tagged_events.hpp:170
friend auto operator<<(std::ostream &s, lost_counts_event const &e) -> std::ostream &
Stream insertion operator.
Definition time_tagged_events.hpp:185
friend auto operator==(lost_counts_event const &lhs, lost_counts_event const &rhs) noexcept -> bool=default
Equality comparison operator.
DataTypes::abstime_type abstime
The absolute time (a.k.a. macrotime) of this event.
Definition time_tagged_events.hpp:166
DataTypes::count_type count
Number of counts that were detected but could not be time-tagged.
Definition time_tagged_events.hpp:176
Event indicating a timing marker.
Definition time_tagged_events.hpp:320
friend auto operator==(marker_event const &lhs, marker_event const &rhs) noexcept -> bool=default
Equality comparison operator.
DataTypes::abstime_type abstime
The absolute time (a.k.a. macrotime) of this event.
Definition time_tagged_events.hpp:322
friend auto operator<<(std::ostream &s, marker_event const &e) -> std::ostream &
Stream insertion operator.
Definition time_tagged_events.hpp:334
DataTypes::channel_type channel
The channel on which this event occurred.
Definition time_tagged_events.hpp:326
Event indicating a detected count (typically photon) with difference time.
Definition time_tagged_events.hpp:267
friend auto operator<<(std::ostream &s, time_correlated_detection_event const &e) -> std::ostream &
Stream insertion operator.
Definition time_tagged_events.hpp:289
DataTypes::difftime_type difftime
Difference time (a.k.a. microtime, nanotime) associated with the detected event.
Definition time_tagged_events.hpp:280
DataTypes::abstime_type abstime
The absolute time (a.k.a. macrotime) of this event.
Definition time_tagged_events.hpp:269
DataTypes::channel_type channel
The channel on which this event occurred.
Definition time_tagged_events.hpp:273
friend auto operator==(time_correlated_detection_event const &lhs, time_correlated_detection_event const &rhs) noexcept -> bool=default
Equality comparison operator.
Event indicating latest abstime reached.
Definition time_tagged_events.hpp:41
friend auto operator<<(std::ostream &s, time_reached_event const &e) -> std::ostream &
Stream insertion operator.
Definition time_tagged_events.hpp:52
friend auto operator==(time_reached_event const &lhs, time_reached_event const &rhs) noexcept -> bool=default
Equality comparison operator.
DataTypes::abstime_type abstime
The absolute time (a.k.a. macrotime) of this event.
Definition time_tagged_events.hpp:43