LDMX Software
GSFProcessor.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/BoundTrackParameters.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/ActorList.hpp"
38#include "Acts/Propagator/EigenStepperDenseExtension.hpp"
39#include "Acts/Propagator/MaterialInteractor.hpp"
40#include "Acts/Propagator/Navigator.hpp"
41#include "Acts/Propagator/Propagator.hpp"
42#include "Acts/Propagator/StandardAborters.hpp"
43#include "Acts/Propagator/VoidNavigator.hpp"
44#include "Acts/Propagator/detail/SteppingLogger.hpp"
45#include "Acts/Surfaces/PerigeeSurface.hpp"
46#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/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/Propagator/MultiEigenStepperLoop.hpp"
66#include "Acts/TrackFitting/BetheHeitlerApprox.hpp"
67#include "Acts/TrackFitting/GaussianSumFitter.hpp"
68#include "Acts/TrackFitting/GsfMixtureReduction.hpp"
69
70//--- Tracking ---//
71#include "Tracking/Event/Measurement.h"
72#include "Tracking/Event/Track.h"
73#include "Tracking/Reco/TrackExtrapolatorTool.h"
74#include "Tracking/Sim/IndexSourceLink.h"
75#include "Tracking/Sim/MeasurementCalibrator.h"
76#include "Tracking/Sim/TrackingUtils.h"
77
78//--- Interpolated magnetic field ---//
79#include "Tracking/Sim/BFieldXYZUtils.h"
80
81using ActionList =
82 Acts::ActorList<Acts::detail::SteppingLogger, Acts::MaterialInteractor,
83 Acts::EndOfWorldReached>;
84
85// using GsfPropagator = Acts::Propagator<
86// Acts::MultiEigenStepperLoop<
87// Acts::StepperExtensionList<
88// Acts::detail::GenericDefaultExtension<double> >,
89// Acts::WeightedComponentReducerLoop,
90// Acts::detail::VoidAuctioneer>,
91// Acts::Navigator>;
92
93using MultiStepper = Acts::MultiEigenStepperLoop<>;
94using Propagator = Acts::Propagator<Acts::EigenStepper<>, Acts::Navigator>;
95using GsfPropagator = Acts::Propagator<MultiStepper, Acts::Navigator>;
96using GsfExtrapPropagator =
97 Acts::Propagator<Acts::EigenStepper<>, Acts::VoidNavigator>;
98
99namespace tracking {
100namespace reco {
101
102class GSFProcessor final : public TrackingGeometryUser {
103 public:
110 GSFProcessor(const std::string& name, framework::Process& process);
111
113 virtual ~GSFProcessor() = default;
114
118 void onProcessStart() override;
119
126 void onNewRun(const ldmx::RunHeader& rh) override;
127
131 void onProcessEnd() override;
132
138 void configure(framework::config::Parameters& parameters) override;
139
145 void produce(framework::Event& event) override;
146
147 private:
148 // Forms the layer to acts map
149 // auto makeLayerSurfacesMap(std::shared_ptr<const Acts::TrackingGeometry>
150 // trackingGeometry) const -> std::unordered_map<unsigned int, const
151 // Acts::Surface*>;
152
153 // Make geoid -> source link map Measurements
154 // auto makeGeoIdSourceLinkMap(
155 // const geo::TrackersTrackingGeometry& tg,
156 // const std::vector<ldmx::Measurement > &ldmxsps) ->
157 // std::unordered_multimap<Acts::GeometryIdentifier,
158 // ActsExamples::IndexSourceLink>;
159
160 // If we want to dump the tracking geometry
161 // bool dumpobj_{false};
162 // int pionstates_{10};
163 // int nevents_{0};
164 // Processing time counter
165 // double processing_time_{0.};
166
167 int nevents_{0};
168 int n_input_tracks_{0};
169 int n_gsf_failed_{0};
170 int n_output_tracks_{0};
171 int n_target_extrap_failed_{0};
172 int n_ecal_extrap_failed_{0};
173 double processing_time_{0.};
174
175 // refitting of tracks
176 // bool kf_refit_{false};
177 // bool gsf_refit_{false};
178
180 bool debug_{false};
181
183 std::default_random_engine generator_;
184
186 std::shared_ptr<std::normal_distribution<float>> normal_;
187
188 // Constant BField
189 // double bfield_{0};
190 // Use constant bfield
191 // bool const_b_field_{true};
192
193 // Remove stereo measurements
194 // bool remove_stereo_{false};
195
196 // Use 2d measurements instead of 1D
197 // bool use1Dmeasurements_{true};
198
199 // Minimum number of hits on tracks
200 // int min_hits_{7};
201
203 std::vector<double> extrapolate_location_{0., 0., 0.};
204 // bool use_seed_perigee_{false};
205
207 std::string measurement_collection_{"TaggerMeasurements"};
208
209 // double outlier_pval_{3.84};
210
212 std::string out_trk_collection_{"GSFTracks"};
213
214 // Select the hits using TrackID and pdg_id__
215
216 // int track_id_{-1};
217 // int pdg_id_{11};
218
219 // Mass for the propagator hypothesis in MeV
220 // double mass_{0.511};
221
223 std::string seed_coll_name_{"seedTracks"};
224
226 std::unique_ptr<
227 const Acts::GaussianSumFitter<GsfPropagator, Acts::VectorMultiTrajectory>>
229
231 std::string track_collection_{"TaggerTracks"};
232
234 std::string meas_collection_{"DigiTaggerSimHits"};
235
237 std::string track_passname_;
238
240 std::string meas_passname_;
241
244
247
250
252 bool abort_on_error_{false};
253
256
258 double weight_cutoff_{1.0e-4};
259
262
265
267 std::string field_map_{""};
268
270 bool use_perigee_{false};
271
272 // Keep track on which system this processor is running on
273 bool tagger_tracking_{true};
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
288 std::shared_ptr<Acts::Surface> beam_origin_surface_;
289
292 std::shared_ptr<Acts::Surface> tagger_start_surface_;
293
295 std::shared_ptr<Acts::Surface> target_surface_;
296
298 std::shared_ptr<Acts::Surface> ecal_surface_;
299
300}; // GSFProcessor
301
302} // namespace reco
303} // 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
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)
virtual ~GSFProcessor()=default
Destructor.
std::unique_ptr< const Acts::GaussianSumFitter< GsfPropagator, Acts::VectorMultiTrajectory > > gsf_
Gaussian Sum Fitter instance for track refitting.
void produce(framework::Event &event) override
Run the processor.
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≈-617mm in ACTS (1mm inside tagger volume outer boundary ~-618mm,...
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::string meas_collection_event_passname_
Pass name qualifier for measurement collection event key.
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...