CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Static Public Member Functions
SeedMatcher Class Reference

#include <SeedMatcher.h>

Static Public Member Functions

static std::vector< int > matchRecHitCombinations (const TrajectorySeed &seed, const FastTrackerRecHitCombinationCollection &recHitCombinationCollection, const std::vector< SimTrack > &simTrackCollection, double maxMatchEstimator, const Propagator &propagator, const MagneticField &magneticField, const TrackerGeometry &trackerGeometry)
 
static double matchSimTrack (const TrajectoryStateOnSurface &seedState, const SimTrack &simTrack, const Propagator &propagator, const MagneticField &magneticField)
 

Detailed Description

Definition at line 14 of file SeedMatcher.h.

Member Function Documentation

std::vector< int32_t > SeedMatcher::matchRecHitCombinations ( const TrajectorySeed seed,
const FastTrackerRecHitCombinationCollection recHitCombinationCollection,
const std::vector< SimTrack > &  simTrackCollection,
double  maxMatchEstimator,
const Propagator propagator,
const MagneticField magneticField,
const TrackerGeometry trackerGeometry 
)
static

Definition at line 14 of file SeedMatcher.cc.

References PTrajectoryStateOnDet::detId(), Exception, TrackerGeometry::idToDet(), matchSimTrack(), mps_fire::result, cscDigiValidation_cfi::simTrack, TrajectorySeed::startingState(), and trajectoryStateTransform::transientState().

Referenced by TrackCandidateProducer::produce().

21  {
22  // container for result
23  std::vector<int32_t> result;
24 
25  // seed state
27  DetId seedState_detId(ptod.detId());
28  const GeomDet* seedState_det = trackerGeometry.idToDet(seedState_detId);
29  const Surface* seedState_surface = &seedState_det->surface();
30  TrajectoryStateOnSurface seedState(trajectoryStateTransform::transientState(ptod, seedState_surface, &magneticField));
31 
32  // find matches
33  int nSimTracks = simTrackCollection.size();
34  for (unsigned recHitCombinationIndex = 0; recHitCombinationIndex < recHitCombinationCollection.size();
35  recHitCombinationIndex++) {
36  const auto& recHitCombination = recHitCombinationCollection[recHitCombinationIndex];
37  int simTrackIndex = recHitCombination.back()->simTrackId(0);
38  if (simTrackIndex < 0 || simTrackIndex >= nSimTracks) {
39  throw cms::Exception("SeedMatcher") << "SimTrack index out of range: " << simTrackIndex << std::endl;
40  }
41  const auto& simTrack = simTrackCollection[recHitCombination.back()->simTrackId(0)];
42  double matchEstimator = matchSimTrack(seedState, simTrack, propagator, magneticField);
43  if (matchEstimator < maxMatchEstimator) {
44  result.push_back(recHitCombinationIndex);
45  }
46  }
47  return result;
48 }
tuple result
Definition: mps_fire.py:311
static double matchSimTrack(const TrajectoryStateOnSurface &seedState, const SimTrack &simTrack, const Propagator &propagator, const MagneticField &magneticField)
Definition: SeedMatcher.cc:50
unsigned int detId() const
const TrackerGeomDet * idToDet(DetId) const override
Definition: DetId.h:17
PTrajectoryStateOnDet const & startingState() const
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
double SeedMatcher::matchSimTrack ( const TrajectoryStateOnSurface seedState,
const SimTrack simTrack,
const Propagator propagator,
const MagneticField magneticField 
)
static

Definition at line 50 of file SeedMatcher.cc.

References PV3DBase< T, PVType, FrameType >::basicVector(), CoreSimTrack::charge(), Basic3DVector< T >::dot(), relativeConstraints::error, TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localParameters(), HLT_FULL_cff::magneticField, LocalTrajectoryError::matrix(), Propagator::propagate(), TrajectoryStateOnSurface::surface(), SimTrack::trackerSurfaceMomentum(), SimTrack::trackerSurfacePosition(), and LocalTrajectoryParameters::vector().

Referenced by matchRecHitCombinations().

53  {
54  // simtrack and simvertex at tracker surface
55  GlobalPoint simTrack_atTrackerSurface_position(simTrack.trackerSurfacePosition().x(),
56  simTrack.trackerSurfacePosition().y(),
57  simTrack.trackerSurfacePosition().z());
58  GlobalVector simTrack_atTrackerSurface_momentum(simTrack.trackerSurfaceMomentum().x(),
59  simTrack.trackerSurfaceMomentum().y(),
60  simTrack.trackerSurfaceMomentum().z());
61 
62  // no match if seedstate and simtrack in oposite direction
63  if (simTrack_atTrackerSurface_position.basicVector().dot(simTrack_atTrackerSurface_momentum.basicVector()) *
64  seedState.globalPosition().basicVector().dot(seedState.globalMomentum().basicVector()) <
65  0.) {
66  return 9999.;
67  }
68 
69  // find simtrack state on surface of seed state
70  GlobalTrajectoryParameters simTrack_atTrackerSurface_parameters(
71  simTrack_atTrackerSurface_position, simTrack_atTrackerSurface_momentum, simTrack.charge(), &magneticField);
72  FreeTrajectoryState simtrack_atTrackerSurface_state(simTrack_atTrackerSurface_parameters);
73  TrajectoryStateOnSurface simtrack_atSeedStateSurface_state =
74  propagator.propagate(simtrack_atTrackerSurface_state, seedState.surface());
75 
76  // simtrack does not propagate to surface of seed state
77  if (!simtrack_atSeedStateSurface_state.isValid()) {
78  return 9999.;
79  }
80 
81  // simtrack and seed state have opposite direction
82  if (simtrack_atSeedStateSurface_state.globalPosition().basicVector().dot(
83  simtrack_atSeedStateSurface_state.globalMomentum().basicVector()) *
84  seedState.globalPosition().basicVector().dot(seedState.globalMomentum().basicVector()) <
85  0.) {
86  return 9999.;
87  }
88 
89  AlgebraicVector5 difference(seedState.localParameters().vector() -
90  simtrack_atSeedStateSurface_state.localParameters().vector());
92  if (!error.Invert()) {
93  edm::LogWarning("FastSim SeedToSimTrackMatcher") << "Cannot invert seed state error matrix => no match...";
94  return 9999.;
95  }
96 
97  return ROOT::Math::Similarity(difference, error);
98 }
const math::XYZVectorD & trackerSurfacePosition() const
Definition: SimTrack.h:40
const LocalTrajectoryParameters & localParameters() const
GlobalPoint globalPosition() const
tuple magneticField
float charge() const
charge
Definition: CoreSimTrack.cc:17
AlgebraicVector5 vector() const
const SurfaceType & surface() const
ROOT::Math::SVector< double, 5 > AlgebraicVector5
const AlgebraicSymMatrix55 & matrix() const
const LocalTrajectoryError & localError() const
const math::XYZTLorentzVectorD & trackerSurfaceMomentum() const
Definition: SimTrack.h:42
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
GlobalVector globalMomentum() const
Log< level::Warning, false > LogWarning
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
T dot(const Basic3DVector &rh) const
Scalar product, or &quot;dot&quot; product, with a vector of same type.