Skip to content

Commit

Permalink
Backup
Browse files Browse the repository at this point in the history
  • Loading branch information
beomki-yeo committed Apr 26, 2024
1 parent 2d06e82 commit ef6cdba
Showing 1 changed file with 60 additions and 101 deletions.
161 changes: 60 additions & 101 deletions core/include/traccc/finding/finding_algorithm.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ finding_algorithm<stepper_t, navigator_t>::operator()(
barcodes.push_back(uniques[i].surface_link);
}

/**********************
* Find tracks
**********************/

std::vector<std::vector<candidate_link>> links;
links.resize(m_cfg.max_track_candidates_per_track);

Expand Down Expand Up @@ -109,6 +105,9 @@ finding_algorithm<stepper_t, navigator_t>::operator()(

std::fill(n_trks_per_seed.begin(), n_trks_per_seed.end(), 0);

// Parameters updated by Kalman fitter
std::vector<bound_track_parameters> updated_params;

for (unsigned int in_param_id = 0; in_param_id < n_in_params;
in_param_id++) {

Expand Down Expand Up @@ -146,10 +145,6 @@ finding_algorithm<stepper_t, navigator_t>::operator()(
static_cast<int>(detray::navigation::direction::e_forward), sf,
sfi.cos_incidence_angle);

/*************************
* CKF
*************************/

// Get barcode and measurements range on surface
const auto bcd = in_param.surface_link();
std::pair<unsigned int, unsigned int> range;
Expand All @@ -175,7 +170,9 @@ finding_algorithm<stepper_t, navigator_t>::operator()(

unsigned int n_branches = 0;

std::vector<float> chi2s;
/*****************************************************************
* Find tracks (CKF)
*****************************************************************/

// Iterate over the measurements
for (unsigned int item_id = range.first; item_id < range.second;
Expand Down Expand Up @@ -204,123 +201,85 @@ finding_algorithm<stepper_t, navigator_t>::operator()(

// Found a good measurement
if (chi2 < m_cfg.chi2_max) {

chi2s.push_back(chi2);
// Current link ID
unsigned int cur_link_id =
static_cast<unsigned int>(links[step].size());

n_branches++;
n_trks_per_seed[orig_param_id]++;

links[step].push_back(
{{previous_step, in_param_id}, item_id, orig_param_id});

/*********************************
* Propagate to the next surface
*********************************/

// Create propagator state
typename propagator_type::state propagation(
trk_state.filtered(), field, det);
propagation._stepping.template set_constraint<
detray::step::constraint::e_accuracy>(
m_cfg.propagation.stepping.step_constraint);

typename detray::pathlimit_aborter::state s0;
typename detray::parameter_transporter<
transform3_type>::state s1;
typename interactor::state s3;
typename interaction_register<interactor>::state s2{s3};
typename detray::next_surface_aborter::state s4{
m_cfg.min_step_length_for_surface_aborter};

// @TODO: Should be removed once detray is fixed to set the
// volume in the constructor
propagation._navigation.set_volume(
trk_state.filtered().surface_link().volume());

// Propagate to the next surface
propagator.propagate_sync(propagation,
std::tie(s0, s1, s2, s3, s4));

// If a surface found, add the parameter for the next
// step
if (s4.success) {
out_params.push_back(
propagation._stepping._bound_params);
param_to_link[step].push_back(cur_link_id);
}
// Unless the track found a surface, it is considered a
// tip
else if (!s4.success &&
step >= m_cfg.min_track_candidates_per_track - 1) {
tips.push_back({step, cur_link_id});
}

// If no more CKF step is expected, current candidate is
// kept as a tip
if (s4.success &&
step == m_cfg.max_track_candidates_per_track - 1) {
tips.push_back({step, cur_link_id});
}
updated_params.push_back(trk_state.filtered());
}
}

/*****************************************************************
* Add a dummy links in case of no branches
*****************************************************************/

if (n_branches == 0) {
// let's skip this CKF step for the current track candidate
if (n_trks_per_seed[orig_param_id] >=
m_cfg.max_num_branches_per_initial_seed) {

continue;
}

unsigned int cur_link_id =
static_cast<unsigned int>(links[step].size());

// Put an invalid link with max item id
links[step].push_back({{previous_step, in_param_id},
std::numeric_limits<unsigned int>::max(),
orig_param_id});

bound_track_parameters bound_param(in_param.surface_link(),
in_param.vector(),
in_param.covariance());
updated_params.push_back(bound_param);
n_branches++;
}
}

/*********************************
* Propagate to the next surface
*********************************/

const unsigned int n_links = links[step].size();
for (unsigned int link_id = 0; link_id < n_links; link_id++) {

// Create propagator state
typename propagator_type::state propagation(bound_param, field,
det);
propagation._stepping.template set_constraint<
detray::step::constraint::e_accuracy>(
const auto& param = updated_params[link_id];
// Create propagator state
typename propagator_type::state propagation(param, field, det);
propagation._stepping
.template set_constraint<detray::step::constraint::e_accuracy>(
m_cfg.propagation.stepping.step_constraint);

typename detray::pathlimit_aborter::state s0;
typename detray::parameter_transporter<transform3_type>::state
s1;
typename interactor::state s3;
typename interaction_register<interactor>::state s2{s3};
typename detray::next_surface_aborter::state s4{
m_cfg.min_step_length_for_surface_aborter};

propagation._navigation.set_volume(
bound_param.surface_link().volume());

// Propagate to the next surface
propagator.propagate_sync(propagation,
std::tie(s0, s1, s2, s3, s4));

// If a surface found, add the parameter for the next
// step
if (s4.success) {
out_params.push_back(propagation._stepping._bound_params);
param_to_link[step].push_back(cur_link_id);
}
// Unless the track found a surface, it is considered a
// tip
else if (!s4.success &&
step >= m_cfg.min_track_candidates_per_track - 1) {
tips.push_back({step, cur_link_id});
}
typename detray::pathlimit_aborter::state s0;
typename detray::parameter_transporter<transform3_type>::state s1;
typename interactor::state s3;
typename interaction_register<interactor>::state s2{s3};
typename detray::next_surface_aborter::state s4{
m_cfg.min_step_length_for_surface_aborter};

// @TODO: Should be removed once detray is fixed to set the
// volume in the constructor
propagation._navigation.set_volume(param.surface_link().volume());

// Propagate to the next surface
propagator.propagate_sync(propagation,
std::tie(s0, s1, s2, s3, s4));

// If a surface found, add the parameter for the next
// step
if (s4.success) {
out_params.push_back(propagation._stepping._bound_params);
param_to_link[step].push_back(link_id);
}
// Unless the track found a surface, it is considered a
// tip
else if (!s4.success &&
step >= m_cfg.min_track_candidates_per_track - 1) {
tips.push_back({step, link_id});
}

// If no more CKF step is expected, current candidate is
// kept as a tip
if (s4.success &&
step == m_cfg.max_track_candidates_per_track - 1) {
tips.push_back({step, link_id});
}
}

Expand Down

0 comments on commit ef6cdba

Please sign in to comment.