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")
35 if (algo ==
"byTrackRef") {
37 }
else if (algo ==
"byPropagatingSrc") {
39 }
else if (algo ==
"byPropagatingMatched") {
41 }
else if (algo ==
"byDirectComparison") {
44 throw cms::Exception(
"Configuration") <<
"Value '" << algo <<
"' for algorithm not yet implemented.\n";
52 throw cms::Exception(
"Configuration") <<
"Algorithm 'byTrackRef' needs tracks not to be 'none'.\n";
65 if (sortBy ==
"deltaLocalPos")
67 else if (sortBy ==
"deltaPtRel")
69 else if (sortBy ==
"deltaR")
71 else if (sortBy ==
"deltaEta")
73 else if (sortBy ==
"deltaPhi")
75 else if (sortBy ==
"chi2")
79 <<
"Parameter 'sortBy' must be one of: deltaLocalPos, deltaPtRel, deltaR, chi2.\n";
97 <<
"When using 'byDirectComparison' with 'src' at vertex (or None), 'matched' must be at vertex too.\n";
101 <<
"When using 'byDirectComparison' with 'src' not at vertex, 'matched' can't be at vertex or None.\n";
103 throw cms::Exception(
"Configuration") <<
"You can't use 'byDirectComparison' with non-matching states.\n";
110 throw cms::Exception(
"Configuration") <<
"Can't compute chi2s if both tracks are set to 'none'.\n";
121 else if (choice !=
"matched")
122 throw cms::Exception(
"Configuration") <<
"chi2MomentumForDxy must be 'src' or 'matched'\n";
129 throw cms::Exception(
"Configuration") <<
"Can't sort by chi2s if 'computeChi2s' is not set to true.\n";
138 if (s_whichTrack ==
"none") {
140 }
else if (s_whichTrack ==
"tracker") {
142 }
else if (s_whichTrack ==
"muon") {
144 }
else if (s_whichTrack ==
"global") {
147 throw cms::Exception(
"Configuration") <<
"Parameter 'useTrack' must be 'none', 'tracker', 'muon', 'global'\n";
150 if (s_whichState ==
"atVertex") {
152 }
else if (s_whichState ==
"innermost") {
154 }
else if (s_whichState ==
"outermost") {
157 throw cms::Exception(
"Configuration") <<
"Parameter 'useState' must be 'atVertex', 'innermost', 'outermost'\n";
168 float &deltaLocalPos,
182 if (t1.
id() != t2.
id()) {
184 <<
"Trying to match by reference tracks coming from different collections.\n";
192 return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
197 return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
202 return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
207 return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
227 float &deltaLocalPos,
248 for (it = c2s.
begin(), ed = c2s.
end(), i = 0; it != ed; ++it, ++
i) {
263 if (t1.
id() != t2.
id()) {
265 <<
"Trying to match by reference tracks coming from different collections.\n";
275 if (
matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
287 if (
matchWithPropagation(start, otherstart, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
293 if (
matchWithPropagation(otherstart, start, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
315 throw cms::Exception(
"Invalid Data") <<
"Input object is not a RecoCandidate.\n";
316 switch (whichTrack) {
336 if (whichTrack !=
None) {
341 switch (whichState) {
368 switch (whichState) {
387 float &lastDeltaLocalPos,
388 float &lastGlobalDPtRel,
389 float &lastChi2)
const {
401 float thisGlobalDPtRel =
412 isBest = (thisLocalPosDiff < lastDeltaLocalPos);
415 isBest = (thisGlobalMomDeltaR < lastDeltaR);
418 isBest = (thisGlobalMomDeltaEta < lastDeltaEta);
421 isBest = (thisGlobalMomDeltaPhi < lastDeltaPhi);
424 isBest = (thisGlobalDPtRel < lastGlobalDPtRel);
427 isBest = (thisChi2 < lastChi2);
431 lastDeltaLocalPos = thisLocalPosDiff;
432 lastDeltaR = thisGlobalMomDeltaR;
433 lastDeltaEta = thisGlobalMomDeltaEta;
434 lastDeltaPhi = thisGlobalMomDeltaPhi;
435 lastGlobalDPtRel = thisGlobalDPtRel;
449 float &lastDeltaLocalPos,
450 float &lastGlobalDPtRel,
451 float &lastChi2)
const {
474 isBest = (thisLocalPosDiff < lastDeltaLocalPos);
477 isBest = (thisGlobalMomDeltaR < lastDeltaR);
480 isBest = (thisGlobalMomDeltaEta < lastDeltaEta);
483 isBest = (thisGlobalMomDeltaPhi < lastDeltaPhi);
486 isBest = (thisGlobalDPtRel < lastGlobalDPtRel);
489 isBest = (thisChi2 < lastChi2);
493 lastDeltaLocalPos = thisLocalPosDiff;
494 lastDeltaR = thisGlobalMomDeltaR;
495 lastDeltaEta = thisGlobalMomDeltaEta;
496 lastDeltaPhi = thisGlobalMomDeltaPhi;
497 lastGlobalDPtRel = thisGlobalDPtRel;
511 float &lastDeltaLocalPos,
512 float &lastGlobalDPtRel,
513 float &lastChi2)
const {
532 isBest = (thisLocalPosDiff < lastDeltaLocalPos);
535 isBest = (thisGlobalMomDeltaR < lastDeltaR);
538 isBest = (thisGlobalMomDeltaEta < lastDeltaEta);
541 isBest = (thisGlobalMomDeltaPhi < lastDeltaPhi);
544 isBest = (thisGlobalDPtRel < lastGlobalDPtRel);
547 isBest = (thisChi2 < lastChi2);
551 lastDeltaLocalPos = thisLocalPosDiff;
552 lastDeltaR = thisGlobalMomDeltaR;
553 lastDeltaEta = thisGlobalMomDeltaEta;
554 lastDeltaPhi = thisGlobalMomDeltaPhi;
555 lastGlobalDPtRel = thisGlobalDPtRel;
567 bool useFirstMomentum) {
569 throw cms::Exception(
"LogicError") <<
"At least one of the two states must have errors to make chi2s.\n";
580 double dsz = (x1.
z() - x2.z()) * pt / pm - ((x1.
x() - x2.x()) * p.
x() + (x1.
y() - x2.y()) * p.
y()) / pt * p.
z() / pm;
581 double dxy = (-(x1.
x() - x2.x()) * p.
y() + (x1.
y() - x2.y()) * p.
x()) / pt;
587 return ROOT::Math::Similarity(
diff, cov);
595 throw cms::Exception(
"LogicError") <<
"At least one of the two states must have errors to make chi2s.\n";
606 return ROOT::Math::Similarity(diff, cov);
614 throw cms::Exception(
"LogicError") <<
"At least one of the two states must have errors to make chi2s.\n";
622 return ROOT::Math::Similarity(
diff, cov);
628 for (
size_t i = 0;
i < 5; ++
i) {
629 for (
size_t j =
i + 1;
j < 5; ++
j) {
646 cov.Place_at(momCov, 0, 0);
648 for (
size_t i = 3;
i < 5; ++
i) {
649 for (
size_t j =
i;
j < 5; ++
j) {
const AlgebraicVector5 & vector() const
tuple ret
prodAgent to be discontinued
PerigeeTrajectoryParameters ftsToPerigeeParameters(const FTS &originalFTS, const GlobalPoint &referencePoint, double &pt)
GlobalPoint position() const
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > geometryToken_
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
const PerigeeTrajectoryError & perigeeError() const
const LocalTrajectoryParameters & localParameters() const
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
virtual double pz() const =0
z coordinate of momentum vector
Geom::Phi< T > phi() const
Global3DPoint GlobalPoint
virtual double vx() const =0
x coordinate of vertex position
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magfieldToken_
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.
virtual double vy() const =0
y coordinate of vertex position
float maxGlobalMomDeltaEta_
virtual reco::TrackRef track() const
reference to a Track
Geom::Theta< T > theta() const
StringCutObjectSelector< reco::Candidate, true > matchedCut_
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_
virtual int charge() const =0
electric charge
const LocalTrajectoryError & localError() const
virtual double py() const =0
y coordinate of momentum vector
float maxGlobalMomDeltaPhi_
bool isNull() const
Checks for null.
GlobalVector momentum() const
edm::ESHandle< Propagator > propagator_
MatcherUsingTracksAlgorithm(const edm::ParameterSet &iConfig, edm::ConsumesCollector)
const AlgebraicSymMatrix55 & covarianceMatrix() const
virtual double px() const =0
x coordinate of momentum vector
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.
T const * product() const
T getParameter(std::string const &) const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
static void cropAndInvert(AlgebraicSymMatrix55 &cov, bool diagonalOnly, bool top3by3only)
Possibly crop the 3x3 part of the matrix or remove off-diagonal terms, then invert.
AlgebraicVector5 mixedFormatVector() const
virtual double vz() const =0
z coordinate of vertex position
edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorToken_
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
reco::TrackRef getTrack(const reco::Candidate &reco, WhichTrack which) const
Get track reference out of a Candidate (via dynamic_cast to reco::RecoCandidate)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Log< level::Warning, false > LogWarning
bool matchByDirectComparison(const FreeTrajectoryState &start, const FreeTrajectoryState &other, float &lastDeltaR, float &lastDeltaEta, float &lastDeltaPhi, float &lastDeltaLocalPos, float &lastGlobalDPtRel, float &lastChi2) const
Compare directly two states. return true if current pair is the new best match (in that case...
GlobalVector momentum() const
Global3DVector GlobalVector
virtual reco::TrackRef combinedMuon() const
reference to a stand-alone muon Track