23 return deltaR<float>(v1.eta(),v1.phi(),v2.eta(),v2.phi());
27 return deltaR2<float>(v1.eta(),v1.phi(),v2.eta(),v2.phi());
32 whichTrack1_(None), whichTrack2_(None),
33 whichState1_(AtVertex), whichState2_(AtVertex),
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)
43 else throw cms::Exception(
"Configuration") <<
"Value '" << algo <<
"' for algorithm not yet implemented.\n";
60 std::string sortBy = iConfig.
getParameter<std::string>(
"sortBy");
67 else throw cms::Exception(
"Configuration") <<
"Parameter 'sortBy' must be one of: deltaLocalPos, deltaPtRel, deltaR, chi2.\n";
83 if (!secAtVertex)
throw cms::Exception(
"Configuration") <<
"When using 'byDirectComparison' with 'src' at vertex (or None), 'matched' must be at vertex too.\n";
85 if (secAtVertex)
throw cms::Exception(
"Configuration") <<
"When using 'byDirectComparison' with 'src' not at vertex, 'matched' can't be at vertex or None.\n";
100 std::string choice = iConfig.
getParameter<std::string>(
"chi2MomentumForDxy");
102 else if (choice !=
"matched")
throw cms::Exception(
"Configuration") <<
"chi2MomentumForDxy must be 'src' or 'matched'\n";
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";
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";
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"; }
146 return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
151 return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
156 return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
161 return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
191 for (it = c2s.
begin(), ed = c2s.
end(), i = 0; it != ed; ++it, ++
i) {
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"; }
208 if (
matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
220 if (
matchWithPropagation(start, otherstart, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
226 if (
matchWithPropagation(otherstart, start, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
249 if (rc == 0)
throw cms::Exception(
"Invalid Data") <<
"Input object is not a RecoCandidate.\n";
250 switch (whichTrack) {
262 if (whichTrack !=
None) {
267 switch (whichState) {
287 switch (whichState) {
302 float &lastDeltaLocalPos,
303 float &lastGlobalDPtRel,
304 float &lastChi2)
const
324 if (thisChi2 >=
maxChi2_)
return false;
326 case LocalPosDiff: isBest = (thisLocalPosDiff < lastDeltaLocalPos);
break;
327 case GlobalMomDeltaR: isBest = (thisGlobalMomDeltaR < lastDeltaR);
break;
330 case GlobalDPtRel: isBest = (thisGlobalDPtRel < lastGlobalDPtRel);
break;
331 case Chi2: isBest = (thisChi2 < lastChi2);
break;
334 lastDeltaLocalPos = thisLocalPosDiff;
335 lastDeltaR = thisGlobalMomDeltaR;
336 lastDeltaEta = thisGlobalMomDeltaEta;
337 lastDeltaPhi = thisGlobalMomDeltaPhi;
338 lastGlobalDPtRel = thisGlobalDPtRel;
353 float &lastDeltaLocalPos,
354 float &lastGlobalDPtRel,
355 float &lastChi2)
const
376 if (thisChi2 >=
maxChi2_)
return false;
378 case LocalPosDiff: isBest = (thisLocalPosDiff < lastDeltaLocalPos);
break;
379 case GlobalMomDeltaR: isBest = (thisGlobalMomDeltaR < lastDeltaR);
break;
382 case GlobalDPtRel: isBest = (thisGlobalDPtRel < lastGlobalDPtRel);
break;
383 case Chi2: isBest = (thisChi2 < lastChi2);
break;
386 lastDeltaLocalPos = thisLocalPosDiff;
387 lastDeltaR = thisGlobalMomDeltaR;
388 lastDeltaEta = thisGlobalMomDeltaEta;
389 lastDeltaPhi = thisGlobalMomDeltaPhi;
390 lastGlobalDPtRel = thisGlobalDPtRel;
406 float &lastDeltaLocalPos,
407 float &lastGlobalDPtRel,
408 float &lastChi2)
const
425 if (thisChi2 >=
maxChi2_)
return false;
427 case LocalPosDiff: isBest = (thisLocalPosDiff < lastDeltaLocalPos);
break;
428 case GlobalMomDeltaR: isBest = (thisGlobalMomDeltaR < lastDeltaR);
break;
431 case GlobalDPtRel: isBest = (thisGlobalDPtRel < lastGlobalDPtRel);
break;
432 case Chi2: isBest = (thisChi2 < lastChi2);
break;
435 lastDeltaLocalPos = thisLocalPosDiff;
436 lastDeltaR = thisGlobalMomDeltaR;
437 lastDeltaEta = thisGlobalMomDeltaEta;
438 lastDeltaPhi = thisGlobalMomDeltaPhi;
439 lastGlobalDPtRel = thisGlobalDPtRel;
449 if (!start.
hasError() && !other.
hasError())
throw cms::Exception(
"LogicError") <<
"At least one of the two states must have errors to make chi2s.\n";
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;
464 return ROOT::Math::Similarity(
diff, cov);
469 if (!start.
hasError() && !other.
hasError())
throw cms::Exception(
"LogicError") <<
"At least one of the two states must have errors to make chi2s.\n";
478 return ROOT::Math::Similarity(diff, cov);
483 if (!start.
hasError() && !other.
hasError())
throw cms::Exception(
"LogicError") <<
"At least one of the two states must have errors to make chi2s.\n";
489 return ROOT::Math::Similarity(
diff, cov);
496 for (
size_t i = 0;
i < 5; ++
i) {
for (
size_t j =
i+1;
j < 5; ++
j) {
504 if (diagonalOnly) { momCov(0,1) = 0; momCov(0,2) = 0; momCov(1,2) = 0; }
508 cov.Place_at(momCov,0,0);
510 for (
size_t i = 3;
i < 5; ++
i) {
for (
size_t j =
i;
j < 5; ++
j) {
T getParameter(std::string const &) const
const AlgebraicVector5 & vector() const
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
GlobalPoint position() const
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
PerigeeTrajectoryParameters ftsToPerigeeParameters(const FTS &originalFTS, const GlobalPoint &referencePoint, double &pt) 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
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
TrackCharge charge() const
double deltaR2< GlobalVector >(const GlobalVector &v1, const GlobalVector &v2)
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
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
bool isNonnull() const
Checks for non-null.
bool isNull() const
Checks for null.
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
const PerigeeTrajectoryParameters & perigeeParameters() const
edm::ESHandle< GlobalTrackingGeometry > geometry_
edm::ESHandle< MagneticField > magfield_
const AlgebraicSymMatrix55 & matrix() const
virtual int charge() const =0
electric charge
MatcherUsingTracksAlgorithm(const edm::ParameterSet &iConfig)
const LocalTrajectoryError & localError() const
virtual double py() const =0
y coordinate of momentum vector
float maxGlobalMomDeltaPhi_
GlobalVector momentum() const
edm::ESHandle< Propagator > propagator_
const AlgebraicSymMatrix55 & covarianceMatrix() const
virtual double px() const =0
x coordinate of momentum vector
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float >, ROOT::Math::GlobalCoordinateSystemTag > GlobalVector
vector in glovbal coordinate system
double deltaR(double eta1, double eta2, double phi1, double phi2)
TrajectoryStateOnSurface targetState(const reco::Candidate &reco, WhichTrack whichTrack, WhichState whichState) const
End state for the propagation.
GlobalPoint position() const
StringCutObjectSelector< reco::Candidate, true > srcCut_
ROOT::Math::SVector< double, 5 > AlgebraicVector5
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
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
const AlgebraicSymMatrix55 & matrix() const
GlobalVector globalMomentum() const
const Surface & surface() const
PerigeeTrajectoryError ftsToPerigeeError(const FTS &originalFTS) const
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...
const_iterator begin() const
const_iterator end() const
ProductID id() const
Accessor for product ID.
reco::TrackRef getTrack(const reco::Candidate &reco, WhichTrack which) const
Get track reference out of a Candidate (via dynamic_cast to reco::RecoCandidate)
double deltaR< GlobalVector >(const GlobalVector &v1, const GlobalVector &v2)
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...
GlobalVector momentum() const
Global3DVector GlobalVector
virtual reco::TrackRef combinedMuon() const
reference to a stand-alone muon Track