LDMX Software
tracking::reco::GSFProcessor Class Referencefinal

Public Member Functions

 GSFProcessor (const std::string &name, framework::Process &process)
 Constructor.
 
virtual ~GSFProcessor ()=default
 Destructor.
 
void onProcessStart () override
 Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.
 
void onNewRun (const ldmx::RunHeader &rh) override
 onNewRun is the first function called for each processor after the conditions are fully configured and accessible.
 
void onProcessEnd () override
 Callback for the EventProcessor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.
 
void configure (framework::config::Parameters &parameters) override
 Configure the processor using the given user specified parameters.
 
void produce (framework::Event &event) override
 Run the processor.
 
- Public Member Functions inherited from tracking::reco::TrackingGeometryUser
 TrackingGeometryUser (const std::string &name, framework::Process &p)
 
- Public Member Functions inherited from framework::Producer
 Producer (const std::string &name, Process &process)
 Class constructor.
 
virtual void process (Event &event) final
 Processing an event for a Producer is calling produce.
 
- Public Member Functions inherited from framework::EventProcessor
 DECLARE_FACTORY (EventProcessor, EventProcessor *, const std::string &, Process &)
 declare that we have a factory for this class
 
 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()=default
 Class destructor.
 
virtual void beforeNewRun (ldmx::RunHeader &run_header)
 Callback for Producers to add parameters to the run header before conditions are initialized.
 
virtual void onFileOpen (EventFile &event_file)
 Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened.
 
virtual void onFileClose (EventFile &event_file)
 Callback for the EventProcessor to take any necessary action when a event input ROOT file is closed.
 
template<class T >
const T & getCondition (const std::string &condition_name)
 Access a conditions object for the current event.
 
TDirectory * getHistoDirectory ()
 Access/create a directory in the histogram file for this event processor to create histograms and analysis tuples.
 
void setStorageHint (framework::StorageControl::Hint hint)
 Mark the current event as having the given storage control hint from this module_.
 
void setStorageHint (framework::StorageControl::Hint hint, const std::string &purposeString)
 Mark the current event as having the given storage control hint from this module and the given purpose string.
 
int getLogFrequency () const
 Get the current logging frequency from the process.
 
int getRunNumber () const
 Get the run number from the process.
 
std::string getName () const
 Get the processor name.
 
void createHistograms (const std::vector< framework::config::Parameters > &histos)
 Internal function which is used to create histograms passed from the python configuration @parma histos vector of Parameters that configure histograms to create.
 

Private Attributes

std::map< std::string, double > profiling_map_
 Time profiling data for performance analysis.
 
bool debug_ {false}
 Enable verbose debug output logging.
 
std::default_random_engine generator_
 Random number generator for smearing operations.
 
std::shared_ptr< std::normal_distribution< float > > normal_
 Normal distribution for smearing measurements.
 
std::vector< double > extrapolate_location_ {0., 0., 0.}
 Location to extrapolate tracks to (x, y, z in mm)
 
std::string measurement_collection_ {"TaggerMeasurements"}
 Collection name for input measurements.
 
std::string out_trk_collection_ {"GSFTracks"}
 Collection name for output GSF-refitted tracks.
 
std::string seed_coll_name_ {"seedTracks"}
 Collection name for seed tracks (currently unused)
 
std::unique_ptr< const Acts::GaussianSumFitter< GsfPropagator, BetheHeitlerApprox, Acts::VectorMultiTrajectory > > gsf_
 Gaussian Sum Fitter instance for track refitting.
 
std::string track_collection_ {"TaggerTracks"}
 Collection name for input tracks to be refit.
 
std::string meas_collection_ {"DigiTaggerSimHits"}
 Collection name for measurements associated with tracks.
 
std::string track_passname_
 Pass name for track collection in event.
 
std::string meas_passname_
 Pass name for measurement collection in event.
 
std::string track_collection_event_passname_
 Pass name qualifier for track collection event key.
 
std::string meas_collection_event_passname_
 Pass name qualifier for measurement collection event key.
 
size_t max_components_ {4}
 Maximum number of mixture components in GSF fit.
 
bool abort_on_error_ {false}
 Abort fit if any error occurs (strict error handling)
 
bool disable_all_material_handling_ {false}
 Disable all material interactions during propagation.
 
double weight_cutoff_ {1.0e-4}
 Weight threshold below which mixture components are dropped.
 
double propagator_step_size_ {200.}
 Step size for track propagation in mm.
 
int propagator_max_steps_ {1000}
 Maximum number of propagation steps before aborting.
 
std::string field_map_ {""}
 Path to magnetic field map file.
 
bool use_perigee_ {false}
 Use perigee parameterization for tracks.
 
bool tagger_tracking_ {true}
 
std::unique_ptr< const Propagator > propagator_
 Propagator for track extrapolation using eigen stepper.
 
std::unordered_map< unsigned int, const Acts::Surface * > layer_surface_map_
 Layer ID to ACTS Surface mapping for hit surface lookup.
 
std::shared_ptr< tracking::reco::TrackExtrapolatorTool< Propagator > > trk_extrap_
 
