CMS 3D CMS Logo

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

#include <MatcherUsingTracksAlgorithm.h>

Public Member Functions

bool hasChi2 () const
 Return 'true' if the matcher will produce also chi2. More...
 
bool hasMetrics () const
 Return 'true' if the matcher will produce meaningful deltaR, deltaLocalPos, deltaPtRel values. More...
 
void init (const edm::EventSetup &iSetup)
 Call this method at the beginning of each run, to initialize geometry, magnetic field and propagators. More...
 
bool match (const reco::Candidate &c1, const reco::Candidate &c2, float &deltaR, float &deltaEta, float &deltaPhi, float &deltaLocalPos, float &deltaPtRel, float &chi2) const
 
int match (const reco::Candidate &tk, const edm::View< reco::Candidate > &c2s, float &deltaR, float &deltaEta, float &deltaPhi, float &deltaLocalPos, float &deltaPtRel, float &chi2) const
 
 MatcherUsingTracksAlgorithm (const edm::ParameterSet &iConfig, edm::ConsumesCollector)
 
virtual ~MatcherUsingTracksAlgorithm ()
 

Static Public Member Functions

static void cropAndInvert (AlgebraicSymMatrix55 &cov, bool diagonalOnly, bool top3by3only)
 Possibly crop the 3x3 part of the matrix or remove off-diagonal terms, then invert. More...
 
static double getChi2 (const FreeTrajectoryState &start, const FreeTrajectoryState &other, bool diagonalOnly, bool useVertex, bool useFirstMomentum)
 
static double getChi2 (const FreeTrajectoryState &start, const TrajectoryStateClosestToPoint &other, bool diagonalOnly, bool useVertex)
 
static double getChi2 (const TrajectoryStateOnSurface &start, const TrajectoryStateOnSurface &other, bool diagonalOnly, bool usePosition)
 

Private Types

enum  AlgoType {
  ByTrackRef, ByDirectComparison, ByPropagatingSrc, ByPropagatingMatched,
  ByPropagatingSrcTSCP, ByPropagatingMatchedTSCP
}
 
enum  SortBy {
  LocalPosDiff, GlobalMomDeltaR, GlobalMomDeltaEta, GlobalMomDeltaPhi,
  GlobalDPtRel, Chi2
}
 
enum  WhichState { AtVertex, Innermost, Outermost }
 
enum  WhichTrack { None, TrackerTk, MuonTk, GlobalTk }
 

Private Member Functions

void getConf (const edm::ParameterSet &iConfig, const std::string &whatFor, WhichTrack &whichTrack, WhichState &whichState)
 Parse some configuration. More...
 
reco::TrackRef getTrack (const reco::Candidate &reco, WhichTrack which) const
 Get track reference out of a Candidate (via dynamic_cast to reco::RecoCandidate) More...
 
bool matchByDirectComparison (const FreeTrajectoryState &start, const FreeTrajectoryState &other, float &lastDeltaR, float &lastDeltaEta, float &lastDeltaPhi, float &lastDeltaLocalPos, float &lastGlobalDPtRel, float &lastChi2) const
 Compare directly two states. return true if current pair is the new best match (in that case, update also deltaR and deltaLocalPos) More...
 
bool matchWithPropagation (const FreeTrajectoryState &start, const FreeTrajectoryState &target, float &lastDeltaR, float &lastDeltaEta, float &lastDeltaPhi, float &lastDeltaLocalPos, float &lastGlobalDPtRel, float &lastChi2) const
 
bool matchWithPropagation (const FreeTrajectoryState &start, const TrajectoryStateOnSurface &target, float &lastDeltaR, float &lastDeltaEta, float &lastDeltaPhi, float &lastDeltaLocalPos, float &lastGlobalDPtRel, float &lastChi2) const
 
FreeTrajectoryState startingState (const reco::Candidate &reco, WhichTrack whichTrack, WhichState whichState) const
 Starting state for the propagation. More...
 
TrajectoryStateOnSurface targetState (const reco::Candidate &reco, WhichTrack whichTrack, WhichState whichState) const
 End state for the propagation. More...
 

Private Attributes

AlgoType algo_
 
bool chi2DiagonalOnly_
 
bool chi2FirstMomentum_
 
bool chi2UseVertex_
 
edm::ESHandle
< GlobalTrackingGeometry
geometry_
 
edm::ESGetToken
< GlobalTrackingGeometry,
GlobalTrackingGeometryRecord
geometryToken_
 
edm::ESHandle< MagneticFieldmagfield_
 
edm::ESGetToken< MagneticField,
IdealMagneticFieldRecord
magfieldToken_
 
StringCutObjectSelector
< reco::Candidate, true > 
matchedCut_
 
float maxChi2_
 
float maxGlobalDPtRel_
 
float maxGlobalMomDeltaEta_
 
float maxGlobalMomDeltaPhi_
 
float maxGlobalMomDeltaR_
 
float maxLocalPosDiff_
 
edm::ESHandle< Propagatorpropagator_
 
edm::ESGetToken< Propagator,
TrackingComponentsRecord
propagatorToken_
 
bool requireSameCharge_
 
SortBy sortBy_
 
StringCutObjectSelector
< reco::Candidate, true > 
srcCut_
 
bool useChi2_
 
WhichState whichState1_
 
WhichState whichState2_
 
WhichTrack whichTrack1_
 
WhichTrack whichTrack2_
 

Detailed Description

Definition at line 34 of file MatcherUsingTracksAlgorithm.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

MatcherUsingTracksAlgorithm::MatcherUsingTracksAlgorithm ( const edm::ParameterSet iConfig,
edm::ConsumesCollector  iC 
)
explicit

Definition at line 19 of file MatcherUsingTracksAlgorithm.cc.

References algo_, AtVertex, ByDirectComparison, ByPropagatingMatched, ByPropagatingMatchedTSCP, ByPropagatingSrc, ByPropagatingSrcTSCP, ByTrackRef, Chi2, chi2DiagonalOnly_, chi2FirstMomentum_, chi2UseVertex_, Exception, edm::ParameterSet::existsAs(), getConf(), edm::ParameterSet::getParameter(), GlobalDPtRel, GlobalMomDeltaEta, GlobalMomDeltaPhi, GlobalMomDeltaR, LocalPosDiff, maxChi2_, maxGlobalDPtRel_, maxGlobalMomDeltaEta_, maxGlobalMomDeltaPhi_, maxGlobalMomDeltaR_, maxLocalPosDiff_, None, sortBy_, AlCaHLTBitMon_QueryRunRegistry::string, useChi2_, whichState1_, whichState2_, whichTrack1_, and whichTrack2_.

