CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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)
 
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::ESHandle< MagneticFieldmagfield_
 
StringCutObjectSelector
< reco::Candidate, true > 
matchedCut_
 
float maxChi2_
 
float maxGlobalDPtRel_
 
float maxGlobalMomDeltaEta_
 
float maxGlobalMomDeltaPhi_
 
float maxGlobalMomDeltaR_
 
float maxLocalPosDiff_
 
edm::ESHandle< Propagatorpropagator_
 
bool requireSameCharge_
 
SortBy sortBy_
 
StringCutObjectSelector
< reco::Candidate, true > 
srcCut_
 
bool useChi2_
 
WhichState whichState1_
 
WhichState whichState2_
 
WhichTrack whichTrack1_
 
WhichTrack whichTrack2_
 

Detailed Description

Definition at line 30 of file MatcherUsingTracksAlgorithm.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

MatcherUsingTracksAlgorithm::MatcherUsingTracksAlgorithm ( const edm::ParameterSet iConfig)
explicit

Definition at line 20 of file MatcherUsingTracksAlgorithm.cc.

References ecalcalib_dqm_sourceclient-live_cfg::algo, 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  :
23  srcCut_(iConfig.existsAs<std::string>("srcPreselection") ? iConfig.getParameter<std::string>("srcPreselection") : ""),
24  matchedCut_(iConfig.existsAs<std::string>("matchedPreselection") ? iConfig.getParameter<std::string>("matchedPreselection") : ""),
25  requireSameCharge_(iConfig.existsAs<bool>("requireSameCharge") ? iConfig.getParameter<bool>("requireSameCharge") : false)
26 {
27  std::string algo = iConfig.getParameter<std::string>("algorithm");
28  if (algo == "byTrackRef") { algo_ = ByTrackRef; }
29  else if (algo == "byPropagatingSrc") { algo_ = ByPropagatingSrc; }
30  else if (algo == "byPropagatingMatched") { algo_ = ByPropagatingMatched; }
31  else if (algo == "byDirectComparison") { algo_ = ByDirectComparison; }
32  else throw cms::Exception("Configuration") << "Value '" << algo << "' for algorithm not yet implemented.\n";
33 
34  getConf(iConfig, "src", whichTrack1_, whichState1_);
35  getConf(iConfig, "matched", whichTrack2_, whichState2_);
36 
37  if (algo_ == ByTrackRef) {
38  // validate the config
39  if (whichTrack1_ == None || whichTrack2_ == None) throw cms::Exception("Configuration") << "Algorithm 'byTrackRef' needs tracks not to be 'none'.\n";
41  // read matching cuts
42  maxLocalPosDiff_ = iConfig.getParameter<double>("maxDeltaLocalPos");
43  maxGlobalMomDeltaR_ = iConfig.getParameter<double>("maxDeltaR");
44  maxGlobalMomDeltaEta_ = iConfig.existsAs<double>("maxDeltaEta") ? iConfig.getParameter<double>("maxDeltaEta") : maxGlobalMomDeltaR_;
45  maxGlobalMomDeltaPhi_ = iConfig.existsAs<double>("maxDeltaPhi") ? iConfig.getParameter<double>("maxDeltaPhi") : maxGlobalMomDeltaR_;
46  maxGlobalDPtRel_ = iConfig.getParameter<double>("maxDeltaPtRel");
47 
48  // choice of sorting variable
49  std::string sortBy = iConfig.getParameter<std::string>("sortBy");
50  if (sortBy == "deltaLocalPos") sortBy_ = LocalPosDiff;
51  else if (sortBy == "deltaPtRel") sortBy_ = GlobalDPtRel;
52  else if (sortBy == "deltaR") sortBy_ = GlobalMomDeltaR;
53  else if (sortBy == "deltaEta") sortBy_ = GlobalMomDeltaEta;
54  else if (sortBy == "deltaPhi") sortBy_ = GlobalMomDeltaPhi;
55  else if (sortBy == "chi2") sortBy_ = Chi2;
56  else throw cms::Exception("Configuration") << "Parameter 'sortBy' must be one of: deltaLocalPos, deltaPtRel, deltaR, chi2.\n";
57  // validate the config
58  if (algo_ == ByPropagatingSrc) {
59  if (whichTrack2_ == None || whichState2_ == AtVertex) {
61  //throw cms::Exception("Configuration") << "Destination track must be non-null, and state must not be 'AtVertex' (not yet).\n";
62  }
63  } else if (algo_ == ByPropagatingMatched) {
64  if (whichTrack1_ == None || whichState1_ == AtVertex) {
66  //throw cms::Exception("Configuration") << "Destination track must be non-null, and state must not be 'AtVertex' (not yet).\n";
67  }
68  } else if (algo_ == ByDirectComparison) {
69  bool firstAtVertex = (whichTrack1_ == None || whichState1_ == AtVertex);
70  bool secAtVertex = (whichTrack2_ == None || whichState2_ == AtVertex);
71  if (firstAtVertex) {
72  if (!secAtVertex) throw cms::Exception("Configuration") << "When using 'byDirectComparison' with 'src' at vertex (or None), 'matched' must be at vertex too.\n";
73  } else {
74  if (secAtVertex) throw cms::Exception("Configuration") << "When using 'byDirectComparison' with 'src' not at vertex, 'matched' can't be at vertex or None.\n";
75  if (whichState1_ != whichState2_) throw cms::Exception("Configuration") << "You can't use 'byDirectComparison' with non-matching states.\n";
76  }
77  }
78 
79  useChi2_ = iConfig.existsAs<bool>("computeChi2") ? iConfig.getParameter<bool>("computeChi2") : false;
80  if (useChi2_) {
81  if (whichTrack1_ == None && whichTrack2_ == None) throw cms::Exception("Configuration") << "Can't compute chi2s if both tracks are set to 'none'.\n";
82  maxChi2_ = iConfig.getParameter<double>("maxChi2");
83  chi2DiagonalOnly_ = iConfig.getParameter<bool>("chi2DiagonalOnly");
85  chi2UseVertex_ = iConfig.getParameter<bool>("chi2UsePosition");
86  } else {
87  chi2UseVertex_ = iConfig.getParameter<bool>("chi2UseVertex");
88  if (algo_ == ByDirectComparison) {
89  std::string choice = iConfig.getParameter<std::string>("chi2MomentumForDxy");
90  if (choice == "src") chi2FirstMomentum_ = true;
91  else if (choice != "matched") throw cms::Exception("Configuration") << "chi2MomentumForDxy must be 'src' or 'matched'\n";
92  }
93  }
94  } else maxChi2_ = 1;
95 
96  if (sortBy_ == Chi2 && !useChi2_) throw cms::Exception("Configuration") << "Can't sort by chi2s if 'computeChi2s' is not set to true.\n";
97  }
98 }
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
void getConf(const edm::ParameterSet &iConfig, const std::string &whatFor, WhichTrack &whichTrack, WhichState &whichState)
Parse some configuration.
StringCutObjectSelector< reco::Candidate, true > srcCut_
StringCutObjectSelector< reco::Candidate, true > matchedCut_
Definition: Chi2.h:17
virtual MatcherUsingTracksAlgorithm::~MatcherUsingTracksAlgorithm ( )
inlinevirtual