std::shared_ptr< Acts::Surface > beam_origin_surface_
 Beam origin surface at z=-700 mm (tagger track initialization)
 
std::shared_ptr< Acts::Surface > target_surface_
 Target surface at z=0 mm (recoil track initialization, perigee output)
 
std::shared_ptr< Acts::Surface > ecal_surface_
 ECAL surface at z=240.5 mm (ECAL scoring plane for recoil tracking)
 

Additional Inherited Members

- Protected Member Functions inherited from tracking::reco::TrackingGeometryUser
const Acts::GeometryContext & geometryContext ()
 
const Acts::MagneticFieldContext & magneticFieldContext ()
 
const Acts::CalibrationContext & calibrationContext ()
 
const geo::TrackersTrackingGeometrygeometry ()
 
- Protected Member Functions inherited from framework::EventProcessor
void abortEvent ()
 Abort the event immediately.
 
- Protected Attributes inherited from framework::EventProcessor
HistogramPool histograms_
 helper object for making and filling histograms
 
NtupleManagerntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger the_log_
 The logger for this EventProcessor.
 

Detailed Description

Definition at line 102 of file GSFProcessor.h.

Constructor & Destructor Documentation

◆ GSFProcessor()

tracking::reco::GSFProcessor::GSFProcessor ( const std::string & name,
framework::Process & process )

Constructor.

Parameters
nameThe name of the instance of this object.
processThe process running this producer.

Definition at line 10 of file GSFProcessor.cxx.

11 : TrackingGeometryUser(name, process) {}
virtual void process(Event &event) final
Processing an event for a Producer is calling produce.

Member Function Documentation

◆ configure()

void tracking::reco::GSFProcessor::configure ( framework::config::Parameters & parameters)
overridevirtual

Configure the processor using the given user specified parameters.

Parameters
parametersSet of parameters used to configure this processor.

Reimplemented from framework::EventProcessor.

Definition at line 129 of file GSFProcessor.cxx.

129 {
131 parameters.get<std::string>("out_trk_collection", "GSFTracks");
132
134 parameters.get<std::string>("track_collection", "TaggerTracks");
136 parameters.get<std::string>("meas_collection", "DigiTaggerSimHits");
137
138 track_passname_ = parameters.get<std::string>("track_passname");
139 meas_passname_ = parameters.get<std::string>("meas_passname");
141 parameters.get<std::string>("track_collection_event_passname");
143 parameters.get<std::string>("meas_collection_event_passname");
144
145 max_components_ = parameters.get<int>("maxComponents", 4);
146 abort_on_error_ = parameters.get<bool>("abortOnError", false);
148 parameters.get<bool>("disableAllMaterialHandling", false);
149 weight_cutoff_ = parameters.get<double>("weight_cutoff_", 1.0e-4);
150
151 propagator_max_steps_ = parameters.get<int>("propagator_maxSteps", 10000);
152 propagator_step_size_ = parameters.get<double>("propagator_step_size", 200.);
153 field_map_ = parameters.get<std::string>("field_map");
154 use_perigee_ = parameters.get<bool>("usePerigee", false);
155
156 debug_ = parameters.get<bool>("debug", false);
157 tagger_tracking_ = parameters.get<bool>("taggerTracking", true);
158
159 // final_reduction_method_ =
160 // parameters.get<double>("finalReductionMethod",);
161} // end of configure()
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
bool disable_all_material_handling_
Disable all material interactions during propagation.
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 meas_passname_
Pass name for measurement collection in event.
double weight_cutoff_
Weight threshold below which mixture components are dropped.
std::string field_map_
Path to magnetic field map file.
int propagator_max_steps_
Maximum number of propagation steps before aborting.
bool use_perigee_
Use perigee parameterization for tracks.
std::string track_collection_event_passname_
Pass name qualifier for track collection event key.
double propagator_step_size_
Step size for track propagation in mm.
std::string track_passname_
Pass name for track collection in event.
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.

References abort_on_error_, debug_, disable_all_material_handling_, field_map_, framework::config::Parameters::get(), max_components_, meas_collection_, meas_collection_event_passname_, meas_passname_, out_trk_collection_, propagator_max_steps_, propagator_step_size_, track_collection_, track_collection_event_passname_, track_passname_, use_perigee_, and weight_cutoff_.

◆ onNewRun()

void tracking::reco::GSFProcessor::onNewRun ( const ldmx::RunHeader & rh)
overridevirtual

onNewRun is the first function called for each processor after the conditions are fully configured and accessible.

This is where you could create single-processors, multi-event calculation objects.

Reimplemented from framework::EventProcessor.

Definition at line 13 of file GSFProcessor.cxx.

