LDMX Software
ldmx::SiStripWaveform Class Reference

Full multi-trigger waveform for one silicon strip channel. More...

#include <SiStripWaveform.h>

Public Member Functions

 SiStripWaveform (std::vector< short > samples, int16_t pchannel, uint8_t hybrid_id, uint8_t feb_id, uint8_t n_triggers)
 
void clear ()
 
const std::vector< short > & getSamples () const
 
int16_t getPchannel () const
 
uint8_t getHybridId () const
 
uint8_t getFebId () const
 
uint8_t getNTriggers () const
 
void setFitResult (float amplitude, float t0, float chi2, int ndf, bool converged)
 Store the result of a pulse-shape fit to this waveform.
 
float getFitAmplitude () const
 Fitted pulse amplitude [ADC counts] (peak of the fitted pulse shape).
 
float getFitT0 () const
 Fitted hit arrival time T [ns] in the sample-window frame (t_i = i*dt).
 
float getFitChi2 () const
 
int getFitNDF () const
 
bool isFitConverged () const
 
short getSample (uint8_t t, uint8_t s) const
 Sample at trigger index t (0-based), APV sample s (0-2).
 
short peakAmplitude () const
 Peak amplitude: the maximum (pedestal-subtracted) ADC sample.
 
uint8_t peakTrigger () const
 Trigger index (0-based) of the sample with the maximum ADC value.
 

Protected Member Functions

 ClassDef (SiStripWaveform, 2)
 

Protected Attributes

std::vector< short > samples_
 n_triggers * 3 pedestal-subtracted ADC samples
 
int16_t pchannel_ {0}
 physical strip number within hybrid [0, 639]
 
uint8_t hybrid_id_ {0}
 
uint8_t feb_id_ {0}
 
uint8_t n_triggers_ {0}
 number of APV triggers assembled
 
float fit_amplitude_ {0}
 fitted amplitude [ADC]
 
float fit_t0_ {0}
 fitted hit arrival time T [ns]
 
float fit_chi2_ {0}
 chi-squared at the minimum
 
int fit_ndf_ {0}
 degrees of freedom = n_samples - 2
 
bool fit_converged_ {false}
 true if the fit succeeded
 

Friends

std::ostream & operator<< (std::ostream &o, const SiStripWaveform &w)
 

Detailed Description

Full multi-trigger waveform for one silicon strip channel.

Assembled by SiStripWaveformBuilder from the per-trigger pedestal-subtracted RawSiStripHit objects for a single (feb, hybrid, pchannel). Samples are stored in trigger order: [s0_t0, s1_t0, s2_t0, s0_t1, s1_t1, s2_t1, ...], so the total size is n_triggers * 3.

This is the natural input for waveform fitting (APV25 CR-RC pulse shape → hit time with ~2.5 ns resolution) and any per-channel waveform corrections before clustering.

Definition at line 24 of file SiStripWaveform.h.

Constructor & Destructor Documentation

◆ SiStripWaveform()

ldmx::SiStripWaveform::SiStripWaveform ( std::vector< short > samples,
int16_t pchannel,
uint8_t hybrid_id,
uint8_t feb_id,
uint8_t n_triggers )

Definition at line 9 of file SiStripWaveform.cxx.

12 : samples_(std::move(samples)),
13 pchannel_(pchannel),
14 hybrid_id_(hybrid_id),
15 feb_id_(feb_id),
16 n_triggers_(n_triggers) {}
std::vector< short > samples_
n_triggers * 3 pedestal-subtracted ADC samples
int16_t pchannel_
physical strip number within hybrid [0, 639]
uint8_t n_triggers_
number of APV triggers assembled

◆ ~SiStripWaveform()

virtual ldmx::SiStripWaveform::~SiStripWaveform ( )
inlinevirtual

Definition at line 31 of file SiStripWaveform.h.

31{}

Member Function Documentation

◆ clear()

void ldmx::SiStripWaveform::clear ( )

Definition at line 18 of file SiStripWaveform.cxx.

18 {
19 samples_.clear();
20 pchannel_ = 0;
21 hybrid_id_ = 0;
22 feb_id_ = 0;
23 n_triggers_ = 0;
25 fit_t0_ = 0;
26 fit_chi2_ = 0;
27 fit_ndf_ = 0;
28 fit_converged_ = false;
29}
int fit_ndf_
degrees of freedom = n_samples - 2
float fit_chi2_
chi-squared at the minimum
bool fit_converged_
true if the fit succeeded
float fit_t0_
fitted hit arrival time T [ns]
float fit_amplitude_
fitted amplitude [ADC]

