LDMX Software
CKFProcessor.h
1#pragma once
2
3//--- Framework ---//
4#include "Framework/Configure/Parameters.h"
7
8//--- C++ ---//
9#include <memory>
10#include <random>
11
12//--- LDMX ---//
13#include "Tracking/Reco/TrackingGeometryUser.h"
14
15//--- ACTS ---//
16
17// Utils and Definitions
18#include "Acts/Definitions/Common.hpp"
19#include "Acts/Definitions/TrackParametrization.hpp"
20#include "Acts/Definitions/Units.hpp"
21#include "Acts/EventData/TrackParameters.hpp"
22#include "Acts/Utilities/Logger.hpp"
23
24// geometry
25#include "Acts/Geometry/GeometryContext.hpp"
26
27// magfield
28#include "Acts/MagneticField/MagneticFieldContext.hpp"
29#include "Acts/MagneticField/MagneticFieldProvider.hpp"
30
31// geometry
32#include <Acts/Geometry/TrackingGeometry.hpp>
33
34// propagation testing
35#include "Acts/MagneticField/ConstantBField.hpp"
36#include "Acts/Propagator/AbortList.hpp"
37#include "Acts/Propagator/ActionList.hpp"
38#include "Acts/Propagator/DenseEnvironmentExtension.hpp"
39#include "Acts/Propagator/EigenStepper.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/detail/SteppingLogger.hpp"
45#include "Acts/Surfaces/PerigeeSurface.hpp"
46#include "Acts/Utilities/Logger.hpp"
47
48// Kalman Filter
49
50//#include "Acts/EventData/Measurement.hpp"
51#include "Acts/EventData/MultiTrajectory.hpp"
52#include "Acts/EventData/MultiTrajectoryHelpers.hpp"
53#include "Acts/EventData/VectorTrackContainer.hpp"
54#include "Acts/Geometry/GeometryIdentifier.hpp"
55#include "Acts/TrackFinding/CombinatorialKalmanFilter.hpp"
56#include "Acts/TrackFinding/MeasurementSelector.hpp"
57#include "Acts/TrackFitting/GainMatrixSmoother.hpp"
58#include "Acts/TrackFitting/GainMatrixUpdater.hpp"
59#include "Acts/Utilities/CalibrationContext.hpp"
60
61//--- Refit with backward propagation ---//
62#include "Acts/TrackFitting/KalmanFitter.hpp"
63
64// GSF
65//#include "Acts/TrackFitting/GaussianSumFitter.hpp"
66#include "Acts/Propagator/MultiEigenStepperLoop.hpp"
67
68//--- Tracking ---//
69#include "Tracking/Event/Measurement.h"
70#include "Tracking/Event/Track.h"
71#include "Tracking/Reco/TrackExtrapolatorTool.h"
72#include "Tracking/Sim/IndexSourceLink.h"
73#include "Tracking/Sim/MeasurementCalibrator.h"
74#include "Tracking/Sim/TrackingUtils.h"
75
76//--- Interpolated magnetic field ---//
77#include "Tracking/Sim/BFieldXYZUtils.h"
78// mg Aug 2024 not sure if these are needed...
79using Updater = Acts::GainMatrixUpdater;
80using Smoother = Acts::GainMatrixSmoother;
81
82using ActionList =
83 Acts::ActionList<Acts::detail::SteppingLogger, Acts::MaterialInteractor>;
84using AbortList = Acts::AbortList<Acts::EndOfWorldReached>;
85
86using CkfPropagator = Acts::Propagator<Acts::EigenStepper<>, Acts::Navigator>;
87using TrackContainer = Acts::TrackContainer<Acts::VectorTrackContainer,
88 Acts::VectorMultiTrajectory>;
89
90namespace tracking {
91namespace reco {
92
93class CKFProcessor final : public TrackingGeometryUser {
94 public:
101 CKFProcessor(const std::string &name, framework::Process &process);
102
105
109 void onProcessStart() override;
110
117 void onNewRun(const ldmx::RunHeader &rh) override;
118
122 void onProcessEnd() override;
123
129 void configure(framework::config::Parameters &parameters) override;
130
136 void produce(framework::Event &event) override;
137
138 private:
139 // Make geoid -> source link map Measurements
140 auto makeGeoIdSourceLinkMap(const geo::TrackersTrackingGeometry &tg,
141 const std::vector<ldmx::Measurement> &ldmxsps)
142 -> std::unordered_multimap<Acts::GeometryIdentifier,
144
145 template <typename geometry_t, typename source_link_hash_t,
146 typename source_link_equality_t>
147 std::vector<std::vector<std::size_t>> computeSharedHits(
148 std::vector<ldmx::Track> tracks, std::vector<ldmx::Measurement> meas_coll,
149 geometry_t &tg, source_link_hash_t &&sourceLinkHash,
150 source_link_equality_t &&sourceLinkEquality) const;
151
152 // If we want to dump the tracking geometry
153 bool dumpobj_{false};
154
155 int pionstates_{10};
156
157 int nevents_{0};
158
159 // Processing time counter
160 double processing_time_{0.};
161
162 // time profiling
163 std::map<std::string, double> profiling_map_;
164
165 bool debug_acts_{false};
166
167 std::shared_ptr<Acts::PlaneSurface> target_surface;
168 Acts::RotationMatrix3 surf_rotation;
169 // Constant BField
170 double bfield_{0};
171 // Use constant bfield
172 bool const_b_field_{true};
173
174 // Remove stereo measurements
175 bool remove_stereo_{false};
176
177 // Use 2d measurements instead of 1D
178 bool use1Dmeasurements_{true};
179
180 // Minimum number of hits on tracks
181 int min_hits_{7};
182
183 // Stepping size (in mm)
184 double propagator_step_size_{200.};
185 int propagator_maxSteps_{1000};
186
187 // The extrapolation surface
188 bool use_extrapolate_location_{true};
189 std::vector<double> extrapolate_location_{0., 0., 0.};
190 bool use_seed_perigee_{false};
191
192 // The measurement collection to use for track reconstruction
193 std::string measurement_collection_{"TaggerMeasurements"};
194
195 // Outlier removal pvalue
196 // The Chi2Cut is applied at filtering stage.
197 // 1DOF pvalues: 0.1 = 2.706 0.05 = 3.841 0.025 = 5.024 0.01 = 6.635 0.005
198 // = 7.879 The probability to reject a good measurement is pvalue The
199 // probability to reject an outlier is given in NIM A262 (1987) 444-450
200 double outlier_pval_{3.84};
201
202 // The output track collection
203 std::string out_trk_collection_{"Tracks"};
204
205 // The seed track collection
206 std::string seed_coll_name_{"seedTracks"};
207
208 // The interpolated bfield
209 std::string field_map_{""};
210
211 std::string input_pass_name_{""};
212
213 // The Propagator
214 std::unique_ptr<const CkfPropagator> propagator_;
215
216 // The CKF
217 std::unique_ptr<
218 const Acts::CombinatorialKalmanFilter<CkfPropagator, TrackContainer>>
219 ckf_;
220
221 // Track Extrapolator Tool
222 std::shared_ptr<tracking::reco::TrackExtrapolatorTool<CkfPropagator>>
223 trk_extrap_;
224
226 int nseeds_{0};
227 int ntracks_{0};
228 int eventnr_{0};
229
230 // BField Systematics
231 std::vector<double> map_offset_{
232 0.,
233 0.,
234 0.,
235 };
236
237 // Keep track on which system this processor is running on
238 bool taggerTracking_{true};
239
240}; // CKFProcessor
241
242} // namespace reco
243} // 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:41
Class which represents the process under execution.
Definition Process.h:36
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:27
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,...
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...