13 {
14 beam_origin_surface_ = tracking::sim::utils::unboundSurface(-700);
15 target_surface_ = tracking::sim::utils::unboundSurface(0.);
16 ecal_surface_ = tracking::sim::utils::unboundSurface(240.5);
17
18 // Custom transformation of the interpolated bfield map
19 bool debug_transform = false;
20 auto transform_pos = [debug_transform](const Acts::Vector3& pos_) {
21 Acts::Vector3 rot_pos;
22 rot_pos(0) = pos_(1);
23 rot_pos(1) = pos_(2);
24 rot_pos(2) = pos_(0) + DIPOLE_OFFSET;
25
26 // Apply A rotation around the center of the magnet. (I guess offset first
27 // and then rotation)
28
29 if (debug_transform) {
30 std::cout << "PF::DEFAULT3 TRANSFORM\n";
31 std::cout << "PF::Check:: transforming Pos\n";
32 std::cout << pos_;
33 std::cout << "\nTO\n";
34 std::cout << rot_pos << "\n";
35 }
36
37 return rot_pos;
38 };
39
40 // Reminder about coordinate system:
41 // acts x = global z
42 // acts y = global x
43 // acts z = global y
44 Acts::RotationMatrix3 rotation = Acts::RotationMatrix3::Identity();
45 double scale = 1.;
46
47 auto transform_b_field = [rotation, scale, debug_transform](
48 const Acts::Vector3& field,
49 const Acts::Vector3& /*pos_*/) {
50 // Rotate the field in tracking coordinates
51 Acts::Vector3 rot_field;
52 rot_field(0) = field(2);
53 rot_field(1) = field(0);
54 rot_field(2) = field(1);
55
56 // Scale the field
57 rot_field = scale * rot_field;
58
59 // Rotate the field
60 rot_field = rotation * rot_field;
61
62 // A distortion scaled by position.
63
64 if (debug_transform) {
65 std::cout << "PF::DEFAULT3 TRANSFORM\n";
66 std::cout << "PF::Check:: transforming\n";
67 std::cout << field;
68 std::cout << "\nTO\n";
69 std::cout << rot_field << "\n";
70 }
71
72 return rot_field;
73 };
74
75 // Setup a interpolated bfield map
76 const auto map = std::make_shared<InterpolatedMagneticField3>(
77 loadDefaultBField(field_map_,
78 // default_transformPos,
79 // default_transformBField));
80 transform_pos, transform_b_field));
81
82 auto acts_logging_level = Acts::Logging::FATAL;
83
84 if (debug_) acts_logging_level = Acts::Logging::VERBOSE;
85
86 // Setup the GSF Fitter
87
88 // Stepper
89 // Acts::MixtureReductionMethod finalReductionMethod;
90 // const auto multi_stepper = Acts::MultiEigenStepperLoop{map};
91
92 // Acts::ComponentMergeMethod reductionMethod =
93 // Acts::ComponentMergeMethod::eMaxWeight;
94 // Acts::MultiEigenStepperLoop multi_stepper(
95 // map, reductionMethod,
96 // Acts::getDefaultLogger("GSF_STEP", acts_loggingLevel));
97
98 Acts::MultiEigenStepperLoop multi_stepper(map);
99 // Detailed Stepper
100
101 // Acts::MultiEigenStepperLoop multi_stepper(map, finalReductionMethod);
102
103 // Navigator
104 Acts::Navigator::Config nav_cfg{geometry().getTG()};
105 nav_cfg.resolveMaterial = true;
106 nav_cfg.resolvePassive = false;
107 nav_cfg.resolveSensitive = true;
108 const Acts::Navigator navigator(nav_cfg);
109
110 auto gsf_propagator =
111 GsfPropagator(std::move(multi_stepper), std::move(navigator),
112 Acts::getDefaultLogger("GSF_PROP", acts_logging_level));
113
114 BetheHeitlerApprox bethe_heitler = Acts::makeDefaultBetheHeitlerApprox();
115
116 gsf_ = std::make_unique<std::decay_t<decltype(*gsf_)>>(
117 std::move(gsf_propagator), std::move(bethe_heitler),
118 Acts::getDefaultLogger("GSF", acts_logging_level));
119
120 const auto stepper = Acts::EigenStepper<>{map};
121 propagator_ = std::make_unique<Propagator>(
122 stepper, navigator,
123 Acts::getDefaultLogger("GSF_EXTRAP", acts_logging_level));
124
125 trk_extrap_ = std::make_shared<std::decay_t<decltype(*trk_extrap_)>>(
126 *propagator_, geometryContext(), magneticFieldContext());
127}
std::unique_ptr< const Acts::GaussianSumFitter< GsfPropagator, BetheHeitlerApprox, Acts::VectorMultiTrajectory > > gsf_
Gaussian Sum Fitter instance for track refitting.
std::shared_ptr< Acts::Surface > target_surface_
Target surface at z=0 mm (recoil track initialization, perigee output)
std::unique_ptr< const Propagator > propagator_
Propagator for track extrapolation using eigen stepper.
std::shared_ptr< Acts::Surface > beam_origin_surface_
Beam origin surface at z=-700 mm (tagger track initialization)
std::shared_ptr< Acts::Surface > ecal_surface_
ECAL surface at z=240.5 mm (ECAL scoring plane for recoil tracking)

References beam_origin_surface_, debug_, ecal_surface_, field_map_, gsf_, propagator_, and target_surface_.

