11 #ifndef LARDATAALG_DUMPERS_RAWDATA_OPDETWAVEFORM_H
12 #define LARDATAALG_DUMPERS_RAWDATA_OPDETWAVEFORM_H
30 using namespace ::raw;
54 virtual std::string
label
69 virtual std::string
label
76 {
return digitsOf(waveform.size()); }
117 template <
typename Stream>
121 template <
typename Stream>
128 (std::string
const&
s,
unsigned int width, std::string padding =
" ");
131 static unsigned int digitsOf(
unsigned int n);
149 template <
typename Stream>
153 static std::string
const headerSep =
" | ";
155 auto const& data = waveform;
158 auto out = indenter(std::forward<Stream>(
stream));
162 <<
"on channel #" << waveform.
ChannelNumber() <<
" (time stamp: "
163 << waveform.
TimeStamp() <<
"): " << data.size() <<
" time ticks";
166 if (fDigitsPerLine == 0)
return;
169 saveIndentSettings().set(indent() +
" ");
171 unsigned int repeat_count = 0U;
172 unsigned int index = 0U;
173 unsigned int firstLineTick = 0U;
176 auto flushRepeatCount
177 = [
this, &out, &waveform, &firstLineTick](
unsigned int&
count)
182 if (fTimeLabelMaker) {
184 << padRight(
"", fTimeLabelMaker->labelWidth(waveform, firstLineTick))
188 out <<
" [ ... repeated " <<
count <<
" more times ]";
194 std::vector<Count_t> DigitBuffer(fDigitsPerLine), LastBuffer;
198 <<
"content of the channel (" << fDigitsPerLine <<
" ticks per line):";
199 auto iTick = data.cbegin(), tend = data.cend();
200 while (iTick != tend) {
202 unsigned int line_size
203 = std::min(fDigitsPerLine, (
unsigned int) data.size() - index);
204 if (line_size == 0)
break;
207 DigitBuffer.resize(line_size);
208 auto iBuf = DigitBuffer.begin(), bend = DigitBuffer.end();
209 while ((iBuf != bend) && (iTick != tend))
210 Extrema.
add(*(iBuf++) = *(iTick++) - fPedestal);
211 firstLineTick = index;
215 if (DigitBuffer == LastBuffer) {
222 flushRepeatCount(repeat_count);
226 if (fTimeLabelMaker) {
228 fTimeLabelMaker->label(waveform, firstLineTick),
229 fTimeLabelMaker->labelWidth(waveform, firstLineTick)
234 for (
auto digit: DigitBuffer)
235 out <<
" " << std::setw(4) << digit;
240 std::swap(LastBuffer, DigitBuffer);
243 flushRepeatCount(repeat_count);
244 if (Extrema.
min() != Extrema.
max()) {
246 <<
" range of " << data.size()
247 <<
" samples: [" << Extrema.
min() <<
";" << Extrema.
max() <<
"] (span: "
248 << (Extrema.
max() - Extrema.
min());
249 if (fPedestal != 0) {
250 out <<
", absolute: ["
251 << (Extrema.
min() + fPedestal) <<
";"
252 << (Extrema.
max() + fPedestal) <<
"]";
257 restoreIndentSettings();
264 (std::string
const&
s,
unsigned int width, std::string padding )
267 if (s.length() > width) {
269 return {
s, 0U, width };
273 padded.reserve(width);
276 unsigned int nPadding
277 = (s.length() >= width)? 0U: (width - s.length()) / padding.length();
280 if (nPadding * padding.length() + s.length() < width) {
283 padding.end() - (width - (nPadding * padding.length() + s.length())),
289 while (nPadding-- > 0) padded += padding;
292 assert(padded.length() == width);
300 unsigned int digits = 1U;
312 #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.
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.
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
std::string to_string(WindowPattern const &pattern)
then echo File list $list not found else cat $list while read file do echo $file sed s
Base class for data dumpers.
std::size_t count(Cont const &cont)
Helper base class for implementing data product dump algorithms.