11 #ifndef LARDATAALG_DUMPERS_RAWDATA_OPDETWAVEFORM_H 12 #define LARDATAALG_DUMPERS_RAWDATA_OPDETWAVEFORM_H 28 using namespace ::
raw;
72 unsigned int)
const override 115 template <
typename Stream>
119 template <
typename Stream>
122 dump(stream, waveform);
126 static std::string
padRight(std::string
const& s,
128 std::string padding =
" ");
131 static unsigned int digitsOf(
unsigned int n);
147 template <
typename Stream>
150 static std::string
const headerSep =
" | ";
152 auto const& data = waveform;
155 auto out =
indenter(std::forward<Stream>(stream));
159 <<
" (time stamp: " << waveform.
TimeStamp() <<
"): " << data.size() <<
" time ticks";
167 unsigned int repeat_count = 0U;
168 unsigned int index = 0U;
169 unsigned int firstLineTick = 0U;
172 auto flushRepeatCount =
173 [
this, &out, &waveform, &firstLineTick](
unsigned int& count) -> decltype(
auto) {
179 out <<
" [ ... repeated " << count <<
" more times ]";
188 out.newline() <<
"content of the channel (" <<
fDigitsPerLine <<
" ticks per line):";
189 auto iTick = data.cbegin(), tend = data.cend();
190 while (iTick != tend) {
192 unsigned int line_size = std::min(
fDigitsPerLine, (
unsigned int)data.size() - index);
193 if (line_size == 0)
break;
196 DigitBuffer.resize(line_size);
197 auto iBuf = DigitBuffer.begin(), bend = DigitBuffer.end();
198 while ((iBuf != bend) && (iTick != tend))
200 firstLineTick = index;
204 if (DigitBuffer == LastBuffer) {
211 flushRepeatCount(repeat_count);
220 for (
auto digit : DigitBuffer)
221 out <<
" " << std::setw(4) << digit;
225 std::swap(LastBuffer, DigitBuffer);
228 flushRepeatCount(repeat_count);
229 if (Extrema.
min() != Extrema.
max()) {
230 out.newline() <<
" range of " << data.size() <<
" samples: [" << Extrema.
min() <<
";" 231 << Extrema.
max() <<
"] (span: " << (Extrema.
max() - Extrema.
min());
246 std::string padding )
249 if (s.length() > width) {
251 return {s, 0U, width};
255 padded.reserve(width);
258 unsigned int nPadding = (s.length() >= width) ? 0U : (width - s.length()) / padding.length();
261 if (nPadding * padding.length() + s.length() < width) {
263 padded.append(padding.end() - (width - (nPadding * padding.length() + s.length())),
268 while (nPadding-- > 0)
272 assert(padded.length() == width);
280 unsigned int digits = 1U;
290 #endif // LARDATAALG_DUMPERS_RAWDATA_OPDETWAVEFORM_H Data_t max() const
Returns the accumulated maximum, or a very small number if no values.
This_t & add(Data_t value)
Include a single value in the statistics.
IndentSettings & restoreIndentSettings()
Restores and returns the last saved settings.
void set(std::string const &newIndent, std::string const &newFirstIndent)
Classes gathering simple statistics.
Keeps track of the minimum and maximum value we observed.
Data_t min() const
Returns the accumulated minimum, or a very large number if no values.
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
std::string const & indent() const
Returns the indentation string currently configured for all lines.
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
decltype(auto) indenter(Stream &&out) const
Returns an Indenter object tied to this dumper and out stream.
IndentSettings & saveIndentSettings()
Stacks a copy of the current settings, and returns the "new" ones.
Base class for data dumpers.
Helper base class for implementing data product dump algorithms.