◆ onProcessEnd()

void tracking::reco::GSFProcessor::onProcessEnd ( )
overridevirtual

Callback for the EventProcessor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.

Reimplemented from framework::EventProcessor.

Definition at line 507 of file GSFProcessor.cxx.

507{};

◆ onProcessStart()

void tracking::reco::GSFProcessor::onProcessStart ( )
overridevirtual

Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.

Reimplemented from framework::EventProcessor.

Definition at line 506 of file GSFProcessor.cxx.

506{};

◆ produce()

void tracking::reco::GSFProcessor::produce ( framework::Event & event)
overridevirtual

Run the processor.

Parameters
eventThe event to process.

Implements framework::Producer.

Definition at line 163 of file GSFProcessor.cxx.

163 {
164 // General Setup
165
166 auto tg{geometry()};
167
168 // Retrieve the tracks
170 return;
171 auto tracks{
172 event.getCollection<ldmx::Track>(track_collection_, track_passname_)};
173
174 // Retrieve the measurements
176 auto measurements{
177 event.getCollection<ldmx::Measurement>(meas_collection_, meas_passname_)};
178
179 tracking::sim::LdmxMeasurementCalibrator calibrator{measurements};
180
181 // GSF Setup
182 Acts::GainMatrixUpdater updater;
183 Acts::GsfExtensions<Acts::VectorMultiTrajectory> gsf_extensions;
184 gsf_extensions.updater.connect<
185 &Acts::GainMatrixUpdater::operator()<Acts::VectorMultiTrajectory>>(
186 &updater);
187 gsf_extensions.calibrator
189 Acts::VectorMultiTrajectory>>(&calibrator);
190
191 // Surface Accessor
192 struct SurfaceAccessor {
193 const Acts::TrackingGeometry* tracking_geometry_;
194
195 const Acts::Surface* operator()(const Acts::SourceLink& sourceLink) const {
196 const auto& index_source_link =
197 sourceLink.get<acts_examples::IndexSourceLink>();
198 return tracking_geometry_->findSurface(index_source_link.geometryId());
199 }
200 };
201
202 SurfaceAccessor m_sl_surface_accessor{tg.getTG().get()};
203 // m_slSurfaceAccessor.trackingGeometry = tg.getTG();
204 gsf_extensions.surfaceAccessor.connect<&SurfaceAccessor::operator()>(
205 &m_sl_surface_accessor);
206 gsf_extensions.mixtureReducer.connect<&Acts::reduceMixtureLargestWeights>();
207
208 // Propagator Options
209
210 // Move this at the start of the producer
211 Acts::PropagatorOptions<Acts::StepperPlainOptions,
212 Acts::NavigatorPlainOptions, ActionList, AbortList>
213 propagator_options(geometryContext(), magneticFieldContext());
214
215 propagator_options.pathLimit = std::numeric_limits<double>::max();
216
217 // Activate loop protection at some pt value
218 propagator_options.loopProtection = false;
219 //(startParameters.transverseMomentum() < cfg.ptLoopers);
220
221 // Switch the material interaction on/off & eventually into logging mode
222 auto& m_interactor =
223 propagator_options.actionList.get<Acts::MaterialInteractor>();
224 m_interactor.multipleScattering = true;
225 m_interactor.energyLoss = true;
226 m_interactor.recordInteractions = false;
227
228 // The logger can be switched to sterile, e.g. for timing logging
229 auto& s_logger =
230 propagator_options.actionList.get<Acts::detail::SteppingLogger>();
231 s_logger.sterile = true;
232 // Set a maximum step size
233 propagator_options.stepping.maxStepSize =
234 propagator_step_size_ * Acts::UnitConstants::mm;
235 propagator_options.maxSteps = propagator_max_steps_;
236
237 // Electron hypothesis
238 // propagator_options.mass = 0.511 * Acts::UnitConstants::MeV;
239
240 // GSF options will be configured per-track
241 std::shared_ptr<const Acts::Surface> gsf_ref_surface;
242 Acts::GsfOptions<Acts::VectorMultiTrajectory> gsf_options{
243 geometryContext(), magneticFieldContext(), calibrationContext()};
244 gsf_options.extensions = gsf_extensions;
245 gsf_options.propagatorPlainOptions = propagator_options;
246 gsf_options.maxComponents = max_components_;
247 gsf_options.weightCutoff = weight_cutoff_;
248 gsf_options.abortOnError = abort_on_error_;
249 gsf_options.disableAllMaterialHandling = disable_all_material_handling_;
250
251 // Output track container
252 std::vector<ldmx::Track> out_tracks;
253
254 Acts::VectorTrackContainer vtc;
255 Acts::VectorMultiTrajectory mtj;
256 Acts::TrackContainer tc{vtc, mtj};
257
258 // Loop on tracks
259 unsigned int itrk = 0;
260 ldmx_log(debug) << "Starting GSF processing of " << tracks.size()
261 << " tracks";
262
263 for (auto& track : tracks) {
264 ldmx_log(debug) << "Processing track " << itrk << " with "
265 << track.getMeasurementsIdxs().size() << " measurements";
266 // Retrieve measurements on track
267 std::vector<ldmx::Measurement> meas_on_track;
268
269 // std::vector<ActsExamples::IndexSourceLink> fit_trackSourceLinks;
270 std::vector<Acts::SourceLink> fit_track_source_links;
271
272 for (auto imeas : track.getMeasurementsIdxs()) {
273 auto meas = measurements.at(imeas);
274 meas_on_track.push_back(meas);
275
276 // Retrieve the surface
277
278 const Acts::Surface* hit_surface =
279 tg.geo::TrackingGeometry::getSurface(meas.getLayerID());
280
281 // Store the index_ source link
282 acts_examples::IndexSourceLink idx_sl(hit_surface->geometryId(), imeas);
283 fit_track_source_links.push_back(Acts::SourceLink(idx_sl));
284 }
285
286 // Reverse the order of the vectors
287 std::reverse(meas_on_track.begin(), meas_on_track.end());
288 std::reverse(fit_track_source_links.begin(), fit_track_source_links.end());
289
290 for (auto m : meas_on_track) {
291 ldmx_log(trace) << " Measurement:\n" << m << "\n";
292 }
293
294 ldmx_log(debug) << " Track bound track parameters preparation:";
295
296 // Get the track parameters
297
298 std::shared_ptr<Acts::PerigeeSurface> perigee =
299 Acts::Surface::makeShared<Acts::PerigeeSurface>(Acts::Vector3(
300 track.getPerigeeX(), track.getPerigeeY(), track.getPerigeeZ()));
301
302 Acts::BoundTrackParameters trk_btp =
303 tracking::sim::utils::boundTrackParameters(track, perigee);
304
305 Acts::BoundTrackParameters trk_btp_beam_origin =
306 tracking::sim::utils::boundTrackParameters(track, perigee);
307
308 if (tagger_tracking_) {
309 if (!track.getTrackState(ldmx::TrackStateType::AtBeamOrigin)
310 .has_value()) {
311 ldmx_log(warn) << "Failed retreiving AtBeamOrigin TrackState for "
312 "track. Skipping..";
313 continue;
314 }
315
316 auto ts = track.getTrackState(ldmx::TrackStateType::AtBeamOrigin).value();
317 trk_btp_beam_origin =
318 tracking::sim::utils::btp(ts, beam_origin_surface_, 11);
319 }
320 // Recoil tracking
321 else {
322 if (!track.getTrackState(ldmx::TrackStateType::AtTarget).has_value()) {
323 ldmx_log(warn)
324 << "Failed retreiving AtTarget TrackState for track. Skipping..";
325 continue;
326 }
327 auto ts = track.getTrackState(ldmx::TrackStateType::AtTarget).value();
328 trk_btp_beam_origin = tracking::sim::utils::btp(ts, target_surface_, 11);
329 }
330 ldmx_log(debug) << " Perigee Surface (acts-x, acts-y, acts-z) = ("
331 << track.getPerigeeX() << ", " << track.getPerigeeY()
332 << ", " << track.getPerigeeZ() << ")";
333
334 const Acts::BoundVector& trkpars = trk_btp.parameters();
335 ldmx_log(debug) << " Track parameters (d0, z0, phi, theta, q/p)= ("
336 << trkpars[Acts::eBoundLoc0] << ", "
337 << trkpars[Acts::eBoundLoc1] << ", "
338 << trkpars[Acts::eBoundPhi] << ", "
339 << trkpars[Acts::eBoundTheta] << ", "
340 << trkpars[Acts::eBoundQOverP] << ")";
341
342 Acts::Vector3 trk_pos = trk_btp.position(geometryContext());
343 ldmx_log(debug) << " Track position (acts-x, acts-y, acts-z) = ("
344 << trk_pos(0) << ", " << trk_pos(1) << ", " << trk_pos(2)
345 << ")";
346
347 const Acts::BoundVector& trk_pars_beam_origin =
348 trk_btp_beam_origin.parameters();
349 ldmx_log(debug)
350 << " BeamOrigin track parameters (d0, z0, phi, theta, q/p)= ("
351 << trk_pars_beam_origin[Acts::eBoundLoc0] << ", "
352 << trk_pars_beam_origin[Acts::eBoundLoc1] << ", "
353 << trk_pars_beam_origin[Acts::eBoundPhi] << ", "
354 << trk_pars_beam_origin[Acts::eBoundTheta] << ", "
355 << trk_pars_beam_origin[Acts::eBoundQOverP] << ")";
356
357 Acts::Vector3 trk_pos_beam_origin =
358 trk_btp_beam_origin.position(geometryContext());
359 ldmx_log(debug)
360 << " BeamOrigin track position (acts-x, acts-y, acts-z) = ("
361 << trk_pos_beam_origin(0) << ", " << trk_pos_beam_origin(1) << ", "
362 << trk_pos_beam_origin(2) << ")";
363
364 ldmx_log(debug) << " About to run GSF fit with "
365 << fit_track_source_links.size() << " source links";
366
367 // Update GSF reference surface for this track
368 if (tagger_tracking_) {
369 gsf_ref_surface = beam_origin_surface_;
370 } else {
371 gsf_ref_surface = target_surface_;
372 }
373 gsf_options.referenceSurface = &(*gsf_ref_surface);
374
375 // Use beam origin track for GSF fitting (has correct trajectory for
376 // measurements) but we'll extrapolate to (0,0,0) for final parameters
377 auto gsf_refit_result =
378 gsf_->fit(fit_track_source_links.begin(), fit_track_source_links.end(),
379 trk_btp_beam_origin, gsf_options, tc);
380
381 if (!gsf_refit_result.ok()) {
382 ldmx_log(warn) << "GSF re-fit failed: "
383 << gsf_refit_result.error().message();
384 continue;
385 }
386
387 ldmx_log(debug) << " GSF fit succeeded, tc.size() = " << tc.size();
388
389 if (tc.size() < 1) continue;
390
391 auto gsftrk = tc.getTrack(0);
392 // calculateTrackQuantities(gsftrk);
393
394 const Acts::BoundVector& perigee_pars = gsftrk.parameters();
395 const Acts::BoundMatrix& trk_cov = gsftrk.covariance();
396 const Acts::Surface& perigee_surface = gsftrk.referenceSurface();
397
398 ldmx_log(debug)
399 << " Reference Surface (acts-x, acts-y, acts-z) = ("
400 << perigee_surface.transform(geometryContext()).translation()(0) << ", "
401 << perigee_surface.transform(geometryContext()).translation()(1) << ", "
402 << perigee_surface.transform(geometryContext()).translation()(2) << ")";
403
404 ldmx_log(debug) << " Found track has " << gsftrk.nTrackStates()
405 << " track states";
406
407 ldmx_log(debug) << " Track parameters (d0, z0, phi, theta, q/p)= ("
408 << perigee_pars[Acts::eBoundLoc0] << ", "
409 << perigee_pars[Acts::eBoundLoc1] << ", "
410 << perigee_pars[Acts::eBoundPhi] << ", "
411 << perigee_pars[Acts::eBoundTheta] << ", "
412 << perigee_pars[Acts::eBoundQOverP] << ") ";
413
414 ldmx::Track trk = ldmx::Track();
415
416 bool success = false;
417 bool success_ecal = false;
418 ldmx::Track::TrackState ts_at_target_surface;
419
420 if (tagger_tracking_) {
421 ldmx_log(debug) << " Target extrapolation";
422 ldmx::Track::TrackState ts_at_target;
423
424 success = trk_extrap_->trackStateAtSurface(
425 gsftrk, target_surface_, ts_at_target,
426 ldmx::TrackStateType::AtTarget);
427
428 if (success) {
429 trk.addTrackState(ts_at_target);
430 ts_at_target_surface = ts_at_target;
431 }
432 } // end tagger tracking
433 else {
434 ldmx_log(debug) << " Ecal Extrapolation";
435 ldmx::Track::TrackState ts_at_ecal;
436 success_ecal = trk_extrap_->trackStateAtSurface(
437 gsftrk, ecal_surface_, ts_at_ecal, ldmx::TrackStateType::AtECAL);
438
439 if (success_ecal) trk.addTrackState(ts_at_ecal);
440
441 // Also get track state at target for perigee parameters
442 ldmx_log(debug) << " Target extrapolation for perigee parameters";
443 success = trk_extrap_->trackStateAtSurface(
444 gsftrk, target_surface_, ts_at_target_surface,
445 ldmx::TrackStateType::AtTarget);
446 if (success) trk.addTrackState(ts_at_target_surface);
447 } // end recoil tracking
448
449 // Use parameters at target surface (0, 0, 0) for perigee
450 trk.setPerigeeLocation(0., 0., 0.);
451 trk.setChi2(gsftrk.chi2());
452 trk.setNhits(gsftrk.nMeasurements());
453 trk.setNdf(gsftrk.nMeasurements() - 5);
454 if (success) {
455 ldmx_log(debug) << " Extrapolated track parameters at target (d0, z0, "
456 "phi, theta, q/p)= ("
457 << ts_at_target_surface.params_[Acts::eBoundLoc0] << ", "
458 << ts_at_target_surface.params_[Acts::eBoundLoc1] << ", "
459 << ts_at_target_surface.params_[Acts::eBoundPhi] << ", "
460 << ts_at_target_surface.params_[Acts::eBoundTheta] << ", "
461 << ts_at_target_surface.params_[Acts::eBoundQOverP]
462 << ")";
463 ldmx_log(debug) << " Using extrapolated parameters";
464 trk.setPerigeeParameters(ts_at_target_surface.params_);
465 std::vector<double> cov;
466 for (auto c : ts_at_target_surface.cov_) cov.push_back(c);
467 ldmx_log(debug) << " Setting extrapolated covariance, size="
468 << cov.size();
469 trk.setPerigeeCov(cov);
470 } else {
471 ldmx_log(debug) << " Extrapolation failed, using perigee parameters";
472 ldmx_log(debug) << " Perigee parameters (d0, z0, phi, theta, q/p)= ("
473 << perigee_pars[Acts::eBoundLoc0] << ", "
474 << perigee_pars[Acts::eBoundLoc1] << ", "
475 << perigee_pars[Acts::eBoundPhi] << ", "
476 << perigee_pars[Acts::eBoundTheta] << ", "
477 << perigee_pars[Acts::eBoundQOverP] << ")";
479 tracking::sim::utils::convertActsToLdmxPars(perigee_pars));
480 std::vector<double> v_trk_cov;
481 tracking::sim::utils::flatCov(trk_cov, v_trk_cov);
482 ldmx_log(debug) << " Setting perigee covariance, size="
483 << v_trk_cov.size();
484 trk.setPerigeeCov(v_trk_cov);
485 }
486 Acts::Vector3 trk_momentum = gsftrk.momentum();
487 trk.setMomentum(trk_momentum(0), trk_momentum(1), trk_momentum(2));
488
489 // truth information
490 trk.setTrackID(track.getTrackID());
491 trk.setPdgID(track.getPdgID());
492 trk.setTruthProb(track.getTruthProb());
493
494 itrk++;
495
496 ldmx_log(debug) << " Added track to output, total tracks = "
497 << (out_tracks.size() + 1);
498
499 out_tracks.push_back(trk);
500
501 } // loop on tracks
502
503 event.add(out_trk_collection_, out_tracks);
504} // end of produce()
bool exists(const std::string &name, const std::string &passName, bool unique=true) const
Check for the existence of an object or collection with the given name and pass name in the event.
Definition Event.cxx:92
Implementation of a track object.
Definition Track.h:53
void setPerigeeParameters(const std::vector< double > &par)
d_0 z_0 phi_0 theta q/p t
Definition Track.h:161
void calibrate1d(const Acts::GeometryContext &, const Acts::CalibrationContext &, const Acts::SourceLink &genericSourceLink, typename traj_t::TrackStateProxy trackState) const
Find the measurement corresponding to the source link.

