STIR 6.4.0
CListRecordSAFIR.inl
Go to the documentation of this file.
1/* CListRecordSAFIR.inl
2
3 Coincidence Event Class for SAFIR: Inline File
4
5 Copyright 2015 ETH Zurich, Institute of Particle Physics
6 Copyright 2017 ETH Zurich, Institute of Particle Physics and Astrophysics
7 Copyright 2020, 2022 Positrigo AG, Zurich
8 Copyright 2021 University College London
9
10 Licensed under the Apache License, Version 2.0 (the "License");
11 you may not use this file except in compliance with the License.
12 You may obtain a copy of the License at
13
14 http://www.apache.org/licenses/LICENSE-2.0
15
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
21
22 */
34
35#include <random>
36
37#include "stir/LORCoordinates.h"
39#include "stir/ProjDataInfo.h"
40#include "stir/Bin.h"
41#include "stir/LORCoordinates.h"
42#include "stir/Succeeded.h"
43
48#include "stir/error.h"
49
50START_NAMESPACE_STIR
51
52template <class Derived>
53LORAs2Points<float>
55{
57 DetectionPositionPair<> det_pos_pair;
58
59 static_cast<const Derived*>(this)->get_data().get_detection_position_pair(det_pos_pair);
60
61 lor.p1() = map_to_use().get_coordinate_for_index(det_pos_pair.pos1());
62 lor.p2() = map_to_use().get_coordinate_for_index(det_pos_pair.pos2());
63
64 return lor;
65}
66
67namespace detail
68{
69template <class PDIT>
70static inline bool
71get_bin_for_det_pos_pair(Bin& bin, DetectionPositionPair<>& det_pos_pair, const ProjDataInfo& proj_data_info)
72{
73 if (auto proj_data_info_ptr = dynamic_cast<const PDIT*>(&proj_data_info))
74 {
75 if (proj_data_info_ptr->get_bin_for_det_pos_pair(bin, det_pos_pair) == Succeeded::yes)
76 bin.set_bin_value(1);
77 else
78 bin.set_bin_value(-1);
79 return true;
80 }
81 else
82 return false;
83}
84} // namespace detail
85
86template <class Derived>
87void
88CListEventSAFIR<Derived>::get_bin(Bin& bin, const ProjDataInfo& proj_data_info) const
89{
90 DetectionPositionPair<> det_pos_pair;
91 static_cast<const Derived*>(this)->get_data().get_detection_position_pair(det_pos_pair);
92
93 if (!map_sptr)
94 {
95 // transform det_pos_pair into stir conventions
96 det_pos_pair.pos1() = map_to_use().get_det_pos_for_index(det_pos_pair.pos1());
97 det_pos_pair.pos2() = map_to_use().get_det_pos_for_index(det_pos_pair.pos2());
98
99 if (det_pos_pair.pos1().tangential_coord() == det_pos_pair.pos2().tangential_coord())
100 {
101 bin.set_bin_value(-1);
102 return;
103 }
104
105 if (!detail::get_bin_for_det_pos_pair<ProjDataInfoGenericNoArcCorr>(bin, det_pos_pair, proj_data_info))
106 {
107 if (!detail::get_bin_for_det_pos_pair<ProjDataInfoCylindricalNoArcCorr>(bin, det_pos_pair, proj_data_info))
108 error("Wrong type of proj-data-info for SAFIR");
109 }
110 }
111 else
112 {
113 const stir::CartesianCoordinate3D<float> c1 = map_sptr->get_coordinate_for_index(det_pos_pair.pos1());
114 const stir::CartesianCoordinate3D<float> c2 = map_sptr->get_coordinate_for_index(det_pos_pair.pos2());
115 const LORAs2Points<float> lor(c1, c2);
116 bin = proj_data_info.get_bin(lor);
117 }
118}
119
120void
122{
123 det_pos_pair.pos1().radial_coord() = layerA;
124 det_pos_pair.pos2().radial_coord() = layerB;
125
126 det_pos_pair.pos1().axial_coord() = ringA;
127 det_pos_pair.pos2().axial_coord() = ringB;
128
129 det_pos_pair.pos1().tangential_coord() = detA;
130 det_pos_pair.pos2().tangential_coord() = detB;
131}
132
133void
135{
136 det_pos_pair.pos1().radial_coord() = layerA;
137 det_pos_pair.pos2().radial_coord() = layerB;
138
139 det_pos_pair.pos1().axial_coord() = ringA;
140 det_pos_pair.pos2().axial_coord() = ringB;
141
142 det_pos_pair.pos1().tangential_coord() = detA;
143 det_pos_pair.pos2().tangential_coord() = detB;
144}
145
146END_NAMESPACE_STIR
Declaration of class stir::Bin.
Declarations of classes stir::CListRecord, and stir::CListEvent which are used for list mode data.
defines the stir::CartesianCoordinate3D<coordT> class
defines various classes for specifying a line in 3 dimensions
Declaration of class stir::ProjDataInfoBlocksOnCylindricalNoArcCorr.
Declaration of class stir::ProjDataInfoCylindricalNoArcCorr.
Declaration of class stir::ProjDataInfoGenericNoArcCorr.
Declaration of class stir::ProjDataInfo.
Declaration of class stir::Succeeded.
A class for storing coordinates and value of a single projection bin.
Definition Bin.h:49
void set_bin_value(float v)
set the value to be back projected
Definition Bin.inl:129
void get_detection_position_pair(DetectionPositionPair<> &det_pos_pair)
Writes detection position pair to reference given as argument.
Definition CListRecordSAFIR.inl:134
void get_detection_position_pair(DetectionPositionPair<> &det_pos_pair)
Writes detection position pair to reference given as argument.
Definition CListRecordSAFIR.inl:121
LORAs2Points< float > get_LOR() const override
Returns LOR corresponding to the given event.
Definition CListRecordSAFIR.inl:54
void get_bin(Bin &bin, const ProjDataInfo &proj_data_info) const override
Override the default implementation.
Definition CListRecordSAFIR.inl:88
a templated class for 3-dimensional coordinates.
Definition CartesianCoordinate3D.h:53
A class for storing 2 coordinates-sets of a detection, together with a timing-position index (for TOF...
Definition DetectionPositionPair.h:41
A class for LORs.
Definition LORCoordinates.h:296
An (abstract base) class that contains information on the projection data.
Definition ProjDataInfo.h:70
virtual Bin get_bin(const LOR< float > &, const double delta_time=0.0) const =0
Find the bin in the projection data that 'contains' an LOR.
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
Namespace for the implementation details of the STIR library.
Definition KeyParser.cxx:1158