20  : whichTrack1_(None),
24  srcCut_(iConfig.existsAs<std::string>("srcPreselection") ? iConfig.getParameter<std::string>("srcPreselection")
25  : ""),
26  matchedCut_(iConfig.existsAs<std::string>("matchedPreselection")
27  ? iConfig.getParameter<std::string>("matchedPreselection")
28  : ""),
29  requireSameCharge_(iConfig.existsAs<bool>("requireSameCharge") ? iConfig.getParameter<bool>("requireSameCharge")
30  : false),
32  propagatorToken_(iC.esConsumes(edm::ESInputTag("", "SteppingHelixPropagatorAny"))),
34  std::string algo = iConfig.getParameter<std::string>("algorithm");
35  if (algo == "byTrackRef") {
36  algo_ = ByTrackRef;
37  } else if (algo == "byPropagatingSrc") {
39  } else if (algo == "byPropagatingMatched") {
41  } else if (algo == "byDirectComparison") {
43  } else
44  throw cms::Exception("Configuration") << "Value '" << algo << "' for algorithm not yet implemented.\n";
45 
46  getConf(iConfig, "src", whichTrack1_, whichState1_);
47  getConf(iConfig, "matched", whichTrack2_, whichState2_);
48 
49  if (algo_ == ByTrackRef) {
50  // validate the config
51  if (whichTrack1_ == None || whichTrack2_ == None)
52  throw cms::Exception("Configuration") << "Algorithm 'byTrackRef' needs tracks not to be 'none'.\n";
54  // read matching cuts
55  maxLocalPosDiff_ = iConfig.getParameter<double>("maxDeltaLocalPos");
56  maxGlobalMomDeltaR_ = iConfig.getParameter<double>("maxDeltaR");
58  iConfig.existsAs<double>("maxDeltaEta") ? iConfig.getParameter<double>("maxDeltaEta") : maxGlobalMomDeltaR_;
60  iConfig.existsAs<double>("maxDeltaPhi") ? iConfig.getParameter<double>("maxDeltaPhi") : maxGlobalMomDeltaR_;
61  maxGlobalDPtRel_ = iConfig.getParameter<double>("maxDeltaPtRel");
62 
63  // choice of sorting variable
64  std::string sortBy = iConfig.getParameter<std::string>("sortBy");
65  if (sortBy == "deltaLocalPos")
67  else if (sortBy == "deltaPtRel")
69  else if (sortBy == "deltaR")
71  else if (sortBy == "deltaEta")
73  else if (sortBy == "deltaPhi")
75  else if (sortBy == "chi2")
76  sortBy_ = Chi2;
77  else
78  throw cms::Exception("Configuration")
79  << "Parameter 'sortBy' must be one of: deltaLocalPos, deltaPtRel, deltaR, chi2.\n";
80  // validate the config
81  if (algo_ == ByPropagatingSrc) {
82  if (whichTrack2_ == None || whichState2_ == AtVertex) {
84  //throw cms::Exception("Configuration") << "Destination track must be non-null, and state must not be 'AtVertex' (not yet).\n";
85  }
86  } else if (algo_ == ByPropagatingMatched) {
87  if (whichTrack1_ == None || whichState1_ == AtVertex) {
89  //throw cms::Exception("Configuration") << "Destination track must be non-null, and state must not be 'AtVertex' (not yet).\n";
90  }
91  } else if (algo_ == ByDirectComparison) {
92  bool firstAtVertex = (whichTrack1_ == None || whichState1_ == AtVertex);
93  bool secAtVertex = (whichTrack2_ == None || whichState2_ == AtVertex);
94  if (firstAtVertex) {
95  if (!secAtVertex)
96  throw cms::Exception("Configuration")
97  << "When using 'byDirectComparison' with 'src' at vertex (or None), 'matched' must be at vertex too.\n";
98  } else {
99  if (secAtVertex)
100  throw cms::Exception("Configuration")
101  << "When using 'byDirectComparison' with 'src' not at vertex, 'matched' can't be at vertex or None.\n";
102  if (whichState1_ != whichState2_)
103  throw cms::Exception("Configuration") << "You can't use 'byDirectComparison' with non-matching states.\n";
104  }
105  }
106 
107  useChi2_ = iConfig.existsAs<bool>("computeChi2") ? iConfig.getParameter<bool>("computeChi2") : false;
108  if (useChi2_) {
109  if (whichTrack1_ == None && whichTrack2_ == None)
110  throw cms::Exception("Configuration") << "Can't compute chi2s if both tracks are set to 'none'.\n";
111  maxChi2_ = iConfig.getParameter<double>("maxChi2");
112  chi2DiagonalOnly_ = iConfig.getParameter<bool>("chi2DiagonalOnly");
114  chi2UseVertex_ = iConfig.getParameter<bool>("chi2UsePosition");
115  } else {
116  chi2UseVertex_ = iConfig.getParameter<bool>("chi2UseVertex");
117  if (algo_ == ByDirectComparison) {
118  std::string choice = iConfig.getParameter<std::string>("chi2MomentumForDxy");
119  if (choice == "src")
120  chi2FirstMomentum_ = true;
121  else if (choice != "matched")
122  throw cms::Exception("Configuration") << "chi2MomentumForDxy must be 'src' or 'matched'\n";
123  }
124  }
125  } else
126  maxChi2_ = 1;
127 
128  if (sortBy_ == Chi2 && !useChi2_)
129  throw cms::Exception("Configuration") << "Can't sort by chi2s if 'computeChi2s' is not set to true.\n";
130  }
131 }
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > geometryToken_
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
void getConf(const edm::ParameterSet &iConfig, const std::string &whatFor, WhichTrack &whichTrack, WhichState &whichState)
Parse some configuration.
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magfieldToken_
StringCutObjectSelector< reco::Candidate, true > matchedCut_
StringCutObjectSelector< reco::Candidate, true > srcCut_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorToken_
Definition: Chi2.h:15
virtual MatcherUsingTracksAlgorithm::~MatcherUsingTracksAlgorithm ( )
inlinevirtual

Definition at line 37 of file MatcherUsingTracksAlgorithm.h.

37 {}

Member Function Documentation

void MatcherUsingTracksAlgorithm::cropAndInvert ( AlgebraicSymMatrix55 cov,
bool  diagonalOnly,
bool  top3by3only 
)
static

Possibly crop the 3x3 part of the matrix or remove off-diagonal terms, then invert.

Definition at line 625 of file MatcherUsingTracksAlgorithm.cc.

References mps_fire::i, and dqmiolumiharvest::j.

Referenced by getChi2().

625  {
626  if (!top3by3only) {
627  if (diagonalOnly) {
628  for (size_t i = 0; i < 5; ++i) {
629  for (size_t j = i + 1; j < 5; ++j) {
630  cov(i, j) = 0;
631  }
632  }
633  }
634  cov.Invert();
635  } else {
636  // get 3x3 covariance
637  AlgebraicSymMatrix33 momCov = cov.Sub<AlgebraicSymMatrix33>(0, 0); // get 3x3 matrix
638  if (diagonalOnly) {
639  momCov(0, 1) = 0;
640  momCov(0, 2) = 0;
641  momCov(1, 2) = 0;
642  }
643  // invert
644  momCov.Invert();
645  // place it
646  cov.Place_at(momCov, 0, 0);
647  // zero the rest
648  for (size_t i = 3; i < 5; ++i) {
649  for (size_t j = i; j < 5; ++j) {
650  cov(i, j) = 0;
651  }
652  }
653  }
654 }
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
double MatcherUsingTracksAlgorithm::getChi2 ( const FreeTrajectoryState start,
const FreeTrajectoryState other,
bool  diagonalOnly,
bool  useVertex,
bool  useFirstMomentum 
)
static

