CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFMuonAlgo.cc
Go to the documentation of this file.
9 
10 bool
12 
13  const reco::PFBlockElementTrack* eltTrack
14  = dynamic_cast<const reco::PFBlockElementTrack*>(&elt);
15 
16  assert ( eltTrack );
17  reco::MuonRef muonRef = eltTrack->muonRef();
18 
19  return isMuon(muonRef);
20 
21 }
22 
23 bool
25 
26  const reco::PFBlockElementTrack* eltTrack
27  = dynamic_cast<const reco::PFBlockElementTrack*>(&elt);
28 
29  assert ( eltTrack );
30  reco::MuonRef muonRef = eltTrack->muonRef();
31 
32  return isLooseMuon(muonRef);
33 
34 }
35 
36 bool
38 
39  const reco::PFBlockElementTrack* eltTrack
40  = dynamic_cast<const reco::PFBlockElementTrack*>(&elt);
41 
42  assert ( eltTrack );
43  reco::MuonRef muonRef = eltTrack->muonRef();
44 
45  return isGlobalTightMuon(muonRef);
46 
47 }
48 
49 bool
51 
52  const reco::PFBlockElementTrack* eltTrack
53  = dynamic_cast<const reco::PFBlockElementTrack*>(&elt);
54 
55  assert ( eltTrack );
56  reco::MuonRef muonRef = eltTrack->muonRef();
57 
58  return isGlobalLooseMuon(muonRef);
59 
60 }
61 
62 bool
64 
65  const reco::PFBlockElementTrack* eltTrack
66  = dynamic_cast<const reco::PFBlockElementTrack*>(&elt);
67 
68  assert ( eltTrack );
69  reco::MuonRef muonRef = eltTrack->muonRef();
70 
71  return isTrackerTightMuon(muonRef);
72 
73 }
74 
75 bool
77 
78  const reco::PFBlockElementTrack* eltTrack
79  = dynamic_cast<const reco::PFBlockElementTrack*>(&elt);
80 
81  assert ( eltTrack );
82  reco::MuonRef muonRef = eltTrack->muonRef();
83 
84  return isIsolatedMuon(muonRef);
85 
86 }
87 
88 
89 bool
91 
92  return isGlobalTightMuon(muonRef) || isTrackerTightMuon(muonRef) || isIsolatedMuon(muonRef);
93 }
94 
95 bool
97 
98  return isGlobalLooseMuon(muonRef) || isTrackerLooseMuon(muonRef);
99 
100 }
101 
102 bool
104 
105  if ( !muonRef.isNonnull() ) return false;
106 
107  if ( !muonRef->isGlobalMuon() ) return false;
108  if ( !muonRef->isStandAloneMuon() ) return false;
109 
110 
111  if ( muonRef->isTrackerMuon() ) {
112 
114 
115  bool isTM2DCompatibilityTight = muon::isGoodMuon(*muonRef,muon::TM2DCompatibilityTight);
116  int nMatches = muonRef->numberOfMatches();
117  bool quality = nMatches > 2 || isTM2DCompatibilityTight;
118 
119  return result && quality;
120 
121  } else {
122 
123  reco::TrackRef standAloneMu = muonRef->standAloneMuon();
124 
125  // No tracker muon -> Request a perfect stand-alone muon, or an even better global muon
126  bool result = false;
127 
128  // Check the quality of the stand-alone muon :
129  // good chi**2 and large number of hits and good pt error
130  if ( ( standAloneMu->hitPattern().numberOfValidMuonDTHits() < 22 &&
131  standAloneMu->hitPattern().numberOfValidMuonCSCHits() < 15 ) ||
132  standAloneMu->normalizedChi2() > 10. ||
133  standAloneMu->ptError()/standAloneMu->pt() > 0.20 ) {
134  result = false;
135  } else {
136 
137  reco::TrackRef combinedMu = muonRef->combinedMuon();
138  reco::TrackRef trackerMu = muonRef->track();
139 
140  // If the stand-alone muon is good, check the global muon
141  if ( combinedMu->normalizedChi2() > standAloneMu->normalizedChi2() ) {
142  // If the combined muon is worse than the stand-alone, it
143  // means that either the corresponding tracker track was not
144  // reconstructed, or that the sta muon comes from a late
145  // pion decay (hence with a momentum smaller than the track)
146  // Take the stand-alone muon only if its momentum is larger
147  // than that of the track
148  result = standAloneMu->pt() > trackerMu->pt() ;
149  } else {
150  // If the combined muon is better (and good enough), take the
151  // global muon
152  result =
153  combinedMu->ptError()/combinedMu->pt() <
154  std::min(0.20,standAloneMu->ptError()/standAloneMu->pt());
155  }
156  }
157 
158  return result;
159  }
160 
161  return false;
162 
163 }
164 
165 bool
167 
168  if ( !muonRef.isNonnull() ) return false;
169 
170  if(!muonRef->isTrackerMuon()) return false;
171 
172  reco::TrackRef trackerMu = muonRef->track();
173  const reco::Track& track = *trackerMu;
174 
175  unsigned nTrackerHits = track.hitPattern().numberOfValidTrackerHits();
176 
177  if(nTrackerHits<=12) return false;
178 
179  bool isAllArbitrated = muon::isGoodMuon(*muonRef,muon::AllArbitrated);
180 
181  bool isTM2DCompatibilityTight = muon::isGoodMuon(*muonRef,muon::TM2DCompatibilityTight);
182 
183  if(!isAllArbitrated || !isTM2DCompatibilityTight) return false;
184 
185  if((trackerMu->ptError()/trackerMu->pt() > 0.10)){
186  //std::cout<<" PT ERROR > 10 % "<< trackerMu->pt() <<std::endl;
187  return false;
188  }
189  return true;
190 
191 }
192 
193 bool
195 
196  if ( !muonRef.isNonnull() ) return false;
197  if ( !muonRef->isGlobalMuon() ) return false;
198  if ( !muonRef->isStandAloneMuon() ) return false;
199 
200  reco::TrackRef standAloneMu = muonRef->standAloneMuon();
201  reco::TrackRef combinedMu = muonRef->combinedMuon();
202  reco::TrackRef trackerMu = muonRef->track();
203 
204  unsigned nMuonHits =
205  standAloneMu->hitPattern().numberOfValidMuonDTHits() +
206  2*standAloneMu->hitPattern().numberOfValidMuonCSCHits();
207 
208  bool quality = false;
209 
210  if ( muonRef->isTrackerMuon() ){
211 
212  bool result = combinedMu->normalizedChi2() < 100.;
213 
214  bool laststation =
216 
217  int nMatches = muonRef->numberOfMatches();
218 
219  quality = laststation && nMuonHits > 12 && nMatches > 1;
220 
221  return result && quality;
222 
223  }
224  else{
225 
226  // Check the quality of the stand-alone muon :
227  // good chi**2 and large number of hits and good pt error
228  if ( nMuonHits <=15 ||
229  standAloneMu->normalizedChi2() > 10. ||
230  standAloneMu->ptError()/standAloneMu->pt() > 0.20 ) {
231  quality = false;
232  }
233  else {
234  // If the stand-alone muon is good, check the global muon
235  if ( combinedMu->normalizedChi2() > standAloneMu->normalizedChi2() ) {
236  // If the combined muon is worse than the stand-alone, it
237  // means that either the corresponding tracker track was not
238  // reconstructed, or that the sta muon comes from a late
239  // pion decay (hence with a momentum smaller than the track)
240  // Take the stand-alone muon only if its momentum is larger
241  // than that of the track
242 
243  // Note that here we even take the standAlone if it has a smaller pT, in contrast to GlobalTight
244  if(standAloneMu->pt() > trackerMu->pt() || combinedMu->normalizedChi2()<5.) quality = true;
245  }
246  else {
247  // If the combined muon is better (and good enough), take the
248  // global muon
249  if(combinedMu->ptError()/combinedMu->pt() < std::min(0.20,standAloneMu->ptError()/standAloneMu->pt()))
250  quality = true;
251 
252  }
253  }
254  }
255 
256 
257  return quality;
258 
259 }
260 
261 
262 bool
264 
265  if ( !muonRef.isNonnull() ) return false;
266  if(!muonRef->isTrackerMuon()) return false;
267 
268  reco::TrackRef trackerMu = muonRef->track();
269 
270  if(trackerMu->ptError()/trackerMu->pt() > 0.20) return false;
271 
272  // this doesn't seem to be necessary on the small samples looked at, but keep it around as insurance
273  if(trackerMu->pt()>20.) return false;
274 
275  bool isAllArbitrated = muon::isGoodMuon(*muonRef,muon::AllArbitrated);
276  bool isTMLastStationAngTight = muon::isGoodMuon(*muonRef,muon::TMLastStationAngTight);
277 
278  bool quality = isAllArbitrated && isTMLastStationAngTight;
279 
280  return quality;
281 
282 }
283 
284 bool
286 
287 
288  if ( !muonRef.isNonnull() ) return false;
289  if ( !muonRef->isIsolationValid() ) return false;
290 
291  // Isolated Muons which are missed by standard cuts are nearly always global+tracker
292  if ( !muonRef->isGlobalMuon() ) return false;
293 
294  // If it's not a tracker muon, only take it if there are valid muon hits
295 
296  reco::TrackRef standAloneMu = muonRef->standAloneMuon();
297 
298  if ( !muonRef->isTrackerMuon() ){
299  if(standAloneMu->hitPattern().numberOfValidMuonDTHits() == 0 &&
300  standAloneMu->hitPattern().numberOfValidMuonCSCHits() ==0) return false;
301  }
302 
303  // for isolation, take the smallest pt available to reject fakes
304 
305  reco::TrackRef combinedMu = muonRef->combinedMuon();
306  double smallestMuPt = combinedMu->pt();
307 
308  if(standAloneMu->pt()<smallestMuPt) smallestMuPt = standAloneMu->pt();
309 
310  if(muonRef->isTrackerMuon())
311  {
312  reco::TrackRef trackerMu = muonRef->track();
313  if(trackerMu->pt() < smallestMuPt) smallestMuPt= trackerMu->pt();
314  }
315 
316  double sumPtR03 = muonRef->isolationR03().sumPt;
317  double emEtR03 = muonRef->isolationR03().emEt;
318  double hadEtR03 = muonRef->isolationR03().hadEt;
319 
320  double relIso = (sumPtR03 + emEtR03 + hadEtR03)/smallestMuPt;
321 
322  if(relIso<0.1) return true;
323  else return false;
324 }
325 
326 bool
328 
329  if(!muon::isGoodMuon(*muonRef,muon::GlobalMuonPromptTight)) return false;
330 
331  if(!muonRef->isTrackerMuon()) return false;
332 
333  if(muonRef->numberOfMatches()<2) return false;
334 
335  //const reco::TrackRef& combinedMuon = muonRef->combinedMuon();
336  const reco::TrackRef& combinedMuon = muonRef->globalTrack();
337 
338  if(combinedMuon->hitPattern().numberOfValidTrackerHits()<11) return false;
339 
340  if(combinedMuon->hitPattern().numberOfValidPixelHits()==0) return false;
341 
342  if(combinedMuon->hitPattern().numberOfValidMuonHits()==0) return false;
343 
344  return true;
345 
346 }
347 
348 void
350 
351  if ( !muonRef.isNonnull() ) return;
352 
353  bool isGL = muonRef->isGlobalMuon();
354  bool isTR = muonRef->isTrackerMuon();
355  bool isST = muonRef->isStandAloneMuon();
356 
357  std::cout<<" GL: "<<isGL<<" TR: "<<isTR<<" ST: "<<isST<<std::endl;
358  std::cout<<" nMatches "<<muonRef->numberOfMatches()<<std::endl;
359 
360  if ( muonRef->isGlobalMuon() ){
361  reco::TrackRef combinedMu = muonRef->combinedMuon();
362  std::cout<<" GL, pt: " << combinedMu->pt()
363  << " +/- " << combinedMu->ptError()/combinedMu->pt()
364  << " chi**2 GBL : " << combinedMu->normalizedChi2()<<std::endl;
365  std::cout<< " Total Muon Hits : " << combinedMu->hitPattern().numberOfValidMuonHits()
366  << "/" << combinedMu->hitPattern().numberOfLostMuonHits()
367  << " DT Hits : " << combinedMu->hitPattern().numberOfValidMuonDTHits()
368  << "/" << combinedMu->hitPattern().numberOfLostMuonDTHits()
369  << " CSC Hits : " << combinedMu->hitPattern().numberOfValidMuonCSCHits()
370  << "/" << combinedMu->hitPattern().numberOfLostMuonCSCHits()
371  << " RPC Hits : " << combinedMu->hitPattern().numberOfValidMuonRPCHits()
372  << "/" << combinedMu->hitPattern().numberOfLostMuonRPCHits()<<std::endl;
373 
374  std::cout<<" # of Valid Tracker Hits "<<combinedMu->hitPattern().numberOfValidTrackerHits()<<std::endl;
375  std::cout<<" # of Valid Pixel Hits "<<combinedMu->hitPattern().numberOfValidPixelHits()<<std::endl;
376  }
377  if ( muonRef->isStandAloneMuon() ){
378  reco::TrackRef standAloneMu = muonRef->standAloneMuon();
379  std::cout<<" ST, pt: " << standAloneMu->pt()
380  << " +/- " << standAloneMu->ptError()/standAloneMu->pt()
381  << " eta : " << standAloneMu->eta()
382  << " DT Hits : " << standAloneMu->hitPattern().numberOfValidMuonDTHits()
383  << "/" << standAloneMu->hitPattern().numberOfLostMuonDTHits()
384  << " CSC Hits : " << standAloneMu->hitPattern().numberOfValidMuonCSCHits()
385  << "/" << standAloneMu->hitPattern().numberOfLostMuonCSCHits()
386  << " RPC Hits : " << standAloneMu->hitPattern().numberOfValidMuonRPCHits()
387  << "/" << standAloneMu->hitPattern().numberOfLostMuonRPCHits()
388  << " chi**2 STA : " << standAloneMu->normalizedChi2()<<std::endl;
389  }
390 
391 
392  if ( muonRef->isTrackerMuon() ){
393  reco::TrackRef trackerMu = muonRef->track();
394  const reco::Track& track = *trackerMu;
395  std::cout<<" TR, pt: " << trackerMu->pt()
396  << " +/- " << trackerMu->ptError()/trackerMu->pt()
397  << " chi**2 TR : " << trackerMu->normalizedChi2()<<std::endl;
398  std::cout<<" nTrackerHits "<<track.hitPattern().numberOfValidTrackerHits()<<std::endl;
399  std::cout<< "TMLastStationAngLoose "
400  << muon::isGoodMuon(*muonRef,muon::TMLastStationAngLoose) << std::endl
401  << "TMLastStationAngTight "
402  << muon::isGoodMuon(*muonRef,muon::TMLastStationAngTight) << std::endl
403  << "TMLastStationLoose "
404  << muon::isGoodMuon(*muonRef,muon::TMLastStationLoose) << std::endl
405  << "TMLastStationTight "
406  << muon::isGoodMuon(*muonRef,muon::TMLastStationTight) << std::endl
407  << "TMOneStationLoose "
408  << muon::isGoodMuon(*muonRef,muon::TMOneStationLoose) << std::endl
409  << "TMOneStationTight "
410  << muon::isGoodMuon(*muonRef,muon::TMOneStationTight) << std::endl
411  << "TMLastStationOptimizedLowPtLoose "
413  << "TMLastStationOptimizedLowPtTight "
415  << "TMLastStationOptimizedBarrelLowPtLoose "
417  << "TMLastStationOptimizedBarrelLowPtTight "
419  << std::endl;
420 
421  }
422 
423  std::cout<< "TM2DCompatibilityLoose "
424  << muon::isGoodMuon(*muonRef,muon::TM2DCompatibilityLoose) << std::endl
425  << "TM2DCompatibilityTight "
426  << muon::isGoodMuon(*muonRef,muon::TM2DCompatibilityTight) << std::endl;
427 
428 
429 
430  if ( muonRef->isGlobalMuon() && muonRef->isTrackerMuon() && muonRef->isStandAloneMuon() ){
431  reco::TrackRef combinedMu = muonRef->combinedMuon();
432  reco::TrackRef trackerMu = muonRef->track();
433  reco::TrackRef standAloneMu = muonRef->standAloneMuon();
434 
435  double sigmaCombined = combinedMu->ptError()/(combinedMu->pt()*combinedMu->pt());
436  double sigmaTracker = trackerMu->ptError()/(trackerMu->pt()*trackerMu->pt());
437  double sigmaStandAlone = standAloneMu->ptError()/(standAloneMu->pt()*standAloneMu->pt());
438 
439  bool combined = combinedMu->ptError()/combinedMu->pt() < 0.20;
440  bool tracker = trackerMu->ptError()/trackerMu->pt() < 0.20;
441  bool standAlone = standAloneMu->ptError()/standAloneMu->pt() < 0.20;
442 
443  double delta1 = combined && tracker ?
444  fabs(1./combinedMu->pt() -1./trackerMu->pt())
445  /sqrt(sigmaCombined*sigmaCombined + sigmaTracker*sigmaTracker) : 100.;
446  double delta2 = combined && standAlone ?
447  fabs(1./combinedMu->pt() -1./standAloneMu->pt())
448  /sqrt(sigmaCombined*sigmaCombined + sigmaStandAlone*sigmaStandAlone) : 100.;
449  double delta3 = standAlone && tracker ?
450  fabs(1./standAloneMu->pt() -1./trackerMu->pt())
451  /sqrt(sigmaStandAlone*sigmaStandAlone + sigmaTracker*sigmaTracker) : 100.;
452 
453  double delta =
454  standAloneMu->hitPattern().numberOfValidMuonDTHits()+
455  standAloneMu->hitPattern().numberOfValidMuonCSCHits() > 0 ?
456  std::min(delta3,std::min(delta1,delta2)) : std::max(delta3,std::max(delta1,delta2));
457 
458  std::cout << "delta = " << delta << " delta1 "<<delta1<<" delta2 "<<delta2<<" delta3 "<<delta3<<std::endl;
459 
460  double ratio =
461  combinedMu->ptError()/combinedMu->pt()
462  / (trackerMu->ptError()/trackerMu->pt());
463  //if ( ratio > 2. && delta < 3. ) std::cout << "ALARM ! " << ratio << ", " << delta << std::endl;
464  std::cout<<" ratio "<<ratio<<" combined mu pt "<<combinedMu->pt()<<std::endl;
465  //bool quality3 = ( combinedMu->pt() < 50. || ratio < 2. ) && delta < 3.;
466 
467 
468  }
469 
470  double sumPtR03 = muonRef->isolationR03().sumPt;
471  double emEtR03 = muonRef->isolationR03().emEt;
472  double hadEtR03 = muonRef->isolationR03().hadEt;
473  double relIsoR03 = (sumPtR03 + emEtR03 + hadEtR03)/muonRef->pt();
474  double sumPtR05 = muonRef->isolationR05().sumPt;
475  double emEtR05 = muonRef->isolationR05().emEt;
476  double hadEtR05 = muonRef->isolationR05().hadEt;
477  double relIsoR05 = (sumPtR05 + emEtR05 + hadEtR05)/muonRef->pt();
478  std::cout<<" 0.3 Radion Rel Iso: "<<relIsoR03<<" sumPt "<<sumPtR03<<" emEt "<<emEtR03<<" hadEt "<<hadEtR03<<std::endl;
479  std::cout<<" 0.5 Radion Rel Iso: "<<relIsoR05<<" sumPt "<<sumPtR05<<" emEt "<<emEtR05<<" hadEt "<<hadEtR05<<std::endl;
480  return;
481 
482 }
dbl * delta
Definition: mlp_gen.cc:36
Abstract base class for a PFBlock element (track, cluster...)
static bool isIsolatedMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:76
static bool isTightMuonPOG(const reco::MuonRef &muonRef)
Definition: PFMuonAlgo.cc:327
static bool isMuon(const reco::PFBlockElement &elt)
Check if a block element is a muon.
Definition: PFMuonAlgo.cc:11
static bool isTrackerLooseMuon(const reco::PFBlockElement &elt)
static bool isGlobalLooseMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:50
#define min(a, b)
Definition: mlp_lapack.h:161
static void printMuonProperties(const reco::MuonRef &muonRef)
Definition: PFMuonAlgo.cc:349
static bool isGlobalTightMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:37
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
reco::MuonRef muonRef() const
const T & max(const T &a, const T &b)
T sqrt(T t)
Definition: SSEVec.h:46
tuple result
Definition: query.py:137
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:223
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
static bool isLooseMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:24
int numberOfValidTrackerHits() const
Definition: HitPattern.h:558
tuple cout
Definition: gather_cfg.py:121
static bool isTrackerTightMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:63