Definition at line 33 of file MatcherUsingTracksAlgorithm.h.

33 { }

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 482 of file MatcherUsingTracksAlgorithm.cc.

References i, and j.

Referenced by getChi2().

482  {
483  if (!top3by3only) {
484  if (diagonalOnly) {
485  for (size_t i = 0; i < 5; ++i) { for (size_t j = i+1; j < 5; ++j) {
486  cov(i,j) = 0;
487  } }
488  }
489  cov.Invert();
490  } else {
491  // get 3x3 covariance
492  AlgebraicSymMatrix33 momCov = cov.Sub<AlgebraicSymMatrix33>(0,0); // get 3x3 matrix
493  if (diagonalOnly) { momCov(0,1) = 0; momCov(0,2) = 0; momCov(1,2) = 0; }
494  // invert
495  momCov.Invert();
496  // place it
497  cov.Place_at(momCov,0,0);
498  // zero the rest
499  for (size_t i = 3; i < 5; ++i) { for (size_t j = i; j < 5; ++j) {
500  cov(i,j) = 0;
501  } }
502  }
503 }
int i
Definition: DBlmapReader.cc:9
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
int j
Definition: DBlmapReader.cc:9
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 437 of file MatcherUsingTracksAlgorithm.cc.

References FreeTrajectoryState::charge(), cropAndInvert(), FreeTrajectoryState::curvilinearError(), mps_update::diff, FreeTrajectoryState::hasError(), PV3DBase< T, PVType, FrameType >::mag(), CurvilinearTrajectoryError::matrix(), FreeTrajectoryState::momentum(), AlCaHLTBitMon_ParallelJobs::p, p1, p2, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), FreeTrajectoryState::position(), EnergyCorrector::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().

