ATLAS Offline Software
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | List of all members
MeasurementSelectorBaseImpl< NMeasMax, derived_t, measurement_container_variant_t > Struct Template Reference

#include <MeasurementSelector.h>

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

Public Types

using T_BoundState = MeasurementSelectorTraits< derived_t >::BoundState
 
using abstract_measurement_range_t = MeasurementSelectorTraits< derived_t >::abstract_measurement_range_t
 
template<std::size_t DIM, typename measurement_t >
using PreCalibrator = Acts::Delegate< std::pair< typename MeasurementSelectorTraits< derived_t >::template PreSelectionMeasurement< DIM >, typename MeasurementSelectorTraits< derived_t >::template PreSelectionMeasurementCovariance< DIM > >(const Acts::GeometryContext &, const Acts::CalibrationContext &, const measurement_t &, const typename MeasurementSelectorTraits< derived_t >::BoundTrackParameters &)>
 
template<std::size_t DIM, typename measurement_t >
using PostCalibrator = Acts::Delegate< std::pair< typename MeasurementSelectorTraits< derived_t >::template CalibratedMeasurement< DIM >, typename MeasurementSelectorTraits< derived_t >::template CalibratedMeasurementCovariance< DIM > >(const Acts::GeometryContext &, const Acts::CalibrationContext &, const measurement_t &, const typename MeasurementSelectorTraits< derived_t >::BoundTrackParameters &)>
 
using Base = MeasurementSelectorBase< NMeasMax, MeasurementSelectorTraits< derived_t >::s_dimMax, derived_t >
 
using trajectory_t = typename Base::trajectory_t
 
using TrackStateProxy = typename Base::TrackStateProxy
 
using Config = Acts::GeometryHierarchyMap< AtlasMeasurementSelectorCuts >
 
using traits = MeasurementSelectorTraits< derived_t >
 

Public Member Functions

template<std::size_t DIM>
ParameterMapping::type< DIM > parameterMap (const Acts::GeometryContext &, const Acts::CalibrationContext &, const Acts::Surface &)
 
template<std::size_t DIM, typename measurement_t >
const PostCalibrator< DIM, measurement_t > & postCalibrator () const
 the calibrator used after the measurement selection which does not have to be "connected" More...
 
template<std::size_t DIM, typename measurement_t >
const PreCalibrator< DIM, measurement_t > & preCalibrator () const
 
std::tuple< const measurement_container_variant_t &, abstract_measurement_range_tcontainerAndRange (const Acts::Surface &surface) const
 Get container and index range for measurements on the given surface. More...
 
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, [[maybe_unused]] 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 const MeasurementSelectorTraits< derived_t >::BoundTrackParameters & boundParams (const T_BoundState &boundState)
 
static const MeasurementSelectorTraits< derived_t >::BoundMatrix & boundJacobiMatrix (const T_BoundState &boundState)
 
static double pathLength (const T_BoundState &boundState)
 
template<typename T_Value >
static Acts::SourceLink makeSourceLink (T_Value &&value)
 
template<typename T >
static const auto & forwardToCalibrator (const T &a)
 
template<typename measurement_container_t >
static auto rangeForContainer (const measurement_container_t &concrete_container, const abstract_measurement_range_t &abstract_range)
 Create a range over elements of the given container from an abstract range. More...
 
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) 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 MeasurementSelectorBaseImpl< NMeasMax, derived_t, measurement_container_variant_t >

Definition at line 770 of file MeasurementSelector.h.

Member Typedef Documentation

◆ abstract_measurement_range_t

template<std::size_t NMeasMax, typename derived_t , typename measurement_container_variant_t >
using MeasurementSelectorBaseImpl< NMeasMax, derived_t, measurement_container_variant_t >::abstract_measurement_range_t = MeasurementSelectorTraits<derived_t>::abstract_measurement_range_t

Definition at line 772 of file MeasurementSelector.h.

◆ 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>
inherited

Definition at line 699 of file MeasurementSelector.h.

