1 |
//
|
2 |
// $Id: Muon.h,v 1.32 2010/05/12 12:31:38 rwolf Exp $
|
3 |
//
|
4 |
|
5 |
#ifndef DataFormats_PatCandidates_Muon_h
|
6 |
#define DataFormats_PatCandidates_Muon_h
|
7 |
|
8 |
/**
|
9 |
\class pat::Muon Muon.h "DataFormats/PatCandidates/interface/Muon.h"
|
10 |
\brief Analysis-level muon class
|
11 |
|
12 |
pat::Muon implements the analysis-level muon class within the 'pat'
|
13 |
namespace.
|
14 |
|
15 |
Please post comments and questions to the Physics Tools hypernews:
|
16 |
https://hypernews.cern.ch/HyperNews/CMS/get/physTools.html
|
17 |
|
18 |
\author Steven Lowette, Giovanni Petrucciani, Frederic Ronga, Colin Bernet
|
19 |
|
20 |
\version $Id: Muon.h,v 1.32 2010/05/12 12:31:38 rwolf Exp $
|
21 |
*/
|
22 |
|
23 |
#include "DataFormats/MuonReco/interface/Muon.h"
|
24 |
#include "DataFormats/MuonReco/interface/MuonFwd.h"
|
25 |
#include "DataFormats/MuonReco/interface/MuonSelectors.h"
|
26 |
#include "DataFormats/MuonReco/interface/MuonMETCorrectionData.h"
|
27 |
|
28 |
#include "DataFormats/TrackReco/interface/Track.h"
|
29 |
#include "DataFormats/PatCandidates/interface/Lepton.h"
|
30 |
#include "DataFormats/ParticleFlowCandidate/interface/IsolatedPFCandidateFwd.h"
|
31 |
#include "DataFormats/ParticleFlowCandidate/interface/IsolatedPFCandidate.h"
|
32 |
|
33 |
|
34 |
// Define typedefs for convenience
|
35 |
namespace pat {
|
36 |
class Muon;
|
37 |
typedef std::vector<Muon> MuonCollection;
|
38 |
typedef edm::Ref<MuonCollection> MuonRef;
|
39 |
typedef edm::RefVector<MuonCollection> MuonRefVector;
|
40 |
}
|
41 |
|
42 |
|
43 |
// Class definition
|
44 |
namespace pat {
|
45 |
|
46 |
|
47 |
class Muon : public Lepton<reco::Muon> {
|
48 |
|
49 |
public:
|
50 |
|
51 |
/// default constructor
|
52 |
Muon();
|
53 |
/// constructor from a reco muon
|
54 |
Muon(const reco::Muon & aMuon);
|
55 |
/// constructor from a RefToBase to a reco muon (to be superseded by Ptr counterpart)
|
56 |
Muon(const edm::RefToBase<reco::Muon> & aMuonRef);
|
57 |
/// constructor from a Ptr to a reco muon
|
58 |
Muon(const edm::Ptr<reco::Muon> & aMuonRef);
|
59 |
/// destructor
|
60 |
virtual ~Muon();
|
61 |
|
62 |
/// required reimplementation of the Candidate's clone method
|
63 |
virtual Muon * clone() const { return new Muon(*this); }
|
64 |
|
65 |
// ---- methods for content embedding ----
|
66 |
/// reference to Track reconstructed in the tracker only (reimplemented from reco::Muon)
|
67 |
reco::TrackRef track() const;
|
68 |
using reco::RecoCandidate::track; // avoid hiding the base implementation
|
69 |
/// reference to Track reconstructed in the tracker only (reimplemented from reco::Muon)
|
70 |
reco::TrackRef innerTrack() const { return track(); }
|
71 |
/// reference to Track reconstructed in the muon detector only (reimplemented from reco::Muon)
|
72 |
reco::TrackRef standAloneMuon() const;
|
73 |
/// reference to Track reconstructed in the muon detector only (reimplemented from reco::Muon)
|
74 |
reco::TrackRef outerTrack() const { return standAloneMuon(); }
|
75 |
/// reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon)
|
76 |
reco::TrackRef combinedMuon() const;
|
77 |
/// reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon)
|
78 |
reco::TrackRef globalTrack() const { return combinedMuon(); }
|
79 |
/// set reference to Track reconstructed in the tracker only (reimplemented from reco::Muon)
|
80 |
void embedTrack();
|
81 |
/// set reference to Track reconstructed in the muon detector only (reimplemented from reco::Muon)
|
82 |
void embedStandAloneMuon();
|
83 |
/// set reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon)
|
84 |
void embedCombinedMuon();
|
85 |
|
86 |
// ---- methods for MuonMETCorrectionData ----
|
87 |
/// muon MET corrections for caloMET; returns the muon correction struct if embedded during pat tuple production or an empty element
|
88 |
reco::MuonMETCorrectionData caloMETMuonCorrs() const { return (embeddedCaloMETMuonCorrs_ ? caloMETMuonCorrs_.front() : reco::MuonMETCorrectionData());};
|
89 |
void embedCaloMETMuonCorrs(const reco::MuonMETCorrectionData& t);
|
90 |
/// muon MET corrections for tcMET; returns the muon correction struct if embedded during pat tuple production or an empty element
|
91 |
reco::MuonMETCorrectionData tcMETMuonCorrs() const {return (embeddedTCMETMuonCorrs_ ? tcMETMuonCorrs_.front() : reco::MuonMETCorrectionData());};
|
92 |
void embedTcMETMuonCorrs(const reco::MuonMETCorrectionData& t);
|
93 |
|
94 |
// ---- methods for TeV refit tracks ----
|
95 |
/// reference to Track reconstructed using hits in the tracker + "good" muon hits
|
96 |
reco::TrackRef pickyMuon() const;
|
97 |
void setPickyMuon(const reco::TrackRef& t) { pickyMuonRef_ = t; }
|
98 |
/// reference to Track reconstructed using hits in the tracker + info from the first muon station that has hits
|
99 |
reco::TrackRef tpfmsMuon() const;
|
100 |
void setTpfmsMuon(const reco::TrackRef& t) { tpfmsMuonRef_ = t; }
|
101 |
/// embed reference to the above picky Track
|
102 |
void embedPickyMuon();
|
103 |
/// embed reference to the above tpfms Track
|
104 |
void embedTpfmsMuon();
|
105 |
|
106 |
// ---- PF specific methods ----
|
107 |
/// reference to the source IsolatedPFCandidates
|
108 |
/// null if this has been built from a standard muon
|
109 |
reco::PFCandidateRef pfCandidateRef() const;
|
110 |
/// add a reference to the source IsolatedPFCandidate
|
111 |
void setPFCandidateRef(const reco::PFCandidateRef& ref) {
|
112 |
pfCandidateRef_ = ref;
|
113 |
}
|
114 |
/// embed the IsolatedPFCandidate pointed to by pfCandidateRef_
|
115 |
void embedPFCandidate();
|
116 |
|
117 |
// ---- methods for accessing muon identification ----
|
118 |
/// accessor for the various muon id algorithms currently defined
|
119 |
/// in DataFormats/MuonReco/interface/MuonSelectors.h
|
120 |
/// e.g. bool result = patmuon.muonID("TMLastStationLoose")
|
121 |
bool muonID (const std::string& name) const;
|
122 |
/// wrapper for the muonID method to maintain backwards compatibility
|
123 |
/// with when the reco::Muon::isGood method existed
|
124 |
bool isGood (const std::string& name) const { return muonID(name); }
|
125 |
/// if muon id results are ever extracted from muon id value maps
|
126 |
/// then the isMuonIDAvailable method will be defined
|
127 |
//bool isMuonIDAvailable(const std::string& name) const;
|
128 |
|
129 |
// ---- overload of isolation functions ----
|
130 |
/// Overload of pat::Lepton::trackIso(); returns the value of
|
131 |
/// the summed track pt in a cone of deltaR<0.3
|
132 |
float trackIso() const { return isolationR03().sumPt; }
|
133 |
/// Overload of pat::Lepton::trackIso(); returns the value of
|
134 |
/// the summed Et of all recHits in the ecal in a cone of
|
135 |
/// deltaR<0.3
|
136 |
float ecalIso() const { return isolationR03().emEt; }
|
137 |
/// Overload of pat::Lepton::trackIso(); returns the value of
|
138 |
/// the summed Et of all caloTowers in the hcal in a cone of
|
139 |
/// deltaR<0.4
|
140 |
float hcalIso() const { return isolationR03().hadEt; }
|
141 |
/// Overload of pat::Lepton::trackIso(); returns the sum of
|
142 |
/// ecalIso() and hcalIso
|
143 |
float caloIso() const { return ecalIso()+hcalIso(); }
|
144 |
|
145 |
/// Muon High Level Selection
|
146 |
/// The user can choose to cache this info so they can drop the
|
147 |
/// global tracks. If the global track is present these should
|
148 |
/// not be set, but the "getters" will return the appropriate
|
149 |
/// value. The exception is dB which requires the beamline
|
150 |
// as external input.
|
151 |
|
152 |
// ---- embed various impact parameters with errors ----
|
153 |
//
|
154 |
// example:
|
155 |
//
|
156 |
// // this will return the muon inner track
|
157 |
// // transverse impact parameter
|
158 |
// // relative to the primary vertex
|
159 |
// muon->dB(pat::Muon::PV2D);
|
160 |
//
|
161 |
// // this will return the uncertainty
|
162 |
// // on the muon inner track
|
163 |
// // transverse impact parameter
|
164 |
// // relative to the primary vertex
|
165 |
// // or -1.0 if there is no valid PV in the event
|
166 |
// muon->edB(pat::Muon::PV2D);
|
167 |
//
|
168 |
// IpType defines the type of the impact parameter
|
169 |
// None is default and reverts to old behavior controlled by
|
170 |
// patMuons.usePV = True/False
|
171 |
typedef enum IPTYPE
|
172 |
{
|
173 |
None = 0, PV2D = 1, PV3D = 2, BS2D = 3, BS3D = 4
|
174 |
} IpType;
|
175 |
void initImpactParameters(void); // init IP defaults in a constructor
|
176 |
double dB(IpType type = None) const;
|
177 |
double edB(IpType type = None) const;
|
178 |
void setDB ( double dB, double edB, IpType type = None )
|
179 |
{ dB_ = dB; edB_ = edB; if (type == None) cachedDB_ = true;
|
180 |
ip_[type] = dB; eip_[type] = edB; cachedIP_[type] = true;}
|
181 |
|
182 |
|
183 |
/// numberOfValidHits returns the number of valid hits on the global track.
|
184 |
unsigned int numberOfValidHits() const;
|
185 |
void setNumberOfValidHits(unsigned int numberOfValidHits )
|
186 |
{ numberOfValidHits_ = numberOfValidHits; cachedNumberOfValidHits_ = true; }
|
187 |
|
188 |
/// Norm chi2 gives the normalized chi2 of the global track.
|
189 |
double normChi2() const;
|
190 |
void setNormChi2 (double normChi2 )
|
191 |
{ normChi2_ = normChi2; cachedNormChi2_ = true; }
|
192 |
|
193 |
/// Returns the segment compatibility, using muon::segmentCompatibility (DataFormats/MuonReco/interface/MuonSelectors.h)
|
194 |
double segmentCompatibility(reco::Muon::ArbitrationType arbitrationType = reco::Muon::SegmentAndTrackArbitration) const ;
|
195 |
|
196 |
protected:
|
197 |
|
198 |
// ---- for content embedding ----
|
199 |
/// tracker of inner track detector
|
200 |
bool embeddedTrack_;
|
201 |
std::vector<reco::Track> track_;
|
202 |
/// track of muon system
|
203 |
bool embeddedStandAloneMuon_;
|
204 |
std::vector<reco::Track> standAloneMuon_;
|
205 |
/// track of combined fit
|
206 |
bool embeddedCombinedMuon_;
|
207 |
std::vector<reco::Track> combinedMuon_;
|
208 |
|
209 |
/// muon MET corrections for tcMET
|
210 |
bool embeddedTCMETMuonCorrs_;
|
211 |
std::vector<reco::MuonMETCorrectionData> tcMETMuonCorrs_;
|
212 |
/// muon MET corrections for caloMET
|
213 |
bool embeddedCaloMETMuonCorrs_;
|
214 |
std::vector<reco::MuonMETCorrectionData> caloMETMuonCorrs_;
|
215 |
|
216 |
// TeV refit tracks, which are not currently stored in the
|
217 |
// reco::Muon like the above tracks are. Also provide capability
|
218 |
// to embed them.
|
219 |
bool embeddedPickyMuon_;
|
220 |
bool embeddedTpfmsMuon_;
|
221 |
reco::TrackRef pickyMuonRef_;
|
222 |
reco::TrackRef tpfmsMuonRef_;
|
223 |
std::vector<reco::Track> pickyMuon_;
|
224 |
std::vector<reco::Track> tpfmsMuon_;
|
225 |
|
226 |
// ---- PF specific members ----
|
227 |
/// true if the IsolatedPFCandidate is embedded
|
228 |
bool embeddedPFCandidate_;
|
229 |
/// if embeddedPFCandidate_, a copy of the source IsolatedPFCandidate
|
230 |
/// is stored in this vector
|
231 |
reco::PFCandidateCollection pfCandidate_;
|
232 |
/// reference to the IsolatedPFCandidate this has been built from
|
233 |
/// null if this has been built from a standard muon
|
234 |
reco::PFCandidateRef pfCandidateRef_;
|
235 |
|
236 |
// V+Jets group selection variables.
|
237 |
bool cachedNormChi2_; /// has the normalized chi2 been cached?
|
238 |
bool cachedDB_; /// has the dB been cached?
|
239 |
|
240 |
bool cachedNumberOfValidHits_;/// has the numberOfValidHits been cached?
|
241 |
double normChi2_; /// globalTrack->chi2() / globalTrack->ndof()
|
242 |
double dB_; /// dB and edB are the impact parameter at the primary vertex,
|
243 |
double edB_; // and its uncertainty as recommended by the tracking group
|
244 |
|
245 |
// ---- cached impact parameters ----
|
246 |
std::vector<bool> cachedIP_; // has the IP (former dB) been cached?
|
247 |
std::vector<double> ip_; // dB and edB are the impact parameter at the primary vertex,
|
248 |
std::vector<double> eip_; // and its uncertainty as recommended by the tracking group
|
249 |
|
250 |
unsigned int numberOfValidHits_;/// globalTrack->numberOfValidHits()
|
251 |
|
252 |
};
|
253 |
|
254 |
|
255 |
}
|
256 |
|
257 |
#endif
|