437  {
438  if (!start.hasError() && !other.hasError()) throw cms::Exception("LogicError") << "At least one of the two states must have errors to make chi2s.\n";
440  if (start.hasError()) cov += start.curvilinearError().matrix();
441  if (other.hasError()) cov += other.curvilinearError().matrix();
442  cropAndInvert(cov, diagonalOnly, !useVertex);
443  GlobalVector p1 = start.momentum(), p2 = other.momentum();
444  GlobalPoint x1 = start.position(), x2 = other.position();
445  GlobalVector p = useFirstMomentum ? p1 : p2; double pt = p.perp(), pm = p.mag();
446  double dsz = (x1.z()-x2.z())*pt/pm - ( (x1.x()-x2.x())*p.x() + (x1.y()-x2.y())*p.y() ) / pt * p.z()/pm;
447  double dxy = ( -(x1.x()-x2.x())*p.y() + (x1.y()-x2.y())*p.x() )/pt;
448  AlgebraicVector5 diff(start.charge()/p1.mag()-other.charge()/p2.mag(),
449  p1.theta()-p2.theta(),
450  (p1.phi()-p2.phi()).value(),
451  dxy,
452  dsz);
453  return ROOT::Math::Similarity(diff, cov);
454 }
T perp() const
Definition: PV3DBase.h:72
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T y() const
Definition: PV3DBase.h:63
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
TrackCharge charge() const
list diff
Definition: mps_update.py:85
const CurvilinearTrajectoryError & curvilinearError() const
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
T mag() const
Definition: PV3DBase.h:67
T z() const
Definition: PV3DBase.h:64
double p2[4]
Definition: TauolaWrapper.h:90
GlobalVector momentum() const
GlobalPoint position() const
ROOT::Math::SVector< double, 5 > AlgebraicVector5
static void cropAndInvert(AlgebraicSymMatrix55 &cov, bool diagonalOnly, bool top3by3only)
Possibly crop the 3x3 part of the matrix or remove off-diagonal terms, then invert.
double p1[4]
Definition: TauolaWrapper.h:89
const AlgebraicSymMatrix55 & matrix() const
T x() const
Definition: PV3DBase.h:62
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 457 of file MatcherUsingTracksAlgorithm.cc.

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

457  {
458  if (!start.hasError() && !other.hasError()) throw cms::Exception("LogicError") << "At least one of the two states must have errors to make chi2s.\n";
459  double pt; // needed by pgconvert
462  if (other.hasError()) cov += other.perigeeError().covarianceMatrix();
463  cropAndInvert(cov, diagonalOnly, !useVertex);
465  AlgebraicVector5 pgpar2 = other.perigeeParameters().vector();
466  AlgebraicVector5 diff(pgpar1-pgpar2);
467  return ROOT::Math::Similarity(diff, cov);
468 }
const AlgebraicVector5 & vector() const
PerigeeTrajectoryParameters ftsToPerigeeParameters(const FTS &originalFTS, const GlobalPoint &referencePoint, double &pt)
const PerigeeTrajectoryError & perigeeError() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
list diff
Definition: mps_update.py:85
const PerigeeTrajectoryParameters & perigeeParameters() const
const AlgebraicSymMatrix55 & covarianceMatrix() const
ROOT::Math::SVector< double, 5 > AlgebraicVector5
const GlobalPoint & referencePoint() const
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 471 of file MatcherUsingTracksAlgorithm.cc.

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

