LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
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 
17 namespace lar_content
18 {
19 
24 {
29 };
30 
31 //------------------------------------------------------------------------------------------------------------------------------------------
32 
37 {
38 public:
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 
77 private:
78  double m_l;
79  double m_fitT;
80  double m_gradient;
81  double m_rms;
82 };
83 
84 typedef std::map<int, LayerFitResult> LayerFitResultMap;
85 
86 //------------------------------------------------------------------------------------------------------------------------------------------
87 
92 {
93 public:
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 
149 private:
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 
158 typedef std::map<int, LayerFitContribution> LayerFitContributionMap;
159 
160 //------------------------------------------------------------------------------------------------------------------------------------------
161 
166 {
167 public:
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 
219 private:
225 };
226 
227 typedef std::vector<LayerInterpolation> LayerInterpolationList;
228 
229 //------------------------------------------------------------------------------------------------------------------------------------------
230 
235 {
236  public:
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 
282 private:
285  double m_minX;
286  double m_maxX;
288 };
289 
290 typedef std::vector<FitSegment> FitSegmentList;
291 
292 //------------------------------------------------------------------------------------------------------------------------------------------
293 //------------------------------------------------------------------------------------------------------------------------------------------
294 
295 inline 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 
305 inline double LayerFitResult::GetL() const
306 {
307  return m_l;
308 }
309 
310 //------------------------------------------------------------------------------------------------------------------------------------------
311 
312 inline double LayerFitResult::GetFitT() const
313 {
314  return m_fitT;
315 }
316 
317 //------------------------------------------------------------------------------------------------------------------------------------------
318 
319 inline double LayerFitResult::GetGradient() const
320 {
321  return m_gradient;
322 }
323 
324 //------------------------------------------------------------------------------------------------------------------------------------------
325 
326 inline double LayerFitResult::GetRms() const
327 {
328  return m_rms;
329 }
330 
331 //------------------------------------------------------------------------------------------------------------------------------------------
332 //------------------------------------------------------------------------------------------------------------------------------------------
333 
335  m_sumT(0.),
336  m_sumL(0.),
337  m_sumTT(0.),
338  m_sumLT(0.),
339  m_sumLL(0.),
340  m_nPoints(0)
341 {
342 }
343 
344 //------------------------------------------------------------------------------------------------------------------------------------------
345 
346 inline void LayerFitContribution::AddPoint(const float l, const float t)
347 {
348  const double T = static_cast<double>(t);
349  const double L = static_cast<double>(l);
350 
351  m_sumT += T;
352  m_sumL += L;
353  m_sumTT += T * T;
354  m_sumLT += L * T;
355  m_sumLL += L * L;
356  ++m_nPoints;
357 }
358 
359 //------------------------------------------------------------------------------------------------------------------------------------------
360 
361 inline double LayerFitContribution::GetSumT() const
362 {
363  return m_sumT;
364 }
365 
366 //------------------------------------------------------------------------------------------------------------------------------------------
367 
368 inline double LayerFitContribution::GetSumL() const
369 {
370  return m_sumL;
371 }
372 
373 //------------------------------------------------------------------------------------------------------------------------------------------
374 
375 inline double LayerFitContribution::GetSumLT() const
376 {
377  return m_sumLT;
378 }
379 
380 //------------------------------------------------------------------------------------------------------------------------------------------
381 
382 inline double LayerFitContribution::GetSumLL() const
383 {
384  return m_sumLL;
385 }
386 
387 //------------------------------------------------------------------------------------------------------------------------------------------
388 
389 inline double LayerFitContribution::GetSumTT() const
390 {
391  return m_sumTT;
392 }
393 
394 //------------------------------------------------------------------------------------------------------------------------------------------
395 
396 inline unsigned int LayerFitContribution::GetNPoints() const
397 {
398  return m_nPoints;
399 }
400 
401 //------------------------------------------------------------------------------------------------------------------------------------------
402 //------------------------------------------------------------------------------------------------------------------------------------------
403 
405  m_isInitialized(false),
406  m_startLayerWeight(0.f),
407  m_endLayerWeight(0.f)
408 {
409 }
410 
411 //------------------------------------------------------------------------------------------------------------------------------------------
412 
414  const LayerFitResultMap::const_iterator &endLayerIter, const double startLayerWeight, const double endLayerWeight) :
415  m_isInitialized(true),
416  m_startLayerIter(startLayerIter),
417  m_endLayerIter(endLayerIter),
418  m_startLayerWeight(startLayerWeight),
419  m_endLayerWeight(endLayerWeight)
420 {
421 }
422 
423 //------------------------------------------------------------------------------------------------------------------------------------------
424 
426 {
427  return m_isInitialized;
428 }
429 
430 //------------------------------------------------------------------------------------------------------------------------------------------
431 
433 {
434  if (!m_isInitialized)
435  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_INITIALIZED);
436 
437  return m_startLayerIter;
438 }
439 
440 //------------------------------------------------------------------------------------------------------------------------------------------
441 
443 {
444  if (!m_isInitialized)
445  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_INITIALIZED);
446 
447  return m_endLayerIter;
448 }
449 
450 //------------------------------------------------------------------------------------------------------------------------------------------
451 
453 {
454  if (!m_isInitialized)
455  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_INITIALIZED);
456 
457  return m_startLayerWeight;
458 }
459 
460 //------------------------------------------------------------------------------------------------------------------------------------------
461 
463 {
464  if (!m_isInitialized)
465  throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_INITIALIZED);
466 
467  return m_endLayerWeight;
468 }
469 
470 //------------------------------------------------------------------------------------------------------------------------------------------
471 //------------------------------------------------------------------------------------------------------------------------------------------
472 
473 inline FitSegment::FitSegment(const int startLayer, const int endLayer, const double startX, const double endX) :
474  m_startLayer(startLayer),
475  m_endLayer(endLayer)
476 {
477  m_minX = std::min(startX, endX);
478  m_maxX = std::max(startX, endX);
479  m_isIncreasingX = (endX > startX);
480 }
481 
482 //------------------------------------------------------------------------------------------------------------------------------------------
483 
484 inline int FitSegment::GetStartLayer() const
485 {
486  return m_startLayer;
487 }
488 
489 //------------------------------------------------------------------------------------------------------------------------------------------
490 
491 inline int FitSegment::GetEndLayer() const
492 {
493  return m_endLayer;
494 }
495 
496 //------------------------------------------------------------------------------------------------------------------------------------------
497 
498 inline double FitSegment::GetMinX() const
499 {
500  return m_minX;
501 }
502 
503 //------------------------------------------------------------------------------------------------------------------------------------------
504 
505 inline double FitSegment::GetMaxX() const
506 {
507  return m_maxX;
508 }
509 
510 //------------------------------------------------------------------------------------------------------------------------------------------
511 
512 inline bool FitSegment::IsIncreasingX() const
513 {
514  return m_isIncreasingX;
515 }
516 
517 } // namespace lar_content
518 
519 #endif // #ifndef LAR_TWO_D_SLIDING_FIT_OBJECTS_H
double GetSumLL() const
Get the sum l * l.
bool IsIncreasingX() const
Whether the x coordinate increases between the start and end layers.
LayerFitResultMap::const_iterator m_startLayerIter
The start layer iterator.
int GetStartLayer() const
Get start layer.
int m_startLayer
The start layer.
double GetEndLayerWeight() const
Get the end layer weight.
void AddPoint(const float l, const float t)
Add point to layer fit.
TransverseDirection
TransverseDirection enum.
double GetSumLT() const
Get the sum l * t.
std::vector< FitSegment > FitSegmentList
bool m_isIncreasingX
Whether the x coordinate increases between the start and end layers.
double m_maxX
The maximum x value.
double GetSumTT() const
Get the sum t * t.
std::map< int, LayerFitContribution > LayerFitContributionMap
TFile f
Definition: plotHisto.C:6
unsigned int GetNPoints() const
Get the number of points used.
Int_t max
Definition: plot.C:27
double GetFitT() const
Get the fitted t coordinate.
LayerFitResultMap::const_iterator GetEndLayerIter() const
Get the end layer iterator.
intermediate_table::const_iterator const_iterator
bool m_isInitialized
Whether the object is initialized.
double GetStartLayerWeight() const
Get the start layer weight.
LayerFitResult(const double l, const double fitT, const double gradient, const double rms)
Constructor.
double m_startLayerWeight
The start layer weight.
std::map< int, LayerFitResult > LayerFitResultMap
double GetGradient() const
Get the fitted gradient dt/dz.
std::vector< LayerInterpolation > LayerInterpolationList
double m_rms
The rms of the fit residuals.
double m_gradient
The fitted gradient dt/dl.
double GetSumL() const
Get the sum l.
double m_fitT
The fitted t coordinate.
double GetRms() const
Get the rms of the fit residuals.
LayerFitResultMap::const_iterator m_endLayerIter
The end layer iterator.
Int_t min
Definition: plot.C:26
double m_endLayerWeight
The end layer weight.
double GetMinX() const
Get the minimum x value.
unsigned int m_nPoints
The number of points used.
LayerFitResultMap::const_iterator GetStartLayerIter() const
Get the start layer iterator.
double GetL() const
Get the l coordinate.
double m_minX
The minimum x value.
int GetEndLayer() const
Get end layer.
double GetSumT() const
Get the sum t.
double GetMaxX() const
Get the maximum x value.
bool IsInitialized() const
Whether the object is initialized.
FitSegment(const int startLayer, const int endLayer, const double startX, const double endX)
Constructor.