103 int surfaceOption)
const {
104 std::pair<TrajectoryStateOnSurface, TrajectoryStateOnSurface> tsosPair;
105 if (surfaceOption == 0)
107 if (surfaceOption == 1)
109 if (surfaceOption != 0 && surfaceOption != 1)
112 if (matchOption == 0) {
114 return match_Chi2(tsosPair.first, tsosPair.second);
115 }
else if (matchOption == 1) {
117 return match_d(tsosPair.first, tsosPair.second);
118 }
else if (matchOption == 2) {
120 return match_Rpos(tsosPair.first, tsosPair.second);
121 }
else if (matchOption == 3) {
122 return match_dist(tsosPair.first, tsosPair.second);
138 vector<TrackCand>::const_iterator
result =
tracks.end();
139 for (vector<TrackCand>::const_iterator is =
tracks.begin(); is !=
tracks.end(); ++is) {
141 std::pair<TrajectoryStateOnSurface, TrajectoryStateOnSurface> tsosPair =
convertToTSOSMuHit(sta, *is);
161 const vector<TrackCand>&
tracks)
const {
162 const string category =
"GlobalMuonTrackMatcher";
169 typedef std::pair<TrackCand, TrajectoryStateOnSurface> TrackCandWithTSOS;
170 vector<TrackCandWithTSOS>
cands;
177 for (vector<TrackCand>::const_iterator is =
tracks.begin(); is !=
tracks.end(); ++is, iiTk++) {
179 std::pair<TrajectoryStateOnSurface, TrajectoryStateOnSurface> tsosPair =
convertToTSOSMuHit(sta, *is);
181 << tsosPair.first.isValid() <<
" tk isValid " << tsosPair.second.isValid() << endl;
182 if (tsosPair.first.isValid())
183 muonTSOS = tsosPair.first;
184 cands.push_back(TrackCandWithTSOS(*is, tsosPair.second));
188 double min_chisq = 999999;
189 double min_d = 999999;
190 double min_de = 999999;
191 double min_r_pos = 999999;
192 std::vector<bool> passes(
cands.size(),
false);
196 for (vector<TrackCandWithTSOS>::const_iterator
ii =
cands.begin();
ii !=
cands.end(); ++
ii,
jj++, iTkCand++) {
198 if (!muonTSOS.
isValid() || !(*ii).second.isValid())
204 double loc_chi2 =
match_dist(muonTSOS, (*ii).second);
208 << (*ii).second.globalPosition().eta() <<
" phi " << (*ii).second.globalPosition().phi() << endl;
225 result.push_back((*ii).first);
229 if ((passes[
jj] ==
false) && (*ii).second.globalMomentum().perp() <
thePt_threshold2) {
233 result.push_back((*ii).first);
240 result.push_back((*ii).first);
248 if (loc_chi2 < min_de)
252 if (
chi2 < min_chisq)
262 for (vector<TrackCandWithTSOS>::const_iterator is =
cands.begin(); is !=
cands.end(); ++is,
jj++) {
265 if (muonTSOS.
isValid() && (*is).second.isValid()) {
271 << (fabs(
deltaPhi((*is).second.globalPosition().barePhi(),
278 result.push_back((*is).first);
286 double loc_chi2 =
match_dist(muonTSOS, (*is).second);
289 if (loc_chi2 < min_de)
293 if (
chi2 < min_chisq)
299 for (vector<TrackCand>::const_iterator iTk =
result.begin(); iTk !=
result.end(); ++iTk) {
301 <<
"selected pt " << iTk->second->pt() <<
" eta " << iTk->second->eta() <<
" phi " 302 << iTk->second->phi() << endl;
315 for (vector<TrackCandWithTSOS>::const_iterator is =
cands.begin(); is !=
cands.end(); ++is,
jj++) {
328 ((
chi2 / min_chisq == 1) ? 1 : 0) + ((
distance / min_d == 1) ? 1 : 0) + ((
deltaR / min_r_pos == 1) ? 1 : 0);
331 result.push_back((*is).first);
335 result.push_back((*is).first);
339 result.push_back((*is).first);
343 result.push_back((*is).first);
347 for (vector<TrackCand>::const_iterator iTk =
result.begin(); iTk !=
result.end(); ++iTk) {
349 <<
"selected pt " << iTk->second->pt() <<
" eta " << iTk->second->eta() <<
" phi " 350 << iTk->second->phi() << endl;
361 const string category =
"GlobalMuonTrackMatcher";
369 if (tkCand.second.isNonnull()) {
371 if (!(tkCand.second->p() <
theMinP || tkCand.second->pt() <
theMinPt)) {
377 if (!impactMuTSOS.isValid() || !outerTkTsos.
isValid())
378 return pair<TrajectoryStateOnSurface, TrajectoryStateOnSurface>(
empty,
empty);
387 if (!
samePlane(tkTsosFromMu, tkTsosFromTk)) {
391 if (tkTsosFromMu.isValid())
393 same1 =
samePlane(newTkTsosFromTk, tkTsosFromMu);
398 same2 =
samePlane(newTkTsosFromMu, tkTsosFromTk);
402 tkTsosFromTk = newTkTsosFromTk;
404 tkTsosFromMu = newTkTsosFromMu;
406 LogTrace(
category) <<
"Could not propagate Muon and Tracker track to the same tracker bound!";
407 return pair<TrajectoryStateOnSurface, TrajectoryStateOnSurface>(
empty,
empty);
411 return pair<TrajectoryStateOnSurface, TrajectoryStateOnSurface>(tkTsosFromMu, tkTsosFromTk);
419 const string category =
"GlobalMuonTrackMatcher";
424 if (tkCand.second.isNonnull()) {
426 if (!(tkCand.second->p() <
theMinP || tkCand.second->pt() <
theMinPt)) {
435 (innerMuTSOS.globalPosition() - innerTkTsos.globalPosition()).
mag())
436 outerTkTsos = innerTkTsos;
440 if (!innerMuTSOS.isValid() || !outerTkTsos.
isValid()) {
441 LogTrace(
category) <<
"A TSOS validity problem! MuTSOS " << innerMuTSOS.isValid() <<
" TkTSOS " 443 return pair<TrajectoryStateOnSurface, TrajectoryStateOnSurface>(
empty,
empty);
446 const Surface& refSurface = innerMuTSOS.surface();
451 LogTrace(
category) <<
"Could not propagate Muon and Tracker track to the same muon hit surface!";
452 return pair<TrajectoryStateOnSurface, TrajectoryStateOnSurface>(
empty,
empty);
455 return pair<TrajectoryStateOnSurface, TrajectoryStateOnSurface>(innerMuTSOS, tkAtMu);
463 const string category =
"GlobalMuonTrackMatcher";
472 if (tkCand.second.isNonnull()) {
474 if (!(tkCand.second->p() <
theMinP || tkCand.second->pt() <
theMinPt)) {
483 outerTkTsos = innerTkTsos;
487 if (!impactMuTSOS.isValid() || !outerTkTsos.
isValid()) {
488 LogTrace(
category) <<
"A TSOS validity problem! MuTSOS " << impactMuTSOS.isValid() <<
" TkTSOS " 490 return pair<TrajectoryStateOnSurface, TrajectoryStateOnSurface>(
empty,
empty);
498 LogTrace(
category) <<
"Could not propagate Muon and Tracker track to the same tracker hit surface!";
499 return pair<TrajectoryStateOnSurface, TrajectoryStateOnSurface>(
empty,
empty);
502 return pair<TrajectoryStateOnSurface, TrajectoryStateOnSurface>(muAtTk, outerTkTsos);
516 const float maxtilt = 0.999;
517 const float maxdist = 0.01;
522 bool returnValue = ((fabs(
p1->normalVector().dot(
p2->normalVector())) > maxtilt) ||
523 (fabs((
p1->toLocal(
p2->position())).z()) < maxdist))
535 const string category =
"GlobalMuonTrackMatcher";
545 bool ierr = !
m.Invert();
552 double est = ROOT::Math::Similarity(
v,
m);
564 if (tkCand.second.isNonnull()) {
565 dR = (deltaR<double>(staCand.second->eta(), staCand.second->phi(), tkCand.second->eta(), tkCand.second->phi()));
578 return (deltaR<double>(
589 return (deltaR<double>(
617 const string category =
"GlobalMuonTrackMatcher";
636 return ROOT::Math::Similarity(
v,
m);
std::pair< const Trajectory *, reco::TrackRef > TrackCand
T getParameter(std::string const &) const
GlobalMuonTrackMatcher(const edm::ParameterSet &, const MuonServiceProxy *)
constructor
const LocalTrajectoryError & localError() const
virtual ConstReferenceCountingPointer< TangentPlane > tangentPlane(const GlobalPoint &) const =0
LocalPoint localPosition() const
std::string theOutPropagatorName
Geom::Phi< T > phi() const
const LocalTrajectoryParameters & localParameters() const
std::vector< TrackCand >::const_iterator matchOne(const TrackCand &sta, const std::vector< TrackCand > &tracks) const
choose the one tracker track which best matches a muon track
LocalError positionError() const
const SurfaceType & surface() const
std::pair< TrajectoryStateOnSurface, TrajectoryStateOnSurface > convertToTSOSMuHit(const TrackCand &, const TrackCand &) const
double match_Rmom(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
double match_dist(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
double match_R_IP(const TrackCand &, const TrackCand &) const
GlobalPoint globalPosition() const
ROOT::Math::SVector< double, 2 > AlgebraicVector2
AlgebraicVector5 vector() const
bool matchTight(const TrackCand &sta, const TrackCand &track) const
check if two tracks are compatible (less than Chi2Cut, DeltaDCut, DeltaRCut)
ROOT::Math::SVector< double, 5 > AlgebraicVector5
double match_d(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
double match(const TrackCand &sta, const TrackCand &track, int matchOption=0, int surfaceOption=1) const
const MuonServiceProxy * theService
std::pair< TrajectoryStateOnSurface, TrajectoryStateOnSurface > convertToTSOSTk(const TrackCand &, const TrackCand &) const
Log< level::Info, false > LogInfo
std::pair< TrajectoryStateOnSurface, TrajectoryStateOnSurface > convertToTSOSTkHit(const TrackCand &, const TrackCand &) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
auto const & tracks
cannot be loose
double match_D(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
GlobalVector globalMomentum() const
bool samePlane(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepStd< double, 2, 2 > > AlgebraicMatrix22
const AlgebraicSymMatrix55 & matrix() const
FreeTrajectoryState const * freeState(bool withErrors=true) const
double match_Chi2(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
double match_Rpos(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
virtual ~GlobalMuonTrackMatcher()
destructor