LDMX Software
SiStripWaveform.h
1#ifndef TRACKING_EVENT_SISTRIPWAVEFORM_H_
2#define TRACKING_EVENT_SISTRIPWAVEFORM_H_
3
4#include <algorithm>
5#include <iostream>
6#include <vector>
7
8#include "TObject.h"
9
10namespace ldmx {
11
25 public:
26 SiStripWaveform() = default;
27
28 SiStripWaveform(std::vector<short> samples, int16_t pchannel,
29 uint8_t hybrid_id, uint8_t feb_id, uint8_t n_triggers);
30
31 virtual ~SiStripWaveform() {}
32
33 void clear();
34
35 const std::vector<short>& getSamples() const { return samples_; }
36 int16_t getPchannel() const { return pchannel_; }
37 uint8_t getHybridId() const { return hybrid_id_; }
38 uint8_t getFebId() const { return feb_id_; }
39 uint8_t getNTriggers() const { return n_triggers_; }
40
42 void setFitResult(float amplitude, float t0, float chi2, int ndf,
43 bool converged) {
44 fit_amplitude_ = amplitude;
45 fit_t0_ = t0;
46 fit_chi2_ = chi2;
47 fit_ndf_ = ndf;
48 fit_converged_ = converged;
49 }
50
52 float getFitAmplitude() const { return fit_amplitude_; }
54 float getFitT0() const { return fit_t0_; }
55 float getFitChi2() const { return fit_chi2_; }
56 int getFitNDF() const { return fit_ndf_; }
57 bool isFitConverged() const { return fit_converged_; }
58
60 short getSample(uint8_t t, uint8_t s) const { return samples_[t * 3 + s]; }
61
65 short peakAmplitude() const {
66 if (samples_.empty()) return 0;
67 return *std::max_element(samples_.begin(), samples_.end());
68 }
69
71 uint8_t peakTrigger() const {
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 }
76
77 friend std::ostream& operator<<(std::ostream& o, const SiStripWaveform& w);
78
79 protected:
80 std::vector<short>
82 int16_t pchannel_{0};
83 uint8_t hybrid_id_{0};
84 uint8_t feb_id_{0};
85 uint8_t n_triggers_{0};
86
87 // Pulse-shape fit result (filled by SiStripWaveformBuilder).
88 float fit_amplitude_{0};
89 float fit_t0_{0};
90 float fit_chi2_{0};
91 int fit_ndf_{0};
92 bool fit_converged_{false};
93
94 ClassDef(SiStripWaveform, 2);
95};
96
97} // namespace ldmx
98
99#endif // TRACKING_EVENT_SISTRIPWAVEFORM_H_
Full multi-trigger waveform for one silicon strip channel.
int fit_ndf_
degrees of freedom = n_samples - 2
float fit_chi2_
chi-squared at the minimum
std::vector< short > samples_
n_triggers * 3 pedestal-subtracted ADC samples
short getSample(uint8_t t, uint8_t s) const
Sample at trigger index t (0-based), APV sample s (0-2).
bool fit_converged_
true if the fit succeeded
uint8_t peakTrigger() const
Trigger index (0-based) of the sample with the maximum ADC value.
int16_t pchannel_
physical strip number within hybrid [0, 639]
short peakAmplitude() const
Peak amplitude: the maximum (pedestal-subtracted) ADC sample.
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).
uint8_t n_triggers_
number of APV triggers assembled
float fit_t0_
fitted hit arrival time T [ns]
float fit_amplitude_
fitted amplitude [ADC]
float getFitT0() const
Fitted hit arrival time T [ns] in the sample-window frame (t_i = i*dt).