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...
 
bool expectMeasurements ([[maybe_unused]] const Acts::Surface &surface, [[maybe_unused]] const measurement_container_variant_t *container_variant_ptr, const abstract_measurement_range_t &abstract_range) const
 
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, 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 MeasurementSelectorBaseImpl< NMeasMax, derived_t, measurement_container_variant_t >

Definition at line 793 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 795 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 716 of file MeasurementSelector.h.

◆ Config

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

Definition at line 318 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 856 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 845 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 794 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 719 of file MeasurementSelector.h.

◆ traits

using MeasurementSelectorBase< NMeasMax, DIMMAX, derived_t >::traits = MeasurementSelectorTraits<derived_t>
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
inherited

Definition at line 718 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 803 of file MeasurementSelector.h.

803  {
804  return std::get<1>(boundState);
805  }

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

798  {
799  return std::get<0>(boundState);
800  }

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

362  {
363  // create track states for all compatible measurement candidates
364  const auto &boundParams = derived_t::boundParams(boundState);
365  const auto &pathLength = derived_t::pathLength(boundState);
366 
367  using PM = Acts::TrackStatePropMask;
368 
369  track_states.reserve( n_new_states );
370  std::optional<TrackStateProxy> firstTrackState{
371  std::nullopt};
372  for (unsigned int state_i=0; state_i<n_new_states; ++state_i) {
373  PM mask = PM::Predicted | PM::Filtered | PM::Jacobian | PM::Calibrated;
374 
375  if (firstTrackState.has_value()) {
376  // subsequent track states don't need storage for these as they will
377  // be shared
378  mask &= ~PM::Predicted & ~PM::Jacobian;
379  }
380 
381  if (outlier_states) {
382  // outlier won't have separate filtered parameters
383  mask &= ~PM::Filtered;
384  }
385 
386  TrackStateProxy trackState = trajectory.makeTrackState(mask, prevTip);
387  ACTS_VERBOSE("Create SourceLink output track state #"
388  << trackState.index() << " with mask: " << mask);
389 
390  if (firstTrackState.has_value()) {
391  trackState.shareFrom(*firstTrackState, PM::Predicted);
392  trackState.shareFrom(*firstTrackState, PM::Jacobian);
393  }
394  else {
395  // only set these for first
396  trackState.predicted() = boundParams.parameters();
397  if (boundParams.covariance()) {
398  trackState.predictedCovariance() = *boundParams.covariance();
399  }
400  trackState.jacobian() = derived_t::boundJacobiMatrix(boundState);
401  firstTrackState = trackState;
402  }
403  trackState.pathLength() = pathLength;
404 
405  trackState.setReferenceSurface(boundParams.referenceSurface().getSharedPtr());
406 
407  trackState.setProjectorSubspaceIndices(subspaceIndices);
408 
409  Acts::TrackStateType typeFlags = trackState.typeFlags();
410  if (trackState.referenceSurface().surfaceMaterial() != nullptr) {
411  typeFlags.set(Acts::TrackStateFlag::MaterialFlag);
412  }
413  typeFlags.set(Acts::TrackStateFlag::ParameterFlag);
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,
[[maybe_unused] ] std::vector< TrackStateProxy > &  trackStateCandidates,
trajectory_t trajectory,
const Acts::Logger &  logger 
) const
inlineinherited

Definition at line 728 of file MeasurementSelector.h.

735  {
736 
737  Acts::Result<boost::container::small_vector< typename TrackStateProxy::IndexType, s_maxBranchesPerSurface> >
738  result = Acts::CombinatorialKalmanFilterError::MeasurementSelectionFailed;
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);
741  if (!forced && !this->derived().expectMeasurements( surface, a_measurement_container_variant_ptr, range)) {
742  result = result.failure(Acts::CombinatorialKalmanFilterError::NoMeasurementExpected);
743  return result;
744  }
745  if (!range.empty()) {
746  auto [numMeasurementsCut, maxChi2Cut] = this->getCuts(surface,boundState, logger);
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,
752  &geometryContext,
753  &calibrationContext,
754  &surface,
755  &boundState,
756  &range,
757  prevTip,
758  &trajectory,
759  &logger,
760  numMeasurementsCut,
761  &maxChi2Cut,
762  forced] (const auto &measurement_container_with_dimension) {
763  using ArgType = std::remove_cv_t<std::remove_reference_t< decltype(measurement_container_with_dimension) > >;
764  constexpr std::size_t DIM = ArgType::dimension();
765  auto measurement_range = this->derived().rangeForContainer(measurement_container_with_dimension,range);
766  return
767  this->template
768  selectMeasurementsCreateTrackStates<DIM, decltype(measurement_range)>(geometryContext,
769  calibrationContext,
770  surface,
771  boundState,
772  std::move(measurement_range),
773  prevTip,
774  trajectory,
775  logger,
776  numMeasurementsCut,
777  maxChi2Cut,
778  forced);
779  },
780  *a_measurement_container_variant_ptr);
781  }
782  }
783  else {
784  result = Acts::Result<boost::container::small_vector< typename TrackStateProxy::IndexType, s_maxBranchesPerSurface> >::success({});
785  }
786  return result;
787  }

◆ derived()

const derived_t& MeasurementSelectorBase< NMeasMax, DIMMAX, derived_t >::derived
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 >
static constexpr std::size_t MeasurementSelectorWithDispatch< NMeasMax, derived_t, measurement_container_variant_t >::dimMax ( )
inlinestaticconstexprinherited

Definition at line 723 of file MeasurementSelector.h.

723  {
725  }

◆ expectMeasurements()

template<std::size_t NMeasMax, typename derived_t , typename measurement_container_variant_t >
bool MeasurementSelectorBaseImpl< NMeasMax, derived_t, measurement_container_variant_t >::expectMeasurements ( [[maybe_unused] ] const Acts::Surface &  surface,
[[maybe_unused] ] const measurement_container_variant_t *  container_variant_ptr,
const abstract_measurement_range_t abstract_range 
) const
Parameters
surfacea surface
container_variant_ptrabstract measurement container as returned by containerAndRange
abstract_rangethe range as returned by containerAndRange for the given surface
Returns
true if measurements are expected, false if the surface is not supposed to have valid measurements.

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

821  {
822  if constexpr( std::is_same<T, std::remove_pointer_t<T> >::value ) {
823  return a;
824  }
825  else {
826  return *a;
827  }
828  }

◆ 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  {
670  std::tuple< std::size_t, std::pair<float,float> > result;
671  std::size_t &numMeasurementsCut = std::get<0>(result);
672  std::pair<float,float> &maxChi2Cut = std::get<1>(result);
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
679  numMeasurementsCut = 0;
680  }
681  else {
682  // num measurement Cut
683  // getchi2 cut
684  std::size_t eta_bin = getEtaBin(derived().boundParams(boundState), cuts->etaBins);
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) ]
690  : std::make_pair<float,float>(std::numeric_limits<float>::max(),
692  ACTS_VERBOSE("Get cut for eta-bin="
693  << (eta_bin < cuts->etaBins.size() ? cuts->etaBins[eta_bin] : std::numeric_limits<float>::max())
694  << ": chi2 (max,max-outlier) " << maxChi2Cut.first << ", " << maxChi2Cut.second
695  << " max.meas." << numMeasurementsCut);
696  }
697  return result;
698  }

◆ getEtaBin()

static 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  }

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

813  {
814  return Acts::SourceLink{value};
815  }

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

839  {
840  return ParameterMapping::identity<DIM>();
841  }

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

807  {
808  return std::get<2>(boundState);
809  }

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

Definition at line 440 of file MeasurementSelector.h.

450  {
451  Acts::Result<boost::container::small_vector< typename TrackStateProxy::IndexType, s_maxBranchesPerSurface> >
452  result = boost::container::small_vector< typename TrackStateProxy::IndexType, s_maxBranchesPerSurface>{};
453 
454  using iterator_t = decltype(measurement_range.begin());
455  using container_value_t = typename MeasurementSelectorTraits<derived_t>::template MeasurementContainerTraits<iterator_t>::value_type;
456  using BaseElementType = std::remove_cv_t<std::remove_pointer_t< container_value_t > >;
457  // get calibrator
458  using TheMatchingMeasurement = MatchingMeasurement<DIM, container_value_t >;
459  using MeasCovPair = TheMatchingMeasurement::MeasCovPair;
460 
461  using Predicted = typename MeasurementSelectorTraits<derived_t>::template Predicted<DIM>;
462  using PredictedCovariance = typename MeasurementSelectorTraits<derived_t>::template PredictedCovariance<DIM>;
463 
464 
465 
466  // get prediction in the measurement domain
467  Acts::SubspaceIndices<DIM> parameter_map = derived().template parameterMap<DIM>(geometryContext,
468  calibrationContext,
469  surface);
470  auto predicted
471  = std::make_pair( project<DIM, Predicted>(parameter_map,
472  derived().boundParams(boundState).parameters()),
473  project<DIM, PredictedCovariance>(parameter_map,
474  derived().boundParams(boundState).covariance().value()));
475 
476  // select n measurents with the smallest chi2.
477  auto preCalibrator = derived().template preCalibrator<DIM, BaseElementType>();
478  auto postCalibrator = derived().template postCalibrator<DIM, BaseElementType>();
479  TopCollection<NMeasMax, TheMatchingMeasurement > selected_measurements(numMeasurementsCut);
480  for ( const auto &measurement : measurement_range ) {
481  TheMatchingMeasurement &matching_measurement=selected_measurements.slot();
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;
487  matching_measurement.m_sourceLink=measurement;
488  if (!selected_measurements.acceptNoSort()) break;
489  } else {
490  matching_measurement.m_measurement = preCalibrator(geometryContext,
491  calibrationContext,
492  derived().forwardToCalibrator(measurement),
493  derived().boundParams(boundState));
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) {
500  matching_measurement.m_sourceLink=measurement;
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
510  using post_calib_meas_cov_pair_t
512  typename MeasurementSelectorTraits<derived_t>::template CalibratedMeasurementCovariance<DIM> >;
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
518  typename MeasurementSelectorTraits<derived_t>::template PreSelectionMeasurement<DIM> >::value
519  && std::is_same< typename MeasurementSelectorTraits<derived_t>::template CalibratedMeasurementCovariance<DIM>,
520  typename MeasurementSelectorTraits<derived_t>::template PreSelectionMeasurementCovariance<DIM> >::value;
521 
522  using Empty = struct {};
523  typename std::conditional< !pre_and_post_calib_types_agree,
524  std::array< post_calib_meas_cov_pair_t, NMeasMax>, // @TODO could use boost static_vector instead
525  Empty>::type calibrated;
526  if (postCalibrator) {
528 
529  // apply final calibration, recompute chi2
531  idx: selected_measurements) {
532  TheMatchingMeasurement &a_selected_measurement = selected_measurements.getSlot(idx);
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.
536  post_calib_meas_cov_pair_t &calibrated_measurement
537  = [&calibrated, &a_selected_measurement, calibrated_meas_cov_i]() -> post_calib_meas_cov_pair_t & {
538  if constexpr(pre_and_post_calib_types_agree) {
539  (void) calibrated;
540  (void) calibrated_meas_cov_i;
541  return a_selected_measurement.m_measurement;
542  }
543  else {
544  (void) a_selected_measurement;
545  assert(calibrated_meas_cov_i < calibrated.size());
546  return calibrated[calibrated_meas_cov_i];
547  }
548  }();
549 
550  // apply the calibration
551  calibrated_measurement = postCalibrator(geometryContext,
552  calibrationContext,
553  derived().forwardToCalibrator(a_selected_measurement.m_sourceLink.value()),
554  derived().boundParams(boundState));
555  // update chi2 using calibrated measurement
556  a_selected_measurement.m_chi2 = computeChi2(calibrated_measurement.first,
557  calibrated_measurement.second,
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) {
563  ++calibrated_meas_cov_i;
564  }
565  }
566  }
567  else {
568  // if no final calibration is performed only the outlier flag still needs to be set
570  idx: selected_measurements) {
571  TheMatchingMeasurement &a_selected_measurement = selected_measurements.getSlot(idx);
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 
582  Acts::BoundSubspaceIndices boundSubspaceIndices;
583  std::copy(parameter_map.begin(), parameter_map.end(), boundSubspaceIndices.begin());
584  createStates( selected_measurements.size(),
585  boundState,
586  prevTip,
587  trajectory,
588  boundSubspaceIndices,
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) {
599  (void) postCalibrator;
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;
612  idx: selected_measurements) {
613  assert( state_i < result->size());
614  TrackStateProxy trackState( trajectory.getTrackState( (*result)[state_i] ) );
615  TheMatchingMeasurement &a_selected_measurement = selected_measurements.getSlot(idx);
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
619  ? Acts::TrackStateFlag::OutlierFlag
620  : Acts::TrackStateFlag::MeasurementFlag );
621  trackState.allocateCalibrated(DIM);
622  if (use_calibrated_storage()) {
623  // if the final clibration is performed after the selection then
624  // copy these measurements and covariances to the track states
625  assert( use_calibrated_storage() == !pre_and_post_calib_types_agree);
626  if constexpr(!pre_and_post_calib_types_agree) {
627  assert( state_i < calibrated.size());
628  trackState.template calibrated<DIM>()
629  = MeasurementSelectorMatrixTraits::matrixTypeCast<typename MeasurementSelectorTraits<derived_t>::MatrixFloatType>(calibrated[state_i].first);
630  trackState.template calibratedCovariance<DIM>()
631  = MeasurementSelectorMatrixTraits::matrixTypeCast<typename MeasurementSelectorTraits<derived_t>::MatrixFloatType>(calibrated[state_i].second);
632  trackState.chi2() = a_selected_measurement.m_chi2;
633  }
634  }
635  else {
636  trackState.template calibrated<DIM>()
637  = MeasurementSelectorMatrixTraits::matrixTypeCast<typename MeasurementSelectorTraits<derived_t>::MatrixFloatType>(a_selected_measurement.m_measurement.first);
638  trackState.template calibratedCovariance<DIM>()
639  = MeasurementSelectorMatrixTraits::matrixTypeCast<typename MeasurementSelectorTraits<derived_t>::MatrixFloatType>(a_selected_measurement.m_measurement.second);
640  trackState.chi2() = a_selected_measurement.m_chi2;
641  }
642  ++state_i;
643  }
644  return result;
645  }

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 >
constexpr std::size_t MeasurementSelectorWithDispatch< NMeasMax, derived_t, measurement_container_variant_t >::s_maxBranchesPerSurface = Base::s_maxBranchesPerSurface
staticconstexprinherited

Definition at line 720 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:326
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:314
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:667
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:459
MeasurementSelectorBase< NMeasMax, MeasurementSelectorTraits< derived_t >::s_dimMax, derived_t >::derived
const derived_t & derived() const
Definition: MeasurementSelector.h:329
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:149
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:355
plotBeamSpotVert.cuts
string cuts
Definition: plotBeamSpotVert.py:92
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
TopCollection::begin
std::array< IndexType, N+1 >::const_iterator begin()
Definition: MeasurementSelector.h:287
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:284
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:76
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:82
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:648
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:26
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:321
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:280
python.SystemOfUnits.m
float m
Definition: SystemOfUnits.py:106