LArPandoraGeometry.h
Go to the documentation of this file.
1 /**
2  * @file larpandora/LArPandoraInterface/LArPandoraGeometry.h
3  *
4  * @brief Helper functions for extracting detector geometry for use in reconsruction
5  */
6 
7 #ifndef LAR_PANDORA_GEOMETRY_H
8 #define LAR_PANDORA_GEOMETRY_H 1
9 
11 
12 #include <map>
13 #include <vector>
14 
15 namespace lar_pandora {
16 
17  /**
18  * @brief drift volume class to hold properties of drift volume
19  */
21  public:
22  /**
23  * @brief Constructor
24  *
25  * @param x1 lower X coordinate
26  * @param y1 lower Y coordinate
27  * @param z1 lower Z coordinate
28  * @param x2 upper X coordinate
29  * @param y2 upper Y coordinate
30  * @param z2 upper Z coordinate
31  */
32  LArDetectorGap(const float x1,
33  const float y1,
34  const float z1,
35  const float x2,
36  const float y2,
37  const float z2);
38 
39  /**
40  * @brief Get lower X coordinate
41  */
42  float GetX1() const;
43 
44  /**
45  * @brief Get lower y coordinate
46  */
47  float GetY1() const;
48 
49  /**
50  * @brief Get lower Z coordinate
51  */
52  float GetZ1() const;
53 
54  /**
55  * @brief Get upper X coordinate
56  */
57  float GetX2() const;
58 
59  /**
60  * @brief Get upper Y coordinate
61  */
62  float GetY2() const;
63 
64  /**
65  * @brief Get upper Z coordinate
66  */
67  float GetZ2() const;
68 
69  /**
70  * @brief Get maximum gap size
71  */
72  static float GetMaxGapSize() noexcept;
73 
74  private:
75  float m_x1;
76  float m_y1;
77  float m_z1;
78  float m_x2;
79  float m_y2;
80  float m_z2;
81  };
82 
83  typedef std::vector<LArDetectorGap> LArDetectorGapList;
84 
85  //------------------------------------------------------------------------------------------------------------------------------------------
86  //------------------------------------------------------------------------------------------------------------------------------------------
87 
88  /**
89  * @brief daughter drift volume class to hold properties of daughter drift volumes
90  */
92  public:
93  /**
94  * @brief Constructor
95  *
96  * @param cryostat the cryostat ID
97  * @param tpc the tpc ID
98  * @param centerX centre of tpc volume (X)
99  * @param centerY centre of tpc volume (Y)
100  * @param centerZ centre of tpc volume (Z)
101  * @param widthX width of tpc volume (X)
102  * @param widthY width of tpc volume (Y)
103  * @param widthZ width of tpc volume (Z)
104  */
105  LArDaughterDriftVolume(const unsigned int cryostat,
106  const unsigned int tpc,
107  const float centerX,
108  const float centerY,
109  const float centerZ,
110  const float widthX,
111  const float widthY,
112  const float widthZ);
113 
114  /**
115  * @brief Return cryostat ID
116  */
117  unsigned int GetCryostat() const;
118 
119  /**
120  * @brief Return tpc ID
121  */
122  unsigned int GetTpc() const;
123 
124  /**
125  * @brief Return X position at centre of tpc volume
126  */
127  float GetCenterX() const;
128 
129  /**
130  * @brief Return Y position at centre of tpc volume
131  */
132  float GetCenterY() const;
133 
134  /**
135  * @brief Return Z position at centre of tpc volume
136  */
137  float GetCenterZ() const;
138 
139  /**
140  * @brief Return X span of tpc volume
141  */
142  float GetWidthX() const;
143 
144  /**
145  * @brief Return Y span of tpc volume
146  */
147  float GetWidthY() const;
148 
149  /**
150  * @brief Return Z span of tpc volume
151  */
152  float GetWidthZ() const;
153 
154  private:
155  unsigned int m_cryostat;
156  unsigned int m_tpc;
157  float m_centerX;
158  float m_centerY;
159  float m_centerZ;
160  float m_widthX;
161  float m_widthY;
162  float m_widthZ;
163  };
164 
165  typedef std::vector<LArDaughterDriftVolume> LArDaughterDriftVolumeList;
166 
167  //------------------------------------------------------------------------------------------------------------------------------------------
168  //------------------------------------------------------------------------------------------------------------------------------------------
169 
170  /**
171  * @brief drift volume class to hold properties of drift volume
172  */
174  public:
175  /**
176  * @brief Constructor
177  *
178  * @param volumeID unique ID number
179  * @param isPositiveDrift direction of drift
180  * @param wirePitchU wire pitch (U view)
181  * @param wirePitchV wire pitch (V view)
182  * @param wirePitchW wire pitch (W view)
183  * @param wireAngleU wire angle (U view)
184  * @param wireAngleV wire angle (V view)
185  * @param wireAngleW wire angle (W view)
186  * @param centerX centre of volume (X)
187  * @param centerY centre of volume (Y)
188  * @param centerZ centre of volume (Z)
189  * @param widthX width of volume (X)
190  * @param widthY width of volume (Y)
191  * @param widthZ width of volume (Z)
192  * @param thetaU wire angle to vertical (U)
193  * @param thetaV wire angle to vertical (V)
194  * @param sigmaUVZ matching between views
195  * @param tpcVolumeList input list of TPC volumes
196  */
197  LArDriftVolume(const unsigned int volumeID,
198  const bool isPositiveDrift,
199  const float wirePitchU,
200  const float wirePitchV,
201  const float wirePitchW,
202  const float wireAngleU,
203  const float wireAngleV,
204  const float wireAngleW,
205  const float centerX,
206  const float centerY,
207  const float centerZ,
208  const float widthX,
209  const float widthY,
210  const float widthZ,
211  const float sigmaUVZ,
212  const LArDaughterDriftVolumeList& tpcVolumeList);
213 
214  /**
215  * @brief Return unique ID
216  */
217  unsigned int GetVolumeID() const;
218 
219  /**
220  * @brief Return drift direction (true if positive)
221  */
222  bool IsPositiveDrift() const;
223 
224  /**
225  * @brief Return wire pitch in U view
226  */
227  float GetWirePitchU() const;
228 
229  /**
230  * @brief Return wire pictch in V view
231  */
232  float GetWirePitchV() const;
233 
234  /**
235  * @brief Return wire pitch in W view
236  */
237  float GetWirePitchW() const;
238 
239  /**
240  * @brief Return wire angle in U view (Pandora convention)
241  */
242  float GetWireAngleU() const;
243 
244  /**
245  * @brief Return wire angle in V view (Pandora convention)
246  */
247  float GetWireAngleV() const;
248 
249  /**
250  * @brief Return wire angle in W view (Pandora convention)
251  */
252  float GetWireAngleW() const;
253 
254  /**
255  * @brief Return X position at centre of drift volume
256  */
257  float GetCenterX() const;
258 
259  /**
260  * @brief Return Y position at centre of drift volume
261  */
262  float GetCenterY() const;
263 
264  /**
265  * @brief Return Z position at centre of drift volume
266  */
267  float GetCenterZ() const;
268 
269  /**
270  * @brief Return X span of drift volume
271  */
272  float GetWidthX() const;
273 
274  /**
275  * @brief Return Y span of drift volume
276  */
277  float GetWidthY() const;
278 
279  /**
280  * @brief Return Z span of drift volume
281  */
282  float GetWidthZ() const;
283 
284  /**
285  * @brief Return sigmaUVZ parameter (used for matching views)
286  */
287  float GetSigmaUVZ() const;
288 
289  /**
290  * @brief Return list of daughter drift volumes associated with this drift volume
291  */
292  const LArDaughterDriftVolumeList& GetTpcVolumeList() const;
293 
294  private:
295  unsigned int m_volumeID;
303  float m_centerX;
304  float m_centerY;
305  float m_centerZ;
306  float m_widthX;
307  float m_widthY;
308  float m_widthZ;
309  float m_sigmaUVZ;
310 
311  LArDaughterDriftVolumeList m_tpcVolumeList;
312  };
313 
314  typedef std::vector<LArDriftVolume> LArDriftVolumeList;
315  typedef std::map<unsigned int, LArDriftVolume> LArDriftVolumeMap;
316 
317  //------------------------------------------------------------------------------------------------------------------------------------------
318  //------------------------------------------------------------------------------------------------------------------------------------------
319 
320  /**
321  * @brief LArPandoraGeometry class
322  */
324  public:
325  /**
326  * @brief Load the 2D gaps that go with the chosen geometry
327  *
328  * @param listOfGaps the output list of 2D gaps.
329  * @param useActiveBoundingBox when true use ActiveBoundingBox instead of the default midpoint. Meant to handle offsets and things in a better way.
330  */
331  static void LoadDetectorGaps(LArDetectorGapList& listOfGaps, const bool useActiveBoundingBox);
332 
333  /**
334  * @brief Load drift volume geometry
335  *
336  * @param outputVolumeList the output list of drift volumes
337  * @param outputVolumeMap the output mapping between cryostat/tpc and drift volumes
338  * @param useActiveBoundingBox when true use ActiveBoundingBox instead of the default midpoint. Meant to handle offsets and things in a better way.
339  */
340  static void LoadGeometry(LArDriftVolumeList& outputVolumeList,
341  LArDriftVolumeMap& outputVolumeMap,
342  const bool useActiveBoundingBox);
343 
344  /**
345  * @brief Get drift volume ID from a specified cryostat/tpc pair
346  *
347  * @param driftVolumeMap the output mapping between cryostat/tpc and drift volumes
348  * @param cstat the input cryostat unique ID
349  * @param tpc the input tpc unique ID
350  */
351  static unsigned int GetVolumeID(const LArDriftVolumeMap& driftVolumeMap,
352  const unsigned int cstat,
353  const unsigned int tpc);
354 
355  /**
356  * @brief Get daughter volume ID from a specified cryostat/tpc pair
357  *
358  * @param driftVolumeMap the output mapping between cryostat/tpc and drift volumes
359  * @param cstat the input cryostat unique ID
360  * @param tpc the input tpc unique ID
361  */
362  static unsigned int GetDaughterVolumeID(const LArDriftVolumeMap& driftVolumeMap,
363  const unsigned int cstat,
364  const unsigned int tpc);
365 
366  /**
367  * @brief Convert to global coordinate system
368  *
369  * @param cstat the input cryostat
370  * @param tpc the input tpc
371  * @param hit_View the input view
372  */
373  static geo::View_t GetGlobalView(const unsigned int cstat,
374  const unsigned int tpc,
375  const geo::View_t hit_View);
376 
377  private:
378  /**
379  * @brief Generate a unique identifier for each TPC
380  *
381  * @param cstat the input cryostat
382  * @param tpc the input tpc
383  */
384  static unsigned int GetTpcID(const unsigned int cstat, const unsigned int tpc);
385 
386  /**
387  * @brief Return whether U/V should be switched in global coordinate system for this cryostat/tpc
388  *
389  * @param cstat the input cryostat
390  * @param tpc the input tpc
391  */
392  static bool ShouldSwitchUV(const unsigned int cstat, const unsigned int tpc);
393 
394  /**
395  * @brief Return whether U/V should be switched in global coordinate system for this drift direction
396  *
397  * @param isPositiveDrift the drift direction
398  */
399  static bool ShouldSwitchUV(const bool isPositiveDrift);
400 
401  /**
402  * @brief This method will group TPCs into drift volumes (these are regions of the detector that share a common drift direction,
403  * common range of X coordinates, and common detector parameters such as wire pitch and wire angle).
404  *
405  * @param driftVolumeList to receive the populated drift volume list
406  * @param useActiveBoundingBox when true use ActiveBoundingBox instead of the default midpoint. Meant to handle offsets and things in a better way.
407  */
408  static void LoadGeometry(LArDriftVolumeList& driftVolumeList, const bool useActiveBoundingBox);
409 
410  /**
411  * @brief This method will create one or more daughter volumes (these share a common drift orientation along the X-axis,
412  * have parallel or near-parallel wire angles, and similar wire pitches)
413  *
414  * @param driftVolumeList to receive the input drift volume list
415  * @param parentVolumeList to receive the output daughter drift volume list
416  */
417  static void LoadGlobalDaughterGeometry(const LArDriftVolumeList& driftVolumeList,
418  LArDriftVolumeList& daughterVolumeList);
419  };
420 
421  //------------------------------------------------------------------------------------------------------------------------------------------
422  //------------------------------------------------------------------------------------------------------------------------------------------
423 
424  inline LArDetectorGap::LArDetectorGap(const float x1,
425  const float y1,
426  const float z1,
427  const float x2,
428  const float y2,
429  const float z2)
430  : m_x1(x1), m_y1(y1), m_z1(z1), m_x2(x2), m_y2(y2), m_z2(z2)
431  {}
432 
433  //------------------------------------------------------------------------------------------------------------------------------------------
434 
435  inline float
437  {
438  return m_x1;
439  }
440 
441  //------------------------------------------------------------------------------------------------------------------------------------------
442 
443  inline float
445  {
446  return m_y1;
447  }
448 
449  //------------------------------------------------------------------------------------------------------------------------------------------
450 
451  inline float
453  {
454  return m_z1;
455  }
456 
457  //------------------------------------------------------------------------------------------------------------------------------------------
458 
459  inline float
461  {
462  return m_x2;
463  }
464 
465  //------------------------------------------------------------------------------------------------------------------------------------------
466 
467  inline float
469  {
470  return m_y2;
471  }
472 
473  //------------------------------------------------------------------------------------------------------------------------------------------
474 
475  inline float
477  {
478  return m_z2;
479  }
480 
481  //------------------------------------------------------------------------------------------------------------------------------------------
482 
483  inline float
485  {
486  return 30.f; // TODO: 30cm should be fine but can we do better than a hard-coded number here?
487  }
488 
489  //------------------------------------------------------------------------------------------------------------------------------------------
490  //------------------------------------------------------------------------------------------------------------------------------------------
491 
492  inline LArDaughterDriftVolume::LArDaughterDriftVolume(const unsigned int cryostat,
493  const unsigned int tpc,
494  const float centerX,
495  const float centerY,
496  const float centerZ,
497  const float widthX,
498  const float widthY,
499  const float widthZ)
500  : m_cryostat(cryostat)
501  , m_tpc(tpc)
502  , m_centerX(centerX)
503  , m_centerY(centerY)
504  , m_centerZ(centerZ)
505  , m_widthX(widthX)
506  , m_widthY(widthY)
507  , m_widthZ(widthZ)
508  {}
509 
510  //------------------------------------------------------------------------------------------------------------------------------------------
511 
512  inline unsigned int
514  {
515  return m_cryostat;
516  }
517 
518  //------------------------------------------------------------------------------------------------------------------------------------------
519 
520  inline unsigned int
522  {
523  return m_tpc;
524  }
525 
526  //------------------------------------------------------------------------------------------------------------------------------------------
527 
528  inline float
530  {
531  return m_centerX;
532  }
533 
534  //------------------------------------------------------------------------------------------------------------------------------------------
535 
536  inline float
538  {
539  return m_centerY;
540  }
541 
542  //------------------------------------------------------------------------------------------------------------------------------------------
543 
544  inline float
546  {
547  return m_centerZ;
548  }
549 
550  //------------------------------------------------------------------------------------------------------------------------------------------
551 
552  inline float
554  {
555  return m_widthX;
556  }
557 
558  //------------------------------------------------------------------------------------------------------------------------------------------
559 
560  inline float
562  {
563  return m_widthY;
564  }
565 
566  //------------------------------------------------------------------------------------------------------------------------------------------
567 
568  inline float
570  {
571  return m_widthZ;
572  }
573 
574  //------------------------------------------------------------------------------------------------------------------------------------------
575  //------------------------------------------------------------------------------------------------------------------------------------------
576 
577  inline unsigned int
579  {
580  return m_volumeID;
581  }
582 
583  //------------------------------------------------------------------------------------------------------------------------------------------
584 
585  inline bool
587  {
588  return m_isPositiveDrift;
589  }
590 
591  //------------------------------------------------------------------------------------------------------------------------------------------
592 
593  inline float
595  {
596  return m_wirePitchU;
597  }
598 
599  //------------------------------------------------------------------------------------------------------------------------------------------
600 
601  inline float
603  {
604  return m_wirePitchV;
605  }
606 
607  //------------------------------------------------------------------------------------------------------------------------------------------
608 
609  inline float
611  {
612  return m_wirePitchW;
613  }
614 
615  //------------------------------------------------------------------------------------------------------------------------------------------
616 
617  inline float
619  {
620  return m_wireAngleU;
621  }
622 
623  //------------------------------------------------------------------------------------------------------------------------------------------
624 
625  inline float
627  {
628  return m_wireAngleV;
629  }
630 
631  //------------------------------------------------------------------------------------------------------------------------------------------
632 
633  inline float
635  {
636  return m_wireAngleW;
637  }
638 
639  //------------------------------------------------------------------------------------------------------------------------------------------
640 
641  inline float
643  {
644  return m_centerX;
645  }
646 
647  //------------------------------------------------------------------------------------------------------------------------------------------
648 
649  inline float
651  {
652  return m_centerY;
653  }
654 
655  //------------------------------------------------------------------------------------------------------------------------------------------
656 
657  inline float
659  {
660  return m_centerZ;
661  }
662 
663  //------------------------------------------------------------------------------------------------------------------------------------------
664 
665  inline float
667  {
668  return m_widthX;
669  }
670 
671  //------------------------------------------------------------------------------------------------------------------------------------------
672 
673  inline float
675  {
676  return m_widthY;
677  }
678 
679  //------------------------------------------------------------------------------------------------------------------------------------------
680 
681  inline float
683  {
684  return m_widthZ;
685  }
686 
687  //------------------------------------------------------------------------------------------------------------------------------------------
688 
689  inline float
691  {
692  return m_sigmaUVZ;
693  }
694 
695  //------------------------------------------------------------------------------------------------------------------------------------------
696 
697  inline const LArDaughterDriftVolumeList&
699  {
700  return m_tpcVolumeList;
701  }
702 
703 } // namespace lar_pandora
704 
705 #endif // #ifndef LAR_PANDORA_GEOMETRY_H
float GetCenterZ() const
Return Z position at centre of tpc volume.
float GetWidthZ() const
Return Z span of drift volume.
float GetWidthY() const
Return Y span of tpc volume.
daughter drift volume class to hold properties of daughter drift volumes
float GetWidthZ() const
Return Z span of tpc volume.
float GetWidthX() const
Return X span of tpc volume.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
std::map< unsigned int, LArDriftVolume > LArDriftVolumeMap
LArDetectorGap(const float x1, const float y1, const float z1, const float x2, const float y2, const float z2)
Constructor.
unsigned int GetCryostat() const
Return cryostat ID.
LArDaughterDriftVolumeList m_tpcVolumeList
std::vector< LArDriftVolume > LArDriftVolumeList
float GetZ1() const
Get lower Z coordinate.
LArDaughterDriftVolume(const unsigned int cryostat, const unsigned int tpc, const float centerX, const float centerY, const float centerZ, const float widthX, const float widthY, const float widthZ)
Constructor.
float GetWireAngleW() const
Return wire angle in W view (Pandora convention)
float GetCenterZ() const
Return Z position at centre of drift volume.
float GetWirePitchW() const
Return wire pitch in W view.
const LArDaughterDriftVolumeList & GetTpcVolumeList() const
Return list of daughter drift volumes associated with this drift volume.
LArPandoraGeometry class.
float GetCenterX() const
Return X position at centre of drift volume.
unsigned int GetVolumeID() const
Return unique ID.
float GetCenterX() const
Return X position at centre of tpc volume.
bool IsPositiveDrift() const
Return drift direction (true if positive)
float GetCenterY() const
Return Y position at centre of tpc volume.
Definition of data types for geometry description.
float GetX1() const
Get lower X coordinate.
float GetWireAngleV() const
Return wire angle in V view (Pandora convention)
std::vector< LArDaughterDriftVolume > LArDaughterDriftVolumeList
static float GetMaxGapSize() noexcept
Get maximum gap size.
std::vector< LArDetectorGap > LArDetectorGapList
float GetWidthY() const
Return Y span of drift volume.
float GetCenterY() const
Return Y position at centre of drift volume.
float GetWirePitchU() const
Return wire pitch in U view.
float GetSigmaUVZ() const
Return sigmaUVZ parameter (used for matching views)
drift volume class to hold properties of drift volume
float GetWirePitchV() const
Return wire pictch in V view.
float GetWidthX() const
Return X span of drift volume.
float GetY1() const
Get lower y coordinate.
float GetY2() const
Get upper Y coordinate.
drift volume class to hold properties of drift volume
float GetX2() const
Get upper X coordinate.
float GetZ2() const
Get upper Z coordinate.
float GetWireAngleU() const
Return wire angle in U view (Pandora convention)
unsigned int GetTpc() const
Return tpc ID.