Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
LArTwoDSlidingFitObjects.h
Go to the documentation of this file.
1
8#ifndef LAR_TWO_D_SLIDING_FIT_OBJECTS_H
9#define LAR_TWO_D_SLIDING_FIT_OBJECTS_H 1
10
11#include "Pandora/StatusCodes.h"
12
13#include <cmath>
14#include <map>
15#include <vector>
16
17namespace lar_content
18{
19
30
31//------------------------------------------------------------------------------------------------------------------------------------------
32
37{
38public:
47 LayerFitResult(const double l, const double fitT, const double gradient, const double rms);
48
54 double GetL() const;
55
61 double GetFitT() const;
62
68 double GetGradient() const;
69
75 double GetRms() const;
76
77private:
78 double m_l;
79 double m_fitT;
80 double m_gradient;
81 double m_rms;
82};
83
84typedef std::map<int, LayerFitResult> LayerFitResultMap;
85
86//------------------------------------------------------------------------------------------------------------------------------------------
87
92{
93public:
98
105 void AddPoint(const float l, const float t);
106
112 double GetSumT() const;
113
119 double GetSumL() const;
120
126 double GetSumTT() const;
127
133 double GetSumLT() const;
134
140 double GetSumLL() const;
141
147 unsigned int GetNPoints() const;
148
149private:
150 double m_sumT;
151 double m_sumL;
152 double m_sumTT;
153 double m_sumLT;
154 double m_sumLL;
155 unsigned int m_nPoints;
156};
157
158typedef std::map<int, LayerFitContribution> LayerFitContributionMap;
159
160//------------------------------------------------------------------------------------------------------------------------------------------
161
166{
167public:
172
181 LayerInterpolation(const LayerFitResultMap::const_iterator &firstLayerIter, const LayerFitResultMap::const_iterator &secondLayerIter,
182 const double firstWeight, const double secondWeight);
183
189 bool IsInitialized() const;
190
196 LayerFitResultMap::const_iterator GetStartLayerIter() const;
197
203 LayerFitResultMap::const_iterator GetEndLayerIter() const;
204
210 double GetStartLayerWeight() const;
211
217 double GetEndLayerWeight() const;
218
219private:
221 LayerFitResultMap::const_iterator m_startLayerIter;
222 LayerFitResultMap::const_iterator m_endLayerIter;
225};
226
227typedef std::vector<LayerInterpolation> LayerInterpolationList;
228
229//------------------------------------------------------------------------------------------------------------------------------------------
230
235{
236public:
245 FitSegment(const int startLayer, const int endLayer, const double startX, const double endX);
246
252 int GetStartLayer() const;
253
259 int GetEndLayer() const;
260
266 double GetMinX() const;
267
273 double GetMaxX() const;
274
280 bool IsIncreasingX() const;
281
282private:
285 double m_minX;
286 double m_maxX;
288};
289
290typedef std::vector<FitSegment> FitSegmentList;
291
292//------------------------------------------------------------------------------------------------------------------------------------------
293//------------------------------------------------------------------------------------------------------------------------------------------
294
295inline LayerFitResult::LayerFitResult(const double l, const double fitT, const double gradient, const double rms) :
296 m_l(l),
297 m_fitT(fitT),
298 m_gradient(gradient),
299 m_rms(rms)
300{
301}
302
303//------------------------------------------------------------------------------------------------------------------------------------------
304
305inline double LayerFitResult::GetL() const
306{
307 return m_l;
308}
309
310//------------------------------------------------------------------------------------------------------------------------------------------
311
312inline double LayerFitResult::GetFitT() const
313{
314 return m_fitT;
315}
316
317//------------------------------------------------------------------------------------------------------------------------------------------
318
319inline double LayerFitResult::GetGradient() const
320{
321 return m_gradient;
322}
323
324//------------------------------------------------------------------------------------------------------------------------------------------
325
326inline double LayerFitResult::GetRms() const
327{
328 return m_rms;
329}
330
331//------------------------------------------------------------------------------------------------------------------------------------------
332//------------------------------------------------------------------------------------------------------------------------------------------
333
334inline LayerFitContribution::LayerFitContribution() : m_sumT(0.), m_sumL(0.), m_sumTT(0.), m_sumLT(0.), m_sumLL(0.), m_nPoints(0)
335{
336}
337
338//------------------------------------------------------------------------------------------------------------------------------------------
339
340inline void LayerFitContribution::AddPoint(const float l, const float t)
341{
342 const double T = static_cast<double>(t);
343 const double L = static_cast<double>(l);
344
345 m_sumT += T;
346 m_sumL += L;
347 m_sumTT += T * T;
348 m_sumLT += L * T;
349 m_sumLL += L * L;
350 ++m_nPoints;
351}
352
353//------------------------------------------------------------------------------------------------------------------------------------------
354
355inline double LayerFitContribution::GetSumT() const
356{
357 return m_sumT;
358}
359
360//------------------------------------------------------------------------------------------------------------------------------------------
361
362inline double LayerFitContribution::GetSumL() const
363{
364 return m_sumL;
365}
366
367//------------------------------------------------------------------------------------------------------------------------------------------
368
370{
371 return m_sumLT;
372}
373
374//------------------------------------------------------------------------------------------------------------------------------------------
375
377{
378 return m_sumLL;
379}
380
381//------------------------------------------------------------------------------------------------------------------------------------------
382
384{
385 return m_sumTT;
386}
387
388//------------------------------------------------------------------------------------------------------------------------------------------
389
390inline unsigned int LayerFitContribution::GetNPoints() const
391{
392 return m_nPoints;
393}
394
395//------------------------------------------------------------------------------------------------------------------------------------------
396//------------------------------------------------------------------------------------------------------------------------------------------
397
398inline LayerInterpolation::LayerInterpolation() : m_isInitialized(false), m_startLayerWeight(0.f), m_endLayerWeight(0.f)
399{
400}
401
402//------------------------------------------------------------------------------------------------------------------------------------------
403
404inline LayerInterpolation::LayerInterpolation(const LayerFitResultMap::const_iterator &startLayerIter,
405 const LayerFitResultMap::const_iterator &endLayerIter, const double startLayerWeight, const double endLayerWeight) :
406 m_isInitialized(true),
407 m_startLayerIter(startLayerIter),
408 m_endLayerIter(endLayerIter),
409 m_startLayerWeight(startLayerWeight),
410 m_endLayerWeight(endLayerWeight)
411{
412}
413
414//------------------------------------------------------------------------------------------------------------------------------------------
415
417{
418 return m_isInitialized;
419}
420
421//------------------------------------------------------------------------------------------------------------------------------------------
422
423inline LayerFitResultMap::const_iterator LayerInterpolation::GetStartLayerIter() const
424{
425 if (!m_isInitialized)
426 throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_INITIALIZED);
427
428 return m_startLayerIter;
429}
430
431//------------------------------------------------------------------------------------------------------------------------------------------
432
433inline LayerFitResultMap::const_iterator LayerInterpolation::GetEndLayerIter() const
434{
435 if (!m_isInitialized)
436 throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_INITIALIZED);
437
438 return m_endLayerIter;
439}
440
441//------------------------------------------------------------------------------------------------------------------------------------------
442
444{
445 if (!m_isInitialized)
446 throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_INITIALIZED);
447
448 return m_startLayerWeight;
449}
450
451//------------------------------------------------------------------------------------------------------------------------------------------
452
454{
455 if (!m_isInitialized)
456 throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_INITIALIZED);
457
458 return m_endLayerWeight;
459}
460
461//------------------------------------------------------------------------------------------------------------------------------------------
462//------------------------------------------------------------------------------------------------------------------------------------------
463
464inline FitSegment::FitSegment(const int startLayer, const int endLayer, const double startX, const double endX) :
465 m_startLayer(startLayer),
466 m_endLayer(endLayer)
467{
468 m_minX = std::min(startX, endX);
469 m_maxX = std::max(startX, endX);
470 m_isIncreasingX = (endX > startX);
471}
472
473//------------------------------------------------------------------------------------------------------------------------------------------
474
476{
477 return m_startLayer;
478}
479
480//------------------------------------------------------------------------------------------------------------------------------------------
481
482inline int FitSegment::GetEndLayer() const
483{
484 return m_endLayer;
485}
486
487//------------------------------------------------------------------------------------------------------------------------------------------
488
489inline double FitSegment::GetMinX() const
490{
491 return m_minX;
492}
493
494//------------------------------------------------------------------------------------------------------------------------------------------
495
496inline double FitSegment::GetMaxX() const
497{
498 return m_maxX;
499}
500
501//------------------------------------------------------------------------------------------------------------------------------------------
502
503inline bool FitSegment::IsIncreasingX() const
504{
505 return m_isIncreasingX;
506}
507
508} // namespace lar_content
509
510#endif // #ifndef LAR_TWO_D_SLIDING_FIT_OBJECTS_H
Header file defining status codes and relevant preprocessor macros.
int GetEndLayer() const
Get end layer.
bool IsIncreasingX() const
Whether the x coordinate increases between the start and end layers.
double m_maxX
The maximum x value.
FitSegment(const int startLayer, const int endLayer, const double startX, const double endX)
Constructor.
double GetMaxX() const
Get the maximum x value.
double m_minX
The minimum x value.
bool m_isIncreasingX
Whether the x coordinate increases between the start and end layers.
int GetStartLayer() const
Get start layer.
double GetMinX() const
Get the minimum x value.
unsigned int GetNPoints() const
Get the number of points used.
unsigned int m_nPoints
The number of points used.
void AddPoint(const float l, const float t)
Add point to layer fit.
double GetSumLT() const
Get the sum l * t.
double GetSumLL() const
Get the sum l * l.
double GetSumTT() const
Get the sum t * t.
double GetFitT() const
Get the fitted t coordinate.
double m_rms
The rms of the fit residuals.
double GetGradient() const
Get the fitted gradient dt/dz.
LayerFitResult(const double l, const double fitT, const double gradient, const double rms)
Constructor.
double GetRms() const
Get the rms of the fit residuals.
double GetL() const
Get the l coordinate.
double m_gradient
The fitted gradient dt/dl.
double m_fitT
The fitted t coordinate.
double m_startLayerWeight
The start layer weight.
LayerFitResultMap::const_iterator GetEndLayerIter() const
Get the end layer iterator.
double GetStartLayerWeight() const
Get the start layer weight.
LayerFitResultMap::const_iterator GetStartLayerIter() const
Get the start layer iterator.
bool IsInitialized() const
Whether the object is initialized.
double GetEndLayerWeight() const
Get the end layer weight.
double m_endLayerWeight
The end layer weight.
LayerFitResultMap::const_iterator m_startLayerIter
The start layer iterator.
LayerFitResultMap::const_iterator m_endLayerIter
The end layer iterator.
bool m_isInitialized
Whether the object is initialized.
StatusCodeException class.
std::vector< FitSegment > FitSegmentList
TransverseDirection
TransverseDirection enum.
std::map< int, LayerFitResult > LayerFitResultMap
std::vector< LayerInterpolation > LayerInterpolationList
std::map< int, LayerFitContribution > LayerFitContributionMap