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  ProjectorBitSetMaker
struct  Flags
struct  PairWithFlags
struct  MatchingMeasurement

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
unsigned int makeOutlierFlag (bool value)
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 321 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 323 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 329 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 331 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 324 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 330 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 360 of file MeasurementSelector.h.

367 {
368 // create track states for all compatible measurement candidates
371
373
374 track_states.reserve( n_new_states );
377 for (unsigned int state_i=0; state_i<n_new_states; ++state_i) {
379
380 if (firstTrackState.has_value()) {
381 // subsequent track states don't need storage for these as they will
382 // be shared
384 }
385
386 if (outlier_states) {
387 // outlier won't have separate filtered parameters
389 }
390
392 ACTS_VERBOSE("Create SourceLink output track state #"
393 << trackState.index() << " with mask: " << mask);
394
395 if (firstTrackState.has_value()) {
398 }
399 else {
400 // only set these for first
401 trackState.predicted() = boundParams.parameters();
402 if (boundParams.covariance()) {
403 trackState.predictedCovariance() = *boundParams.covariance();
404 }
407 }
408 trackState.pathLength() = pathLength;
409
410 trackState.setReferenceSurface(boundParams.referenceSurface().getSharedPtr());
411
412 trackState.setProjectorSubspaceIndices(subspaceIndices);
413
414 auto typeFlags = trackState.typeFlags();
415 if (trackState.referenceSurface().surfaceMaterial() != nullptr) {
416 typeFlags.setHasMaterial();
417 }
418 typeFlags.setHasParameters();
419
420 // @TODO these track states still need some additional processing. Should there be a special
421 // flag for this ?
422 track_states.push_back( trackState.index());
423 }
424 }
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 334 of file MeasurementSelector.h.

