CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GlobalMuonTrackMatcher.cc
Go to the documentation of this file.
1 
16 
17 //---------------
18 // C++ Headers --
19 //---------------
20 
21 
22 //-------------------------------
23 // Collaborating Class Headers --
24 //-------------------------------
25 
29 
35 
37 
40 
43 
45 
46 using namespace std;
47 using namespace reco;
48 
49 //
50 // constructor
51 //
53  const MuonServiceProxy* service) :
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 }
76 
77 
78 //
79 // destructor
80 //
82 
83 }
84 
85 
86 //
87 // check if two tracks are compatible with the *tight* criteria
88 //
89 bool
91  const TrackCand& track) const {
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 }
108 
109 
110 //
111 // check if two tracks are compatible
112 //
113 double
115  const TrackCand& track,
116  int matchOption,
117  int surfaceOption) const {
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 }
143 
144 
145 //
146 // choose the track from a TrackCollection which best
147 // matches a given standalone muon track
148 //
149 std::vector<GlobalMuonTrackMatcher::TrackCand>::const_iterator
151  const std::vector<TrackCand>& tracks) const {
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 }
174 
175 
176 //
177 // choose a vector of tracks from a TrackCollection that are compatible
178 // with a given standalone track. The order of checks for compatability
179 // * for low momentum: use chi2 selection
180 // * high momentum: use direction or local position
181 //
182 vector<GlobalMuonTrackMatcher::TrackCand>
184  const vector<TrackCand>& tracks) const {
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 }
362 
363 
364 //
365 // propagate the two track candidates to the tracker bound surface
366 //
367 std::pair<TrajectoryStateOnSurface,TrajectoryStateOnSurface>
369  const TrackCand& tkCand) const {
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 }
419 
420 
421 //
422 // propagate the two track candidates to the surface of the innermost muon hit
423 //
424 std::pair<TrajectoryStateOnSurface,TrajectoryStateOnSurface>
426  const TrackCand& tkCand) const {
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 }
463 
464 
465 //
466 // propagate the two track candidates to the surface of the outermost tracker hit
467 //
468 std::pair<TrajectoryStateOnSurface,TrajectoryStateOnSurface>
470  const TrackCand& tkCand) const {
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 }
511 
512 
513 //
514 //
515 //
516 bool
518  const TrajectoryStateOnSurface& tsos2) const {
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 }
535 
536 
537 //
538 // calculate Chi^2 of two trajectory states
539 //
540 double
542  const TrajectoryStateOnSurface& tsos2) const {
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 }
567 
568 
569 //
570 // calculate Delta_R of two track candidates at the IP
571 //
572 double
574  const TrackCand& tkCand) const {
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 }
585 
586 
587 //
588 // calculate Delta_R of two trajectory states
589 //
590 double
592  const TrajectoryStateOnSurface& tk) const {
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 }
599 
600 
601 //
602 // calculate Delta_R of two trajectory states
603 //
604 double
606  const TrajectoryStateOnSurface& tk) const {
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 }
613 
614 
615 //
616 // calculate the distance in global position of two trajectory states
617 //
618 double
620  const TrajectoryStateOnSurface& tk) const {
621 
622  if ( !sta.isValid() || !tk.isValid() ) return -1;
623  return (sta.globalPosition() - tk.globalPosition()).mag();
624 
625 }
626 
627 
628 //
629 // calculate the distance in local position of two trajectory states
630 //
631 double
633  const TrajectoryStateOnSurface& tk) const {
634 
635  if ( !sta.isValid() || !tk.isValid() ) return -1;
636  return (sta.localPosition() - tk.localPosition()).mag();
637 
638 }
639 
640 
641 //
642 // calculate the chi2 of the distance in local position of two
643 // trajectory states including local errors
644 //
645 double
647  const TrajectoryStateOnSurface& tk) const {
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 }
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
T getParameter(std::string const &) const
float xx() const
Definition: LocalError.h:24
GlobalMuonTrackMatcher(const edm::ParameterSet &, const MuonServiceProxy *)
constructor
TrajectoryStateOnSurface innerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field)
const LocalTrajectoryParameters & localParameters() const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
bool matchTight(const TrackCand &sta, const TrackCand &track) const
check if two tracks are compatible (less than Chi2Cut, DeltaDCut, DeltaRCut)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T y() const
Definition: PV3DBase.h:63
GlobalPoint globalPosition() const
std::pair< TrajectoryStateOnSurface, TrajectoryStateOnSurface > convertToTSOSTkHit(const TrackCand &, const TrackCand &) const
double match_Rmom(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
int ii
Definition: cuy.py:588
double match_R_IP(const TrackCand &, const TrackCand &) const
LocalError positionError() const
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepStd< double, 2, 2 > > AlgebraicMatrix22
std::pair< TrajectoryStateOnSurface, TrajectoryStateOnSurface > convertToTSOSMuHit(const TrackCand &, const TrackCand &) const
AlgebraicVector5 vector() const
float xy() const
Definition: LocalError.h:25
const SurfaceType & surface() const
std::pair< TrajectoryStateOnSurface, TrajectoryStateOnSurface > convertToTSOSTk(const TrackCand &, const TrackCand &) const
FreeTrajectoryState * freeState(bool withErrors=true) const
float yy() const
Definition: LocalError.h:26
tuple result
Definition: query.py:137
double match_d(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
double match_Chi2(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
const AlgebraicSymMatrix55 & matrix() const
const LocalTrajectoryError & localError() const
double match(const TrackCand &sta, const TrackCand &track, int matchOption=0, int surfaceOption=1) const
double match_D(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
double p2[4]
Definition: TauolaWrapper.h:90
#define LogTrace(id)
const MuonServiceProxy * theService
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
virtual ReferenceCountingPointer< TangentPlane > tangentPlane(const GlobalPoint &) const =0
ROOT::Math::SVector< double, 5 > AlgebraicVector5
tuple tracks
Definition: testEve_cfg.py:39
TrajectoryStateOnSurface outerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field)
T eta() const
Definition: PV3DBase.h:76
double match_dist(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
std::pair< const Trajectory *, reco::TrackRef > TrackCand
double p1[4]
Definition: TauolaWrapper.h:89
double match_Rpos(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
GlobalVector globalMomentum() const
bool samePlane(const TrajectoryStateOnSurface &, const TrajectoryStateOnSurface &) const
T x() const
Definition: PV3DBase.h:62
ROOT::Math::SVector< double, 2 > AlgebraicVector2
virtual ~GlobalMuonTrackMatcher()
destructor