18#ifndef __stir_listmode_CListRecordGEHDF5_H__
19#define __stir_listmode_CListRecordGEHDF5_H__
26#include <boost/static_assert.hpp>
65 TIME_MARKER_EVT = 0x0,
66 COINC_COUNT_EVT = 0x1,
67 EXTERN_TRIG_EVT = 0x2,
82#if STIRIsNativeByteOrderBigEndian
86 std::uint16_t eventLength : 2;
87 std::uint16_t eventType : 1;
88 std::uint16_t eventTypeExt : 4;
89 std::uint16_t dummy : 9;
101 inline bool is_prompt()
const {
return true; }
102 inline Succeeded set_prompt(
const bool prompt =
true)
105 return Succeeded::no;
107 inline bool is_event()
const
109 return (eventType == COINC_EVT) ;
112 inline int get_tof_bin()
const {
return static_cast<int>(-deltaTime); }
113#if STIRIsNativeByteOrderBigEndian
117 std::uint16_t eventLength : 2;
118 std::uint16_t eventType : 1;
119 std::uint16_t hiXtalShortInteg : 1;
120 std::uint16_t loXtalShortInteg : 1;
121 std::uint16_t hiXtalScatterRec : 1;
122 std::uint16_t loXtalScatterRec : 1;
123 std::int16_t deltaTime : 9;
124 std::uint16_t hiXtalAxialID : 6;
125 std::uint16_t hiXtalTransAxID : 10;
126 std::uint16_t loXtalAxialID : 6;
127 std::uint16_t loXtalTransAxID : 10;
139 inline unsigned long get_time_in_millisecs()
const {
return (time_hi() << 16) | time_lo(); }
140 inline Succeeded set_time_in_millisecs(
const unsigned long time_in_millisecs)
142 data.timeMarkerLS = ((1UL << 16) - 1) & (time_in_millisecs);
143 data.timeMarkerMS = (time_in_millisecs) >> 16;
145 return Succeeded::yes;
147 inline bool is_time()
const
149 return (data.eventType == EXTENDED_EVT) && (data.eventTypeExt == TIME_MARKER_EVT);
155#if STIRIsNativeByteOrderBigEndian
158 std::uint16_t eventLength : 2;
159 std::uint16_t eventType : 1;
160 std::uint16_t eventTypeExt : 4;
161 std::uint16_t unused1 : 5;
162 std::uint16_t externEvt3 : 1;
163 std::uint16_t externEvt2 : 1;
164 std::uint16_t externEvt1 : 1;
165 std::uint16_t externEvt0 : 1;
166 std::uint16_t timeMarkerLS : 16;
167 std::uint16_t timeMarkerMS : 16;
173 unsigned long time_lo()
const
175 return data.timeMarkerLS;
177 unsigned long time_hi()
const
179 return data.timeMarkerMS;
206 CListRecordGEHDF5(
const shared_ptr<const ProjDataInfo>& proj_data_info_sptr,
const unsigned long first_time_stamp)
208 first_time_stamp(first_time_stamp)
211 bool is_time()
const override {
return this->time_data.is_time(); }
213 bool is_gating_input()
const
215 return this->gating_data.is_gating_input();
219 bool is_event()
const override
221 return this->event_data.is_event();
223 CListEvent& event()
override
227 const CListEvent& event()
const override
231 ListTime& time()
override
235 const ListTime& time()
const override
240 virtual CListGatingInput& gating_input()
242 virtual const CListGatingInput& gating_input()
const
245 bool operator==(
const CListRecord& e2)
const
250dynamic_cast<CListRecordGEHDF5
const *
>(&e2) != 0 &&
251 raw[0] ==
static_cast<CListRecordGEHDF5
const &
>(e2).raw[0] &&
252 (this->is_event() || (raw[1] ==
static_cast<CListRecordGEHDF5
const &
>(e2).raw[1]));
257 inline unsigned long get_time_in_millisecs()
const override
259 return time_data.get_time_in_millisecs() - first_time_stamp;
262 inline Succeeded set_time_in_millisecs(
const unsigned long time_in_millisecs)
override
264 return time_data.set_time_in_millisecs(time_in_millisecs);
267 inline unsigned int get_gating()
const
268 {
return gating_data.get_gating(); }
269 inline Succeeded set_gating(
unsigned int g)
270 {
return gating_data.set_gating(g); }
273 inline bool is_prompt()
const override
275 return event_data.is_prompt();
279 return event_data.set_prompt(prompt);
284 det_pos.pos1().tangential_coord()
285 = this->get_uncompressed_proj_data_info_sptr()->get_scanner_sptr()->get_num_detectors_per_ring() - 1
286 - event_data.loXtalTransAxID;
287 det_pos.pos1().axial_coord() = event_data.loXtalAxialID;
288 det_pos.pos2().tangential_coord()
289 = this->get_uncompressed_proj_data_info_sptr()->get_scanner_sptr()->get_num_detectors_per_ring() - 1
290 - event_data.hiXtalTransAxID;
291 det_pos.pos2().axial_coord() = event_data.hiXtalAxialID;
292 det_pos.timing_pos() = event_data.get_tof_bin();
301 virtual std::size_t size_of_record_at_ptr(
const char*
const data_ptr,
const std::size_t,
const bool do_byte_swap)
const
304 assert(do_byte_swap ==
false);
310 std::uint16_t raw[4];
312 std::copy(data_ptr, data_ptr + 2, &raw[0]);
313 switch (rec.eventLength)
315 case detail::LENGTH_6_EVT:
316 return std::size_t(6);
317 case detail::LENGTH_8_EVT:
318 return std::size_t(8);
319 case detail::LENGTH_16_EVT:
320 return std::size_t(16);
322 error(
"ClistRecordGEHDF5: error decoding event (eventLength bits are incorrect)");
323 return std::size_t(0);
327 virtual Succeeded init_from_data_ptr(
const char*
const data_ptr,
const std::size_t size,
const bool do_byte_swap)
331 std::copy(data_ptr, data_ptr + size,
reinterpret_cast<char*
>(&this->raw[0]));
335 error(
"ClistRecordGEHDF5: byte-swapping not supported yet. sorry");
339 return Succeeded::yes;
343 unsigned long first_time_stamp;
349 std::int32_t raw[16 / 4];
351 BOOST_STATIC_ASSERT(
sizeof(std::int32_t) == 4);
352 BOOST_STATIC_ASSERT(
sizeof(DataType) == 6);
353 BOOST_STATIC_ASSERT(
sizeof(TimeType) == 6);
Definition of STIRIsNativeByteOrderBigEndian and STIRIsNativeByteOrderLittleEndian preprocessor symbo...
This file declares the stir::ByteOrder class.
Declarations of class stir::CListEventCylindricalScannerWithDiscreteDetectors.
Declarations of classes stir::CListRecord, and stir::CListEvent which are used for list mode data.
Declaration of class stir::Succeeded.
Class for storing and using a coincidence event from a list mode file for a cylindrical scanner.
Definition CListEventCylindricalScannerWithDiscreteDetectors.h:33
Class for records in a PET list mode file.
Definition CListRecord.h:68
A class for storing 2 coordinates-sets of a detection, together with a timing-position index (for TOF...
Definition DetectionPositionPair.h:41
CListRecordGEHDF5(const shared_ptr< const ProjDataInfo > &proj_data_info_sptr, const unsigned long first_time_stamp)
constructor
Definition CListRecordGEHDF5.h:206
void set_detection_position(const DetectionPositionPair<> &) override
This routine sets in a coincidence event from detector "indices".
Definition CListRecordGEHDF5.h:296
void get_detection_position(DetectionPositionPair<> &det_pos) const override
This routine returns the corresponding detector pair.
Definition CListRecordGEHDF5.h:282
Succeeded set_prompt(const bool prompt=true) override
Changes the event from prompt to delayed or vice versa.
Definition CListRecordGEHDF5.h:277
Class for finding out what the event/size-type is in a GE RDF9 listmode file.
Definition CListRecordGEHDF5.h:80
Class for storing and using a coincidence event from a GE RDF9 listmode file.
Definition CListRecordGEHDF5.h:99
A class for storing and using a timing 'event' from a GE RDF9 listmode file.
Definition CListRecordGEHDF5.h:137
A class for storing and using a timing record from a listmode file.
Definition ListTime.h:47
a class containing an enumeration type that can be used by functions to signal successful operation o...
Definition Succeeded.h:44
Declaration of stir::error().
void error(const char *const s,...)
Print error with format string a la printf and throw exception.
Definition error.cxx:42