Falaise  4.0.1
SuperNEMO Software Toolkit
gveto_locator.h
Go to the documentation of this file.
1 /// \file falaise/snemo/geometry/gveto_locator.h
2 /* Author(s) : Xavier Garrido <garrido@lal.in2p3.fr>
3  * Creation date : 2012-06-12
4  * Last modified : 2015-09-19
5  *
6  * Copyright (C) 2011-2015 Francois Mauger <mauger@lpccaen.in2p3.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or (at
11  * your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  *
23  * Description:
24  *
25  * Gamma-veto scintillator block locator for one module of the SuperNEMO detector
26  *
27  * History:
28  *
29  */
30 
31 #ifndef FALAISE_SNEMO_GEOMETRY_GVETO_LOCATOR_H
32 #define FALAISE_SNEMO_GEOMETRY_GVETO_LOCATOR_H 1
33 
34 // Standard library:
35 #include <string>
36 
37 // Third party:
38 // - Boost :
39 #include <boost/cstdint.hpp>
40 // - Bayeux/geomtools:
41 #include <geomtools/i_locator.h>
42 
43 // This project:
45 
46 /** forward declaration */
47 namespace geomtools {
48 class mapping;
49 class id_mgr;
50 class manager;
51 class placement;
52 class i_shape_3d;
53 class box;
54 } // namespace geomtools
55 
56 namespace snemo {
57 
58 namespace geometry {
59 
60 /// \brief Fast locator class for SuperNEMO gamma-veto scintillator block volumes
62  public:
63  static const unsigned int NWALLS_PER_SIDE = 2;
64 
65  /// \brief Wall identifier constants (SuperNEMO module Z axis)
66  enum wall_type {
67  WALL_INVALID = -1, //!< Invalid/undefined wall
68  WALL_BOTTOM = 0, //!< Bottom wall
69  WALL_TOP = 1 //!< Top wall
70  };
71 
72  virtual bool is_initialized() const;
73 
74  /// Constructor
75  gveto_locator();
76 
77  /// Constructor:
78  gveto_locator(const ::geomtools::manager& mgr_, uint32_t module_number_);
79 
80  /// Destructor
81  virtual ~gveto_locator();
82 
83  virtual void initialize(const datatools::properties& config_);
84 
85  virtual void reset();
86 
87  void initialize();
88 
89  bool has_submodule(uint32_t side_) const;
90 
91  bool id_is_valid(uint32_t side_, uint32_t wall_, uint32_t column_) const;
92 
93  // Interfaces from geomtools::i_locator :
94  virtual bool find_geom_id(const geomtools::vector_3d& world_position_, int type_,
95  geomtools::geom_id& gid_,
96  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
97 
98  bool find_block_geom_id(const geomtools::vector_3d& world_position_, geomtools::geom_id& gid_,
99  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
100 
101  protected:
102  /**
103  */
104  bool find_block_geom_id_(const geomtools::vector_3d& in_module_position_,
105  geomtools::geom_id& gid_,
106  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE);
107 
108  void _set_defaults_();
109 
110  /// Hack trace
111  void _hack_trace();
112 
113  public:
114  /**! @return the number of the module (>=0).
115  */
116  uint32_t get_module_number() const;
117 
118  /**! set the number of the module for this locator.
119  */
120  void set_module_number(uint32_t module_number_);
121 
122  /**! check if block is partitioned in the current setup.
123  */
124  bool is_block_partitioned() const;
125 
126  /**! @return the width of a calorimeter block.
127  */
128  double get_block_width() const;
129 
130  /**! @return the height of a calorimeter block.
131  */
132  double get_block_height() const;
133 
134  /**! @return the thickness of a block.
135  */
136  double get_block_thickness() const;
137 
138  /**! @return the number of sides on the calorimeter.
139  */
140  size_t get_number_of_sides() const;
141 
142  /**! @return the number of walls on the calorimeter.
143  */
144  size_t get_number_of_walls() const;
145 
146  /**! @return the number of columns in one side and one wall of the calorimeter.
147  */
148  size_t get_number_of_columns(uint32_t side_, uint32_t wall_) const;
149 
150  /**! @return the Z-position of a wall for specific side and wall (in module coordinate system).
151  */
152  double get_wall_z(uint32_t side_, uint32_t wall_) const;
153 
154  /**! @return the Z-position of the entrance window of a wall for specific side and wall (in module
155  * coordinate system).
156  */
157  double get_wall_window_z(uint32_t side_, uint32_t wall_) const;
158 
159  /**! @return the X-position of a block for specific side, wall and column (in module coordinate
160  * system).
161  */
162  double get_column_x(uint32_t side_, uint32_t wall_, uint32_t column_) const;
163 
164  /**! @return the Y-position of a block for specific side, wall and column (in module coordinate
165  * system).
166  */
167  double get_column_y(uint32_t side_, uint32_t wall_, uint32_t column_) const;
168 
169  /**! Compute the position of a block
170  * for specific side, wall and column (in module coordinate system).
171  */
172  void compute_block_position(uint32_t side_, uint32_t wall_, uint32_t column_,
173  geomtools::vector_3d& module_position_) const;
174 
175  /**! Compute the position of the center of the entrance window of a block
176  * for specific side and column (in module coordinate system).
177  */
178  void compute_block_window_position(uint32_t side_, uint32_t wall_, uint32_t column_,
179  geomtools::vector_3d& module_position_) const;
180 
181  /**! @return the position of a block for specific side, wall and column (in module coordinate
182  * system).
183  */
184  geomtools::vector_3d get_block_position(uint32_t side_, uint32_t wall_, uint32_t column_) const;
185 
186  /**! @return the position of the center of the entrance window of a block
187  * for specific side, wall and column (in module coordinate system).
188  */
189  geomtools::vector_3d get_block_window_position(uint32_t side_, uint32_t wall_,
190  uint32_t column_) const;
191 
192  /** Tranform a world coordinate system position to the corresponding module coordinate system
193  * position.
194  */
195  void transform_world_to_module(const geomtools::vector_3d& world_position_,
196  geomtools::vector_3d& module_position_) const;
197 
198  /** Tranform a module coordinate system position to the corresponding world coordinate system
199  * position.
200  */
201  void transform_module_to_world(const geomtools::vector_3d& module_position_,
202  geomtools::vector_3d& world_position_) const;
203 
204  /** Check if a world coordinate system position is in the module virtual volume (its bounding
205  * envelope).
206  */
207  bool is_world_position_in_module(const geomtools::vector_3d& world_position_,
208  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
209 
210  /** Check if a module coordinate system position is in the module virtual volume (its bounding
211  * envelope).
212  */
213  bool is_in_module(const geomtools::vector_3d& module_position_,
214  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
215 
216  /** Check if a module coordinate system position is in a specific block virtual volume (its
217  * bounding envelope).
218  */
219  bool is_in_block(const geomtools::vector_3d& module_position_, uint32_t side_, uint32_t wall_,
220  uint32_t column_, double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
221 
222  /** Check if a world coordinate system position is in a specific block virtual volume (its
223  * bounding envelope).
224  */
225  bool is_world_position_in_block(const geomtools::vector_3d& world_position_, uint32_t side_,
226  uint32_t wall_, uint32_t column_,
227  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
228 
229  /** Given a block at specific side, wall and column, returns the number of neighbouring blocks.
230  */
231  size_t get_number_of_neighbours(uint32_t side_, uint32_t wall_, uint32_t column_,
232  uint8_t mask_ = utils::NEIGHBOUR_FIRST) const;
233 
234  /** Given a block with a specific geometry ID, returns the number of neighbouring blocks.
235  */
236  size_t get_number_of_neighbours(const geomtools::geom_id& gid_,
237  uint8_t mask_ = utils::NEIGHBOUR_FIRST) const;
238 
239  /** Given a block at specific side, wall and column, compute the array of geometry IDs for
240  * associated neighbouring blocks.
241  */
242  void get_neighbours_ids(uint32_t side_, uint32_t wall_, uint32_t column_,
243  std::vector<geomtools::geom_id>& ids_,
244  uint8_t mask_ = utils::NEIGHBOUR_FIRST) const;
245 
246  /** Given a block with a specific geometry IDs, compute the array of geometry IDs for associated
247  * neighbouring blocks.
248  */
249  void get_neighbours_ids(const geomtools::geom_id& gid_, std::vector<geomtools::geom_id>& ids_,
250  uint8_t mask_ = utils::NEIGHBOUR_FIRST) const;
251 
252  /** Given a block with a specific geometry IDs, compute its position in the module coordinate
253  * system.
254  */
255  void get_block_position(const geomtools::geom_id& gid_, geomtools::vector_3d& position_) const;
256 
257  /** Given a block with a specific side, wall and column, compute its position in the module
258  * coordinate system.
259  */
260  void get_block_position(uint32_t side_, uint32_t wall_, uint32_t column_,
261  geomtools::vector_3d& position_) const;
262 
263  int get_module_address_index() const;
264 
265  int get_side_address_index() const;
266 
267  int get_wall_address_index() const;
268 
269  int get_column_address_index() const;
270 
271  int get_part_address_index() const;
272 
273  uint32_t extract_module(const geomtools::geom_id& gid_) const;
274 
275  uint32_t extract_side(const geomtools::geom_id& gid_) const;
276 
277  uint32_t extract_wall(const geomtools::geom_id& gid_) const;
278 
279  uint32_t extract_column(const geomtools::geom_id& gid_) const;
280 
281  uint32_t extract_part(const geomtools::geom_id& gid_) const;
282 
283  bool is_calo_block(const geomtools::geom_id& gid_) const;
284 
285  bool is_calo_block_in_current_module(const geomtools::geom_id& gid_) const;
286 
287  /// Smart print
288  virtual void tree_dump(std::ostream& out_ = std::clog, const std::string& title_ = "",
289  const std::string& indent_ = "", bool inherit_ = false) const;
290 
291  /// Dump
292  void dump(std::ostream& out_) const;
293 
294  protected:
295  void _construct();
296 
297  private:
298  bool _initialized_;
299 
300  // Configuration parameters :
301  uint32_t _module_number_;
302  uint32_t _block_part_;
303 
304  // Running values :
305  uint32_t _module_type_;
306  uint32_t _tracker_submodule_type_;
307  uint32_t _block_type_;
308  uint32_t _wrapper_type_;
309  bool _block_partitioned_;
310 
311  const geomtools::mapping* _mapping_;
312  const geomtools::id_mgr* _id_manager_;
313 
314  const geomtools::geom_info* _module_ginfo_;
315  const geomtools::placement* _module_world_placement_;
316  const geomtools::box* _module_box_;
317  const geomtools::i_shape_3d* _block_shape_;
318  bool _composite_block_shape_;
319  const geomtools::box* _block_box_;
320  double _block_z_[2][NWALLS_PER_SIDE];
321  double _block_window_z_[2][NWALLS_PER_SIDE];
322  std::vector<double> _back_block_x_[NWALLS_PER_SIDE];
323  std::vector<double> _front_block_x_[NWALLS_PER_SIDE];
324  std::vector<double> _back_block_y_[NWALLS_PER_SIDE];
325  std::vector<double> _front_block_y_[NWALLS_PER_SIDE];
326 
327  double _block_width_;
328  double _block_height_;
329  double _block_thickness_;
330 
331  // Block GID addressing :
332  int _module_address_index_;
333  int _side_address_index_;
334  int _wall_address_index_;
335  int _column_address_index_;
336  int _part_address_index_;
337 
338  // Submodules are present :
339  bool _submodules_[2];
340 };
341 
342 } // end of namespace geometry
343 
344 } // end of namespace snemo
345 
346 #endif // FALAISE_SNEMO_GEOMETRY_GVETO_LOCATOR_H
347 
348 /*
349 ** Local Variables: --
350 ** mode: c++ --
351 ** c-file-style: "gnu" --
352 ** tab-width: 2 --
353 ** End: --
354 */
void set_module_number(uint32_t module_number_)
uint32_t extract_side(const geomtools::geom_id &gid_) const
void dump(std::ostream &out_) const
Dump.
void get_neighbours_ids(uint32_t side_, uint32_t wall_, uint32_t column_, std::vector< geomtools::geom_id > &ids_, uint8_t mask_=utils::NEIGHBOUR_FIRST) const
Bottom wall.
Definition: gveto_locator.h:68
double get_column_y(uint32_t side_, uint32_t wall_, uint32_t column_) const
Invalid/undefined wall.
Definition: gveto_locator.h:67
double get_column_x(uint32_t side_, uint32_t wall_, uint32_t column_) const
wall_type
Wall identifier constants (SuperNEMO module Z axis)
Definition: gveto_locator.h:66
geomtools::vector_3d get_block_window_position(uint32_t side_, uint32_t wall_, uint32_t column_) const
uint32_t extract_part(const geomtools::geom_id &gid_) const
uint32_t extract_wall(const geomtools::geom_id &gid_) const
bool is_world_position_in_block(const geomtools::vector_3d &world_position_, uint32_t side_, uint32_t wall_, uint32_t column_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
size_t get_number_of_columns(uint32_t side_, uint32_t wall_) const
static const unsigned int NWALLS_PER_SIDE
Definition: gveto_locator.h:63
bool has_submodule(uint32_t side_) const
size_t get_number_of_sides() const
void transform_module_to_world(const geomtools::vector_3d &module_position_, geomtools::vector_3d &world_position_) const
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
virtual ~gveto_locator()
Destructor.
bool is_in_block(const geomtools::vector_3d &module_position_, uint32_t side_, uint32_t wall_, uint32_t column_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
void transform_world_to_module(const geomtools::vector_3d &world_position_, geomtools::vector_3d &module_position_) const
bool is_calo_block_in_current_module(const geomtools::geom_id &gid_) const
D : nearest diagonal.
Definition: utils.h:91
bool is_calo_block(const geomtools::geom_id &gid_) const
uint32_t extract_column(const geomtools::geom_id &gid_) const
bool is_world_position_in_module(const geomtools::vector_3d &world_position_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
Definition: calo_tapered_scin_box_model.h:54
bool find_block_geom_id_(const geomtools::vector_3d &in_module_position_, geomtools::geom_id &gid_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE)
double get_wall_window_z(uint32_t side_, uint32_t wall_) const
double get_wall_z(uint32_t side_, uint32_t wall_) const
geomtools::vector_3d get_block_position(uint32_t side_, uint32_t wall_, uint32_t column_) const
uint32_t extract_module(const geomtools::geom_id &gid_) const
size_t get_number_of_neighbours(uint32_t side_, uint32_t wall_, uint32_t column_, uint8_t mask_=utils::NEIGHBOUR_FIRST) const
void compute_block_position(uint32_t side_, uint32_t wall_, uint32_t column_, geomtools::vector_3d &module_position_) const
virtual bool is_initialized() const
size_t get_number_of_walls() const
CLHEP::Hep3Vector vector_3d
uint32_t get_module_number() const
void _hack_trace()
Hack trace.
Fast locator class for SuperNEMO gamma-veto scintillator block volumes.
Definition: gveto_locator.h:61
double get_block_thickness() const
bool find_block_geom_id(const geomtools::vector_3d &world_position_, geomtools::geom_id &gid_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
virtual bool find_geom_id(const geomtools::vector_3d &world_position_, int type_, geomtools::geom_id &gid_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
bool id_is_valid(uint32_t side_, uint32_t wall_, uint32_t column_) const
bool is_in_module(const geomtools::vector_3d &module_position_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
void compute_block_window_position(uint32_t side_, uint32_t wall_, uint32_t column_, geomtools::vector_3d &module_position_) const
Top wall.
Definition: gveto_locator.h:69