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 31 of file MatcherUsingTracksAlgorithm.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

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

Definition at line 31 of file MatcherUsingTracksAlgorithm.cc.

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

31  :
34  srcCut_(iConfig.existsAs<std::string>("srcPreselection") ? iConfig.getParameter<std::string>("srcPreselection") : ""),
35  matchedCut_(iConfig.existsAs<std::string>("matchedPreselection") ? iConfig.getParameter<std::string>("matchedPreselection") : ""),
36  requireSameCharge_(iConfig.existsAs<bool>("requireSameCharge") ? iConfig.getParameter<bool>("requireSameCharge") : false)
37 {
38  std::string algo = iConfig.getParameter<std::string>("algorithm");
39  if (algo == "byTrackRef") { algo_ = ByTrackRef; }
40  else if (algo == "byPropagatingSrc") { algo_ = ByPropagatingSrc; }
41  else if (algo == "byPropagatingMatched") { algo_ = ByPropagatingMatched; }
42  else if (algo == "byDirectComparison") { algo_ = ByDirectComparison; }
43  else throw cms::Exception("Configuration") << "Value '" << algo << "' for algorithm not yet implemented.\n";
44 
45  getConf(iConfig, "src", whichTrack1_, whichState1_);
46  getConf(iConfig, "matched", whichTrack2_, whichState2_);
47 
48  if (algo_ == ByTrackRef) {
49  // validate the config
50  if (whichTrack1_ == None || whichTrack2_ == None) throw cms::Exception("Configuration") << "Algorithm 'byTrackRef' needs tracks not to be 'none'.\n";
52  // read matching cuts
53  maxLocalPosDiff_ = iConfig.getParameter<double>("maxDeltaLocalPos");
54  maxGlobalMomDeltaR_ = iConfig.getParameter<double>("maxDeltaR");
55  maxGlobalMomDeltaEta_ = iConfig.existsAs<double>("maxDeltaEta") ? iConfig.getParameter<double>("maxDeltaEta") : maxGlobalMomDeltaR_;
56  maxGlobalMomDeltaPhi_ = iConfig.existsAs<double>("maxDeltaPhi") ? iConfig.getParameter<double>("maxDeltaPhi") : maxGlobalMomDeltaR_;
57  maxGlobalDPtRel_ = iConfig.getParameter<double>("maxDeltaPtRel");
58 
59  // choice of sorting variable
60  std::string sortBy = iConfig.getParameter<std::string>("sortBy");
61  if (sortBy == "deltaLocalPos") sortBy_ = LocalPosDiff;
62  else if (sortBy == "deltaPtRel") sortBy_ = GlobalDPtRel;
63  else if (sortBy == "deltaR") sortBy_ = GlobalMomDeltaR;
64  else if (sortBy == "deltaEta") sortBy_ = GlobalMomDeltaEta;
65  else if (sortBy == "deltaPhi") sortBy_ = GlobalMomDeltaPhi;
66  else if (sortBy == "chi2") sortBy_ = Chi2;
67  else throw cms::Exception("Configuration") << "Parameter 'sortBy' must be one of: deltaLocalPos, deltaPtRel, deltaR, chi2.\n";
68  // validate the config
69  if (algo_ == ByPropagatingSrc) {
70  if (whichTrack2_ == None || whichState2_ == AtVertex) {
72  //throw cms::Exception("Configuration") << "Destination track must be non-null, and state must not be 'AtVertex' (not yet).\n";
73  }
74  } else if (algo_ == ByPropagatingMatched) {
75  if (whichTrack1_ == None || whichState1_ == AtVertex) {
77  //throw cms::Exception("Configuration") << "Destination track must be non-null, and state must not be 'AtVertex' (not yet).\n";
78  }
79  } else if (algo_ == ByDirectComparison) {
80  bool firstAtVertex = (whichTrack1_ == None || whichState1_ == AtVertex);
81  bool secAtVertex = (whichTrack2_ == None || whichState2_ == AtVertex);
82  if (firstAtVertex) {
83  if (!secAtVertex) throw cms::Exception("Configuration") << "When using 'byDirectComparison' with 'src' at vertex (or None), 'matched' must be at vertex too.\n";
84  } else {
85  if (secAtVertex) throw cms::Exception("Configuration") << "When using 'byDirectComparison' with 'src' not at vertex, 'matched' can't be at vertex or None.\n";
86  if (whichState1_ != whichState2_) throw cms::Exception("Configuration") << "You can't use 'byDirectComparison' with non-matching states.\n";
87  }
88  }
89 
90  useChi2_ = iConfig.existsAs<bool>("computeChi2") ? iConfig.getParameter<bool>("computeChi2") : false;
91  if (useChi2_) {
92  if (whichTrack1_ == None && whichTrack2_ == None) throw cms::Exception("Configuration") << "Can't compute chi2s if both tracks are set to 'none'.\n";
93  maxChi2_ = iConfig.getParameter<double>("maxChi2");
94  chi2DiagonalOnly_ = iConfig.getParameter<bool>("chi2DiagonalOnly");
96  chi2UseVertex_ = iConfig.getParameter<bool>("chi2UsePosition");
97  } else {
98  chi2UseVertex_ = iConfig.getParameter<bool>("chi2UseVertex");
99  if (algo_ == ByDirectComparison) {
100  std::string choice = iConfig.getParameter<std::string>("chi2MomentumForDxy");
101  if (choice == "src") chi2FirstMomentum_ = true;
102  else if (choice != "matched") throw cms::Exception("Configuration") << "chi2MomentumForDxy must be 'src' or 'matched'\n";
103  }
104  }
105  } else maxChi2_ = 1;
106 
107  if (sortBy_ == Chi2 && !useChi2_) throw cms::Exception("Configuration") << "Can't sort by chi2s if 'computeChi2s' is not set to true.\n";
108  }
109 }
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:187
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_
LimitAlgo * algo
Definition: Combine.cc:60
Definition: Chi2.h:17
virtual MatcherUsingTracksAlgorithm::~MatcherUsingTracksAlgorithm ( )
inlinevirtual

