LDMX Software
StripFitProcessor.cxx
1#include "Tracking/Reco/StripFitProcessor.h"
2
3#include "Tracking/Event/FittedSiStripHit.h"
4#include "Tracking/Event/RawSiStripHit.h"
5
6using namespace framework;
7
8namespace tracking::reco {
9
10StripFitProcessor::StripFitProcessor(const std::string& name,
11 framework::Process& process)
12 : framework::Producer(name, process) {}
13
14void StripFitProcessor::configure(framework::config::Parameters& parameters) {
15 in_collection_ =
16 parameters.get<std::string>("in_collection", "RawSiStripHits");
17 in_pass_ = parameters.get<std::string>("in_pass", "");
18 out_collection_ =
19 parameters.get<std::string>("out_collection", "FittedSiStripHits");
20
21 t_scan_min_ns_ = parameters.get<double>("t_scan_min_ns", -50.0);
22 t_scan_max_ns_ = parameters.get<double>("t_scan_max_ns", 150.0);
23 t_scan_step_ns_ = parameters.get<double>("t_scan_step_ns", 1.0);
24
25 max_chi2_ndf_ = parameters.get<double>("max_chi2_ndf", -1.0);
26}
27
28void StripFitProcessor::onProcessStart() {
29 using namespace tracking::digitization;
30
31 pulse_shape_ = PulseShape::make(std::string(PULSE_SHAPE_NAME),
32 PEAKING_TIME_NS, SECOND_TIME_CONST_NS);
33
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_);
38
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";
45}
46
47void StripFitProcessor::produce(framework::Event& event) {
48 const auto& raw_hits =
49 event.getCollection<ldmx::RawSiStripHit>(in_collection_, in_pass_);
50
51 std::vector<ldmx::FittedSiStripHit> fitted_hits;
52 fitted_hits.reserve(raw_hits.size());
53
54 ldmx_log(debug) << "Fitting " << raw_hits.size() << " RawSiStripHits";
55
56 for (const auto& raw : raw_hits) {
57 const auto result = fitter_->fit(raw.getSamples());
58
59 if (!result.converged) {
60 ldmx_log(trace) << "Fit did not converge for layer=" << raw.getLayerID()
61 << " strip=" << raw.getStripID() << " — skipping";
62 continue;
63 }
64
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";
70 continue;
71 }
72 }
73
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());
79
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 << "/"
84 << result.ndf;
85 }
86
87 ldmx_log(debug) << "Produced " << fitted_hits.size() << " FittedSiStripHits";
88
89 event.add(out_collection_, fitted_hits);
90}
91
92} // namespace tracking::reco
93
#define DECLARE_PRODUCER(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Implements an event buffer system for storing event data.
Definition Event.h:42
Class which represents the process under execution.
Definition Process.h:37
Base class for a module which produces a data product.
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
Implementation of a raw digitized hit from a silicon strip detector.
Fits a pulse shape to each RawSiStripHit and produces FittedSiStripHits.
All classes in the ldmx-sw project use this namespace.