CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Muon.cc
Go to the documentation of this file.
1 //
2 //
3 
8 #include <limits>
9 
10 using namespace pat;
11 
12 
15  Lepton<reco::Muon>(),
16  embeddedTrack_(false),
17  embeddedStandAloneMuon_(false),
18  embeddedCombinedMuon_(false),
19  embeddedTCMETMuonCorrs_(false),
20  embeddedCaloMETMuonCorrs_(false),
21  embeddedPickyMuon_(false),
22  embeddedTpfmsMuon_(false),
23  embeddedDytMuon_(false),
24  embeddedPFCandidate_(false),
25  pfCandidateRef_(),
26  cachedNormChi2_(false),
27  cachedDB_(false),
28  cachedNumberOfValidHits_(0),
29  normChi2_(0.0),
30  dB_(0.0),
31  edB_(0.0),
32  numberOfValidHits_(0)
33 {
35 }
36 
38 Muon::Muon(const reco::Muon & aMuon) :
39  Lepton<reco::Muon>(aMuon),
40  embeddedTrack_(false),
41  embeddedStandAloneMuon_(false),
42  embeddedCombinedMuon_(false),
43  embeddedTCMETMuonCorrs_(false),
44  embeddedCaloMETMuonCorrs_(false),
45  embeddedPickyMuon_(false),
46  embeddedTpfmsMuon_(false),
47  embeddedDytMuon_(false),
48  embeddedPFCandidate_(false),
49  pfCandidateRef_(),
50  cachedNormChi2_(false),
51  cachedDB_(false),
52  cachedNumberOfValidHits_(0),
53  normChi2_(0.0),
54  dB_(0.0),
55  edB_(0.0),
56  numberOfValidHits_(0)
57 {
59 }
60 
63  Lepton<reco::Muon>(aMuonRef),
64  embeddedTrack_(false),
65  embeddedStandAloneMuon_(false),
66  embeddedCombinedMuon_(false),
67  embeddedTCMETMuonCorrs_(false),
68  embeddedCaloMETMuonCorrs_(false),
69  embeddedPickyMuon_(false),
70  embeddedTpfmsMuon_(false),
71  embeddedDytMuon_(false),
72  embeddedPFCandidate_(false),
73  pfCandidateRef_(),
74  cachedNormChi2_(false),
75  cachedDB_(false),
76  cachedNumberOfValidHits_(0),
77  normChi2_(0.0),
78  dB_(0.0),
79  edB_(0.0),
80  numberOfValidHits_(0)
81 {
83 }
84 
86 Muon::Muon(const edm::Ptr<reco::Muon> & aMuonRef) :
87  Lepton<reco::Muon>(aMuonRef),
88  embeddedTrack_(false),
89  embeddedStandAloneMuon_(false),
90  embeddedCombinedMuon_(false),
91  embeddedTCMETMuonCorrs_(false),
92  embeddedCaloMETMuonCorrs_(false),
93  embeddedPickyMuon_(false),
94  embeddedTpfmsMuon_(false),
95  embeddedDytMuon_(false),
96  embeddedPFCandidate_(false),
97  pfCandidateRef_(),
98  cachedNormChi2_(false),
99  cachedDB_(false),
100  cachedNumberOfValidHits_(0),
101  normChi2_(0.0),
102  dB_(0.0),
103  edB_(0.0),
104  numberOfValidHits_(0)
105 {
107 }
108 
111 }
112 
113 std::ostream&
114 reco::operator<<(std::ostream& out, const pat::Muon& obj)
115 {
116  if(!out) return out;
117 
118  out << "\tpat::Muon: ";
119  out << std::setiosflags(std::ios::right);
120  out << std::setiosflags(std::ios::fixed);
121  out << std::setprecision(3);
122  out << " E/pT/eta/phi "
123  << obj.energy()<<"/"
124  << obj.pt()<<"/"
125  << obj.eta()<<"/"
126  << obj.phi();
127  return out;
128 }
129 
130 // initialize impact parameter container vars
132  for (int i_ = 0; i_<5; ++i_){
133  ip_.push_back(0.0);
134  eip_.push_back(0.0);
135  cachedIP_.push_back(false);
136  }
137 }
138 
139 
142  if (embeddedTrack_) {
143  return reco::TrackRef(&track_, 0);
144  } else {
145  return reco::Muon::innerTrack();
146  }
147 }
148 
149 
153  return reco::TrackRef(&standAloneMuon_, 0);
154  } else {
155  return reco::Muon::outerTrack();
156  }
157 }
158 
159 
162  if (embeddedCombinedMuon_) {
163  return reco::TrackRef(&combinedMuon_, 0);
164  } else {
165  return reco::Muon::globalTrack();
166  }
167 }
168 
171  if (embeddedPickyMuon_) {
172  return reco::TrackRef(&pickyMuon_, 0);
173  } else {
174  return reco::Muon::pickyTrack();
175  }
176 }
177 
180  if (embeddedTpfmsMuon_) {
181  return reco::TrackRef(&tpfmsMuon_, 0);
182  } else {
183  return reco::Muon::tpfmsTrack();
184  }
185 }
186 
189  if (embeddedDytMuon_) {
190  return reco::TrackRef(&dytMuon_, 0);
191  } else {
192  return reco::Muon::dytTrack();
193  }
194 }
195 
199  return reco::TrackRef(&muonBestTrack_, 0);
200  } else {
201  return reco::Muon::muonBestTrack();
202  }
203 }
204 
209  } else if (muonBestTrackType() == tunePMuonBestTrackType()) {
210  return muonBestTrack();
211  } else {
213  }
214 }
215 
216 
217 
218 
221  if (embeddedPFCandidate_) {
223  } else {
224  return pfCandidateRef_;
225  }
226 }
227 
231  if(refToOrig_.isNonnull() && pfCandidateRef_.isNonnull() && i==1 ) return refToOrig_;
232  if(refToOrig_.isNonnull() && ! pfCandidateRef_.isNonnull() && i==0 ) return refToOrig_;
233  return reco::CandidatePtr();
234 }
235 
237 void Muon::embedMuonBestTrack(bool force) {
238  muonBestTrack_.clear();
239  bool alreadyEmbedded = force;
240  if (!force) {
241  switch (muonBestTrackType()) {
242  case None: alreadyEmbedded = true; break;
243  case InnerTrack: if (embeddedTrack_) alreadyEmbedded = true; break;
244  case OuterTrack: if (embeddedStandAloneMuon_) alreadyEmbedded = true; break;
245  case CombinedTrack: if (embeddedCombinedMuon_) alreadyEmbedded = true; break;
246  case TPFMS: if (embeddedTpfmsMuon_) alreadyEmbedded = true; break;
247  case Picky: if (embeddedPickyMuon_) alreadyEmbedded = true; break;
248  case DYT: if (embeddedDytMuon_) alreadyEmbedded = true; break;
249  }
250  }
251  if (!alreadyEmbedded) {
253  embeddedMuonBestTrack_ = true;
254  }
255 }
256 
259  tunePMuonBestTrack_.clear();
260  bool alreadyEmbedded = force;
261  if (!force) {
262  switch (muonBestTrackType()) {
263  case None: alreadyEmbedded = true; break;
264  case InnerTrack: if (embeddedTrack_) alreadyEmbedded = true; break;
265  case OuterTrack: if (embeddedStandAloneMuon_) alreadyEmbedded = true; break;
266  case CombinedTrack: if (embeddedCombinedMuon_) alreadyEmbedded = true; break;
267  case TPFMS: if (embeddedTpfmsMuon_) alreadyEmbedded = true; break;
268  case Picky: if (embeddedPickyMuon_) alreadyEmbedded = true; break;
269  case DYT: if (embeddedDytMuon_) alreadyEmbedded = true; break;
270  }
272  if (embeddedMuonBestTrack_) alreadyEmbedded = true;
273  }
274  }
275  if (!alreadyEmbedded) {
278  }
279 }
280 
281 
284  track_.clear();
285  if (reco::Muon::innerTrack().isNonnull()) {
286  track_.push_back(*reco::Muon::innerTrack());
287  embeddedTrack_ = true;
288  }
289 }
290 
291 
294  standAloneMuon_.clear();
295  if (reco::Muon::outerTrack().isNonnull()) {
298  }
299 }
300 
301 
304  combinedMuon_.clear();
305  if (reco::Muon::globalTrack().isNonnull()) {
307  embeddedCombinedMuon_ = true;
308  }
309 }
310 
313  caloMETMuonCorrs_.clear();
314  caloMETMuonCorrs_.push_back(t);
316 }
317 
320  tcMETMuonCorrs_.clear();
321  tcMETMuonCorrs_.push_back(t);
323 }
324 
327  pickyMuon_.clear();
329  if (tk.isNonnull()) {
330  pickyMuon_.push_back(*tk);
331  embeddedPickyMuon_ = true;
332  }
333 }
334 
337  tpfmsMuon_.clear();
339  if (tk.isNonnull()) {
340  tpfmsMuon_.push_back(*tk);
341  embeddedTpfmsMuon_ = true;
342  }
343 }
344 
347  dytMuon_.clear();
349  if (tk.isNonnull()) {
350  dytMuon_.push_back(*tk);
351  embeddedDytMuon_ = true;
352  }
353 }
354 
357  pfCandidate_.clear();
359  pfCandidate_.push_back( *pfCandidateRef_ );
360  embeddedPFCandidate_ = true;
361  }
362 }
363 
364 bool Muon::muonID(const std::string& name) const {
366  return muon::isGoodMuon(*this, st);
367 }
368 
369 
374 double Muon::normChi2() const {
375  if ( cachedNormChi2_ ) {
376  return normChi2_;
377  } else {
379  return t->chi2() / t->ndof();
380  }
381 }
382 
387 unsigned int Muon::numberOfValidHits() const {
388  if ( cachedNumberOfValidHits_ ) {
389  return numberOfValidHits_;
390  } else {
392  return t->numberOfValidHits();
393  }
394 }
395 
396 // embed various impact parameters with errors
397 // IpType defines the type of the impact parameter
398 // None is default and reverts to old behavior controlled by
399 // patMuons.usePV = True/False
400 double Muon::dB(IpType type_) const {
401 
402  // preserve old functionality exactly
403  if (type_ == None){
404  if ( cachedDB_ ) {
405  return dB_;
406  }
407  else {
409  }
410  }
411 
412  // more IP types (new)
413  else if ( cachedIP_[type_] ) {
414  return ip_[type_];
415  } else {
417  }
418 }
419 
420 
421 // embed various impact parameters with errors
422 // IpType defines the type of the impact parameter
423 // None is default and reverts to old behavior controlled by
424 // patMuons.usePV = True/False
425 double Muon::edB(IpType type_) const {
426 
427  // preserve old functionality exactly
428  if (type_ == None){
429  if ( cachedDB_ ) {
430  return edB_;
431  }
432  else {
434  }
435  }
436 
437  // more IP types (new)
438  else if ( cachedIP_[type_] ) {
439  return eip_[type_];
440  } else {
442  }
443 }
444 
445 
447  return muon::segmentCompatibility(*this, arbitrationType);
448 }
449 
450 // Selectors
451 bool Muon::isTightMuon(const reco::Vertex&vtx) const {
452  return muon::isTightMuon(*this, vtx);
453 }
454 
455 bool Muon::isLooseMuon() const {
456  return muon::isLooseMuon(*this);
457 
458 }
459 
460 bool Muon::isSoftMuon(const reco::Vertex& vtx) const {
461  return muon::isSoftMuon(*this, vtx);
462 }
463 
464 
465 bool Muon::isHighPtMuon(const reco::Vertex& vtx) const{
466  return muon::isHighPtMuon(*this, vtx);
467 }
468 
double normChi2() const
Norm chi2 gives the normalized chi2 of the global track.
Definition: Muon.cc:374
virtual double energy() const GCC11_FINAL
energy
int i
Definition: DBlmapReader.cc:9
void embedStandAloneMuon()
set reference to Track reconstructed in the muon detector only (reimplemented from reco::Muon) ...
Definition: Muon.cc:293
reco::PFCandidateRef pfCandidateRef_
Definition: Muon.h:285
unsigned int numberOfValidHits() const
numberOfValidHits returns the number of valid hits on the global track.
Definition: Muon.cc:387
reco::TrackRef innerTrack() const
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.h:73
bool embeddedTCMETMuonCorrs_
muon MET corrections for tcMET
Definition: Muon.h:263
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
virtual MuonTrackType muonBestTrackType() const
Definition: Muon.h:64
void embedPFCandidate()
embed the IsolatedPFCandidate pointed to by pfCandidateRef_
Definition: Muon.cc:356
size_t size_type
Definition: Candidate.h:34
bool muonID(const std::string &name) const
Definition: Muon.cc:364
unsigned int numberOfValidHits_
Definition: Muon.h:301
virtual TrackRef innerTrack() const
Definition: Muon.h:48
void embedMuonBestTrack(bool force=false)
embed the Track selected to be the best measurement of the muon parameters
Definition: Muon.cc:237
unsigned int type_
muon type mask
Definition: Muon.h:269
bool embeddedTrack_
track of inner track detector
Definition: Muon.h:253
std::vector< reco::MuonMETCorrectionData > tcMETMuonCorrs_
Definition: Muon.h:264
bool cachedNumberOfValidHits_
has the dB been cached?
Definition: Muon.h:291
double segmentCompatibility(reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration) const
Returns the segment compatibility, using muon::segmentCompatibility (DataFormats/MuonReco/interface/M...
Definition: Muon.cc:446
bool embeddedStandAloneMuon_
track of muon system
Definition: Muon.h:256
std::vector< reco::Track > tunePMuonBestTrack_
Definition: Muon.h:251
bool isAvailable() const
Definition: Ref.h:276
bool embeddedPickyMuon_
Definition: Muon.h:270
virtual TrackRef tpfmsTrack() const
Definition: Muon.h:57
Muon()
default constructor
Definition: Muon.cc:14
void embedPickyMuon()
embed reference to the above picky Track
Definition: Muon.cc:326
bool isLooseMuon(const reco::Muon &)
void embedCombinedMuon()
set reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon...
Definition: Muon.cc:303
SelectionType
Selector type.
Definition: MuonSelectors.h:17
bool isSoftMuon(const reco::Muon &, const reco::Vertex &)
std::vector< reco::Track > pickyMuon_
Definition: Muon.h:273
void embedCaloMETMuonCorrs(const reco::MuonMETCorrectionData &t)
embed the MuonMETCorrectionData for muon corrected caloMET
Definition: Muon.cc:312
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
reco::CandidatePtr sourceCandidatePtr(size_type i) const
get the candidate pointer with index i
Definition: Muon.cc:229
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:152
bool embeddedTpfmsMuon_
Definition: Muon.h:271
bool cachedNormChi2_
Definition: Muon.h:288
reco::PFCandidateRef pfCandidateRef() const
reference to the source IsolatedPFCandidates
Definition: Muon.cc:220
std::vector< reco::MuonMETCorrectionData > caloMETMuonCorrs_
Definition: Muon.h:267
reco::PFCandidateCollection pfCandidate_
Definition: Muon.h:282
virtual reco::TrackRef tunePMuonBestTrack() const
Track selected to be the best measurement of the muon parameters (from muon information alone) ...
Definition: Muon.cc:206
virtual TrackRef muonBestTrack() const
Definition: Muon.h:63
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:71
std::vector< reco::Track > dytMuon_
Definition: Muon.h:275
double normChi2_
has the numberOfValidHits been cached?
Definition: Muon.h:292
const T & max(const T &a, const T &b)
bool isLooseMuon() const
Definition: Muon.cc:455
enum pat::Muon::IPTYPE IpType
void embedTrack()
set reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.cc:283
ArbitrationType
define arbitration schemes
Definition: Muon.h:178
bool embeddedTunePMuonBestTrack_
best muon track (muon only)
Definition: Muon.h:250
void embedTcMETMuonCorrs(const reco::MuonMETCorrectionData &t)
embed the MuonMETCorrectionData for tcMET
Definition: Muon.cc:319
Analysis-level lepton class.
Definition: Lepton.h:30
bool embeddedDytMuon_
Definition: Muon.h:272
virtual TrackRef pickyTrack() const
Definition: Muon.h:58
float segmentCompatibility(const reco::Muon &muon, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
std::vector< bool > cachedIP_
Definition: Muon.h:297
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
bool embeddedPFCandidate_
true if the IsolatedPFCandidate is embedded
Definition: Muon.h:279
double dB(IpType type=None) const
Definition: Muon.cc:400
reco::TrackRef tpfmsTrack() const
reference to Track reconstructed using hits in the tracker + info from the first muon station that ha...
Definition: Muon.cc:179
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:51
reco::TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon) ...
Definition: Muon.h:81
bool embeddedCaloMETMuonCorrs_
muon MET corrections for caloMET
Definition: Muon.h:266
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
reco::TrackRef combinedMuon() const
reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon) ...
Definition: Muon.cc:161
tuple out
Definition: dbtoconf.py:99
bool isHighPtMuon(const reco::Vertex &) const
Definition: Muon.cc:465
reco::TrackRef standAloneMuon() const
reference to Track reconstructed in the muon detector only (reimplemented from reco::Muon) ...
Definition: Muon.cc:151
bool isTightMuon(const reco::Vertex &) const
Definition: Muon.cc:451
void embedTpfmsMuon()
embed reference to the above tpfms Track
Definition: Muon.cc:336
std::vector< double > ip_
Definition: Muon.h:298
reco::TrackRef muonBestTrack() const
Track selected to be the best measurement of the muon parameters (including PFlow global information)...
Definition: Muon.cc:197
bool isHighPtMuon(const reco::Muon &, const reco::Vertex &)
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
bool embeddedCombinedMuon_
track of combined fit
Definition: Muon.h:259
bool isSoftMuon(const reco::Vertex &) const
Definition: Muon.cc:460
void embedDytMuon()
embed reference to the above dyt Track
Definition: Muon.cc:346
double edB(IpType type=None) const
Definition: Muon.cc:425
std::vector< double > eip_
Definition: Muon.h:299
SelectionType selectionTypeFromString(const std::string &label)
Definition: MuonSelectors.cc:9
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
bool cachedDB_
has the normalized chi2 been cached?
Definition: Muon.h:289
std::vector< reco::Track > muonBestTrack_
Definition: Muon.h:248
void embedTunePMuonBestTrack(bool force=false)
embed the Track selected to be the best measurement of the muon parameters
Definition: Muon.cc:258
reco::TrackRef dytTrack() const
reference to Track reconstructed using DYT algorithm
Definition: Muon.cc:188
virtual TrackRef dytTrack() const
Definition: Muon.h:59
std::vector< reco::Track > track_
Definition: Muon.h:254
virtual MuonTrackType tunePMuonBestTrackType() const
Definition: Muon.h:66
std::vector< reco::Track > combinedMuon_
Definition: Muon.h:260
std::vector< reco::Track > standAloneMuon_
Definition: Muon.h:257
virtual ~Muon()
destructor
Definition: Muon.cc:110
double edB_
dB and edB are the impact parameter at the primary vertex,
Definition: Muon.h:294
reco::TrackRef pickyTrack() const
reference to Track reconstructed using hits in the tracker + &quot;good&quot; muon hits (reimplemented from rec...
Definition: Muon.cc:170
virtual TrackRef tunePMuonBestTrack() const
Definition: Muon.h:65
double dB_
globalTrack-&gt;chi2() / globalTrack-&gt;ndof()
Definition: Muon.h:293
volatile std::atomic< bool > shutdown_flag false
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
virtual float pt() const GCC11_FINAL
transverse momentum
Analysis-level muon class.
Definition: Muon.h:50
edm::Ptr< reco::Candidate > refToOrig_
Definition: PATObject.h:407
bool embeddedMuonBestTrack_
best muon track (global pflow)
Definition: Muon.h:247
reco::TrackRef track() const
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.cc:141
std::vector< reco::Track > tpfmsMuon_
Definition: Muon.h:274
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
Definition: Muon.h:54
void initImpactParameters(void)
Definition: Muon.cc:131