CMS 3D CMS Logo

SeedMatcher.cc
Go to the documentation of this file.
2 
11 
12 #include "iostream"
13 
15  const TrajectorySeed& seed,
16  const FastTrackerRecHitCombinationCollection& recHitCombinationCollection,
18  double maxMatchEstimator,
19  const Propagator& propagator,
21  const TrackerGeometry& trackerGeometry) {
22  // container for result
23  std::vector<int32_t> result;
24 
25  // seed state
26  PTrajectoryStateOnDet ptod = seed.startingState();
27  DetId seedState_detId(ptod.detId());
28  const GeomDet* seedState_det = trackerGeometry.idToDet(seedState_detId);
29  const Surface* seedState_surface = &seedState_det->surface();
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 }
49 
51  const SimTrack& simTrack,
52  const Propagator& propagator,
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 }
Vector3DBase
Definition: Vector3DBase.h:8
TrackerGeometry::idToDet
const TrackerGeomDet * idToDet(DetId) const override
Definition: TrackerGeometry.cc:193
Propagator.h
cscDigiValidation_cfi.simTrack
simTrack
Definition: cscDigiValidation_cfi.py:29
SeedMatcher.h
MessageLogger.h
TrackerGeometry.h
GeomDet
Definition: GeomDet.h:27
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
SeedMatcher::matchRecHitCombinations
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)
Definition: SeedMatcher.cc:14
Surface
Definition: Surface.h:36
LocalTrajectoryError::matrix
const AlgebraicSymMatrix55 & matrix() const
Definition: LocalTrajectoryError.h:60
HLT_FULL_cff.magneticField
magneticField
Definition: HLT_FULL_cff.py:348
relativeConstraints.error
error
Definition: relativeConstraints.py:53
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
caloTruthProducer_cfi.simTrackCollection
simTrackCollection
Definition: caloTruthProducer_cfi.py:28
fileCollector.seed
seed
Definition: fileCollector.py:127
Propagator
Definition: Propagator.h:44
DetId
Definition: DetId.h:17
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
PTrajectoryStateOnDet::detId
unsigned int detId() const
Definition: PTrajectoryStateOnDet.h:65
TrackCandidateProducer_cfi.propagator
propagator
Definition: TrackCandidateProducer_cfi.py:17
PTrajectoryStateOnDet.h
SeedMatcher::matchSimTrack
static double matchSimTrack(const TrajectoryStateOnSurface &seedState, const SimTrack &simTrack, const Propagator &propagator, const MagneticField &magneticField)
Definition: SeedMatcher.cc:50
Basic3DVector::dot
T dot(const Basic3DVector &rh) const
Scalar product, or "dot" product, with a vector of same type.
Definition: extBasic3DVector.h:189
GlobalTrajectoryParameters
Definition: GlobalTrajectoryParameters.h:15
LocalTrajectoryParameters::vector
AlgebraicVector5 vector() const
Definition: LocalTrajectoryParameters.h:120
Point3DBase< float, GlobalTag >
TrajectorySeed.h
TrajectoryStateOnSurface::localParameters
const LocalTrajectoryParameters & localParameters() const
Definition: TrajectoryStateOnSurface.h:73
FastTrackerRecHitCombinationCollection
std::vector< FastTrackerRecHitCombination > FastTrackerRecHitCombinationCollection
Definition: FastTrackerRecHitCollection.h:12
trajectoryStateTransform::transientState
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
Definition: TrajectoryStateTransform.cc:35
AlgebraicVector5
ROOT::Math::SVector< double, 5 > AlgebraicVector5
Definition: AlgebraicROOTObjects.h:14
PV3DBase::basicVector
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
TrajectoryStateOnSurface::globalMomentum
GlobalVector globalMomentum() const
Definition: TrajectoryStateOnSurface.h:66
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
edm::SimTrackContainer
std::vector< SimTrack > SimTrackContainer
Definition: SimTrackContainer.h:12
SimTrack
Definition: SimTrack.h:9
Exception
Definition: hltDiff.cc:245
TrajectorySeed
Definition: TrajectorySeed.h:18
TrajectoryStateTransform.h
TrajectoryStateOnSurface::surface
const SurfaceType & surface() const
Definition: TrajectoryStateOnSurface.h:78
FastTrackerRecHit.h
mps_fire.result
result
Definition: mps_fire.py:311
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
TrajectoryStateOnSurface::localError
const LocalTrajectoryError & localError() const
Definition: TrajectoryStateOnSurface.h:77
MagneticField
Definition: MagneticField.h:19
AlgebraicSymMatrix55
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
Definition: AlgebraicROOTObjects.h:23
SimTrackContainer.h
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
TrackerGeometry
Definition: TrackerGeometry.h:14