◆ Config

using MeasurementSelectorBase< NMeasMax, DIMMAX, derived_t >::Config = Acts::GeometryHierarchyMap<AtlasMeasurementSelectorCuts>
inherited

Definition at line 309 of file MeasurementSelector.h.

◆ PostCalibrator

template<std::size_t NMeasMax, typename derived_t , typename measurement_container_variant_t >
template<std::size_t DIM, typename measurement_t >
using MeasurementSelectorBaseImpl< NMeasMax, derived_t, measurement_container_variant_t >::PostCalibrator = Acts::Delegate< std::pair < typename MeasurementSelectorTraits<derived_t>::template CalibratedMeasurement<DIM>, typename MeasurementSelectorTraits<derived_t>::template CalibratedMeasurementCovariance<DIM> > (const Acts::GeometryContext&, const Acts::CalibrationContext&, const measurement_t &, const typename MeasurementSelectorTraits<derived_t>::BoundTrackParameters &)>

Definition at line 833 of file MeasurementSelector.h.

◆ PreCalibrator

template<std::size_t NMeasMax, typename derived_t , typename measurement_container_variant_t >
template<std::size_t DIM, typename measurement_t >
using MeasurementSelectorBaseImpl< NMeasMax, derived_t, measurement_container_variant_t >::PreCalibrator = Acts::Delegate< std::pair < typename MeasurementSelectorTraits<derived_t>::template PreSelectionMeasurement<DIM>, typename MeasurementSelectorTraits<derived_t>::template PreSelectionMeasurementCovariance<DIM> > (const Acts::GeometryContext&, const Acts::CalibrationContext&, const measurement_t &, const typename MeasurementSelectorTraits<derived_t>::BoundTrackParameters &)>

Definition at line 822 of file MeasurementSelector.h.

◆ T_BoundState

template<std::size_t NMeasMax, typename derived_t , typename measurement_container_variant_t >
using MeasurementSelectorBaseImpl< NMeasMax, derived_t, measurement_container_variant_t >::T_BoundState = MeasurementSelectorTraits<derived_t>::BoundState

Definition at line 771 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
inherited

Definition at line 702 of file MeasurementSelector.h.

◆ traits

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

Definition at line 310 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
inherited

Definition at line 701 of file MeasurementSelector.h.

Member Function Documentation

◆ boundJacobiMatrix()

template<std::size_t NMeasMax, typename derived_t , typename measurement_container_variant_t >
static const MeasurementSelectorTraits<derived_t>::BoundMatrix& MeasurementSelectorBaseImpl< NMeasMax, derived_t, measurement_container_variant_t >::boundJacobiMatrix ( const T_BoundState boundState)
inlinestatic

Definition at line 780 of file MeasurementSelector.h.

780  {
781  return std::get<1>(boundState);
782  }

◆ boundParams()

template<std::size_t NMeasMax, typename derived_t , typename measurement_container_variant_t >
static const MeasurementSelectorTraits<derived_t>::BoundTrackParameters& MeasurementSelectorBaseImpl< NMeasMax, derived_t, measurement_container_variant_t >::boundParams ( const T_BoundState boundState)
inlinestatic

Definition at line 775 of file MeasurementSelector.h.

775  {
776  return std::get<0>(boundState);
777  }

◆ containerAndRange()

template<std::size_t NMeasMax, typename derived_t , typename measurement_container_variant_t >
std::tuple<const measurement_container_variant_t &, abstract_measurement_range_t> MeasurementSelectorBaseImpl< NMeasMax, derived_t, measurement_container_variant_t >::containerAndRange ( const Acts::Surface &  surface) const

Get container and index range for measurements on the given surface.

Returns
tuple of container, begin index and end index
Note
return a tuple containing a measurement container variant for the given surface and the index range for measurements on that surface. The index range may be empty.

◆ createStates()

static 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 346 of file MeasurementSelector.h.