◆ getFebId()

uint8_t ldmx::SiStripWaveform::getFebId ( ) const
inline

Definition at line 38 of file SiStripWaveform.h.

38{ return feb_id_; }

◆ getFitAmplitude()

float ldmx::SiStripWaveform::getFitAmplitude ( ) const
inline

Fitted pulse amplitude [ADC counts] (peak of the fitted pulse shape).

Definition at line 52 of file SiStripWaveform.h.

52{ return fit_amplitude_; }

References fit_amplitude_.

◆ getFitChi2()

float ldmx::SiStripWaveform::getFitChi2 ( ) const
inline

Definition at line 55 of file SiStripWaveform.h.

55{ return fit_chi2_; }

◆ getFitNDF()

int ldmx::SiStripWaveform::getFitNDF ( ) const
inline

Definition at line 56 of file SiStripWaveform.h.

56{ return fit_ndf_; }

◆ getFitT0()

float ldmx::SiStripWaveform::getFitT0 ( ) const
inline

Fitted hit arrival time T [ns] in the sample-window frame (t_i = i*dt).

Definition at line 54 of file SiStripWaveform.h.

54{ return fit_t0_; }

References fit_t0_.

◆ getHybridId()

uint8_t ldmx::SiStripWaveform::getHybridId ( ) const
inline

Definition at line 37 of file SiStripWaveform.h.

37{ return hybrid_id_; }

◆ getNTriggers()

uint8_t ldmx::SiStripWaveform::getNTriggers ( ) const
inline

Definition at line 39 of file SiStripWaveform.h.

39{ return n_triggers_; }

◆ getPchannel()

int16_t ldmx::SiStripWaveform::getPchannel ( ) const
inline

Definition at line 36 of file SiStripWaveform.h.

36{ return pchannel_; }

◆ getSample()

short ldmx::SiStripWaveform::getSample ( uint8_t t,
uint8_t s ) const
inline

Sample at trigger index t (0-based), APV sample s (0-2).

Definition at line 60 of file SiStripWaveform.h.

60{ return samples_[t * 3 + s]; }

References samples_.

◆ getSamples()

const std::vector< short > & ldmx::SiStripWaveform::getSamples ( ) const
inline

Definition at line 35 of file SiStripWaveform.h.

35{ return samples_; }

◆ isFitConverged()

bool ldmx::SiStripWaveform::isFitConverged ( ) const
inline

Definition at line 57 of file SiStripWaveform.h.

57{ return fit_converged_; }

◆ peakAmplitude()

short ldmx::SiStripWaveform::peakAmplitude ( ) const
inline

Peak amplitude: the maximum (pedestal-subtracted) ADC sample.

Convert to a significance downstream by dividing by the per-channel noise from the TrackerPedestals conditions object.

Definition at line 65 of file SiStripWaveform.h.

65 {
66 if (samples_.empty()) return 0;
67 return *std::max_element(samples_.begin(), samples_.end());
68 }

References samples_.

◆ peakTrigger()

uint8_t ldmx::SiStripWaveform::peakTrigger ( ) const
inline

Trigger index (0-based) of the sample with the maximum ADC value.

Definition at line 71 of file SiStripWaveform.h.

71 {
72 if (samples_.empty()) return 0;
73 auto it = std::max_element(samples_.begin(), samples_.end());
74 return static_cast<uint8_t>(std::distance(samples_.begin(), it) / 3);
75 }

References samples_.

◆ setFitResult()

void ldmx::SiStripWaveform::setFitResult ( float amplitude,
float t0,
float chi2,
int ndf,
bool converged )
inline

Store the result of a pulse-shape fit to this waveform.

Definition at line 42 of file SiStripWaveform.h.

43 {
44 fit_amplitude_ = amplitude;
45 fit_t0_ = t0;
46 fit_chi2_ = chi2;
47 fit_ndf_ = ndf;
48 fit_converged_ = converged;
49 }

References fit_amplitude_, fit_chi2_, fit_converged_, fit_ndf_, and fit_t0_.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & o,
const SiStripWaveform & w )
friend

Definition at line 31 of file SiStripWaveform.cxx.

