8#include <framework/utilities/HTML.h>
10#include <boost/algorithm/string/replace.hpp>
13#include <TMatrixFBase.h>
16#include <framework/gearbox/Unit.h>
22using namespace boost::algorithm;
26 const int nr = matrix.GetNrows();
27 const int nc = matrix.GetNcols();
29 TMatrixD matrix_double(nr, nc);
30 for (
int ir = 0; ir < nr; ir++)
31 for (
int ic = 0; ic < nc; ic++)
32 matrix_double(ir, ic) = matrix(ir, ic);
33 return getString(matrix_double, precision, color);
38 std::stringstream stream;
39 stream.precision(precision);
41 stream <<
"<table padding=0>";
42 const double max = matrix.Max();
43 const double min = matrix.Min();
44 for (
int i = 0; i < matrix.GetNrows(); i++) {
46 for (
int k = 0; k < matrix.GetNcols(); k++) {
47 const double value = matrix(i, k);
48 stream <<
"<td align=right";
49 if (color and value != 0.0) {
55 b = g = 255 - 180 * value / max;
57 r = 255 - 200 * value / min;
59 stream <<
" bgcolor=" << std::setfill(
'0') << std::hex;
60 stream << std::setw(2) << r;
61 stream << std::setw(2) << g;
62 stream << std::setw(2) << b;
63 stream << std::dec << std::setfill(
' ');
65 stream <<
">" << std::setw(11) << value;
78 std::stringstream stream;
79 stream.precision(precision);
81 stream << std::fixed <<
"(" << vec.X() <<
", " << vec.Y() <<
", " << vec.Z() <<
")";
87 std::stringstream stream;
88 stream.precision(precision);
89 std::string displayedUnitType = unitType;
92 displayedUnitType =
"\x0b5m";
97 <<
") " << displayedUnitType;
105 std::string unitType;
106 vec.GetCoordinates(xyz);
109 for (
auto entry : xyz)
110 if (std::abs(entry) > max)
111 max = std::abs(entry);
123 std::stringstream stream;
124 stream <<
"<small><tt>";
127 for (
int i = 0; i < length; i++) {
130 snprintf(str,
sizeof(str),
"%08x ", buf[i]);
133 stream <<
"</tt></small>";
140 std::string tmp = html;
142 replace_all(tmp,
"<br>",
"\n");
143 replace_all(tmp,
"</p>",
"\n");
144 replace_all(tmp,
"</tr>",
"\n");
145 replace_all(tmp,
" ",
" ");
148 replace_all(tmp,
"\x0b5",
"u");
151 const static std::regex tagRegex(
"<.*?>");
152 tmp = std::regex_replace(tmp, tagRegex,
"");
161 std::string tmp = str;
162 replace_all(tmp,
"&",
"&");
163 replace_all(tmp,
">",
">");
164 replace_all(tmp,
"<",
"<");
165 replace_all(tmp,
"\"",
""");
171 std::string tmp = str;
173 replace_all(tmp,
""",
"\"");
174 replace_all(tmp,
">",
">");
175 replace_all(tmp,
"<",
"<");
176 replace_all(tmp,
"&",
"&");
static double convertValueToUnit(double value, const std::string &unitString)
Converts a floating point value from the standard framework unit to the given unit.
std::string escape(const std::string &str)
Convert &, <, > etc.
std::string getStringConvertToUnit(const ROOT::Math::XYZVector &vec, int precision=2, const std::string &unitType="cm")
get a string with vector coordinates: (x, y, z).
std::string chooseUnitOfLength(const ROOT::Math::XYZVector &vec)
get a string with a unit type to convert a vector, so that it is easily readable.
std::string getHexDump(const int *buf, int length)
Create hexdump of given buffer.
std::string unescape(const std::string &str)
inverse of escape()
std::string getString(const TMatrixFBase &matrix, int precision=2, bool color=true)
get HTML table representing a matrix.
std::string htmlToPlainText(const std::string &html)
Reformat given HTML string into terminal-friendly plain text.
Abstract base class for different kinds of events.