471  {
472  if (!start.hasError() && !other.hasError()) throw cms::Exception("LogicError") << "At least one of the two states must have errors to make chi2s.\n";
474  if (start.hasError()) cov += start.localError().matrix();
475  if (other.hasError()) cov += other.localError().matrix();
476  cropAndInvert(cov, diagonalOnly, !usePosition);
478  return ROOT::Math::Similarity(diff, cov);
479 }
const LocalTrajectoryParameters & localParameters() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
list diff
Definition: mps_update.py:85
const AlgebraicSymMatrix55 & matrix() const
const LocalTrajectoryError & localError() const
ROOT::Math::SVector< double, 5 > AlgebraicVector5
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 101 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().

101  {
102  std::string s_whichTrack = iConfig.getParameter<std::string>(whatFor+"Track");
103  if (s_whichTrack == "none") { whichTrack = None; }
104  else if (s_whichTrack == "tracker") { whichTrack = TrackerTk; }
105  else if (s_whichTrack == "muon") { whichTrack = MuonTk; }
106  else if (s_whichTrack == "global") { whichTrack = GlobalTk; }
107  else throw cms::Exception("Configuration") << "Parameter 'useTrack' must be 'none', 'tracker', 'muon', 'global'\n";
108  if ((whichTrack != None) && (algo_ != ByTrackRef)) {
109  std::string s_whichState = iConfig.getParameter<std::string>(whatFor+"State");
110  if (s_whichState == "atVertex") { whichState = AtVertex; }
111  else if (s_whichState == "innermost") { whichState = Innermost; }
112  else if (s_whichState == "outermost") { whichState = Outermost; }
113  else throw cms::Exception("Configuration") << "Parameter 'useState' must be 'atVertex', 'innermost', 'outermost'\n";
114  }
115 }
T getParameter(std::string const &) const
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 235 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().

235  {
236  reco::TrackRef tk;
237  const reco::RecoCandidate *rc = dynamic_cast<const reco::RecoCandidate *>(&reco);
238  if (rc == 0) throw cms::Exception("Invalid Data") << "Input object is not a RecoCandidate.\n";
239  switch (whichTrack) {
240  case TrackerTk: tk = rc->track(); break;
241  case MuonTk : tk = rc->standAloneMuon(); break;
242  case GlobalTk : tk = rc->combinedMuon(); break;
243  default: break; // just to make gcc happy
244  }
245  return tk;
246 }
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 51 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 48 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 227 of file MatcherUsingTracksAlgorithm.cc.

References geometry_, edm::EventSetup::get(), magfield_, and propagator_.

227  {
228  iSetup.get<IdealMagneticFieldRecord>().get(magfield_);
229  iSetup.get<TrackingComponentsRecord>().get("SteppingHelixPropagatorAny", propagator_);
231 }
edm::ESHandle< GlobalTrackingGeometry > geometry_
edm::ESHandle< MagneticField > magfield_
edm::ESHandle< Propagator > propagator_
const T & get() const
Definition: EventSetup.h:56
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 120 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_, dqm_diff::start, startingState(), reco::t2, filterCSVwithJSON::target, targetState(), whichState1_, whichState2_, whichTrack1_, and whichTrack2_.

Referenced by match().