31 {
32 // Header.
33 output << "[ SiStripWaveform ] FEB=" << static_cast<int>(w.feb_id_)
34 << " Hybrid=" << static_cast<int>(w.hybrid_id_)
35 << " PCh=" << w.pchannel_
36 << " NTrig=" << static_cast<int>(w.n_triggers_)
37 << " PeakAmp=" << w.peakAmplitude();
38 if (w.fit_converged_) {
39 output << " | fit amp=" << w.fit_amplitude_ << " t0=" << w.fit_t0_ << "ns"
40 << " chi2/ndf=" << w.fit_chi2_ << "/" << w.fit_ndf_;
41 }
42 output << "\n";
43
44 if (w.samples_.empty()) return output;
45
46 // Determine scale — always include zero so the baseline is visible.
47 short s_min = *std::min_element(w.samples_.begin(), w.samples_.end());
48 short s_max = *std::max_element(w.samples_.begin(), w.samples_.end());
49 s_min = std::min(s_min, static_cast<short>(0));
50 s_max = std::max(s_max, static_cast<short>(0));
51
52 const int bar_width = 50;
53 const float range = static_cast<float>(s_max - s_min);
54
55 output << " Idx ADC |\n";
56
57 for (int i = 0; i < static_cast<int>(w.samples_.size()); ++i) {
58 short val = w.samples_[i];
59 int t = i / 3, s = i % 3;
60
61 const std::string label = "T" + std::to_string(t) + "." + std::to_string(s);
62
63 // Column positions for zero and this sample.
64 int zero_pos =
65 (range > 0) ? static_cast<int>((0.f - s_min) / range * (bar_width - 1))
66 : bar_width / 2;
67 int val_pos = (range > 0)
68 ? static_cast<int>((static_cast<float>(val) - s_min) /
69 range * (bar_width - 1))
70 : zero_pos;
71 val_pos = std::max(0, std::min(bar_width - 1, val_pos));
72
73 std::string bar(bar_width, ' ');
74 // Fill between zero and sample.
75 int lo = std::min(zero_pos, val_pos);
76 int hi = std::max(zero_pos, val_pos);
77 for (int k = lo; k <= hi; ++k) bar[k] = (val >= 0) ? '+' : '-';
78 // Tip marker.
79 bar[val_pos] = (val > 0) ? '>' : (val < 0) ? '<' : '|';
80 // Zero marker (only when sample is non-zero).
81 if (val != 0 && bar[zero_pos] == ' ') bar[zero_pos] = '|';
82
83 output << " " << std::left << std::setw(4) << label << " " << std::right
84 << std::setw(5) << static_cast<int>(val) << " |" << bar << "|\n";
85 }
86 return output;
87}

Member Data Documentation

◆ feb_id_

uint8_t ldmx::SiStripWaveform::feb_id_ {0}
protected

Definition at line 84 of file SiStripWaveform.h.

84{0};

◆ fit_amplitude_

float ldmx::SiStripWaveform::fit_amplitude_ {0}
protected

fitted amplitude [ADC]

Definition at line 88 of file SiStripWaveform.h.

88{0};

Referenced by getFitAmplitude(), and setFitResult().

◆ fit_chi2_

float ldmx::SiStripWaveform::fit_chi2_ {0}
protected

chi-squared at the minimum

Definition at line 90 of file SiStripWaveform.h.

90{0};

Referenced by setFitResult().

◆ fit_converged_

bool ldmx::SiStripWaveform::fit_converged_ {false}
protected

true if the fit succeeded

Definition at line 92 of file SiStripWaveform.h.

92{false};

Referenced by setFitResult().

◆ fit_ndf_

int ldmx::SiStripWaveform::fit_ndf_ {0}
protected

degrees of freedom = n_samples - 2

Definition at line 91 of file SiStripWaveform.h.

91{0};

Referenced by setFitResult().

◆ fit_t0_

float ldmx::SiStripWaveform::fit_t0_ {0}
protected

fitted hit arrival time T [ns]

Definition at line 89 of file SiStripWaveform.h.

89{0};

Referenced by getFitT0(), and setFitResult().

◆ hybrid_id_

uint8_t ldmx::SiStripWaveform::hybrid_id_ {0}
protected

Definition at line 83 of file SiStripWaveform.h.

83{0};

◆ n_triggers_

uint8_t ldmx::SiStripWaveform::n_triggers_ {0}
protected

number of APV triggers assembled

Definition at line 85 of file SiStripWaveform.h.

85{0};

◆ pchannel_

int16_t ldmx::SiStripWaveform::pchannel_ {0}
protected

physical strip number within hybrid [0, 639]

Definition at line 82 of file SiStripWaveform.h.

82{0};

◆ samples_

std::vector<short> ldmx::SiStripWaveform::samples_
protected

n_triggers * 3 pedestal-subtracted ADC samples

Definition at line 81 of file SiStripWaveform.h.

Referenced by getSample(), peakAmplitude(), and peakTrigger().


The documentation for this class was generated from the following files: