LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
LArTwoViewXOverlap.h
Go to the documentation of this file.
1 
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 
22 {
23 public:
32  TwoViewXOverlap(const float xMin0, const float xMax0, const float xMin1, const float xMax1);
33 
39  float GetXMin0() const;
40 
46  float GetXMax0() const;
47 
53  float GetXMin1() const;
54 
60  float GetXMax1() const;
61 
67  float GetXSpan0() const;
68 
74  float GetXSpan1() const;
75 
81  float GetTwoViewXOverlapSpan() const;
82 
88  float GetTwoViewXOverlapMin() const;
89 
95  float GetTwoViewXOverlapMax() const;
96 
102  float GetXOverlapFraction0() const;
103 
109  float GetXOverlapFraction1() const;
110 
111 private:
112  float m_xMin0;
113  float m_xMax0;
114  float m_xMin1;
115  float m_xMax1;
117 };
118 
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.
float m_xOverlapSpan
The x overlap span.
float GetXOverlapFraction0() const
Get the fraction of the view 0 cluster that overlaps in x.
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.