Bayeux  3.4.1
Core Foundation library for SuperNEMO
blur_spot.h
Go to the documentation of this file.
1 /* Author(s): Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2012-03-22
4  * Last modified: 2014-07-08
5  *
6  * License:
7  * GPL 3.0
8  * Description:
9  *
10  * Classes that represent various spot patterns :
11  * - point-like spot (no blur)
12  * - spot blured on a segment (blur impact on a wire)
13  * - spot blured as a stain (blur impact on a surface)
14  * - spot blured as a tiny volume (blur 3D-vertex: 'gazeous drop/cloud/bubble')
15  *
16  */
17 
18 #ifndef GEOMTOOLS_BLUR_SPOT_H
19 #define GEOMTOOLS_BLUR_SPOT_H 1
20 
21 // Third party:
22 // - Boost:
23 #include <boost/serialization/access.hpp>
24 #include <boost/random/normal_distribution.hpp>
25 // - Bayeux/datatools:
27 #include <datatools/i_tree_dump.h>
28 #include <datatools/properties.h>
29 // - Bayeux/mygsl:
30 #include <mygsl/rng.h>
31 
32 // This project:
34 #include <geomtools/utils.h>
35 #include <geomtools/placement.h>
36 #include <geomtools/i_object_3d.h>
38 #include <geomtools/base_hit.h>
39 
40 namespace geomtools {
41 
43  /*
44  *
45  * <---> tolerance
46  * :
47  * ..*.. point like spot +/- tolerance in 3D
48  * :\
49  * placement
50  *
51  *
52  * : zerror :
53  * ..++++++++++*++++++++++.. blur_spot (1D)
54  * : / :
55  * placement
56  *
57  *
58  * : xerror :
59  * y ..+++++++++++++++++..
60  * e ..+++++++++++++++++..
61  * r ..++++++++*++++++++.. blur_spot (2D)
62  * r ..+++++++++\+++++++..
63  * o ..++++++++++\++++++..
64  * r : \ :
65  * placement
66  *
67  *
68  * <no representation> for blur_spot (3D)
69  *
70  *
71  */
72  class blur_spot
73  : public base_hit
74  , public i_wires_3d_rendering
75  {
76  public:
77 
89  };
90 
92  enum mode_type {
97  };
98 
102  };
103 
105  static const double DEFAULT_VALUE;
106 
108  static const double DEFAULT_NSIGMA;
109 
111  double get_tolerance() const;
112 
114  void set_tolerance(double tolerance_);
115 
117  bool is_dimension_zero() const;
118 
120  bool is_dimension_one() const;
121 
123  bool is_dimension_two() const;
124 
126  bool is_dimension_three() const;
127 
129  void set_blur_dimension(int);
130 
132  int get_blur_dimension() const;
133 
135  blur_spot();
136 
138  blur_spot(int8_t dimension_,
139  double tolerance_ = DEFAULT_VALUE);
140 
142  void set_position(const vector_3d & position_);
143 
146 
148  const placement & get_placement() const;
149 
151  void set_placement(const placement & placement_);
152 
154  void invalidate_placement();
155 
157  const vector_3d & get_position() const;
158 
160  const rotation_3d & get_rotation() const;
161 
163  const rotation_3d & get_inverse_rotation() const;
164 
166  virtual ~blur_spot();
167 
169  virtual void invalidate();
170 
172  void reset();
173 
175  virtual bool is_valid() const;
176 
178  double get_x_error() const;
179 
181  void set_x_error(double);
182 
184  double get_y_error() const;
185 
187  void set_y_error(double);
188 
190  double get_z_error() const;
191 
193  void set_z_error(double);
194 
196  void set_errors(double,
197  double = std::numeric_limits<double>::quiet_NaN(),
198  double = std::numeric_limits<double>::quiet_NaN());
199 
201  template <class Randomizer>
202  void randomize_boost(Randomizer & ran_,
203  vector_3d & random_point_,
204  int mode_ = MODE_INTERVAL) const;
205 
207  void randomize_mygsl(mygsl::rng & ran_,
208  vector_3d & random_point_,
209  int mode_ = MODE_INTERVAL) const;
210 
212  bool match(const vector_3d & position_,
213  int mode_ = MODE_INTERVAL,
214  double nsigma1_or_tolerance_ = DEFAULT_VALUE,
215  double nsigma2_or_tolerance_ = DEFAULT_VALUE,
216  double nsigma3_or_tolerance_ = DEFAULT_VALUE) const;
217 
219  virtual void generate_wires_self(wires_type & wires_,
220  uint32_t options_ = 0) const;
221 
223  virtual void tree_dump(std::ostream & out_ = std::clog,
224  const std::string & title_ = "",
225  const std::string & indent_ = "",
226  bool inherit_ = false) const;
227 
229  void print() const;
230 
231  protected:
232 
233  bool _match_0d(const vector_3d & position_,
234  double tolerance_ = DEFAULT_VALUE) const;
235 
236  bool _match_1d(const vector_3d & position_,
237  int mode_ = MODE_INTERVAL,
238  double nsigma1_or_tolerance_ = DEFAULT_VALUE,
239  double nsigma2_or_tolerance_ = DEFAULT_VALUE) const;
240 
241  bool _match_2d(const vector_3d & position_,
242  int mode_ = MODE_INTERVAL,
243  double nsigma1_or_tolerance_ = DEFAULT_VALUE,
244  double nsigma2_or_tolerance_ = DEFAULT_VALUE,
245  double nsigma3_or_tolerance_ = DEFAULT_VALUE) const;
246 
247  bool _match_3d(const vector_3d & position_,
248  int mode_ = MODE_INTERVAL,
249  double nsigma1_or_tolerance_ = DEFAULT_VALUE,
250  double nsigma2_or_tolerance_ = DEFAULT_VALUE,
251  double nsigma3_or_tolerance_ = DEFAULT_VALUE) const;
252 
253  private:
254 
255  int8_t _blur_dimension_;
256  double _tolerance_;
257  placement _placement_;
258  double _x_error_;
259  double _y_error_;
260  double _z_error_;
261 
264 
265 
266  DR_CLASS_RTTI()
267 
269 
270  };
271 
272  template <class BoostRandomizer>
273  void blur_spot::randomize_boost(BoostRandomizer & ran_,
274  vector_3d & random_point_,
275  int mode_) const
276  {
277  if (is_dimension_zero()) {
278  random_point_ = _placement_.get_translation();
279  return;
280  }
281  vector_3d local_pos(0.0, 0.0, 0.0);
282  if (is_dimension_one()) {
283  if (mode_ == MODE_INTERVAL) {
284  local_pos.setZ(_z_error_ * ( -1. + 2 * ran_()));
285  } else {
286  boost::random::normal_distribution<double> gauss_random;
287  local_pos.setZ(gauss_random(ran_, boost::random::normal_distribution<double>::param_type(0.0, _z_error_)));
288  }
289  } else if (is_dimension_two()) {
290  if (mode_ == MODE_INTERVAL) {
291  local_pos.setX(_x_error_ * ( -1. + 2 * ran_()));
292  local_pos.setY(_y_error_ * ( -1. + 2 * ran_()));
293  } else {
294  boost::random::normal_distribution<double> gauss_random;
295  local_pos.setX(gauss_random(ran_, boost::random::normal_distribution<double>::param_type(0.0, _x_error_)));
296  local_pos.setY(gauss_random(ran_, boost::random::normal_distribution<double>::param_type(0.0, _y_error_)));
297  }
298  } else if (is_dimension_three()) {
299  if (mode_ == MODE_INTERVAL) {
300  local_pos.setX(_x_error_ * ( -1. + 2 * ran_()));
301  local_pos.setY(_y_error_ * ( -1. + 2 * ran_()));
302  local_pos.setZ(_z_error_ * ( -1. + 2 * ran_()));
303  } else {
304  boost::random::normal_distribution<double> gauss_random;
305  local_pos.setX(gauss_random(ran_, boost::random::normal_distribution<double>::param_type(0.0, _x_error_)));
306  local_pos.setY(gauss_random(ran_, boost::random::normal_distribution<double>::param_type(0.0, _y_error_)));
307  local_pos.setZ(gauss_random(ran_, boost::random::normal_distribution<double>::param_type(0.0, _z_error_)));
308  }
309  }
310  _placement_.child_to_mother(local_pos, random_point_);
311  return;
312  }
313 
314 } // end of namespace geomtools
315 
316 #include <boost/serialization/export.hpp>
317 BOOST_CLASS_EXPORT_KEY2(geomtools::blur_spot, "geomtools::blur_spot")
318 
319 // Activate reflection layer for the blur_spot class :
320 DR_CLASS_INIT(::geomtools::blur_spot)
321 
322 // Class version:
323 // 2014-07-03 FM: Now inherits from geomtools::base_hit :
324 #include <boost/serialization/version.hpp>
325 BOOST_CLASS_VERSION(geomtools::blur_spot, 1)
326 
327 #endif // GEOMTOOLS_BLUR_SPOT_H
328 
329 // Local Variables: --
330 // mode: c++ --
331 // c-file-style: "gnu" --
332 // tab-width: 2 --
333 // End: --
334 
#define DR_CLASS_INIT(Introspectable)
Inform Camp that class Introspectable exists and trigger the automatic registration of dedicated refl...
Definition: reflection_interface.h:149
void set_errors(double, double=std::numeric_limits< double >::quiet_NaN(), double=std::numeric_limits< double >::quiet_NaN())
Set all errors of the spot.
Definition: blur_spot.h:87
Definition: blur_spot.h:85
void randomize_mygsl(mygsl::rng &ran_, vector_3d &random_point_, int mode_=MODE_INTERVAL) const
Randomize point from the spot region.
bool _match_2d(const vector_3d &position_, int mode_=MODE_INTERVAL, double nsigma1_or_tolerance_=DEFAULT_VALUE, double nsigma2_or_tolerance_=DEFAULT_VALUE, double nsigma3_or_tolerance_=DEFAULT_VALUE) const
Definition: blur_spot.h:88
void child_to_mother(const vector_3d &, vector_3d &) const
void set_y_error(double)
Set the transverse error of the spot along the Y axis.
Definition: blur_spot.h:81
blur_dimension_type
Dimensionality of the blur object.
Definition: blur_spot.h:79
const rotation_3d & get_inverse_rotation() const
Return the inverse rotation matrix of the object.
void reset()
Reset internal data.
void randomize_boost(Randomizer &ran_, vector_3d &random_point_, int mode_=MODE_INTERVAL) const
Randomize point from the spot region.
void set_position(const vector_3d &position_)
Set the position of the object.
static const uint32_t bit03
Definition: bit_mask.h:30
static const double DEFAULT_NSIGMA
Special sigma factor.
Definition: blur_spot.h:108
A blur spot is a measurement hit that may represents a vertex with 1D, 2D or 3D dimension.
Definition: blur_spot.h:72
bool is_dimension_two() const
Check dimension two.
const placement & get_placement() const
Return the no mutable placement of the object.
double get_y_error() const
Return the transverse error of the spot along the Y axis.
void set_blur_dimension(int)
Set the intrinsic dimension of the object.
bool match(const vector_3d &position_, int mode_=MODE_INTERVAL, double nsigma1_or_tolerance_=DEFAULT_VALUE, double nsigma2_or_tolerance_=DEFAULT_VALUE, double nsigma3_or_tolerance_=DEFAULT_VALUE) const
Check if a given point matches the object within some tolerance.
Definition: blur_spot.h:82
#define DATATOOLS_SERIALIZATION_DECLARATION()
Definition: i_serializable.h:266
Definition: blur_spot.h:95
Definition: blur_spot.h:86
const vector_3d & get_position() const
Return the position of the object.
Definition: blur_spot.h:80
The base class for hit objects that locate events in a geometry model.
Definition: base_hit.h:38
blur_spot()
Default constructor.
const vector_3d & get_translation() const
Return the translation.
static const double DEFAULT_VALUE
Special default real value.
Definition: blur_spot.h:105
void print() const
Smart print shortcut.
void set_placement(const placement &placement_)
Set the placement of the object.
Definition: blur_spot.h:93
void set_z_error(double)
Set the longitudinal error of the spot along the Z axis.
double get_z_error() const
Return the longitudinal error of the spot along the Z axis.
bool is_dimension_three() const
Check dimension three.
double get_x_error() const
Return the transverse error of the spot along the X axis.
void set_tolerance(double tolerance_)
Set the intrinsic geometry tolerance of the object.
Definition: blur_spot.h:84
CLHEP::HepRotation rotation_3d
Alias for the CLHEP 3D-rotation class.
Definition: clhep.h:66
placement & grab_placement()
Return the mutable placement of the object.
brief Abstract interface for objects that can describe themselves as a collection of polylines for 3D...
Definition: i_wires_3d_rendering.h:39
CLHEP::Hep3Vector vector_3d
Alias for the CLHEP 3D-vector class.
Definition: clhep.h:63
virtual bool is_valid() const
Check the validity of the object.
bool _match_1d(const vector_3d &position_, int mode_=MODE_INTERVAL, double nsigma1_or_tolerance_=DEFAULT_VALUE, double nsigma2_or_tolerance_=DEFAULT_VALUE) const
The placement for a geometry volume with its translation and rotation with respect to some mother ref...
Definition: placement.h:34
int get_blur_dimension() const
Return the intrinsic dimension of the object.
std::list< polyline_type > wires_type
Alias for a list of 3D-polylines.
Definition: utils.h:61
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
Definition: blur_spot.h:96
mode_type
Mode.
Definition: blur_spot.h:92
void set_x_error(double)
Set the transverse error of the spot along the X axis.
bool is_dimension_zero() const
Check dimension zero (point-like spot)
#define DR_CLASS_RTTI()
Declare Camp RTTI within class declaration.
Definition: reflection_interface.h:46
Definition: blur_spot.h:101
void invalidate_placement()
Invalidate the placement of the object.
bool is_dimension_one() const
Check dimension one.
Definition: blur_spot.h:83
bool _match_0d(const vector_3d &position_, double tolerance_=DEFAULT_VALUE) const
virtual void generate_wires_self(wires_type &wires_, uint32_t options_=0) const
Generate rendering wires.
bool _match_3d(const vector_3d &position_, int mode_=MODE_INTERVAL, double nsigma1_or_tolerance_=DEFAULT_VALUE, double nsigma2_or_tolerance_=DEFAULT_VALUE, double nsigma3_or_tolerance_=DEFAULT_VALUE) const
store_mask_type
Masks to automatically tag the attributes to be stored.
Definition: base_hit.h:46
virtual ~blur_spot()
Destructor.
Definition: blur_spot.h:94
#define GEOMTOOLS_HIT_REGISTRATION_INTERFACE(HitClassName)
Definition: base_hit.h:393
const rotation_3d & get_rotation() const
Return the rotation matrix of the object.
Pseudo random number generator.
Definition: rng.h:53
virtual void invalidate()
Invalidate the object.
double get_tolerance() const
Return the intrinsic geometry tolerance of the object.
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39