LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
LArTrackOverlapResult.cc
Go to the documentation of this file.
1 
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 
122  m_xOverlap(XOverlap(0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f))
123 {
124 }
125 
126 //------------------------------------------------------------------------------------------------------------------------------------------
127 
128 TransverseOverlapResult::TransverseOverlapResult(const unsigned int nMatchedSamplingPoints, const unsigned int nSamplingPoints,
129  const float chi2, const XOverlap &xOverlap) :
130  TrackOverlapResult(nMatchedSamplingPoints, nSamplingPoints, chi2),
131  m_xOverlap(xOverlap)
132 {
133 }
134 
135 //------------------------------------------------------------------------------------------------------------------------------------------
136 
138  TrackOverlapResult(rhs),
139  m_xOverlap(rhs.IsInitialized() ? rhs.GetXOverlap() : XOverlap(0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f))
140 {
141 }
142 
143 //------------------------------------------------------------------------------------------------------------------------------------------
144 
146 {
147 }
148 
149 //------------------------------------------------------------------------------------------------------------------------------------------
150 
152 {
154 
155  if (rhs.IsInitialized())
156  {
157  m_xOverlap = rhs.GetXOverlap();
158  }
159  else
160  {
161  m_xOverlap = XOverlap(0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f);
162  }
163 
164  return *this;
165 }
166 
167 //------------------------------------------------------------------------------------------------------------------------------------------
168 //------------------------------------------------------------------------------------------------------------------------------------------
169 
171 {
172  if (!lhs.IsInitialized() && !rhs.IsInitialized())
173  throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
174 
175  if (!lhs.IsInitialized())
176  return rhs;
177 
178  if (!rhs.IsInitialized())
179  return lhs;
180 
182  lhs.GetNSamplingPoints() + rhs.GetNSamplingPoints(), lhs.GetChi2() + rhs.GetChi2(), lhs.GetXOverlap() + rhs.GetXOverlap());
183 }
184 
185 //------------------------------------------------------------------------------------------------------------------------------------------
186 //------------------------------------------------------------------------------------------------------------------------------------------
187 
190  m_innerChi2(0.f),
191  m_outerChi2(0.f)
192 {
193 }
194 //------------------------------------------------------------------------------------------------------------------------------------------
195 
196 LongitudinalOverlapResult::LongitudinalOverlapResult(const TrackOverlapResult trackOverlapResult, const float innerChi2, const float outerChi2) :
197  TrackOverlapResult(trackOverlapResult),
198  m_innerChi2(innerChi2),
199  m_outerChi2(outerChi2)
200 {
201 
202 }
203 
204 //------------------------------------------------------------------------------------------------------------------------------------------
205 
206 LongitudinalOverlapResult::LongitudinalOverlapResult(const unsigned int nMatchedSamplingPoints, const unsigned int nSamplingPoints,
207  const float chi2, const float innerChi2, const float outerChi2) :
208  TrackOverlapResult(nMatchedSamplingPoints, nSamplingPoints, chi2),
209  m_innerChi2(innerChi2),
210  m_outerChi2(outerChi2)
211 {
212 }
213 
214 //------------------------------------------------------------------------------------------------------------------------------------------
215 
217  TrackOverlapResult(rhs),
218  m_innerChi2(rhs.IsInitialized() ? rhs.GetInnerChi2() : 0.f),
219  m_outerChi2(rhs.IsInitialized() ? rhs.GetOuterChi2() : 0.f)
220 {
221 }
222 
223 //------------------------------------------------------------------------------------------------------------------------------------------
224 
226 {
227 }
228 
229 //------------------------------------------------------------------------------------------------------------------------------------------
230 
232 {
234  m_innerChi2 = rhs.GetInnerChi2();
235  m_outerChi2 = rhs.GetOuterChi2();
236 
237  return *this;
238 }
239 
240 //------------------------------------------------------------------------------------------------------------------------------------------
241 //------------------------------------------------------------------------------------------------------------------------------------------
242 
245  m_caloHitList(),
246  m_clusterList()
247 {
248 }
249 //------------------------------------------------------------------------------------------------------------------------------------------
250 
251 FragmentOverlapResult::FragmentOverlapResult(const TrackOverlapResult trackOverlapResult, const pandora::CaloHitList &caloHitList,
252  const pandora::ClusterList &clusterList) :
253  TrackOverlapResult(trackOverlapResult),
254  m_caloHitList(caloHitList),
255  m_clusterList(clusterList)
256 {
257 
258 }
259 
260 //------------------------------------------------------------------------------------------------------------------------------------------
261 
262 FragmentOverlapResult::FragmentOverlapResult(const unsigned int nMatchedSamplingPoints, const unsigned int nSamplingPoints,
263  const float chi2, const pandora::CaloHitList &caloHitList, const pandora::ClusterList &clusterList) :
264  TrackOverlapResult(nMatchedSamplingPoints, nSamplingPoints, chi2),
265  m_caloHitList(caloHitList),
266  m_clusterList(clusterList)
267 {
268 }
269 
270 //------------------------------------------------------------------------------------------------------------------------------------------
271 
273  TrackOverlapResult(rhs),
274  m_caloHitList(rhs.IsInitialized() ? rhs.GetFragmentCaloHitList() : CaloHitList()),
275  m_clusterList(rhs.IsInitialized() ? rhs.GetFragmentClusterList() : ClusterList())
276 {
277 }
278 
279 //------------------------------------------------------------------------------------------------------------------------------------------
280 
282 {
283 }
284 
285 //------------------------------------------------------------------------------------------------------------------------------------------
286 
288 {
292 
293  return *this;
294 }
295 
296 //------------------------------------------------------------------------------------------------------------------------------------------
297 
299 {
300  if (m_caloHitList.empty())
301  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
302 
303  return (*(m_caloHitList.begin()))->GetHitType();
304 }
305 
306 } // 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.
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.
TFile f
Definition: plotHisto.C:6
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.
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.
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.
pandora::CaloHitList m_caloHitList
The list of fragment-associated hits.
XOverlap m_xOverlap
The x overlap object.