21 whichTrack1_(None), whichTrack2_(None),
22 whichState1_(AtVertex), whichState2_(AtVertex),
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)
32 else throw cms::Exception(
"Configuration") <<
"Value '" << algo <<
"' for algorithm not yet implemented.\n";
56 else throw cms::Exception(
"Configuration") <<
"Parameter 'sortBy' must be one of: deltaLocalPos, deltaPtRel, deltaR, chi2.\n";
72 if (!secAtVertex)
throw cms::Exception(
"Configuration") <<
"When using 'byDirectComparison' with 'src' at vertex (or None), 'matched' must be at vertex too.\n";
74 if (secAtVertex)
throw cms::Exception(
"Configuration") <<
"When using 'byDirectComparison' with 'src' not at vertex, 'matched' can't be at vertex or None.\n";
91 else if (choice !=
"matched")
throw cms::Exception(
"Configuration") <<
"chi2MomentumForDxy must be 'src' or 'matched'\n";
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";
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";
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"; }
135 return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
140 return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
145 return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
150 return matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2);
180 for (it = c2s.
begin(), ed = c2s.
end(), i = 0; it != ed; ++it, ++
i) {
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"; }
197 if (
matchWithPropagation(start, target, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
209 if (
matchWithPropagation(start, otherstart, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
215 if (
matchWithPropagation(otherstart, start, deltR, deltEta, deltPhi, deltaLocalPos, deltaPtRel, chi2)) {
238 if (rc == 0)
throw cms::Exception(
"Invalid Data") <<
"Input object is not a RecoCandidate.\n";
239 switch (whichTrack) {
251 if (whichTrack !=
None) {
256 switch (whichState) {
276 switch (whichState) {
291 float &lastDeltaLocalPos,
292 float &lastGlobalDPtRel,
293 float &lastChi2)
const
313 if (thisChi2 >=
maxChi2_)
return false;
315 case LocalPosDiff: isBest = (thisLocalPosDiff < lastDeltaLocalPos);
break;
316 case GlobalMomDeltaR: isBest = (thisGlobalMomDeltaR < lastDeltaR);
break;
319 case GlobalDPtRel: isBest = (thisGlobalDPtRel < lastGlobalDPtRel);
break;
320 case Chi2: isBest = (thisChi2 < lastChi2);
break;
323 lastDeltaLocalPos = thisLocalPosDiff;
324 lastDeltaR = thisGlobalMomDeltaR;
325 lastDeltaEta = thisGlobalMomDeltaEta;
326 lastDeltaPhi = thisGlobalMomDeltaPhi;
327 lastGlobalDPtRel = thisGlobalDPtRel;
342 float &lastDeltaLocalPos,
343 float &lastGlobalDPtRel,
344 float &lastChi2)
const
365 if (thisChi2 >=
maxChi2_)
return false;
367 case LocalPosDiff: isBest = (thisLocalPosDiff < lastDeltaLocalPos);
break;
368 case GlobalMomDeltaR: isBest = (thisGlobalMomDeltaR < lastDeltaR);
break;
371 case GlobalDPtRel: isBest = (thisGlobalDPtRel < lastGlobalDPtRel);
break;
372 case Chi2: isBest = (thisChi2 < lastChi2);
break;
375 lastDeltaLocalPos = thisLocalPosDiff;
376 lastDeltaR = thisGlobalMomDeltaR;
377 lastDeltaEta = thisGlobalMomDeltaEta;
378 lastDeltaPhi = thisGlobalMomDeltaPhi;
379 lastGlobalDPtRel = thisGlobalDPtRel;
395 float &lastDeltaLocalPos,
396 float &lastGlobalDPtRel,
397 float &lastChi2)
const
414 if (thisChi2 >=
maxChi2_)
return false;
416 case LocalPosDiff: isBest = (thisLocalPosDiff < lastDeltaLocalPos);
break;
417 case GlobalMomDeltaR: isBest = (thisGlobalMomDeltaR < lastDeltaR);
break;
420 case GlobalDPtRel: isBest = (thisGlobalDPtRel < lastGlobalDPtRel);
break;
421 case Chi2: isBest = (thisChi2 < lastChi2);
break;
424 lastDeltaLocalPos = thisLocalPosDiff;
425 lastDeltaR = thisGlobalMomDeltaR;
426 lastDeltaEta = thisGlobalMomDeltaEta;
427 lastDeltaPhi = thisGlobalMomDeltaPhi;
428 lastGlobalDPtRel = thisGlobalDPtRel;
438 if (!start.
hasError() && !other.
hasError())
throw cms::Exception(
"LogicError") <<
"At least one of the two states must have errors to make chi2s.\n";
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;
453 return ROOT::Math::Similarity(
diff, cov);
458 if (!start.
hasError() && !other.
hasError())
throw cms::Exception(
"LogicError") <<
"At least one of the two states must have errors to make chi2s.\n";
467 return ROOT::Math::Similarity(diff, cov);
472 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);
485 for (
size_t i = 0;
i < 5; ++
i) {
for (
size_t j =
i+1;
j < 5; ++
j) {
493 if (diagonalOnly) { momCov(0,1) = 0; momCov(0,2) = 0; momCov(1,2) = 0; }
497 cov.Place_at(momCov,0,0);
499 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
PerigeeTrajectoryParameters ftsToPerigeeParameters(const FTS &originalFTS, const GlobalPoint &referencePoint, double &pt)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
GlobalPoint position() const
tuple start
Check for commandline option errors.
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
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
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
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.
const SurfaceType & surface() const
bool isNull() const
Checks for null.
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
const PerigeeTrajectoryParameters & perigeeParameters() const
auto const T2 &decltype(t1.eta()) t2
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
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
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
PerigeeTrajectoryError ftsToPerigeeError(const FTS &originalFTS)
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)
volatile std::atomic< bool > shutdown_flag false
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