ATLAS Offline Software
Loading...
Searching...
No Matches
MeasurementSelectorWithDispatch< NMeasMax, derived_t, measurement_container_variant_t > Struct Template Reference

#include <MeasurementSelector.h>

Inheritance diagram for MeasurementSelectorWithDispatch< NMeasMax, derived_t, measurement_container_variant_t >:
Collaboration diagram for MeasurementSelectorWithDispatch< NMeasMax, derived_t, measurement_container_variant_t >:

Public Types

using Base = MeasurementSelectorBase< NMeasMax, MeasurementSelectorTraits<derived_t>::s_dimMax, derived_t>
using T_BoundState = typename Base::T_BoundState
using trajectory_t = typename Base::trajectory_t
using TrackStateProxy = typename Base::TrackStateProxy
using Config
using traits

Public Member Functions

Acts::Result< boost::container::small_vector< typename TrackStateProxy::IndexType, s_maxBranchesPerSurface > > createTrackStates (const Acts::GeometryContext &geometryContext, const Acts::CalibrationContext &calibrationContext, const Acts::Surface &surface, const T_BoundState &boundState, typename TrackStateProxy::IndexType prevTip, std::vector< TrackStateProxy > &trackStateCandidates, trajectory_t &trajectory, const Acts::Logger &logger) const
std::tuple< std::size_t, std::pair< float, float > > getCuts (const Acts::Surface &surface, const T_BoundState &boundState, const Acts::Logger &logger) const

Static Public Member Functions

static constexpr std::size_t dimMax ()

Public Attributes

Config m_config

Static Public Attributes

static constexpr std::size_t s_maxBranchesPerSurface = Base::s_maxBranchesPerSurface

Protected Member Functions

const derived_t & derived () const
Acts::Result< boost::container::small_vector< typename TrackStateProxy::IndexType, s_maxBranchesPerSurface > > selectMeasurementsCreateTrackStates (const Acts::GeometryContext &geometryContext, const Acts::CalibrationContext &calibrationContext, const Acts::Surface &surface, const T_BoundState &boundState, T_MeasurementRange &&measurement_range, std::size_t prevTip, trajectory_t &trajectory, const Acts::Logger &logger, const std::size_t numMeasurementsCut, const std::pair< float, float > &maxChi2Cut, bool forced) const

Static Protected Member Functions

static void createStates (std::size_t n_new_states, const T_BoundState &boundState, std::size_t prevTip, trajectory_t &trajectory, const Acts::BoundSubspaceIndices &subspaceIndices, boost::container::small_vector< typename TrackStateProxy::IndexType, s_maxBranchesPerSurface > &track_states, const Acts::Logger &logger, bool outlier_states)
static std::size_t getEtaBin (const parameters_t &boundParameters, const std::vector< float > &etaBins)

Detailed Description

template<std::size_t NMeasMax, typename derived_t, typename measurement_container_variant_t>
struct MeasurementSelectorWithDispatch< NMeasMax, derived_t, measurement_container_variant_t >

Definition at line 714 of file MeasurementSelector.h.

Member Typedef Documentation

◆ Base

template<std::size_t NMeasMax, typename derived_t, typename measurement_container_variant_t>
using MeasurementSelectorWithDispatch< NMeasMax, derived_t, measurement_container_variant_t >::Base = MeasurementSelectorBase< NMeasMax, MeasurementSelectorTraits<derived_t>::s_dimMax, derived_t>

Definition at line 716 of file MeasurementSelector.h.

◆ Config

using MeasurementSelectorBase< NMeasMax, DIMMAX, derived_t >::Config
inherited

Definition at line 318 of file MeasurementSelector.h.

◆ T_BoundState

template<std::size_t NMeasMax, typename derived_t, typename measurement_container_variant_t>
using MeasurementSelectorWithDispatch< NMeasMax, derived_t, measurement_container_variant_t >::T_BoundState = typename Base::T_BoundState

Definition at line 717 of file MeasurementSelector.h.

◆ TrackStateProxy

template<std::size_t NMeasMax, typename derived_t, typename measurement_container_variant_t>
using MeasurementSelectorWithDispatch< NMeasMax, derived_t, measurement_container_variant_t >::TrackStateProxy = typename Base::TrackStateProxy

Definition at line 719 of file MeasurementSelector.h.

◆ traits

using MeasurementSelectorBase< NMeasMax, DIMMAX, derived_t >::traits
inherited

Definition at line 319 of file MeasurementSelector.h.

◆ trajectory_t