References abort_on_error_, beam_origin_surface_, tracking::sim::LdmxMeasurementCalibrator::calibrate1d(), disable_all_material_handling_, ecal_surface_, framework::Event::exists(), gsf_, max_components_, meas_collection_, meas_collection_event_passname_, meas_passname_, out_trk_collection_, propagator_max_steps_, propagator_step_size_, ldmx::Track::setPerigeeParameters(), target_surface_, track_collection_, track_collection_event_passname_, track_passname_, and weight_cutoff_.

Member Data Documentation

◆ abort_on_error_

bool tracking::reco::GSFProcessor::abort_on_error_ {false}
private

Abort fit if any error occurs (strict error handling)

Definition at line 247 of file GSFProcessor.h.

247{false};

Referenced by configure(), and produce().

◆ beam_origin_surface_

std::shared_ptr<Acts::Surface> tracking::reco::GSFProcessor::beam_origin_surface_
private

Beam origin surface at z=-700 mm (tagger track initialization)

Definition at line 281 of file GSFProcessor.h.

Referenced by onNewRun(), and produce().

◆ debug_

bool tracking::reco::GSFProcessor::debug_ {false}
private

Enable verbose debug output logging.

Definition at line 175 of file GSFProcessor.h.

175{false};

Referenced by configure(), and onNewRun().