120  {
121  if (!(srcCut_(c1) && matchedCut_(c2))) return false;
122  if (requireSameCharge_ && (c1.charge() != c2.charge())) return false;
123  switch (algo_) {
124  case ByTrackRef: {
127  if (t1.isNonnull()) {
128  if (t1 == t2) return true;
129  if (t1.id() != t2.id()) { edm::LogWarning("MatcherUsingTracksAlgorithm") << "Trying to match by reference tracks coming from different collections.\n"; }
130  }
131  }
132  case ByPropagatingSrc: {
135  return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
136  }
137  case ByPropagatingMatched: {
140  return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
141  }
142  case ByPropagatingSrcTSCP: {
145  return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
146  }
147  case ByPropagatingMatchedTSCP: {
150  return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
151  }
152 
153  case ByDirectComparison: {
156  return matchByDirectComparison(start, otherstart, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
157  }
158  }
159  return false;
160 }
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
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:258
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:16
virtual int charge() const =0
electric charge
TrajectoryStateOnSurface targetState(const reco::Candidate &reco, WhichTrack whichTrack, WhichState whichState) const
End state for the propagation.
StringCutObjectSelector< reco::Candidate, true > srcCut_
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)
StringCutObjectSelector< reco::Candidate, true > matchedCut_
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 166 of file MatcherUsingTracksAlgorithm.cc.

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

166  {
167  if (!srcCut_(c1)) return -1;
168 
169  // working and output variables
171  int match = -1;
172 
173  // pre-fetch some states if needed
176  } else if (algo_ == ByPropagatingMatched) target = targetState(c1, whichTrack1_, whichState1_);
177 
178  // loop on the collection
180  for (it = c2s.begin(), ed = c2s.end(), i = 0; it != ed; ++it, ++i) {
181  if (!matchedCut_(*it)) continue;
182  if (requireSameCharge_ && (c1.charge() != it->charge()) ) continue;
183  bool exit = false;
184  switch (algo_) {
185  case ByTrackRef: {
188  if (t1.isNonnull()) {
189  if (t1 == t2) { match = i; exit = true; }
190  if (t1.id() != t2.id()) { edm::LogWarning("MatcherUsingTracksAlgorithm") << "Trying to match by reference tracks coming from different collections.\n"; }
191  }
192  } break;
193  case ByPropagatingSrc:
194  case ByPropagatingMatched: {
196  else if (algo_ == ByPropagatingSrc) target = targetState(*it, whichTrack2_, whichState2_);
197  if (matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
198  match = i;
199  }
200  } break;
201  case ByDirectComparison: {
203  if (matchByDirectComparison(start, otherstart, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
204  match = i;
205  }
206  } break;
207  case ByPropagatingSrcTSCP: {
209  if (matchWithPropagation(start, otherstart, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
210  match = i;
211  }
212  } break;
215  if (matchWithPropagation(otherstart, start, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
216  match = i;
217  }
218  } break;
219  }
220  if (exit) break;
221  }
222 
223  return match;
224 }
int i
Definition: DBlmapReader.cc:9
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
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:258
const_iterator begin() const
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:16
virtual int charge() const =0
electric charge
TrajectoryStateOnSurface targetState(const reco::Candidate &reco, WhichTrack whichTrack, WhichState whichState) const
End state for the propagation.
StringCutObjectSelector< reco::Candidate, true > srcCut_
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:81
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)
StringCutObjectSelector< reco::Candidate, true > matchedCut_
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 390 of file MatcherUsingTracksAlgorithm.cc.

References PV3DBase< T, PVType, FrameType >::barePhi(), chi2DiagonalOnly_, chi2FirstMomentum_, chi2UseVertex_, SiPixelRawToDigiRegional_cfi::deltaPhi, 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().