template<std::size_t NMeasMax, typename derived_t, typename measurement_container_variant_t>
using MeasurementSelectorWithDispatch< NMeasMax, derived_t, measurement_container_variant_t >::trajectory_t = typename Base::trajectory_t

Definition at line 718 of file MeasurementSelector.h.

Member Function Documentation

◆ createStates()

void MeasurementSelectorBase< NMeasMax, DIMMAX, derived_t >::createStates ( std::size_t n_new_states,
const T_BoundState & boundState,
std::size_t prevTip,
trajectory_t & trajectory,
const Acts::BoundSubspaceIndices & subspaceIndices,
boost::container::small_vector< typename TrackStateProxy::IndexType, s_maxBranchesPerSurface > & track_states,
const Acts::Logger & logger,
bool outlier_states )
inlinestaticprotectedinherited

Definition at line 355 of file MeasurementSelector.h.

362 {
363 // create track states for all compatible measurement candidates
366
368
369 track_states.reserve( n_new_states );
372 for (unsigned int state_i=0; state_i<n_new_states; ++state_i) {
374
375 if (firstTrackState.has_value()) {
376 // subsequent track states don't need storage for these as they will
377 // be shared
379 }
380
381 if (outlier_states) {
382 // outlier won't have separate filtered parameters
384 }
385
387 ACTS_VERBOSE("Create SourceLink output track state #"
388 << trackState.index() << " with mask: " << mask);
389
390 if (firstTrackState.has_value()) {
393 }
394 else {
395 // only set these for first
396 trackState.predicted() = boundParams.parameters();
397 if (boundParams.covariance()) {
398 trackState.predictedCovariance() = *boundParams.covariance();
399 }
402 }
403 trackState.pathLength() = pathLength;
404
405 trackState.setReferenceSurface(boundParams.referenceSurface().getSharedPtr());
406
407 trackState.setProjectorSubspaceIndices(subspaceIndices);
408
410 if (trackState.referenceSurface().surfaceMaterial() != nullptr) {
412 }
414
415 // @TODO these track states still need some additional processing. Should there be a special
416 // flag for this ?
417 track_states.push_back( trackState.index());
418 }
419 }

◆ createTrackStates()

template<std::size_t NMeasMax, typename derived_t, typename measurement_container_variant_t>
Acts::Result< boost::container::small_vector< typename TrackStateProxy::IndexType, s_maxBranchesPerSurface > > MeasurementSelectorWithDispatch< NMeasMax, derived_t, measurement_container_variant_t >::createTrackStates ( const Acts::GeometryContext & geometryContext,
const Acts::CalibrationContext & calibrationContext,
const Acts::Surface & surface,
const T_BoundState & boundState,
typename TrackStateProxy::IndexType prevTip,
std::vector< TrackStateProxy > & trackStateCandidates,
trajectory_t & trajectory,
const Acts::Logger & logger ) const
inline

Definition at line 728 of file MeasurementSelector.h.

735 {
736
739 // get associated measurement container and the relevant measurement range for the given surface.
740 auto [a_measurement_container_variant_ptr, range, forced] = this->derived().containerAndRange(surface);
743 return result;
744 }
745 if (!range.empty()) {
747 // numMeasurementsCut is == 0 in case getCuts failed
748 // anyway cannot select anything if numMeasurementsCut==0;
749 if (numMeasurementsCut>0) {
750
751 result = std::visit( [this,
754 &surface,
755 &boundState,
756 &range,
757 prevTip,
758 &trajectory,
759 &logger,
761 &maxChi2Cut,
764 constexpr std::size_t DIM = ArgType::dimension();
766 return
767 this->template
770 surface,
773 prevTip,
775 logger,
778 forced);
779 },
781 }
782 }
783 else {
785 }
786 return result;
787 }
std::tuple< std::size_t, std::pair< float, float > > getCuts(const Acts::Surface &surface, const T_BoundState &boundState, const Acts::Logger &logger) const
Acts::Result< boost::container::small_vector< typename TrackStateProxy::IndexType, s_maxBranchesPerSurface > > selectMeasurementsCreateTrackStates(const Acts::GeometryContext &geometryContext, const Acts::CalibrationContext &calibrationContext, const Acts::Surface &surface, const T_BoundState &boundState, T_MeasurementRange &&measurement_range, std::size_t prevTip, trajectory_t &trajectory, const Acts::Logger &logger, const std::size_t numMeasurementsCut, const std::pair< float, float > &maxChi2Cut, bool forced) const

◆ derived()

