Falaise  4.0.1
SuperNEMO Software Toolkit
gg_locator.h
Go to the documentation of this file.
1 /// \file falaise/snemo/geometry/gg_locator.h
2 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date : 2011-04-12
4  * Last modified : 2014-01-28
5  *
6  * Copyright (C) 2011-2014 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  * Geiger cell locator for one module of the SuperNEMO detector
26  *
27  * History:
28  *
29  */
30 
31 #ifndef FALAISE_SNEMO_GEOMETRY_GG_LOCATOR_H
32 #define FALAISE_SNEMO_GEOMETRY_GG_LOCATOR_H 1
33 
34 // Standard library:
35 #include <string>
36 
37 // Third party
38 // - Boost :
39 #include <boost/cstdint.hpp>
40 // - Bayeux/datatools
41 #include <datatools/logger.h>
42 // - Bayeux/geomtools
43 #include <geomtools/i_locator.h>
44 
45 // This project:
47 
48 /** forward declaration */
49 namespace geomtools {
50 class mapping;
51 class id_mgr;
52 class manager;
53 class placement;
54 class box;
55 } // namespace geomtools
56 
57 namespace snemo {
58 
59 namespace geometry {
60 
61 /// \brief Fast locator class for SuperNEMO drift chamber volumes
63  public:
64  /// Check intialization flag
65  virtual bool is_initialized() const;
66 
67  /// Constructor
68  gg_locator();
69 
70  /// Constructor
71  gg_locator(const ::geomtools::manager& mgr_, uint32_t module_number_);
72 
73  /// Destructor
74  virtual ~gg_locator();
75 
76  /// Reset
77  virtual void reset();
78 
79  /// Initialize
80  virtual void initialize(const datatools::properties& config_);
81 
82  /// Initialize
83  void initialize();
84 
85  // Interfaces from geomtools::i_locator :
86  virtual bool find_geom_id(const geomtools::vector_3d& world_position_, int type_,
87  geomtools::geom_id& gid_,
88  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
89 
90  bool find_cell_geom_id(const geomtools::vector_3d& world_position_, geomtools::geom_id& gid_,
91  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
92 
93  protected:
94  /**
95  */
96  bool _find_cell_geom_id(const geomtools::vector_3d& in_module_position_, geomtools::geom_id& gid_,
97  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE);
98 
99  public:
100  /**! @return the number of the module (>=0).
101  */
102  uint32_t get_module_number() const;
103 
104  /**! @return set the number of the module for this locator.
105  */
106  void set_module_number(uint32_t module_number_);
107 
108  /**! @return the diameter of a cell.
109  */
110  double get_cell_diameter() const;
111 
112  /**! @return the length of a cell (including the base and cathode ring).
113  */
114  double get_cell_length() const;
115 
116  /**! @return the length of anode wires.
117  */
118  double get_anode_wire_length() const;
119 
120  /**! @return the diameter of anode wires.
121  */
122  double get_anode_wire_diameter() const;
123 
124  /**! @return the diameter of field wires.
125  */
126  double get_field_wire_length() const;
127 
128  /**! @return the length field wires.
129  */
130  double get_field_wire_diameter() const;
131 
132  /**! @return the number of sides on the tracking chamber.
133  */
134  size_t get_number_of_sides() const;
135 
136  /**! @return true if the submodule at given side is present
137  */
138  bool has_submodules(uint32_t side_) const;
139 
140  /**! @return the number of drift cells layers in one side of the tracking chamber.
141  */
142  size_t get_number_of_layers(uint32_t side_) const;
143 
144  /**! @return the number of drift cells rows in one side of the tracking chamber.
145  */
146  size_t get_number_of_rows(uint32_t side_) const;
147 
148  /**! @return the X-position of a cell for specific side and layer (in module coordinate system).
149  */
150  double get_layer_x(uint32_t side_, uint32_t layer_) const;
151 
152  /**! @return the Y-position of a cell for specific side and row (in module coordinate system.
153  */
154  double get_row_y(uint32_t side_, uint32_t row_) const;
155 
156  /**! Compute the position of a cell for specific side, layer and row (in module coordinate
157  * system).
158  */
159  void compute_cell_position(uint32_t side_, uint32_t layer_, uint32_t row_,
160  geomtools::vector_3d& module_position_) const;
161 
162  /**! @return the position of a cell for specific side, layer and row (in module coordinate
163  * system).
164  */
165  geomtools::vector_3d get_cell_position(uint32_t side_, uint32_t layer_, uint32_t row_) const;
166 
167  /** Tranform a world coordinate system position to the corresponding module coordinate system
168  * position.
169  */
170  void transform_world_to_module(const geomtools::vector_3d& world_position_,
171  geomtools::vector_3d& module_position_) const;
172 
173  /** Tranform a module coordinate system position to the corresponding world coordinate system
174  * position.
175  */
176  void transform_module_to_world(const geomtools::vector_3d& module_position_,
177  geomtools::vector_3d& world_position_) const;
178 
179  /** Check if a world coordinate system position is in the module virtual volume (its bounding
180  * envelope).
181  */
182  bool is_world_position_in_module(const geomtools::vector_3d& world_position_,
183  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
184 
185  /** Check if a module coordinate system position is in the module virtual volume (its bounding
186  * envelope).
187  */
188  bool is_in_module(const geomtools::vector_3d& module_position_,
189  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
190 
191  /** Check if a module coordinate system position is in a specific cell virtual volume (its
192  * bounding envelope).
193  */
194  bool is_in_cell(const geomtools::vector_3d& module_position_, uint32_t side_, uint32_t layer_,
195  uint32_t row_, double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
196 
197  /** Check if a world coordinate system position is in a specific cell virtual volume (its bounding
198  * envelope).
199  */
200  bool is_world_position_in_cell(const geomtools::vector_3d& world_position_, uint32_t side_,
201  uint32_t layer_, uint32_t row_,
202  double tolerance_ = GEOMTOOLS_PROPER_TOLERANCE) const;
203 
204  /** Given a cell at specific side, layer and row, returns the number of neighbouring cells.
205  * If asked, cells on the layer==0 on any side of the chamber are associated to cells on the other
206  * side of the source plane.
207  */
208  size_t get_number_of_neighbours(uint32_t side_, uint32_t layer_, uint32_t row_,
209  bool other_side_ = false) const;
210 
211  /** Given a cell with a specific geometry ID, returns the number of neighbouring cells.
212  */
213  size_t get_number_of_neighbours(const geomtools::geom_id& gid_, bool other_side_ = false) const;
214 
215  /** Given a cell at specific side, layer and row, compute the array of geometry IDs for associated
216  * neighbouring cells.
217  */
218  void get_neighbours_ids(uint32_t side_, uint32_t layer_, uint32_t row_,
219  std::vector<geomtools::geom_id>& ids_, bool other_side_ = false) const;
220 
221  /** Given a cell with a specific geometry IDs, compute the array of geometry IDs for associated
222  * neighbouring cells.
223  */
224  void get_neighbours_ids(const geomtools::geom_id& gid_, std::vector<geomtools::geom_id>& ids_,
225  bool other_side_ = false) const;
226 
227  /** Given a cell with a specific geometry IDs, compute its position in the module coordinate
228  * system.
229  */
230  void get_cell_position(const geomtools::geom_id& gid_, geomtools::vector_3d& position_) const;
231 
232  /** Given a cell with a specific side, layer and row, compute its position in the module
233  * coordinate system.
234  */
235  void get_cell_position(uint32_t side_, uint32_t layer_, uint32_t row_,
236  geomtools::vector_3d& position_) const;
237 
238  uint32_t extract_module(const geomtools::geom_id& gid_) const;
239 
240  uint32_t extract_side(const geomtools::geom_id& gid) const;
241 
242  uint32_t extract_layer(const geomtools::geom_id& gid_) const;
243 
244  uint32_t extract_row(const geomtools::geom_id& gid_) const;
245 
246  /** @arg a_gid the GID to be checked.
247  * @return true if the GID corresponds to a Geiger cell's drift volume.
248  */
249  bool is_drift_cell_volume(const geomtools::geom_id& gid_) const;
250 
251  /** @arg a_gid the GID to be checked
252  * @return true if the GID corresponds to a Geiger cell's drift volume in the
253  * module number associated to the locator.
254  */
256 
257  /// Smart print
258  virtual void tree_dump(std::ostream& out_ = std::clog, const std::string& title_ = "",
259  const std::string& indent_ = "", bool inherit_ = false) const;
260 
261  /// Dump
262  void dump(std::ostream& out_ = std::clog) const;
263 
264  protected:
265  /** Protected construction method. */
266  void _construct();
267 
268  /// Set default values
269  void _set_defaults();
270 
271  /// Hack trace
272  void _hack_trace();
273 
274  private:
275  bool _initialized_;
276 
277  std::string _module_category_;
278  std::string _tracker_volume_category_;
279  std::string _tracker_layer_category_;
280  std::string _drift_cell_volume_category_;
281 
282  int _module_index_;
283  int _side_index_;
284  int _layer_index_;
285  int _row_index_;
286 
287  uint32_t _module_type_;
288  uint32_t _tracker_volume_type_;
289  uint32_t _tracker_layer_type_;
290  uint32_t _cell_type_;
291  uint32_t _module_number_;
292  const geomtools::mapping* _mapping_;
293  const geomtools::id_mgr* _id_manager_;
294 
295  const geomtools::geom_info* _module_ginfo_;
296  const geomtools::placement* _module_world_placement_;
297  const geomtools::box* _module_box_;
298  const geomtools::box* _cell_box_;
299 
300  std::vector<double> _back_cell_x_;
301  std::vector<double> _front_cell_x_;
302  std::vector<double> _back_cell_y_;
303  std::vector<double> _front_cell_y_;
304  double _anode_wire_length_;
305  double _anode_wire_diameter_;
306  double _field_wire_length_;
307  double _field_wire_diameter_;
308 
309  int _module_address_index_;
310  int _side_address_index_;
311  int _layer_address_index_;
312  int _row_address_index_;
313 
314  // Submodules are present :
315  bool _submodules_[2];
316 };
317 
318 } // end of namespace geometry
319 
320 } // end of namespace snemo
321 
322 #endif // FALAISE_SNEMO_GEOMETRY_GG_LOCATOR_H
323 
324 /*
325 ** Local Variables: --
326 ** mode: c++ --
327 ** c-file-style: "gnu" --
328 ** tab-width: 2 --
329 ** End: --
330 */
void initialize()
Initialize.
void _hack_trace()
Hack trace.
uint32_t extract_layer(const geomtools::geom_id &gid_) const
geomtools::vector_3d get_cell_position(uint32_t side_, uint32_t layer_, uint32_t row_) const
virtual bool is_initialized() const
Check intialization flag.
bool is_in_module(const geomtools::vector_3d &module_position_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
double get_layer_x(uint32_t side_, uint32_t layer_) const
void transform_module_to_world(const geomtools::vector_3d &module_position_, geomtools::vector_3d &world_position_) const
bool is_in_cell(const geomtools::vector_3d &module_position_, uint32_t side_, uint32_t layer_, uint32_t row_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
void set_module_number(uint32_t module_number_)
uint32_t extract_row(const geomtools::geom_id &gid_) const
virtual void reset()
Reset.
double get_cell_diameter() const
void dump(std::ostream &out_=std::clog) const
Dump.
uint32_t extract_side(const geomtools::geom_id &gid) const
double get_anode_wire_diameter() const
void transform_world_to_module(const geomtools::vector_3d &world_position_, geomtools::vector_3d &module_position_) const
#define GEOMTOOLS_PROPER_TOLERANCE
void compute_cell_position(uint32_t side_, uint32_t layer_, uint32_t row_, geomtools::vector_3d &module_position_) const
size_t get_number_of_sides() const
bool is_drift_cell_volume_in_current_module(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
void get_neighbours_ids(uint32_t side_, uint32_t layer_, uint32_t row_, std::vector< geomtools::geom_id > &ids_, bool other_side_=false) const
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
uint32_t extract_module(const geomtools::geom_id &gid_) const
virtual ~gg_locator()
Destructor.
CLHEP::Hep3Vector vector_3d
void _set_defaults()
Set default values.
bool is_drift_cell_volume(const geomtools::geom_id &gid_) const
virtual bool find_geom_id(const geomtools::vector_3d &world_position_, int type_, geomtools::geom_id &gid_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
size_t get_number_of_neighbours(uint32_t side_, uint32_t layer_, uint32_t row_, bool other_side_=false) const
uint32_t get_module_number() const
double get_row_y(uint32_t side_, uint32_t row_) const
size_t get_number_of_rows(uint32_t side_) const
double get_field_wire_length() const
double get_field_wire_diameter() const
double get_anode_wire_length() const
size_t get_number_of_layers(uint32_t side_) const
Fast locator class for SuperNEMO drift chamber volumes.
Definition: gg_locator.h:62
bool find_cell_geom_id(const geomtools::vector_3d &world_position_, geomtools::geom_id &gid_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
bool is_world_position_in_cell(const geomtools::vector_3d &world_position_, uint32_t side_, uint32_t layer_, uint32_t row_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE) const
bool has_submodules(uint32_t side_) const
double get_cell_length() const
bool _find_cell_geom_id(const geomtools::vector_3d &in_module_position_, geomtools::geom_id &gid_, double tolerance_=GEOMTOOLS_PROPER_TOLERANCE)