334{ 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 677 of file MeasurementSelector.h.

679 {
683 // Get geoID of this surface
684 auto geoID = surface.geometryId();
685 // Find the appropriate cuts
686 auto cuts = m_config.find(geoID);
687 if (cuts == m_config.end()) {
688 // indicates failure
690 }
691 else {
692 // num measurement Cut
693 // getchi2 cut
695 numMeasurementsCut = (!cuts->numMeasurementsCutOff.empty()
696 ? cuts->numMeasurementsCutOff[ std::min(cuts->numMeasurementsCutOff.size()-1, eta_bin) ]
697 : NMeasMax);
698 maxChi2Cut = ! cuts->chi2CutOff.empty()
699 ? cuts->chi2CutOff[ std::min(cuts->chi2CutOff.size()-1, eta_bin) ]
702 ACTS_VERBOSE("Get cut for eta-bin="
704 << ": chi2 (max,max-outlier) " << maxChi2Cut.first << ", " << maxChi2Cut.second
705 << " max.meas." << numMeasurementsCut);
706 }
707 return result;
708 }
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 658 of file MeasurementSelector.h.

659 {
660 if (etaBins.empty()) {
661 return 0u; // shortcut if no etaBins
662 }
663 const float eta = std::abs(std::atanh(std::cos(boundParameters.parameters()[Acts::eBoundTheta])));
664 std::size_t bin = 0;
665 for (auto etaBin : etaBins) {
666 if (etaBin >= eta) {
667 break;
668 }
669 bin++;
670 }
671 return bin;
672 }

◆ makeOutlierFlag()

template<std::size_t NMeasMax, std::size_t DIMMAX, typename derived_t>
unsigned int MeasurementSelectorBase< NMeasMax, DIMMAX, derived_t >::makeOutlierFlag ( bool value)
inlineprotected

Definition at line 446 of file MeasurementSelector.h.

446{ return static_cast<unsigned int>(value)<<2u; }

◆ 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 464 of file MeasurementSelector.h.

474 {
477
478 using iterator_t = decltype(measurement_range.begin());
481 // get calibrator
484
487
488
489
490 // get prediction in the measurement domain
493 surface);
494 auto predicted
499
500 // select n measurents with the smallest chi2.
504 for ( const auto &measurement : measurement_range ) {
506 if (forced && postCalibrator) {
507 // skip preCalibrator and computeChi2, by doing everything else. We start with what's done if no preCalibrator.
508 const auto &m = derived().forwardToCalibrator(measurement);
509 matching_measurement.m_measurement = std::make_tuple( m.template localPosition<DIM>(), m.template localCovariance<DIM>(), 0u );
510 matching_measurement.m_chi2 = 0.0f;
512 if (!selected_measurements.acceptNoSort()) break;
513 } else {
516 surface,
519 matching_measurement.m_chi2 = computeChi2(matching_measurement.m_measurement.position(),
520 matching_measurement.m_measurement.covariance(),
521 predicted.first,
522 predicted.second);
523 // only consider measurements which pass the outlier chi2 cut
524 if (matching_measurement.m_chi2<maxChi2Cut.second) {
526 selected_measurements.acceptAndSort([](const TheMatchingMeasurement &a,
527 const TheMatchingMeasurement &b) {
528 return a.m_chi2 < b.m_chi2;
529 });
530 }
531 }
532 }
533
534 if (selected_measurements.empty()) {
535 auto config_for_surface = m_config.find(surface.geometryId());
536 if (config_for_surface != m_config.end()) {
537 if (config_for_surface->edgeTolerance.has_value()) {
538 // if the prediction failes the bound test, where the edgeTolerance is expected to be negative
539 // then the "hole" is considered to be an edge hole which is not treated as a hole.
540 auto local_coords = derived().boundParams(boundState).parameters().template block<2,1>(0,0);
541 if (!surface.insideBounds(local_coords,config_for_surface->edgeTolerance.value())) {
543 }
544 }
545 }
546 }
547 else {
548
549 // apply final calibration to n-best measurements
553
554 // First Create states without setting information about the calibrated measurement for the selected measurements
555 // @TODO first create state then copy measurements, or crete state by state and set measurements ?
556 // the lastter has the "advantage" that the outlier flag can be set individually
557 // the former has the advantage that part of the state creation code is independent of the
558 // the measurement.
559
564 prevTip,
567 *result,
568 logger,
569 (!selected_measurements.empty()
570 ? selected_measurements.getSlot( *(selected_measurements.begin())).m_measurement.flags().isOutlier() || postCalibrator
571 : false) );
572 assert( result->size() == selected_measurements.size() );
573
574 if (postCalibrator) {
575 // either run post selection calibrator which will set the calibrated position and covariance
576 // directly to the state.
577 auto predicted_pos_dbl = predicted.first.template cast<double>();
578 auto predicted_cov_dbl = predicted.second.template cast<double>();
579 unsigned int state_i=0u;
583 TrackStateProxy trackState( trajectory.getTrackState( (*result)[state_i] ) );
586
587 // apply the calibration
590 derived().forwardToCalibrator(a_selected_measurement.m_sourceLink.value()),
592 );
593 // update chi2 using calibrated measurement
598 // ... and set outlier flag
599 // and share or create storage for filtered.
600 bool is_outlier = !forced && trackState.chi2() >= maxChi2Cut.first;
601 if (is_outlier) {
602 trackState.typeFlags().setIsOutlier();
605 } else {
606 trackState.typeFlags().setIsMeasurement();
608 }
609 ++state_i;
610 }
611 }
612 else {
613 // or copy the pre-selection calibrated position and covariance to the
614 // track states and adjust the flags.
615 unsigned int state_i=0u;
619 TrackStateProxy trackState( trajectory.getTrackState( (*result)[state_i] ) );
621
622 bool is_outlier = !forced && a_selected_measurement.m_chi2 >= maxChi2Cut.first;
623 auto type_flags = trackState.typeFlags();
624 if (is_outlier) {
625 // the filtered parameters will not be computed for outliers, so has to be shared from the prediction.
626 type_flags.setIsOutlier();
629 } else {
630 // for measurements the filtered parameters will be computed, so space needs to be allocated.
631 type_flags.setIsMeasurement();
633 }
634 if (a_selected_measurement.m_measurement.flags().isSplitHit()) {
635 type_flags.setIsSplitHit();
636 }
637
639 ::pack(std::move(a_selected_measurement.m_sourceLink.value())));
640
641 trackState.allocateCalibrated(DIM);
642 trackState.template calibrated<DIM>()
644 ::MatrixFloatType>(a_selected_measurement.m_measurement.position());
647 ::MatrixFloatType>(a_selected_measurement.m_measurement.covariance());
648 trackState.chi2() = a_selected_measurement.m_chi2;
649 ++state_i;
650 }
651 }
652 }
653
654 return result;
655 }
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)
size_t size() const
Number of registered mappings.
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 326 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 332 of file MeasurementSelector.h.


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