34#ifndef __stir_listmode_CListRecordSAFIR_H__
35#define __stir_listmode_CListRecordSAFIR_H__
45#include "boost/static_assert.hpp"
46#include "boost/cstdint.hpp"
49#include "boost/make_shared.hpp"
71template <
class Derived>
84 inline void get_bin(
Bin& bin,
const ProjDataInfo& proj_data_info)
const override;
94 inline bool is_prompt()
const override {
return !(
static_cast<const Derived*
>(
this)->is_prompt()); }
97 inline void set_map_sptr(shared_ptr<const DetectorCoordinateMap> new_map_sptr) { map_sptr = new_map_sptr; }
100 inline void set_scanner_sptr(shared_ptr<const Scanner> new_scanner_sptr) { scanner_sptr = new_scanner_sptr; }
103 shared_ptr<const DetectorCoordinateMap> map_sptr;
104 shared_ptr<const Scanner> scanner_sptr;
106 const DetectorCoordinateMap& map_to_use()
const {
return map_sptr ? *map_sptr : *this->scanner_sptr->get_detector_map_sptr(); }
127 return Succeeded::yes;
131#if STIRIsNativeByteOrderBigEndian
133 unsigned isDelayed : 1;
134 unsigned reserved : 6;
148 unsigned reserved : 6;
149 unsigned isDelayed : 1;
172 return Succeeded::yes;
176#if STIRIsNativeByteOrderBigEndian
178 unsigned isDelayed : 1;
179 unsigned reserved : 8;
193 unsigned reserved : 8;
194 unsigned isDelayed : 1;
204 inline unsigned long get_time_in_millisecs()
const {
return static_cast<unsigned long>(time); }
205 inline Succeeded set_time_in_millisecs(
const unsigned long time_in_millisecs)
207 time = ((boost::uint64_t(1) << 49) - 1) &
static_cast<boost::uint64_t
>(time_in_millisecs);
208 return Succeeded::yes;
210 inline bool is_time()
const {
return type; }
213#if STIRIsNativeByteOrderBigEndian
214 boost::uint64_t type : 1;
215 boost::uint64_t reserved : 15;
216 boost::uint64_t time : 48;
218 boost::uint64_t time : 48;
219 boost::uint64_t reserved : 15;
220 boost::uint64_t type : 1;
226template <
class DataType>
231 DataType
get_data()
const {
return this->event_data; }
237 ~CListRecordSAFIR()
override {}
239 bool is_time()
const override {
return time_data.is_time(); }
241 bool is_event()
const override {
return !time_data.is_time(); }
243 CListEvent& event()
override {
return *
this; }
245 const CListEvent& event()
const override {
return *
this; }
247 virtual CListEventSAFIR<CListRecordSAFIR<DataType>>& event_SAFIR() {
return *
this; }
249 virtual const CListEventSAFIR<CListRecordSAFIR<DataType>>& event_SAFIR()
const {
return *
this; }
251 ListTime& time()
override {
return *
this; }
253 const ListTime& time()
const override {
return *
this; }
255 virtual bool operator==(
const CListRecord& e2)
const
257 return dynamic_cast<CListRecordSAFIR<DataType> const*
>(&e2) != 0
258 && raw ==
static_cast<CListRecordSAFIR<DataType> const&
>(e2).raw;
261 inline unsigned long get_time_in_millisecs()
const override {
return time_data.get_time_in_millisecs(); }
263 inline Succeeded set_time_in_millisecs(
const unsigned long time_in_millisecs)
override
265 return time_data.set_time_in_millisecs(time_in_millisecs);
268 inline bool is_prompt()
const override {
return event_data.is_prompt(); }
270 Succeeded init_from_data_ptr(
const char*
const data_ptr,
const std::size_t size_of_record,
const bool do_byte_swap)
272 assert(size_of_record >= 8);
273 std::copy(data_ptr, data_ptr + 8,
reinterpret_cast<char*
>(&raw));
276 return Succeeded::yes;
279 std::size_t size_of_record_at_ptr(
const char*
const ,
const std::size_t ,
const bool )
const
292 CListTimeDataSAFIR time_data;
295 BOOST_STATIC_ASSERT(
sizeof(boost::uint64_t) == 8);
296 BOOST_STATIC_ASSERT(
sizeof(DataType) == 8);
297 BOOST_STATIC_ASSERT(
sizeof(CListTimeDataSAFIR) == 8);
Definition of STIRIsNativeByteOrderBigEndian and STIRIsNativeByteOrderLittleEndian preprocessor symbo...
This file declares the stir::ByteOrder class.
Inline implementation of class stir::CListEventSAFIR and stir::CListRecordSAFIR with supporting class...
Declarations of classes stir::CListRecord, and stir::CListEvent which are used for list mode data.
Declaration of class stir::DetectionPositionPair.
Declaration of class stir::DetectorCoordinateMap.
Declaration of class stir::Succeeded.
A class for storing coordinates and value of a single projection bin.
Definition Bin.h:49
static void swap_order(NUMBER &value)
swap the byteorder of the argument
Definition ByteOrder.h:122
Class for record with coincidence data using NeuroLF bitfield definition.
Definition CListRecordSAFIR.h:157
Succeeded set_prompt(const bool prompt=true)
Can be used to set "promptness" of event.
Definition CListRecordSAFIR.h:169
bool is_prompt() const
Returns 0 if event is prompt and 1 if delayed.
Definition CListRecordSAFIR.h:163
void get_detection_position_pair(DetectionPositionPair<> &det_pos_pair)
Writes detection position pair to reference given as argument.
Definition CListRecordSAFIR.inl:134
bool is_time() const
Returns 1 if if event is time and 0 if it is prompt.
Definition CListRecordSAFIR.h:166
Class for record with coincidence data using SAFIR bitfield definition.
Definition CListRecordSAFIR.h:112
Succeeded set_prompt(const bool prompt=true)
Can be used to set "promptness" of event.
Definition CListRecordSAFIR.h:124
void get_detection_position_pair(DetectionPositionPair<> &det_pos_pair)
Writes detection position pair to reference given as argument.
Definition CListRecordSAFIR.inl:121
bool is_prompt() const
Returns 0 if event is prompt and 1 if delayed.
Definition CListRecordSAFIR.h:118
bool is_time() const
Returns 1 if if event is time and 0 if it is prompt.
Definition CListRecordSAFIR.h:121
Definition CListRecordSAFIR.h:73
CListEventSAFIR()
Definition CListRecordSAFIR.h:78
bool is_prompt() const override
Returns 0 if event is prompt and 1 if delayed.
Definition CListRecordSAFIR.h:94
void set_scanner_sptr(shared_ptr< const Scanner > new_scanner_sptr)
Definition CListRecordSAFIR.h:100
void set_map_sptr(shared_ptr< const DetectorCoordinateMap > new_map_sptr)
Function to set map for detector indices to coordinates.
Definition CListRecordSAFIR.h:97
bool is_valid_template(const ProjDataInfo &) const override
This method checks if the template is valid for LmToProjData.
Definition CListRecordSAFIR.h:91
Class for storing and using a coincidence event from a list mode file.
Definition CListRecord.h:53
Class for general SAFIR record, containing a union of data, time and raw record and providing access ...
Definition CListRecordSAFIR.h:228
bool is_prompt() const override
Returns 0 if event is prompt and 1 if delayed.
Definition CListRecordSAFIR.h:268
DataType get_data() const
Returns event_data (without checking if the type is really event and not time).
Definition CListRecordSAFIR.h:231
Class for records in a PET list mode file.
Definition CListRecord.h:67
Class for record with time data using SAFIR bitfield definition.
Definition CListRecordSAFIR.h:202
A class for storing 2 coordinates-sets of a detection, together with a timing-position index (for TOF...
Definition DetectionPositionPair.h:41
Definition DetectorCoordinateMap.h:51
A class for LORs.
Definition LORCoordinates.h:296
A class for storing and using a timing record from a listmode file.
Definition ListTime.h:47
An (abstract base) class that contains information on the projection data.
Definition ProjDataInfo.h:70
a class containing an enumeration type that can be used by functions to signal successful operation o...
Definition Succeeded.h:44