Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 08:22:00

0001 /** TRACCC library, part of the ACTS project (R&D line)
0002  *
0003  * (c) 2026 CERN for the benefit of the ACTS project
0004  *
0005  * Mozilla Public License Version 2.0
0006  */
0007 
0008 #pragma once
0009 
0010 #include "traccc/fitting/kalman_filter/kalman_fitter.hpp"
0011 #include "traccc/fitting/status_codes.hpp"
0012 
0013 namespace traccc::host {
0014 
0015 /// Run the Kalman smoother over the collected surfaces
0016 template <typename fitter_t>
0017 TRACCC_HOST inline void kalman_smoother(
0018     const typename fitter_t::config_type cfg,
0019     const typename fitter_t::detector_type& det,
0020     const typename fitter_t::bfield_type& field,
0021     typename edm::track_container<
0022         typename fitter_t::detector_type::algebra_type>::host& track_container,
0023     vecmem::data::jagged_vector_view<
0024         typename fitter_t::detector_type::surface_type>
0025         surfaces_view) {
0026   using algebra_t = typename fitter_t::detector_type::algebra_type;
0027 
0028   // Run fitting
0029   fitter_t fitter(det, field, cfg);
0030 
0031   // Create the input container(s).
0032   typename edm::track_container<algebra_t>::data tracks_data{track_container};
0033   typename edm::track_container<algebra_t>::view tracks_view{tracks_data};
0034   typename edm::track_container<algebra_t>::device device_track_container{
0035       tracks_view};
0036   edm::measurement_collection::const_device measurements{
0037       track_container.measurements};
0038 
0039   for (unsigned int trk_idx = 0u; trk_idx < track_container.tracks.size();
0040        trk_idx++) {
0041     // Device(!) container proxy type
0042     auto track = device_track_container.tracks.at(trk_idx);
0043     if (track.constituent_links().size() == 0u) {
0044       continue;
0045     }
0046     TRACCC_INFO_HOST("Fitting track " << trk_idx << " ("
0047                                       << track.constituent_links().size()
0048                                       << " track states)");
0049     TRACCC_VERBOSE_HOST("" << track_container.tracks.at(trk_idx));
0050 
0051     vecmem::data::vector_view<typename fitter_t::detector_type::surface_type>
0052         sf_view{*(surfaces_view.ptr() + trk_idx)};
0053 
0054     typename fitter_t::state fitter_state(
0055         track, device_track_container.states, measurements, sf_view,
0056         fitter.config().propagation, fitter.config().meas_calibration);
0057 
0058     const kalman_fitter_status fit_status = fitter.smooth(fitter_state);
0059 
0060     fitter.update_statistics(fitter_state);
0061 
0062     // Assume that this branch is only called if the forward fit was
0063     // successfull (track param are alive)
0064     fitter.check_fitting_result(fitter_state, kalman_fitter_status::SUCCESS,
0065                                 fit_status);
0066   }
0067 }
0068 
0069 }  // namespace traccc::host