Definition at line 34 of file MatcherUsingTracksAlgorithm.h.

34 { }

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

References i, and j.

Referenced by getChi2().

493  {
494  if (!top3by3only) {
495  if (diagonalOnly) {
496  for (size_t i = 0; i < 5; ++i) { for (size_t j = i+1; j < 5; ++j) {
497  cov(i,j) = 0;
498  } }
499  }
500  cov.Invert();
501  } else {
502  // get 3x3 covariance
503  AlgebraicSymMatrix33 momCov = cov.Sub<AlgebraicSymMatrix33>(0,0); // get 3x3 matrix
504  if (diagonalOnly) { momCov(0,1) = 0; momCov(0,2) = 0; momCov(1,2) = 0; }
505  // invert
506  momCov.Invert();
507  // place it
508  cov.Place_at(momCov,0,0);
509  // zero the rest
510  for (size_t i = 3; i < 5; ++i) { for (size_t j = i; j < 5; ++j) {
511  cov(i,j) = 0;
512  } }
513  }
514 }
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 448 of file MatcherUsingTracksAlgorithm.cc.

References FreeTrajectoryState::charge(), cropAndInvert(), FreeTrajectoryState::curvilinearError(), diffTreeTool::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(), 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().

448  {
449  if (!start.hasError() && !other.hasError()) throw cms::Exception("LogicError") << "At least one of the two states must have errors to make chi2s.\n";
451  if (start.hasError()) cov += start.curvilinearError().matrix();
452  if (other.hasError()) cov += other.curvilinearError().matrix();
453  cropAndInvert(cov, diagonalOnly, !useVertex);
454  GlobalVector p1 = start.momentum(), p2 = other.momentum();
455  GlobalPoint x1 = start.position(), x2 = other.position();
456  GlobalVector p = useFirstMomentum ? p1 : p2; double pt = p.perp(), pm = p.mag();
457  double dsz = (x1.z()-x2.z())*pt/pm - ( (x1.x()-x2.x())*p.x() + (x1.y()-x2.y())*p.y() ) / pt * p.z()/pm;
458  double dxy = ( -(x1.x()-x2.x())*p.y() + (x1.y()-x2.y())*p.x() )/pt;
459  AlgebraicVector5 diff(start.charge()/p1.mag()-other.charge()/p2.mag(),
460  p1.theta()-p2.theta(),
461  (p1.phi()-p2.phi()).value(),
462  dxy,
463  dsz);
464  return ROOT::Math::Similarity(diff, cov);
465 }
T perp() const
Definition: PV3DBase.h:71
Geom::Phi< T > phi() const
Definition: PV3DBase.h:68
T y() const
Definition: PV3DBase.h:62
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
TrackCharge charge() const
const CurvilinearTrajectoryError & curvilinearError() const
Geom::Theta< T > theta() const
Definition: PV3DBase.h:74
T mag() const
Definition: PV3DBase.h:66
T z() const
Definition: PV3DBase.h:63
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:61
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 468 of file MatcherUsingTracksAlgorithm.cc.

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

