CMS 3D CMS Logo

PFMuonAlgo.cc
Go to the documentation of this file.
10 #include <iostream>
11 
12 
13 using namespace std;
14 using namespace reco;
15 using namespace boost;
16 
17 namespace {
18 
19  template<class T>
20  T getParameter(edm::ParameterSet const& pset, std::string && name, T && defaultValue) {
21  return pset.exists(name) ? pset.getParameter<T>(name) : defaultValue;
22  }
23 
24 }
25 
27 
28  : pfCosmicsMuonCleanedCandidates_(std::make_unique<reco::PFCandidateCollection>())
29  , pfCleanedTrackerAndGlobalMuonCandidates_(std::make_unique<reco::PFCandidateCollection>())
30  , pfFakeMuonCleanedCandidates_(std::make_unique<reco::PFCandidateCollection>())
31  , pfPunchThroughMuonCleanedCandidates_(std::make_unique<reco::PFCandidateCollection>())
32  , pfPunchThroughHadronCleanedCandidates_(std::make_unique<reco::PFCandidateCollection>())
33  , pfAddedMuonCandidates_(std::make_unique<reco::PFCandidateCollection>())
34 
35  , maxDPtOPt_(getParameter<double>(iConfig, "maxDPtOPt", 1.0))
36  , minTrackerHits_(getParameter<int>(iConfig, "minTrackerHits", 8))
37  , minPixelHits_(getParameter<int>(iConfig, "minPixelHits", 1))
38  , trackQuality_(reco::TrackBase::qualityByName(getParameter<std::string>(iConfig, "trackQuality", "highPurity")))
39  , errorCompScale_(getParameter<double>(iConfig, "ptErrorScale", 4.0))
40  , eventFractionCleaning_(getParameter<double>(iConfig, "eventFractionForCleaning", 0.75))
41  , dzPV_(getParameter<double>(iConfig, "dzPV", 0.2))
42  , postCleaning_(getParameter<bool>(iConfig, "postMuonCleaning", false)) // disable by default (for HLT)
43  , minPostCleaningPt_(getParameter<double>(iConfig, "minPtForPostCleaning", 20.))
44  , eventFactorCosmics_(getParameter<double>(iConfig, "eventFactorForCosmics", 10.))
45  , metSigForCleaning_(getParameter<double>(iConfig, "metSignificanceForCleaning", 3.))
46  , metSigForRejection_(getParameter<double>(iConfig, "metSignificanceForRejection", 4.))
47  , metFactorCleaning_(getParameter<double>(iConfig, "metFactorForCleaning", 4.))
48  , eventFractionRejection_(getParameter<double>(iConfig, "eventFractionForRejection", 0.75))
49  , metFactorRejection_(getParameter<double>(iConfig, "metFactorForRejection", 4.))
50  , metFactorHighEta_(getParameter<double>(iConfig, "metFactorForHighEta", 4.))
51  , ptFactorHighEta_(getParameter<double>(iConfig, "ptFactorForHighEta", 2.))
52  , metFactorFake_(getParameter<double>(iConfig, "metFactorForFakes", 4.))
53  , minPunchThroughMomentum_(getParameter<double>(iConfig, "minMomentumForPunchThrough", 100.))
54  , minPunchThroughEnergy_(getParameter<double>(iConfig, "minEnergyForPunchThrough", 100.))
55  , punchThroughFactor_(getParameter<double>(iConfig, "punchThroughFactor", 3.))
56  , punchThroughMETFactor_(getParameter<double>(iConfig, "punchThroughMETFactor", 4.))
57  , cosmicRejDistance_(getParameter<double>(iConfig, "cosmicRejectionDistance", 1.))
58 {}
59 
60 
61 
62 
63 
64 
65 bool
67 
68  const auto* eltTrack = dynamic_cast<const reco::PFBlockElementTrack*>(&elt);
69 
70  assert ( eltTrack );
71  reco::MuonRef muonRef = eltTrack->muonRef();
72 
73  return isMuon(muonRef);
74 
75 }
76 
77 bool
79 
80 
81  const reco::PFBlockElementTrack* eltTrack
82  = dynamic_cast<const reco::PFBlockElementTrack*>(&elt);
83 
84 
85 
86  assert ( eltTrack );
87 
88 
89  reco::MuonRef muonRef = eltTrack->muonRef();
90 
91 
92  return isLooseMuon(muonRef);
93 
94 }
95 
96 
97 bool
99 
100  const reco::PFBlockElementTrack* eltTrack
101  = dynamic_cast<const reco::PFBlockElementTrack*>(&elt);
102 
103  assert ( eltTrack );
104  reco::MuonRef muonRef = eltTrack->muonRef();
105 
106  return isGlobalTightMuon(muonRef);
107 
108 }
109 
110 bool
112 
113  const reco::PFBlockElementTrack* eltTrack
114  = dynamic_cast<const reco::PFBlockElementTrack*>(&elt);
115 
116  assert ( eltTrack );
117  reco::MuonRef muonRef = eltTrack->muonRef();
118 
119  return isGlobalLooseMuon(muonRef);
120 
121 }
122 
123 bool
125 
126  const reco::PFBlockElementTrack* eltTrack
127  = dynamic_cast<const reco::PFBlockElementTrack*>(&elt);
128 
129  assert ( eltTrack );
130  reco::MuonRef muonRef = eltTrack->muonRef();
131 
132  return isTrackerTightMuon(muonRef);
133 
134 }
135 
136 bool
138 
139  const reco::PFBlockElementTrack* eltTrack
140  = dynamic_cast<const reco::PFBlockElementTrack*>(&elt);
141 
142  assert ( eltTrack );
143  reco::MuonRef muonRef = eltTrack->muonRef();
144 
145  return isIsolatedMuon(muonRef);
146 
147 }
148 
149 bool
151 
152  return isGlobalTightMuon(muonRef) || isTrackerTightMuon(muonRef) || isIsolatedMuon(muonRef);
153 }
154 
155 bool
157 
158  return (isGlobalLooseMuon(muonRef) || isTrackerLooseMuon(muonRef));
159 
160 }
161 
162 bool
164 
165  if ( !muonRef.isNonnull() ) return false;
166 
167  if ( !muonRef->isGlobalMuon() ) return false;
168  if ( !muonRef->isStandAloneMuon() ) return false;
169 
170 
171  if ( muonRef->isTrackerMuon() ) {
172 
174 
175  bool isTM2DCompatibilityTight = muon::isGoodMuon(*muonRef,muon::TM2DCompatibilityTight);
176  int nMatches = muonRef->numberOfMatches();
177  bool quality = nMatches > 2 || isTM2DCompatibilityTight;
178 
179  return result && quality;
180 
181  } else {
182 
183  reco::TrackRef standAloneMu = muonRef->standAloneMuon();
184 
185  // No tracker muon -> Request a perfect stand-alone muon, or an even better global muon
186  bool result = false;
187 
188  // Check the quality of the stand-alone muon :
189  // good chi**2 and large number of hits and good pt error
190  if ( ( standAloneMu->hitPattern().numberOfValidMuonDTHits() < 22 &&
191  standAloneMu->hitPattern().numberOfValidMuonCSCHits() < 15 ) ||
192  standAloneMu->normalizedChi2() > 10. ||
193  standAloneMu->ptError()/standAloneMu->pt() > 0.20 ) {
194  result = false;
195  } else {
196 
197  reco::TrackRef combinedMu = muonRef->combinedMuon();
198  reco::TrackRef trackerMu = muonRef->track();
199 
200  // If the stand-alone muon is good, check the global muon
201  if ( combinedMu->normalizedChi2() > standAloneMu->normalizedChi2() ) {
202  // If the combined muon is worse than the stand-alone, it
203  // means that either the corresponding tracker track was not
204  // reconstructed, or that the sta muon comes from a late
205  // pion decay (hence with a momentum smaller than the track)
206  // Take the stand-alone muon only if its momentum is larger
207  // than that of the track
208  result = standAloneMu->pt() > trackerMu->pt() ;
209  } else {
210  // If the combined muon is better (and good enough), take the
211  // global muon
212  result =
213  combinedMu->ptError()/combinedMu->pt() <
214  std::min(0.20,standAloneMu->ptError()/standAloneMu->pt());
215  }
216  }
217 
218  return result;
219  }
220 
221  return false;
222 
223 }
224 
225 bool
227 
228  if ( !muonRef.isNonnull() ) return false;
229 
230  if(!muonRef->isTrackerMuon()) return false;
231 
232  reco::TrackRef trackerMu = muonRef->track();
233  const reco::Track& track = *trackerMu;
234 
235  unsigned nTrackerHits = track.hitPattern().numberOfValidTrackerHits();
236 
237  if(nTrackerHits<=12) return false;
238 
239  bool isAllArbitrated = muon::isGoodMuon(*muonRef,muon::AllArbitrated);
240 
241  bool isTM2DCompatibilityTight = muon::isGoodMuon(*muonRef,muon::TM2DCompatibilityTight);
242 
243  if(!isAllArbitrated || !isTM2DCompatibilityTight) return false;
244 
245  if((trackerMu->ptError()/trackerMu->pt() > 0.10)){
246  //std::cout<<" PT ERROR > 10 % "<< trackerMu->pt() <<std::endl;
247  return false;
248  }
249  return true;
250 
251 }
252 
253 bool
255 
256  if ( !muonRef.isNonnull() ) return false;
257  if ( !muonRef->isGlobalMuon() ) return false;
258  if ( !muonRef->isStandAloneMuon() ) return false;
259 
260  reco::TrackRef standAloneMu = muonRef->standAloneMuon();
261  reco::TrackRef combinedMu = muonRef->combinedMuon();
262  reco::TrackRef trackerMu = muonRef->track();
263 
264  unsigned nMuonHits =
265  standAloneMu->hitPattern().numberOfValidMuonDTHits() +
266  2*standAloneMu->hitPattern().numberOfValidMuonCSCHits();
267 
268  bool quality = false;
269 
270  if ( muonRef->isTrackerMuon() ){
271 
272  bool result = combinedMu->normalizedChi2() < 100.;
273 
274  bool laststation =
276 
277  int nMatches = muonRef->numberOfMatches();
278 
279  quality = laststation && nMuonHits > 12 && nMatches > 1;
280 
281  return result && quality;
282 
283  }
284  else{
285 
286  // Check the quality of the stand-alone muon :
287  // good chi**2 and large number of hits and good pt error
288  if ( nMuonHits <=15 ||
289  standAloneMu->normalizedChi2() > 10. ||
290  standAloneMu->ptError()/standAloneMu->pt() > 0.20 ) {
291  quality = false;
292  }
293  else {
294  // If the stand-alone muon is good, check the global muon
295  if ( combinedMu->normalizedChi2() > standAloneMu->normalizedChi2() ) {
296  // If the combined muon is worse than the stand-alone, it
297  // means that either the corresponding tracker track was not
298  // reconstructed, or that the sta muon comes from a late
299  // pion decay (hence with a momentum smaller than the track)
300  // Take the stand-alone muon only if its momentum is larger
301  // than that of the track
302 
303  // Note that here we even take the standAlone if it has a smaller pT, in contrast to GlobalTight
304  if(standAloneMu->pt() > trackerMu->pt() || combinedMu->normalizedChi2()<5.) quality = true;
305  }
306  else {
307  // If the combined muon is better (and good enough), take the
308  // global muon
309  if(combinedMu->ptError()/combinedMu->pt() < std::min(0.20,standAloneMu->ptError()/standAloneMu->pt()))
310  quality = true;
311 
312  }
313  }
314  }
315 
316 
317  return quality;
318 
319 }
320 
321 
322 bool
324 
325  if ( !muonRef.isNonnull() ) return false;
326  if(!muonRef->isTrackerMuon()) return false;
327 
328  reco::TrackRef trackerMu = muonRef->track();
329 
330  if(trackerMu->ptError()/trackerMu->pt() > 0.20) return false;
331 
332  // this doesn't seem to be necessary on the small samples looked at, but keep it around as insurance
333  if(trackerMu->pt()>20.) return false;
334 
335  bool isAllArbitrated = muon::isGoodMuon(*muonRef,muon::AllArbitrated);
336  bool isTMLastStationAngTight = muon::isGoodMuon(*muonRef,muon::TMLastStationAngTight);
337 
338  bool quality = isAllArbitrated && isTMLastStationAngTight;
339 
340  return quality;
341 
342 }
343 
344 bool
346 
347 
348  if ( !muonRef.isNonnull() ) return false;
349  if ( !muonRef->isIsolationValid() ) return false;
350 
351  // Isolated Muons which are missed by standard cuts are nearly always global+tracker
352  if ( !muonRef->isGlobalMuon() ) return false;
353 
354  // If it's not a tracker muon, only take it if there are valid muon hits
355 
356  reco::TrackRef standAloneMu = muonRef->standAloneMuon();
357 
358  if ( !muonRef->isTrackerMuon() ){
359  if(standAloneMu->hitPattern().numberOfValidMuonDTHits() == 0 &&
360  standAloneMu->hitPattern().numberOfValidMuonCSCHits() ==0) return false;
361  }
362 
363  // for isolation, take the smallest pt available to reject fakes
364 
365  reco::TrackRef combinedMu = muonRef->combinedMuon();
366  double smallestMuPt = combinedMu->pt();
367 
368  if(standAloneMu->pt()<smallestMuPt) smallestMuPt = standAloneMu->pt();
369 
370  if(muonRef->isTrackerMuon())
371  {
372  reco::TrackRef trackerMu = muonRef->track();
373  if(trackerMu->pt() < smallestMuPt) smallestMuPt= trackerMu->pt();
374  }
375 
376 
377  double sumPtR03 = muonRef->isolationR03().sumPt;
378 
379  double relIso = sumPtR03/smallestMuPt;
380 
381 
382 
383 
384  if(relIso<0.1) return true;
385  else return false;
386 }
387 
388 bool
390 
391  if(!muon::isGoodMuon(*muonRef,muon::GlobalMuonPromptTight)) return false;
392 
393  if(!muonRef->isTrackerMuon()) return false;
394 
395  if(muonRef->numberOfMatches()<2) return false;
396 
397  //const reco::TrackRef& combinedMuon = muonRef->combinedMuon();
398  const reco::TrackRef& combinedMuon = muonRef->globalTrack();
399 
400  if(combinedMuon->hitPattern().numberOfValidTrackerHits()<11) return false;
401 
402  if(combinedMuon->hitPattern().numberOfValidPixelHits()==0) return false;
403 
404  if(combinedMuon->hitPattern().numberOfValidMuonHits()==0) return false;
405 
406  return true;
407 
408 }
409 
410 
411 bool
412 PFMuonAlgo::hasValidTrack(const reco::MuonRef& muonRef,bool loose) {
413  if(loose)
414  return !muonTracks(muonRef).empty();
415  else
416  return !goodMuonTracks(muonRef).empty();
417 
418 }
419 
420 
421 void
423 
424  if ( !muonRef.isNonnull() ) return;
425 
426  bool isGL = muonRef->isGlobalMuon();
427  bool isTR = muonRef->isTrackerMuon();
428  bool isST = muonRef->isStandAloneMuon();
429 
430  std::cout<<" GL: "<<isGL<<" TR: "<<isTR<<" ST: "<<isST<<std::endl;
431  std::cout<<" nMatches "<<muonRef->numberOfMatches()<<std::endl;
432 
433  if ( muonRef->isGlobalMuon() ){
434  reco::TrackRef combinedMu = muonRef->combinedMuon();
435  std::cout<<" GL, pt: " << combinedMu->pt()
436  << " +/- " << combinedMu->ptError()/combinedMu->pt()
437  << " chi**2 GBL : " << combinedMu->normalizedChi2()<<std::endl;
438  std::cout<< " Total Muon Hits : " << combinedMu->hitPattern().numberOfValidMuonHits()
439  << "/" << combinedMu->hitPattern().numberOfLostMuonHits()
440  << " DT Hits : " << combinedMu->hitPattern().numberOfValidMuonDTHits()
441  << "/" << combinedMu->hitPattern().numberOfLostMuonDTHits()
442  << " CSC Hits : " << combinedMu->hitPattern().numberOfValidMuonCSCHits()
443  << "/" << combinedMu->hitPattern().numberOfLostMuonCSCHits()
444  << " RPC Hits : " << combinedMu->hitPattern().numberOfValidMuonRPCHits()
445  << "/" << combinedMu->hitPattern().numberOfLostMuonRPCHits()<<std::endl;
446 
447  std::cout<<" # of Valid Tracker Hits "<<combinedMu->hitPattern().numberOfValidTrackerHits()<<std::endl;
448  std::cout<<" # of Valid Pixel Hits "<<combinedMu->hitPattern().numberOfValidPixelHits()<<std::endl;
449  }
450  if ( muonRef->isStandAloneMuon() ){
451  reco::TrackRef standAloneMu = muonRef->standAloneMuon();
452  std::cout<<" ST, pt: " << standAloneMu->pt()
453  << " +/- " << standAloneMu->ptError()/standAloneMu->pt()
454  << " eta : " << standAloneMu->eta()
455  << " DT Hits : " << standAloneMu->hitPattern().numberOfValidMuonDTHits()
456  << "/" << standAloneMu->hitPattern().numberOfLostMuonDTHits()
457  << " CSC Hits : " << standAloneMu->hitPattern().numberOfValidMuonCSCHits()
458  << "/" << standAloneMu->hitPattern().numberOfLostMuonCSCHits()
459  << " RPC Hits : " << standAloneMu->hitPattern().numberOfValidMuonRPCHits()
460  << "/" << standAloneMu->hitPattern().numberOfLostMuonRPCHits()
461  << " chi**2 STA : " << standAloneMu->normalizedChi2()<<std::endl;
462  }
463 
464 
465  if ( muonRef->isTrackerMuon() ){
466  reco::TrackRef trackerMu = muonRef->track();
467  const reco::Track& track = *trackerMu;
468  std::cout<<" TR, pt: " << trackerMu->pt()
469  << " +/- " << trackerMu->ptError()/trackerMu->pt()
470  << " chi**2 TR : " << trackerMu->normalizedChi2()<<std::endl;
471  std::cout<<" nTrackerHits "<<track.hitPattern().numberOfValidTrackerHits()<<std::endl;
472  std::cout<< "TMLastStationAngLoose "
473  << muon::isGoodMuon(*muonRef,muon::TMLastStationAngLoose) << std::endl
474  << "TMLastStationAngTight "
475  << muon::isGoodMuon(*muonRef,muon::TMLastStationAngTight) << std::endl
476  << "TMLastStationLoose "
477  << muon::isGoodMuon(*muonRef,muon::TMLastStationLoose) << std::endl
478  << "TMLastStationTight "
479  << muon::isGoodMuon(*muonRef,muon::TMLastStationTight) << std::endl
480  << "TMOneStationLoose "
481  << muon::isGoodMuon(*muonRef,muon::TMOneStationLoose) << std::endl
482  << "TMOneStationTight "
483  << muon::isGoodMuon(*muonRef,muon::TMOneStationTight) << std::endl
484  << "TMLastStationOptimizedLowPtLoose "
486  << "TMLastStationOptimizedLowPtTight "
488  << "TMLastStationOptimizedBarrelLowPtLoose "
490  << "TMLastStationOptimizedBarrelLowPtTight "
492  << std::endl;
493 
494  }
495 
496  std::cout<< "TM2DCompatibilityLoose "
497  << muon::isGoodMuon(*muonRef,muon::TM2DCompatibilityLoose) << std::endl
498  << "TM2DCompatibilityTight "
499  << muon::isGoodMuon(*muonRef,muon::TM2DCompatibilityTight) << std::endl;
500 
501 
502 
503  if ( muonRef->isGlobalMuon() && muonRef->isTrackerMuon() && muonRef->isStandAloneMuon() ){
504  reco::TrackRef combinedMu = muonRef->combinedMuon();
505  reco::TrackRef trackerMu = muonRef->track();
506  reco::TrackRef standAloneMu = muonRef->standAloneMuon();
507 
508  double sigmaCombined = combinedMu->ptError()/(combinedMu->pt()*combinedMu->pt());
509  double sigmaTracker = trackerMu->ptError()/(trackerMu->pt()*trackerMu->pt());
510  double sigmaStandAlone = standAloneMu->ptError()/(standAloneMu->pt()*standAloneMu->pt());
511 
512  bool combined = combinedMu->ptError()/combinedMu->pt() < 0.20;
513  bool tracker = trackerMu->ptError()/trackerMu->pt() < 0.20;
514  bool standAlone = standAloneMu->ptError()/standAloneMu->pt() < 0.20;
515 
516  double delta1 = combined && tracker ?
517  fabs(1./combinedMu->pt() -1./trackerMu->pt())
518  /sqrt(sigmaCombined*sigmaCombined + sigmaTracker*sigmaTracker) : 100.;
519  double delta2 = combined && standAlone ?
520  fabs(1./combinedMu->pt() -1./standAloneMu->pt())
521  /sqrt(sigmaCombined*sigmaCombined + sigmaStandAlone*sigmaStandAlone) : 100.;
522  double delta3 = standAlone && tracker ?
523  fabs(1./standAloneMu->pt() -1./trackerMu->pt())
524  /sqrt(sigmaStandAlone*sigmaStandAlone + sigmaTracker*sigmaTracker) : 100.;
525 
526  double delta =
527  standAloneMu->hitPattern().numberOfValidMuonDTHits()+
528  standAloneMu->hitPattern().numberOfValidMuonCSCHits() > 0 ?
529  std::min(delta3,std::min(delta1,delta2)) : std::max(delta3,std::max(delta1,delta2));
530 
531  std::cout << "delta = " << delta << " delta1 "<<delta1<<" delta2 "<<delta2<<" delta3 "<<delta3<<std::endl;
532 
533  double ratio =
534  combinedMu->ptError()/combinedMu->pt()
535  / (trackerMu->ptError()/trackerMu->pt());
536  //if ( ratio > 2. && delta < 3. ) std::cout << "ALARM ! " << ratio << ", " << delta << std::endl;
537  std::cout<<" ratio "<<ratio<<" combined mu pt "<<combinedMu->pt()<<std::endl;
538  //bool quality3 = ( combinedMu->pt() < 50. || ratio < 2. ) && delta < 3.;
539 
540 
541  }
542 
543  double sumPtR03 = muonRef->isolationR03().sumPt;
544  double emEtR03 = muonRef->isolationR03().emEt;
545  double hadEtR03 = muonRef->isolationR03().hadEt;
546  double relIsoR03 = (sumPtR03 + emEtR03 + hadEtR03)/muonRef->pt();
547  double sumPtR05 = muonRef->isolationR05().sumPt;
548  double emEtR05 = muonRef->isolationR05().emEt;
549  double hadEtR05 = muonRef->isolationR05().hadEt;
550  double relIsoR05 = (sumPtR05 + emEtR05 + hadEtR05)/muonRef->pt();
551  std::cout<<" 0.3 Radion Rel Iso: "<<relIsoR03<<" sumPt "<<sumPtR03<<" emEt "<<emEtR03<<" hadEt "<<hadEtR03<<std::endl;
552  std::cout<<" 0.5 Radion Rel Iso: "<<relIsoR05<<" sumPt "<<sumPtR05<<" emEt "<<emEtR05<<" hadEt "<<hadEtR05<<std::endl;
553  return;
554 
555 }
556 
557 
558 
559 std::vector<reco::Muon::MuonTrackTypePair> PFMuonAlgo::goodMuonTracks(const reco::MuonRef& muon,bool includeSA) {
560  return muonTracks(muon,includeSA,maxDPtOPt_);
561 }
562 
563 
564 
565 std::vector<reco::Muon::MuonTrackTypePair> PFMuonAlgo::muonTracks(const reco::MuonRef& muon,bool includeSA,double dpt) {
566 
567 
568 
569  std::vector<reco::Muon::MuonTrackTypePair> out;
570 
571 
572  if(muon->globalTrack().isNonnull() && muon->globalTrack()->pt()>0)
573  if(muon->globalTrack()->ptError()/muon->globalTrack()->pt()<dpt)
574  out.emplace_back(muon->globalTrack(),reco::Muon::CombinedTrack);
575 
576  if(muon->innerTrack().isNonnull() && muon->innerTrack()->pt()>0)
577  if(muon->innerTrack()->ptError()/muon->innerTrack()->pt()<dpt)//Here Loose!@
578  out.emplace_back(muon->innerTrack(),reco::Muon::InnerTrack);
579 
580  bool pickyExists=false;
581  double pickyDpt=99999.;
582  if(muon->pickyTrack().isNonnull() && muon->pickyTrack()->pt()>0) {
583  pickyDpt = muon->pickyTrack()->ptError()/muon->pickyTrack()->pt();
584  if(pickyDpt<dpt)
585  out.emplace_back(muon->pickyTrack(),reco::Muon::Picky);
586  pickyExists=true;
587  }
588 
589  bool dytExists=false;
590  double dytDpt=99999.;
591  if(muon->dytTrack().isNonnull() && muon->dytTrack()->pt()>0) {
592  dytDpt = muon->dytTrack()->ptError()/muon->dytTrack()->pt();
593  if(dytDpt<dpt)
594  out.emplace_back(muon->dytTrack(),reco::Muon::DYT);
595  dytExists=true;
596  }
597 
598  //Magic: TPFMS is not a really good track especially under misalignment
599  //IT is kind of crap because if mu system is displaced it can make a change
600  //So allow TPFMS if there is no picky or the error of tpfms is better than picky
601  //AND if there is no DYT or the error of tpfms is better than DYT
602  if(muon->tpfmsTrack().isNonnull() && muon->tpfmsTrack()->pt()>0) {
603  double tpfmsDpt = muon->tpfmsTrack()->ptError()/muon->tpfmsTrack()->pt();
604  if( ( (pickyExists && tpfmsDpt<pickyDpt) || (!pickyExists) ) &&
605  ( (dytExists && tpfmsDpt<dytDpt) || (!dytExists) ) &&
606  tpfmsDpt<dpt )
607  out.emplace_back(muon->tpfmsTrack(),reco::Muon::TPFMS);
608  }
609 
610  if(includeSA && muon->outerTrack().isNonnull())
611  if(muon->outerTrack()->ptError()/muon->outerTrack()->pt()<dpt)
612  out.emplace_back(muon->outerTrack(),reco::Muon::OuterTrack);
613 
614  return out;
615 
616 }
617 
618 
619 
620 
621 
623 
624 
625 
626 
627 bool PFMuonAlgo::reconstructMuon(reco::PFCandidate& candidate, const reco::MuonRef& muon, bool allowLoose) {
628  using namespace std;
629  using namespace reco;
630 
631  if (!muon.isNonnull())
632  return false;
633 
634 
635 
636 
637  bool isMu=false;
638 
639  if(allowLoose)
640  isMu = isMuon(muon) || isLooseMuon(muon);
641  else
642  isMu = isMuon(muon);
643 
644  if( !isMu)
645  return false;
646 
647 
648 
649 
650 
651  //get the valid tracks(without standalone except we allow loose muons)
652  //MIKE: Here we need to be careful. If we have a muon inside a dense
653  //jet environment often the track is badly measured. In this case
654  //we should not apply Dpt/Pt<1
655 
656  std::vector<reco::Muon::MuonTrackTypePair> validTracks = goodMuonTracks(muon);
657  if (!allowLoose)
658  validTracks = goodMuonTracks(muon);
659  else
660  validTracks = muonTracks(muon);
661 
662  if( validTracks.empty())
663  return false;
664 
665 
666 
667 
668  //check what is the track used.Rerun TuneP
669  reco::Muon::MuonTrackTypePair bestTrackPair = muon::tevOptimized(*muon);
670 
671  TrackRef bestTrack = bestTrackPair.first;
672  MuonTrackType trackType = bestTrackPair.second;
673 
674 
675 
676  MuonTrackTypePair trackPairWithSmallestError = getTrackWithSmallestError(validTracks);
677  TrackRef trackWithSmallestError = trackPairWithSmallestError.first;
678 
679  if( trackType == reco::Muon::InnerTrack &&
680  (!bestTrack->quality(trackQuality_) ||
681  bestTrack->ptError()/bestTrack->pt()> errorCompScale_*trackWithSmallestError->ptError()/trackWithSmallestError->pt() )) {
682  bestTrack = trackWithSmallestError;
683  trackType = trackPairWithSmallestError.second;
684  }
685  else if (trackType != reco::Muon::InnerTrack &&
686  bestTrack->ptError()/bestTrack->pt()> errorCompScale_*trackWithSmallestError->ptError()/trackWithSmallestError->pt()) {
687  bestTrack = trackWithSmallestError;
688  trackType = trackPairWithSmallestError.second;
689 
690  }
691 
692 
693  changeTrack(candidate,std::make_pair(bestTrack,trackType));
694  candidate.setMuonRef( muon );
695 
696  return true;
697 }
698 
699 
700 
701 
703  using namespace reco;
704  reco::TrackRef bestTrack = track.first;
705  MuonTrackType trackType = track.second;
706  //OK Now redefine the canddiate with that track
707  double px = bestTrack->px();
708  double py = bestTrack->py();
709  double pz = bestTrack->pz();
710  double energy = sqrt(bestTrack->p()*bestTrack->p() + 0.1057*0.1057);
711 
712  candidate.setCharge(bestTrack->charge()>0 ? 1 : -1);
713  candidate.setP4(math::XYZTLorentzVector(px,py,pz,energy));
715  // candidate.setTrackRef( bestTrack );
716  candidate.setMuonTrackType(trackType);
717  if(trackType == reco::Muon::InnerTrack)
718  candidate.setVertexSource( PFCandidate::kTrkMuonVertex );
719  else if(trackType == reco::Muon::CombinedTrack)
720  candidate.setVertexSource( PFCandidate::kComMuonVertex );
721  else if(trackType == reco::Muon::TPFMS)
722  candidate.setVertexSource( PFCandidate::kTPFMSMuonVertex );
723  else if(trackType == reco::Muon::Picky)
724  candidate.setVertexSource( PFCandidate::kPickyMuonVertex );
725  else if(trackType == reco::Muon::DYT)
726  candidate.setVertexSource( PFCandidate::kDYTMuonVertex );
727  }
728 
729 
731 PFMuonAlgo::getTrackWithSmallestError(const std::vector<reco::Muon::MuonTrackTypePair>& tracks) {
733  return *std::min_element(tracks.begin(),tracks.end(),sorter);
734 }
735 
736 
737 
738 
739 
741 {
742  //SUM ET
743  sumetPU_ = 0.0;
744  METX_=0.;
745  METY_=0.;
746  sumet_=0.0;
747  for(reco::PFCandidateCollection::const_iterator i = pfc->begin();i!=pfc->end();++i) {
748  sumet_+=i->pt();
749  METX_+=i->px();
750  METY_+=i->py();
751  }
752 
753 }
754 
755 
756 
757 
758 
760  using namespace std;
761  using namespace reco;
762  if (!postCleaning_)
763  return;
764 
765  //Initialize vectors
766 
769  else
771 
774  else
776 
777  if( pfFakeMuonCleanedCandidates_.get() )
779  else
781 
782 
785  else
787 
790  else
792 
793 
794 
796 
797  maskedIndices_.clear();
798 
799  //Estimate MET and SumET
800 
802 
803 
804  std::vector<int> muons;
805  std::vector<int> cosmics;
806  //get the muons
807  for(unsigned int i=0;i<cands->size();++i) {
808  const reco::PFCandidate& cand = (*cands)[i];
809  if ( cand.particleId() == reco::PFCandidate::mu )
810  muons.push_back(i);
811 
812  }
813  //Then sort the muon indicess by decsending pt
814 
815  IndexPtComparator comparator(cands);
816  std::sort(muons.begin(),muons.end(),comparator);
817 
818 
819  //first kill cosmics
820  double METXCosmics=0;
821  double METYCosmics=0;
822  double SUMETCosmics=0.0;
823 
824  for(unsigned int i=0;i<muons.size();++i) {
825  const PFCandidate& pfc = cands->at(muons[i]);
826  double origin=0.0;
827  if(!vertices_->empty()&& vertices_->at(0).isValid() && ! vertices_->at(0).isFake())
828  origin = pfc.muonRef()->muonBestTrack()->dxy(vertices_->at(0).position());
829 
830  if( origin> cosmicRejDistance_) {
831  cosmics.push_back(muons[i]);
832  METXCosmics +=pfc.px();
833  METYCosmics +=pfc.py();
834  SUMETCosmics +=pfc.pt();
835  }
836  }
837  double MET2Cosmics = METXCosmics*METXCosmics+METYCosmics*METYCosmics;
838 
839  if ( SUMETCosmics > (sumet_-sumetPU_)/eventFactorCosmics_ && MET2Cosmics < METX_*METX_+ METY_*METY_)
840  for(unsigned int i=0;i<cosmics.size();++i) {
841  maskedIndices_.push_back(cosmics[i]);
842  pfCosmicsMuonCleanedCandidates_->push_back(cands->at(cosmics[i]));
843  }
844 
845  //Loop on the muons candidates and clean
846  for(unsigned int i=0;i<muons.size();++i) {
847  if( cleanMismeasured(cands->at(muons[i]),muons[i]))
848  continue;
849  cleanPunchThroughAndFakes(cands->at(muons[i]),cands,muons[i]);
850 
851  }
852 
853 
854 
855  //OK Now do the hard job ->remove the candidates that were cleaned
857 
858 
859 
860 
861 }
862 
864  if(!postCleaning_)
865  return;
866 
867 
868  if( pfAddedMuonCandidates_.get() )
869  pfAddedMuonCandidates_->clear();
870  else
872 
873 
874 
875  for ( unsigned imu = 0; imu < muons->size(); ++imu ) {
876  reco::MuonRef muonRef( muons, imu );
877  bool used = false;
878  bool hadron = false;
879  for(unsigned i=0; i<cands->size(); i++) {
880  const PFCandidate& pfc = cands->at(i);
881  if ( !pfc.trackRef().isNonnull() ) continue;
882  if ( pfc.trackRef().isNonnull() && pfc.trackRef() == muonRef->track() )
883  hadron = true;
884  if ( !pfc.muonRef().isNonnull() ) continue;
885 
886  if ( pfc.muonRef()->innerTrack() == muonRef->innerTrack())
887  used = true;
888  else {
889  // Check if the stand-alone muon is not a spurious copy of an existing muon
890  // (Protection needed for HLT)
891  if ( pfc.muonRef()->isStandAloneMuon() && muonRef->isStandAloneMuon() ) {
892  double dEta = pfc.muonRef()->standAloneMuon()->eta() - muonRef->standAloneMuon()->eta();
893  double dPhi = pfc.muonRef()->standAloneMuon()->phi() - muonRef->standAloneMuon()->phi();
894  double dR = sqrt(dEta*dEta + dPhi*dPhi);
895  if ( dR < 0.005 ) {
896  used = true;
897  }
898  }
899  }
900 
901  if ( used ) break;
902  }
903 
904  if ( used ||hadron||(!muonRef.isNonnull()) ) continue;
905 
906 
907  TrackMETComparator comparator(METX_,METY_);
908  //Low pt dont need to be cleaned
909 
910  std::vector<reco::Muon::MuonTrackTypePair> tracks = goodMuonTracks(muonRef,true);
911  //If there is at least 1 track choice try to change the track
912  if(!tracks.empty()) {
913 
914  //Find tracks that change dramatically MET or Pt
915  std::vector<reco::Muon::MuonTrackTypePair> tracksThatChangeMET = tracksPointingAtMET(tracks);
916  //From those tracks get the one with smallest MET
917  if (!tracksThatChangeMET.empty()) {
918  reco::Muon::MuonTrackTypePair bestTrackType = *std::min_element(tracksThatChangeMET.begin(),tracksThatChangeMET.end(),comparator);
919 
920  //Make sure it is not cosmic
921  if((vertices_->empty()) ||bestTrackType.first->dz(vertices_->at(0).position())<cosmicRejDistance_){
922 
923  //make a pfcandidate
924  int charge = bestTrackType.first->charge()>0 ? 1 : -1;
925  math::XYZTLorentzVector momentum(bestTrackType.first->px(),
926  bestTrackType.first->py(),
927  bestTrackType.first->pz(),
928  sqrt(bestTrackType.first->p()*bestTrackType.first->p()+0.1057*0.1057));
929 
930  cands->push_back( PFCandidate( charge,
931  momentum,
933 
934  changeTrack(cands->back(),bestTrackType);
935 
936  if (muonRef->track().isNonnull() )
937  cands->back().setTrackRef( muonRef->track() );
938 
939  cands->back().setMuonRef(muonRef);
940 
941 
942  pfAddedMuonCandidates_->push_back(cands->back());
943 
944  }
945  }
946  }
947  }
948 }
949 
950 std::pair<double,double>
952  std::vector<reco::Muon::MuonTrackTypePair> tracks = goodMuonTracks((pfc.muonRef()),true);
953 
954  double METXNO = METX_-pfc.px();
955  double METYNO = METY_-pfc.py();
956  std::vector<double> met2;
957  for (unsigned int i=0;i<tracks.size();++i) {
958  met2.push_back(pow(METXNO+tracks.at(i).first->px(),2)+pow(METYNO+tracks.at(i).first->py(),2));
959  }
960 
961  //PROTECT for cases of only one track. If there is only one track it will crash .
962  //Has never happened but could likely happen!
963 
964  if(tracks.size()>1)
965  return std::make_pair(*std::min_element(met2.begin(),met2.end()),*std::max_element(met2.begin(),met2.end()));
966  else
967  return std::make_pair(0,0);
968 }
969 
970 
972  using namespace std;
973  using namespace reco;
974  bool cleaned=false;
975 
976  //First define the MET without this guy
977  double METNOX = METX_ - pfc.px();
978  double METNOY = METY_ - pfc.py();
979  double SUMETNO = sumet_ -pfc.pt();
980 
981  TrackMETComparator comparator(METNOX,METNOY);
982  //Low pt dont need to be cleaned
983  if (pfc.pt()<minPostCleaningPt_)
984  return false;
985  std::vector<reco::Muon::MuonTrackTypePair> tracks = goodMuonTracks(pfc.muonRef(),false);
986 
987 
988 
989  //If there is more than 1 track choice try to change the track
990  if(tracks.size()>1) {
991  //Find tracks that change dramatically MET or Pt
992  std::vector<reco::Muon::MuonTrackTypePair> tracksThatChangeMET = tracksWithBetterMET(tracks,pfc);
993  //From those tracks get the one with smallest MET
994  if (!tracksThatChangeMET.empty()) {
995  reco::Muon::MuonTrackTypePair bestTrackType = *std::min_element(tracksThatChangeMET.begin(),tracksThatChangeMET.end(),comparator);
996  changeTrack(pfc,bestTrackType);
997 
999  //update eventquantities
1000  METX_ = METNOX+pfc.px();
1001  METY_ = METNOY+pfc.py();
1002  sumet_=SUMETNO+pfc.pt();
1003 
1004  }
1005  }
1006 
1007  //Now attempt to kill it
1008  if (!(pfc.muonRef()->isGlobalMuon() && pfc.muonRef()->isTrackerMuon())) {
1009  //define MET significance and SUM ET
1010  double MET2 = METX_*METX_+METY_*METY_;
1011  double newMET2 = METNOX*METNOX+METNOY*METNOY;
1012  double METSig = sqrt(MET2)/sqrt(sumet_-sumetPU_);
1013  if( METSig>metSigForRejection_)
1014  if((newMET2 < MET2/metFactorRejection_) &&
1016  pfFakeMuonCleanedCandidates_->push_back(pfc);
1017  maskedIndices_.push_back(i);
1018  METX_ = METNOX;
1019  METY_ = METNOY;
1020  sumet_=SUMETNO;
1021  cleaned=true;
1022  }
1023 
1024  }
1025  return cleaned;
1026 
1027 }
1028 
1029 std::vector<reco::Muon::MuonTrackTypePair>
1030 PFMuonAlgo::tracksWithBetterMET(const std::vector<reco::Muon::MuonTrackTypePair>& tracks ,const reco::PFCandidate& pfc) {
1031  std::vector<reco::Muon::MuonTrackTypePair> outputTracks;
1032 
1033  double METNOX = METX_ - pfc.px();
1034  double METNOY = METY_ - pfc.py();
1035  double SUMETNO = sumet_ -pfc.pt();
1036  double MET2 = METX_*METX_+METY_*METY_;
1037  double newMET2=0.0;
1038  double newSUMET=0.0;
1039  double METSIG = sqrt(MET2)/sqrt(sumet_-sumetPU_);
1040 
1041 
1042  if(METSIG>metSigForCleaning_)
1043  for( unsigned int i=0;i<tracks.size();++i) {
1044  //calculate new SUM ET and MET2
1045  newSUMET = SUMETNO+tracks.at(i).first->pt()-sumetPU_;
1046  newMET2 = pow(METNOX+tracks.at(i).first->px(),2)+pow(METNOY+tracks.at(i).first->py(),2);
1047 
1048  if(newSUMET/(sumet_-sumetPU_)>eventFractionCleaning_ && newMET2<MET2/metFactorCleaning_)
1049  outputTracks.push_back(tracks.at(i));
1050  }
1051 
1052 
1053  return outputTracks;
1054 }
1055 
1056 
1057 std::vector<reco::Muon::MuonTrackTypePair>
1058 PFMuonAlgo::tracksPointingAtMET(const std::vector<reco::Muon::MuonTrackTypePair>& tracks) {
1059  std::vector<reco::Muon::MuonTrackTypePair> outputTracks;
1060 
1061 
1062  double newMET2=0.0;
1063 
1064  for( unsigned int i=0;i<tracks.size();++i) {
1065  //calculate new SUM ET and MET2
1066  newMET2 = pow(METX_+tracks.at(i).first->px(),2)+pow(METY_+tracks.at(i).first->py(),2);
1067 
1068  if(newMET2<(METX_*METX_+METY_*METY_)/metFactorCleaning_)
1069  outputTracks.push_back(tracks.at(i));
1070  }
1071 
1072 
1073  return outputTracks;
1074 }
1075 
1076 
1077 
1079 
1081  using namespace reco;
1082 
1083  bool cleaned=false;
1084 
1085  if (pfc.pt()<minPostCleaningPt_)
1086  return false;
1087 
1088 
1089  double METXNO = METX_-pfc.pt();
1090  double METYNO = METY_-pfc.pt();
1091  double MET2NO = METXNO*METXNO+METYNO*METYNO;
1092  double MET2 = METX_*METX_+METY_*METY_;
1093  bool fake1=false;
1094 
1095  std::pair<double,double> met2 = getMinMaxMET2(pfc);
1096 
1097  //Check for Fakes at high pseudorapidity
1098  if(pfc.muonRef()->standAloneMuon().isNonnull())
1099  fake1 =fabs ( pfc.eta() ) > 2.15 &&
1100  met2.first<met2.second/2 &&
1101  MET2NO < MET2/metFactorHighEta_ &&
1102  pfc.muonRef()->standAloneMuon()->pt() < pfc.pt()/ptFactorHighEta_;
1103 
1104  double factor = std::max(2.,2000./(sumet_-pfc.pt()-sumetPU_));
1105  bool fake2 = ( pfc.pt()/(sumet_-sumetPU_) < 0.25 && MET2NO < MET2/metFactorFake_ && met2.first<met2.second/factor );
1106 
1107  bool punchthrough =pfc.p() > minPunchThroughMomentum_ &&
1109  pfc.rawEcalEnergy()+pfc.rawHcalEnergy() > pfc.p()/punchThroughFactor_ &&
1110  !isIsolatedMuon(pfc.muonRef()) && MET2NO < MET2/punchThroughMETFactor_;
1111 
1112 
1113  if(fake1 || fake2||punchthrough) {
1114  // Find the block of the muon
1115  const PFCandidate::ElementsInBlocks& eleInBlocks = pfc.elementsInBlocks();
1116  if ( !eleInBlocks.empty() ) {
1117  PFBlockRef blockRefMuon = eleInBlocks[0].first;
1118  unsigned indexMuon = eleInBlocks[0].second;
1119  if (eleInBlocks.size()>1)
1120  indexMuon = eleInBlocks[1].second;
1121 
1122  // Check if the muon gave rise to a neutral hadron
1123  double iHad = 1E9;
1124  bool hadron = false;
1125  for ( unsigned i = imu+1; i < cands->size(); ++i ) {
1126  const PFCandidate& pfcn = cands->at(i);
1127  const PFCandidate::ElementsInBlocks& ele = pfcn.elementsInBlocks();
1128  if ( ele.empty() ) {
1129  continue;
1130  }
1131  PFBlockRef blockRefHadron = ele[0].first;
1132  unsigned indexHadron = ele[0].second;
1133  // We are out of the block -> exit the loop
1134  if ( blockRefHadron.key() != blockRefMuon.key() ) break;
1135  // Check that this particle is a neutral hadron
1136  if ( indexHadron == indexMuon &&
1137  pfcn.particleId() == reco::PFCandidate::h0 ) {
1138  iHad = i;
1139  hadron = true;
1140  }
1141  if ( hadron ) break;
1142  }
1143 
1144  if ( hadron ) {
1145 
1146  double rescaleFactor = cands->at(iHad).p()/cands->at(imu).p();
1147  METX_ -= cands->at(imu).px() + cands->at(iHad).px();
1148  METY_ -= cands->at(imu).py() + cands->at(iHad).py();
1149  sumet_ -=cands->at(imu).pt();
1150  cands->at(imu).rescaleMomentum(rescaleFactor);
1151  maskedIndices_.push_back(iHad);
1152  pfPunchThroughHadronCleanedCandidates_->push_back(cands->at(iHad));
1153  cands->at(imu).setParticleType(reco::PFCandidate::h);
1154  pfPunchThroughMuonCleanedCandidates_->push_back(cands->at(imu));
1155  METX_ += cands->at(imu).px();
1156  METY_ += cands->at(imu).py();
1157  sumet_ += cands->at(imu).pt();
1158 
1159  } else if ( fake1 || fake2 ) {
1160  METX_ -= cands->at(imu).px();
1161  METY_ -= cands->at(imu).py();
1162  sumet_ -= cands->at(imu).pt();
1163  maskedIndices_.push_back(imu);
1164  pfFakeMuonCleanedCandidates_->push_back(cands->at(imu));
1165  cleaned=true;
1166  }
1167  }
1168  }
1169  return cleaned;
1170 }
1171 
1172 
1173 void PFMuonAlgo::removeDeadCandidates(reco::PFCandidateCollection* obj, const std::vector<unsigned int>& indices)
1174 {
1175  size_t N = indices.size();
1176  size_t collSize = obj->size();
1177 
1178  for (size_t i = 0 ; i < N ; ++i)
1179  obj->at(indices.at(i)) = obj->at(collSize-i-1);
1180 
1181  obj->resize(collSize - indices.size());
1182 }
dbl * delta
Definition: mlp_gen.cc:36
T getParameter(std::string const &) const
Abstract base class for a PFBlock element (track, cluster...)
static bool isIsolatedMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:137
bool cleanMismeasured(reco::PFCandidate &, unsigned int)
Definition: PFMuonAlgo.cc:971
static bool isTightMuonPOG(const reco::MuonRef &muonRef)
Definition: PFMuonAlgo.cc:389
double sumet_
Definition: PFMuonAlgo.h:157
void removeDeadCandidates(reco::PFCandidateCollection *, const std::vector< unsigned int > &)
Definition: PFMuonAlgo.cc:1173
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
std::unique_ptr< reco::PFCandidateCollection > pfPunchThroughMuonCleanedCandidates_
the collection of punch-through cleaned muon candidates
Definition: PFMuonAlgo.h:117
double eta() const final
momentum pseudorapidity
double rawEcalEnergy() const
return corrected Ecal energy
Definition: PFCandidate.h:225
void addMissingMuons(edm::Handle< reco::MuonCollection >, reco::PFCandidateCollection *cands)
Definition: PFMuonAlgo.cc:863
Definition: CLHEP.h:16
static bool isMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:66
const double minPunchThroughEnergy_
Definition: PFMuonAlgo.h:151
static bool isTrackerLooseMuon(const reco::PFBlockElement &elt)
const double metFactorRejection_
Definition: PFMuonAlgo.h:146
const bool postCleaning_
Definition: PFMuonAlgo.h:139
double px() const final
x coordinate of momentum vector
PFMuonAlgo(edm::ParameterSet const &)
constructor
Definition: PFMuonAlgo.cc:26
std::unique_ptr< reco::PFCandidateCollection > pfFakeMuonCleanedCandidates_
the collection of fake cleaned muon candidates
Definition: PFMuonAlgo.h:115
static bool isGlobalLooseMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:111
const double minPunchThroughMomentum_
Definition: PFMuonAlgo.h:150
bool exists(std::string const &parameterName) const
checks if a parameter exists
bool cleanPunchThroughAndFakes(reco::PFCandidate &, reco::PFCandidateCollection *, unsigned int)
Definition: PFMuonAlgo.cc:1080
void setInputsForCleaning(reco::VertexCollection const &)
Definition: PFMuonAlgo.cc:1078
double pt() const final
transverse momentum
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
reco::Muon::MuonTrackTypePair MuonTrackTypePair
Definition: PFMuonAlgo.h:14
const double punchThroughFactor_
Definition: PFMuonAlgo.h:152
std::unique_ptr< reco::PFCandidateCollection > pfCleanedTrackerAndGlobalMuonCandidates_
the collection of tracker/global cleaned muon candidates
Definition: PFMuonAlgo.h:113
const double maxDPtOPt_
Definition: PFMuonAlgo.h:132
key_type key() const
Accessor for product key.
Definition: Ref.h:263
const double metFactorCleaning_
Definition: PFMuonAlgo.h:144
static void printMuonProperties(const reco::MuonRef &muonRef)
Definition: PFMuonAlgo.cc:422
std::vector< MuonTrackTypePair > tracksPointingAtMET(const std::vector< MuonTrackTypePair > &)
Definition: PFMuonAlgo.cc:1058
bool hasValidTrack(const reco::MuonRef &muonRef, bool loose=false)
Definition: PFMuonAlgo.cc:412
static bool isGlobalTightMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:98
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:387
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:442
MuonTrackTypePair getTrackWithSmallestError(const std::vector< MuonTrackTypePair > &)
Definition: PFMuonAlgo.cc:731
U second(std::pair< T, U > const &p)
void setCharge(Charge q) final
set electric charge
Definition: LeafCandidate.h:93
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
void setVertexSource(PFVertexType vt)
Definition: PFCandidate.h:407
reco::Muon::MuonTrackTypePair tevOptimized(const reco::TrackRef &combinedTrack, const reco::TrackRef &trackerTrack, const reco::TrackRef &tpfmsTrack, const reco::TrackRef &pickyTrack, const reco::TrackRef &dytTrack, const double ptThreshold=200., const double tune1=17., const double tune2=40., const double dptcut=0.25)
Definition: MuonCocktails.cc:9
const double metFactorHighEta_
Definition: PFMuonAlgo.h:147
const double cosmicRejDistance_
Definition: PFMuonAlgo.h:154
void setMuonTrackType(const reco::Muon::MuonTrackType &type)
set the Best Muon Track Ref
Definition: PFCandidate.h:357
void setParticleType(ParticleType type)
set Particle Type
Definition: PFCandidate.cc:265
T sqrt(T t)
Definition: SSEVec.h:18
const double minPostCleaningPt_
Definition: PFMuonAlgo.h:140
std::vector< reco::Muon::MuonTrackTypePair > goodMuonTracks(const reco::MuonRef &muon, bool includeSA=false)
Definition: PFMuonAlgo.cc:559
T min(T a, T b)
Definition: MathUtil.h:58
void estimateEventQuantities(const reco::PFCandidateCollection *)
Definition: PFMuonAlgo.cc:740
const double ptFactorHighEta_
Definition: PFMuonAlgo.h:148
void changeTrack(reco::PFCandidate &, const MuonTrackTypePair &)
Definition: PFMuonAlgo.cc:702
const double eventFractionCleaning_
Definition: PFMuonAlgo.h:137
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:459
std::unique_ptr< reco::PFCandidateCollection > pfAddedMuonCandidates_
the collection of added muon candidates
Definition: PFMuonAlgo.h:121
const double metFactorFake_
Definition: PFMuonAlgo.h:149
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
double p() const final
magnitude of momentum vector
#define N
Definition: blowfish.cc:9
std::vector< unsigned int > maskedIndices_
Definition: PFMuonAlgo.h:123
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:485
static bool isLooseMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:78
double METX_
Definition: PFMuonAlgo.h:158
double py() const final
y coordinate of momentum vector
const double eventFactorCosmics_
Definition: PFMuonAlgo.h:141
std::pair< double, double > getMinMaxMET2(const reco::PFCandidate &)
Definition: PFMuonAlgo.cc:951
int numberOfValidTrackerHits() const
Definition: HitPattern.h:901
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
fixed size matrix
void setMuonRef(const reco::MuonRef &ref)
set muon reference
Definition: PFCandidate.cc:445
double sumetPU_
Definition: PFMuonAlgo.h:156
const reco::VertexCollection * vertices_
Definition: PFMuonAlgo.h:127
MuonTrackType
map for Global Muon refitters
Definition: Muon.h:38
const double punchThroughMETFactor_
Definition: PFMuonAlgo.h:153
const reco::MuonRef & muonRef() const override
virtual ParticleType particleId() const
Definition: PFCandidate.h:374
std::pair< TrackRef, Muon::MuonTrackType > MuonTrackTypePair
Definition: Muon.h:40
std::unique_ptr< reco::PFCandidateCollection > pfCosmicsMuonCleanedCandidates_
the collection of cosmics cleaned muon candidates
Definition: PFMuonAlgo.h:111
std::vector< MuonTrackTypePair > tracksWithBetterMET(const std::vector< MuonTrackTypePair > &, const reco::PFCandidate &)
Definition: PFMuonAlgo.cc:1030
void postClean(reco::PFCandidateCollection *)
Definition: PFMuonAlgo.cc:759
const ElementsInBlocks & elementsInBlocks() const
Definition: PFCandidate.cc:691
long double T
std::vector< reco::Muon::MuonTrackTypePair > muonTracks(const reco::MuonRef &muon, bool includeSA=false, double dpt=1e+9)
Definition: PFMuonAlgo.cc:565
const double eventFractionRejection_
Definition: PFMuonAlgo.h:145
void setP4(const LorentzVector &p4) final
set 4-momentum
const double errorCompScale_
Definition: PFMuonAlgo.h:136
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
const double metSigForCleaning_
Definition: PFMuonAlgo.h:142
static bool isTrackerTightMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:124
double rawHcalEnergy() const
return raw Hcal energy
Definition: PFCandidate.h:235
const reco::TrackBase::TrackQuality trackQuality_
Definition: PFMuonAlgo.h:135
const double metSigForRejection_
Definition: PFMuonAlgo.h:143
std::unique_ptr< reco::PFCandidateCollection > pfPunchThroughHadronCleanedCandidates_
the collection of punch-through cleaned neutral hadron candidates
Definition: PFMuonAlgo.h:119
bool reconstructMuon(reco::PFCandidate &, const reco::MuonRef &, bool allowLoose=false)
Definition: PFMuonAlgo.cc:627
double METY_
Definition: PFMuonAlgo.h:159