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 ---//
14#include "Tracking/Reco/TrackingGeometryUser.h"
15
16//--- ACTS ---//
17
18// Utils and Definitions
19#include "Acts/Definitions/Common.hpp"
20#include "Acts/Definitions/TrackParametrization.hpp"
21#include "Acts/Definitions/Units.hpp"
22#include "Acts/EventData/TrackParameters.hpp"
23#include "Acts/Utilities/Logger.hpp"
24
25// geometry
26#include "Acts/Geometry/GeometryContext.hpp"
27
28// magfield
29#include "Acts/MagneticField/MagneticFieldContext.hpp"
30#include "Acts/MagneticField/MagneticFieldProvider.hpp"
31
32// geometry
33#include <Acts/Geometry/TrackingGeometry.hpp>
34
35// propagation testing
36#include "Acts/MagneticField/ConstantBField.hpp"
37#include "Acts/Propagator/AbortList.hpp"
38#include "Acts/Propagator/ActionList.hpp"
39#include "Acts/Propagator/DenseEnvironmentExtension.hpp"
40#include "Acts/Propagator/EigenStepper.hpp"
41#include "Acts/Propagator/MaterialInteractor.hpp"
42#include "Acts/Propagator/Navigator.hpp"
43#include "Acts/Propagator/Propagator.hpp"
44#include "Acts/Propagator/StandardAborters.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/TrackFitting/GainMatrixSmoother.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;
81using Smoother = Acts::GainMatrixSmoother;
82
83using ActionList =
84 Acts::ActionList<Acts::detail::SteppingLogger, Acts::MaterialInteractor>;
85using AbortList = Acts::AbortList<Acts::EndOfWorldReached>;
86
87using CkfPropagator = Acts::Propagator<Acts::EigenStepper<>, Acts::Navigator>;
88using TrackContainer = Acts::TrackContainer<Acts::VectorTrackContainer,
89 Acts::VectorMultiTrajectory>;
90
91namespace tracking {
92namespace reco {
93
94class CKFProcessor final : public TrackingGeometryUser {
95 public:
102 CKFProcessor(const std::string &name, framework::Process &process);
103
105 virtual ~CKFProcessor() = default;
106
110 void onProcessStart() override;
111
118 void onNewRun(const ldmx::RunHeader &rh) override;
119
123 void onProcessEnd() override;
124
130 void configure(framework::config::Parameters &parameters) override;
131
137 void produce(framework::Event &event) override;
138
139 private:
140 // Make geoid -> source link map Measurements
141 auto makeGeoIdSourceLinkMap(const geo::TrackersTrackingGeometry &tg,
142 const std::vector<ldmx::Measurement> &ldmxsps)
143 -> std::unordered_multimap<Acts::GeometryIdentifier,
145
146 template <typename geometry_t, typename source_link_hash_t,
147 typename source_link_equality_t>
148 std::vector<std::vector<std::size_t>> computeSharedHits(
149 std::vector<ldmx::Track> tracks, std::vector<ldmx::Measurement> meas_coll,
150 geometry_t &tg, source_link_hash_t &&sourceLinkHash,
151 source_link_equality_t &&sourceLinkEquality) const;
152
153 // If we want to dump the tracking geometry
154 bool dumpobj_{false};
155
156 int pionstates_{10};
157
158 int nevents_{0};
159
160 // Processing time counter
161 double processing_time_{0.};
162
163 // time profiling
164 std::map<std::string, double> profiling_map_;
165
166 bool debug_acts_{false};
167
168 std::shared_ptr<Acts::PlaneSurface> target_surface_;
169 Acts::RotationMatrix3 surf_rotation_;
170 // Constant BField
171 double bfield_{0};
172 // Use constant bfield
173 bool const_b_field_{true};
174
175 // Remove stereo measurements
176 bool remove_stereo_{false};
177
178 // Use 2d measurements instead of 1D
179 bool use1_dmeasurements_{true};
180
181 // Minimum number of hits on tracks
182 int min_hits_{7};
183
184 // Stepping size (in mm)
185 double propagator_step_size_{200.};
186 int propagator_max_steps_{1000};
187
188 // The extrapolation surface
189 bool use_extrapolate_location_{true};
190 std::vector<double> extrapolate_location_{0., 0., 0.};
191 bool use_seed_perigee_{false};
192
193 // The measurement collection to use for track reconstruction
194 std::string measurement_collection_{"TaggerMeasurements"};
195
196 std::string sim_particles_pass_name_;
197 std::string sim_particles_event_passname_;
198
199 // Outlier removal pvalue
200 // The Chi2Cut is applied at filtering stage.
201 // 1DOF pvalues: 0.1 = 2.706 0.05 = 3.841 0.025 = 5.024 0.01 = 6.635 0.005
202 // = 7.879 The probability to reject a good measurement is pvalue The
203 // probability to reject an outlier is given in NIM A262 (1987) 444-450
204 double outlier_pval_{3.84};
205
206 // The output track collection
207 std::string out_trk_collection_{"Tracks"};
208
209 // The seed track collection
210 std::string seed_coll_name_{"seedTracks"};
211
212 // The interpolated bfield
213 std::string field_map_{""};
214
215 std::string input_pass_name_{""};
216
217 // The Propagator
218 std::unique_ptr<const CkfPropagator> propagator_;
219
220 // The CKF
221 std::unique_ptr<
222 const Acts::CombinatorialKalmanFilter<CkfPropagator, TrackContainer>>
223 ckf_;
224
225 // Track Extrapolator Tool
226 std::shared_ptr<tracking::reco::TrackExtrapolatorTool<CkfPropagator>>
227 trk_extrap_;
228
230 int nseeds_{0};
231 int ntracks_{0};
232 int eventnr_{0};
233
234 // BField Systematics
235 std::vector<double> map_offset_{
236 0.,
237 0.,
238 0.,
239 };
240
241 // Keep track on which system this processor is running on
242 bool tagger_tracking_{true};
243
244}; // CKFProcessor
245
246} // namespace reco
247} // namespace tracking
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:36
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...