◆ disable_all_material_handling_

bool tracking::reco::GSFProcessor::disable_all_material_handling_ {false}
private

Disable all material interactions during propagation.

Definition at line 250 of file GSFProcessor.h.

250{false};

Referenced by configure(), and produce().

◆ ecal_surface_

std::shared_ptr<Acts::Surface> tracking::reco::GSFProcessor::ecal_surface_
private

ECAL surface at z=240.5 mm (ECAL scoring plane for recoil tracking)

Definition at line 287 of file GSFProcessor.h.

Referenced by onNewRun(), and produce().

◆ extrapolate_location_

std::vector<double> tracking::reco::GSFProcessor::extrapolate_location_ {0., 0., 0.}
private

Location to extrapolate tracks to (x, y, z in mm)

Definition at line 198 of file GSFProcessor.h.

198{0., 0., 0.};

◆ field_map_

std::string tracking::reco::GSFProcessor::field_map_ {""}
private

Path to magnetic field map file.

Definition at line 262 of file GSFProcessor.h.

262{""};

Referenced by configure(), and onNewRun().

◆ generator_

std::default_random_engine tracking::reco::GSFProcessor::generator_
private

Random number generator for smearing operations.

Definition at line 178 of file GSFProcessor.h.

◆ gsf_

std::unique_ptr<const Acts::GaussianSumFitter< GsfPropagator, BetheHeitlerApprox, Acts::VectorMultiTrajectory> > tracking::reco::GSFProcessor::gsf_
private

