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 11 of file GSFProcessor.cxx.

12 : 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 130 of file GSFProcessor.cxx.

130 {
132 parameters.get<std::string>("out_trk_collection", "GSFTracks");
133
135 parameters.get<std::string>("track_collection", "TaggerTracks");
137 parameters.get<std::string>("meas_collection", "DigiTaggerSimHits");
138
139 track_passname_ = parameters.get<std::string>("track_passname");
140 meas_passname_ = parameters.get<std::string>("meas_passname");
142 parameters.get<std::string>("track_collection_event_passname");
144 parameters.get<std::string>("meas_collection_event_passname");
145
146 max_components_ = parameters.get<int>("max_components", 4);
147 abort_on_error_ = parameters.get<bool>("abort_on_error", false);
149 parameters.get<bool>("disable_all_material_handling", false);
150 weight_cutoff_ = parameters.get<double>("weight_cutoff_", 1.0e-4);
151
152 propagator_max_steps_ = parameters.get<int>("propagator_max_steps", 10000);
153 propagator_step_size_ = parameters.get<double>("propagator_step_size", 200.);
154 field_map_ = parameters.get<std::string>("field_map");
155 use_perigee_ = parameters.get<bool>("usePerigee", false);
156
157 debug_ = parameters.get<bool>("debug", false);
158 tagger_tracking_ = parameters.get<bool>("tagger_tracking", true);
159
160 // final_reduction_method_ =
161 // parameters.get<double>("finalReductionMethod",);
162} // 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 14 of file GSFProcessor.cxx.

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

469{};

◆ 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 468 of file GSFProcessor.cxx.

468{};

◆ produce()

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

Run the processor.

Parameters
eventThe event to process.

Implements framework::Producer.

Definition at line 164 of file GSFProcessor.cxx.

