28void StripFitProcessor::onProcessStart() {
29 using namespace tracking::digitization;
31 pulse_shape_ = PulseShape::make(std::string(PULSE_SHAPE_NAME),
32 PEAKING_TIME_NS, SECOND_TIME_CONST_NS);
34 fitter_ = std::make_unique<tracking::digitization::StripPulseFitter>(
35 *pulse_shape_, T0_OFFSET_NS, SAMPLING_INTERVAL_NS,
36 static_cast<double>(ADC_PEDESTAL), NOISE_SIGMA_ADC, t_scan_min_ns_,
37 t_scan_max_ns_, t_scan_step_ns_);
39 ldmx_log(info) <<
"StripFitProcessor configured:" <<
" shape="
40 << PULSE_SHAPE_NAME <<
" tp=" << PEAKING_TIME_NS <<
" ns"
41 <<
" pedestal=" << ADC_PEDESTAL <<
" ADC"
42 <<
" noise_σ=" << NOISE_SIGMA_ADC <<
" ADC" <<
" T scan ["
43 << t_scan_min_ns_ <<
", " << t_scan_max_ns_ <<
"] ns"
44 <<
" step=" << t_scan_step_ns_ <<
" ns";
48 const auto& raw_hits =
51 std::vector<ldmx::FittedSiStripHit> fitted_hits;
52 fitted_hits.reserve(raw_hits.size());
54 ldmx_log(debug) <<
"Fitting " << raw_hits.size() <<
" RawSiStripHits";
56 for (
const auto& raw : raw_hits) {
57 const auto result = fitter_->fit(raw.getSamples());
59 if (!result.converged) {
60 ldmx_log(trace) <<
"Fit did not converge for layer=" << raw.getLayerID()
61 <<
" strip=" << raw.getStripID() <<
" — skipping";
65 if (max_chi2_ndf_ > 0.0 && result.ndf > 0) {
66 const double reduced_chi2 = result.chi2 / result.ndf;
67 if (reduced_chi2 > max_chi2_ndf_) {
68 ldmx_log(trace) <<
"χ²/ndf=" << reduced_chi2
69 <<
" exceeds cut=" << max_chi2_ndf_ <<
" — skipping";
74 fitted_hits.emplace_back(
75 raw.getLayerID(), raw.getStripID(),
76 static_cast<float>(result.amplitude),
static_cast<float>(result.t0),
77 static_cast<float>(result.chi2), result.ndf, raw.getTrackID(),
78 raw.getPdgID(), raw.getSimHitID(), raw.getEdep());
80 ldmx_log(trace) <<
"Fitted: layer=" << raw.getLayerID()
81 <<
" strip=" << raw.getStripID()
82 <<
" amp=" << result.amplitude <<
" t0=" << result.t0
83 <<
" ns" <<
" chi2/ndf=" << result.chi2 <<
"/"
87 ldmx_log(debug) <<
"Produced " << fitted_hits.size() <<
" FittedSiStripHits";
89 event.add(out_collection_, fitted_hits);