Gaussian Sum Fitter instance for track refitting.

Definition at line 223 of file GSFProcessor.h.

Referenced by onNewRun(), and produce().

◆ layer_surface_map_

std::unordered_map<unsigned int, const Acts::Surface *> tracking::reco::GSFProcessor::layer_surface_map_
private

Layer ID to ACTS Surface mapping for hit surface lookup.

Definition at line 274 of file GSFProcessor.h.

◆ max_components_

size_t tracking::reco::GSFProcessor::max_components_ {4}
private

Maximum number of mixture components in GSF fit.

Definition at line 244 of file GSFProcessor.h.

244{4};

Referenced by configure(), and produce().

◆ meas_collection_

std::string tracking::reco::GSFProcessor::meas_collection_ {"DigiTaggerSimHits"}
private

Collection name for measurements associated with tracks.

Definition at line 229 of file GSFProcessor.h.

229{"DigiTaggerSimHits"};

Referenced by configure(), and produce().

◆ meas_collection_event_passname_

std::string tracking::reco::GSFProcessor::meas_collection_event_passname_
private

Pass name qualifier for measurement collection event key.

Definition at line 241 of file GSFProcessor.h.

Referenced by configure(), and produce().

◆ meas_passname_

std::string tracking::reco::GSFProcessor::meas_passname_
private

