LArTrackOverlapResult.cc
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArObjects/LArTrackOverlapResult.cc
3  *
4  * @brief Implementation of the lar track overlap result class.
5  *
6  * $Log: $
7  */
8 
9 #include "Objects/CaloHit.h"
10 
11 #include "Pandora/PandoraInternal.h"
12 
14 
15 using namespace pandora;
16 
17 namespace lar_content
18 {
19 
20 TrackOverlapResult::TrackOverlapResult() :
21  m_isInitialized(false),
22  m_nMatchedSamplingPoints(0),
23  m_nSamplingPoints(0),
24  m_matchedFraction(0.f),
25  m_chi2(0.f),
26  m_reducedChi2(0.f)
27 {
28 }
29 
30 //------------------------------------------------------------------------------------------------------------------------------------------
31 
32 TrackOverlapResult::TrackOverlapResult(const unsigned int nMatchedSamplingPoints, const unsigned int nSamplingPoints, const float chi2) :
33  m_isInitialized(true),
34  m_nMatchedSamplingPoints(nMatchedSamplingPoints),
35  m_nSamplingPoints(nSamplingPoints),
37  m_chi2(chi2),
38  m_reducedChi2(0.f)
39 {
41  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
42 
43  m_matchedFraction = static_cast<float>(m_nMatchedSamplingPoints) / static_cast<float>(m_nSamplingPoints);
44  m_reducedChi2 = m_chi2 / static_cast<float>(m_nSamplingPoints);
45 }
46 
47 //------------------------------------------------------------------------------------------------------------------------------------------
48 
54  m_chi2(rhs.m_chi2),
56 {
57 }
58 
59 //------------------------------------------------------------------------------------------------------------------------------------------
60 
62 {
63 }
64 
65 //------------------------------------------------------------------------------------------------------------------------------------------
66 
68 {
69  if (this == &rhs)
70  return false;
71 
72  if (!m_isInitialized && !rhs.IsInitialized())
73  throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
74 
75  if (!m_isInitialized)
76  return true;
77 
78  if (!rhs.IsInitialized())
79  return false;
80 
83 
84  if (std::fabs(m_reducedChi2 - rhs.m_reducedChi2) > std::numeric_limits<float>::epsilon())
85  return (m_reducedChi2 > rhs.m_reducedChi2);
86 
87  return (m_matchedFraction < rhs.m_matchedFraction);
88 }
89 
90 //------------------------------------------------------------------------------------------------------------------------------------------
91 
93 {
94  if (this == &rhs)
95  return false;
96 
97  return !(*this < rhs);
98 }
99 
100 //------------------------------------------------------------------------------------------------------------------------------------------
101 
103 {
104  if (this == &rhs)
105  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
106 
111  m_chi2 = rhs.m_chi2;
113 
114  return *this;
115 }
116 
117 //------------------------------------------------------------------------------------------------------------------------------------------
118 //------------------------------------------------------------------------------------------------------------------------------------------
119 
121 {
122 }
123 
124 //------------------------------------------------------------------------------------------------------------------------------------------
125 
127  const unsigned int nMatchedSamplingPoints, const unsigned int nSamplingPoints, const float chi2, const XOverlap &xOverlap) :
128  TrackOverlapResult(nMatchedSamplingPoints, nSamplingPoints, chi2),
129  m_xOverlap(xOverlap)
130 {
131 }
132 
133 //------------------------------------------------------------------------------------------------------------------------------------------
134 
136  TrackOverlapResult(rhs),
137  m_xOverlap(rhs.IsInitialized() ? rhs.GetXOverlap() : XOverlap(0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f))
138 {
139 }
140 
141 //------------------------------------------------------------------------------------------------------------------------------------------
142 
144 {
145 }
146 
147 //------------------------------------------------------------------------------------------------------------------------------------------
148 
150 {
152 
153  if (rhs.IsInitialized())
154  {
155  m_xOverlap = rhs.GetXOverlap();
156  }
157  else
158  {
159  m_xOverlap = XOverlap(0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f);
160  }
161 
162  return *this;
163 }
164 
165 //------------------------------------------------------------------------------------------------------------------------------------------
166 //------------------------------------------------------------------------------------------------------------------------------------------
167 
169 {
170  if (!lhs.IsInitialized() && !rhs.IsInitialized())
171  throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
172 
173  if (!lhs.IsInitialized())
174  return rhs;
175 
176  if (!rhs.IsInitialized())
177  return lhs;
178 
180  lhs.GetNSamplingPoints() + rhs.GetNSamplingPoints(), lhs.GetChi2() + rhs.GetChi2(), lhs.GetXOverlap() + rhs.GetXOverlap());
181 }
182 
183 //------------------------------------------------------------------------------------------------------------------------------------------
184 //------------------------------------------------------------------------------------------------------------------------------------------
185 
187 {
188 }
189 //------------------------------------------------------------------------------------------------------------------------------------------
190 
191 LongitudinalOverlapResult::LongitudinalOverlapResult(const TrackOverlapResult trackOverlapResult, const float innerChi2, const float outerChi2) :
192  TrackOverlapResult(trackOverlapResult),
193  m_innerChi2(innerChi2),
194  m_outerChi2(outerChi2)
195 {
196 }
197 
198 //------------------------------------------------------------------------------------------------------------------------------------------
199 
200 LongitudinalOverlapResult::LongitudinalOverlapResult(const unsigned int nMatchedSamplingPoints, const unsigned int nSamplingPoints,
201  const float chi2, const float innerChi2, const float outerChi2) :
202  TrackOverlapResult(nMatchedSamplingPoints, nSamplingPoints, chi2),
203  m_innerChi2(innerChi2),
204  m_outerChi2(outerChi2)
205 {
206 }
207 
208 //------------------------------------------------------------------------------------------------------------------------------------------
209 
211  TrackOverlapResult(rhs),
212  m_innerChi2(rhs.IsInitialized() ? rhs.GetInnerChi2() : 0.f),
213  m_outerChi2(rhs.IsInitialized() ? rhs.GetOuterChi2() : 0.f)
214 {
215 }
216 
217 //------------------------------------------------------------------------------------------------------------------------------------------
218 
220 {
221 }
222 
223 //------------------------------------------------------------------------------------------------------------------------------------------
224 
226 {
228  m_innerChi2 = rhs.GetInnerChi2();
229  m_outerChi2 = rhs.GetOuterChi2();
230 
231  return *this;
232 }
233 
234 //------------------------------------------------------------------------------------------------------------------------------------------
235 //------------------------------------------------------------------------------------------------------------------------------------------
236 
238 {
239 }
240 //------------------------------------------------------------------------------------------------------------------------------------------
241 
243  const TrackOverlapResult trackOverlapResult, const pandora::CaloHitList &caloHitList, const pandora::ClusterList &clusterList) :
244  TrackOverlapResult(trackOverlapResult),
245  m_caloHitList(caloHitList),
246  m_clusterList(clusterList)
247 {
248 }
249 
250 //------------------------------------------------------------------------------------------------------------------------------------------
251 
252 FragmentOverlapResult::FragmentOverlapResult(const unsigned int nMatchedSamplingPoints, const unsigned int nSamplingPoints,
253  const float chi2, const pandora::CaloHitList &caloHitList, const pandora::ClusterList &clusterList) :
254  TrackOverlapResult(nMatchedSamplingPoints, nSamplingPoints, chi2),
255  m_caloHitList(caloHitList),
256  m_clusterList(clusterList)
257 {
258 }
259 
260 //------------------------------------------------------------------------------------------------------------------------------------------
261 
263  TrackOverlapResult(rhs),
264  m_caloHitList(rhs.IsInitialized() ? rhs.GetFragmentCaloHitList() : CaloHitList()),
265  m_clusterList(rhs.IsInitialized() ? rhs.GetFragmentClusterList() : ClusterList())
266 {
267 }
268 
269 //------------------------------------------------------------------------------------------------------------------------------------------
270 
272 {
273 }
274 
275 //------------------------------------------------------------------------------------------------------------------------------------------
276 
278 {
282 
283  return *this;
284 }
285 
286 //------------------------------------------------------------------------------------------------------------------------------------------
287 
289 {
290  if (m_caloHitList.empty())
291  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
292 
293  return (*(m_caloHitList.begin()))->GetHitType();
294 }
295 
296 //------------------------------------------------------------------------------------------------------------------------------------------
297 //------------------------------------------------------------------------------------------------------------------------------------------
298 
300 {
301 }
302 
303 //------------------------------------------------------------------------------------------------------------------------------------------
304 
305 DeltaRayOverlapResult::DeltaRayOverlapResult(const unsigned int nMatchedSamplingPoints, const unsigned int nSamplingPoints,
306  const float chi2, const XOverlap &xOverlap, const PfoList &commonMuonPfoList) :
307  TransverseOverlapResult(nMatchedSamplingPoints, nSamplingPoints, chi2, xOverlap),
308  m_commonMuonPfoList(commonMuonPfoList)
309 {
310 }
311 
312 //------------------------------------------------------------------------------------------------------------------------------------------
313 
317 {
318 }
319 
320 //------------------------------------------------------------------------------------------------------------------------------------------
321 
323 {
324 }
325 
326 //------------------------------------------------------------------------------------------------------------------------------------------
327 
329 {
331 
333 
334  return *this;
335 }
336 
337 //------------------------------------------------------------------------------------------------------------------------------------------
338 //------------------------------------------------------------------------------------------------------------------------------------------
339 
340 } // namespace lar_content
LongitudinalOverlapResult class.
pandora::ClusterList m_clusterList
The list of fragment-associated clusters.
float m_chi2
The absolute chi2 value.
FragmentOverlapResult class.
unsigned int GetNMatchedSamplingPoints() const
Get the number of matched sampling points.
enum cvn::HType HitType
bool IsInitialized() const
Whether the track overlap result has been initialized.
virtual ~TrackOverlapResult()
Destructor.
FragmentOverlapResult & operator=(const FragmentOverlapResult &rhs)
Fragments overlap result assigment operator.
TrackOverlapResult()
Default constructor.
unsigned int m_nMatchedSamplingPoints
The number of matched sampling points.
bool m_isInitialized
Whether the track overlap result has been initialized.
float m_outerChi2
The outer chi squared.
float m_innerChi2
The inner chi squared.
bool operator<(const TrackOverlapResult &rhs) const
Track overlap result less than operator.
const XOverlap & GetXOverlap() const
Get the x overlap object.
TransverseOverlapResult operator+(const TransverseOverlapResult &lhs, const TransverseOverlapResult &rhs)
Transverse overlap result + operator.
pandora::HitType GetFragmentHitType() const
Get the fragment hit type.
const pandora::CaloHitList & GetFragmentCaloHitList() const
Get the list of fragment-associated hits.
unsigned int GetNSamplingPoints() const
Get the number of sampling points.
const pandora::PfoList & GetCommonMuonPfoList() const
Get the common muon pfo list.
DeltaRayOverlapResult class.
TransverseOverlapResult class.
TrackOverlapResult class.
LongitudinalOverlapResult & operator=(const LongitudinalOverlapResult &rhs)
Track overlap result assigment operator.
TrackOverlapResult & operator=(const TrackOverlapResult &rhs)
Track overlap result assigment operator.
Header file for the lar track overlap result class.
bool operator>(const TrackOverlapResult &rhs) const
Track overlap result greater than operator.
float m_reducedChi2
The chi2 per samping point value.
pandora::PfoList m_commonMuonPfoList
The list of cosmic ray pfos that, in each view, lie close to the clusters of the tensor element...
unsigned int m_nSamplingPoints
The number of sampling points.
float m_matchedFraction
The fraction of sampling points resulting in a match.
TransverseOverlapResult & operator=(const TransverseOverlapResult &rhs)
Track overlap result assigment operator.
XOverlap class.
Definition: LArXOverlap.h:17
const pandora::ClusterList & GetFragmentClusterList() const
Get the list of fragment-associated clusters.
float GetChi2() const
Get the absolute chi2 value.
DeltaRayOverlapResult & operator=(const DeltaRayOverlapResult &rhs)
Track overlap result assigment operator.
pandora::CaloHitList m_caloHitList
The list of fragment-associated hits.
XOverlap m_xOverlap
The x overlap object.