LDMX Software
CKFProcessor.h
1#pragma once
2
3//--- Framework ---//
4#include "Framework/Configure/Parameters.h"
6#include "Framework/Logger.h"
8
9//--- C++ ---//
10#include <memory>
11#include <random>
12
13//--- LDMX ---//
15#include "Tracking/Reco/TrackingGeometryUser.h"
16
17//--- ACTS ---//
18
19// Utils and Definitions
20#include "Acts/Definitions/Common.hpp"
21#include "Acts/Definitions/TrackParametrization.hpp"
22#include "Acts/Definitions/Units.hpp"
23#include "Acts/EventData/BoundTrackParameters.hpp"
24#include "Acts/Utilities/Logger.hpp"
25
26// geometry
27#include "Acts/Geometry/GeometryContext.hpp"
28
29// magfield
30#include "Acts/MagneticField/MagneticFieldContext.hpp"
31#include "Acts/MagneticField/MagneticFieldProvider.hpp"
32
33// geometry
34#include <Acts/Geometry/TrackingGeometry.hpp>
35
36// propagation testing
37#include "Acts/MagneticField/ConstantBField.hpp"
38#include "Acts/Propagator/ActorList.hpp"
39#include "Acts/Propagator/EigenStepperDenseExtension.hpp"
40#include "Acts/Propagator/MaterialInteractor.hpp"
41#include "Acts/Propagator/Navigator.hpp"
42#include "Acts/Propagator/Propagator.hpp"
43#include "Acts/Propagator/StandardAborters.hpp"
44#include "Acts/Propagator/VoidNavigator.hpp"
45#include "Acts/Propagator/detail/SteppingLogger.hpp"
46#include "Acts/Surfaces/PerigeeSurface.hpp"
47#include "Acts/Utilities/Logger.hpp"
48
49// Kalman Filter
50
51// #include "Acts/EventData/Measurement.hpp"
52#include "Acts/EventData/MultiTrajectory.hpp"
53#include "Acts/EventData/MultiTrajectoryHelpers.hpp"
54#include "Acts/EventData/VectorTrackContainer.hpp"
55#include "Acts/Geometry/GeometryIdentifier.hpp"
56#include "Acts/TrackFinding/CombinatorialKalmanFilter.hpp"
57#include "Acts/TrackFinding/MeasurementSelector.hpp"
58#include "Acts/TrackFinding/TrackStateCreator.hpp"
59#include "Acts/TrackFitting/GainMatrixUpdater.hpp"
60#include "Acts/Utilities/CalibrationContext.hpp"
61
62//--- Refit with backward propagation ---//
63#include "Acts/TrackFitting/KalmanFitter.hpp"
64
65// GSF
66// #include "Acts/TrackFitting/GaussianSumFitter.hpp"
67#include "Acts/Propagator/MultiEigenStepperLoop.hpp"
68
69//--- Tracking ---//
70#include "Tracking/Event/Measurement.h"
71#include "Tracking/Event/Track.h"
72#include "Tracking/Reco/TrackExtrapolatorTool.h"
73#include "Tracking/Sim/IndexSourceLink.h"
74#include "Tracking/Sim/MeasurementCalibrator.h"
75#include "Tracking/Sim/TrackingUtils.h"
76
77//--- Interpolated magnetic field ---//
78#include "Tracking/Sim/BFieldXYZUtils.h"
79// mg Aug 2024 not sure if these are needed...
80using Updater = Acts::GainMatrixUpdater;
81
82using ActionList =
83 Acts::ActorList<Acts::detail::SteppingLogger, Acts::MaterialInteractor,
84 Acts::EndOfWorldReached>;
85
86using CkfPropagator = Acts::Propagator<Acts::EigenStepper<>, Acts::Navigator>;
87using ExtrapPropagator =
88 Acts::Propagator<Acts::EigenStepper<>, Acts::VoidNavigator>;
89using TrackContainer = Acts::TrackContainer<Acts::VectorTrackContainer,
90 Acts::VectorMultiTrajectory>;
91
92namespace tracking {
93namespace reco {
94
95class CKFProcessor final : public TrackingGeometryUser {
96 public:
103 CKFProcessor(const std::string& name, framework::Process& process);
104
106 virtual ~CKFProcessor() = default;
107
111 void onProcessStart() override;
112
119 void onNewRun(const ldmx::RunHeader& rh) override;
120
124 void onProcessEnd() override;
125
131 void configure(framework::config::Parameters& parameters) override;
132
138 void produce(framework::Event& event) override;
139
140 private:
141 // Make geoid -> source link map Measurements
142 auto makeGeoIdSourceLinkMap(const geo::TrackersTrackingGeometry& tg,
143 const std::vector<ldmx::Measurement>& ldmxsps)
144 -> std::unordered_multimap<Acts::GeometryIdentifier,
146
147 template <typename geometry_t, typename source_link_hash_t,
148 typename source_link_equality_t>
149 std::vector<std::vector<std::size_t>> computeSharedHits(
150 std::vector<ldmx::Track> tracks, std::vector<ldmx::Measurement> meas_coll,
151 geometry_t& tg, source_link_hash_t&& sourceLinkHash,
152 source_link_equality_t&& sourceLinkEquality) const;
153
154 // If we want to dump the tracking geometry
155 bool dumpobj_{false};
156
157 int pionstates_{10};
158
159 int nevents_{0};
160
161 // Processing time counter
162 double processing_time_{0.};
163
164 // time profiling
165 std::map<std::string, double> profiling_map_;
166
167 bool debug_acts_{false};
168
169 std::shared_ptr<Acts::PlaneSurface> target_surface_;
170 Acts::RotationMatrix3 surf_rotation_;
171 // Constant BField
172 double bfield_{0};
173 // Use constant bfield
174 bool const_b_field_{true};
175
176 // Remove stereo measurements
177 bool remove_stereo_{false};
178
179 // Use 2d measurements instead of 1D
180 bool use1_dmeasurements_{true};
181
182 // Minimum number of hits on tracks
183 int min_hits_{7};
184
185 // Stepping size (in mm)
186 double propagator_step_size_{200.};
187 int propagator_max_steps_{1000};
188
189 // The extrapolation surface
190 bool use_extrapolate_location_{true};
191 std::vector<double> extrapolate_location_{0., 0., 0.};
192 bool use_seed_perigee_{false};
193
194 // The measurement collection to use for track reconstruction
195 std::string measurement_collection_{"TaggerMeasurements"};
196
197 std::string sim_particles_coll_name_;
198 std::string sim_particles_event_passname_;
199
200 // Outlier removal pvalue
201 // The Chi2Cut is applied at filtering stage.
202 // 1DOF pvalues: 0.1 = 2.706 0.05 = 3.841 0.025 = 5.024 0.01 = 6.635 0.005
203 // = 7.879 The probability to reject a good measurement is pvalue The
204 // probability to reject an outlier is given in NIM A262 (1987) 444-450
205 double outlier_pval_;
206
207 // The output track collection
208 std::string out_trk_collection_{"Tracks"};
209
210 // The seed track collection
211 std::string seed_coll_name_{"seedTracks"};
212
213 // The interpolated bfield
214 std::string field_map_{""};
215
216 std::string input_pass_name_{""};
217
218 // The Propagator
219 std::unique_ptr<const CkfPropagator> propagator_;
220
221 // The CKF
222 std::unique_ptr<
223 const Acts::CombinatorialKalmanFilter<CkfPropagator, TrackContainer>>
224 ckf_;
225
226 // Track Extrapolator Tool (uses VoidNavigator to propagate freely to any
227 // surface)
228 std::unique_ptr<const ExtrapPropagator> propagator_extrap_;
229 std::shared_ptr<tracking::reco::TrackExtrapolatorTool<ExtrapPropagator>>
230 trk_extrap_;
231
232 // Zero-B CKF as fallback
233 std::unique_ptr<const CkfPropagator> propagator_zero_b_;
234 std::unique_ptr<
235 const Acts::CombinatorialKalmanFilter<CkfPropagator, TrackContainer>>
236 ckf_zero_b_;
237 std::unique_ptr<const ExtrapPropagator> propagator_extrap_zero_b_;
238 std::shared_ptr<tracking::reco::TrackExtrapolatorTool<ExtrapPropagator>>
239 trk_extrap_zero_b_;
240
241 // Const-B (1.5T) CKF as fallback for tagger
242 std::unique_ptr<const CkfPropagator> propagator_const_b_;
243 std::unique_ptr<
244 const Acts::CombinatorialKalmanFilter<CkfPropagator, TrackContainer>>
245 ckf_const_b_;
246 std::unique_ptr<const ExtrapPropagator> propagator_extrap_const_b_;
247 std::shared_ptr<tracking::reco::TrackExtrapolatorTool<ExtrapPropagator>>
248 trk_extrap_const_b_;
249
252 int ntracks_;
253 int eventnr_;
254
255 // CKF fallback statistics
256 int n_fieldmap_ckf_failed_tagger_{0};
257 int n_fieldmap_ckf_failed_recoil_{0};
258 int n_constb_ckf_recovered_tagger_{0};
259 int n_zerob_ckf_recovered_recoil_{0};
260
261 // Extrapolation fallback statistics
262 int n_fieldmap_target_extrap_failed_tagger_{0};
263 int n_constb_target_extrap_recovered_tagger_{0};
264 int n_fieldmap_target_extrap_failed_recoil_{0};
265 int n_zerob_target_extrap_recovered_recoil_{0};
266 int n_fieldmap_ecal_extrap_failed_recoil_{0};
267 int n_zerob_ecal_extrap_recovered_recoil_{0};
268
269 // BField Systematics
270 std::vector<double> map_offset_{
271 0.,
272 0.,
273 0.,
274 };
275
276 // Keep track on which system this processor is running on
277 bool tagger_tracking_{true};
278
279}; // CKFProcessor
280
281} // namespace reco
282} // 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.
Conditions object for random number seeds.
Implements an event buffer system for storing event data.
Definition Event.h:42
Class which represents the process under execution.
Definition Process.h:37
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:29
Run-specific configuration and data stored in its own output TTree alongside the event TTree in the o...
Definition RunHeader.h:57
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...