Pass name for measurement collection in event.

Definition at line 235 of file GSFProcessor.h.

Referenced by configure(), and produce().

◆ measurement_collection_

std::string tracking::reco::GSFProcessor::measurement_collection_ {"TaggerMeasurements"}
private

Collection name for input measurements.

Definition at line 202 of file GSFProcessor.h.

202{"TaggerMeasurements"};

◆ normal_

std::shared_ptr<std::normal_distribution<float> > tracking::reco::GSFProcessor::normal_
private

Normal distribution for smearing measurements.

Definition at line 181 of file GSFProcessor.h.

◆ out_trk_collection_

std::string tracking::reco::GSFProcessor::out_trk_collection_ {"GSFTracks"}
private

Collection name for output GSF-refitted tracks.

Definition at line 207 of file GSFProcessor.h.

207{"GSFTracks"};

Referenced by configure(), and produce().

◆ profiling_map_

std::map<std::string, double> tracking::reco::GSFProcessor::profiling_map_
private

Time profiling data for performance analysis.

Definition at line 168 of file GSFProcessor.h.

◆ propagator_

std::unique_ptr<const Propagator> tracking::reco::GSFProcessor::propagator_
private

Propagator for track extrapolation using eigen stepper.

Definition at line 271 of file GSFProcessor.h.

Referenced by onNewRun().

◆ propagator_max_steps_

int tracking::reco::GSFProcessor::propagator_max_steps_ {1000}
private

Maximum number of propagation steps before aborting.

Definition at line 259 of file GSFProcessor.h.

259{1000};

Referenced by configure(), and produce().

◆ propagator_step_size_

double tracking::reco::GSFProcessor::propagator_step_size_ {200.}
private

Step size for track propagation in mm.

Definition at line 256 of file GSFProcessor.h.

256{200.};

Referenced by configure(), and produce().

◆ seed_coll_name_

std::string tracking::reco::GSFProcessor::seed_coll_name_ {"seedTracks"}
private

Collection name for seed tracks (currently unused)

Definition at line 218 of file GSFProcessor.h.

218{"seedTracks"};

◆ tagger_tracking_

bool tracking::reco::GSFProcessor::tagger_tracking_ {true}
private

Definition at line 268 of file GSFProcessor.h.

268{true};

◆ target_surface_

std::shared_ptr<Acts::Surface> tracking::reco::GSFProcessor::target_surface_
private

Target surface at z=0 mm (recoil track initialization, perigee output)

Definition at line 284 of file GSFProcessor.h.

Referenced by onNewRun(), and produce().

◆ track_collection_

std::string tracking::reco::GSFProcessor::track_collection_ {"TaggerTracks"}
private

Collection name for input tracks to be refit.

Definition at line 226 of file GSFProcessor.h.

226{"TaggerTracks"};

Referenced by configure(), and produce().

◆ track_collection_event_passname_

std::string tracking::reco::GSFProcessor::track_collection_event_passname_
private

Pass name qualifier for track collection event key.

Definition at line 238 of file GSFProcessor.h.

Referenced by configure(), and produce().

◆ track_passname_

std::string tracking::reco::GSFProcessor::track_passname_
private

Pass name for track collection in event.

Definition at line 232 of file GSFProcessor.h.

Referenced by configure(), and produce().

◆ trk_extrap_

std::shared_ptr<tracking::reco::TrackExtrapolatorTool<Propagator> > tracking::reco::GSFProcessor::trk_extrap_
private

Definition at line 278 of file GSFProcessor.h.

◆ use_perigee_

bool tracking::reco::GSFProcessor::use_perigee_ {false}
private

Use perigee parameterization for tracks.

Definition at line 265 of file GSFProcessor.h.

265{false};

Referenced by configure().

◆ weight_cutoff_

double tracking::reco::GSFProcessor::weight_cutoff_ {1.0e-4}
private

Weight threshold below which mixture components are dropped.

Definition at line 253 of file GSFProcessor.h.

253{1.0e-4};

Referenced by configure(), and produce().


The documentation for this class was generated from the following files: