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

#include <MeasurementSelector.h>

Collaboration diagram for MeasurementSelectorBase< NMeasMax, DIMMAX, derived_t >:

Classes

struct  MatchingMeasurement
struct  ProjectorBitSetMaker

Public Types

using Config = Acts::GeometryHierarchyMap<AtlasMeasurementSelectorCuts>
using traits = MeasurementSelectorTraits<derived_t>

Public Member Functions

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

Public Attributes

Config m_config

Protected Types

using T_BoundState = typename MeasurementSelectorTraits<derived_t>::BoundState
using trajectory_t = typename MeasurementSelectorTraits<derived_t>::trajectory_t
using TrackStateProxy = typename MeasurementSelectorTraits<derived_t>::TrackStateProxy

Protected Member Functions

const derived_t & derived () const
template<std::size_t DIM, typename T_MeasurementRange>
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)
template<typename parameters_t>
static std::size_t getEtaBin (const parameters_t &boundParameters, const std::vector< float > &etaBins)

Static Protected Attributes

static constexpr std::size_t s_maxBranchesPerSurface = MeasurementSelectorTraits<derived_t>::s_maxBranchesPerSurface

Detailed Description

template<std::size_t NMeasMax, std::size_t DIMMAX, typename derived_t>
struct MeasurementSelectorBase< NMeasMax, DIMMAX, derived_t >

Definition at line 318 of file MeasurementSelector.h.

Member Typedef Documentation

◆ Config

template<std::size_t NMeasMax, std::size_t DIMMAX, typename derived_t>
using MeasurementSelectorBase< NMeasMax, DIMMAX, derived_t >::Config = Acts::GeometryHierarchyMap<AtlasMeasurementSelectorCuts>

Definition at line 320 of file MeasurementSelector.h.

◆ T_BoundState

template<std::size_t NMeasMax, std::size_t DIMMAX, typename derived_t>
using MeasurementSelectorBase< NMeasMax, DIMMAX, derived_t >::T_BoundState = typename MeasurementSelectorTraits<derived_t>::BoundState
protected

Definition at line 326 of file MeasurementSelector.h.

◆ TrackStateProxy

template<std::size_t NMeasMax, std::size_t DIMMAX, typename derived_t>
using MeasurementSelectorBase< NMeasMax, DIMMAX, derived_t >::TrackStateProxy = typename MeasurementSelectorTraits<derived_t>::TrackStateProxy
protected

Definition at line 328 of file MeasurementSelector.h.

◆ traits

template<std::size_t NMeasMax, std::size_t DIMMAX, typename derived_t>
using MeasurementSelectorBase< NMeasMax, DIMMAX, derived_t >::traits = MeasurementSelectorTraits<derived_t>

Definition at line 321 of file MeasurementSelector.h.

◆ trajectory_t

template<std::size_t NMeasMax, std::size_t DIMMAX, typename derived_t>
using MeasurementSelectorBase< NMeasMax, DIMMAX, derived_t >::trajectory_t = typename MeasurementSelectorTraits<derived_t>::trajectory_t
protected

Definition at line 327 of file MeasurementSelector.h.

Member Function Documentation

◆ createStates()

template<std::size_t NMeasMax, std::size_t DIMMAX, typename derived_t>
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 )
inlinestaticprotected

Definition at line 357 of file MeasurementSelector.h.

364 {
365 // create track states for all compatible measurement candidates
368
370
371 track_states.reserve( n_new_states );
374 for (unsigned int state_i=0; state_i<n_new_states; ++state_i) {
376
377 if (firstTrackState.has_value()) {
378 // subsequent track states don't need storage for these as they will
379 // be shared
381 }
382
383 if (outlier_states) {
384 // outlier won't have separate filtered parameters
386 }
387
389 ACTS_VERBOSE("Create SourceLink output track state #"
390 << trackState.index() << " with mask: " << mask);
391
392 if (firstTrackState.has_value()) {
395 }
396 else {
397 // only set these for first
398 trackState.predicted() = boundParams.parameters();
399 if (boundParams.covariance()) {
400 trackState.predictedCovariance() = *boundParams.covariance();
401 }
404 }
405 trackState.pathLength() = pathLength;
406
407 trackState.setReferenceSurface(boundParams.referenceSurface().getSharedPtr());
408
409 trackState.setProjectorSubspaceIndices(subspaceIndices);
410
412 if (trackState.referenceSurface().surfaceMaterial() != nullptr) {
414 }
416
417 // @TODO these track states still need some additional processing. Should there be a special
418 // flag for this ?
419 track_states.push_back( trackState.index());
420 }
421 }
typename MeasurementSelectorTraits< derived_t >::TrackStateProxy TrackStateProxy

◆ derived()

template<std::size_t NMeasMax, std::size_t DIMMAX, typename derived_t>
const derived_t & MeasurementSelectorBase< NMeasMax, DIMMAX, derived_t >::derived ( ) const
inlineprotected

Definition at line 331 of file MeasurementSelector.h.

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

◆ getCuts()

template<std::size_t NMeasMax, std::size_t DIMMAX, typename derived_t>
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
inline

Definition at line 684 of file MeasurementSelector.h.

686 {
690 // Get geoID of this surface
691 auto geoID = surface.geometryId();
692 // Find the appropriate cuts
693 auto cuts = m_config.find(geoID);
694 if (cuts == m_config.end()) {
695 // indicates failure
697 }
698 else {
699 // num measurement Cut
700 // getchi2 cut
702 numMeasurementsCut = (!cuts->numMeasurementsCutOff.empty()
703 ? cuts->numMeasurementsCutOff[ std::min(cuts->numMeasurementsCutOff.size()-1, eta_bin) ]
704 : NMeasMax);
705 maxChi2Cut = ! cuts->chi2CutOff.empty()
706 ? cuts->chi2CutOff[ std::min(cuts->chi2CutOff.size()-1, eta_bin) ]
709 ACTS_VERBOSE("Get cut for eta-bin="
711 << ": chi2 (max,max-outlier) " << maxChi2Cut.first << ", " << maxChi2Cut.second
712 << " max.meas." << numMeasurementsCut);
713 }
714 return result;
715 }
const derived_t & derived() const
static std::size_t getEtaBin(const parameters_t &boundParameters, const std::vector< float > &etaBins)

◆ getEtaBin()

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

Definition at line 665 of file MeasurementSelector.h.

666 {
667 if (etaBins.empty()) {
668 return 0u; // shortcut if no etaBins
669 }
670 const float eta = std::abs(std::atanh(std::cos(boundParameters.parameters()[Acts::eBoundTheta])));
671 std::size_t bin = 0;
672 for (auto etaBin : etaBins) {
673 if (etaBin >= eta) {
674 break;
675 }
676 bin++;
677 }
678 return bin;
679 }

◆ selectMeasurementsCreateTrackStates()

template<std::size_t NMeasMax, std::size_t DIMMAX, typename derived_t>
template<std::size_t DIM, typename T_MeasurementRange>
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
inlineprotected

Definition at line 442 of file MeasurementSelector.h.

