CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
GlobalMuonTrackMatcher Class Reference

#include <GlobalMuonTrackMatcher.h>

Public Types

typedef std::pair< const
Trajectory *, reco::TrackRef
TrackCand
 

Public Member Functions

std::pair
< TrajectoryStateOnSurface,
TrajectoryStateOnSurface
convertToTSOSMuHit (const TrackCand &, const TrackCand &) const
 
std::pair
< TrajectoryStateOnSurface,
TrajectoryStateOnSurface
convertToTSOSTk (const TrackCand &, const TrackCand &) const
 
std::pair
< TrajectoryStateOnSurface,
TrajectoryStateOnSurface
convertToTSOSTkHit (const TrackCand &, const TrackCand &) const
 
 GlobalMuonTrackMatcher (const edm::ParameterSet &, const MuonServiceProxy *)
 constructor More...
 
double match (const TrackCand &sta, const TrackCand &track, int matchOption=0, int surfaceOption=1) const
 
std::vector< TrackCandmatch (const TrackCand &sta, const std::vector< TrackCand > &tracks) const
 choose all tracks with a matching-chi2 less than Chi2Cut More...
 
double match_Chi2 (const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
 
double match_D (const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
 
double match_d (const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
 
double match_dist (const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
 
double match_R_IP (const TrackCand &, const TrackCand &) const
 
double match_Rmom (const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
 
double match_Rpos (const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) 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 More...
 
bool matchTight (const TrackCand &sta, const TrackCand &track) const
 check if two tracks are compatible (less than Chi2Cut, DeltaDCut, DeltaRCut) More...
 
bool samePlane (const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
 
virtual ~GlobalMuonTrackMatcher ()
 destructor More...
 

Private Attributes

double theChi2_1
 
double theChi2_2
 
double theChi2_3
 
double theDeltaD_1
 
double theDeltaD_2
 
double theDeltaD_3
 
double theDeltaR_1
 
double theDeltaR_2
 
double theDeltaR_3
 
double theEta_threshold
 
double theLocChi2
 
double theMinP
 
double theMinPt
 
std::string theOutPropagatorName
 
double thePt_threshold1
 
double thePt_threshold2
 
double theQual_1
 
double theQual_2
 
double theQual_3
 
const MuonServiceProxytheService
 

Detailed Description

Match a standalone muon track with the most compatible tracker tracks in a TrackCollection. GlobalMuonTrackMatcher is used during global muon reconstruction to check the compatability of a tracker track with a standalone muon track. The compatability is determined on a chi2 comparison, of the local parameters of the two corresponding TrajectoryStates on the surface of the innermost muon measurement for momentum below a threshold and above this, with the position and direction parameters on the mentioned surface. If the comparison of local parameters fails to yield any matches, then it makes a comparison of the TSOS local direction.

Date:
2010/05/17 09:44:29
Revision:
1.12
Author
Edwin Antillon Purdue University
Chang Liu Purdue University
Adam Everett Purdue University
Norbert Neumeister Purdue University

Definition at line 39 of file GlobalMuonTrackMatcher.h.

Member Typedef Documentation

Definition at line 43 of file GlobalMuonTrackMatcher.h.

Constructor & Destructor Documentation

GlobalMuonTrackMatcher::GlobalMuonTrackMatcher ( const edm::ParameterSet par,
const MuonServiceProxy service 
)

constructor

Definition at line 52 of file GlobalMuonTrackMatcher.cc.

References edm::ParameterSet::getParameter(), theChi2_1, theChi2_2, theChi2_3, theDeltaD_1, theDeltaD_2, theDeltaD_3, theDeltaR_1, theDeltaR_2, theDeltaR_3, theEta_threshold, theLocChi2, theMinP, theMinPt, theOutPropagatorName, thePt_threshold1, thePt_threshold2, theQual_1, theQual_2, and theQual_3.

53  :
54  theService(service) {
55  theMinP = par.getParameter<double>("MinP");
56  theMinPt = par.getParameter<double>("MinPt");
57  thePt_threshold1 = par.getParameter<double>("Pt_threshold1");
58  thePt_threshold2 = par.getParameter<double>("Pt_threshold2");
59  theEta_threshold= par.getParameter<double>("Eta_threshold");
60  theChi2_1= par.getParameter<double>("Chi2Cut_1");
61  theChi2_2= par.getParameter<double>("Chi2Cut_2");
62  theChi2_3= par.getParameter<double>("Chi2Cut_3");
63  theLocChi2= par.getParameter<double>("LocChi2Cut");
64  theDeltaD_1= par.getParameter<double>("DeltaDCut_1");
65  theDeltaD_2= par.getParameter<double>("DeltaDCut_2");
66  theDeltaD_3= par.getParameter<double>("DeltaDCut_3");
67  theDeltaR_1= par.getParameter<double>("DeltaRCut_1");
68  theDeltaR_2= par.getParameter<double>("DeltaRCut_2");
69  theDeltaR_3= par.getParameter<double>("DeltaRCut_3");
70  theQual_1= par.getParameter<double>("Quality_1");
71  theQual_2= par.getParameter<double>("Quality_2");
72  theQual_3= par.getParameter<double>("Quality_3");
73  theOutPropagatorName = par.getParameter<string>("Propagator");
74 
75 }
T getParameter(std::string const &) const
const MuonServiceProxy * theService
GlobalMuonTrackMatcher::~GlobalMuonTrackMatcher ( )
virtual

destructor

Definition at line 81 of file GlobalMuonTrackMatcher.cc.

81  {
82 
83 }

Member Function Documentation

std::pair< TrajectoryStateOnSurface, TrajectoryStateOnSurface > GlobalMuonTrackMatcher::convertToTSOSMuHit ( const TrackCand staCand,
const TrackCand tkCand 
) const

Definition at line 425 of file GlobalMuonTrackMatcher.cc.

References python.rootplot.argparse::category, relativeConstraints::empty, TrajectoryStateOnSurface::freeState(), TrajectoryStateOnSurface::globalPosition(), trajectoryStateTransform::innerStateOnSurface(), TrajectoryStateOnSurface::isValid(), LogTrace, mag(), trajectoryStateTransform::outerStateOnSurface(), theMinP, theMinPt, theOutPropagatorName, and theService.

Referenced by match(), matchOne(), and matchTight().

426  {
427 
428  const string category = "GlobalMuonTrackMatcher";
430  TransientTrack muTT(*staCand.second,&*theService->magneticField(),theService->trackingGeometry());
431  TrajectoryStateOnSurface innerMuTSOS = muTT.innermostMeasurementState();
432  TrajectoryStateOnSurface outerTkTsos,innerTkTsos;
433  if ( tkCand.second.isNonnull() ) {
434  // make sure the tracker track has enough momentum to reach the muon chambers
435  if ( !(tkCand.second->p() < theMinP || tkCand.second->pt() < theMinPt ) ) {
436  TrajectoryStateOnSurface innerTkTsos;
437 
438  outerTkTsos = trajectoryStateTransform::outerStateOnSurface(*tkCand.second,*theService->trackingGeometry(),&*theService->magneticField());
439  innerTkTsos = trajectoryStateTransform::innerStateOnSurface(*tkCand.second,*theService->trackingGeometry(),&*theService->magneticField());
440  // for cosmics, outer-most referst to last traversed layer
441  if ( (innerMuTSOS.globalPosition() - outerTkTsos.globalPosition()).mag() > (innerMuTSOS.globalPosition() - innerTkTsos.globalPosition()).mag() )
442  outerTkTsos = innerTkTsos;
443 
444  }
445  }
446 
447  if ( !innerMuTSOS.isValid() || !outerTkTsos.isValid() ) {
448  LogTrace(category) << "A TSOS validity problem! MuTSOS " << innerMuTSOS.isValid() << " TkTSOS " << outerTkTsos.isValid();
449  return pair<TrajectoryStateOnSurface,TrajectoryStateOnSurface>(empty,empty);
450  }
451 
452  const Surface& refSurface = innerMuTSOS.surface();
453  TrajectoryStateOnSurface tkAtMu = theService->propagator(theOutPropagatorName)->propagate(*outerTkTsos.freeState(),refSurface);
454 
455  if ( !tkAtMu.isValid() ) {
456  LogTrace(category) << "Could not propagate Muon and Tracker track to the same muon hit surface!";
457  return pair<TrajectoryStateOnSurface,TrajectoryStateOnSurface>(empty,empty);
458  }
459 
460  return pair<TrajectoryStateOnSurface,TrajectoryStateOnSurface>(innerMuTSOS, tkAtMu);
461 
462 }
TrajectoryStateOnSurface innerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
GlobalPoint globalPosition() const
FreeTrajectoryState * freeState(bool withErrors=true) const
#define LogTrace(id)
const MuonServiceProxy * theService
TrajectoryStateOnSurface outerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field)
std::pair< TrajectoryStateOnSurface, TrajectoryStateOnSurface > GlobalMuonTrackMatcher::convertToTSOSTk ( const TrackCand staCand,
const TrackCand tkCand 
) const

Definition at line 368 of file GlobalMuonTrackMatcher.cc.

References python.rootplot.argparse::category, relativeConstraints::empty, TrajectoryStateOnSurface::isValid(), LogTrace, trajectoryStateTransform::outerStateOnSurface(), samePlane(), TrajectoryStateOnSurface::surface(), theMinP, theMinPt, theOutPropagatorName, and theService.

369  {
370 
371  const string category = "GlobalMuonTrackMatcher";
372 
374 
375  TransientTrack muTT(*staCand.second,&*theService->magneticField(),theService->trackingGeometry());
376  TrajectoryStateOnSurface impactMuTSOS = muTT.impactPointState();
377 
378  TrajectoryStateOnSurface outerTkTsos;
379  if (tkCand.second.isNonnull()) {
380  // make sure the tracker track has enough momentum to reach the muon chambers
381  if ( !(tkCand.second->p() < theMinP || tkCand.second->pt() < theMinPt )) {
382 
383  outerTkTsos = trajectoryStateTransform::outerStateOnSurface(*tkCand.second,*theService->trackingGeometry(),&*theService->magneticField());
384  }
385  }
386 
387  if ( !impactMuTSOS.isValid() || !outerTkTsos.isValid() ) return pair<TrajectoryStateOnSurface,TrajectoryStateOnSurface>(empty,empty);
388 
389  // define StateOnTrackerBound object
390  StateOnTrackerBound fromInside(&*theService->propagator(theOutPropagatorName));
391 
392  // extrapolate to outer tracker surface
393  TrajectoryStateOnSurface tkTsosFromMu = fromInside(impactMuTSOS);
394  TrajectoryStateOnSurface tkTsosFromTk = fromInside(outerTkTsos);
395 
396  if ( !samePlane(tkTsosFromMu,tkTsosFromTk) ) {
397  // propagate tracker track to same surface as muon
398  bool same1, same2;
399  TrajectoryStateOnSurface newTkTsosFromTk, newTkTsosFromMu;
400  if ( tkTsosFromMu.isValid() ) newTkTsosFromTk = theService->propagator(theOutPropagatorName)->propagate(outerTkTsos,tkTsosFromMu.surface());
401  same1 = samePlane(newTkTsosFromTk,tkTsosFromMu);
402  LogTrace(category) << "Propagating to same tracker surface (Mu):" << same1;
403  if ( !same1 ) {
404  if ( tkTsosFromTk.isValid() ) newTkTsosFromMu = theService->propagator(theOutPropagatorName)->propagate(impactMuTSOS,tkTsosFromTk.surface());
405  same2 = samePlane(newTkTsosFromMu,tkTsosFromTk);
406  LogTrace(category) << "Propagating to same tracker surface (Tk):" << same2;
407  }
408  if (same1) tkTsosFromTk = newTkTsosFromTk;
409  else if (same2) tkTsosFromMu = newTkTsosFromMu;
410  else {
411  LogTrace(category) << "Could not propagate Muon and Tracker track to the same tracker bound!";
412  return pair<TrajectoryStateOnSurface,TrajectoryStateOnSurface>(empty, empty);
413  }
414  }
415 
416  return pair<TrajectoryStateOnSurface,TrajectoryStateOnSurface>(tkTsosFromMu, tkTsosFromTk);
417 
418 }
const SurfaceType & surface() const
#define LogTrace(id)
const MuonServiceProxy * theService
TrajectoryStateOnSurface outerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field)
bool samePlane(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
std::pair< TrajectoryStateOnSurface, TrajectoryStateOnSurface > GlobalMuonTrackMatcher::convertToTSOSTkHit ( const TrackCand staCand,
const TrackCand tkCand 
) const

Definition at line 469 of file GlobalMuonTrackMatcher.cc.

References python.rootplot.argparse::category, relativeConstraints::empty, TrajectoryStateOnSurface::globalPosition(), trajectoryStateTransform::innerStateOnSurface(), TrajectoryStateOnSurface::isValid(), LogTrace, mag(), trajectoryStateTransform::outerStateOnSurface(), TrajectoryStateOnSurface::surface(), theMinP, theMinPt, theOutPropagatorName, and theService.

Referenced by match().

470  {
471 
472  const string category = "GlobalMuonTrackMatcher";
473 
475 
476  TransientTrack muTT(*staCand.second,&*theService->magneticField(),theService->trackingGeometry());
477  TrajectoryStateOnSurface impactMuTSOS = muTT.impactPointState();
478  TrajectoryStateOnSurface innerMuTSOS = muTT.innermostMeasurementState();
479 
480  TrajectoryStateOnSurface outerTkTsos,innerTkTsos;
481  if ( tkCand.second.isNonnull() ) {
482  // make sure the tracker track has enough momentum to reach the muon chambers
483  if ( !(tkCand.second->p() < theMinP || tkCand.second->pt() < theMinPt )) {
484 
485  outerTkTsos = trajectoryStateTransform::outerStateOnSurface(*tkCand.second,*theService->trackingGeometry(),&*theService->magneticField());
486  innerTkTsos = trajectoryStateTransform::innerStateOnSurface(*tkCand.second,*theService->trackingGeometry(),&*theService->magneticField());
487 
488  // for cosmics, outer-most referst to last traversed layer
489  if ( (innerMuTSOS.globalPosition() - outerTkTsos.globalPosition()).mag() > (innerMuTSOS.globalPosition() - innerTkTsos.globalPosition()).mag() )
490  outerTkTsos = innerTkTsos;
491 
492  }
493  }
494 
495  if ( !impactMuTSOS.isValid() || !outerTkTsos.isValid() ) {
496  LogTrace(category) << "A TSOS validity problem! MuTSOS " << impactMuTSOS.isValid() << " TkTSOS " << outerTkTsos.isValid();
497  return pair<TrajectoryStateOnSurface,TrajectoryStateOnSurface>(empty,empty);
498  }
499 
500  const Surface& refSurface = outerTkTsos.surface();
501  TrajectoryStateOnSurface muAtTk = theService->propagator(theOutPropagatorName)->propagate(*impactMuTSOS.freeState(),refSurface);
502 
503  if ( !muAtTk.isValid() ) {
504  LogTrace(category) << "Could not propagate Muon and Tracker track to the same tracker hit surface!";
505  return pair<TrajectoryStateOnSurface,TrajectoryStateOnSurface>(empty,empty);
506  }
507 
508  return pair<TrajectoryStateOnSurface,TrajectoryStateOnSurface>(muAtTk, outerTkTsos);
509 
510 }
TrajectoryStateOnSurface innerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
GlobalPoint globalPosition() const
const SurfaceType & surface() const
#define LogTrace(id)
const MuonServiceProxy * theService
TrajectoryStateOnSurface outerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field)
double GlobalMuonTrackMatcher::match ( const TrackCand sta,
const TrackCand track,
int  matchOption = 0,
int  surfaceOption = 1 
) const

check if two tracks are compatible matchOption: 0 = chi2, 1 = distance, 2 = deltaR surfaceOption: 0 = outermost tracker surface, 1 = innermost muon system surface

Definition at line 114 of file GlobalMuonTrackMatcher.cc.

References convertToTSOSMuHit(), convertToTSOSTkHit(), match_Chi2(), match_d(), match_dist(), and match_Rpos().

Referenced by GlobalCosmicMuonTrajectoryBuilder::match(), GlobalTrackQualityProducer::produce(), GlobalMuonTrajectoryBuilder::trajectories(), and L3MuonTrajectoryBuilder::trajectories().

117  {
118 
119  std::pair<TrajectoryStateOnSurface, TrajectoryStateOnSurface> tsosPair;
120  if ( surfaceOption == 0 ) tsosPair = convertToTSOSMuHit(sta,track);
121  if ( surfaceOption == 1 ) tsosPair = convertToTSOSTkHit(sta,track);
122  if ( surfaceOption != 0 && surfaceOption != 1 ) return -1.0;
123 
124  if ( matchOption == 0 ) {
125  // chi^2
126  return match_Chi2(tsosPair.first,tsosPair.second);
127  }
128  else if ( matchOption == 1 ) {
129  // distance
130  return match_d(tsosPair.first,tsosPair.second);
131  }
132  else if ( matchOption == 2 ) {
133  // deltaR
134  return match_Rpos(tsosPair.first,tsosPair.second);
135  }
136  else if ( matchOption == 3 ) {
137  return match_dist(tsosPair.first,tsosPair.second);
138  }
139  else {
140  return -1.0;
141  }
142 }
std::pair< TrajectoryStateOnSurface, TrajectoryStateOnSurface > convertToTSOSTkHit(const TrackCand &, const TrackCand &) const
std::pair< TrajectoryStateOnSurface, TrajectoryStateOnSurface > convertToTSOSMuHit(const TrackCand &, const TrackCand &) const
double match_d(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
double match_Chi2(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
double match_dist(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
double match_Rpos(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
vector< GlobalMuonTrackMatcher::TrackCand > GlobalMuonTrackMatcher::match ( const TrackCand sta,
const std::vector< TrackCand > &  tracks 
) const

choose all tracks with a matching-chi2 less than Chi2Cut

Definition at line 183 of file GlobalMuonTrackMatcher.cc.

References python.rootplot.argparse::category, convertToTSOSMuHit(), SiPixelRawToDigiRegional_cfi::deltaPhi, deltaR(), PV3DBase< T, PVType, FrameType >::eta(), TrajectoryStateOnSurface::globalPosition(), cuy::ii, TrajectoryStateOnSurface::isValid(), findQualityFiles::jj, LogTrace, match_Chi2(), match_d(), match_dist(), match_Rpos(), PV3DBase< T, PVType, FrameType >::phi(), query::result, theChi2_1, theChi2_2, theDeltaD_1, theDeltaD_2, theDeltaR_1, theDeltaR_2, theEta_threshold, theLocChi2, thePt_threshold1, thePt_threshold2, theQual_1, theQual_2, and theQual_3.

184  {
185  const string category = "GlobalMuonTrackMatcher";
186 
187  vector<TrackCand> result;
188 
189  if ( tracks.empty() ) return result;
190 
191  typedef std::pair<TrackCand, TrajectoryStateOnSurface> TrackCandWithTSOS;
192  vector<TrackCandWithTSOS> cands;
193  int iiTk = 1;
194  TrajectoryStateOnSurface muonTSOS;
195 
196  LogTrace(category) << " ***" << endl << "STA Muon pT "<< sta.second->pt();
197  LogTrace(category) << " Tk in Region " << tracks.size() << endl;
198 
199  for (vector<TrackCand>::const_iterator is = tracks.begin(); is != tracks.end(); ++is,iiTk++) {
200  // propagate to a common surface
201  std::pair<TrajectoryStateOnSurface, TrajectoryStateOnSurface> tsosPair = convertToTSOSMuHit(sta,*is);
202  LogTrace(category) << " Tk " << iiTk << " of " << tracks.size() << " ConvertToMuHitSurface muon isValid " << tsosPair.first.isValid() << " tk isValid " << tsosPair.second.isValid() << endl;
203  if(tsosPair.first.isValid()) muonTSOS = tsosPair.first;
204  cands.push_back(TrackCandWithTSOS(*is,tsosPair.second));
205  }
206 
207  // initialize variables
208  double min_chisq = 999999;
209  double min_d = 999999;
210  double min_de= 999999;
211  double min_r_pos = 999999;
212  std::vector<bool> passes(cands.size(),false);
213  int jj=0;
214 
215  int iTkCand = 1;
216  for (vector<TrackCandWithTSOS>::const_iterator ii = cands.begin(); ii != cands.end(); ++ii,jj++,iTkCand++) {
217 
218  // tracks that are able not able propagate to a common surface
219  if(!muonTSOS.isValid() || !(*ii).second.isValid()) continue;
220 
221  // calculate matching variables
222  double distance = match_d(muonTSOS,(*ii).second);
223  double chi2 = match_Chi2(muonTSOS,(*ii).second);
224  double loc_chi2 = match_dist(muonTSOS,(*ii).second);
225  double deltaR = match_Rpos(muonTSOS,(*ii).second);
226 
227  LogTrace(category) << " iTk " << iTkCand << " of " << cands.size() << " eta " << (*ii).second.globalPosition().eta() << " phi " << (*ii).second.globalPosition().phi() << endl;
228  LogTrace(category) << " distance " << distance << " distance cut " << " " << endl;
229  LogTrace(category) << " chi2 " << chi2 << " chi2 cut " << " " << endl;
230  LogTrace(category) << " loc_chi2 " << loc_chi2 << " locChi2 cut " << " " << endl;
231  LogTrace(category) << " deltaR " << deltaR << " deltaR cut " << " " << endl;
232 
233  if( (*ii).second.globalMomentum().perp()<thePt_threshold1){
234  LogTrace(category) << " Enters a1" << endl;
235 
236  if( ( chi2>0 && fabs((*ii).second.globalMomentum().eta())<theEta_threshold && chi2<theChi2_1 ) || (distance>0 && distance/(*ii).first.second->pt()<theDeltaD_1 && loc_chi2>0 && loc_chi2<theLocChi2) ){
237  LogTrace(category) << " Passes a1" << endl;
238  result.push_back((*ii).first);
239  passes[jj]=true;
240  }
241  }
242  if( (passes[jj]==false) && (*ii).second.globalMomentum().perp()<thePt_threshold2){
243  LogTrace(category) << " Enters a2" << endl;
244  if( ( chi2>0 && chi2< theChi2_2 ) || (distance>0 && distance<theDeltaD_2) ){
245  LogTrace(category) << " Passes a2" << endl;
246  result.push_back((*ii).first);
247  passes[jj] = true;
248  }
249  }else{
250  LogTrace(category) << " Enters a3" << endl;
251  if( distance>0 && distance<theDeltaD_3 && deltaR>0 && deltaR<theDeltaR_1){
252  LogTrace(category) << " Passes a3" << endl;
253  result.push_back((*ii).first);
254  passes[jj]=true;
255  }
256  }
257 
258  if(passes[jj]){
259  if(distance<min_d) min_d = distance;
260  if(loc_chi2<min_de) min_de = loc_chi2;
261  if(deltaR<min_r_pos) min_r_pos = deltaR;
262  if(chi2<min_chisq) min_chisq = chi2;
263  }
264 
265  }
266 
267  // re-initialize mask counter
268  jj=0;
269 
270  if ( result.empty() ) {
271  LogTrace(category) << " Stage 1 returned 0 results";
272  for (vector<TrackCandWithTSOS>::const_iterator is = cands.begin(); is != cands.end(); ++is,jj++) {
273  double deltaR = match_Rpos(muonTSOS,(*is).second);
274 
275  if (muonTSOS.isValid() && (*is).second.isValid()) {
276  // check matching between tracker and muon tracks using dEta cut looser then dPhi cut
277  LogTrace(category) << " Stage 2 deltaR " << deltaR << " deltaEta " << fabs((*is).second.globalPosition().eta()-muonTSOS.globalPosition().eta()<1.5*theDeltaR_2) << " deltaPhi " << (fabs(deltaPhi((*is).second.globalPosition().phi(),muonTSOS.globalPosition().phi()))<theDeltaR_2) << endl;
278 
279  if(fabs((*is).second.globalPosition().eta()-muonTSOS.globalPosition().eta())<1.5*theDeltaR_2
280  &&fabs(deltaPhi((*is).second.globalPosition().phi(),muonTSOS.globalPosition().phi()))<theDeltaR_2){
281  result.push_back((*is).first);
282  passes[jj]=true;
283  }
284  }
285 
286  if(passes[jj]){
287  double distance = match_d(muonTSOS,(*is).second);
288  double chi2 = match_Chi2(muonTSOS,(*is).second);
289  double loc_chi2 = match_dist(muonTSOS,(*is).second);
290  if(distance<min_d) min_d = distance;
291  if(loc_chi2<min_de) min_de = loc_chi2;
292  if(deltaR<min_r_pos) min_r_pos = deltaR;
293  if(chi2<min_chisq) min_chisq = chi2;
294 
295  }
296 
297  }
298 
299  }
300 
301  for(vector<TrackCand>::const_iterator iTk=result.begin();
302  iTk != result.end(); ++iTk) {
303  LogTrace(category) << " -----" << endl
304  << "selected pt " << iTk->second->pt()
305  << " eta " << iTk->second->eta()
306  << " phi " << iTk->second->phi() << endl;
307  }
308 
309  if(result.size()<2)
310  return result;
311  else
312  result.clear();
313 
314  LogTrace(category) << " Cleaning matched candiates" << endl;
315 
316  // re-initialize mask counter
317  jj=0;
318 
319 
320  for (vector<TrackCandWithTSOS>::const_iterator is = cands.begin(); is != cands.end(); ++is,jj++) {
321 
322  if(!passes[jj]) continue;
323 
324  double distance = match_d(muonTSOS,(*is).second);
325  double chi2 = match_Chi2(muonTSOS,(*is).second);
326  //unused double loc_chi2 = match_dist(muonTSOS,(*is).second);
327  double deltaR = match_Rpos(muonTSOS,(*is).second);
328 
329  // compute quality as the relative ratio to the minimum found for each variable
330 
331  int qual = (int)(chi2/min_chisq + distance/min_d + deltaR/min_r_pos);
332  int n_min = ((chi2/min_chisq==1)?1:0) + ((distance/min_d==1)?1:0) + ((deltaR/min_r_pos==1)?1:0);
333 
334  if(n_min == 3){
335  result.push_back((*is).first);
336  }
337 
338  if(n_min == 2 && qual < theQual_1 ){
339  result.push_back((*is).first);
340  }
341 
342  if(n_min == 1 && qual < theQual_2 ){
343  result.push_back((*is).first);
344  }
345 
346  if(n_min == 0 && qual < theQual_3 ){
347  result.push_back((*is).first);
348  }
349 
350  }
351 
352  for(vector<TrackCand>::const_iterator iTk=result.begin();
353  iTk != result.end(); ++iTk) {
354  LogTrace(category) << " -----" << endl
355  << "selected pt " << iTk->second->pt()
356  << " eta " << iTk->second->eta()
357  << " phi " << iTk->second->phi() << endl;
358  }
359 
360  return result;
361 }
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
GlobalPoint globalPosition() const
int ii
Definition: cuy.py:588
std::pair< TrajectoryStateOnSurface, TrajectoryStateOnSurface > convertToTSOSMuHit(const TrackCand &, const TrackCand &) const
tuple result
Definition: query.py:137
double match_d(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
double match_Chi2(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
#define LogTrace(id)
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
tuple tracks
Definition: testEve_cfg.py:39
T eta() const
Definition: PV3DBase.h:76
double match_dist(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
double match_Rpos(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
double GlobalMuonTrackMatcher::match_Chi2 ( const TrajectoryStateOnSurface tsos1,
const TrajectoryStateOnSurface tsos2 
) const

Definition at line 541 of file GlobalMuonTrackMatcher.cc.

References python.rootplot.argparse::category, TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localParameters(), m, LocalTrajectoryError::matrix(), findQualityFiles::v, and LocalTrajectoryParameters::vector().

Referenced by match(), matchOne(), and matchTight().

542  {
543 
544  const string category = "GlobalMuonTrackMatcher";
545  //LogTrace(category) << "match_Chi2 sanity check: " << tsos1.isValid() << " " << tsos2.isValid();
546  if ( !tsos1.isValid() || !tsos2.isValid() ) return -1.;
547 
549  AlgebraicSymMatrix55 m(tsos1.localError().matrix() + tsos2.localError().matrix());
550 
551  //LogTrace(category) << "match_Chi2 vector v " << v;
552 
553  bool ierr = !m.Invert();
554 
555  if ( ierr ) {
556  edm::LogInfo(category) << "Error inverting covariance matrix";
557  return -1;
558  }
559 
560  double est = ROOT::Math::Similarity(v,m);
561 
562  //LogTrace(category) << "Chi2 " << est;
563 
564  return est;
565 
566 }
const LocalTrajectoryParameters & localParameters() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
AlgebraicVector5 vector() const
const AlgebraicSymMatrix55 & matrix() const
const LocalTrajectoryError & localError() const
ROOT::Math::SVector< double, 5 > AlgebraicVector5
double GlobalMuonTrackMatcher::match_D ( const TrajectoryStateOnSurface sta,
const TrajectoryStateOnSurface tk 
) const

Definition at line 619 of file GlobalMuonTrackMatcher.cc.

References TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::isValid(), and mag().

Referenced by samePlane().

620  {
621 
622  if ( !sta.isValid() || !tk.isValid() ) return -1;
623  return (sta.globalPosition() - tk.globalPosition()).mag();
624 
625 }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
GlobalPoint globalPosition() const
double GlobalMuonTrackMatcher::match_d ( const TrajectoryStateOnSurface sta,
const TrajectoryStateOnSurface tk 
) const

Definition at line 632 of file GlobalMuonTrackMatcher.cc.

References TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localPosition(), and mag().

Referenced by match(), matchTight(), and samePlane().

633  {
634 
635  if ( !sta.isValid() || !tk.isValid() ) return -1;
636  return (sta.localPosition() - tk.localPosition()).mag();
637 
638 }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
double GlobalMuonTrackMatcher::match_dist ( const TrajectoryStateOnSurface sta,
const TrajectoryStateOnSurface tk 
) const

Definition at line 646 of file GlobalMuonTrackMatcher.cc.

References python.rootplot.argparse::category, TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localPosition(), LogTrace, m, LocalTrajectoryError::positionError(), findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), LocalError::xx(), LocalError::xy(), PV3DBase< T, PVType, FrameType >::y(), and LocalError::yy().

Referenced by match().

647  {
648 
649  const string category = "GlobalMuonTrackMatcher";
650 
651  if ( !sta.isValid() || !tk.isValid() ) return -1;
652 
654  m(0,0) = tk.localError().positionError().xx() + sta.localError().positionError().xx();
655  m(1,0) = m(0,1) = tk.localError().positionError().xy() + sta.localError().positionError().xy();
656  m(1,1) = tk.localError().positionError().yy() + sta.localError().positionError().yy();
657 
659  v[0] = tk.localPosition().x() - sta.localPosition().x();
660  v[1] = tk.localPosition().y() - sta.localPosition().y();
661 
662  if ( !m.Invert() ) {
663  LogTrace(category) << "Error inverting local matrix ";
664  return -1;
665  }
666 
667  return ROOT::Math::Similarity(v,m);
668 
669 }
float xx() const
Definition: LocalError.h:24
T y() const
Definition: PV3DBase.h:63
LocalError positionError() const
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepStd< double, 2, 2 > > AlgebraicMatrix22
float xy() const
Definition: LocalError.h:25
float yy() const
Definition: LocalError.h:26
const LocalTrajectoryError & localError() const
#define LogTrace(id)
T x() const
Definition: PV3DBase.h:62
ROOT::Math::SVector< double, 2 > AlgebraicVector2
double GlobalMuonTrackMatcher::match_R_IP ( const TrackCand staCand,
const TrackCand tkCand 
) const

Definition at line 573 of file GlobalMuonTrackMatcher.cc.

References PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR.

574  {
575 
576  double dR = 99.0;
577  if (tkCand.second.isNonnull()) {
578  dR = (deltaR<double>(staCand.second->eta(),staCand.second->phi(),
579  tkCand.second->eta(),tkCand.second->phi()));
580  }
581 
582  return dR;
583 
584 }
double GlobalMuonTrackMatcher::match_Rmom ( const TrajectoryStateOnSurface sta,
const TrajectoryStateOnSurface tk 
) const

Definition at line 591 of file GlobalMuonTrackMatcher.cc.

References PV3DBase< T, PVType, FrameType >::eta(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::isValid(), and PV3DBase< T, PVType, FrameType >::phi().

592  {
593 
594  if( !sta.isValid() || !tk.isValid() ) return -1;
595  return (deltaR<double>(sta.globalMomentum().eta(),sta.globalMomentum().phi(),
596  tk.globalMomentum().eta(),tk.globalMomentum().phi()));
597 
598 }
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T eta() const
Definition: PV3DBase.h:76
GlobalVector globalMomentum() const
double GlobalMuonTrackMatcher::match_Rpos ( const TrajectoryStateOnSurface sta,
const TrajectoryStateOnSurface tk 
) const

Definition at line 605 of file GlobalMuonTrackMatcher.cc.

References PV3DBase< T, PVType, FrameType >::eta(), TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::isValid(), and PV3DBase< T, PVType, FrameType >::phi().

Referenced by match().

606  {
607 
608  if ( !sta.isValid() || !tk.isValid() ) return -1;
609  return (deltaR<double>(sta.globalPosition().eta(),sta.globalPosition().phi(),
610  tk.globalPosition().eta(),tk.globalPosition().phi()));
611 
612 }
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
GlobalPoint globalPosition() const
T eta() const
Definition: PV3DBase.h:76
std::vector< GlobalMuonTrackMatcher::TrackCand >::const_iterator GlobalMuonTrackMatcher::matchOne ( const TrackCand sta,
const std::vector< TrackCand > &  tracks 
) const

choose the one tracker track which best matches a muon track

Definition at line 150 of file GlobalMuonTrackMatcher.cc.

References convertToTSOSMuHit(), match_Chi2(), and query::result.

151  {
152 
153  if ( tracks.empty() ) return tracks.end();
154 
155  double minChi2 = 1000.0;
156  vector<TrackCand>::const_iterator result = tracks.end();
157  for (vector<TrackCand>::const_iterator is = tracks.begin(); is != tracks.end(); ++is) {
158  // propagate to common surface
159  std::pair<TrajectoryStateOnSurface, TrajectoryStateOnSurface> tsosPair
160  = convertToTSOSMuHit(sta,*is);
161 
162  // calculate chi^2 of local track parameters
163  double chi2 = match_Chi2(tsosPair.first,tsosPair.second);
164  if ( chi2 > 0. && chi2 <= minChi2 ) {
165  minChi2 = chi2;
166  result = is;
167  }
168 
169  }
170 
171  return result;
172 
173 }
std::pair< TrajectoryStateOnSurface, TrajectoryStateOnSurface > convertToTSOSMuHit(const TrackCand &, const TrackCand &) const
tuple result
Definition: query.py:137
double match_Chi2(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
tuple tracks
Definition: testEve_cfg.py:39
bool GlobalMuonTrackMatcher::matchTight ( const TrackCand sta,
const TrackCand track 
) const

check if two tracks are compatible (less than Chi2Cut, DeltaDCut, DeltaRCut)

Definition at line 90 of file GlobalMuonTrackMatcher.cc.

References convertToTSOSMuHit(), match_Chi2(), match_d(), theChi2_2, and theDeltaD_2.

Referenced by GlobalTrackQualityProducer::produce().

91  {
92 
93  std::pair<TrajectoryStateOnSurface, TrajectoryStateOnSurface> tsosPair
94  = convertToTSOSMuHit(sta,track);
95 
96  double chi2 = match_Chi2(tsosPair.first,tsosPair.second);
97  if ( chi2 > 0. && chi2 < theChi2_2 ) return true;
98 
99  double distance = match_d(tsosPair.first,tsosPair.second);
100  if ( distance > 0. && distance < theDeltaD_2 ) return true;
101 
102  //double deltaR = match_Rpos(tsosPair.first,tsosPair.second);
103  //if ( deltaR > 0. && deltaR < theDeltaR_3 ) return true;
104 
105  return false;
106 
107 }
std::pair< TrajectoryStateOnSurface, TrajectoryStateOnSurface > convertToTSOSMuHit(const TrackCand &, const TrackCand &) const
double match_d(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
double match_Chi2(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
bool GlobalMuonTrackMatcher::samePlane ( const TrajectoryStateOnSurface tsos1,
const TrajectoryStateOnSurface tsos2 
) const

Definition at line 517 of file GlobalMuonTrackMatcher.cc.

References TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localPosition(), match_D(), match_d(), p1, p2, TrajectoryStateOnSurface::surface(), and Surface::tangentPlane().

Referenced by convertToTSOSTk().

518  {
519 
520  if ( !tsos1.isValid() || !tsos2.isValid() ) return false;
521 
522  if ( fabs(match_D(tsos1,tsos2) - match_d(tsos1,tsos2)) > 0.1 ) return false;
523 
524  const float maxtilt = 0.999;
525  const float maxdist = 0.01; // in cm
526 
529 
530  bool returnValue = ( (fabs(p1->normalVector().dot(p2->normalVector())) > maxtilt) || (fabs((p1->toLocal(p2->position())).z()) < maxdist) ) ? true : false;
531 
532  return returnValue;
533 
534 }
const SurfaceType & surface() const
double match_d(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
double match_D(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
double p2[4]
Definition: TauolaWrapper.h:90
virtual ReferenceCountingPointer< TangentPlane > tangentPlane(const GlobalPoint &) const =0
double p1[4]
Definition: TauolaWrapper.h:89

Member Data Documentation

double GlobalMuonTrackMatcher::theChi2_1
private

Definition at line 92 of file GlobalMuonTrackMatcher.h.

Referenced by GlobalMuonTrackMatcher(), and match().

double GlobalMuonTrackMatcher::theChi2_2
private

Definition at line 93 of file GlobalMuonTrackMatcher.h.

Referenced by GlobalMuonTrackMatcher(), match(), and matchTight().

double GlobalMuonTrackMatcher::theChi2_3
private

Definition at line 94 of file GlobalMuonTrackMatcher.h.

Referenced by GlobalMuonTrackMatcher().

double GlobalMuonTrackMatcher::theDeltaD_1
private

Definition at line 96 of file GlobalMuonTrackMatcher.h.

Referenced by GlobalMuonTrackMatcher(), and match().

double GlobalMuonTrackMatcher::theDeltaD_2
private

Definition at line 97 of file GlobalMuonTrackMatcher.h.

Referenced by GlobalMuonTrackMatcher(), match(), and matchTight().

double GlobalMuonTrackMatcher::theDeltaD_3
private

Definition at line 98 of file GlobalMuonTrackMatcher.h.

Referenced by GlobalMuonTrackMatcher().

double GlobalMuonTrackMatcher::theDeltaR_1
private

Definition at line 99 of file GlobalMuonTrackMatcher.h.

Referenced by GlobalMuonTrackMatcher(), and match().

double GlobalMuonTrackMatcher::theDeltaR_2
private

Definition at line 100 of file GlobalMuonTrackMatcher.h.

Referenced by GlobalMuonTrackMatcher(), and match().

double GlobalMuonTrackMatcher::theDeltaR_3
private

Definition at line 101 of file GlobalMuonTrackMatcher.h.

Referenced by GlobalMuonTrackMatcher().

double GlobalMuonTrackMatcher::theEta_threshold
private

Definition at line 91 of file GlobalMuonTrackMatcher.h.

Referenced by GlobalMuonTrackMatcher(), and match().

double GlobalMuonTrackMatcher::theLocChi2
private

Definition at line 95 of file GlobalMuonTrackMatcher.h.

Referenced by GlobalMuonTrackMatcher(), and match().

double GlobalMuonTrackMatcher::theMinP
private
double GlobalMuonTrackMatcher::theMinPt
private
std::string GlobalMuonTrackMatcher::theOutPropagatorName
private
double GlobalMuonTrackMatcher::thePt_threshold1
private

Definition at line 89 of file GlobalMuonTrackMatcher.h.

Referenced by GlobalMuonTrackMatcher(), and match().

double GlobalMuonTrackMatcher::thePt_threshold2
private

Definition at line 90 of file GlobalMuonTrackMatcher.h.

Referenced by GlobalMuonTrackMatcher(), and match().

double GlobalMuonTrackMatcher::theQual_1
private

Definition at line 102 of file GlobalMuonTrackMatcher.h.

Referenced by GlobalMuonTrackMatcher(), and match().

double GlobalMuonTrackMatcher::theQual_2
private

Definition at line 103 of file GlobalMuonTrackMatcher.h.

Referenced by GlobalMuonTrackMatcher(), and match().

double GlobalMuonTrackMatcher::theQual_3
private

Definition at line 104 of file GlobalMuonTrackMatcher.h.

Referenced by GlobalMuonTrackMatcher(), and match().

const MuonServiceProxy* GlobalMuonTrackMatcher::theService
private