Compute the chi2 of two free trajectory states, in the curvilinear frame (q/p, theta, phi, dxy, dsz) At least one must have errors diagonalOnly: don't use off-diagonal terms of covariance matrix useVertex : use dxy, dsz in the chi2 (if false, use only q/p, theta, phi) useFirstMomentum : use the 'start' state momentum to compute dxy, dsx (if false, use 'other')

Definition at line 563 of file MatcherUsingTracksAlgorithm.cc.

References FreeTrajectoryState::charge(), cropAndInvert(), FreeTrajectoryState::curvilinearError(), change_name::diff, PVValHelper::dxy, FreeTrajectoryState::hasError(), PV3DBase< T, PVType, FrameType >::mag(), CurvilinearTrajectoryError::matrix(), FreeTrajectoryState::momentum(), AlCaHLTBitMon_ParallelJobs::p, fireworks::p1, fireworks::p2, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), FreeTrajectoryState::position(), DiDispStaMuonMonitor_cfi::pt, PV3DBase< T, PVType, FrameType >::theta(), relativeConstraints::value, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by matchByDirectComparison(), and matchWithPropagation().

567  {
568  if (!start.hasError() && !other.hasError())
569  throw cms::Exception("LogicError") << "At least one of the two states must have errors to make chi2s.\n";
571  if (start.hasError())
572  cov += start.curvilinearError().matrix();
573  if (other.hasError())
574  cov += other.curvilinearError().matrix();
575  cropAndInvert(cov, diagonalOnly, !useVertex);
576  GlobalVector p1 = start.momentum(), p2 = other.momentum();
577  GlobalPoint x1 = start.position(), x2 = other.position();
578  GlobalVector p = useFirstMomentum ? p1 : p2;
579  double pt = p.perp(), pm = p.mag();
580  double dsz = (x1.z() - x2.z()) * pt / pm - ((x1.x() - x2.x()) * p.x() + (x1.y() - x2.y()) * p.y()) / pt * p.z() / pm;
581  double dxy = (-(x1.x() - x2.x()) * p.y() + (x1.y() - x2.y()) * p.x()) / pt;
582  AlgebraicVector5 diff(start.charge() / p1.mag() - other.charge() / p2.mag(),
583  p1.theta() - p2.theta(),
584  (p1.phi() - p2.phi()).value(),
585  dxy,
586  dsz);
587  return ROOT::Math::Similarity(diff, cov);
588 }
T perp() const
Definition: PV3DBase.h:69
const TString p2
Definition: fwPaths.cc:13
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T y() const
Definition: PV3DBase.h:60
TrackCharge charge() const
const CurvilinearTrajectoryError & curvilinearError() const
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
T mag() const
Definition: PV3DBase.h:64
T z() const
Definition: PV3DBase.h:61
const TString p1
Definition: fwPaths.cc:12
ROOT::Math::SVector< double, 5 > AlgebraicVector5
GlobalVector momentum() const
GlobalPoint position() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
static void cropAndInvert(AlgebraicSymMatrix55 &cov, bool diagonalOnly, bool top3by3only)
Possibly crop the 3x3 part of the matrix or remove off-diagonal terms, then invert.
const AlgebraicSymMatrix55 & matrix() const
T x() const
Definition: PV3DBase.h:59
double MatcherUsingTracksAlgorithm::getChi2 ( const FreeTrajectoryState start,
const TrajectoryStateClosestToPoint other,
bool  diagonalOnly,
bool  useVertex 
)
static

Compute the chi2 of one free trajectory state and a TrajectoryStateClosestToPoint closest to it, in the perigee frame At least one must have errors diagonalOnly: don't use off-diagonal terms of covariance matrix useVertex : use dxy, dsz in the chi2 (if false, use only q/p, theta, phi)

Definition at line 590 of file MatcherUsingTracksAlgorithm.cc.

References PerigeeTrajectoryError::covarianceMatrix(), cropAndInvert(), change_name::diff, PerigeeConversions::ftsToPerigeeError(), PerigeeConversions::ftsToPerigeeParameters(), FreeTrajectoryState::hasError(), TrajectoryStateClosestToPoint::hasError(), TrajectoryStateClosestToPoint::perigeeError(), TrajectoryStateClosestToPoint::perigeeParameters(), DiDispStaMuonMonitor_cfi::pt, TrajectoryStateClosestToPoint::referencePoint(), trackerHitRTTI::vector, and PerigeeTrajectoryParameters::vector().

593  {
594  if (!start.hasError() && !other.hasError())
595  throw cms::Exception("LogicError") << "At least one of the two states must have errors to make chi2s.\n";
596  double pt; // needed by pgconvert
598  if (start.hasError())
600  if (other.hasError())
601  cov += other.perigeeError().covarianceMatrix();
602  cropAndInvert(cov, diagonalOnly, !useVertex);
604  AlgebraicVector5 pgpar2 = other.perigeeParameters().vector();
605  AlgebraicVector5 diff(pgpar1 - pgpar2);
606  return ROOT::Math::Similarity(diff, cov);
607 }
const AlgebraicVector5 & vector() const
PerigeeTrajectoryParameters ftsToPerigeeParameters(const FTS &originalFTS, const GlobalPoint &referencePoint, double &pt)
const PerigeeTrajectoryError & perigeeError() const
const PerigeeTrajectoryParameters & perigeeParameters() const
ROOT::Math::SVector< double, 5 > AlgebraicVector5
const AlgebraicSymMatrix55 & covarianceMatrix() const
const GlobalPoint & referencePoint() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
static void cropAndInvert(AlgebraicSymMatrix55 &cov, bool diagonalOnly, bool top3by3only)
Possibly crop the 3x3 part of the matrix or remove off-diagonal terms, then invert.
PerigeeTrajectoryError ftsToPerigeeError(const FTS &originalFTS)
double MatcherUsingTracksAlgorithm::getChi2 ( const TrajectoryStateOnSurface start,
const TrajectoryStateOnSurface other,
bool  diagonalOnly,
bool  usePosition 
)
static

Compute the chi2 of two free trajectory states, in the local frame (q/p, dx, dy, dxdz, dydz) At least one must have errors diagonalOnly: don't use off-diagonal terms of covariance matrix useVertex : use dx, dy in the chi2 (if false, use only direction and q/p)

Definition at line 609 of file MatcherUsingTracksAlgorithm.cc.

References cropAndInvert(), change_name::diff, TrajectoryStateOnSurface::hasError(), TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localParameters(), LocalTrajectoryError::matrix(), and LocalTrajectoryParameters::mixedFormatVector().