398 {
399  if ((start.momentum().mag() == 0) || target.momentum().mag() == 0) return false;
400 
401  bool isBest = false;
402  float thisLocalPosDiff = (start.position()-target.position()).mag();
403  float thisGlobalMomDeltaR = deltaR(start.momentum(), target.momentum());
404  float thisGlobalMomDeltaPhi = fabs(deltaPhi(start.momentum().barePhi(), target.momentum().barePhi()));
405  float thisGlobalMomDeltaEta = fabs(start.momentum().eta() - target.momentum().eta());
406  float thisGlobalDPtRel = (start.momentum().perp() - target.momentum().perp())/target.momentum().perp();
407 
408  if ((thisLocalPosDiff < maxLocalPosDiff_) &&
409  (thisGlobalMomDeltaR < maxGlobalMomDeltaR_) &&
410  (thisGlobalMomDeltaEta < maxGlobalMomDeltaEta_) &&
411  (thisGlobalMomDeltaPhi < maxGlobalMomDeltaPhi_) &&
412  (fabs(thisGlobalDPtRel) < maxGlobalDPtRel_)) {
413  float thisChi2 = useChi2_ ? getChi2(start, target, chi2DiagonalOnly_, chi2UseVertex_, chi2FirstMomentum_) : 0;
414  if (thisChi2 >= maxChi2_) return false;
415  switch (sortBy_) {
416  case LocalPosDiff: isBest = (thisLocalPosDiff < lastDeltaLocalPos); break;
417  case GlobalMomDeltaR: isBest = (thisGlobalMomDeltaR < lastDeltaR); break;
418  case GlobalMomDeltaEta: isBest = (thisGlobalMomDeltaEta < lastDeltaEta); break;
419  case GlobalMomDeltaPhi: isBest = (thisGlobalMomDeltaPhi < lastDeltaPhi); break;
420  case GlobalDPtRel: isBest = (thisGlobalDPtRel < lastGlobalDPtRel); break;
421  case Chi2: isBest = (thisChi2 < lastChi2); break;
422  }
423  if (isBest) {
424  lastDeltaLocalPos = thisLocalPosDiff;
425  lastDeltaR = thisGlobalMomDeltaR;
426  lastDeltaEta = thisGlobalMomDeltaEta;
427  lastDeltaPhi = thisGlobalMomDeltaPhi;
428  lastGlobalDPtRel = thisGlobalDPtRel;
429  lastChi2 = thisChi2;
430  }
431  } // if match
432 
433  return isBest;
434 }
T perp() const
Definition: PV3DBase.h:72
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:68
T mag() const
Definition: PV3DBase.h:67
GlobalVector momentum() const
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
GlobalPoint position() const
T eta() const
Definition: PV3DBase.h:76
Definition: Chi2.h:17
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 337 of file MatcherUsingTracksAlgorithm.cc.

References PV3DBase< T, PVType, FrameType >::barePhi(), chi2DiagonalOnly_, chi2UseVertex_, SiPixelRawToDigiRegional_cfi::deltaPhi, 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(), TrajectoryStateClosestToPoint::momentum(), PV3DBase< T, PVType, FrameType >::perp(), FreeTrajectoryState::position(), TrajectoryStateClosestToPoint::position(), HLT_25ns10e33_v2_cff::propagator, sortBy_, and useChi2_.

Referenced by match().