353  {
354  // create track states for all compatible measurement candidates
355  const auto &boundParams = derived_t::boundParams(boundState);
356  const auto &pathLength = derived_t::pathLength(boundState);
357 
358  using PM = Acts::TrackStatePropMask;
359 
360  track_states.reserve( n_new_states );
361  std::optional<TrackStateProxy> firstTrackState{
362  std::nullopt};
363  for (unsigned int state_i=0; state_i<n_new_states; ++state_i) {
364  PM mask = PM::Predicted | PM::Filtered | PM::Jacobian | PM::Calibrated;
365 
366  if (firstTrackState.has_value()) {
367  // subsequent track states don't need storage for these as they will
368  // be shared
369  mask &= ~PM::Predicted & ~PM::Jacobian;
370  }
371 
372  if (outlier_states) {
373  // outlier won't have separate filtered parameters
374  mask &= ~PM::Filtered;
375  }
376 
377  TrackStateProxy trackState = trajectory.makeTrackState(mask, prevTip);
378  ACTS_VERBOSE("Create SourceLink output track state #"
379  << trackState.index() << " with mask: " << mask);
380 
381  if (firstTrackState.has_value()) {
382  trackState.shareFrom(*firstTrackState, PM::Predicted);
383  trackState.shareFrom(*firstTrackState, PM::Jacobian);
384  }
385  else {
386  // only set these for first
387  trackState.predicted() = boundParams.parameters();
388  if (boundParams.covariance()) {
389  trackState.predictedCovariance() = *boundParams.covariance();
390  }
391  trackState.jacobian() = derived_t::boundJacobiMatrix(boundState);
392  firstTrackState = trackState;
393  }
394  trackState.pathLength() = pathLength;
395 
396  trackState.setReferenceSurface(boundParams.referenceSurface().getSharedPtr());
397 
398  trackState.setProjectorSubspaceIndices(subspaceIndices);
399 
400  Acts::TrackStateType typeFlags = trackState.typeFlags();
401  if (trackState.referenceSurface().surfaceMaterial() != nullptr) {
402  typeFlags.set(Acts::TrackStateFlag::MaterialFlag);
403  }
404  typeFlags.set(Acts::TrackStateFlag::ParameterFlag);
405 
406  // @TODO these track states still need some additional processing. Should there be a special
407  // flag for this ?
408  track_states.push_back( trackState.index());
409  }
410  }

◆ 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,
[[maybe_unused] ] std::vector< TrackStateProxy > &  trackStateCandidates,
trajectory_t trajectory,
const Acts::Logger &  logger 
) const
inlineinherited

Definition at line 711 of file MeasurementSelector.h.

718  {
719 
720  Acts::Result<boost::container::small_vector< typename TrackStateProxy::IndexType, s_maxBranchesPerSurface> >
721  result = Acts::CombinatorialKalmanFilterError::MeasurementSelectionFailed;
722  // get associated measurement container and the relevant measurement range for the given surface.
723  auto [a_measurement_container_variant_ptr, range] = this->derived().containerAndRange(surface);
724  if (!range.empty()) {
725  auto [numMeasurementsCut, maxChi2Cut] = this->getCuts(surface,boundState, logger);
726  // numMeasurementsCut is == 0 in case getCuts failed
727  // anyway cannot select anything if numMeasurementsCut==0;
728  if (numMeasurementsCut>0) {
729 
730  result = std::visit( [this,
731  &geometryContext,
732  &calibrationContext,
733  &surface,
734  &boundState,
735  &range,
736  prevTip,
737  &trajectory,
738  &logger,
739  numMeasurementsCut,
740  &maxChi2Cut] (const auto &measurement_container_with_dimension) {
741  using ArgType = std::remove_cv_t<std::remove_reference_t< decltype(measurement_container_with_dimension) > >;
742  constexpr std::size_t DIM = ArgType::dimension();
743  auto measurement_range = this->derived().rangeForContainer(measurement_container_with_dimension,range);
744  return
745  this->template
746  selectMeasurementsCreateTrackStates<DIM, decltype(measurement_range)>(geometryContext,
747  calibrationContext,
748  surface,
749  boundState,
750  std::move(measurement_range),
751  prevTip,
752  trajectory,
753  logger,
754  numMeasurementsCut,
755  maxChi2Cut);
756  },
757  *a_measurement_container_variant_ptr);
758  }
759  }
760  else {
761  result = Acts::Result<boost::container::small_vector< typename TrackStateProxy::IndexType, s_maxBranchesPerSurface> >::success({});
762  }
763  return result;
764  }