612  {
613  if (!start.hasError() && !other.hasError())
614  throw cms::Exception("LogicError") << "At least one of the two states must have errors to make chi2s.\n";
616  if (start.hasError())
617  cov += start.localError().matrix();
618  if (other.hasError())
619  cov += other.localError().matrix();
620  cropAndInvert(cov, diagonalOnly, !usePosition);
622  return ROOT::Math::Similarity(diff, cov);
623 }
const LocalTrajectoryParameters & localParameters() const
ROOT::Math::SVector< double, 5 > AlgebraicVector5
const AlgebraicSymMatrix55 & matrix() const
const LocalTrajectoryError & localError() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
static void cropAndInvert(AlgebraicSymMatrix55 &cov, bool diagonalOnly, bool top3by3only)
Possibly crop the 3x3 part of the matrix or remove off-diagonal terms, then invert.
AlgebraicVector5 mixedFormatVector() const
void MatcherUsingTracksAlgorithm::getConf ( const edm::ParameterSet iConfig,
const std::string &  whatFor,
WhichTrack whichTrack,
WhichState whichState 
)
private

Parse some configuration.

Definition at line 133 of file MatcherUsingTracksAlgorithm.cc.

References algo_, AtVertex, ByTrackRef, Exception, edm::ParameterSet::getParameter(), GlobalTk, Innermost, MuonTk, None, Outermost, AlCaHLTBitMon_QueryRunRegistry::string, and TrackerTk.

Referenced by MatcherUsingTracksAlgorithm().