468  {
469  if (!start.hasError() && !other.hasError()) throw cms::Exception("LogicError") << "At least one of the two states must have errors to make chi2s.\n";
470  PerigeeConversions pgconvert; double pt; // needed by pgconvert
472  if (start.hasError()) cov += pgconvert.ftsToPerigeeError(start).covarianceMatrix();
473  if (other.hasError()) cov += other.perigeeError().covarianceMatrix();
474  cropAndInvert(cov, diagonalOnly, !useVertex);
475  AlgebraicVector5 pgpar1 = pgconvert.ftsToPerigeeParameters(start,other.referencePoint(),pt).vector();
476  AlgebraicVector5 pgpar2 = other.perigeeParameters().vector();
477  AlgebraicVector5 diff(pgpar1-pgpar2);
478  return ROOT::Math::Similarity(diff, cov);
479 }
const AlgebraicVector5 & vector() const
const PerigeeTrajectoryError & perigeeError() const
PerigeeTrajectoryParameters ftsToPerigeeParameters(const FTS &originalFTS, const GlobalPoint &referencePoint, double &pt) const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
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) const
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 482 of file MatcherUsingTracksAlgorithm.cc.

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

482  {
483  if (!start.hasError() && !other.hasError()) throw cms::Exception("LogicError") << "At least one of the two states must have errors to make chi2s.\n";
485  if (start.hasError()) cov += start.localError().matrix();
486  if (other.hasError()) cov += other.localError().matrix();
487  cropAndInvert(cov, diagonalOnly, !usePosition);
489  return ROOT::Math::Similarity(diff, cov);
490 }
const LocalTrajectoryParameters & localParameters() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
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 112 of file MatcherUsingTracksAlgorithm.cc.

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

Referenced by MatcherUsingTracksAlgorithm().

112  {
113  std::string s_whichTrack = iConfig.getParameter<std::string>(whatFor+"Track");
114  if (s_whichTrack == "none") { whichTrack = None; }
115  else if (s_whichTrack == "tracker") { whichTrack = TrackerTk; }
116  else if (s_whichTrack == "muon") { whichTrack = MuonTk; }
117  else if (s_whichTrack == "global") { whichTrack = GlobalTk; }
118  else throw cms::Exception("Configuration") << "Parameter 'useTrack' must be 'none', 'tracker', 'muon', 'global'\n";
119  if ((whichTrack != None) && (algo_ != ByTrackRef)) {
120  std::string s_whichState = iConfig.getParameter<std::string>(whatFor+"State");
121  if (s_whichState == "atVertex") { whichState = AtVertex; }
122  else if (s_whichState == "innermost") { whichState = Innermost; }
123  else if (s_whichState == "outermost") { whichState = Outermost; }
124  else throw cms::Exception("Configuration") << "Parameter 'useState' must be 'atVertex', 'innermost', 'outermost'\n";
125  }
126 }
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 246 of file MatcherUsingTracksAlgorithm.cc.

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

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

246  {
247  reco::TrackRef tk;
248  const reco::RecoCandidate *rc = dynamic_cast<const reco::RecoCandidate *>(&reco);
249  if (rc == 0) throw cms::Exception("Invalid Data") << "Input object is not a RecoCandidate.\n";
250  switch (whichTrack) {
251  case TrackerTk: tk = rc->track(); break;
252  case MuonTk : tk = rc->standAloneMuon(); break;
253  case GlobalTk : tk = rc->combinedMuon(); break;
254  default: break; // just to make gcc happy
255  }
256  return tk;
257 }
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 52 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 49 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 238 of file MatcherUsingTracksAlgorithm.cc.

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