◆ derived()

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

Definition at line 320 of file MeasurementSelector.h.

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

◆ dimMax()

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

Definition at line 706 of file MeasurementSelector.h.

706  {
708  }

◆ forwardToCalibrator()

template<std::size_t NMeasMax, typename derived_t , typename measurement_container_variant_t >
template<typename T >
static const auto& MeasurementSelectorBaseImpl< NMeasMax, derived_t, measurement_container_variant_t >::forwardToCalibrator ( const T &  a)
inlinestatic

Definition at line 798 of file MeasurementSelector.h.

798  {
799  if constexpr( std::is_same<T, std::remove_pointer_t<T> >::value ) {
800  return a;
801  }
802  else {
803  return *a;
804  }
805  }

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

652  {
653  std::tuple< std::size_t, std::pair<float,float> > result;
654  std::size_t &numMeasurementsCut = std::get<0>(result);
655  std::pair<float,float> &maxChi2Cut = std::get<1>(result);
656  // Get geoID of this surface
657  auto geoID = surface.geometryId();
658  // Find the appropriate cuts
659  auto cuts = m_config.find(geoID);
660  if (cuts == m_config.end()) {
661  // indicats failure
662  numMeasurementsCut = 0;
663  }
664  else {
665  // num measurement Cut
666  // getchi2 cut
667  std::size_t eta_bin = getEtaBin(derived().boundParams(boundState), cuts->etaBins);
668  numMeasurementsCut = (!cuts->numMeasurementsCutOff.empty()
669  ? cuts->numMeasurementsCutOff[ std::min(cuts->numMeasurementsCutOff.size()-1, eta_bin) ]
670  : NMeasMax);
671  maxChi2Cut = ! cuts->chi2CutOff.empty()
672  ? cuts->chi2CutOff[ std::min(cuts->chi2CutOff.size()-1, eta_bin) ]
673  : std::make_pair<float,float>(std::numeric_limits<float>::max(),
675  ACTS_VERBOSE("Get cut for eta-bin="
676  << (eta_bin < cuts->etaBins.size() ? cuts->etaBins[eta_bin] : std::numeric_limits<float>::max())
677  << ": chi2 (max,max-outlier) " << maxChi2Cut.first << ", " << maxChi2Cut.second
678  << " max.meas." << numMeasurementsCut);
679  }
680  return result;
681  }

◆ getEtaBin()

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

Definition at line 631 of file MeasurementSelector.h.

632  {
633  if (etaBins.empty()) {
634  return 0u; // shortcut if no etaBins
635  }
636  const float eta = std::abs(std::atanh(std::cos(boundParameters.parameters()[Acts::eBoundTheta])));
637  std::size_t bin = 0;
638  for (auto etaBin : etaBins) {
639  if (etaBin >= eta) {
640  break;
641  }
642  bin++;
643  }
644  return bin;
645  }

◆ makeSourceLink()

template<std::size_t NMeasMax, typename derived_t , typename measurement_container_variant_t >
template<typename T_Value >
static Acts::SourceLink MeasurementSelectorBaseImpl< NMeasMax, derived_t, measurement_container_variant_t >::makeSourceLink ( T_Value &&  value)
inlinestatic

Definition at line 790 of file MeasurementSelector.h.

790  {
791  return Acts::SourceLink{value};
792  }

◆ parameterMap()

template<std::size_t NMeasMax, typename derived_t , typename measurement_container_variant_t >
template<std::size_t DIM>
ParameterMapping::type<DIM> MeasurementSelectorBaseImpl< NMeasMax, derived_t, measurement_container_variant_t >::parameterMap ( const Acts::GeometryContext &  ,
const Acts::CalibrationContext &  ,
const Acts::Surface &   
)
inline

Definition at line 814 of file MeasurementSelector.h.

816  {
817  return ParameterMapping::identity<DIM>();
818  }

◆ pathLength()

template<std::size_t NMeasMax, typename derived_t , typename measurement_container_variant_t >
static double MeasurementSelectorBaseImpl< NMeasMax, derived_t, measurement_container_variant_t >::pathLength ( const T_BoundState boundState)
inlinestatic

Definition at line 784 of file MeasurementSelector.h.

784  {
785  return std::get<2>(boundState);
786  }

◆ postCalibrator()

template<std::size_t NMeasMax, typename derived_t , typename measurement_container_variant_t >
template<std::size_t DIM, typename measurement_t >
const PostCalibrator<DIM, measurement_t>& MeasurementSelectorBaseImpl< NMeasMax, derived_t, measurement_container_variant_t >::postCalibrator ( ) const

the calibrator used after the measurement selection which does not have to be "connected"

Note
The return value does not have to be a delegate, it can be an arbitrary functor/lambda, which however must be castable to bool to test whether there is a postCalibrator

◆ preCalibrator()

template<std::size_t NMeasMax, typename derived_t , typename measurement_container_variant_t >
template<std::size_t DIM, typename measurement_t >
const PreCalibrator<DIM, measurement_t>& MeasurementSelectorBaseImpl< NMeasMax, derived_t, measurement_container_variant_t >::preCalibrator ( ) const
Note
The return value does not have to be a delegate, it can be an arbitrary functor/lambda,

◆ rangeForContainer()

template<std::size_t NMeasMax, typename derived_t , typename measurement_container_variant_t >
template<typename measurement_container_t >
static auto MeasurementSelectorBaseImpl< NMeasMax, derived_t, measurement_container_variant_t >::rangeForContainer ( const measurement_container_t &  concrete_container,
const abstract_measurement_range_t abstract_range 
)
static

Create a range over elements of the given container from an abstract range.

Template Parameters
measurement_container_ta concrete container type which is one of one of the possible types of measurement_container_variant_t
Parameters
abstract_rangethe range as returned by containerAndRange
Returns
an itrerable range over elements of the given specified by the abstract range.

◆ 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 
) const
inlineprotectedinherited

