LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
SpacePoint.cxx
Go to the documentation of this file.
1 //
3 // Implementation of SpacePoint class for LArSoft
4 //
5 // msoderbe@syr.edu
6 //
8 
10 
11 #include <algorithm> // std::swap()
12 #include <iomanip>
13 
14 namespace recob {
15 
16  //----------------------------------------------------------------------
17  SpacePoint::SpacePoint() : fID(-1), fXYZ{0.0}, fErrXYZ{0.0}, fChisq(0.) {}
18 
19  //----------------------------------------------------------------------
20  SpacePoint::SpacePoint(Double32_t const* xyz, Double32_t const* err, Double32_t chisq, int id)
21  : fID(id), fChisq(chisq)
22  {
23  for (int i = 0; i < 3; ++i)
24  fXYZ[i] = xyz[i];
25  for (int i = 0; i < 6; ++i)
26  fErrXYZ[i] = err[i];
27  }
28 
29  //----------------------------------------------------------------------
30  double SpacePoint::covariance(unsigned int i, unsigned int j) const
31  {
32 
33  return fErrXYZ[covIndex(i, j)];
34 
35  } // SpacePoint::covariance()
36 
37  //----------------------------------------------------------------------
38  constexpr std::size_t SpacePoint::covIndex(unsigned int i, unsigned int j)
39  {
40 
41  constexpr std::size_t offsets[3U] = {0U, 1U, 3U};
42 
43  if (i < j) std::swap(i, j);
44  return offsets[i] + j;
45 
46  } // SpacePoint::covIndex()
47 
48  //----------------------------------------------------------------------
49  // ostream operator.
50  //
51  std::ostream& operator<<(std::ostream& o, const SpacePoint& a)
52  {
53  o << std::setiosflags(std::ios::fixed) << std::setprecision(2);
54  o << " SpacePoint ID " << std::setw(5) << std::right << a.ID() << " (X,Y,Z) = (" << std::setw(5)
55  << std::right << a.XYZ()[0] << " , " << std::setw(5) << std::right << a.XYZ()[1] << " , "
56  << std::setw(5) << std::right << a.XYZ()[2] << ")";
57 
58  return o;
59  }
60 
61  //----------------------------------------------------------------------
62  // < operator.
63  //
64  bool operator<(const SpacePoint& a, const SpacePoint& b)
65  {
66  if (a.ID() != b.ID()) return a.ID() < b.ID();
67 
68  return false; //They are equal
69  }
70 
71 }
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:102
Reconstruction base classes.
Double32_t fXYZ[3]
position of SpacePoint in xyz
Definition: SpacePoint.h:35
static constexpr std::size_t covIndex(unsigned int i, unsigned int j)
Returns the internal index of correlation structure for coordinates i and j.
Definition: SpacePoint.cxx:38
friend bool operator<(const SpacePoint &a, const SpacePoint &b)
Definition: SpacePoint.cxx:64
const Double32_t * XYZ() const
Definition: SpacePoint.h:78
double covariance(unsigned int i, unsigned int j) const
Definition: SpacePoint.cxx:30
Double32_t fErrXYZ[6]
Error matrix (lower triangular).
Definition: SpacePoint.h:36
ID_t ID() const
Definition: SpacePoint.h:74
friend std::ostream & operator<<(std::ostream &o, const SpacePoint &a)
Definition: SpacePoint.cxx:51