238  {
239  iSetup.get<IdealMagneticFieldRecord>().get(magfield_);
240  iSetup.get<TrackingComponentsRecord>().get("SteppingHelixPropagatorAny", propagator_);
242 }
edm::ESHandle< GlobalTrackingGeometry > geometry_
edm::ESHandle< MagneticField > magfield_
edm::ESHandle< Propagator > propagator_
const T & get() const
Definition: EventSetup.h:55
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 131 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_, errorMatrix2Lands_multiChannel::start, startingState(), filterCSVwithJSON::target, targetState(), whichState1_, whichState2_, whichTrack1_, and whichTrack2_.

Referenced by match().

131  {
132  if (!(srcCut_(c1) && matchedCut_(c2))) return false;
133  if (requireSameCharge_ && (c1.charge() != c2.charge())) return false;
134  switch (algo_) {
135  case ByTrackRef: {
138  if (t1.isNonnull()) {
139  if (t1 == t2) return true;
140  if (t1.id() != t2.id()) { edm::LogWarning("MatcherUsingTracksAlgorithm") << "Trying to match by reference tracks coming from different collections.\n"; }
141  }
142  }
143  case ByPropagatingSrc: {
146  return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
147  }
148  case ByPropagatingMatched: {
151  return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
152  }
153  case ByPropagatingSrcTSCP: {
156  return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
157  }
158  case ByPropagatingMatchedTSCP: {
161  return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
162  }
163 
164  case ByDirectComparison: {
167  return matchByDirectComparison(start, otherstart, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
168  }
169  }
170  return false;
171 }
bool matchWithPropagation(const FreeTrajectoryState &start, const FreeTrajectoryState &target, float &lastDeltaR, float &lastDeltaEta, float &lastDeltaPhi, float &lastDeltaLocalPos, float &lastGlobalDPtRel, float &lastChi2) const
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
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.
ProductID id() const
Accessor for product ID.
Definition: Ref.h:256
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 177 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_, errorMatrix2Lands_multiChannel::start, startingState(), filterCSVwithJSON::target, targetState(), whichState1_, whichState2_, whichTrack1_, and whichTrack2_.

177  {
178  if (!srcCut_(c1)) return -1;
179 
180  // working and output variables
182  int match = -1;
183 
184  // pre-fetch some states if needed
187  } else if (algo_ == ByPropagatingMatched) target = targetState(c1, whichTrack1_, whichState1_);
188 
189  // loop on the collection
191  for (it = c2s.begin(), ed = c2s.end(), i = 0; it != ed; ++it, ++i) {
192  if (!matchedCut_(*it)) continue;
193  if (requireSameCharge_ && (c1.charge() != it->charge()) ) continue;
194  bool exit = false;
195  switch (algo_) {
196  case ByTrackRef: {
199  if (t1.isNonnull()) {
200  if (t1 == t2) { match = i; exit = true; }
201  if (t1.id() != t2.id()) { edm::LogWarning("MatcherUsingTracksAlgorithm") << "Trying to match by reference tracks coming from different collections.\n"; }
202  }
203  } break;
204  case ByPropagatingSrc:
205  case ByPropagatingMatched: {
207  else if (algo_ == ByPropagatingSrc) target = targetState(*it, whichTrack2_, whichState2_);
208  if (matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
209  match = i;
210  }
211  } break;
212  case ByDirectComparison: {
214  if (matchByDirectComparison(start, otherstart, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
215  match = i;
216  }
217  } break;
218  case ByPropagatingSrcTSCP: {
220  if (matchWithPropagation(start, otherstart, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
221  match = i;
222  }
223  } break;
226  if (matchWithPropagation(otherstart, start, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
227  match = i;
228  }
229  } break;
230  }
231  if (exit) break;
232  }
233 
234  return match;
235 }
int i
Definition: DBlmapReader.cc:9
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
bool matchWithPropagation(const FreeTrajectoryState &start, const FreeTrajectoryState &target, float &lastDeltaR, float &lastDeltaEta, float &lastDeltaPhi, float &lastDeltaLocalPos, float &lastGlobalDPtRel, float &lastChi2) const
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
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.
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 begin() const
const_iterator end() const
ProductID id() const
Accessor for product ID.
Definition: Ref.h:256
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 401 of file MatcherUsingTracksAlgorithm.cc.

References 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(), PV3DBase< T, PVType, FrameType >::phi(), FreeTrajectoryState::position(), sortBy_, and useChi2_.

Referenced by match().

409 {
410  if ((start.momentum().mag() == 0) || target.momentum().mag() == 0) return false;
411 
412  bool isBest = false;
413  float thisLocalPosDiff = (start.position()-target.position()).mag();
414  float thisGlobalMomDeltaR = deltaR(start.momentum(), target.momentum());
415  float thisGlobalMomDeltaPhi = fabs(deltaPhi(start.momentum().phi(), target.momentum().phi()));
416  float thisGlobalMomDeltaEta = fabs(start.momentum().eta() - target.momentum().eta());
417  float thisGlobalDPtRel = (start.momentum().perp() - target.momentum().perp())/target.momentum().perp();
418 
419  if ((thisLocalPosDiff < maxLocalPosDiff_) &&
420  (thisGlobalMomDeltaR < maxGlobalMomDeltaR_) &&
421  (thisGlobalMomDeltaEta < maxGlobalMomDeltaEta_) &&
422  (thisGlobalMomDeltaPhi < maxGlobalMomDeltaPhi_) &&
423  (fabs(thisGlobalDPtRel) < maxGlobalDPtRel_)) {
424  float thisChi2 = useChi2_ ? getChi2(start, target, chi2DiagonalOnly_, chi2UseVertex_, chi2FirstMomentum_) : 0;
425  if (thisChi2 >= maxChi2_) return false;
426  switch (sortBy_) {
427  case LocalPosDiff: isBest = (thisLocalPosDiff < lastDeltaLocalPos); break;
428  case GlobalMomDeltaR: isBest = (thisGlobalMomDeltaR < lastDeltaR); break;
429  case GlobalMomDeltaEta: isBest = (thisGlobalMomDeltaEta < lastDeltaEta); break;
430  case GlobalMomDeltaPhi: isBest = (thisGlobalMomDeltaPhi < lastDeltaPhi); break;
431  case GlobalDPtRel: isBest = (thisGlobalDPtRel < lastGlobalDPtRel); break;
432  case Chi2: isBest = (thisChi2 < lastChi2); break;
433  }
434  if (isBest) {
435  lastDeltaLocalPos = thisLocalPosDiff;
436  lastDeltaR = thisGlobalMomDeltaR;
437  lastDeltaEta = thisGlobalMomDeltaEta;
438  lastDeltaPhi = thisGlobalMomDeltaPhi;
439  lastGlobalDPtRel = thisGlobalDPtRel;
440  lastChi2 = thisChi2;
441  }
442  } // if match
443 
444  return isBest;
445 }
T perp() const
Definition: PV3DBase.h:71
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Geom::Phi< T > phi() const
Definition: PV3DBase.h:68
static double getChi2(const FreeTrajectoryState &start, const FreeTrajectoryState &other, bool diagonalOnly, bool useVertex, bool useFirstMomentum)
T mag() const
Definition: PV3DBase.h:66
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:75
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 348 of file MatcherUsingTracksAlgorithm.cc.

References 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(), PV3DBase< T, PVType, FrameType >::phi(), FreeTrajectoryState::position(), TrajectoryStateClosestToPoint::position(), LargeD0_PixelPairStep_cff::propagator, sortBy_, and useChi2_.

Referenced by match().

356 {
357  if ((start.momentum().mag() == 0) || (target.momentum().mag() == 0)) return false;
359  /*2.2.X*/ try {
360  TrajectoryStateClosestToPoint tscp = propagator(start, target.position());
361  // if (!tscp.isValid()) return false; // in 3.1.X
362 
363  bool isBest = false;
364  float thisLocalPosDiff = (tscp.position()-target.position()).mag();
365  float thisGlobalMomDeltaR = deltaR(tscp.momentum(), target.momentum());
366  float thisGlobalMomDeltaPhi = fabs(deltaPhi(tscp.momentum().phi(), target.momentum().phi()));
367  float thisGlobalMomDeltaEta = fabs(tscp.momentum().eta() - target.momentum().eta());
368  float thisGlobalDPtRel = (tscp.momentum().perp() - target.momentum().perp())/target.momentum().perp();
369 
370  if ((thisLocalPosDiff < maxLocalPosDiff_) &&
371  (thisGlobalMomDeltaR < maxGlobalMomDeltaR_) &&
372  (thisGlobalMomDeltaEta < maxGlobalMomDeltaEta_) &&
373  (thisGlobalMomDeltaPhi < maxGlobalMomDeltaPhi_) &&
374  (fabs(thisGlobalDPtRel) < maxGlobalDPtRel_)) {
375  float thisChi2 = useChi2_ ? getChi2(target, tscp, chi2DiagonalOnly_, chi2UseVertex_) : 0;
376  if (thisChi2 >= maxChi2_) return false;
377  switch (sortBy_) {
378  case LocalPosDiff: isBest = (thisLocalPosDiff < lastDeltaLocalPos); break;
379  case GlobalMomDeltaR: isBest = (thisGlobalMomDeltaR < lastDeltaR); break;
380  case GlobalMomDeltaEta: isBest = (thisGlobalMomDeltaEta < lastDeltaEta); break;
381  case GlobalMomDeltaPhi: isBest = (thisGlobalMomDeltaPhi < lastDeltaPhi); break;
382  case GlobalDPtRel: isBest = (thisGlobalDPtRel < lastGlobalDPtRel); break;
383  case Chi2: isBest = (thisChi2 < lastChi2); break;
384  }
385  if (isBest) {
386  lastDeltaLocalPos = thisLocalPosDiff;
387  lastDeltaR = thisGlobalMomDeltaR;
388  lastDeltaEta = thisGlobalMomDeltaEta;
389  lastDeltaPhi = thisGlobalMomDeltaPhi;
390  lastGlobalDPtRel = thisGlobalDPtRel;
391  lastChi2 = thisChi2;
392  }
393  } // if match
394 
395  return isBest;
396  /*2.2.X*/ } catch (const TrajectoryStateException &err) { return false; }
397 }
T perp() const
Definition: PV3DBase.h:71
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Geom::Phi< T > phi() const
Definition: PV3DBase.h:68
static double getChi2(const FreeTrajectoryState &start, const FreeTrajectoryState &other, bool diagonalOnly, bool useVertex, bool useFirstMomentum)
T mag() const
Definition: PV3DBase.h:66
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:75
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 297 of file MatcherUsingTracksAlgorithm.cc.

References 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(), PV3DBase< T, PVType, FrameType >::phi(), propagator_, sortBy_, TrajectoryStateOnSurface::surface(), and useChi2_.

305 {
306  if ((start.momentum().mag() == 0) || !target.isValid()) return false;
307 
308  TrajectoryStateOnSurface tsos = propagator_->propagate(start, target.surface());
309 
310  bool isBest = false;
311  if (tsos.isValid()) {
312  float thisLocalPosDiff = (tsos.localPosition()-target.localPosition()).mag();
313  float thisGlobalMomDeltaR = deltaR(tsos.globalMomentum(), target.globalMomentum());
314  float thisGlobalMomDeltaPhi = fabs(deltaPhi(tsos.globalMomentum().phi(), target.globalMomentum().phi()));
315  float thisGlobalMomDeltaEta = fabs(tsos.globalMomentum().eta() - target.globalMomentum().eta());
316  float thisGlobalDPtRel = (tsos.globalMomentum().perp() - target.globalMomentum().perp())/target.globalMomentum().perp();
317 
318  if ((thisLocalPosDiff < maxLocalPosDiff_) &&
319  (thisGlobalMomDeltaR < maxGlobalMomDeltaR_) &&
320  (thisGlobalMomDeltaEta < maxGlobalMomDeltaEta_) &&
321  (thisGlobalMomDeltaPhi < maxGlobalMomDeltaPhi_) &&
322  (fabs(thisGlobalDPtRel) < maxGlobalDPtRel_)) {
323  float thisChi2 = useChi2_ ? getChi2(target, tsos, chi2DiagonalOnly_, chi2UseVertex_) : 0;
324  if (thisChi2 >= maxChi2_) return false;
325  switch (sortBy_) {
326  case LocalPosDiff: isBest = (thisLocalPosDiff < lastDeltaLocalPos); break;
327  case GlobalMomDeltaR: isBest = (thisGlobalMomDeltaR < lastDeltaR); break;
328  case GlobalMomDeltaEta: isBest = (thisGlobalMomDeltaEta < lastDeltaEta); break;
329  case GlobalMomDeltaPhi: isBest = (thisGlobalMomDeltaPhi < lastDeltaPhi); break;
330  case GlobalDPtRel: isBest = (thisGlobalDPtRel < lastGlobalDPtRel); break;
331  case Chi2: isBest = (thisChi2 < lastChi2); break;
332  }
333  if (isBest) {
334  lastDeltaLocalPos = thisLocalPosDiff;
335  lastDeltaR = thisGlobalMomDeltaR;
336  lastDeltaEta = thisGlobalMomDeltaEta;
337  lastDeltaPhi = thisGlobalMomDeltaPhi;
338  lastGlobalDPtRel = thisGlobalDPtRel;
339  lastChi2 = thisChi2;
340  }
341  } // if match
342  }
343 
344  return isBest;
345 }
T perp() const
Definition: PV3DBase.h:71
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Geom::Phi< T > phi() const
Definition: PV3DBase.h:68
static double getChi2(const FreeTrajectoryState &start, const FreeTrajectoryState &other, bool diagonalOnly, bool useVertex, bool useFirstMomentum)
T mag() const
Definition: PV3DBase.h:66
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:75
GlobalVector globalMomentum() const
const Surface & surface() 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 260 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(), run_regression::ret, reco::Candidate::vx(), reco::Candidate::vy(), and reco::Candidate::vz().

Referenced by match().

260  {
262  if (whichTrack != None) {
263  reco::TrackRef tk = getTrack(reco, whichTrack);
264  if (tk.isNull()) {
265  ret = FreeTrajectoryState();
266  } else {
267  switch (whichState) {
271  }
272  }
273  } else {
274  ret = FreeTrajectoryState( GlobalPoint( reco.vx(), reco.vy(), reco.vz()),
275  GlobalVector(reco.px(), reco.py(), reco.pz()),
276  reco.charge(),
277  magfield_.product());
278  }
279  return ret;
280 }
FreeTrajectoryState innerFreeState(const reco::Track &tk, const MagneticField *field)
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
bool isNull() const
Checks for null.
Definition: Ref.h:247
edm::ESHandle< MagneticField > magfield_
virtual int charge() const =0
electric charge
virtual double py() const =0
y coordinate of momentum vector
virtual double px() const =0
x coordinate of momentum vector
FreeTrajectoryState initialFreeState(const reco::Track &tk, const MagneticField *field)
T const * product() const
Definition: ESHandle.h:62
virtual double vz() const =0
z coordinate of vertex position
FreeTrajectoryState outerFreeState(const reco::Track &tk, const MagneticField *field)
reco::TrackRef getTrack(const reco::Candidate &reco, WhichTrack which) const
Get track reference out of a Candidate (via dynamic_cast to reco::RecoCandidate)
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 283 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 run_regression::ret.

Referenced by match().

283  {
285  reco::TrackRef tk = getTrack(reco, whichTrack);
286  if (tk.isNonnull()) {
287  switch (whichState) {
290  default: break; // just to make gcc happy
291  }
292  }
293  return ret;
294 }
TrajectoryStateOnSurface innerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
edm::ESHandle< GlobalTrackingGeometry > geometry_
edm::ESHandle< MagneticField > magfield_
TrajectoryStateOnSurface outerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field)
T const * product() const
Definition: ESHandle.h:62
reco::TrackRef getTrack(const reco::Candidate &reco, WhichTrack which) const
Get track reference out of a Candidate (via dynamic_cast to reco::RecoCandidate)

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 105 of file MatcherUsingTracksAlgorithm.h.

Referenced by init(), and targetState().

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

Definition at line 103 of file MatcherUsingTracksAlgorithm.h.

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

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

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

Referenced by init(), and matchWithPropagation().

bool MatcherUsingTracksAlgorithm::requireSameCharge_
private

Definition at line 96 of file MatcherUsingTracksAlgorithm.h.

Referenced by match().

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

Definition at line 87 of file MatcherUsingTracksAlgorithm.h.

Referenced by match().

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

Definition at line 84 of file MatcherUsingTracksAlgorithm.h.

Referenced by match(), and MatcherUsingTracksAlgorithm().

WhichState MatcherUsingTracksAlgorithm::whichState2_
private

Definition at line 84 of file MatcherUsingTracksAlgorithm.h.

Referenced by match(), and MatcherUsingTracksAlgorithm().

WhichTrack MatcherUsingTracksAlgorithm::whichTrack1_
private

Definition at line 83 of file MatcherUsingTracksAlgorithm.h.

Referenced by match(), and MatcherUsingTracksAlgorithm().

WhichTrack MatcherUsingTracksAlgorithm::whichTrack2_
private

Definition at line 83 of file MatcherUsingTracksAlgorithm.h.

Referenced by match(), and MatcherUsingTracksAlgorithm().