28 #include <boost/algorithm/string.hpp> 29 #include <boost/unordered_map.hpp> 37 #ifndef __stir_DetectorCoordinateMap_H__ 38 # define __stir_DetectorCoordinateMap_H__ 57 boost::hash_combine(seed, detpos.axial_coord());
58 boost::hash_combine(seed, detpos.radial_coord());
59 boost::hash_combine(seed, detpos.tangential_coord());
66 typedef boost::unordered_map<stir::DetectionPosition<>,
stir::DetectionPosition<>, ihash> unordered_to_ordered_det_pos_type;
72 read_detectormap_from_file(filename);
78 set_detector_map(coord_map);
82 void read_detectormap_from_file(
const std::string& filename);
85 void set_detector_map(
const det_pos_to_coord_type& coord_map);
87 stir::DetectionPosition<> get_det_pos_for_index(
const stir::DetectionPosition<>& index)
const 89 return input_index_to_det_pos.at(index);
94 auto coord = det_pos_to_coord.
at(det_pos);
99 auto thread_id = omp_get_thread_num();
104 coord.x() +=
static_cast<float>(distributions[thread_id](generators[thread_id]));
105 coord.y() +=
static_cast<float>(distributions[thread_id](generators[thread_id]));
106 coord.z() +=
static_cast<float>(distributions[thread_id](generators[thread_id]));
112 return get_coordinate_for_det_pos(get_det_pos_for_index(index));
118 unsigned get_num_tangential_coords()
const {
return num_tangential_coords; }
119 unsigned get_num_axial_coords()
const {
return num_axial_coords; }
120 unsigned get_num_radial_coords()
const {
return num_radial_coords; }
127 generators.resize(omp_get_max_threads());
128 distributions.resize(omp_get_max_threads());
129 for (
auto& distribution : distributions)
130 distribution = std::normal_distribution<double>(0.0, sigma);
132 generators.resize(1);
133 distributions.resize(1);
134 distributions[0] = std::normal_distribution<double>(0.0, sigma);
139 unsigned num_tangential_coords;
140 unsigned num_axial_coords;
141 unsigned num_radial_coords;
142 unordered_to_ordered_det_pos_type input_index_to_det_pos;
143 det_pos_to_coord_type det_pos_to_coord;
144 std::map<stir::CartesianCoordinate3D<float>, stir::DetectionPosition<>>
145 detection_position_map_given_cartesian_coord_keys_3_decimal;
146 std::map<stir::CartesianCoordinate3D<float>, stir::DetectionPosition<>>
147 detection_position_map_given_cartesian_coord_keys_2_decimal;
150 mutable std::vector<std::default_random_engine> generators;
151 mutable std::vector<std::normal_distribution<double>> distributions;
153 static det_pos_to_coord_type read_detectormap_from_file_help(
const std::string& crystal_map_name);
stir::CartesianCoordinate3D< float > get_coordinate_for_index(const stir::DetectionPosition<> &index) const
Returns a cartesian coordinate given an (unsorted) index.
Definition: DetectorCoordinateMap.h:110
stir::CartesianCoordinate3D< float > get_coordinate_for_det_pos(const stir::DetectionPosition<> &det_pos) const
Returns a cartesian coordinate given a detection position.
Definition: DetectorCoordinateMap.h:92
DetectorCoordinateMap(const det_pos_to_coord_type &coord_map, double sigma=0.0)
Constructor calls set_detector_map(coord_map).
Definition: DetectorCoordinateMap.h:75
DetectorCoordinateMap(const std::string &filename, double sigma=0.0)
Constructor calls read_detectormap_from_file( filename ).
Definition: DetectorCoordinateMap.h:69
Declaration of class stir::DetectionPosition.
Definition: DetectorCoordinateMap.h:50
coordT & at(const int d)
Return value at index t (which is 1-based), but with range checking (throws std::out_of_range) ...
Definition: BasicCoordinate.inl:90
a class containing an enumeration type that can be used by functions to signal successful operation o...
Definition: Succeeded.h:43
defines the stir::CartesianCoordinate3D<coordT> class