345 {
346  if ((start.momentum().mag() == 0) || (target.momentum().mag() == 0)) return false;
348  /*2.2.X*/ try {
349  TrajectoryStateClosestToPoint tscp = propagator(start, target.position());
350  // if (!tscp.isValid()) return false; // in 3.1.X
351 
352  bool isBest = false;
353  float thisLocalPosDiff = (tscp.position()-target.position()).mag();
354  float thisGlobalMomDeltaR = deltaR(tscp.momentum(), target.momentum());
355  float thisGlobalMomDeltaPhi = fabs(deltaPhi(tscp.momentum().barePhi(), target.momentum().barePhi()));
356  float thisGlobalMomDeltaEta = fabs(tscp.momentum().eta() - target.momentum().eta());
357  float thisGlobalDPtRel = (tscp.momentum().perp() - target.momentum().perp())/target.momentum().perp();
358 
359  if ((thisLocalPosDiff < maxLocalPosDiff_) &&
360  (thisGlobalMomDeltaR < maxGlobalMomDeltaR_) &&
361  (thisGlobalMomDeltaEta < maxGlobalMomDeltaEta_) &&
362  (thisGlobalMomDeltaPhi < maxGlobalMomDeltaPhi_) &&
363  (fabs(thisGlobalDPtRel) < maxGlobalDPtRel_)) {
364  float thisChi2 = useChi2_ ? getChi2(target, tscp, chi2DiagonalOnly_, chi2UseVertex_) : 0;
365  if (thisChi2 >= maxChi2_) return false;
366  switch (sortBy_) {
367  case LocalPosDiff: isBest = (thisLocalPosDiff < lastDeltaLocalPos); break;
368  case GlobalMomDeltaR: isBest = (thisGlobalMomDeltaR < lastDeltaR); break;
369  case GlobalMomDeltaEta: isBest = (thisGlobalMomDeltaEta < lastDeltaEta); break;
370  case GlobalMomDeltaPhi: isBest = (thisGlobalMomDeltaPhi < lastDeltaPhi); break;
371  case GlobalDPtRel: isBest = (thisGlobalDPtRel < lastGlobalDPtRel); break;
372  case Chi2: isBest = (thisChi2 < lastChi2); break;
373  }
374  if (isBest) {
375  lastDeltaLocalPos = thisLocalPosDiff;
376  lastDeltaR = thisGlobalMomDeltaR;
377  lastDeltaEta = thisGlobalMomDeltaEta;
378  lastDeltaPhi = thisGlobalMomDeltaPhi;
379  lastGlobalDPtRel = thisGlobalDPtRel;
380  lastChi2 = thisChi2;
381  }
382  } // if match
383 
384  return isBest;
385  /*2.2.X*/ } catch (const TrajectoryStateException &err) { return false; }
386 }
T perp() const
Definition: PV3DBase.h:72
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:68
T mag() const
Definition: PV3DBase.h:67
GlobalVector momentum() const
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
GlobalPoint position() const
T eta() const
Definition: PV3DBase.h:76
Definition: Chi2.h:17
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 286 of file MatcherUsingTracksAlgorithm.cc.

References PV3DBase< T, PVType, FrameType >::barePhi(), chi2DiagonalOnly_, chi2UseVertex_, SiPixelRawToDigiRegional_cfi::deltaPhi, 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_.

