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;
82 void read_detectormap_from_file(
const std::string& filename);
85 void set_detector_map(
const det_pos_to_coord_type& coord_map);
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]));
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; }
123 explicit DetectorCoordinateMap(
double sigma = 0.0)
129 generators.resize(omp_get_max_threads());
130 distributions.resize(omp_get_max_threads());
131 for (
auto& distribution : distributions)
132 distribution = std::normal_distribution<double>(0.0, sigma);
134 generators.resize(1);
135 distributions.resize(1);
136 distributions[0] = std::normal_distribution<double>(0.0, sigma);
141 unsigned num_tangential_coords;
142 unsigned num_axial_coords;
143 unsigned num_radial_coords;
144 unordered_to_ordered_det_pos_type input_index_to_det_pos;
145 det_pos_to_coord_type det_pos_to_coord;
146 std::map<stir::CartesianCoordinate3D<float>, stir::DetectionPosition<>>
147 detection_position_map_given_cartesian_coord_keys_3_decimal;
148 std::map<stir::CartesianCoordinate3D<float>, stir::DetectionPosition<>>
149 detection_position_map_given_cartesian_coord_keys_2_decimal;
152 mutable std::vector<std::default_random_engine> generators;
153 mutable std::vector<std::normal_distribution<double>> distributions;
155 static det_pos_to_coord_type read_detectormap_from_file_help(
const std::string& crystal_map_name);
DetectorCoordinateMap(const std::string &filename, double sigma=0.0)
Constructor calls read_detectormap_from_file( filename ).
Definition DetectorCoordinateMap.h:69
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
stir::CartesianCoordinate3D< float > get_coordinate_for_index(const stir::DetectionPosition<> &index) const
Returns a cartesian coordinate given an (unsorted) index.
Definition DetectorCoordinateMap.h:110
DetectorCoordinateMap(const det_pos_to_coord_type &coord_map, double sigma=0.0)
Constructor calls set_detector_map(coord_map).
Definition DetectorCoordinateMap.h:75