PCAxis.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////
2 //
3 // \file PCAxis.cxx
4 // \brief Definition of Principal Components Axis object for LArSoft
5 //
6 // \author usher@slac.stanford.edu
7 //
8 // \see PCAxis.h
9 //
10 ////////////////////////////////////////////////////////////////////////////
11 
13 
14 #include <iomanip>
15 #include <ostream>
16 
17 namespace recob
18 {
19 
20 //----------------------------------------------------------------------
22 {
23 }
24 
25 //----------------------------------------------------------------------
27  int nHits,
28  const double* eigenValues,
29  const recob::PCAxis::EigenVectors& eigenVecs,
30  const double* avePos,
31  const double aveHitDoca,
32  size_t id) :
33  fSvdOK(ok),
34  fNumHitsUsed(nHits),
35  fEigenVectors(eigenVecs),
36  fAveHitDoca(aveHitDoca),
37  fID(id)
38 {
39  fEigenValues[0] = eigenValues[0];
40  fEigenValues[1] = eigenValues[1];
41  fEigenValues[2] = eigenValues[2];
42  fAvePosition[0] = avePos[0];
43  fAvePosition[1] = avePos[1];
44  fAvePosition[2] = avePos[2];
45 }
46 
47 //----------------------------------------------------------------------
48 // ostream operator.
49 //
50 std::ostream& operator<< (std::ostream & o, const PCAxis & a)
51 {
52  if (a.fSvdOK)
53  {
54  o << std::setiosflags(std::ios::fixed) << std::setprecision(2);
55  o << " PCAxis ID " << a.fID << " run with " << a.fNumHitsUsed << " space points" << std::endl;
56  o << " - center position: " << std::setw(6) << a.fAvePosition[0] << ", " << a.fAvePosition[1] << ", " << a.fAvePosition[2] << std::endl;
57  o << " - eigen values: " << std::setw(8) << std::right << a.fEigenValues[0] << ", "
58  << a.fEigenValues[1] << ", " << a.fEigenValues[2] << std::endl;
59  o << " - average doca: " << a.fAveHitDoca << std::endl;
60  o << " - Principle axis: " << std::setw(7) << std::setprecision(4) << a.fEigenVectors[0][0] << ", " << a.fEigenVectors[0][1] << ", " << a.fEigenVectors[0][2] << std::endl;
61  o << " - second axis: " << std::setw(7) << std::setprecision(4) << a.fEigenVectors[1][0] << ", " << a.fEigenVectors[1][1] << ", " << a.fEigenVectors[1][2] << std::endl;
62  o << " - third axis: " << std::setw(7) << std::setprecision(4) << a.fEigenVectors[2][0] << ", " << a.fEigenVectors[2][1] << ", " << a.fEigenVectors[2][2] << std::endl;
63  }
64  else
65  o << " Principal Components Axis is not valid" << std::endl;
66 
67  return o;
68 }
69 
70 //----------------------------------------------------------------------------
71 // comparison operator
72 //
73 bool operator < (const PCAxis& a, const PCAxis& b)
74 {
75  if(a.getID() != b. getID())
76  return a.getID() < b.getID();
77 
78  return false; //They are equal
79 }
80 
81 } // End of namespace
bool fSvdOK
SVD Decomposition was successful.
Definition: PCAxis.h:35
Reconstruction base classes.
friend bool operator<(const PCAxis &a, const PCAxis &b)
Definition: PCAxis.cxx:73
double fEigenValues[3]
Eigen values from SVD decomposition.
Definition: PCAxis.h:37
Q_EXPORT QTSManip setprecision(int p)
Definition: qtextstream.h:343
size_t getID() const
Definition: PCAxis.h:69
friend std::ostream & operator<<(std::ostream &o, const PCAxis &a)
Definition: PCAxis.cxx:50
const double a
size_t fID
axis ID
Definition: PCAxis.h:41
EigenVectors fEigenVectors
The three principle axes.
Definition: PCAxis.h:38
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
int fNumHitsUsed
Number of hits in the decomposition.
Definition: PCAxis.h:36
static bool * b
Definition: config.cpp:1043
double fAveHitDoca
Average doca of hits used in PCA.
Definition: PCAxis.h:40
double fAvePosition[3]
Average position of hits fed to PCA.
Definition: PCAxis.h:39
std::vector< std::vector< double > > EigenVectors
Definition: PCAxis.h:29
QTextStream & endl(QTextStream &s)