164 {
165 // General Setup
166
167 auto tg{geometry()};
168
169 // Retrieve the tracks
171 return;
172 auto tracks{
173 event.getCollection<ldmx::Track>(track_collection_, track_passname_)};
174
175 // Retrieve the measurements
177 auto measurements{
178 event.getCollection<ldmx::Measurement>(meas_collection_, meas_passname_)};
179
180 tracking::sim::LdmxMeasurementCalibrator calibrator{measurements};
181
182 // GSF Setup
183 Acts::GainMatrixUpdater updater;
184 Acts::GsfExtensions<Acts::VectorMultiTrajectory> gsf_extensions;
185 gsf_extensions.updater.connect<
186 &Acts::GainMatrixUpdater::operator()<Acts::VectorMultiTrajectory>>(
187 &updater);
188 gsf_extensions.calibrator
190 Acts::VectorMultiTrajectory>>(&calibrator);
191
192 // Surface Accessor
193 struct SurfaceAccessor {
194 const Acts::TrackingGeometry* tracking_geometry_;
195
196 const Acts::Surface* operator()(const Acts::SourceLink& sourceLink) const {
197 const auto& index_source_link =
198 sourceLink.get<acts_examples::IndexSourceLink>();
199 return tracking_geometry_->findSurface(index_source_link.geometryId());
200 }
201 };
202
203 SurfaceAccessor m_sl_surface_accessor{tg.getTG().get()};
204 // m_slSurfaceAccessor.trackingGeometry = tg.getTG();
205 gsf_extensions.surfaceAccessor.connect<&SurfaceAccessor::operator()>(
206 &m_sl_surface_accessor);
207 gsf_extensions.mixtureReducer.connect<&Acts::reduceMixtureLargestWeights>();
208
209 // Propagator Options
210
211 // Move this at the start of the producer
212 Acts::PropagatorOptions<Acts::StepperPlainOptions,
213 Acts::NavigatorPlainOptions, ActionList, AbortList>
214 propagator_options(geometryContext(), magneticFieldContext());
215
216 propagator_options.pathLimit = std::numeric_limits<double>::max();
217
218 // Activate loop protection at some pt value
219 propagator_options.loopProtection = false;
220 //(startParameters.transverseMomentum() < cfg.ptLoopers);
221
222 // Switch the material interaction on/off & eventually into logging mode
223 auto& m_interactor =
224 propagator_options.actionList.get<Acts::MaterialInteractor>();
225 m_interactor.multipleScattering = true;
226 m_interactor.energyLoss = true;
227 m_interactor.recordInteractions = false;
228
229 // The logger can be switched to sterile, e.g. for timing logging
230 auto& s_logger =
231 propagator_options.actionList.get<Acts::detail::SteppingLogger>();
232 s_logger.sterile = true;
233 // Set a maximum step size
234 propagator_options.stepping.maxStepSize =
235 propagator_step_size_ * Acts::UnitConstants::mm;
236 propagator_options.maxSteps = propagator_max_steps_;
237
238 // Electron hypothesis
239 // propagator_options.mass = 0.511 * Acts::UnitConstants::MeV;
240
241 // GSF options will be configured per-track
242 std::shared_ptr<const Acts::Surface> gsf_ref_surface;
243 Acts::GsfOptions<Acts::VectorMultiTrajectory> gsf_options{
244 geometryContext(), magneticFieldContext(), calibrationContext()};
245 gsf_options.extensions = gsf_extensions;
246 gsf_options.propagatorPlainOptions = propagator_options;
247 gsf_options.maxComponents = max_components_;
248 gsf_options.weightCutoff = weight_cutoff_;
249 gsf_options.abortOnError = abort_on_error_;
250 gsf_options.disableAllMaterialHandling = disable_all_material_handling_;
251
252 // Output track container
253 std::vector<ldmx::Track> out_tracks;
254
255 Acts::VectorTrackContainer vtc;
256 Acts::VectorMultiTrajectory mtj;
257 Acts::TrackContainer tc{vtc, mtj};
258
259 // Loop on tracks
260 unsigned int itrk = 0;
261 ldmx_log(debug) << "Starting GSF processing of " << tracks.size()
262 << " tracks";
263
264 for (auto& track : tracks) {
265 ldmx_log(debug) << "Processing track " << itrk << " with "
266 << track.getMeasurementsIdxs().size() << " measurements";
267 // Retrieve measurements on track
268 std::vector<ldmx::Measurement> meas_on_track;
269
270 // std::vector<ActsExamples::IndexSourceLink> fit_trackSourceLinks;
271 std::vector<Acts::SourceLink> fit_track_source_links;
272
273 for (auto imeas : track.getMeasurementsIdxs()) {
274 auto meas = measurements.at(imeas);
275 meas_on_track.push_back(meas);
276
277 // Retrieve the surface
278
279 const Acts::Surface* hit_surface =
280 tg.geo::TrackingGeometry::getSurface(meas.getLayerID());
281
282 // Store the index_ source link
283 acts_examples::IndexSourceLink idx_sl(hit_surface->geometryId(), imeas);
284 fit_track_source_links.push_back(Acts::SourceLink(idx_sl));
285 }
286
287 // Reverse the order of the vectors
288 std::reverse(meas_on_track.begin(), meas_on_track.end());
289 std::reverse(fit_track_source_links.begin(), fit_track_source_links.end());
290
291 for (auto m : meas_on_track) {
292 ldmx_log(trace) << " Measurement:\n" << m << "\n";
293 }
294
295 ldmx_log(debug) << " Track bound track parameters preparation:";
296
297 // Reconstruct BoundTrackParameters at perigee (target) from stored params.
298 // perigee_ is stored in LDMX frame; rotate to ACTS frame for surface
299 // creation.
300 Acts::Vector3 perigee_acts = tracking::sim::utils::ldmx2Acts(Acts::Vector3(
301 track.getPerigeeX(), track.getPerigeeY(), track.getPerigeeZ()));
302 std::shared_ptr<Acts::PerigeeSurface> perigee =
303 Acts::Surface::makeShared<Acts::PerigeeSurface>(perigee_acts);
304
305 Acts::BoundTrackParameters trk_btp =
306 tracking::sim::utils::boundTrackParameters(track, perigee);
307
308 // GSF starting parameters: for tagger, extrapolate back to beam origin;
309 // for recoil, use target parameters directly.
310 Acts::BoundTrackParameters trk_btp_fit_start = trk_btp;
311
312 if (tagger_tracking_) {
313 auto opt_beam_origin =
314 trk_extrap_->extrapolate(trk_btp, beam_origin_surface_);
315 if (!opt_beam_origin) {
316 ldmx_log(warn) << "Failed extrapolating to beam origin for GSF start. "
317 "Skipping..";
318 continue;
319 }
320 trk_btp_fit_start = *opt_beam_origin;
321 }
322
323 ldmx_log(debug) << " Perigee surface (acts): (" << track.getPerigeeX()
324 << ", " << track.getPerigeeY() << ", "
325 << track.getPerigeeZ() << ")";
326
327 const Acts::BoundVector& trkpars = trk_btp.parameters();
328 ldmx_log(debug) << " Perigee parameters (d0, z0, phi, theta, q/p)= ("
329 << trkpars[Acts::eBoundLoc0] << ", "
330 << trkpars[Acts::eBoundLoc1] << ", "
331 << trkpars[Acts::eBoundPhi] << ", "
332 << trkpars[Acts::eBoundTheta] << ", "
333 << trkpars[Acts::eBoundQOverP] << ")";
334
335 const Acts::BoundVector& fit_start_pars = trk_btp_fit_start.parameters();
336 ldmx_log(debug) << " GSF start parameters (d0, z0, phi, theta, q/p)= ("
337 << fit_start_pars[Acts::eBoundLoc0] << ", "
338 << fit_start_pars[Acts::eBoundLoc1] << ", "
339 << fit_start_pars[Acts::eBoundPhi] << ", "
340 << fit_start_pars[Acts::eBoundTheta] << ", "
341 << fit_start_pars[Acts::eBoundQOverP] << ")";
342
343 ldmx_log(debug) << " About to run GSF fit with "
344 << fit_track_source_links.size() << " source links";
345
346 // Update GSF reference surface for this track
347 if (tagger_tracking_) {
348 gsf_ref_surface = beam_origin_surface_;
349 } else {
350 gsf_ref_surface = target_surface_;
351 }
352 gsf_options.referenceSurface = &(*gsf_ref_surface);
353
354 auto gsf_refit_result =
355 gsf_->fit(fit_track_source_links.begin(), fit_track_source_links.end(),
356 trk_btp_fit_start, gsf_options, tc);
357
358 if (!gsf_refit_result.ok()) {
359 ldmx_log(warn) << "GSF re-fit failed: "
360 << gsf_refit_result.error().message();
361 continue;
362 }
363
364 ldmx_log(debug) << " GSF fit succeeded, tc.size() = " << tc.size();
365
366 if (tc.size() < 1) continue;
367
368 auto gsftrk = tc.getTrack(0);
369 // calculateTrackQuantities(gsftrk);
370
371 const Acts::BoundVector& perigee_pars = gsftrk.parameters();
372 const Acts::BoundMatrix& trk_cov = gsftrk.covariance();
373 const Acts::Surface& perigee_surface = gsftrk.referenceSurface();
374
375 ldmx_log(debug)
376 << " Reference Surface (acts-x, acts-y, acts-z) = ("
377 << perigee_surface.transform(geometryContext()).translation()(0) << ", "
378 << perigee_surface.transform(geometryContext()).translation()(1) << ", "
379 << perigee_surface.transform(geometryContext()).translation()(2) << ")";
380
381 ldmx_log(debug) << " Found track has " << gsftrk.nTrackStates()
382 << " track states";
383
384 ldmx_log(debug) << " Track parameters (d0, z0, phi, theta, q/p)= ("
385 << perigee_pars[Acts::eBoundLoc0] << ", "
386 << perigee_pars[Acts::eBoundLoc1] << ", "
387 << perigee_pars[Acts::eBoundPhi] << ", "
388 << perigee_pars[Acts::eBoundTheta] << ", "
389 << perigee_pars[Acts::eBoundQOverP] << ") ";
390
391 ldmx::Track trk;
392
393 // Extrapolate GSF track to target surface to get perigee parameters
394 auto opt_target = trk_extrap_->extrapolate(gsftrk, target_surface_);
395
396 if (opt_target) {
397 ldmx_log(debug) << " GSF target extrapolation succeeded";
398 auto ts_at_target = tracking::sim::utils::makeTrackState(
399 geometryContext(), *opt_target, ldmx::AtTarget);
400 trk.addTrackState(ts_at_target);
401
402 trk.setPerigeeParameters(tracking::sim::utils::convertActsToLdmxPars(
403 opt_target->parameters()));
404 if (opt_target->covariance()) {
405 std::vector<double> cov_vec;
406 tracking::sim::utils::flatCov(*(opt_target->covariance()), cov_vec);
407 trk.setPerigeeCov(cov_vec);
408 }
409 Acts::Vector3 target_loc_ldmx = tracking::sim::utils::acts2Ldmx(
410 target_surface_->transform(geometryContext()).translation());
411 trk.setPerigeeLocation(target_loc_ldmx[0], target_loc_ldmx[1],
412 target_loc_ldmx[2]);
413
414 ldmx_log(debug)
415 << " GSF target parameters (d0, z0, phi, theta, q/p)= ("
416 << opt_target->parameters()[Acts::eBoundLoc0] << ", "
417 << opt_target->parameters()[Acts::eBoundLoc1] << ", "
418 << opt_target->parameters()[Acts::eBoundPhi] << ", "
419 << opt_target->parameters()[Acts::eBoundTheta] << ", "
420 << opt_target->parameters()[Acts::eBoundQOverP] << ")";
421 } else {
422 ldmx_log(debug) << " GSF target extrapolation failed, using GSF fit "
423 "parameters at reference surface";
424 trk.setPerigeeParameters(
425 tracking::sim::utils::convertActsToLdmxPars(perigee_pars));
426 std::vector<double> v_trk_cov;
427 tracking::sim::utils::flatCov(trk_cov, v_trk_cov);
428 trk.setPerigeeCov(v_trk_cov);
429 }
430
431 // Tagger: also add beam-origin state; Recoil: add ECAL state
432 if (tagger_tracking_) {
433 auto opt_beam_origin =
434 trk_extrap_->extrapolate(gsftrk, beam_origin_surface_);
435 if (opt_beam_origin)
436 trk.addTrackState(tracking::sim::utils::makeTrackState(
437 geometryContext(), *opt_beam_origin, ldmx::AtBeamOrigin));
438 } else {
439 ldmx_log(debug) << " ECAL extrapolation";
440 auto opt_ecal = trk_extrap_->extrapolate(gsftrk, ecal_surface_);
441 if (opt_ecal)
442 trk.addTrackState(tracking::sim::utils::makeTrackState(
443 geometryContext(), *opt_ecal, ldmx::AtECAL));
444 }
445
446 trk.setChi2(gsftrk.chi2());
447 trk.setNhits(gsftrk.nMeasurements());
448 trk.setNdf(gsftrk.nMeasurements() - 5);
449 trk.setCharge(perigee_pars[Acts::eBoundQOverP] > 0 ? 1 : -1);
450
451 // Truth information carried over from input track
452 trk.setTrackID(track.getTrackID());
453 trk.setPdgID(track.getPdgID());
454 trk.setTruthProb(track.getTruthProb());
455
456 itrk++;
457
458 ldmx_log(debug) << " Added track to output, total tracks = "
459 << (out_tracks.size() + 1);
460
461 out_tracks.push_back(trk);
462
463 } // loop on tracks
464
465 event.add(out_trk_collection_, out_tracks);
466} // 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:105
Implementation of a track object.
Definition Track.h:53
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_, 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: