All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
bool operator<(Cluster const &a, Cluster const &b)
Definition: Cluster.cxx:196
EResult err(const char *call)
walls no right
Definition: selectors.fcl:105
Double32_t fXYZ[3]
position of SpacePoint in xyz
Definition: SpacePoint.h:36
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
process_name gaushit a
const Double32_t * XYZ() const
Definition: SpacePoint.h:76
double covariance(unsigned int i, unsigned int j) const
Definition: SpacePoint.cxx:38
Double32_t fErrXYZ[6]
Error matrix (lower triangular).
Definition: SpacePoint.h:37
ID_t ID() const
Definition: SpacePoint.h:75
std::ostream & operator<<(std::ostream &o, Cluster const &c)
Definition: Cluster.cxx:173