Definition at line 431 of file MeasurementSelector.h.

440  {
441  Acts::Result<boost::container::small_vector< typename TrackStateProxy::IndexType, s_maxBranchesPerSurface> >
442  result = boost::container::small_vector< typename TrackStateProxy::IndexType, s_maxBranchesPerSurface>{};
443 
444  using iterator_t = decltype(measurement_range.begin());
445  using container_value_t = typename MeasurementSelectorTraits<derived_t>::template MeasurementContainerTraits<iterator_t>::value_type;
446  using BaseElementType = std::remove_cv_t<std::remove_pointer_t< container_value_t > >;
447  // get calibrator
448  using TheMatchingMeasurement = MatchingMeasurement<DIM, container_value_t >;
449  using MeasCovPair = TheMatchingMeasurement::MeasCovPair;
450 
451  using Predicted = typename MeasurementSelectorTraits<derived_t>::template Predicted<DIM>;
452  using PredictedCovariance = typename MeasurementSelectorTraits<derived_t>::template PredictedCovariance<DIM>;
453 
454 
455 
456  // get prediction in the measurement domain
457  Acts::SubspaceIndices<DIM> parameter_map = derived().template parameterMap<DIM>(geometryContext,
458  calibrationContext,
459  surface);
460  auto predicted
461  = std::make_pair( project<DIM, Predicted>(parameter_map,
462  derived().boundParams(boundState).parameters()),
463  project<DIM, PredictedCovariance>(parameter_map,
464  derived().boundParams(boundState).covariance().value()));
465 
466  // select n measurents with the smallest chi2.
467  auto preCalibrator = derived().template preCalibrator<DIM, BaseElementType>();
468  TopCollection<NMeasMax, TheMatchingMeasurement > selected_measurements(numMeasurementsCut);
469  {
470  for ( const auto &measurement : measurement_range ) {
471  TheMatchingMeasurement &matching_measurement=selected_measurements.slot();
472  matching_measurement.m_measurement = preCalibrator(geometryContext,
473  calibrationContext,
474  derived().forwardToCalibrator(measurement),
475  derived().boundParams(boundState));
476  matching_measurement.m_chi2 = computeChi2(matching_measurement.m_measurement.first,
477  matching_measurement.m_measurement.second,
478  predicted.first,
479  predicted.second);
480  // only consider measurements which pass the outlier chi2 cut
481  if (matching_measurement.m_chi2<maxChi2Cut.second) {
482  matching_measurement.m_sourceLink=measurement;
483  selected_measurements.acceptAndSort([](const TheMatchingMeasurement &a,
484  const TheMatchingMeasurement &b) {
485  return a.m_chi2 < b.m_chi2;
486  });
487  }
488  }
489  }
490 
491  // apply final calibration to n-best measurements
492  auto postCalibrator = derived().template postCalibrator<DIM, BaseElementType>();
493  using post_calib_meas_cov_pair_t
495  typename MeasurementSelectorTraits<derived_t>::template CalibratedMeasurementCovariance<DIM> >;
496 
497  // need extra temporary buffer if the types to store "measurements" during measurement selection
498  // and calibrated measurements after the measurement selection are not identical
499  static constexpr bool pre_and_post_calib_types_agree
501  typename MeasurementSelectorTraits<derived_t>::template PreSelectionMeasurement<DIM> >::value
502  && std::is_same< typename MeasurementSelectorTraits<derived_t>::template CalibratedMeasurementCovariance<DIM>,
503  typename MeasurementSelectorTraits<derived_t>::template PreSelectionMeasurementCovariance<DIM> >::value;
504 
505  using Empty = struct {};
506  typename std::conditional< !pre_and_post_calib_types_agree,
507  std::array< post_calib_meas_cov_pair_t, NMeasMax>, // @TODO could use boost static_vector instead
508  Empty>::type calibrated;
509  if (postCalibrator) {
511 
512  // apply final calibration, recompute chi2
514  idx: selected_measurements) {
515  TheMatchingMeasurement &a_selected_measurement = selected_measurements.getSlot(idx);
516 
517  // helper to select the destination storage which is the extra temporary buffer
518  // if the measurement storage types during and after selection are different.
519  post_calib_meas_cov_pair_t &calibrated_measurement
520  = [&calibrated, &a_selected_measurement, calibrated_meas_cov_i]() -> post_calib_meas_cov_pair_t & {
521  if constexpr(pre_and_post_calib_types_agree) {
522  (void) calibrated;
523  (void) calibrated_meas_cov_i;
524  return a_selected_measurement.m_measurement;
525  }
526  else {
527  (void) a_selected_measurement;
528  assert(calibrated_meas_cov_i < calibrated.size());
529  return calibrated[calibrated_meas_cov_i];
530  }
531  }();
532 
533  // apply the calibration
534  calibrated_measurement = postCalibrator(geometryContext,
535  calibrationContext,
536  derived().forwardToCalibrator(a_selected_measurement.m_sourceLink.value()),
537  derived().boundParams(boundState));
538  // update chi2 using calibrated measurement
539  a_selected_measurement.m_chi2 = computeChi2(calibrated_measurement.first,
540  calibrated_measurement.second,
541  predicted.first,
542  predicted.second);
543  // ... and set outlier flag
544  a_selected_measurement.m_isOutLier = (a_selected_measurement.m_chi2 >= maxChi2Cut.first);
545  if constexpr(!pre_and_post_calib_types_agree) {
546  ++calibrated_meas_cov_i;
547  }
548  }
549  }
550  else {
551  // if no final calibration is performed only the outlier flag still needs to be set
553  idx: selected_measurements) {
554  TheMatchingMeasurement &a_selected_measurement = selected_measurements.getSlot(idx);
555  a_selected_measurement.m_isOutLier = (a_selected_measurement.m_chi2 >= maxChi2Cut.first);
556  }
557  }
558 
559  // First Create states without setting information about the calibrated measurement for the selected measurements
560  // @TODO first create state then copy measurements, or crete state by state and set measurements ?
561  // the lastter has the "advantage" that the outlier flag can be set individually
562  // the former has the advantage that part of the state creation code is independent of the
563  // the measurement.
564 
565  Acts::BoundSubspaceIndices boundSubspaceIndices;
566  std::copy(parameter_map.begin(), parameter_map.end(), boundSubspaceIndices.begin());
567  createStates( selected_measurements.size(),
568  boundState,
569  prevTip,
570  trajectory,
571  boundSubspaceIndices,
572  *result,
573  logger,
574  (!selected_measurements.empty()
575  ? selected_measurements.getSlot( *(selected_measurements.begin())).m_isOutLier
576  : false) );
577  assert( result->size() == selected_measurements.size() );
578 
579  // helper to determine whether calibrated storeage is to be used
580  auto use_calibrated_storage = [&postCalibrator]() -> bool {
581  if constexpr(pre_and_post_calib_types_agree) {
582  (void) postCalibrator;
583  return false;
584  }
585  else {
586  // this is only known during runtime
587  // but it should not be tested if the types agree.
588  return postCalibrator;
589  }
590  };
591 
592  // copy selected measurements to pre-created states
593  unsigned int state_i=0;
595  idx: selected_measurements) {
596  assert( state_i < result->size());
597  TrackStateProxy trackState( trajectory.getTrackState( (*result)[state_i] ) );
598  TheMatchingMeasurement &a_selected_measurement = selected_measurements.getSlot(idx);
599  trackState.setUncalibratedSourceLink(derived().makeSourceLink(std::move(a_selected_measurement.m_sourceLink.value())));
600  // flag outliers accordingly, so that they are handled correctly by the post processing
601  trackState.typeFlags().set( a_selected_measurement.m_isOutLier
602  ? Acts::TrackStateFlag::OutlierFlag
603  : Acts::TrackStateFlag::MeasurementFlag );
604  trackState.allocateCalibrated(DIM);
605  if (use_calibrated_storage()) {
606  // if the final clibration is performed after the selection then
607  // copy these measurements and covariances to the track states
608  assert( use_calibrated_storage() == !pre_and_post_calib_types_agree);
609  if constexpr(!pre_and_post_calib_types_agree) {
610  assert( state_i < calibrated.size());
611  trackState.template calibrated<DIM>()
612  = MeasurementSelectorMatrixTraits::matrixTypeCast<typename MeasurementSelectorTraits<derived_t>::MatrixFloatType>(calibrated[state_i].first);
613  trackState.template calibratedCovariance<DIM>()
614  = MeasurementSelectorMatrixTraits::matrixTypeCast<typename MeasurementSelectorTraits<derived_t>::MatrixFloatType>(calibrated[state_i].second);
615  trackState.chi2() = a_selected_measurement.m_chi2;
616  }
617  }
618  else {
619  trackState.template calibrated<DIM>()
620  = MeasurementSelectorMatrixTraits::matrixTypeCast<typename MeasurementSelectorTraits<derived_t>::MatrixFloatType>(a_selected_measurement.m_measurement.first);
621  trackState.template calibratedCovariance<DIM>()
622  = MeasurementSelectorMatrixTraits::matrixTypeCast<typename MeasurementSelectorTraits<derived_t>::MatrixFloatType>(a_selected_measurement.m_measurement.second);
623  trackState.chi2() = a_selected_measurement.m_chi2;
624  }
625  ++state_i;
626  }
627  return result;
628  }

