22 whichState1_(AtVertex),
23 whichState2_(AtVertex),
24 srcCut_(iConfig.existsAs<
std::
string>(
"srcPreselection") ? iConfig.getParameter<
std::
string>(
"srcPreselection")
26 matchedCut_(iConfig.existsAs<
std::
string>(
"matchedPreselection")
27 ? iConfig.getParameter<
std::
string>(
"matchedPreselection")
29 requireSameCharge_(iConfig.existsAs<
bool>(
"requireSameCharge") ? iConfig.getParameter<
bool>(
"requireSameCharge")
32 if (algo ==
"byTrackRef") {
34 }
else if (algo ==
"byPropagatingSrc") {
36 }
else if (algo ==
"byPropagatingMatched") {
38 }
else if (algo ==
"byDirectComparison") {
41 throw cms::Exception(
"Configuration") <<
"Value '" << algo <<
"' for algorithm not yet implemented.\n";
49 throw cms::Exception(
"Configuration") <<
"Algorithm 'byTrackRef' needs tracks not to be 'none'.\n";
62 if (sortBy ==
"deltaLocalPos")
64 else if (sortBy ==
"deltaPtRel")
66 else if (sortBy ==
"deltaR")
68 else if (sortBy ==
"deltaEta")
70 else if (sortBy ==
"deltaPhi")
72 else if (sortBy ==
"chi2")
76 <<
"Parameter 'sortBy' must be one of: deltaLocalPos, deltaPtRel, deltaR, chi2.\n";
94 <<
"When using 'byDirectComparison' with 'src' at vertex (or None), 'matched' must be at vertex too.\n";
98 <<
"When using 'byDirectComparison' with 'src' not at vertex, 'matched' can't be at vertex or None.\n";
100 throw cms::Exception(
"Configuration") <<
"You can't use 'byDirectComparison' with non-matching states.\n";
107 throw cms::Exception(
"Configuration") <<
"Can't compute chi2s if both tracks are set to 'none'.\n";
118 else if (choice !=
"matched")
119 throw cms::Exception(
"Configuration") <<
"chi2MomentumForDxy must be 'src' or 'matched'\n";
126 throw cms::Exception(
"Configuration") <<
"Can't sort by chi2s if 'computeChi2s' is not set to true.\n";
135 if (s_whichTrack ==
"none") {
137 }
else if (s_whichTrack ==
"tracker") {
139 }
else if (s_whichTrack ==
"muon") {
141 }
else if (s_whichTrack ==
"global") {
144 throw cms::Exception(
"Configuration") <<
"Parameter 'useTrack' must be 'none', 'tracker', 'muon', 'global'\n";
147 if (s_whichState ==
"atVertex") {
149 }
else if (s_whichState ==
"innermost") {
151 }
else if (s_whichState ==
"outermost") {
154 throw cms::Exception(
"Configuration") <<
"Parameter 'useState' must be 'atVertex', 'innermost', 'outermost'\n";
165 float &deltaLocalPos,
179 if (t1.
id() != t2.
id()) {
181 <<
"Trying to match by reference tracks coming from different collections.\n";
189 return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
194 return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
199 return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
204 return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
224 float &deltaLocalPos,
245 for (it = c2s.
begin(), ed = c2s.
end(), i = 0; it != ed; ++it, ++
i) {
260 if (t1.
id() != t2.
id()) {
262 <<
"Trying to match by reference tracks coming from different collections.\n";
272 if (
matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
284 if (
matchWithPropagation(start, otherstart, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
290 if (
matchWithPropagation(otherstart, start, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
312 throw cms::Exception(
"Invalid Data") <<
"Input object is not a RecoCandidate.\n";
313 switch (whichTrack) {
333 if (whichTrack !=
None) {
338 switch (whichState) {
365 switch (whichState) {
384 float &lastDeltaLocalPos,
385 float &lastGlobalDPtRel,
386 float &lastChi2)
const {
398 float thisGlobalDPtRel =
409 isBest = (thisLocalPosDiff < lastDeltaLocalPos);
412 isBest = (thisGlobalMomDeltaR < lastDeltaR);
415 isBest = (thisGlobalMomDeltaEta < lastDeltaEta);
418 isBest = (thisGlobalMomDeltaPhi < lastDeltaPhi);
421 isBest = (thisGlobalDPtRel < lastGlobalDPtRel);
424 isBest = (thisChi2 < lastChi2);
428 lastDeltaLocalPos = thisLocalPosDiff;
429 lastDeltaR = thisGlobalMomDeltaR;
430 lastDeltaEta = thisGlobalMomDeltaEta;
431 lastDeltaPhi = thisGlobalMomDeltaPhi;
432 lastGlobalDPtRel = thisGlobalDPtRel;
446 float &lastDeltaLocalPos,
447 float &lastGlobalDPtRel,
448 float &lastChi2)
const {
471 isBest = (thisLocalPosDiff < lastDeltaLocalPos);
474 isBest = (thisGlobalMomDeltaR < lastDeltaR);
477 isBest = (thisGlobalMomDeltaEta < lastDeltaEta);
480 isBest = (thisGlobalMomDeltaPhi < lastDeltaPhi);
483 isBest = (thisGlobalDPtRel < lastGlobalDPtRel);
486 isBest = (thisChi2 < lastChi2);
490 lastDeltaLocalPos = thisLocalPosDiff;
491 lastDeltaR = thisGlobalMomDeltaR;
492 lastDeltaEta = thisGlobalMomDeltaEta;
493 lastDeltaPhi = thisGlobalMomDeltaPhi;
494 lastGlobalDPtRel = thisGlobalDPtRel;
508 float &lastDeltaLocalPos,
509 float &lastGlobalDPtRel,
510 float &lastChi2)
const {
529 isBest = (thisLocalPosDiff < lastDeltaLocalPos);
532 isBest = (thisGlobalMomDeltaR < lastDeltaR);
535 isBest = (thisGlobalMomDeltaEta < lastDeltaEta);
538 isBest = (thisGlobalMomDeltaPhi < lastDeltaPhi);
541 isBest = (thisGlobalDPtRel < lastGlobalDPtRel);
544 isBest = (thisChi2 < lastChi2);
548 lastDeltaLocalPos = thisLocalPosDiff;
549 lastDeltaR = thisGlobalMomDeltaR;
550 lastDeltaEta = thisGlobalMomDeltaEta;
551 lastDeltaPhi = thisGlobalMomDeltaPhi;
552 lastGlobalDPtRel = thisGlobalDPtRel;
564 bool useFirstMomentum) {
566 throw cms::Exception(
"LogicError") <<
"At least one of the two states must have errors to make chi2s.\n";
577 double dsz = (x1.
z() -
x2.z()) * pt / pm - ((x1.
x() -
x2.x()) * p.
x() + (x1.
y() -
x2.y()) * p.
y()) / pt * p.
z() / pm;
578 double dxy = (-(x1.
x() -
x2.x()) * p.
y() + (x1.
y() -
x2.y()) * p.
x()) / pt;
584 return ROOT::Math::Similarity(
diff, cov);
592 throw cms::Exception(
"LogicError") <<
"At least one of the two states must have errors to make chi2s.\n";
603 return ROOT::Math::Similarity(diff, cov);
611 throw cms::Exception(
"LogicError") <<
"At least one of the two states must have errors to make chi2s.\n";
619 return ROOT::Math::Similarity(
diff, cov);
625 for (
size_t i = 0;
i < 5; ++
i) {
626 for (
size_t j =
i + 1;
j < 5; ++
j) {
643 cov.Place_at(momCov, 0, 0);
645 for (
size_t i = 3;
i < 5; ++
i) {
646 for (
size_t j =
i;
j < 5; ++
j) {
T getParameter(std::string const &) const
const AlgebraicVector5 & vector() const
PerigeeTrajectoryParameters ftsToPerigeeParameters(const FTS &originalFTS, const GlobalPoint &referencePoint, double &pt)
GlobalPoint position() const
virtual double pz() const =0
z coordinate of momentum vector
bool isNonnull() const
Checks for non-null.
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
virtual double vx() const =0
x coordinate of vertex position
const PerigeeTrajectoryError & perigeeError() const
const LocalTrajectoryParameters & localParameters() const
ret
prodAgent to be discontinued
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
void getConf(const edm::ParameterSet &iConfig, const std::string &whatFor, WhichTrack &whichTrack, WhichState &whichState)
Parse some configuration.
LocalPoint localPosition() const
Geom::Phi< T > phi() const
Global3DPoint GlobalPoint
virtual double vy() const =0
y coordinate of vertex position
TrackCharge charge() const
virtual reco::TrackRef standAloneMuon() const
reference to a stand-alone muon Track
static double getChi2(const FreeTrajectoryState &start, const FreeTrajectoryState &other, bool diagonalOnly, bool useVertex, bool useFirstMomentum)
const CurvilinearTrajectoryError & curvilinearError() const
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.
float maxGlobalMomDeltaEta_
virtual reco::TrackRef track() const
reference to a Track
Geom::Theta< T > theta() const
StringCutObjectSelector< reco::Candidate, true > matchedCut_
virtual double py() const =0
y coordinate of momentum vector
const SurfaceType & surface() const
const_iterator begin() const
const PerigeeTrajectoryParameters & perigeeParameters() const
edm::ESHandle< GlobalTrackingGeometry > geometry_
edm::ESHandle< MagneticField > magfield_
ROOT::Math::SVector< double, 5 > AlgebraicVector5
const AlgebraicSymMatrix55 & matrix() const
StringCutObjectSelector< reco::Candidate, true > srcCut_
MatcherUsingTracksAlgorithm(const edm::ParameterSet &iConfig)
const LocalTrajectoryError & localError() const
float maxGlobalMomDeltaPhi_
bool isNull() const
Checks for null.
GlobalVector momentum() const
edm::ESHandle< Propagator > propagator_
const AlgebraicSymMatrix55 & covarianceMatrix() const
TrajectoryStateOnSurface targetState(const reco::Candidate &reco, WhichTrack whichTrack, WhichState whichState) const
End state for the propagation.
GlobalPoint position() const
float maxGlobalMomDeltaR_
const GlobalPoint & referencePoint() const
FreeTrajectoryState startingState(const reco::Candidate &reco, WhichTrack whichTrack, WhichState whichState) const
Starting state for the propagation.
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) 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.
AlgebraicVector5 mixedFormatVector() const
virtual int charge() const =0
electric charge
const AlgebraicSymMatrix55 & matrix() const
GlobalVector globalMomentum() const
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
bool match(const reco::Candidate &c1, const reco::Candidate &c2, float &deltaR, float &deltaEta, float &deltaPhi, float &deltaLocalPos, float &deltaPtRel, float &chi2) const
void init(const edm::EventSetup &iSetup)
Call this method at the beginning of each run, to initialize geometry, magnetic field and propagators...
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
PerigeeTrajectoryError ftsToPerigeeError(const FTS &originalFTS)
const_iterator end() const
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)
virtual double px() const =0
x coordinate of momentum vector
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...
T const * product() const
GlobalVector momentum() const
Global3DVector GlobalVector
virtual reco::TrackRef combinedMuon() const
reference to a stand-alone muon Track