LDMX Software
CKFProcessor.h
1#pragma once
2
3//--- Framework ---//
4#include "Framework/Configure/Parameters.h"
6#include "Framework/Logger.h"
7
8//--- C++ ---//
9#include <memory>
10
11//--- LDMX ---//
12#include "Tracking/EigenStepper.h" // IWYU pragma: keep
13#include "Tracking/Reco/TrackingGeometryUser.h"
14
15//--- ACTS ---//
16
17// Utils and Definitions
18
19// geometry
20
21// magfield
22
23// geometry
24
25// propagation testing
26#include "Acts/Propagator/ActorList.hpp"
27#include "Acts/Propagator/MaterialInteractor.hpp"
28#include "Acts/Propagator/Navigator.hpp"
29#include "Acts/Propagator/Propagator.hpp"
30#include "Acts/Propagator/StandardAborters.hpp"
31#include "Acts/Propagator/VoidNavigator.hpp"
32#include "Acts/Propagator/detail/SteppingLogger.hpp"
33
34// Kalman Filter
35
36// #include "Acts/EventData/Measurement.hpp"
37#include "Acts/EventData/VectorTrackContainer.hpp"
38#include "Acts/Geometry/GeometryIdentifier.hpp"
39#include "Acts/TrackFinding/CombinatorialKalmanFilter.hpp"
40#include "Acts/TrackFitting/GainMatrixUpdater.hpp"
41
42//--- Refit with backward propagation ---//
43
44// GSF
45// #include "Acts/TrackFitting/GaussianSumFitter.hpp"
46
47//--- Tracking ---//
48#include "Tracking/Event/Measurement.h"
49#include "Tracking/Event/Track.h"
50#include "Tracking/Reco/TrackExtrapolatorTool.h"
51#include "Tracking/Sim/IndexSourceLink.h"
52
53//--- Interpolated magnetic field ---//
54#include "Tracking/Sim/BFieldXYZUtils.h"
55// mg Aug 2024 not sure if these are needed...
56using Updater = Acts::GainMatrixUpdater;
57
58using ActionList =
59 Acts::ActorList<Acts::detail::SteppingLogger, Acts::MaterialInteractor,
60 Acts::EndOfWorldReached>;
61
62using CkfPropagator = Acts::Propagator<Acts::EigenStepper<>, Acts::Navigator>;
63using ExtrapPropagator =
64 Acts::Propagator<Acts::EigenStepper<>, Acts::VoidNavigator>;
65using TrackContainer = Acts::TrackContainer<Acts::VectorTrackContainer,
66 Acts::VectorMultiTrajectory>;
67
68namespace tracking {
69namespace reco {
70
71class CKFProcessor final : public TrackingGeometryUser {
72 public:
79 CKFProcessor(const std::string& name, framework::Process& process);
80
82 virtual ~CKFProcessor() = default;
83
87 void onProcessStart() override;
88
95 void onNewRun(const ldmx::RunHeader& rh) override;
96
100 void onProcessEnd() override;
101
107 void configure(framework::config::Parameters& parameters) override;
108
114 void produce(framework::Event& event) override;
115
116 private:
117 // Make geoid -> source link map Measurements
118 auto makeGeoIdSourceLinkMap(const geo::TrackersTrackingGeometry& tg,
119 const std::vector<ldmx::Measurement>& ldmxsps)
120 -> std::unordered_multimap<Acts::GeometryIdentifier,
122
123 template <typename geometry_t, typename source_link_hash_t,
124 typename source_link_equality_t>
125 std::vector<std::vector<std::size_t>> computeSharedHits(
126 std::vector<ldmx::Track> tracks, std::vector<ldmx::Measurement> meas_coll,
127 geometry_t& tg, source_link_hash_t&& sourceLinkHash,
128 source_link_equality_t&& sourceLinkEquality) const;
129
130 // If we want to dump the tracking geometry
131 bool dumpobj_{false};
132
133 int pionstates_{10};
134
135 int nevents_{0};
136
137 // Processing time counter
138 double processing_time_{0.};
139
140 // time profiling
141 std::map<std::string, double> profiling_map_;
142
143 bool debug_acts_{false};
144
145 std::shared_ptr<Acts::PlaneSurface> target_surface_;
146 Acts::RotationMatrix3 surf_rotation_;
147 // Constant BField
148 double bfield_{0};
149 // Use constant bfield
150 bool const_b_field_{true};
151
152 // Remove stereo measurements
153 bool remove_stereo_{false};
154
155 // Use 2d measurements instead of 1D
156 bool use1_dmeasurements_{true};
157
158 // Minimum number of hits on tracks
159 int min_hits_{7};
160
161 // Stepping size (in mm)
162 double propagator_step_size_{200.};
163 int propagator_max_steps_{1000};
164
165 // The extrapolation surface
166 bool use_extrapolate_location_{true};
167 std::vector<double> extrapolate_location_{0., 0., 0.};
168 bool use_seed_perigee_{false};
169
170 // The measurement collection to use for track reconstruction
171 std::string measurement_collection_{"TaggerMeasurements"};
172
173 std::string sim_particles_coll_name_;
174 std::string sim_particles_event_passname_;
175
176 // Outlier removal pvalue
177 // The Chi2Cut is applied at filtering stage.
178 // 1DOF pvalues: 0.1 = 2.706 0.05 = 3.841 0.025 = 5.024 0.01 = 6.635 0.005
179 // = 7.879 The probability to reject a good measurement is pvalue The
180 // probability to reject an outlier is given in NIM A262 (1987) 444-450
181 double outlier_pval_;
182
183 // The output track collection
184 std::string out_trk_collection_{"Tracks"};
185
186 // The seed track collection
187 std::string seed_coll_name_{"seedTracks"};
188
189 // The interpolated bfield
190 std::string field_map_{""};
191
192 std::string input_pass_name_{""};
193
194 // The Propagator
195 std::unique_ptr<const CkfPropagator> propagator_;
196
197 // The CKF
198 std::unique_ptr<
199 const Acts::CombinatorialKalmanFilter<CkfPropagator, TrackContainer>>
200 ckf_;
201
202 // Track Extrapolator Tool (uses VoidNavigator to propagate freely to any
203 // surface)
204 std::unique_ptr<const ExtrapPropagator> propagator_extrap_;
205 std::shared_ptr<tracking::reco::TrackExtrapolatorTool<ExtrapPropagator>>
206 trk_extrap_;
207
208 // Zero-B CKF as fallback
209 std::unique_ptr<const CkfPropagator> propagator_zero_b_;
210 std::unique_ptr<
211 const Acts::CombinatorialKalmanFilter<CkfPropagator, TrackContainer>>
212 ckf_zero_b_;
213 std::unique_ptr<const ExtrapPropagator> propagator_extrap_zero_b_;
214 std::shared_ptr<tracking::reco::TrackExtrapolatorTool<ExtrapPropagator>>
215 trk_extrap_zero_b_;
216
217 // Const-B (1.5T) CKF as fallback for tagger
218 std::unique_ptr<const CkfPropagator> propagator_const_b_;
219 std::unique_ptr<
220 const Acts::CombinatorialKalmanFilter<CkfPropagator, TrackContainer>>
221 ckf_const_b_;
222 std::unique_ptr<const ExtrapPropagator> propagator_extrap_const_b_;
223 std::shared_ptr<tracking::reco::TrackExtrapolatorTool<ExtrapPropagator>>
224 trk_extrap_const_b_;
225
228 int ntracks_;
229 int eventnr_;
230
231 // CKF fallback statistics
232 int n_fieldmap_ckf_failed_tagger_{0};
233 int n_fieldmap_ckf_failed_recoil_{0};
234 int n_constb_ckf_recovered_tagger_{0};
235 int n_zerob_ckf_recovered_recoil_{0};
236
237 // Extrapolation fallback statistics
238 int n_fieldmap_target_extrap_failed_tagger_{0};
239 int n_constb_target_extrap_recovered_tagger_{0};
240 int n_fieldmap_target_extrap_failed_recoil_{0};
241 int n_zerob_target_extrap_recovered_recoil_{0};
242 int n_fieldmap_ecal_extrap_failed_recoil_{0};
243 int n_zerob_ecal_extrap_recovered_recoil_{0};
244
245 // BField Systematics
246 BFieldDistortion bfield_distortion_{};
247
248 // Keep track on which system this processor is running on
249 bool tagger_tracking_{true};
250
251}; // CKFProcessor
252
253} // namespace reco
254} // namespace tracking
The only reason this file exists is to silence an annoying maybe-uninitialized warning that originate...
Base classes for all user event processing components to extend.
Implements an event buffer system for storing event data.
Definition Event.h:40
Class which represents the process under execution.
Definition Process.h:34
virtual void process(Event &event) final
Processing an event for a Producer is calling produce.
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:26
Run-specific configuration and data stored in its own output TTree alongside the event TTree in the o...
Definition RunHeader.h:68
void produce(framework::Event &event) override
Run the processor.
void configure(framework::config::Parameters &parameters) override
Configure the processor using the given user specified parameters.
void onNewRun(const ldmx::RunHeader &rh) override
onNewRun is the first function called for each processor after the conditions are fully configured an...
CKFProcessor(const std::string &name, framework::Process &process)
Constructor.
int nseeds_
n seeds and n tracks
void onProcessStart() override
Callback for the EventProcessor to take any necessary action when the processing of events starts,...
void onProcessEnd() override
Callback for the EventProcessor to take any necessary action when the processing of events finishes,...
virtual ~CKFProcessor()=default
Destructor.
a helper base class providing some methods to shorten access to common conditions used within the tra...
The measurement calibrator can be a function or a class/struct able to retrieve the sim hits containe...
A deliberate mis-placement of the reconstruction magnetic field, used to quantify how well we need to...