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 
7 
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 
198  if (embeddedPFCandidate_) {
200  } else {
201  return pfCandidateRef_;
202  }
203 }
204 
207  if (embeddedPFCandidate_) {
209  } else {
210  return reco::CandidatePtr();
211  }
212 }
213 
216  muonBestTrack_.clear();
217  if (reco::Muon::muonBestTrack().isNonnull()) {
219  embeddedMuonBestTrack_ = true;
220  }
221 }
222 
223 
224 
227  track_.clear();
228  if (reco::Muon::innerTrack().isNonnull()) {
229  track_.push_back(*reco::Muon::innerTrack());
230  embeddedTrack_ = true;
231  }
232 }
233 
234 
237  standAloneMuon_.clear();
238  if (reco::Muon::outerTrack().isNonnull()) {
241  }
242 }
243 
244 
247  combinedMuon_.clear();
248  if (reco::Muon::globalTrack().isNonnull()) {
250  embeddedCombinedMuon_ = true;
251  }
252 }
253 
256  caloMETMuonCorrs_.clear();
257  caloMETMuonCorrs_.push_back(t);
259 }
260 
263  tcMETMuonCorrs_.clear();
264  tcMETMuonCorrs_.push_back(t);
266 }
267 
270  pickyMuon_.clear();
272  if (tk.isNonnull()) {
273  pickyMuon_.push_back(*tk);
274  embeddedPickyMuon_ = true;
275  }
276 }
277 
280  tpfmsMuon_.clear();
282  if (tk.isNonnull()) {
283  tpfmsMuon_.push_back(*tk);
284  embeddedTpfmsMuon_ = true;
285  }
286 }
287 
290  dytMuon_.clear();
292  if (tk.isNonnull()) {
293  dytMuon_.push_back(*tk);
294  embeddedDytMuon_ = true;
295  }
296 }
297 
300  pfCandidate_.clear();
302  pfCandidate_.push_back( *pfCandidateRef_ );
303  embeddedPFCandidate_ = true;
304  }
305 }
306 
307 bool Muon::muonID(const std::string& name) const {
309  return muon::isGoodMuon(*this, st);
310 }
311 
312 
317 double Muon::normChi2() const {
318  if ( cachedNormChi2_ ) {
319  return normChi2_;
320  } else {
322  return t->chi2() / t->ndof();
323  }
324 }
325 
330 unsigned int Muon::numberOfValidHits() const {
331  if ( cachedNumberOfValidHits_ ) {
332  return numberOfValidHits_;
333  } else {
335  return t->numberOfValidHits();
336  }
337 }
338 
339 // embed various impact parameters with errors
340 // IpType defines the type of the impact parameter
341 // None is default and reverts to old behavior controlled by
342 // patMuons.usePV = True/False
343 double Muon::dB(IpType type_) const {
344 
345  // preserve old functionality exactly
346  if (type_ == None){
347  if ( cachedDB_ ) {
348  return dB_;
349  }
350  else {
352  }
353  }
354 
355  // more IP types (new)
356  else if ( cachedIP_[type_] ) {
357  return ip_[type_];
358  } else {
360  }
361 }
362 
363 
364 // embed various impact parameters with errors
365 // IpType defines the type of the impact parameter
366 // None is default and reverts to old behavior controlled by
367 // patMuons.usePV = True/False
368 double Muon::edB(IpType type_) const {
369 
370  // preserve old functionality exactly
371  if (type_ == None){
372  if ( cachedDB_ ) {
373  return edB_;
374  }
375  else {
377  }
378  }
379 
380  // more IP types (new)
381  else if ( cachedIP_[type_] ) {
382  return eip_[type_];
383  } else {
385  }
386 }
387 
388 
390  return muon::segmentCompatibility(*this, arbitrationType);
391 }
392 
393 // Selectors
394 bool Muon::isTightMuon(const reco::Vertex&vtx) const {
395  return muon::isTightMuon(*this, vtx);
396 }
397 
398 bool Muon::isLooseMuon() const {
399  return muon::isLooseMuon(*this);
400 
401 }
402 
403 bool Muon::isSoftMuon(const reco::Vertex& vtx) const {
404  return muon::isSoftMuon(*this, vtx);
405 }
406 
407 
408 bool Muon::isHighPtMuon(const reco::Vertex& vtx) const{
409  return muon::isHighPtMuon(*this, vtx);
410 }
411 
double normChi2() const
Norm chi2 gives the normalized chi2 of the global track.
Definition: Muon.cc:317
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:236
reco::PFCandidateRef pfCandidateRef_
Definition: Muon.h:266
unsigned int numberOfValidHits() const
numberOfValidHits returns the number of valid hits on the global track.
Definition: Muon.cc:330
reco::TrackRef innerTrack() const
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.h:72
bool embeddedTCMETMuonCorrs_
muon MET corrections for tcMET
Definition: Muon.h:244
void embedPFCandidate()
embed the IsolatedPFCandidate pointed to by pfCandidateRef_
Definition: Muon.cc:299
size_t size_type
Definition: Candidate.h:34
bool muonID(const std::string &name) const
Definition: Muon.cc:307
unsigned int numberOfValidHits_
Definition: Muon.h:282
virtual TrackRef innerTrack() const
Definition: Muon.h:48
unsigned int type_
muon type mask
Definition: Muon.h:269
bool embeddedTrack_
track of inner track detector
Definition: Muon.h:234
std::vector< reco::MuonMETCorrectionData > tcMETMuonCorrs_
Definition: Muon.h:245
bool cachedNumberOfValidHits_
has the dB been cached?
Definition: Muon.h:272
double segmentCompatibility(reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration) const
Returns the segment compatibility, using muon::segmentCompatibility (DataFormats/MuonReco/interface/M...
Definition: Muon.cc:389
bool embeddedStandAloneMuon_
track of muon system
Definition: Muon.h:237
bool isAvailable() const
Definition: Ref.h:276
bool embeddedPickyMuon_
Definition: Muon.h:251
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:269
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:246
SelectionType
Selector type.
Definition: MuonSelectors.h:17
bool isSoftMuon(const reco::Muon &, const reco::Vertex &)
std::vector< reco::Track > pickyMuon_
Definition: Muon.h:254
void embedCaloMETMuonCorrs(const reco::MuonMETCorrectionData &t)
embed the MuonMETCorrectionData for muon corrected caloMET
Definition: Muon.cc:255
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:206
bool embeddedTpfmsMuon_
Definition: Muon.h:252
bool cachedNormChi2_
Definition: Muon.h:269
reco::PFCandidateRef pfCandidateRef() const
reference to the source IsolatedPFCandidates
Definition: Muon.cc:197
std::vector< reco::MuonMETCorrectionData > caloMETMuonCorrs_
Definition: Muon.h:248
reco::PFCandidateCollection pfCandidate_
Definition: Muon.h:263
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:256
double normChi2_
has the numberOfValidHits been cached?
Definition: Muon.h:273
const T & max(const T &a, const T &b)
bool isLooseMuon() const
Definition: Muon.cc:398
enum pat::Muon::IPTYPE IpType
void embedTrack()
set reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.cc:226
ArbitrationType
define arbitration schemes
Definition: Muon.h:178
void embedTcMETMuonCorrs(const reco::MuonMETCorrectionData &t)
embed the MuonMETCorrectionData for tcMET
Definition: Muon.cc:262
Analysis-level lepton class.
Definition: Lepton.h:30
bool embeddedDytMuon_
Definition: Muon.h:253
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:278
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
bool embeddedPFCandidate_
true if the IsolatedPFCandidate is embedded
Definition: Muon.h:260
double dB(IpType type=None) const
Definition: Muon.cc:343
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:80
bool embeddedCaloMETMuonCorrs_
muon MET corrections for caloMET
Definition: Muon.h:247
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:408
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:394
void embedTpfmsMuon()
embed reference to the above tpfms Track
Definition: Muon.cc:279
std::vector< double > ip_
Definition: Muon.h:279
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:240
bool isSoftMuon(const reco::Vertex &) const
Definition: Muon.cc:403
void embedDytMuon()
embed reference to the above dyt Track
Definition: Muon.cc:289
double edB(IpType type=None) const
Definition: Muon.cc:368
std::vector< double > eip_
Definition: Muon.h:280
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:215
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:270
std::vector< reco::Track > muonBestTrack_
Definition: Muon.h:232
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:235
std::vector< reco::Track > combinedMuon_
Definition: Muon.h:241
std::vector< reco::Track > standAloneMuon_
Definition: Muon.h:238
virtual ~Muon()
destructor
Definition: Muon.cc:110
double edB_
dB and edB are the impact parameter at the primary vertex,
Definition: Muon.h:275
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
double dB_
globalTrack-&gt;chi2() / globalTrack-&gt;ndof()
Definition: Muon.h:274
ProductID id() const
Accessor for product ID.
Definition: Ref.h:256
volatile std::atomic< bool > shutdown_flag false
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:49
bool embeddedMuonBestTrack_
best muon track
Definition: Muon.h:231
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:255
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