Member Data Documentation

◆ m_config

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

Definition at line 312 of file MeasurementSelector.h.

◆ s_maxBranchesPerSurface

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 >::s_maxBranchesPerSurface = Base::s_maxBranchesPerSurface
staticconstexprinherited

Definition at line 703 of file MeasurementSelector.h.


The documentation for this struct was generated from the following file:
MeasurementSelectorBase< NMeasMax, MeasurementSelectorTraits< derived_t >::s_dimMax, derived_t >::TrackStateProxy
typename MeasurementSelectorTraits< derived_t >::TrackStateProxy TrackStateProxy
Definition: MeasurementSelector.h:317
get_generator_info.result
result
Definition: get_generator_info.py:21
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
ConvertOldUJHistosToNewHistos.etaBins
list etaBins
Definition: ConvertOldUJHistosToNewHistos.py:145
taskman.template
dictionary template
Definition: taskman.py:317
bin
Definition: BinsDiffFromStripMedian.h:43
MeasurementSelectorBase< NMeasMax, MeasurementSelectorTraits< derived_t >::s_dimMax, derived_t >::getCuts
std::tuple< std::size_t, std::pair< float, float > > getCuts(const Acts::Surface &surface, const T_BoundState &boundState, const Acts::Logger &logger) const
Definition: MeasurementSelector.h:650
athena.value
value
Definition: athena.py:124
TopCollection::IndexType
unsigned short IndexType
Definition: MeasurementSelector.h:220
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
MeasurementSelectorBase< NMeasMax, MeasurementSelectorTraits< derived_t >::s_dimMax, derived_t >::derived
const derived_t & derived() const
Definition: MeasurementSelector.h:320
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
xAOD::etaBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
Definition: L2StandAloneMuon_v1.cxx:148
MeasurementSelectorBase< NMeasMax, MeasurementSelectorTraits< derived_t >::s_dimMax, derived_t >::createStates
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)
Definition: MeasurementSelector.h:346
plotBeamSpotVert.cuts
string cuts
Definition: plotBeamSpotVert.py:93
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
TopCollection::begin
std::array< IndexType, N+1 >::const_iterator begin()
Definition: MeasurementSelector.h:278
TopCollection::getSlot
const PayloadType & getSlot(IndexType idx) const
Definition: MeasurementSelector.h:242
doL1CaloHVCorrections.eta_bin
eta_bin
Definition: doL1CaloHVCorrections.py:368
TopCollection::size
IndexType size() const
Definition: MeasurementSelector.h:275
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
MeasurementSelectorBase< NMeasMax, MeasurementSelectorTraits< derived_t >::s_dimMax, derived_t >::getEtaBin
static std::size_t getEtaBin(const parameters_t &boundParameters, const std::vector< float > &etaBins)
Definition: MeasurementSelector.h:631
MeasurementSelectorTraits
Definition: MeasurementSelector.h:43
a
TList * a
Definition: liststreamerinfos.cxx:10
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
physics_parameters.parameters
parameters
Definition: physics_parameters.py:144
calibdata.copy
bool copy
Definition: calibdata.py:27
computeChi2
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)
Definition: MeasurementSelector.h:188
TopCollection
Definition: MeasurementSelector.h:219
Trk::TrackState::TrackStateType
TrackStateType
enum describing the role of track states during cleaning and outlier removal.
Definition: TrackStateDefs.h:51
MeasurementSelectorBase< NMeasMax, MeasurementSelectorTraits< derived_t >::s_dimMax, derived_t >::m_config
Config m_config
Definition: MeasurementSelector.h:312
python.iconfTool.gui.pad.logger
logger
Definition: pad.py:14
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
TopCollection::empty
bool empty() const
Definition: MeasurementSelector.h:271