LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
PCAxisDumpers.h
Go to the documentation of this file.
1 
9 #ifndef LARDATA_RECOBASE_DUMPERS_PCAXISDUMPERS_H
10 #define LARDATA_RECOBASE_DUMPERS_PCAXISDUMPERS_H 1
11 
12 // LArSoft libraries
14 
15 // C/C++ standard libraries
16 #include <string>
17 #include <iomanip>
18 #include <type_traits> // std::decay<>
19 
20 
21 // --- for the implementation ---
22 // LArSoft libraries
24 
25 
26 namespace recob {
27  namespace dumper {
28 
32  template <typename Stream, typename NewLineRef>
33  std::enable_if_t
34  <std::is_same<recob::dumper::NewLine<std::decay_t<Stream>>, std::decay_t<NewLineRef>>::value>
36  (Stream&& out, recob::PCAxis const& pca, NewLineRef&& nl);
37 
50  template <typename Stream>
51  void DumpPCAxis(Stream&& out, recob::PCAxis const& pca,
52  std::string indent = "",
53  bool indentFirst = true
54  )
55  {
56  DumpPCAxis(
57  std::forward<Stream>(out), pca, makeNewLine(out, indent, !indentFirst)
58  );
59  }
60 
61 
62  } // namespace dumper
63 } // namespace lar
64 
65 
66 //==============================================================================
67 //=== template implementation
68 //===
69 //------------------------------------------------------------------------------
70 //--- recob::dumper::DumpPCAxis
71 //---
72 template <typename Stream, typename NewLineRef>
73 std::enable_if_t
74  <std::is_same<recob::dumper::NewLine<std::decay_t<Stream>>, std::decay_t<NewLineRef>>::value>
76  (Stream&& out, recob::PCAxis const& pca, NewLineRef&& nl)
77 {
78 
79  if (!pca.getSvdOK()) {
80  nl() << "<not valid>";
81  return;
82  }
83 
84  nl() << std::setiosflags(std::ios::fixed) << std::setprecision(2)
85  << " ID " << pca.getID()
86  << " run on " << pca.getNumHitsUsed() << " space points";
87  nl()
88  << " - center position: " << std::setw(6) << pca.getAvePosition()[0]
89  << ", " << pca.getAvePosition()[1]
90  << ", " << pca.getAvePosition()[2];
91  nl()
92  << " - eigen values: " << std::setw(8) << std::right
93  << pca.getEigenValues()[0] << ", "
94  << pca.getEigenValues()[1] << ", " << pca.getEigenValues()[2];
95  nl()
96  << " - average doca: " << pca.getAveHitDoca();
97  nl()
98  << " - principle axis: "
99  << std::setw(7) << std::setprecision(4) << pca.getEigenVectors()[0][0]
100  << ", " << pca.getEigenVectors()[0][1]
101  << ", " << pca.getEigenVectors()[0][2];
102  nl()
103  << " - second axis: "
104  << std::setw(7) << std::setprecision(4) << pca.getEigenVectors()[1][0]
105  << ", " << pca.getEigenVectors()[1][1]
106  << ", " << pca.getEigenVectors()[1][2];
107  nl()
108  << " - third axis: "
109  << std::setw(7) << std::setprecision(4) << pca.getEigenVectors()[2][0]
110  << ", " << pca.getEigenVectors()[2][1]
111  << ", " << pca.getEigenVectors()[2][2];
112 
113 } // recob::dumper::DumpPCAxis()
114 
115 //------------------------------------------------------------------------------
116 
117 #endif // LARDATA_RECOBASE_DUMPERS_PCAXISDUMPERS_H
118 
double getAveHitDoca() const
Definition: PCAxis.h:68
const EigenVectors & getEigenVectors() const
Definition: PCAxis.h:66
const double * getEigenValues() const
Definition: PCAxis.h:65
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:112
Reconstruction base classes.
std::enable_if_t< std::is_same< recob::dumper::NewLine< std::decay_t< Stream > >, std::decay_t< NewLineRef > >::value > DumpPCAxis(Stream &&out, recob::PCAxis const &pca, NewLineRef &&nl)
Definition: PCAxisDumpers.h:76
int getNumHitsUsed() const
Definition: PCAxis.h:64
size_t getID() const
Definition: PCAxis.h:69
Simple class managing a repetitive output task.
std::string indent(std::size_t const i)
const double * getAvePosition() const
Definition: PCAxis.h:67
std::string value(boost::any const &)
NewLine< Stream > makeNewLine(Stream &stream, std::string indent, bool followLine=false)
Convenience function to create a temporary NewLine.
Definition: NewLine.h:146
std::string nl(std::size_t i=1)
bool getSvdOK() const
Definition: PCAxis.h:63