294 {
295  if ((start.momentum().mag() == 0) || !target.isValid()) return false;
296 
297  TrajectoryStateOnSurface tsos = propagator_->propagate(start, target.surface());
298 
299  bool isBest = false;
300  if (tsos.isValid()) {
301  float thisLocalPosDiff = (tsos.localPosition()-target.localPosition()).mag();
302  float thisGlobalMomDeltaR = deltaR(tsos.globalMomentum(), target.globalMomentum());
303  float thisGlobalMomDeltaPhi = fabs(deltaPhi(tsos.globalMomentum().barePhi(), target.globalMomentum().barePhi()));
304  float thisGlobalMomDeltaEta = fabs(tsos.globalMomentum().eta() - target.globalMomentum().eta());
305  float thisGlobalDPtRel = (tsos.globalMomentum().perp() - target.globalMomentum().perp())/target.globalMomentum().perp();
306 
307  if ((thisLocalPosDiff < maxLocalPosDiff_) &&
308  (thisGlobalMomDeltaR < maxGlobalMomDeltaR_) &&
309  (thisGlobalMomDeltaEta < maxGlobalMomDeltaEta_) &&
310  (thisGlobalMomDeltaPhi < maxGlobalMomDeltaPhi_) &&
311  (fabs(thisGlobalDPtRel) < maxGlobalDPtRel_)) {
312  float thisChi2 = useChi2_ ? getChi2(target, tsos, chi2DiagonalOnly_, chi2UseVertex_) : 0;
313  if (thisChi2 >= maxChi2_) return false;
314  switch (sortBy_) {
315  case LocalPosDiff: isBest = (thisLocalPosDiff < lastDeltaLocalPos); break;
316  case GlobalMomDeltaR: isBest = (thisGlobalMomDeltaR < lastDeltaR); break;
317  case GlobalMomDeltaEta: isBest = (thisGlobalMomDeltaEta < lastDeltaEta); break;
318  case GlobalMomDeltaPhi: isBest = (thisGlobalMomDeltaPhi < lastDeltaPhi); break;
319  case GlobalDPtRel: isBest = (thisGlobalDPtRel < lastGlobalDPtRel); break;
320  case Chi2: isBest = (thisChi2 < lastChi2); break;
321  }
322  if (isBest) {
323  lastDeltaLocalPos = thisLocalPosDiff;
324  lastDeltaR = thisGlobalMomDeltaR;
325  lastDeltaEta = thisGlobalMomDeltaEta;
326  lastDeltaPhi = thisGlobalMomDeltaPhi;
327  lastGlobalDPtRel = thisGlobalDPtRel;
328  lastChi2 = thisChi2;
329  }
330  } // if match
331  }
332 
333  return isBest;
334 }
T perp() const
Definition: PV3DBase.h:72
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:68
const SurfaceType & surface() const
T mag() const
Definition: PV3DBase.h:67
GlobalVector momentum() const
edm::ESHandle< Propagator > propagator_
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
T eta() const
Definition: PV3DBase.h:76
GlobalVector globalMomentum() const
Definition: Chi2.h:17
FreeTrajectoryState MatcherUsingTracksAlgorithm::startingState ( const reco::Candidate reco,
WhichTrack  whichTrack,
WhichState  whichState 
) const
private

Starting state for the propagation.

Definition at line 249 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().

249  {
251  if (whichTrack != None) {
252  reco::TrackRef tk = getTrack(reco, whichTrack);
253  if (tk.isNull()) {
254  ret = FreeTrajectoryState();
255  } else {
256  switch (whichState) {
260  }
261  }
262  } else {
263  ret = FreeTrajectoryState( GlobalPoint( reco.vx(), reco.vy(), reco.vz()),
264  GlobalVector(reco.px(), reco.py(), reco.pz()),
265  reco.charge(),
266  magfield_.product());
267  }
268  return ret;
269 }
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:249
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 272 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().

272  {
274  reco::TrackRef tk = getTrack(reco, whichTrack);
275  if (tk.isNonnull()) {
276  switch (whichState) {
279  default: break; // just to make gcc happy
280  }
281  }
282  return ret;
283 }
tuple ret
prodAgent to be discontinued
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
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 104 of file MatcherUsingTracksAlgorithm.h.

Referenced by init(), and targetState().

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

Definition at line 102 of file MatcherUsingTracksAlgorithm.h.

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

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

Definition at line 86 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 103 of file MatcherUsingTracksAlgorithm.h.

Referenced by init(), and matchWithPropagation().

bool MatcherUsingTracksAlgorithm::requireSameCharge_
private

Definition at line 95 of file MatcherUsingTracksAlgorithm.h.

Referenced by match().

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

Definition at line 86 of file MatcherUsingTracksAlgorithm.h.

Referenced by match().

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

Definition at line 83 of file MatcherUsingTracksAlgorithm.h.

Referenced by match(), and MatcherUsingTracksAlgorithm().

WhichState MatcherUsingTracksAlgorithm::whichState2_
private

Definition at line 83 of file MatcherUsingTracksAlgorithm.h.

Referenced by match(), and MatcherUsingTracksAlgorithm().

WhichTrack MatcherUsingTracksAlgorithm::whichTrack1_
private

Definition at line 82 of file MatcherUsingTracksAlgorithm.h.

Referenced by match(), and MatcherUsingTracksAlgorithm().

WhichTrack MatcherUsingTracksAlgorithm::whichTrack2_
private

Definition at line 82 of file MatcherUsingTracksAlgorithm.h.

Referenced by match(), and MatcherUsingTracksAlgorithm().