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 // $Id: Muon.cc,v 1.32.2.3 2013/01/24 13:17:36 bellan Exp $
3 //
4 
10 
11 #include <limits>
12 
13 using namespace pat;
14 
15 
18  Lepton<reco::Muon>(),
19  embeddedMuonBestTrack_(false),
20  embeddedImprovedMuonBestTrack_(false),
21  improvedMuonBestTrackType_(reco::Muon::None),
22  embeddedTrack_(false),
23  embeddedStandAloneMuon_(false),
24  embeddedCombinedMuon_(false),
25  embeddedTCMETMuonCorrs_(false),
26  embeddedCaloMETMuonCorrs_(false),
27  embeddedPickyMuon_(false),
28  embeddedTpfmsMuon_(false),
29  embeddedDytMuon_(false),
30  embeddedPFCandidate_(false),
31  pfCandidateRef_(),
32  cachedNormChi2_(false),
33  cachedDB_(false),
34  cachedNumberOfValidHits_(0),
35  normChi2_(0.0),
36  dB_(0.0),
37  edB_(0.0),
38  numberOfValidHits_(0)
39 {
41 }
42 
44 Muon::Muon(const reco::Muon & aMuon) :
45  Lepton<reco::Muon>(aMuon),
46  embeddedMuonBestTrack_(false),
47  embeddedImprovedMuonBestTrack_(false),
48  improvedMuonBestTrackType_(reco::Muon::None),
49  embeddedTrack_(false),
50  embeddedStandAloneMuon_(false),
51  embeddedCombinedMuon_(false),
52  embeddedTCMETMuonCorrs_(false),
53  embeddedCaloMETMuonCorrs_(false),
54  embeddedPickyMuon_(false),
55  embeddedTpfmsMuon_(false),
56  embeddedDytMuon_(false),
57  embeddedPFCandidate_(false),
58  pfCandidateRef_(),
59  cachedNormChi2_(false),
60  cachedDB_(false),
61  cachedNumberOfValidHits_(0),
62  normChi2_(0.0),
63  dB_(0.0),
64  edB_(0.0),
65  numberOfValidHits_(0)
66 {
68 }
69 
72  Lepton<reco::Muon>(aMuonRef),
73  embeddedMuonBestTrack_(false),
74  embeddedImprovedMuonBestTrack_(false),
75  improvedMuonBestTrackType_(reco::Muon::None),
76  embeddedTrack_(false),
77  embeddedStandAloneMuon_(false),
78  embeddedCombinedMuon_(false),
79  embeddedTCMETMuonCorrs_(false),
80  embeddedCaloMETMuonCorrs_(false),
81  embeddedPickyMuon_(false),
82  embeddedTpfmsMuon_(false),
83  embeddedDytMuon_(false),
84  embeddedPFCandidate_(false),
85  pfCandidateRef_(),
86  cachedNormChi2_(false),
87  cachedDB_(false),
88  cachedNumberOfValidHits_(0),
89  normChi2_(0.0),
90  dB_(0.0),
91  edB_(0.0),
92  numberOfValidHits_(0)
93 {
95 }
96 
98 Muon::Muon(const edm::Ptr<reco::Muon> & aMuonRef) :
99  Lepton<reco::Muon>(aMuonRef),
100  embeddedMuonBestTrack_(false),
101  embeddedImprovedMuonBestTrack_(false),
102  improvedMuonBestTrackType_(reco::Muon::None),
103  embeddedTrack_(false),
104  embeddedStandAloneMuon_(false),
105  embeddedCombinedMuon_(false),
106  embeddedTCMETMuonCorrs_(false),
107  embeddedCaloMETMuonCorrs_(false),
108  embeddedPickyMuon_(false),
109  embeddedTpfmsMuon_(false),
110  embeddedDytMuon_(false),
111  embeddedPFCandidate_(false),
112  pfCandidateRef_(),
113  cachedNormChi2_(false),
114  cachedDB_(false),
115  cachedNumberOfValidHits_(0),
116  normChi2_(0.0),
117  dB_(0.0),
118  edB_(0.0),
119  numberOfValidHits_(0)
120 {
122 }
123 
126 }
127 
128 std::ostream&
129 reco::operator<<(std::ostream& out, const pat::Muon& obj)
130 {
131  if(!out) return out;
132 
133  out << "\tpat::Muon: ";
134  out << std::setiosflags(std::ios::right);
135  out << std::setiosflags(std::ios::fixed);
136  out << std::setprecision(3);
137  out << " E/pT/eta/phi "
138  << obj.energy()<<"/"
139  << obj.pt()<<"/"
140  << obj.eta()<<"/"
141  << obj.phi();
142  return out;
143 }
144 
145 // initialize impact parameter container vars
147  for (int i_ = 0; i_<5; ++i_){
148  ip_.push_back(0.0);
149  eip_.push_back(0.0);
150  cachedIP_.push_back(false);
151  }
152 }
153 
154 
157  if (embeddedTrack_) {
158  return reco::TrackRef(&track_, 0);
159  } else {
160  return reco::Muon::innerTrack();
161  }
162 }
163 
164 
168  return reco::TrackRef(&standAloneMuon_, 0);
169  } else {
170  return reco::Muon::outerTrack();
171  }
172 }
173 
174 
177  if (embeddedCombinedMuon_) {
178  return reco::TrackRef(&combinedMuon_, 0);
179  } else {
180  return reco::Muon::globalTrack();
181  }
182 }
183 
186  if (embeddedPickyMuon_) {
187  return reco::TrackRef(&pickyMuon_, 0);
188  } else {
189  return reco::Muon::pickyTrack();
190  }
191 }
192 
195  if (embeddedTpfmsMuon_) {
196  return reco::TrackRef(&tpfmsMuon_, 0);
197  } else {
198  return reco::Muon::tpfmsTrack();
199  }
200 }
201 
204  if (embeddedDytMuon_) {
205  return reco::TrackRef(&dytMuon_, 0);
206  } else {
207  return reco::Muon::dytTrack();
208  }
209 }
210 
213  return reco::TrackRef(&muonBestTrack_,0);
214  } else {
216  return newBestTrack.first;
217  }
218 }
219 
220 
224  } else {
226  return newBestTrack.first;
227  }
228 }
229 
230 
233  if (embeddedPFCandidate_) {
235  } else {
236  return pfCandidateRef_;
237  }
238 }
239 
242  if (embeddedPFCandidate_) {
244  } else {
245  return reco::CandidatePtr();
246  }
247 }
248 
251  muonBestTrack_.clear(); embeddedMuonBestTrack_ = false;
252  if (reco::Muon::muonBestTrack().isNonnull()) {
254  embeddedMuonBestTrack_ = true;
255  }
256 }
257 
261 
262  if(improvedMuonBestTrack().isNonnull()){
265  }
266  else
267  edm::LogError("PATMuon|embedImprovedMuonBestTrack") << "Orphan best track this must not happend!";
268 }
269 
270 
273  track_.clear();
274  if (reco::Muon::innerTrack().isNonnull()) {
275  track_.push_back(*reco::Muon::innerTrack());
276  embeddedTrack_ = true;
277  }
278 }
279 
280 
283  standAloneMuon_.clear();
284  if (reco::Muon::outerTrack().isNonnull()) {
287  }
288 }
289 
290 
293  combinedMuon_.clear();
294  if (reco::Muon::globalTrack().isNonnull()) {
296  embeddedCombinedMuon_ = true;
297  }
298 }
299 
302  caloMETMuonCorrs_.clear();
303  caloMETMuonCorrs_.push_back(t);
305 }
306 
309  tcMETMuonCorrs_.clear();
310  tcMETMuonCorrs_.push_back(t);
312 }
313 
316  pickyMuon_.clear();
318  if (tk.isNonnull()) {
319  pickyMuon_.push_back(*tk);
320  embeddedPickyMuon_ = true;
321  }
322 }
323 
326  tpfmsMuon_.clear();
328  if (tk.isNonnull()) {
329  tpfmsMuon_.push_back(*tk);
330  embeddedTpfmsMuon_ = true;
331  }
332 }
333 
336  dytMuon_.clear();
338  if (tk.isNonnull()) {
339  dytMuon_.push_back(*tk);
340  embeddedDytMuon_ = true;
341  }
342 }
343 
346  pfCandidate_.clear();
348  pfCandidate_.push_back( *pfCandidateRef_ );
349  embeddedPFCandidate_ = true;
350  }
351 }
352 
353 bool Muon::muonID(const std::string& name) const {
355  return muon::isGoodMuon(*this, st);
356 }
357 
358 
363 double Muon::normChi2() const {
364  if ( cachedNormChi2_ ) {
365  return normChi2_;
366  } else {
368  return t->chi2() / t->ndof();
369  }
370 }
371 
376 unsigned int Muon::numberOfValidHits() const {
377  if ( cachedNumberOfValidHits_ ) {
378  return numberOfValidHits_;
379  } else {
381  return t->numberOfValidHits();
382  }
383 }
384 
385 // embed various impact parameters with errors
386 // IpType defines the type of the impact parameter
387 // None is default and reverts to old behavior controlled by
388 // patMuons.usePV = True/False
389 double Muon::dB(IpType type_) const {
390 
391  // preserve old functionality exactly
392  if (type_ == None){
393  if ( cachedDB_ ) {
394  return dB_;
395  }
396  else {
398  }
399  }
400 
401  // more IP types (new)
402  else if ( cachedIP_[type_] ) {
403  return ip_[type_];
404  } else {
406  }
407 }
408 
409 
410 // embed various impact parameters with errors
411 // IpType defines the type of the impact parameter
412 // None is default and reverts to old behavior controlled by
413 // patMuons.usePV = True/False
414 double Muon::edB(IpType type_) const {
415 
416  // preserve old functionality exactly
417  if (type_ == None){
418  if ( cachedDB_ ) {
419  return edB_;
420  }
421  else {
423  }
424  }
425 
426  // more IP types (new)
427  else if ( cachedIP_[type_] ) {
428  return eip_[type_];
429  } else {
431  }
432 }
433 
434 
436  return muon::segmentCompatibility(*this, arbitrationType);
437 }
438 
439 
440 
441 // Selectors
442 bool Muon::isTightMuon(const reco::Vertex&vtx) const {
443  return muon::isTightMuon(*this, vtx);
444 }
445 
446 bool Muon::isLooseMuon() const {
447  return muon::isLooseMuon(*this);
448 
449 }
450 
451 bool Muon::isSoftMuon(const reco::Vertex& vtx) const {
452  return muon::isSoftMuon(*this, vtx);
453 }
454 
455 
457  return muon::isHighPtMuon(*this, vtx, type);
458 }
459 
type
Definition: HCALResponse.h:22
double normChi2() const
Norm chi2 gives the normalized chi2 of the global track.
Definition: Muon.cc:363
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:282
reco::PFCandidateRef pfCandidateRef_
Definition: Muon.h:288
unsigned int numberOfValidHits() const
numberOfValidHits returns the number of valid hits on the global track.
Definition: Muon.cc:376
reco::TrackRef innerTrack() const
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.h:74
reco::Muon::MuonTrackTypePair muonBestTrack(const reco::Muon &muon, reco::TunePType tunePType)
bool embeddedTCMETMuonCorrs_
muon MET corrections for tcMET
Definition: Muon.h:266
bool embeddedImprovedMuonBestTrack_
best muon track, after new tuneP
Definition: Muon.h:252
void embedPFCandidate()
embed the IsolatedPFCandidate pointed to by pfCandidateRef_
Definition: Muon.cc:345
size_t size_type
Definition: Candidate.h:31
bool muonID(const std::string &name) const
Definition: Muon.cc:353
unsigned int numberOfValidHits_
Definition: Muon.h:304
virtual TrackRef innerTrack() const
Definition: Muon.h:49
unsigned int type_
muon type mask
Definition: Muon.h:256
bool embeddedTrack_
track of inner track detector
Definition: Muon.h:256
std::vector< reco::MuonMETCorrectionData > tcMETMuonCorrs_
Definition: Muon.h:267
bool cachedNumberOfValidHits_
has the dB been cached?
Definition: Muon.h:294
double segmentCompatibility(reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration) const
Returns the segment compatibility, using muon::segmentCompatibility (DataFormats/MuonReco/interface/M...
Definition: Muon.cc:435
bool embeddedStandAloneMuon_
track of muon system
Definition: Muon.h:259
bool isAvailable() const
Definition: Ref.h:276
bool embeddedPickyMuon_
Definition: Muon.h:273
virtual TrackRef tpfmsTrack() const
Definition: Muon.h:58
std::vector< reco::Track > improvedMuonBestTrack_
Definition: Muon.h:253
reco::TrackRef improvedMuonBestTrack() const
reference to the Best Track reconstructed in both tracked and muon detector (reimplemented from reco:...
Definition: Muon.cc:221
Muon()
default constructor
Definition: Muon.cc:17
virtual double eta() const
momentum pseudorapidity
void embedPickyMuon()
embed reference to the above picky Track
Definition: Muon.cc:315
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:292
SelectionType
Selector type.
Definition: MuonSelectors.h:19
bool isSoftMuon(const reco::Muon &, const reco::Vertex &)
std::vector< reco::Track > pickyMuon_
Definition: Muon.h:276
void embedCaloMETMuonCorrs(const reco::MuonMETCorrectionData &t)
embed the MuonMETCorrectionData for muon corrected caloMET
Definition: Muon.cc:301
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
reco::CandidatePtr sourceCandidatePtr(size_type i) const
get the candidate pointer with index i
Definition: Muon.cc:241
virtual double energy() const
energy
bool embeddedTpfmsMuon_
Definition: Muon.h:274
bool cachedNormChi2_
Definition: Muon.h:291
reco::PFCandidateRef pfCandidateRef() const
reference to the source IsolatedPFCandidates
Definition: Muon.cc:232
std::vector< reco::MuonMETCorrectionData > caloMETMuonCorrs_
Definition: Muon.h:270
reco::PFCandidateCollection pfCandidate_
Definition: Muon.h:285
virtual TrackRef muonBestTrack() const
Definition: Muon.h:64
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:72
std::vector< reco::Track > dytMuon_
Definition: Muon.h:278
double normChi2_
has the numberOfValidHits been cached?
Definition: Muon.h:295
const T & max(const T &a, const T &b)
bool isLooseMuon() const
Definition: Muon.cc:446
enum pat::Muon::IPTYPE IpType
void embedTrack()
set reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.cc:272
ArbitrationType
define arbitration schemes
Definition: Muon.h:173
void embedTcMETMuonCorrs(const reco::MuonMETCorrectionData &t)
embed the MuonMETCorrectionData for tcMET
Definition: Muon.cc:308
Analysis-level lepton class.
Definition: Lepton.h:32
bool embeddedDytMuon_
Definition: Muon.h:275
virtual TrackRef pickyTrack() const
Definition: Muon.h:59
float segmentCompatibility(const reco::Muon &muon, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
std::vector< bool > cachedIP_
Definition: Muon.h:300
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
bool embeddedPFCandidate_
true if the IsolatedPFCandidate is embedded
Definition: Muon.h:282
double dB(IpType type=None) const
Definition: Muon.cc:389
reco::TrackRef tpfmsTrack() const
reference to Track reconstructed using hits in the tracker + info from the first muon station that ha...
Definition: Muon.cc:194
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:52
reco::TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon) ...
Definition: Muon.h:82
bool embeddedCaloMETMuonCorrs_
muon MET corrections for caloMET
Definition: Muon.h:269
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
bool isHighPtMuon(const reco::Vertex &, reco::TunePType) const
Definition: Muon.cc:456
reco::TrackRef combinedMuon() const
reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon) ...
Definition: Muon.cc:176
tuple out
Definition: dbtoconf.py:99
reco::TrackRef standAloneMuon() const
reference to Track reconstructed in the muon detector only (reimplemented from reco::Muon) ...
Definition: Muon.cc:166
bool isTightMuon(const reco::Vertex &) const
Definition: Muon.cc:442
void embedTpfmsMuon()
embed reference to the above tpfms Track
Definition: Muon.cc:325
std::vector< double > ip_
Definition: Muon.h:301
reco::TrackRef muonBestTrack() const
reference to the Best Track reconstructed in both tracked and muon detector (reimplemented from reco:...
Definition: Muon.cc:211
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:262
bool isSoftMuon(const reco::Vertex &) const
Definition: Muon.cc:451
void embedDytMuon()
embed reference to the above dyt Track
Definition: Muon.cc:335
double edB(IpType type=None) const
Definition: Muon.cc:414
std::vector< double > eip_
Definition: Muon.h:302
SelectionType selectionTypeFromString(const std::string &label)
Definition: MuonSelectors.cc:8
void embedMuonBestTrack()
set reference to Track selected to be the best measurement of the muon parameters (reimplemented from...
Definition: Muon.cc:250
virtual double pt() const
transverse momentum
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
key_type key() const
Accessor for product key.
Definition: Ref.h:266
bool cachedDB_
has the normalized chi2 been cached?
Definition: Muon.h:292
void embedImprovedMuonBestTrack()
set reference to Track selected to be the best measurement of the muon parameters (reimplemented from...
Definition: Muon.cc:259
std::vector< reco::Track > muonBestTrack_
Definition: Muon.h:250
reco::TrackRef dytTrack() const
reference to Track reconstructed using DYT algorithm
Definition: Muon.cc:203
virtual TrackRef dytTrack() const
Definition: Muon.h:60
std::vector< reco::Track > track_
Definition: Muon.h:257
std::vector< reco::Track > combinedMuon_
Definition: Muon.h:263
std::vector< reco::Track > standAloneMuon_
Definition: Muon.h:260
virtual ~Muon()
destructor
Definition: Muon.cc:125
double edB_
dB and edB are the impact parameter at the primary vertex,
Definition: Muon.h:297
reco::TrackRef pickyTrack() const
reference to Track reconstructed using hits in the tracker + &quot;good&quot; muon hits (reimplemented from rec...
Definition: Muon.cc:185
bool isHighPtMuon(const reco::Muon &, const reco::Vertex &, reco::TunePType)
double dB_
globalTrack-&gt;chi2() / globalTrack-&gt;ndof()
Definition: Muon.h:296
ProductID id() const
Accessor for product ID.
Definition: Ref.h:256
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
std::pair< TrackRef, Muon::MuonTrackType > MuonTrackTypePair
Definition: Muon.h:41
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:242
virtual double phi() const
momentum azimuthal angle
TunePType
Definition: MuonFwd.h:32
Analysis-level muon class.
Definition: Muon.h:51
bool embeddedMuonBestTrack_
best muon track
Definition: Muon.h:249
reco::TrackRef track() const
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.cc:156
std::vector< reco::Track > tpfmsMuon_
Definition: Muon.h:277
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
Definition: Muon.h:55
void initImpactParameters(void)
Definition: Muon.cc:146