1#include "Tracking/Event/SiStripWaveform.h"
9SiStripWaveform::SiStripWaveform(std::vector<short> samples, int16_t pchannel,
10 uint8_t hybrid_id, uint8_t feb_id,
12 : samples_(std::move(samples)),
14 hybrid_id_(hybrid_id),
16 n_triggers_(n_triggers) {}
18void SiStripWaveform::clear() {
26std::ostream& operator<<(std::ostream& output,
const SiStripWaveform& w) {
28 output <<
"[ SiStripWaveform ] FEB=" <<
static_cast<int>(w.feb_id_)
29 <<
" Hybrid=" <<
static_cast<int>(w.hybrid_id_)
30 <<
" PCh=" << w.pchannel_
31 <<
" NTrig=" <<
static_cast<int>(w.n_triggers_)
32 <<
" PeakAmp=" << w.peakAmplitude() <<
"\n";
34 if (w.samples_.empty())
return output;
37 short s_min = *std::min_element(w.samples_.begin(), w.samples_.end());
38 short s_max = *std::max_element(w.samples_.begin(), w.samples_.end());
39 s_min = std::min(s_min,
static_cast<short>(0));
40 s_max = std::max(s_max,
static_cast<short>(0));
42 const int bar_width = 50;
43 const float range =
static_cast<float>(s_max - s_min);
45 output <<
" Idx ADC |\n";
47 for (
int i = 0; i < static_cast<int>(w.samples_.size()); ++i) {
48 short val = w.samples_[i];
49 int t = i / 3, s = i % 3;
51 const std::string label =
"T" + std::to_string(t) +
"." + std::to_string(s);
55 (range > 0) ?
static_cast<int>((0.f - s_min) / range * (bar_width - 1))
57 int val_pos = (range > 0)
58 ?
static_cast<int>((
static_cast<float>(val) - s_min) /
59 range * (bar_width - 1))
61 val_pos = std::max(0, std::min(bar_width - 1, val_pos));
63 std::string bar(bar_width,
' ');
65 int lo = std::min(zero_pos, val_pos);
66 int hi = std::max(zero_pos, val_pos);
67 for (
int k = lo; k <= hi; ++k) bar[k] = (val >= 0) ?
'+' :
'-';
69 bar[val_pos] = (val > 0) ?
'>' : (val < 0) ?
'<' :
'|';
71 if (val != 0 && bar[zero_pos] ==
' ') bar[zero_pos] =
'|';
73 output <<
" " << std::left << std::setw(4) << label <<
" " << std::right
74 << std::setw(5) <<
static_cast<int>(val) <<
" |" << bar <<
"|\n";
constexpr int16_t pchannel(uint8_t apv_id, uint8_t channel)
Convert an (APV id, APV channel) pair into the physical strip number (pchannel) within a hybrid,...