LArSoft  v09_90_00
Liquid Argon Software toolkit - https://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 <iomanip>
17 #include <string>
18 #include <type_traits> // std::decay<>
19 
20 // --- for the implementation ---
21 // LArSoft libraries
23 
24 namespace recob {
25  namespace dumper {
26 
30  template <typename Stream, typename NewLineRef>
31  std::enable_if_t<
32  std::is_same<recob::dumper::NewLine<std::decay_t<Stream>>, std::decay_t<NewLineRef>>::value>
33  DumpPCAxis(Stream&& out, recob::PCAxis const& pca, NewLineRef&& nl);
34 
47  template <typename Stream>
48  void DumpPCAxis(Stream&& out,
49  recob::PCAxis const& pca,
50  std::string indent = "",
51  bool indentFirst = true)
52  {
53  DumpPCAxis(std::forward<Stream>(out), pca, makeNewLine(out, indent, !indentFirst));
54  }
55 
56  } // namespace dumper
57 } // namespace lar
58 
59 //==============================================================================
60 //=== template implementation
61 //===
62 //------------------------------------------------------------------------------
63 //--- recob::dumper::DumpPCAxis
64 //---
65 template <typename Stream, typename NewLineRef>
66 std::enable_if_t<
67  std::is_same<recob::dumper::NewLine<std::decay_t<Stream>>, std::decay_t<NewLineRef>>::value>
68 recob::dumper::DumpPCAxis(Stream&& out, recob::PCAxis const& pca, NewLineRef&& nl)
69 {
70 
71  if (!pca.getSvdOK()) {
72  nl() << "<not valid>";
73  return;
74  }
75 
76  nl() << std::setiosflags(std::ios::fixed) << std::setprecision(2) << " ID " << pca.getID()
77  << " run on " << pca.getNumHitsUsed() << " space points";
78  nl() << " - center position: " << std::setw(6) << pca.getAvePosition()[0] << ", "
79  << pca.getAvePosition()[1] << ", " << pca.getAvePosition()[2];
80  nl() << " - eigen values: " << std::setw(8) << std::right << pca.getEigenValues()[0] << ", "
81  << pca.getEigenValues()[1] << ", " << pca.getEigenValues()[2];
82  nl() << " - average doca: " << pca.getAveHitDoca();
83  nl() << " - principle axis: " << std::setw(7) << std::setprecision(4)
84  << pca.getEigenVectors()[0][0] << ", " << pca.getEigenVectors()[0][1] << ", "
85  << pca.getEigenVectors()[0][2];
86  nl() << " - second axis: " << std::setw(7) << std::setprecision(4) << pca.getEigenVectors()[1][0]
87  << ", " << pca.getEigenVectors()[1][1] << ", " << pca.getEigenVectors()[1][2];
88  nl() << " - third axis: " << std::setw(7) << std::setprecision(4) << pca.getEigenVectors()[2][0]
89  << ", " << pca.getEigenVectors()[2][1] << ", " << pca.getEigenVectors()[2][2];
90 
91 } // recob::dumper::DumpPCAxis()
92 
93 //------------------------------------------------------------------------------
94 
95 #endif // LARDATA_RECOBASE_DUMPERS_PCAXISDUMPERS_H
double getAveHitDoca() const
Definition: PCAxis.h:82
const EigenVectors & getEigenVectors() const
Definition: PCAxis.h:74
const double * getEigenValues() const
Definition: PCAxis.h:70
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.
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:68
int getNumHitsUsed() const
Definition: PCAxis.h:66
size_t getID() const
Definition: PCAxis.h:86
Simple class managing a repetitive output task.
std::string indent(std::size_t const i)
double value
Definition: spectrum.C:18
const double * getAvePosition() const
Definition: PCAxis.h:78
NewLine< Stream > makeNewLine(Stream &stream, std::string indent, bool followLine=false)
Convenience function to create a temporary NewLine.
Definition: NewLine.h:148
std::string nl(std::size_t i=1)
bool getSvdOK() const
Definition: PCAxis.h:62