LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 
13 // LArSoft libraries
15 
16 // C/C++ standard libraries
17 #include <string>
18 #include <utility> // std::forward<>()
19 #include <type_traits> // std::decay<>
20 
21 
22 // --- for the implementation ---
23 // LArSoft libraries
26 
27 
28 namespace recob {
29  namespace dumper {
30 
34  bool hexFloats = false;
35 
46  SpacePointPrintOptions_t() = default;
47 
49  (IndentOptions_t indentOptions, bool bHexFloats)
50  : indent(indentOptions), hexFloats(bHexFloats)
51  {}
52 
53  }; // SpacePointPrintOptions_t
54 
55 
64  template
65  <typename Stream, typename NewLineRef = recob::dumper::NewLine<Stream>>
66  auto DumpSpacePoint(
67  Stream&& out,
68  recob::SpacePoint const& sp,
69  SpacePointPrintOptions_t const& options = {}
70  ) -> std::enable_if_t
71  <std::is_same<NewLine<std::decay_t<Stream>>, std::decay_t<NewLineRef>>::value>;
72 
73  } // namespace dumper
74 } // namespace recob
75 
76 
77 //==============================================================================
78 //=== template implementation
79 //===
80 //------------------------------------------------------------------------------
81 //--- recob::dumper::DumpSpacePoint
82 //---
83 template <typename Stream, typename NewLineRef>
85  Stream&& out,
86  recob::SpacePoint const& sp,
87  SpacePointPrintOptions_t const& options /* = {} */
88 ) -> std::enable_if_t<
89  std::is_same<
91  std::decay_t<NewLineRef>
92  >::value>
93 {
94  double const* pos = sp.XYZ();
95  double const* err = sp.ErrXYZ();
96 
97  NewLineRef nl(out, options.indent);
98  lar::OptionalHexFloat hexfloat(options.hexFloats);
99 
100  nl()
101  << "ID=" << sp.ID() << " at (" << hexfloat(pos[0])
102  << ", " << hexfloat(pos[1]) << ", " << hexfloat(pos[2])
103  << ") cm, chi^2/NDF=" << hexfloat(sp.Chisq());
104 
105  nl()
106  << "variances { x^2=" << hexfloat(err[0]) << " y^2=" << hexfloat(err[2])
107  << " z^2=" << hexfloat(err[5])
108  << " xy=" << hexfloat(err[1]) << " xz=" << hexfloat(err[3])
109  << " yz=" << hexfloat(err[4]) << " }";
110 
111 } // recob::dumper::DumpSpacePoint()
112 
113 //------------------------------------------------------------------------------
114 
115 #endif // LARDATA_RECOBASE_DUMPERS_SPACEPOINTDUMPERS_H
116 
Starts a new line in a output stream.
Definition: NewLine.h:74
Reconstruction base classes.
IndentOptions_t indent
indentation string
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.
Simple class managing a repetitive output task.
Structure collecting indentation options.
Definition: NewLine.h:20
Helper for formatting floats in base 16.
Definition: hexfloat.h:105
std::string value(boost::any const &)
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
std::string nl(std::size_t i=1)
Collection of available printing style options.