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.33 2012/09/27 09:52:17 bellan Exp $
3 //
4 
8 
9 #include <limits>
10 
11 using namespace pat;
12 
13 
16  Lepton<reco::Muon>(),
17  embeddedTrack_(false),
18  embeddedStandAloneMuon_(false),
19  embeddedCombinedMuon_(false),
20  embeddedTCMETMuonCorrs_(false),
21  embeddedCaloMETMuonCorrs_(false),
22  embeddedPickyMuon_(false),
23  embeddedTpfmsMuon_(false),
24  embeddedDytMuon_(false),
25  embeddedPFCandidate_(false),
26  pfCandidateRef_(),
27  cachedNormChi2_(false),
28  cachedDB_(false),
29  cachedNumberOfValidHits_(0),
30  normChi2_(0.0),
31  dB_(0.0),
32  edB_(0.0),
33  numberOfValidHits_(0)
34 {
36 }
37 
39 Muon::Muon(const reco::Muon & aMuon) :
40  Lepton<reco::Muon>(aMuon),
41  embeddedTrack_(false),
42  embeddedStandAloneMuon_(false),
43  embeddedCombinedMuon_(false),
44  embeddedTCMETMuonCorrs_(false),
45  embeddedCaloMETMuonCorrs_(false),
46  embeddedPickyMuon_(false),
47  embeddedTpfmsMuon_(false),
48  embeddedDytMuon_(false),
49  embeddedPFCandidate_(false),
50  pfCandidateRef_(),
51  cachedNormChi2_(false),
52  cachedDB_(false),
53  cachedNumberOfValidHits_(0),
54  normChi2_(0.0),
55  dB_(0.0),
56  edB_(0.0),
57  numberOfValidHits_(0)
58 {
60 }
61 
64  Lepton<reco::Muon>(aMuonRef),
65  embeddedTrack_(false),
66  embeddedStandAloneMuon_(false),
67  embeddedCombinedMuon_(false),
68  embeddedTCMETMuonCorrs_(false),
69  embeddedCaloMETMuonCorrs_(false),
70  embeddedPickyMuon_(false),
71  embeddedTpfmsMuon_(false),
72  embeddedDytMuon_(false),
73  embeddedPFCandidate_(false),
74  pfCandidateRef_(),
75  cachedNormChi2_(false),
76  cachedDB_(false),
77  cachedNumberOfValidHits_(0),
78  normChi2_(0.0),
79  dB_(0.0),
80  edB_(0.0),
81  numberOfValidHits_(0)
82 {
84 }
85 
87 Muon::Muon(const edm::Ptr<reco::Muon> & aMuonRef) :
88  Lepton<reco::Muon>(aMuonRef),
89  embeddedTrack_(false),
90  embeddedStandAloneMuon_(false),
91  embeddedCombinedMuon_(false),
92  embeddedTCMETMuonCorrs_(false),
93  embeddedCaloMETMuonCorrs_(false),
94  embeddedPickyMuon_(false),
95  embeddedTpfmsMuon_(false),
96  embeddedDytMuon_(false),
97  embeddedPFCandidate_(false),
98  pfCandidateRef_(),
99  cachedNormChi2_(false),
100  cachedDB_(false),
101  cachedNumberOfValidHits_(0),
102  normChi2_(0.0),
103  dB_(0.0),
104  edB_(0.0),
105  numberOfValidHits_(0)
106 {
108 }
109 
112 }
113 
114 std::ostream&
115 reco::operator<<(std::ostream& out, const pat::Muon& obj)
116 {
117  if(!out) return out;
118 
119  out << "\tpat::Muon: ";
120  out << std::setiosflags(std::ios::right);
121  out << std::setiosflags(std::ios::fixed);
122  out << std::setprecision(3);
123  out << " E/pT/eta/phi "
124  << obj.energy()<<"/"
125  << obj.pt()<<"/"
126  << obj.eta()<<"/"
127  << obj.phi();
128  return out;
129 }
130 
131 // initialize impact parameter container vars
133  for (int i_ = 0; i_<5; ++i_){
134  ip_.push_back(0.0);
135  eip_.push_back(0.0);
136  cachedIP_.push_back(false);
137  }
138 }
139 
140 
143  if (embeddedTrack_) {
144  return reco::TrackRef(&track_, 0);
145  } else {
146  return reco::Muon::innerTrack();
147  }
148 }
149 
150 
154  return reco::TrackRef(&standAloneMuon_, 0);
155  } else {
156  return reco::Muon::outerTrack();
157  }
158 }
159 
160 
163  if (embeddedCombinedMuon_) {
164  return reco::TrackRef(&combinedMuon_, 0);
165  } else {
166  return reco::Muon::globalTrack();
167  }
168 }
169 
172  if (embeddedPickyMuon_) {
173  return reco::TrackRef(&pickyMuon_, 0);
174  } else {
175  return reco::Muon::pickyTrack();
176  }
177 }
178 
181  if (embeddedTpfmsMuon_) {
182  return reco::TrackRef(&tpfmsMuon_, 0);
183  } else {
184  return reco::Muon::tpfmsTrack();
185  }
186 }
187 
190  if (embeddedDytMuon_) {
191  return reco::TrackRef(&dytMuon_, 0);
192  } else {
193  return reco::Muon::dytTrack();
194  }
195 }
196 
199  if (embeddedPFCandidate_) {
201  } else {
202  return pfCandidateRef_;
203  }
204 }
205 
208  if (embeddedPFCandidate_) {
210  } else {
211  return reco::CandidatePtr();
212  }
213 }
214 
217  muonBestTrack_.clear();
218  if (reco::Muon::muonBestTrack().isNonnull()) {
220  embeddedMuonBestTrack_ = true;
221  }
222 }
223 
224 
225 
228  track_.clear();
229  if (reco::Muon::innerTrack().isNonnull()) {
230  track_.push_back(*reco::Muon::innerTrack());
231  embeddedTrack_ = true;
232  }
233 }
234 
235 
238  standAloneMuon_.clear();
239  if (reco::Muon::outerTrack().isNonnull()) {
242  }
243 }
244 
245 
248  combinedMuon_.clear();
249  if (reco::Muon::globalTrack().isNonnull()) {
251  embeddedCombinedMuon_ = true;
252  }
253 }
254 
257  caloMETMuonCorrs_.clear();
258  caloMETMuonCorrs_.push_back(t);
260 }
261 
264  tcMETMuonCorrs_.clear();
265  tcMETMuonCorrs_.push_back(t);
267 }
268 
271  pickyMuon_.clear();
273  if (tk.isNonnull()) {
274  pickyMuon_.push_back(*tk);
275  embeddedPickyMuon_ = true;
276  }
277 }
278 
281  tpfmsMuon_.clear();
283  if (tk.isNonnull()) {
284  tpfmsMuon_.push_back(*tk);
285  embeddedTpfmsMuon_ = true;
286  }
287 }
288 
291  dytMuon_.clear();
293  if (tk.isNonnull()) {
294  dytMuon_.push_back(*tk);
295  embeddedDytMuon_ = true;
296  }
297 }
298 
301  pfCandidate_.clear();
303  pfCandidate_.push_back( *pfCandidateRef_ );
304  embeddedPFCandidate_ = true;
305  }
306 }
307 
308 bool Muon::muonID(const std::string& name) const {
310  return muon::isGoodMuon(*this, st);
311 }
312 
313 
318 double Muon::normChi2() const {
319  if ( cachedNormChi2_ ) {
320  return normChi2_;
321  } else {
323  return t->chi2() / t->ndof();
324  }
325 }
326 
331 unsigned int Muon::numberOfValidHits() const {
332  if ( cachedNumberOfValidHits_ ) {
333  return numberOfValidHits_;
334  } else {
336  return t->numberOfValidHits();
337  }
338 }
339 
340 // embed various impact parameters with errors
341 // IpType defines the type of the impact parameter
342 // None is default and reverts to old behavior controlled by
343 // patMuons.usePV = True/False
344 double Muon::dB(IpType type_) const {
345 
346  // preserve old functionality exactly
347  if (type_ == None){
348  if ( cachedDB_ ) {
349  return dB_;
350  }
351  else {
353  }
354  }
355 
356  // more IP types (new)
357  else if ( cachedIP_[type_] ) {
358  return ip_[type_];
359  } else {
361  }
362 }
363 
364 
365 // embed various impact parameters with errors
366 // IpType defines the type of the impact parameter
367 // None is default and reverts to old behavior controlled by
368 // patMuons.usePV = True/False
369 double Muon::edB(IpType type_) const {
370 
371  // preserve old functionality exactly
372  if (type_ == None){
373  if ( cachedDB_ ) {
374  return edB_;
375  }
376  else {
378  }
379  }
380 
381  // more IP types (new)
382  else if ( cachedIP_[type_] ) {
383  return eip_[type_];
384  } else {
386  }
387 }
388 
389 
391  return muon::segmentCompatibility(*this, arbitrationType);
392 }
393 
394 // Selectors
395 bool Muon::isTightMuon(const reco::Vertex&vtx) const {
396  return muon::isTightMuon(*this, vtx);
397 }
398 
399 bool Muon::isLooseMuon() const {
400  return muon::isLooseMuon(*this);
401 
402 }
403 
404 bool Muon::isSoftMuon(const reco::Vertex& vtx) const {
405  return muon::isSoftMuon(*this, vtx);
406 }
407 
408 
409 bool Muon::isHighPtMuon(const reco::Vertex& vtx) const{
410  return muon::isHighPtMuon(*this, vtx);
411 }
412 
double normChi2() const
Norm chi2 gives the normalized chi2 of the global track.
Definition: Muon.cc:318
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:237
reco::PFCandidateRef pfCandidateRef_
Definition: Muon.h:268
unsigned int numberOfValidHits() const
numberOfValidHits returns the number of valid hits on the global track.
Definition: Muon.cc:331
reco::TrackRef innerTrack() const
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.h:74
bool embeddedTCMETMuonCorrs_
muon MET corrections for tcMET
Definition: Muon.h:246
void embedPFCandidate()
embed the IsolatedPFCandidate pointed to by pfCandidateRef_
Definition: Muon.cc:300
size_t size_type
Definition: Candidate.h:34
bool muonID(const std::string &name) const
Definition: Muon.cc:308
unsigned int numberOfValidHits_
Definition: Muon.h:284
virtual TrackRef innerTrack() const
Definition: Muon.h:49
unsigned int type_
muon type mask
Definition: Muon.h:270
bool embeddedTrack_
track of inner track detector
Definition: Muon.h:236
std::vector< reco::MuonMETCorrectionData > tcMETMuonCorrs_
Definition: Muon.h:247
bool cachedNumberOfValidHits_
has the dB been cached?
Definition: Muon.h:274
double segmentCompatibility(reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration) const
Returns the segment compatibility, using muon::segmentCompatibility (DataFormats/MuonReco/interface/M...
Definition: Muon.cc:390
bool embeddedStandAloneMuon_
track of muon system
Definition: Muon.h:239
bool isAvailable() const
Definition: Ref.h:276
bool embeddedPickyMuon_
Definition: Muon.h:253
virtual TrackRef tpfmsTrack() const
Definition: Muon.h:58
Muon()
default constructor
Definition: Muon.cc:15
void embedPickyMuon()
embed reference to the above picky Track
Definition: Muon.cc:270
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:247
SelectionType
Selector type.
Definition: MuonSelectors.h:18
bool isSoftMuon(const reco::Muon &, const reco::Vertex &)
std::vector< reco::Track > pickyMuon_
Definition: Muon.h:256
void embedCaloMETMuonCorrs(const reco::MuonMETCorrectionData &t)
embed the MuonMETCorrectionData for muon corrected caloMET
Definition: Muon.cc:256
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:207
bool embeddedTpfmsMuon_
Definition: Muon.h:254
bool cachedNormChi2_
Definition: Muon.h:271
reco::PFCandidateRef pfCandidateRef() const
reference to the source IsolatedPFCandidates
Definition: Muon.cc:198
std::vector< reco::MuonMETCorrectionData > caloMETMuonCorrs_
Definition: Muon.h:250
reco::PFCandidateCollection pfCandidate_
Definition: Muon.h:265
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:258
double normChi2_
has the numberOfValidHits been cached?
Definition: Muon.h:275
const T & max(const T &a, const T &b)
bool isLooseMuon() const
Definition: Muon.cc:399
enum pat::Muon::IPTYPE IpType
void embedTrack()
set reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.cc:227
ArbitrationType
define arbitration schemes
Definition: Muon.h:179
void embedTcMETMuonCorrs(const reco::MuonMETCorrectionData &t)
embed the MuonMETCorrectionData for tcMET
Definition: Muon.cc:263
Analysis-level lepton class.
Definition: Lepton.h:32
bool embeddedDytMuon_
Definition: Muon.h:255
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:280
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
bool embeddedPFCandidate_
true if the IsolatedPFCandidate is embedded
Definition: Muon.h:262
double dB(IpType type=None) const
Definition: Muon.cc:344
reco::TrackRef tpfmsTrack() const
reference to Track reconstructed using hits in the tracker + info from the first muon station that ha...
Definition: Muon.cc:180
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:249
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:162
tuple out
Definition: dbtoconf.py:99
bool isHighPtMuon(const reco::Vertex &) const
Definition: Muon.cc:409
reco::TrackRef standAloneMuon() const
reference to Track reconstructed in the muon detector only (reimplemented from reco::Muon) ...
Definition: Muon.cc:152
bool isTightMuon(const reco::Vertex &) const
Definition: Muon.cc:395
void embedTpfmsMuon()
embed reference to the above tpfms Track
Definition: Muon.cc:280
std::vector< double > ip_
Definition: Muon.h:281
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:242
bool isSoftMuon(const reco::Vertex &) const
Definition: Muon.cc:404
void embedDytMuon()
embed reference to the above dyt Track
Definition: Muon.cc:290
double edB(IpType type=None) const
Definition: Muon.cc:369
std::vector< double > eip_
Definition: Muon.h:282
SelectionType selectionTypeFromString(const std::string &label)
Definition: MuonSelectors.cc:9
void embedMuonBestTrack()
set reference to Track selected to be the best measurement of the muon parameters (reimplemented from...
Definition: Muon.cc:216
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:272
std::vector< reco::Track > muonBestTrack_
Definition: Muon.h:234
reco::TrackRef dytTrack() const
reference to Track reconstructed using DYT algorithm
Definition: Muon.cc:189
virtual TrackRef dytTrack() const
Definition: Muon.h:60
std::vector< reco::Track > track_
Definition: Muon.h:237
std::vector< reco::Track > combinedMuon_
Definition: Muon.h:243
std::vector< reco::Track > standAloneMuon_
Definition: Muon.h:240
virtual ~Muon()
destructor
Definition: Muon.cc:111
double edB_
dB and edB are the impact parameter at the primary vertex,
Definition: Muon.h:277
reco::TrackRef pickyTrack() const
reference to Track reconstructed using hits in the tracker + &quot;good&quot; muon hits (reimplemented from rec...
Definition: Muon.cc:171
double dB_
globalTrack-&gt;chi2() / globalTrack-&gt;ndof()
Definition: Muon.h:276
ProductID id() const
Accessor for product ID.
Definition: Ref.h:256
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:242
virtual float pt() const GCC11_FINAL
transverse momentum
Analysis-level muon class.
Definition: Muon.h:51
bool embeddedMuonBestTrack_
best muon track
Definition: Muon.h:233
reco::TrackRef track() const
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.cc:142
std::vector< reco::Track > tpfmsMuon_
Definition: Muon.h:257
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
Definition: Muon.h:55
void initImpactParameters(void)
Definition: Muon.cc:132