const derived_t & MeasurementSelectorBase< NMeasMax, DIMMAX, derived_t >::derived ( ) const
inlineprotectedinherited

Definition at line 329 of file MeasurementSelector.h.

329{ return *static_cast<const derived_t *>(this); }

◆ dimMax()

template<std::size_t NMeasMax, typename derived_t, typename measurement_container_variant_t>
constexpr std::size_t MeasurementSelectorWithDispatch< NMeasMax, derived_t, measurement_container_variant_t >::dimMax ( )
inlinestaticconstexpr

Definition at line 723 of file MeasurementSelector.h.

◆ getCuts()

std::tuple< std::size_t, std::pair< float, float > > MeasurementSelectorBase< NMeasMax, DIMMAX, derived_t >::getCuts ( const Acts::Surface & surface,
const T_BoundState & boundState,
const Acts::Logger & logger ) const
inlineinherited

Definition at line 667 of file MeasurementSelector.h.

669 {
673 // Get geoID of this surface
674 auto geoID = surface.geometryId();
675 // Find the appropriate cuts
676 auto cuts = m_config.find(geoID);
677 if (cuts == m_config.end()) {
678 // indicats failure
680 }
681 else {
682 // num measurement Cut
683 // getchi2 cut
685 numMeasurementsCut = (!cuts->numMeasurementsCutOff.empty()
686 ? cuts->numMeasurementsCutOff[ std::min(cuts->numMeasurementsCutOff.size()-1, eta_bin) ]
687 : NMeasMax);
688 maxChi2Cut = ! cuts->chi2CutOff.empty()
689 ? cuts->chi2CutOff[ std::min(cuts->chi2CutOff.size()-1, eta_bin) ]
692 ACTS_VERBOSE("Get cut for eta-bin="
694 << ": chi2 (max,max-outlier) " << maxChi2Cut.first << ", " << maxChi2Cut.second
695 << " max.meas." << numMeasurementsCut);
696 }
697 return result;
698 }

◆ getEtaBin()

std::size_t MeasurementSelectorBase< NMeasMax, DIMMAX, derived_t >::getEtaBin ( const parameters_t & boundParameters,
const std::vector< float > & etaBins )
inlinestaticprotectedinherited

Definition at line 648 of file MeasurementSelector.h.

649 {
650 if (etaBins.empty()) {
651 return 0u; // shortcut if no etaBins
652 }
653 const float eta = std::abs(std::atanh(std::cos(boundParameters.parameters()[Acts::eBoundTheta])));
654 std::size_t bin = 0;
655 for (auto etaBin : etaBins) {
656 if (etaBin >= eta) {
657 break;
658 }
659 bin++;
660 }
661 return bin;
662 }

◆ selectMeasurementsCreateTrackStates()

Acts::Result< boost::container::small_vector< typename TrackStateProxy::IndexType, s_maxBranchesPerSurface > > MeasurementSelectorBase< NMeasMax, DIMMAX, derived_t >::selectMeasurementsCreateTrackStates ( const Acts::GeometryContext & geometryContext,
const Acts::CalibrationContext & calibrationContext,
const Acts::Surface & surface,
const T_BoundState & boundState,
T_MeasurementRange && measurement_range,
std::size_t prevTip,
trajectory_t & trajectory,
const Acts::Logger & logger,
const std::size_t numMeasurementsCut,
const std::pair< float, float > & maxChi2Cut,
bool forced ) const
inlineprotectedinherited

Definition at line 440 of file MeasurementSelector.h.