136  {
137  std::string s_whichTrack = iConfig.getParameter<std::string>(whatFor + "Track");
138  if (s_whichTrack == "none") {
139  whichTrack = None;
140  } else if (s_whichTrack == "tracker") {
141  whichTrack = TrackerTk;
142  } else if (s_whichTrack == "muon") {
143  whichTrack = MuonTk;
144  } else if (s_whichTrack == "global") {
145  whichTrack = GlobalTk;
146  } else
147  throw cms::Exception("Configuration") << "Parameter 'useTrack' must be 'none', 'tracker', 'muon', 'global'\n";
148  if ((whichTrack != None) && (algo_ != ByTrackRef)) {
149  std::string s_whichState = iConfig.getParameter<std::string>(whatFor + "State");
150  if (s_whichState == "atVertex") {
151  whichState = AtVertex;
152  } else if (s_whichState == "innermost") {
153  whichState = Innermost;
154  } else if (s_whichState == "outermost") {
155  whichState = Outermost;
156  } else
157  throw cms::Exception("Configuration") << "Parameter 'useState' must be 'atVertex', 'innermost', 'outermost'\n";
158  }
159 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
reco::TrackRef MatcherUsingTracksAlgorithm::getTrack ( const reco::Candidate reco,
WhichTrack  which 
) const
private

Get track reference out of a Candidate (via dynamic_cast to reco::RecoCandidate)

Definition at line 311 of file MatcherUsingTracksAlgorithm.cc.

References reco::RecoCandidate::combinedMuon(), Exception, GlobalTk, MuonTk, dt_dqm_sourceclient_common_cff::reco, reco::RecoCandidate::standAloneMuon(), reco::RecoCandidate::track(), and TrackerTk.

Referenced by match(), startingState(), and targetState().

311  {
312  reco::TrackRef tk;
313  const reco::RecoCandidate *rc = dynamic_cast<const reco::RecoCandidate *>(&reco);
314  if (rc == nullptr)
315  throw cms::Exception("Invalid Data") << "Input object is not a RecoCandidate.\n";
316  switch (whichTrack) {
317  case TrackerTk:
318  tk = rc->track();
319  break;
320  case MuonTk:
321  tk = rc->standAloneMuon();
322  break;
323  case GlobalTk:
324  tk = rc->combinedMuon();
325  break;
326  default:
327  break; // just to make gcc happy
328  }
329  return tk;
330 }
virtual reco::TrackRef standAloneMuon() const
reference to a stand-alone muon Track
virtual reco::TrackRef track() const
reference to a Track
virtual reco::TrackRef combinedMuon() const
reference to a stand-alone muon Track
bool MatcherUsingTracksAlgorithm::hasChi2 ( ) const
inline

Return 'true' if the matcher will produce also chi2.

Definition at line 69 of file MatcherUsingTracksAlgorithm.h.

References useChi2_.

bool MatcherUsingTracksAlgorithm::hasMetrics ( ) const
inline

Return 'true' if the matcher will produce meaningful deltaR, deltaLocalPos, deltaPtRel values.

Definition at line 66 of file MatcherUsingTracksAlgorithm.h.

References algo_, and ByTrackRef.

void MatcherUsingTracksAlgorithm::init ( const edm::EventSetup iSetup)

Call this method at the beginning of each run, to initialize geometry, magnetic field and propagators.

Definition at line 305 of file MatcherUsingTracksAlgorithm.cc.

References geometry_, geometryToken_, edm::EventSetup::getHandle(), magfield_, magfieldToken_, propagator_, and propagatorToken_.

305  {
309 }
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > geometryToken_
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magfieldToken_
edm::ESHandle< GlobalTrackingGeometry > geometry_
edm::ESHandle< MagneticField > magfield_
edm::ESHandle< Propagator > propagator_
edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorToken_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157
bool MatcherUsingTracksAlgorithm::match ( const reco::Candidate c1,
const reco::Candidate c2,
float &  deltR,
float &  deltEta,
float &  deltPhi,
float &  deltaLocalPos,
float &  deltaPtRel,
float &  chi2 
) const

Try to match one track to another one. Return true if succeeded. For matches not by ref, it will update deltaR, deltaLocalPos and deltaPtRel if the match suceeded

Definition at line 163 of file MatcherUsingTracksAlgorithm.cc.

References algo_, ByDirectComparison, ByPropagatingMatched, ByPropagatingMatchedTSCP, ByPropagatingSrc, ByPropagatingSrcTSCP, ByTrackRef, reco::Candidate::charge(), getTrack(), edm::Ref< C, T, F >::id(), edm::Ref< C, T, F >::isNonnull(), matchByDirectComparison(), matchedCut_, matchWithPropagation(), requireSameCharge_, srcCut_, command_line::start, startingState(), filterCSVwithJSON::target, targetState(), whichState1_, whichState2_, whichTrack1_, and whichTrack2_.

Referenced by match().

170  {
171  if (!(srcCut_(c1) && matchedCut_(c2)))
172  return false;
173  if (requireSameCharge_ && (c1.charge() != c2.charge()))
174  return false;
175  switch (algo_) {
176  case ByTrackRef: {
179  if (t1.isNonnull()) {
180  if (t1 == t2)
181  return true;
182  if (t1.id() != t2.id()) {
183  edm::LogWarning("MatcherUsingTracksAlgorithm")
184  << "Trying to match by reference tracks coming from different collections.\n";
185  }
186  }
187  }
188  [[fallthrough]];
189  case ByPropagatingSrc: {
192  return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
193  }
194  case ByPropagatingMatched: {
197  return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
198  }
199  case ByPropagatingSrcTSCP: {
202  return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
203  }
207  return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
208  }
209 
210  case ByDirectComparison: {
213  return matchByDirectComparison(start, otherstart, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
214  }
215  }
216  return false;
217 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool matchWithPropagation(const FreeTrajectoryState &start, const FreeTrajectoryState &target, float &lastDeltaR, float &lastDeltaEta, float &lastDeltaPhi, float &lastDeltaLocalPos, float &lastGlobalDPtRel, float &lastChi2) const
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
StringCutObjectSelector< reco::Candidate, true > matchedCut_
StringCutObjectSelector< reco::Candidate, true > srcCut_
virtual int charge() const =0
electric charge
TrajectoryStateOnSurface targetState(const reco::Candidate &reco, WhichTrack whichTrack, WhichState whichState) const
End state for the propagation.
FreeTrajectoryState startingState(const reco::Candidate &reco, WhichTrack whichTrack, WhichState whichState) const
Starting state for the propagation.
reco::TrackRef getTrack(const reco::Candidate &reco, WhichTrack which) const
Get track reference out of a Candidate (via dynamic_cast to reco::RecoCandidate)
Log< level::Warning, false > LogWarning
bool matchByDirectComparison(const FreeTrajectoryState &start, const FreeTrajectoryState &other, float &lastDeltaR, float &lastDeltaEta, float &lastDeltaPhi, float &lastDeltaLocalPos, float &lastGlobalDPtRel, float &lastChi2) const
Compare directly two states. return true if current pair is the new best match (in that case...
int MatcherUsingTracksAlgorithm::match ( const reco::Candidate c1,
const edm::View< reco::Candidate > &  c2s,
float &  deltR,
float &  deltEta,
float &  deltPhi,
float &  deltaLocalPos,
float &  deltaPtRel,
float &  chi2 
) const

Find the best match to another candidate, and return its index in the vector For matches not by ref, it will update deltaR, deltaLocalPos and deltaPtRel if the match suceeded Returns -1 if the match fails

Definition at line 222 of file MatcherUsingTracksAlgorithm.cc.

References algo_, edm::View< T >::begin(), ByDirectComparison, ByPropagatingMatched, ByPropagatingMatchedTSCP, ByPropagatingSrc, ByPropagatingSrcTSCP, ByTrackRef, reco::Candidate::charge(), edm::View< T >::end(), beamvalidation::exit(), getTrack(), mps_fire::i, edm::Ref< C, T, F >::id(), edm::Ref< C, T, F >::isNonnull(), match(), matchByDirectComparison(), matchedCut_, matchWithPropagation(), requireSameCharge_, srcCut_, command_line::start, startingState(), filterCSVwithJSON::target, targetState(), whichState1_, whichState2_, whichTrack1_, and whichTrack2_.

229  {
230  if (!srcCut_(c1))
231  return -1;
232 
233  // working and output variables
236  int match = -1;
237 
238  // pre-fetch some states if needed
242  } else if (algo_ == ByPropagatingMatched)
243  target = targetState(c1, whichTrack1_, whichState1_);
244 
245  // loop on the collection
247  int i;
248  for (it = c2s.begin(), ed = c2s.end(), i = 0; it != ed; ++it, ++i) {
249  if (!matchedCut_(*it))
250  continue;
251  if (requireSameCharge_ && (c1.charge() != it->charge()))
252  continue;
253  bool exit = false;
254  switch (algo_) {
255  case ByTrackRef: {
258  if (t1.isNonnull()) {
259  if (t1 == t2) {
260  match = i;
261  exit = true;
262  }
263  if (t1.id() != t2.id()) {
264  edm::LogWarning("MatcherUsingTracksAlgorithm")
265  << "Trying to match by reference tracks coming from different collections.\n";
266  }
267  }
268  } break;
269  case ByPropagatingSrc:
270  case ByPropagatingMatched: {
272  start = startingState(*it, whichTrack2_, whichState2_);
273  else if (algo_ == ByPropagatingSrc)
274  target = targetState(*it, whichTrack2_, whichState2_);
275  if (matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
276  match = i;
277  }
278  } break;
279  case ByDirectComparison: {
281  if (matchByDirectComparison(start, otherstart, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
282  match = i;
283  }
284  } break;
285  case ByPropagatingSrcTSCP: {
287  if (matchWithPropagation(start, otherstart, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
288  match = i;
289  }
290  } break;
293  if (matchWithPropagation(otherstart, start, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
294  match = i;
295  }
296  } break;
297  }
298  if (exit)
299  break;
300  }
301 
302  return match;
303 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool matchWithPropagation(const FreeTrajectoryState &start, const FreeTrajectoryState &target, float &lastDeltaR, float &lastDeltaEta, float &lastDeltaPhi, float &lastDeltaLocalPos, float &lastGlobalDPtRel, float &lastChi2) const
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
StringCutObjectSelector< reco::Candidate, true > matchedCut_
const_iterator begin() const
StringCutObjectSelector< reco::Candidate, true > srcCut_
virtual int charge() const =0
electric charge
TrajectoryStateOnSurface targetState(const reco::Candidate &reco, WhichTrack whichTrack, WhichState whichState) const
End state for the propagation.
FreeTrajectoryState startingState(const reco::Candidate &reco, WhichTrack whichTrack, WhichState whichState) const
Starting state for the propagation.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
bool match(const reco::Candidate &c1, const reco::Candidate &c2, float &deltaR, float &deltaEta, float &deltaPhi, float &deltaLocalPos, float &deltaPtRel, float &chi2) const
const_iterator end() const
reco::TrackRef getTrack(const reco::Candidate &reco, WhichTrack which) const
Get track reference out of a Candidate (via dynamic_cast to reco::RecoCandidate)
Log< level::Warning, false > LogWarning
bool matchByDirectComparison(const FreeTrajectoryState &start, const FreeTrajectoryState &other, float &lastDeltaR, float &lastDeltaEta, float &lastDeltaPhi, float &lastDeltaLocalPos, float &lastGlobalDPtRel, float &lastChi2) const
Compare directly two states. return true if current pair is the new best match (in that case...
bool MatcherUsingTracksAlgorithm::matchByDirectComparison ( const FreeTrajectoryState start,
const FreeTrajectoryState other,
float &  lastDeltaR,
float &  lastDeltaEta,
float &  lastDeltaPhi,
float &  lastDeltaLocalPos,
float &  lastGlobalDPtRel,
float &  lastChi2 
) const
private

Compare directly two states. return true if current pair is the new best match (in that case, update also deltaR and deltaLocalPos)

Definition at line 506 of file MatcherUsingTracksAlgorithm.cc.

References PV3DBase< T, PVType, FrameType >::barePhi(), chi2DiagonalOnly_, chi2FirstMomentum_, chi2UseVertex_, srCondWrite_cfg::deltaPhi, HLT_FULL_cff::deltaR, PV3DBase< T, PVType, FrameType >::eta(), getChi2(), GlobalDPtRel, GlobalMomDeltaEta, GlobalMomDeltaPhi, GlobalMomDeltaR, LocalPosDiff, PV3DBase< T, PVType, FrameType >::mag(), mag(), maxChi2_, maxGlobalDPtRel_, maxGlobalMomDeltaEta_, maxGlobalMomDeltaPhi_, maxGlobalMomDeltaR_, maxLocalPosDiff_, FreeTrajectoryState::momentum(), PV3DBase< T, PVType, FrameType >::perp(), FreeTrajectoryState::position(), sortBy_, and useChi2_.

Referenced by match().

513  {
514  if ((start.momentum().mag() == 0) || target.momentum().mag() == 0)
515  return false;
516 
517  bool isBest = false;
518  float thisLocalPosDiff = (start.position() - target.position()).mag();
519  float thisGlobalMomDeltaR = deltaR(start.momentum(), target.momentum());
520  float thisGlobalMomDeltaPhi = fabs(deltaPhi(start.momentum().barePhi(), target.momentum().barePhi()));
521  float thisGlobalMomDeltaEta = fabs(start.momentum().eta() - target.momentum().eta());
522  float thisGlobalDPtRel = (start.momentum().perp() - target.momentum().perp()) / target.momentum().perp();
523 
524  if ((thisLocalPosDiff < maxLocalPosDiff_) && (thisGlobalMomDeltaR < maxGlobalMomDeltaR_) &&
525  (thisGlobalMomDeltaEta < maxGlobalMomDeltaEta_) && (thisGlobalMomDeltaPhi < maxGlobalMomDeltaPhi_) &&
526  (fabs(thisGlobalDPtRel) < maxGlobalDPtRel_)) {
527  float thisChi2 = useChi2_ ? getChi2(start, target, chi2DiagonalOnly_, chi2UseVertex_, chi2FirstMomentum_) : 0;
528  if (thisChi2 >= maxChi2_)
529  return false;
530  switch (sortBy_) {
531  case LocalPosDiff:
532  isBest = (thisLocalPosDiff < lastDeltaLocalPos);
533  break;
534  case GlobalMomDeltaR:
535  isBest = (thisGlobalMomDeltaR < lastDeltaR);
536  break;
537  case GlobalMomDeltaEta:
538  isBest = (thisGlobalMomDeltaEta < lastDeltaEta);
539  break;
540  case GlobalMomDeltaPhi:
541  isBest = (thisGlobalMomDeltaPhi < lastDeltaPhi);
542  break;
543  case GlobalDPtRel:
544  isBest = (thisGlobalDPtRel < lastGlobalDPtRel);
545  break;
546  case Chi2:
547  isBest = (thisChi2 < lastChi2);
548  break;
549  }
550  if (isBest) {
551  lastDeltaLocalPos = thisLocalPosDiff;
552  lastDeltaR = thisGlobalMomDeltaR;
553  lastDeltaEta = thisGlobalMomDeltaEta;
554  lastDeltaPhi = thisGlobalMomDeltaPhi;
555  lastGlobalDPtRel = thisGlobalDPtRel;
556  lastChi2 = thisChi2;
557  }
558  } // if match
559 
560  return isBest;
561 }
T perp() const
Definition: PV3DBase.h:69
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
static double getChi2(const FreeTrajectoryState &start, const FreeTrajectoryState &other, bool diagonalOnly, bool useVertex, bool useFirstMomentum)
T barePhi() const
Definition: PV3DBase.h:65
T mag() const
Definition: PV3DBase.h:64
GlobalVector momentum() const
GlobalPoint position() const
T eta() const
Definition: PV3DBase.h:73
Definition: Chi2.h:15
bool MatcherUsingTracksAlgorithm::matchWithPropagation ( const FreeTrajectoryState start,
const FreeTrajectoryState target,
float &  lastDeltaR,
float &  lastDeltaEta,
float &  lastDeltaPhi,
float &  lastDeltaLocalPos,
float &  lastGlobalDPtRel,
float &  lastChi2 
) const
private

Propagate and match. return true if current pair is the new best match (in that case, update also deltaR and deltaLocalPos) Uses TrajectoryStateClosestToPointBuilder

Definition at line 444 of file MatcherUsingTracksAlgorithm.cc.

References PV3DBase< T, PVType, FrameType >::barePhi(), chi2DiagonalOnly_, chi2UseVertex_, srCondWrite_cfg::deltaPhi, HLT_FULL_cff::deltaR, submitPVValidationJobs::err, PV3DBase< T, PVType, FrameType >::eta(), getChi2(), GlobalDPtRel, GlobalMomDeltaEta, GlobalMomDeltaPhi, GlobalMomDeltaR, LocalPosDiff, PV3DBase< T, PVType, FrameType >::mag(), mag(), maxChi2_, maxGlobalDPtRel_, maxGlobalMomDeltaEta_, maxGlobalMomDeltaPhi_, maxGlobalMomDeltaR_, maxLocalPosDiff_, FreeTrajectoryState::momentum(), TrajectoryStateClosestToPoint::momentum(), PV3DBase< T, PVType, FrameType >::perp(), FreeTrajectoryState::position(), TrajectoryStateClosestToPoint::position(), HLT_FULL_cff::propagator, sortBy_, and useChi2_.

Referenced by match().

451  {
452  if ((start.momentum().mag() == 0) || (target.momentum().mag() == 0))
453  return false;
455  /*2.2.X*/ try {
456  TrajectoryStateClosestToPoint tscp = propagator(start, target.position());
457  // if (!tscp.isValid()) return false; // in 3.1.X
458 
459  bool isBest = false;
460  float thisLocalPosDiff = (tscp.position() - target.position()).mag();
461  float thisGlobalMomDeltaR = deltaR(tscp.momentum(), target.momentum());
462  float thisGlobalMomDeltaPhi = fabs(deltaPhi(tscp.momentum().barePhi(), target.momentum().barePhi()));
463  float thisGlobalMomDeltaEta = fabs(tscp.momentum().eta() - target.momentum().eta());
464  float thisGlobalDPtRel = (tscp.momentum().perp() - target.momentum().perp()) / target.momentum().perp();
465 
466  if ((thisLocalPosDiff < maxLocalPosDiff_) && (thisGlobalMomDeltaR < maxGlobalMomDeltaR_) &&
467  (thisGlobalMomDeltaEta < maxGlobalMomDeltaEta_) && (thisGlobalMomDeltaPhi < maxGlobalMomDeltaPhi_) &&
468  (fabs(thisGlobalDPtRel) < maxGlobalDPtRel_)) {
469  float thisChi2 = useChi2_ ? getChi2(target, tscp, chi2DiagonalOnly_, chi2UseVertex_) : 0;
470  if (thisChi2 >= maxChi2_)
471  return false;
472  switch (sortBy_) {
473  case LocalPosDiff:
474  isBest = (thisLocalPosDiff < lastDeltaLocalPos);
475  break;
476  case GlobalMomDeltaR:
477  isBest = (thisGlobalMomDeltaR < lastDeltaR);
478  break;
479  case GlobalMomDeltaEta:
480  isBest = (thisGlobalMomDeltaEta < lastDeltaEta);
481  break;
482  case GlobalMomDeltaPhi:
483  isBest = (thisGlobalMomDeltaPhi < lastDeltaPhi);
484  break;
485  case GlobalDPtRel:
486  isBest = (thisGlobalDPtRel < lastGlobalDPtRel);
487  break;
488  case Chi2:
489  isBest = (thisChi2 < lastChi2);
490  break;
491  }
492  if (isBest) {
493  lastDeltaLocalPos = thisLocalPosDiff;
494  lastDeltaR = thisGlobalMomDeltaR;
495  lastDeltaEta = thisGlobalMomDeltaEta;
496  lastDeltaPhi = thisGlobalMomDeltaPhi;
497  lastGlobalDPtRel = thisGlobalDPtRel;
498  lastChi2 = thisChi2;
499  }
500  } // if match
501 
502  return isBest;
503  /*2.2.X*/ } catch (const TrajectoryStateException &err) { return false; }
504 }
tuple propagator
T perp() const
Definition: PV3DBase.h:69
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
static double getChi2(const FreeTrajectoryState &start, const FreeTrajectoryState &other, bool diagonalOnly, bool useVertex, bool useFirstMomentum)
T barePhi() const
Definition: PV3DBase.h:65
T mag() const
Definition: PV3DBase.h:64
GlobalVector momentum() const
GlobalPoint position() const
T eta() const
Definition: PV3DBase.h:73
Definition: Chi2.h:15
bool MatcherUsingTracksAlgorithm::matchWithPropagation ( const FreeTrajectoryState start,
const TrajectoryStateOnSurface target,
float &  lastDeltaR,
float &  lastDeltaEta,
float &  lastDeltaPhi,
float &  lastDeltaLocalPos,
float &  lastGlobalDPtRel,
float &  lastChi2 
) const
private

Propagate and match. return true if current pair is the new best match (in that case, update also deltaR and deltaLocalPos) Uses standard propagator to reach target's surface

Definition at line 382 of file MatcherUsingTracksAlgorithm.cc.

References PV3DBase< T, PVType, FrameType >::barePhi(), chi2DiagonalOnly_, chi2UseVertex_, srCondWrite_cfg::deltaPhi, HLT_FULL_cff::deltaR, PV3DBase< T, PVType, FrameType >::eta(), getChi2(), GlobalDPtRel, GlobalMomDeltaEta, GlobalMomDeltaPhi, GlobalMomDeltaR, TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::isValid(), LocalPosDiff, TrajectoryStateOnSurface::localPosition(), PV3DBase< T, PVType, FrameType >::mag(), mag(), maxChi2_, maxGlobalDPtRel_, maxGlobalMomDeltaEta_, maxGlobalMomDeltaPhi_, maxGlobalMomDeltaR_, maxLocalPosDiff_, FreeTrajectoryState::momentum(), PV3DBase< T, PVType, FrameType >::perp(), propagator_, sortBy_, TrajectoryStateOnSurface::surface(), and useChi2_.

389  {
390  if ((start.momentum().mag() == 0) || !target.isValid())
391  return false;
392 
393  TrajectoryStateOnSurface tsos = propagator_->propagate(start, target.surface());
394 
395  bool isBest = false;
396  if (tsos.isValid()) {
397  float thisLocalPosDiff = (tsos.localPosition() - target.localPosition()).mag();
398  float thisGlobalMomDeltaR = deltaR(tsos.globalMomentum(), target.globalMomentum());
399  float thisGlobalMomDeltaPhi = fabs(deltaPhi(tsos.globalMomentum().barePhi(), target.globalMomentum().barePhi()));
400  float thisGlobalMomDeltaEta = fabs(tsos.globalMomentum().eta() - target.globalMomentum().eta());
401  float thisGlobalDPtRel =
402  (tsos.globalMomentum().perp() - target.globalMomentum().perp()) / target.globalMomentum().perp();
403 
404  if ((thisLocalPosDiff < maxLocalPosDiff_) && (thisGlobalMomDeltaR < maxGlobalMomDeltaR_) &&
405  (thisGlobalMomDeltaEta < maxGlobalMomDeltaEta_) && (thisGlobalMomDeltaPhi < maxGlobalMomDeltaPhi_) &&
406  (fabs(thisGlobalDPtRel) < maxGlobalDPtRel_)) {
407  float thisChi2 = useChi2_ ? getChi2(target, tsos, chi2DiagonalOnly_, chi2UseVertex_) : 0;
408  if (thisChi2 >= maxChi2_)
409  return false;
410  switch (sortBy_) {
411  case LocalPosDiff:
412  isBest = (thisLocalPosDiff < lastDeltaLocalPos);
413  break;
414  case GlobalMomDeltaR:
415  isBest = (thisGlobalMomDeltaR < lastDeltaR);
416  break;
417  case GlobalMomDeltaEta:
418  isBest = (thisGlobalMomDeltaEta < lastDeltaEta);
419  break;
420  case GlobalMomDeltaPhi:
421  isBest = (thisGlobalMomDeltaPhi < lastDeltaPhi);
422  break;
423  case GlobalDPtRel:
424  isBest = (thisGlobalDPtRel < lastGlobalDPtRel);
425  break;
426  case Chi2:
427  isBest = (thisChi2 < lastChi2);
428  break;
429  }
430  if (isBest) {
431  lastDeltaLocalPos = thisLocalPosDiff;
432  lastDeltaR = thisGlobalMomDeltaR;
433  lastDeltaEta = thisGlobalMomDeltaEta;
434  lastDeltaPhi = thisGlobalMomDeltaPhi;
435  lastGlobalDPtRel = thisGlobalDPtRel;
436  lastChi2 = thisChi2;
437  }
438  } // if match
439  }
440 
441  return isBest;
442 }
T perp() const
Definition: PV3DBase.h:69
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
static double getChi2(const FreeTrajectoryState &start, const FreeTrajectoryState &other, bool diagonalOnly, bool useVertex, bool useFirstMomentum)
T barePhi() const
Definition: PV3DBase.h:65
const SurfaceType & surface() const
T mag() const
Definition: PV3DBase.h:64
GlobalVector momentum() const
edm::ESHandle< Propagator > propagator_
T eta() const
Definition: PV3DBase.h:73
GlobalVector globalMomentum() const
Definition: Chi2.h:15
FreeTrajectoryState MatcherUsingTracksAlgorithm::startingState ( const reco::Candidate reco,
WhichTrack  whichTrack,
WhichState  whichState 
) const
private

Starting state for the propagation.

Definition at line 332 of file MatcherUsingTracksAlgorithm.cc.

References AtVertex, reco::Candidate::charge(), getTrack(), trajectoryStateTransform::initialFreeState(), trajectoryStateTransform::innerFreeState(), Innermost, edm::Ref< C, T, F >::isNull(), magfield_, None, trajectoryStateTransform::outerFreeState(), Outermost, edm::ESHandle< class >::product(), reco::Candidate::px(), reco::Candidate::py(), reco::Candidate::pz(), runTheMatrix::ret, reco::Candidate::vx(), reco::Candidate::vy(), and reco::Candidate::vz().

Referenced by match().

334  {
336  if (whichTrack != None) {
337  reco::TrackRef tk = getTrack(reco, whichTrack);
338  if (tk.isNull()) {
339  ret = FreeTrajectoryState();
340  } else {
341  switch (whichState) {
342  case AtVertex:
344  break;
345  case Innermost:
347  break;
348  case Outermost:
350  break;
351  }
352  }
353  } else {
354  ret = FreeTrajectoryState(GlobalPoint(reco.vx(), reco.vy(), reco.vz()),
355  GlobalVector(reco.px(), reco.py(), reco.pz()),
356  reco.charge(),
357  magfield_.product());
358  }
359  return ret;
360 }
tuple ret
prodAgent to be discontinued
virtual double pz() const =0
z coordinate of momentum vector
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
virtual double vx() const =0
x coordinate of vertex position
virtual double vy() const =0
y coordinate of vertex position
edm::ESHandle< MagneticField > magfield_
virtual int charge() const =0
electric charge
virtual double py() const =0
y coordinate of momentum vector
bool isNull() const
Checks for null.
Definition: Ref.h:235
virtual double px() const =0
x coordinate of momentum vector
T const * product() const
Definition: ESHandle.h:86
virtual double vz() const =0
z coordinate of vertex position
reco::TrackRef getTrack(const reco::Candidate &reco, WhichTrack which) const
Get track reference out of a Candidate (via dynamic_cast to reco::RecoCandidate)
FreeTrajectoryState innerFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)
FreeTrajectoryState outerFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)
FreeTrajectoryState initialFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)
Global3DVector GlobalVector
Definition: GlobalVector.h:10
TrajectoryStateOnSurface MatcherUsingTracksAlgorithm::targetState ( const reco::Candidate reco,
WhichTrack  whichTrack,
WhichState  whichState 
) const
private

End state for the propagation.

Definition at line 362 of file MatcherUsingTracksAlgorithm.cc.

References geometry_, getTrack(), Innermost, trajectoryStateTransform::innerStateOnSurface(), edm::Ref< C, T, F >::isNonnull(), magfield_, Outermost, trajectoryStateTransform::outerStateOnSurface(), edm::ESHandle< class >::product(), and runTheMatrix::ret.

Referenced by match().

364  {
366  reco::TrackRef tk = getTrack(reco, whichTrack);
367  if (tk.isNonnull()) {
368  switch (whichState) {
369  case Innermost:
371  break;
372  case Outermost:
374  break;
375  default:
376  break; // just to make gcc happy
377  }
378  }
379  return ret;
380 }
tuple ret
prodAgent to be discontinued
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
TrajectoryStateOnSurface outerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field, bool withErr=true)
edm::ESHandle< GlobalTrackingGeometry > geometry_
edm::ESHandle< MagneticField > magfield_
T const * product() const
Definition: ESHandle.h:86
reco::TrackRef getTrack(const reco::Candidate &reco, WhichTrack which) const
Get track reference out of a Candidate (via dynamic_cast to reco::RecoCandidate)
TrajectoryStateOnSurface innerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field, bool withErr=true)

Member Data Documentation

AlgoType MatcherUsingTracksAlgorithm::algo_
private
bool MatcherUsingTracksAlgorithm::chi2DiagonalOnly_
private
bool MatcherUsingTracksAlgorithm::chi2FirstMomentum_
private
bool MatcherUsingTracksAlgorithm::chi2UseVertex_
private
edm::ESHandle<GlobalTrackingGeometry> MatcherUsingTracksAlgorithm::geometry_
private

Definition at line 137 of file MatcherUsingTracksAlgorithm.h.

Referenced by init(), and targetState().

edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> MatcherUsingTracksAlgorithm::geometryToken_
private

Definition at line 141 of file MatcherUsingTracksAlgorithm.h.

Referenced by init().

edm::ESHandle<MagneticField> MatcherUsingTracksAlgorithm::magfield_
private

Definition at line 135 of file MatcherUsingTracksAlgorithm.h.

Referenced by init(), startingState(), and targetState().

edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> MatcherUsingTracksAlgorithm::magfieldToken_
private

Definition at line 139 of file MatcherUsingTracksAlgorithm.h.

Referenced by init().

StringCutObjectSelector<reco::Candidate, true> MatcherUsingTracksAlgorithm::matchedCut_
private

Definition at line 120 of file MatcherUsingTracksAlgorithm.h.

Referenced by match().

float MatcherUsingTracksAlgorithm::maxChi2_
private
float MatcherUsingTracksAlgorithm::maxGlobalDPtRel_
private
float MatcherUsingTracksAlgorithm::maxGlobalMomDeltaEta_
private
float MatcherUsingTracksAlgorithm::maxGlobalMomDeltaPhi_
private
float MatcherUsingTracksAlgorithm::maxGlobalMomDeltaR_
private
float MatcherUsingTracksAlgorithm::maxLocalPosDiff_
private
edm::ESHandle<Propagator> MatcherUsingTracksAlgorithm::propagator_
private

Definition at line 136 of file MatcherUsingTracksAlgorithm.h.

Referenced by init(), and matchWithPropagation().

edm::ESGetToken<Propagator, TrackingComponentsRecord> MatcherUsingTracksAlgorithm::propagatorToken_
private

Definition at line 140 of file MatcherUsingTracksAlgorithm.h.

Referenced by init().

bool MatcherUsingTracksAlgorithm::requireSameCharge_
private

Definition at line 129 of file MatcherUsingTracksAlgorithm.h.

Referenced by match().

SortBy MatcherUsingTracksAlgorithm::sortBy_
private
StringCutObjectSelector<reco::Candidate, true> MatcherUsingTracksAlgorithm::srcCut_
private

Definition at line 120 of file MatcherUsingTracksAlgorithm.h.

Referenced by match().

bool MatcherUsingTracksAlgorithm::useChi2_
private
WhichState MatcherUsingTracksAlgorithm::whichState1_
private

Definition at line 117 of file MatcherUsingTracksAlgorithm.h.

Referenced by match(), and MatcherUsingTracksAlgorithm().

WhichState MatcherUsingTracksAlgorithm::whichState2_
private

Definition at line 117 of file MatcherUsingTracksAlgorithm.h.

Referenced by match(), and MatcherUsingTracksAlgorithm().

WhichTrack MatcherUsingTracksAlgorithm::whichTrack1_
private

Definition at line 116 of file MatcherUsingTracksAlgorithm.h.

Referenced by match(), and MatcherUsingTracksAlgorithm().

WhichTrack MatcherUsingTracksAlgorithm::whichTrack2_
private

Definition at line 116 of file MatcherUsingTracksAlgorithm.h.

Referenced by match(), and MatcherUsingTracksAlgorithm().