SpacePoint.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////
2 //
3 // Implementation of SpacePoint class for LArSoft
4 //
5 // msoderbe@syr.edu
6 //
7 ////////////////////////////////////////////////////////////////////////////
8 
10 
11 #include <iomanip>
12 #include <algorithm> // std::swap()
13 
14 namespace recob{
15 
16  //----------------------------------------------------------------------
18  fID(-1),
19  fXYZ { 0.0 },
20  fErrXYZ { 0.0 },
21  fChisq(0.)
22  {
23  }
24 
25  //----------------------------------------------------------------------
26  SpacePoint::SpacePoint(Double32_t const*xyz,
27  Double32_t const*err,
28  Double32_t chisq,
29  int id)
30  : fID(id)
31  , fChisq(chisq)
32  {
33  for(int i = 0; i < 3; ++i) fXYZ[i] = xyz[i];
34  for(int i = 0; i < 6; ++i) fErrXYZ[i] = err[i];
35  }
36 
37  //----------------------------------------------------------------------
38  double SpacePoint::covariance(unsigned int i, unsigned int j) const {
39 
40  return fErrXYZ[covIndex(i, j)];
41 
42  } // SpacePoint::covariance()
43 
44 
45  //----------------------------------------------------------------------
46  constexpr std::size_t SpacePoint::covIndex(unsigned int i, unsigned int j) {
47 
48  constexpr std::size_t offsets[3U] = { 0U, 1U, 3U };
49 
50  if (i < j) std::swap(i, j);
51  return offsets[i] + j;
52 
53  } // SpacePoint::covIndex()
54 
55  //----------------------------------------------------------------------
56  // ostream operator.
57  //
58  std::ostream& operator<< (std::ostream& o, const SpacePoint & a)
59  {
60  o << std::setiosflags(std::ios::fixed) << std::setprecision(2);
61  o << " SpacePoint ID " << std::setw(5) << std::right << a.ID()
62  << " (X,Y,Z) = (" << std::setw(5) << std::right << a.XYZ()[0]
63  << " , " << std::setw(5) << std::right << a.XYZ()[1]
64  << " , " << std::setw(5) << std::right << a.XYZ()[2]
65  << ")" ;
66 
67  return o;
68  }
69 
70 
71  //----------------------------------------------------------------------
72  // < operator.
73  //
74  bool operator < (const SpacePoint & a, const SpacePoint & b)
75  {
76  if(a.ID() != b. ID())
77  return a.ID()<b.ID();
78 
79  return false; //They are equal
80 
81  }
82 
83 }
84 
double covariance(unsigned int i, unsigned int j) const
Definition: SpacePoint.cxx:38
Reconstruction base classes.
ID_t fID
Default constructor.
Definition: SpacePoint.h:35
Q_EXPORT QTSManip setprecision(int p)
Definition: qtextstream.h:343
Double32_t fXYZ[3]
position of SpacePoint in xyz
Definition: SpacePoint.h:36
void swap(Handle< T > &a, Handle< T > &b)
const double a
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:46
Double32_t fChisq
Chisquare.
Definition: SpacePoint.h:38
friend bool operator<(const SpacePoint &a, const SpacePoint &b)
Definition: SpacePoint.cxx:74
void err(const char *fmt,...)
Definition: message.cpp:226
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
Double32_t fErrXYZ[6]
Error matrix (lower triangular).
Definition: SpacePoint.h:37
const Double32_t * XYZ() const
Definition: SpacePoint.h:76
static bool * b
Definition: config.cpp:1043
ID_t ID() const
Definition: SpacePoint.h:75
friend std::ostream & operator<<(std::ostream &o, const SpacePoint &a)
Definition: SpacePoint.cxx:58