LArTwoViewXOverlap.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArObjects/LArTwoViewXOverlap.h
3  *
4  * @brief Header file for the lar x two view overlap class.
5  *
6  * $Log: $
7  */
8 #ifndef LAR_TWO_VIEW_X_OVERLAP_H
9 #define LAR_TWO_VIEW_X_OVERLAP_H 1
10 
11 #include <algorithm>
12 #include <cmath>
13 #include <limits>
14 
15 namespace lar_content
16 {
17 
18 /**
19  * @brief TwoViewXOverlap class
20  */
22 {
23 public:
24  /**
25  * @brief Constructor
26  *
27  * @param xMin0 min x value in the view 0
28  * @param xMax0 max x value in the view 0
29  * @param xMin1 min x value in the view 1
30  * @param xMax1 max x value in the view 1
31  */
32  TwoViewXOverlap(const float xMin0, const float xMax0, const float xMin1, const float xMax1);
33 
34  /**
35  * @brief Get the min x value in the view 0
36  *
37  * @return the min x value in the view 0
38  */
39  float GetXMin0() const;
40 
41  /**
42  * @brief Get the max x value in the view 0
43  *
44  * @return the max x value in the view 0
45  */
46  float GetXMax0() const;
47 
48  /**
49  * @brief Get the min x value in the view 1
50  *
51  * @return the min x value in the view 1
52  */
53  float GetXMin1() const;
54 
55  /**
56  * @brief Get the max x value in the view 1
57  *
58  * @return the max x value in the view 1
59  */
60  float GetXMax1() const;
61 
62  /**
63  * @brief Get the x span in the view 0
64  *
65  * @return the x span in the view 0
66  */
67  float GetXSpan0() const;
68 
69  /**
70  * @brief Get the x span in the view 1
71  *
72  * @return the x span in the view 1
73  */
74  float GetXSpan1() const;
75 
76  /**
77  * @brief Get the x overlap span
78  *
79  * @return the x overlap span
80  */
81  float GetTwoViewXOverlapSpan() const;
82 
83  /**
84  * @brief Get the x overlap max X value
85  *
86  * @return the x overlap min
87  */
88  float GetTwoViewXOverlapMin() const;
89 
90  /**
91  * @brief Get the x overlap min X value
92  *
93  * @return the x overlap max
94  */
95  float GetTwoViewXOverlapMax() const;
96 
97  /**
98  * @brief Get the fraction of the view 0 cluster that overlaps in x
99  *
100  * @return the view 0 cluster's fractional overlap
101  */
102  float GetXOverlapFraction0() const;
103 
104  /**
105  * @brief Get the fraction of the view 1 cluster that overlaps in x
106  *
107  * @return the view 1 cluster's fractional overlap
108  */
109  float GetXOverlapFraction1() const;
110 
111 private:
112  float m_xMin0; ///< The min x value in the view 0
113  float m_xMax0; ///< The max x value in the view 0
114  float m_xMin1; ///< The min x value in the view 1
115  float m_xMax1; ///< The max x value in the view 1
116  float m_xOverlapSpan; ///< The x overlap span
117 };
118 
119 /**
120  * @brief x overlap result + operator
121  *
122  * @param lhs the first x overlap result to add
123  * @param rhs the second x overlap result to add
124  */
126 
127 //------------------------------------------------------------------------------------------------------------------------------------------
128 
129 inline TwoViewXOverlap::TwoViewXOverlap(const float xMin0, const float xMax0, const float xMin1, const float xMax1) :
130  m_xMin0(xMin0),
131  m_xMax0(xMax0),
132  m_xMin1(xMin1),
133  m_xMax1(xMax1),
135 {
136 }
137 
138 //------------------------------------------------------------------------------------------------------------------------------------------
139 
140 inline float TwoViewXOverlap::GetXMin0() const
141 {
142  return m_xMin0;
143 }
144 
145 //------------------------------------------------------------------------------------------------------------------------------------------
146 
147 inline float TwoViewXOverlap::GetXMax0() const
148 {
149  return m_xMax0;
150 }
151 
152 //------------------------------------------------------------------------------------------------------------------------------------------
153 
154 inline float TwoViewXOverlap::GetXMin1() const
155 {
156  return m_xMin1;
157 }
158 
159 //------------------------------------------------------------------------------------------------------------------------------------------
160 
161 inline float TwoViewXOverlap::GetXMax1() const
162 {
163  return m_xMax1;
164 }
165 
166 //------------------------------------------------------------------------------------------------------------------------------------------
167 
168 inline float TwoViewXOverlap::GetXSpan0() const
169 {
170  return std::fabs(m_xMax0 - m_xMin0);
171 }
172 
173 //------------------------------------------------------------------------------------------------------------------------------------------
174 
175 inline float TwoViewXOverlap::GetXSpan1() const
176 {
177  return std::fabs(m_xMax1 - m_xMin1);
178 }
179 
180 //------------------------------------------------------------------------------------------------------------------------------------------
181 
183 {
184  return m_xOverlapSpan;
185 }
186 
187 //------------------------------------------------------------------------------------------------------------------------------------------
188 
190 {
191  return std::max(m_xMin0, m_xMin1);
192 }
193 
194 //------------------------------------------------------------------------------------------------------------------------------------------
195 
197 {
198  return std::min(m_xMax0, m_xMax1);
199 }
200 
201 //------------------------------------------------------------------------------------------------------------------------------------------
202 
204 {
205  return (std::numeric_limits<float>::epsilon() < this->GetXSpan0()) ? m_xOverlapSpan / this->GetXSpan0() : 0.f;
206 }
207 
208 //------------------------------------------------------------------------------------------------------------------------------------------
209 
211 {
212  return (std::numeric_limits<float>::epsilon() < this->GetXSpan1()) ? m_xOverlapSpan / this->GetXSpan1() : 0.f;
213 }
214 
215 //------------------------------------------------------------------------------------------------------------------------------------------
216 
218 {
219  const float xMin0(std::min(lhs.GetXMin0(), rhs.GetXMin0()));
220  const float xMax0(std::max(lhs.GetXMax0(), rhs.GetXMax0()));
221  const float xMin1(std::min(lhs.GetXMin1(), rhs.GetXMin1()));
222  const float xMax1(std::max(lhs.GetXMax1(), rhs.GetXMax1()));
223 
224  return TwoViewXOverlap(xMin0, xMax0, xMin1, xMax1);
225 }
226 
227 } // namespace lar_content
228 
229 #endif // #ifndef LAR_TWO_VIEW_X_OVERLAP_H
float m_xMax1
The max x value in the view 1.
float GetTwoViewXOverlapMax() const
Get the x overlap min X value.
float GetXMax0() const
Get the max x value in the view 0.
STL namespace.
float m_xMin1
The min x value in the view 1.
TransverseOverlapResult operator+(const TransverseOverlapResult &lhs, const TransverseOverlapResult &rhs)
Transverse overlap result + operator.
float GetXSpan0() const
Get the x span in the view 0.
float GetXMin1() const
Get the min x value in the view 1.
float GetTwoViewXOverlapMin() const
Get the x overlap max X value.
float GetXMin0() const
Get the min x value in the view 0.
float GetXSpan1() const
Get the x span in the view 1.
float m_xMax0
The max x value in the view 0.
float GetXOverlapFraction1() const
Get the fraction of the view 1 cluster that overlaps in x.
float GetXMax1() const
Get the max x value in the view 1.
static int max(int a, int b)
float m_xOverlapSpan
The x overlap span.
float GetXOverlapFraction0() const
Get the fraction of the view 0 cluster that overlaps in x.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
float GetTwoViewXOverlapSpan() const
Get the x overlap span.
TwoViewXOverlap(const float xMin0, const float xMax0, const float xMin1, const float xMax1)
Constructor.
TwoViewXOverlap class.
float m_xMin0
The min x value in the view 0.