450 {
453
454 using iterator_t = decltype(measurement_range.begin());
457 // get calibrator
460
463
464
465
466 // get prediction in the measurement domain
469 surface);
470 auto predicted
475
476 // select n measurents with the smallest chi2.
480 for ( const auto &measurement : measurement_range ) {
482 if (forced && postCalibrator) {
483 // skip preCalibrator and computeChi2, by doing everything else. We start with what's done if no preCalibrator.
484 const auto &m = derived().forwardToCalibrator(measurement);
485 matching_measurement.m_measurement = std::make_pair( m.template localPosition<DIM>(), m.template localCovariance<DIM>() );
486 matching_measurement.m_chi2 = 0.0f;
488 if (!selected_measurements.acceptNoSort()) break;
489 } else {
494 matching_measurement.m_chi2 = computeChi2(matching_measurement.m_measurement.first,
495 matching_measurement.m_measurement.second,
496 predicted.first,
497 predicted.second);
498 // only consider measurements which pass the outlier chi2 cut
499 if (matching_measurement.m_chi2<maxChi2Cut.second) {
501 selected_measurements.acceptAndSort([](const TheMatchingMeasurement &a,
502 const TheMatchingMeasurement &b) {
503 return a.m_chi2 < b.m_chi2;
504 });
505 }
506 }
507 }
508
509 // apply final calibration to n-best measurements
513
514 // need extra temporary buffer if the types to store "measurements" during measurement selection
515 // and calibrated measurements after the measurement selection are not identical
516 static constexpr bool pre_and_post_calib_types_agree
521
522 using Empty = struct {};
524 std::array< post_calib_meas_cov_pair_t, NMeasMax>, // @TODO could use boost static_vector instead
526 if (postCalibrator) {
528
529 // apply final calibration, recompute chi2
533
534 // helper to select the destination storage which is the extra temporary buffer
535 // if the measurement storage types during and after selection are different.
538 if constexpr(pre_and_post_calib_types_agree) {
541 return a_selected_measurement.m_measurement;
542 }
543 else {
547 }
548 }();
549
550 // apply the calibration
553 derived().forwardToCalibrator(a_selected_measurement.m_sourceLink.value()),
555 // update chi2 using calibrated measurement
558 predicted.first,
559 predicted.second);
560 // ... and set outlier flag
561 a_selected_measurement.m_isOutLier = (!forced && a_selected_measurement.m_chi2 >= maxChi2Cut.first);
562 if constexpr(!pre_and_post_calib_types_agree) {
564 }
565 }
566 }
567 else {
568 // if no final calibration is performed only the outlier flag still needs to be set
572 a_selected_measurement.m_isOutLier = (!forced && a_selected_measurement.m_chi2 >= maxChi2Cut.first);
573 }
574 }
575
576 // First Create states without setting information about the calibrated measurement for the selected measurements
577 // @TODO first create state then copy measurements, or crete state by state and set measurements ?
578 // the lastter has the "advantage" that the outlier flag can be set individually
579 // the former has the advantage that part of the state creation code is independent of the
580 // the measurement.
581
586 prevTip,
589 *result,
590 logger,
591 (!selected_measurements.empty()
592 ? selected_measurements.getSlot( *(selected_measurements.begin())).m_isOutLier
593 : false) );
594 assert( result->size() == selected_measurements.size() );
595
596 // helper to determine whether calibrated storeage is to be used
597 auto use_calibrated_storage = [&postCalibrator]() -> bool {
598 if constexpr(pre_and_post_calib_types_agree) {
600 return false;
601 }
602 else {
603 // this is only known during runtime
604 // but it should not be tested if the types agree.
605 return postCalibrator;
606 }
607 };
608
609 // copy selected measurements to pre-created states
610 unsigned int state_i=0;
614 TrackStateProxy trackState( trajectory.getTrackState( (*result)[state_i] ) );
616 trackState.setUncalibratedSourceLink(derived().makeSourceLink(std::move(a_selected_measurement.m_sourceLink.value())));
617 // flag outliers accordingly, so that they are handled correctly by the post processing
618 trackState.typeFlags().set( a_selected_measurement.m_isOutLier
621 trackState.allocateCalibrated(DIM);
623 // if the final clibration is performed after the selection then
624 // copy these measurements and covariances to the track states
626 if constexpr(!pre_and_post_calib_types_agree) {
627 assert( state_i < calibrated.size());
628 trackState.template calibrated<DIM>()
632 trackState.chi2() = a_selected_measurement.m_chi2;
633 }
634 }
635 else {
636 trackState.template calibrated<DIM>()
640 trackState.chi2() = a_selected_measurement.m_chi2;
641 }
642 ++state_i;
643 }
644 return result;
645 }
double computeChi2(const measurement_vector_t &a, const measurement_cov_matrix_t &a_cov, const predicted_vector_t &b, const predicted_cov_matrix_t &b_cov)

Member Data Documentation

◆ m_config

Config MeasurementSelectorBase< NMeasMax, DIMMAX, derived_t >::m_config
inherited

Definition at line 321 of file MeasurementSelector.h.

◆ s_maxBranchesPerSurface

template<std::size_t NMeasMax, typename derived_t, typename measurement_container_variant_t>
std::size_t MeasurementSelectorWithDispatch< NMeasMax, derived_t, measurement_container_variant_t >::s_maxBranchesPerSurface = Base::s_maxBranchesPerSurface
staticconstexpr

Definition at line 720 of file MeasurementSelector.h.


The documentation for this struct was generated from the following file: