CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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, TrajectorySeed::startingState(), and trajectoryStateTransform::transientState().

Referenced by TrackCandidateProducer::produce().

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

Definition at line 53 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_25ns10e33_v2_cff::magneticField, LocalTrajectoryError::matrix(), Propagator::propagate(), TrajectoryStateOnSurface::surface(), SimTrack::trackerSurfaceMomentum(), SimTrack::trackerSurfacePosition(), and LocalTrajectoryParameters::vector().

Referenced by matchRecHitCombinations().

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