452 {
455
456 using iterator_t = decltype(measurement_range.begin());
459 // get calibrator
462
465
466
467
468 // get prediction in the measurement domain
471 surface);
472 auto predicted
477
478 // select n measurents with the smallest chi2.
482 for ( const auto &measurement : measurement_range ) {
484 if (forced && postCalibrator) {
485 // skip preCalibrator and computeChi2, by doing everything else. We start with what's done if no preCalibrator.
486 const auto &m = derived().forwardToCalibrator(measurement);
487 matching_measurement.m_measurement = std::make_pair( m.template localPosition<DIM>(), m.template localCovariance<DIM>() );
488 matching_measurement.m_chi2 = 0.0f;
490 if (!selected_measurements.acceptNoSort()) break;
491 } else {
496 matching_measurement.m_chi2 = computeChi2(matching_measurement.m_measurement.first,
497 matching_measurement.m_measurement.second,
498 predicted.first,
499 predicted.second);
500 // only consider measurements which pass the outlier chi2 cut
501 if (matching_measurement.m_chi2<maxChi2Cut.second) {
503 selected_measurements.acceptAndSort([](const TheMatchingMeasurement &a,
504 const TheMatchingMeasurement &b) {
505 return a.m_chi2 < b.m_chi2;
506 });
507 }
508 }
509 }
510
511 // apply final calibration to n-best measurements
515
516 // need extra temporary buffer if the types to store "measurements" during measurement selection
517 // and calibrated measurements after the measurement selection are not identical
518 static constexpr bool pre_and_post_calib_types_agree
523
524 using Empty = struct {};
526 std::array< post_calib_meas_cov_pair_t, NMeasMax>, // @TODO could use boost static_vector instead
528 if (postCalibrator) {
530
531 // apply final calibration, recompute chi2
535
536 // helper to select the destination storage which is the extra temporary buffer
537 // if the measurement storage types during and after selection are different.
540 if constexpr(pre_and_post_calib_types_agree) {
543 return a_selected_measurement.m_measurement;
544 }
545 else {
549 }
550 }();
551
552 // apply the calibration
555 derived().forwardToCalibrator(a_selected_measurement.m_sourceLink.value()),
557 // update chi2 using calibrated measurement
560 predicted.first,
561 predicted.second);
562 // ... and set outlier flag
563 a_selected_measurement.m_isOutLier = (!forced && a_selected_measurement.m_chi2 >= maxChi2Cut.first);
564 if constexpr(!pre_and_post_calib_types_agree) {
566 }
567 }
568 }
569 else {
570 // if no final calibration is performed only the outlier flag still needs to be set
574 a_selected_measurement.m_isOutLier = (!forced && a_selected_measurement.m_chi2 >= maxChi2Cut.first);
575 }
576 }
577
578 // First Create states without setting information about the calibrated measurement for the selected measurements
579 // @TODO first create state then copy measurements, or crete state by state and set measurements ?
580 // the lastter has the "advantage" that the outlier flag can be set individually
581 // the former has the advantage that part of the state creation code is independent of the
582 // the measurement.
583
588 prevTip,
591 *result,
592 logger,
593 (!selected_measurements.empty()
594 ? selected_measurements.getSlot( *(selected_measurements.begin())).m_isOutLier
595 : false) );
596 assert( result->size() == selected_measurements.size() );
597
598 // helper to determine whether calibrated storeage is to be used
599 auto use_calibrated_storage = [&postCalibrator]() -> bool {
600 if constexpr(pre_and_post_calib_types_agree) {
602 return false;
603 }
604 else {
605 // this is only known during runtime
606 // but it should not be tested if the types agree.
607 return postCalibrator;
608 }
609 };
610
611 if (selected_measurements.empty()) {
612 auto config_for_surface = m_config.find(surface.geometryId());
613 if (config_for_surface != m_config.end()) {
614 if (config_for_surface->edgeTolerance.has_value()) {
615 // if the prediction failes the bound test, where the edgeTolerance is expected to be negative
616 // then the "hole" is considered to be an edge hole which is not treated as a hole.
617 auto local_coords = derived().boundParams(boundState).parameters().template block<2,1>(0,0);
618 if (!surface.insideBounds(local_coords,config_for_surface->edgeTolerance.value())) {
620 }
621 }
622 }
623 }
624 else {
625 // copy selected measurements to pre-created states
626 unsigned int state_i=0;
630 TrackStateProxy trackState( trajectory.getTrackState( (*result)[state_i] ) );
632 trackState.setUncalibratedSourceLink(derived().makeSourceLink(std::move(a_selected_measurement.m_sourceLink.value())));
633 // flag outliers accordingly, so that they are handled correctly by the post processing
634 trackState.typeFlags().set( a_selected_measurement.m_isOutLier
637 trackState.allocateCalibrated(DIM);
639 // if the final clibration is performed after the selection then
640 // copy these measurements and covariances to the track states
642 if constexpr(!pre_and_post_calib_types_agree) {
643 assert( state_i < calibrated.size());
644 trackState.template calibrated<DIM>()
648 trackState.chi2() = a_selected_measurement.m_chi2;
649 }
650 }
651 else {
652 trackState.template calibrated<DIM>()
656 trackState.chi2() = a_selected_measurement.m_chi2;
657 }
658 ++state_i;
659 }
660 }
661 return result;
662 }
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)
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)

Member Data Documentation

◆ m_config

template<std::size_t NMeasMax, std::size_t DIMMAX, typename derived_t>
Config MeasurementSelectorBase< NMeasMax, DIMMAX, derived_t >::m_config

Definition at line 323 of file MeasurementSelector.h.

◆ s_maxBranchesPerSurface

template<std::size_t NMeasMax, std::size_t DIMMAX, typename derived_t>
std::size_t MeasurementSelectorBase< NMeasMax, DIMMAX, derived_t >::s_maxBranchesPerSurface = MeasurementSelectorTraits<derived_t>::s_maxBranchesPerSurface
staticconstexprprotected

Definition at line 329 of file MeasurementSelector.h.


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