LDMX Software
GSFProcessor.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#include <random>
11
12//--- LDMX ---//
13#include "Tracking/Reco/TrackingGeometryUser.h"
14
15//--- ACTS ---//
16
17// Utils and Definitions
18
19// geometry
20
21// magfield
22
23// geometry
24#include <Acts/Geometry/TrackingGeometry.hpp>
25
26// propagation testing
27#include "Acts/Propagator/ActorList.hpp"
28#include "Acts/Propagator/MaterialInteractor.hpp"
29#include "Acts/Propagator/Navigator.hpp"
30#include "Acts/Propagator/Propagator.hpp"
31#include "Acts/Propagator/StandardAborters.hpp"
32#include "Acts/Propagator/VoidNavigator.hpp"
33#include "Acts/Propagator/detail/SteppingLogger.hpp"
34#include "Tracking/EigenStepper.h" // IWYU pragma: keep
35
36// Kalman Filter
37
38// #include "Acts/EventData/Measurement.hpp"
39#include "Acts/EventData/MultiTrajectory.hpp"
40#include "Acts/EventData/VectorTrackContainer.hpp"
41#include "Acts/Geometry/GeometryIdentifier.hpp"
42
43//--- Refit with backward propagation ---//
44
45// GSF
46#include "Acts/Propagator/MultiEigenStepperLoop.hpp"
47#include "Acts/TrackFitting/GaussianSumFitter.hpp"
48
49//--- Tracking ---//
50#include "Tracking/Reco/TrackExtrapolatorTool.h"
51
52//--- Interpolated magnetic field ---//
53#include "Tracking/Sim/BFieldXYZUtils.h"
54
55using ActionList =
56 Acts::ActorList<Acts::detail::SteppingLogger, Acts::MaterialInteractor,
57 Acts::EndOfWorldReached>;
58
59// using GsfPropagator = Acts::Propagator<
60// Acts::MultiEigenStepperLoop<
61// Acts::StepperExtensionList<
62// Acts::detail::GenericDefaultExtension<double> >,
63// Acts::WeightedComponentReducerLoop,
64// Acts::detail::VoidAuctioneer>,
65// Acts::Navigator>;
66
67using MultiStepper = Acts::MultiEigenStepperLoop<>;
68using Propagator = Acts::Propagator<Acts::EigenStepper<>, Acts::Navigator>;
69using GsfPropagator = Acts::Propagator<MultiStepper, Acts::Navigator>;
70using GsfExtrapPropagator =
71 Acts::Propagator<Acts::EigenStepper<>, Acts::VoidNavigator>;
72using GsfFitter =
73 Acts::GaussianSumFitter<GsfPropagator, Acts::VectorMultiTrajectory>;
74
75namespace tracking {
76namespace reco {
77
78class GSFProcessor final : public TrackingGeometryUser {
79 public:
86 GSFProcessor(const std::string& name, framework::Process& process);
87
89 virtual ~GSFProcessor() = default;
90
94 void onProcessStart() override;
95
102 void onNewRun(const ldmx::RunHeader& rh) override;
103
107 void onProcessEnd() override;
108
114 void configure(framework::config::Parameters& parameters) override;
115
121 void produce(framework::Event& event) override;
122
123 private:
124 // Forms the layer to acts map
125 // auto makeLayerSurfacesMap(std::shared_ptr<const Acts::TrackingGeometry>
126 // trackingGeometry) const -> std::unordered_map<unsigned int, const
127 // Acts::Surface*>;
128
129 // Make geoid -> source link map Measurements
130 // auto makeGeoIdSourceLinkMap(
131 // const geo::TrackersTrackingGeometry& tg,
132 // const std::vector<ldmx::Measurement > &ldmxsps) ->
133 // std::unordered_multimap<Acts::GeometryIdentifier,
134 // ActsExamples::IndexSourceLink>;
135
136 // If we want to dump the tracking geometry
137 // bool dumpobj_{false};
138 // int pionstates_{10};
139 // int nevents_{0};
140 // Processing time counter
141 // double processing_time_{0.};
142
143 int nevents_{0};
144 int n_input_tracks_{0};
145 int n_gsf_failed_{0};
146 int n_output_tracks_{0};
147 int n_target_extrap_failed_{0};
148 int n_ecal_extrap_failed_{0};
149 double processing_time_{0.};
150
151 // Fallback statistics
152 int n_fieldmap_gsf_failed_{0};
153 int n_fallback_gsf_recovered_{0};
154 int n_fieldmap_start_extrap_failed_{0};
155 int n_fallback_start_extrap_recovered_{0};
156 int n_fieldmap_target_extrap_failed_{0};
157 int n_fallback_target_extrap_recovered_{0};
158 int n_fieldmap_ecal_extrap_failed_{0};
159 int n_fallback_ecal_extrap_recovered_{0};
160 int n_start_extrap_failed_{0};
161
162 // refitting of tracks
163 // bool kf_refit_{false};
164 // bool gsf_refit_{false};
165
167 bool debug_{false};
168
170 std::default_random_engine generator_;
171
173 std::shared_ptr<std::normal_distribution<float>> normal_;
174
175 // Constant BField
176 // double bfield_{0};
177 // Use constant bfield
178 // bool const_b_field_{true};
179
180 // Remove stereo measurements
181 // bool remove_stereo_{false};
182
183 // Use 2d measurements instead of 1D
184 // bool use1Dmeasurements_{true};
185
186 // Minimum number of hits on tracks
187 // int min_hits_{7};
188
190 std::vector<double> extrapolate_location_{0., 0., 0.};
191 // bool use_seed_perigee_{false};
192
194 std::string measurement_collection_{"TaggerMeasurements"};
195
196 // double outlier_pval_{3.84};
197
199 std::string out_trk_collection_{"GSFTracks"};
200
201 // Select the hits using TrackID and pdg_id__
202
203 // int track_id_{-1};
204 // int pdg_id_{11};
205
206 // Mass for the propagator hypothesis in MeV
207 // double mass_{0.511};
208
210 std::string seed_coll_name_{"seedTracks"};
211
213 std::unique_ptr<const GsfFitter> gsf_;
214
216 std::unique_ptr<const GsfFitter> gsf_zero_b_;
217
219 std::unique_ptr<const GsfFitter> gsf_const_b_;
220
222 std::string track_collection_{"TaggerTracks"};
223
225 std::string meas_collection_{"DigiTaggerSimHits"};
226
228 std::string track_passname_;
229
231 std::string meas_passname_;
232
235
238
241
243 bool abort_on_error_{false};
244
247
249 double weight_cutoff_{1.0e-4};
250
253
256
258 std::string field_map_{""};
259
261 double bfield_{-1.5};
262
265
267 bool use_perigee_{false};
268
269 // Keep track on which system this processor is running on
270 bool tagger_tracking_{true};
271
273 double tagger_start_x_{-617.};
274
276 std::unique_ptr<const Propagator> propagator_;
277
279 std::unordered_map<unsigned int, const Acts::Surface*> layer_surface_map_;
280
281 // Track Extrapolator Tool (VoidNavigator to reach surfaces outside geometry)
282 std::unique_ptr<const GsfExtrapPropagator> propagator_extrap_;
283 std::shared_ptr<tracking::reco::TrackExtrapolatorTool<GsfExtrapPropagator>>
284 trk_extrap_;
285
286 // Zero-field extrapolator, fallback for the recoil
287 std::unique_ptr<const GsfExtrapPropagator> propagator_extrap_zero_b_;
288 std::shared_ptr<tracking::reco::TrackExtrapolatorTool<GsfExtrapPropagator>>
289 trk_extrap_zero_b_;
290
291 // Constant-field extrapolator, fallback for the tagger
292 std::unique_ptr<const GsfExtrapPropagator> propagator_extrap_const_b_;
293 std::shared_ptr<tracking::reco::TrackExtrapolatorTool<GsfExtrapPropagator>>
294 trk_extrap_const_b_;
295
298 std::shared_ptr<Acts::Surface> beam_origin_surface_;
299
301 std::shared_ptr<Acts::Surface> tagger_start_surface_;
302
304 std::shared_ptr<Acts::Surface> target_surface_;
305
307 std::shared_ptr<Acts::Surface> ecal_surface_;
308
309}; // GSFProcessor
310
311} // namespace reco
312} // 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
bool disable_all_material_handling_
Disable all material interactions during propagation.
std::shared_ptr< Acts::Surface > target_surface_
Target surface at z=0 mm (recoil track initialization, perigee output)
std::unique_ptr< const GsfFitter > gsf_
Gaussian Sum Fitter instance for track refitting.
virtual ~GSFProcessor()=default
Destructor.
double bfield_
Bz of the tagger fallback field, in Tesla.
std::unique_ptr< const GsfFitter > gsf_zero_b_
Zero-field GSF, fallback for the recoil.
void produce(framework::Event &event) override
Run the processor.
BFieldDistortion bfield_distortion_
Mis-placement of the reconstruction field; must match the CKF's.
bool debug_
Enable verbose debug output logging.
std::string track_collection_
Collection name for input tracks to be refit.
size_t max_components_
Maximum number of mixture components in GSF fit.
std::string meas_collection_
Collection name for measurements associated with tracks.
bool abort_on_error_
Abort fit if any error occurs (strict error handling)
std::string seed_coll_name_
Collection name for seed tracks (currently unused)
std::string meas_passname_
Pass name for measurement collection in event.
void onProcessEnd() override
Callback for the EventProcessor to take any necessary action when the processing of events finishes,...
double weight_cutoff_
Weight threshold below which mixture components are dropped.
std::string field_map_
Path to magnetic field map file.
std::unordered_map< unsigned int, const Acts::Surface * > layer_surface_map_
Layer ID to ACTS Surface mapping for hit surface lookup.
std::shared_ptr< Acts::Surface > tagger_start_surface_
Tagger GSF start surface at x=tagger_start_x_ in ACTS.
std::string measurement_collection_
Collection name for input measurements.
std::shared_ptr< std::normal_distribution< float > > normal_
Normal distribution for smearing measurements.
void configure(framework::config::Parameters &parameters) override
Configure the processor using the given user specified parameters.
int propagator_max_steps_
Maximum number of propagation steps before aborting.
bool use_perigee_
Use perigee parameterization for tracks.
std::vector< double > extrapolate_location_
Location to extrapolate tracks to (x, y, z in mm)
GSFProcessor(const std::string &name, framework::Process &process)
Constructor.
void onProcessStart() override
Callback for the EventProcessor to take any necessary action when the processing of events starts,...
void onNewRun(const ldmx::RunHeader &rh) override
onNewRun is the first function called for each processor after the conditions are fully configured an...
std::string track_collection_event_passname_
Pass name qualifier for track collection event key.
std::unique_ptr< const Propagator > propagator_
Propagator for track extrapolation using eigen stepper.
std::default_random_engine generator_
Random number generator for smearing operations.
double propagator_step_size_
Step size for track propagation in mm.
std::shared_ptr< Acts::Surface > beam_origin_surface_
Beam origin surface at z=-700 mm (tagger post-fit extrapolation via VoidNavigator)
std::string track_passname_
Pass name for track collection in event.
std::shared_ptr< Acts::Surface > ecal_surface_
ECAL surface at z=240.5 mm (ECAL scoring plane for recoil tracking)
std::unique_ptr< const GsfFitter > gsf_const_b_
Constant-field (bfield_) GSF, fallback for the tagger.
std::string meas_collection_event_passname_
Pass name qualifier for measurement collection event key.
double tagger_start_x_
ACTS x of the tagger GSF start surface [mm].
std::string out_trk_collection_
Collection name for output GSF-refitted tracks.
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...