LDMX Software
StripFitProcessor.cxx
1#include "Tracking/Reco/StripFitProcessor.h"
2
3#include "Tracking/Digitization/SiStripConstants.h"
4#include "Tracking/Event/FittedSiStripHit.h"
5#include "Tracking/Event/SimSiStripHit.h"
6
7using namespace framework;
8
9namespace tracking::reco {
10
11StripFitProcessor::StripFitProcessor(const std::string& name,
12 framework::Process& process)
13 : framework::Producer(name, process) {}
14
15void StripFitProcessor::configure(framework::config::Parameters& parameters) {
16 in_collection_ =
17 parameters.get<std::string>("in_collection", "SimSiStripHits");
18 in_pass_ = parameters.get<std::string>("in_pass", "");
19 out_collection_ =
20 parameters.get<std::string>("out_collection", "FittedSiStripHits");
21
22 t_scan_min_ns_ = parameters.get<double>("t_scan_min_ns", -50.0);
23 t_scan_max_ns_ = parameters.get<double>("t_scan_max_ns", 150.0);
24 t_scan_step_ns_ = parameters.get<double>("t_scan_step_ns", 1.0);
25
26 max_chi2_ndf_ = parameters.get<double>("max_chi2_ndf", -1.0);
27}
28
29void StripFitProcessor::onProcessStart() {
30 using namespace tracking::digitization;
31
32 pulse_shape_ = PulseShape::make(std::string(PULSE_SHAPE_NAME),
33 PEAKING_TIME_NS, SECOND_TIME_CONST_NS);
34
35 fitter_ = std::make_unique<tracking::digitization::StripPulseFitter>(
36 *pulse_shape_, T0_OFFSET_NS, SAMPLING_INTERVAL_NS,
37 static_cast<double>(ADC_PEDESTAL), NOISE_SIGMA_ADC, t_scan_min_ns_,
38 t_scan_max_ns_, t_scan_step_ns_);
39
40 ldmx_log(info) << "StripFitProcessor configured:" << " shape="
41 << PULSE_SHAPE_NAME << " tp=" << PEAKING_TIME_NS << " ns"
42 << " pedestal=" << ADC_PEDESTAL << " ADC"
43 << " noise_σ=" << NOISE_SIGMA_ADC << " ADC" << " T scan ["
44 << t_scan_min_ns_ << ", " << t_scan_max_ns_ << "] ns"
45 << " step=" << t_scan_step_ns_ << " ns";
46}
47
48void StripFitProcessor::produce(framework::Event& event) {
49 const auto& raw_hits =
50 event.getCollection<ldmx::SimSiStripHit>(in_collection_, in_pass_);
51
52 std::vector<ldmx::FittedSiStripHit> fitted_hits;
53 fitted_hits.reserve(raw_hits.size());
54
55 ldmx_log(debug) << "Fitting " << raw_hits.size() << " SimSiStripHits";
56
57 for (const auto& raw : raw_hits) {
58 const auto result = fitter_->fit(raw.getSamples());
59
60 if (!result.converged) {
61 ldmx_log(trace) << "Fit did not converge for layer=" << raw.getLayerID()
62 << " strip=" << raw.getStripID() << " — skipping";
63 continue;
64 }
65
66 if (max_chi2_ndf_ > 0.0 && result.ndf > 0) {
67 const double reduced_chi2 = result.chi2 / result.ndf;
68 if (reduced_chi2 > max_chi2_ndf_) {
69 ldmx_log(trace) << "χ²/ndf=" << reduced_chi2
70 << " exceeds cut=" << max_chi2_ndf_ << " — skipping";
71 continue;
72 }
73 }
74
75 fitted_hits.emplace_back(
76 raw.getLayerID(), raw.getStripID(),
77 static_cast<float>(result.amplitude), static_cast<float>(result.t0),
78 static_cast<float>(result.chi2), result.ndf, raw.getTrackID(),
79 raw.getPdgID(), raw.getSimHitID(), raw.getEdep(),
80 tracking::digitization::NOISE_SIGMA_ADC);
81
82 ldmx_log(trace) << "Fitted: layer=" << raw.getLayerID()
83 << " strip=" << raw.getStripID()
84 << " amp=" << result.amplitude << " t0=" << result.t0
85 << " ns" << " chi2/ndf=" << result.chi2 << "/"
86 << result.ndf;
87 }
88
89 ldmx_log(debug) << "Produced " << fitted_hits.size() << " FittedSiStripHits";
90
91 event.add(out_collection_, fitted_hits);
92}
93
94} // namespace tracking::reco
95
#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:40
Class which represents the process under execution.
Definition Process.h:34
Base class for a module which produces a data product.
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:26
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:75
Truth (Monte Carlo) representation of a digitized silicon strip detector hit.
Fits a pulse shape to each SimSiStripHit and produces FittedSiStripHits.
All classes in the ldmx-sw project use this namespace.