LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
SpacePointDumpers.h
Go to the documentation of this file.
1 
9 #ifndef LARDATA_RECOBASE_DUMPERS_SPACEPOINTDUMPERS_H
10 #define LARDATA_RECOBASE_DUMPERS_SPACEPOINTDUMPERS_H 1
11 
12 // LArSoft libraries
14 
15 // C/C++ standard libraries
16 #include <type_traits> // std::decay<>
17 #include <utility> // std::forward<>()
18 
19 // --- for the implementation ---
20 // LArSoft libraries
23 
24 namespace recob {
25  namespace dumper {
26 
30  bool hexFloats = false;
31 
42  SpacePointPrintOptions_t() = default;
43 
44  SpacePointPrintOptions_t(IndentOptions_t indentOptions, bool bHexFloats)
45  : indent(indentOptions), hexFloats(bHexFloats)
46  {}
47 
48  }; // SpacePointPrintOptions_t
49 
58  template <typename Stream, typename NewLineRef = recob::dumper::NewLine<Stream>>
59  auto DumpSpacePoint(Stream&& out,
60  recob::SpacePoint const& sp,
61  SpacePointPrintOptions_t const& options = {})
62  -> std::enable_if_t<
63  std::is_same<NewLine<std::decay_t<Stream>>, std::decay_t<NewLineRef>>::value>;
64 
65  } // namespace dumper
66 } // namespace recob
67 
68 //==============================================================================
69 //=== template implementation
70 //===
71 //------------------------------------------------------------------------------
72 //--- recob::dumper::DumpSpacePoint
73 //---
74 template <typename Stream, typename NewLineRef>
76  recob::SpacePoint const& sp,
77  SpacePointPrintOptions_t const& options /* = {} */
78  )
79  -> std::enable_if_t<std::is_same<NewLine<std::decay_t<Stream>>, std::decay_t<NewLineRef>>::value>
80 {
81  double const* pos = sp.XYZ();
82  double const* err = sp.ErrXYZ();
83 
84  NewLineRef nl(out, options.indent);
85  lar::OptionalHexFloat hexfloat(options.hexFloats);
86 
87  nl() << "ID=" << sp.ID() << " at (" << hexfloat(pos[0]) << ", " << hexfloat(pos[1]) << ", "
88  << hexfloat(pos[2]) << ") cm, chi^2/NDF=" << hexfloat(sp.Chisq());
89 
90  nl() << "variances { x^2=" << hexfloat(err[0]) << " y^2=" << hexfloat(err[2])
91  << " z^2=" << hexfloat(err[5]) << " xy=" << hexfloat(err[1]) << " xz=" << hexfloat(err[3])
92  << " yz=" << hexfloat(err[4]) << " }";
93 
94 } // recob::dumper::DumpSpacePoint()
95 
96 //------------------------------------------------------------------------------
97 
98 #endif // LARDATA_RECOBASE_DUMPERS_SPACEPOINTDUMPERS_H
Starts a new line in a output stream.
Definition: NewLine.h:76
Reconstruction base classes.
IndentOptions_t indent
indentation string
Simple class managing a repetitive output task.
Structure collecting indentation options.
Definition: NewLine.h:19
Helper for formatting floats in base 16.
Definition: hexfloat.h:109
double value
Definition: spectrum.C:18
SpacePointPrintOptions_t()=default
Default constructor.
Helper to support output of real numbers in base 16.
bool hexFloats
print all floating point numbers in base 16
SpacePointPrintOptions_t(IndentOptions_t indentOptions, bool bHexFloats)
std::string nl(std::size_t i=1)
auto DumpSpacePoint(Stream &&out, recob::SpacePoint const &sp, SpacePointPrintOptions_t const &options={}) -> std::enable_if_t< std::is_same< NewLine< std::decay_t< Stream >>, std::decay_t< NewLineRef >>::value >
Dumps the content of the specified space point into a stream.
Collection of available printing style options.