File indexing completed on 2024-04-06 12:04:47
0001 #ifndef MuonReco_Muon_h
0002 #define MuonReco_Muon_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
0016 #include "DataFormats/MuonReco/interface/MuonChamberMatch.h"
0017 #include "DataFormats/MuonReco/interface/MuonIsolation.h"
0018 #include "DataFormats/MuonReco/interface/MuonPFIsolation.h"
0019 #include "DataFormats/MuonReco/interface/MuonEnergy.h"
0020 #include "DataFormats/MuonReco/interface/MuonTime.h"
0021 #include "DataFormats/MuonReco/interface/MuonQuality.h"
0022 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0023 #include "DataFormats/TrackReco/interface/Track.h"
0024
0025 namespace reco {
0026
0027 class Muon : public RecoCandidate {
0028 public:
0029 Muon();
0030
0031 Muon(Charge, const LorentzVector&, const Point& = Point(0, 0, 0));
0032
0033 Muon* clone() const override;
0034
0035
0036 enum MuonTrackType { None, InnerTrack, OuterTrack, CombinedTrack, TPFMS, Picky, DYT };
0037 typedef std::map<MuonTrackType, reco::TrackRef> MuonTrackRefMap;
0038 typedef std::pair<TrackRef, Muon::MuonTrackType> MuonTrackTypePair;
0039
0040
0041
0042
0043
0044 using reco::RecoCandidate::track;
0045 virtual TrackRef innerTrack() const { return innerTrack_; }
0046 TrackRef track() const override { return innerTrack(); }
0047
0048 virtual TrackRef outerTrack() const { return outerTrack_; }
0049 TrackRef standAloneMuon() const override { return outerTrack(); }
0050
0051 virtual TrackRef globalTrack() const { return globalTrack_; }
0052 TrackRef combinedMuon() const override { return globalTrack(); }
0053
0054 virtual TrackRef tpfmsTrack() const { return muonTrackFromMap(TPFMS); }
0055 virtual TrackRef pickyTrack() const { return muonTrackFromMap(Picky); }
0056 virtual TrackRef dytTrack() const { return muonTrackFromMap(DYT); }
0057
0058 const Track* bestTrack() const override { return muonTrack(bestTrackType_).get(); }
0059 TrackBaseRef bestTrackRef() const override { return reco::TrackBaseRef(muonTrack(bestTrackType_)); }
0060 virtual TrackRef muonBestTrack() const { return muonTrack(bestTrackType_); }
0061 virtual MuonTrackType muonBestTrackType() const { return bestTrackType_; }
0062 virtual TrackRef tunePMuonBestTrack() const { return muonTrack(bestTunePTrackType_); }
0063 virtual MuonTrackType tunePMuonBestTrackType() const { return bestTunePTrackType_; }
0064
0065 bool isAValidMuonTrack(const MuonTrackType& type) const;
0066 TrackRef muonTrack(const MuonTrackType&) const;
0067
0068 TrackRef muonTrackFromMap(const MuonTrackType& type) const {
0069 MuonTrackRefMap::const_iterator iter = refittedTrackMap_.find(type);
0070 if (iter != refittedTrackMap_.end())
0071 return iter->second;
0072 else
0073 return TrackRef();
0074 }
0075
0076
0077 virtual void setInnerTrack(const TrackRef& t);
0078 virtual void setTrack(const TrackRef& t);
0079
0080 virtual void setOuterTrack(const TrackRef& t);
0081 virtual void setStandAlone(const TrackRef& t);
0082
0083 virtual void setGlobalTrack(const TrackRef& t);
0084 virtual void setCombined(const TrackRef& t);
0085
0086 virtual void setBestTrack(MuonTrackType muonType) { bestTrackType_ = muonType; }
0087
0088 virtual void setTunePBestTrack(MuonTrackType muonType) { bestTunePTrackType_ = muonType; }
0089
0090 void setMuonTrack(const MuonTrackType&, const TrackRef&);
0091
0092
0093
0094
0095
0096
0097 reco::Candidate::LorentzVector pfP4() const { return pfP4_; }
0098 virtual void setPFP4(const reco::Candidate::LorentzVector& p4_);
0099
0100
0101
0102
0103
0104 bool isEnergyValid() const { return energyValid_; }
0105
0106 MuonEnergy calEnergy() const { return calEnergy_; }
0107
0108 void setCalEnergy(const MuonEnergy& calEnergy) {
0109 calEnergy_ = calEnergy;
0110 energyValid_ = true;
0111 }
0112
0113
0114
0115
0116
0117 bool isQualityValid() const { return qualityValid_; }
0118
0119 MuonQuality combinedQuality() const { return combinedQuality_; }
0120
0121 void setCombinedQuality(const MuonQuality& combinedQuality) {
0122 combinedQuality_ = combinedQuality;
0123 qualityValid_ = true;
0124 }
0125
0126
0127
0128
0129
0130 bool isTimeValid() const { return (time_.nDof > 0); }
0131
0132 MuonTime time() const { return time_; }
0133
0134 void setTime(const MuonTime& time) { time_ = time; }
0135
0136 MuonTime rpcTime() const { return rpcTime_; }
0137
0138 void setRPCTime(const MuonTime& time) { rpcTime_ = time; }
0139
0140
0141
0142
0143 bool isMatchesValid() const { return matchesValid_; }
0144
0145 std::vector<MuonChamberMatch>& matches() { return muMatches_; }
0146 const std::vector<MuonChamberMatch>& matches() const { return muMatches_; }
0147
0148 void setMatches(const std::vector<MuonChamberMatch>& matches) {
0149 muMatches_ = matches;
0150 matchesValid_ = true;
0151 }
0152
0153
0154
0155
0156
0157
0158 float caloCompatibility() const { return caloCompatibility_; }
0159 void setCaloCompatibility(float input) { caloCompatibility_ = input; }
0160 bool isCaloCompatibilityValid() const { return caloCompatibility_ >= 0; }
0161
0162
0163
0164
0165
0166 const MuonIsolation& isolationR03() const { return isolationR03_; }
0167 const MuonIsolation& isolationR05() const { return isolationR05_; }
0168
0169 const MuonPFIsolation& pfIsolationR03() const { return pfIsolationR03_; }
0170 const MuonPFIsolation& pfMeanDRIsoProfileR03() const { return pfIsoMeanDRR03_; }
0171 const MuonPFIsolation& pfSumDRIsoProfileR03() const { return pfIsoSumDRR03_; }
0172 const MuonPFIsolation& pfIsolationR04() const { return pfIsolationR04_; }
0173 const MuonPFIsolation& pfMeanDRIsoProfileR04() const { return pfIsoMeanDRR04_; }
0174 const MuonPFIsolation& pfSumDRIsoProfileR04() const { return pfIsoSumDRR04_; }
0175
0176 void setIsolation(const MuonIsolation& isoR03, const MuonIsolation& isoR05);
0177 bool isIsolationValid() const { return isolationValid_; }
0178 void setPFIsolation(const std::string& label, const reco::MuonPFIsolation& deposit);
0179
0180 bool isPFIsolationValid() const { return pfIsolationValid_; }
0181
0182
0183
0184
0185
0186
0187 enum ArbitrationType {
0188 NoArbitration,
0189 SegmentArbitration,
0190 SegmentAndTrackArbitration,
0191 SegmentAndTrackArbitrationCleaned,
0192 RPCHitAndTrackArbitration,
0193 GEMSegmentAndTrackArbitration,
0194 ME0SegmentAndTrackArbitration,
0195 GEMHitAndTrackArbitration
0196 };
0197
0198
0199
0200
0201
0202 enum Selector {
0203 CutBasedIdLoose = 0,
0204 CutBasedIdMedium = 1,
0205 CutBasedIdMediumPrompt = 2,
0206 CutBasedIdTight = 3,
0207 CutBasedIdGlobalHighPt = 4,
0208 CutBasedIdTrkHighPt = 5,
0209 PFIsoVeryLoose = 6,
0210 PFIsoLoose = 7,
0211 PFIsoMedium = 8,
0212 PFIsoTight = 9,
0213 PFIsoVeryTight = 10,
0214 TkIsoLoose = 11,
0215 TkIsoTight = 12,
0216 SoftCutBasedId = 13,
0217 SoftMvaId = 14,
0218 MvaLoose = 15,
0219 MvaMedium = 16,
0220 MvaTight = 17,
0221 MiniIsoLoose = 18,
0222 MiniIsoMedium = 19,
0223 MiniIsoTight = 20,
0224 MiniIsoVeryTight = 21,
0225 TriggerIdLoose = 22,
0226 InTimeMuon = 23,
0227 PFIsoVeryVeryTight = 24,
0228 MultiIsoLoose = 25,
0229 MultiIsoMedium = 26,
0230 PuppiIsoLoose = 27,
0231 PuppiIsoMedium = 28,
0232 PuppiIsoTight = 29,
0233 MvaVTight = 30,
0234 MvaVVTight = 31,
0235 LowPtMvaLoose = 32,
0236 LowPtMvaMedium = 33,
0237 MvaIDwpMedium = 34,
0238 MvaIDwpTight = 35,
0239 };
0240
0241 bool passed(uint64_t selection) const { return (selectors_ & selection) == selection; }
0242 bool passed(Selector selection) const { return passed(static_cast<uint64_t>(1UL << selection)); }
0243 uint64_t selectors() const { return selectors_; }
0244 void setSelectors(uint64_t selectors) { selectors_ = selectors; }
0245 void setSelector(Selector selector, bool passed) {
0246 auto selector64 = 1UL << selector;
0247 if (passed)
0248 selectors_ |= selector64;
0249 else
0250 selectors_ &= ~selector64;
0251 }
0252
0253
0254
0255
0256
0257 int numberOfChambers() const { return muMatches_.size(); }
0258
0259 int numberOfChambersCSCorDT() const;
0260
0261 int numberOfMatches(ArbitrationType type = SegmentAndTrackArbitration) const;
0262
0263
0264 int numberOfMatchedStations(ArbitrationType type = SegmentAndTrackArbitration) const;
0265
0266
0267 unsigned int expectedNnumberOfMatchedStations(float minDistanceFromEdge = 10.0) const;
0268
0269
0270
0271 unsigned int stationMask(ArbitrationType type = SegmentAndTrackArbitration) const;
0272
0273
0274
0275 int numberOfMatchedRPCLayers(ArbitrationType type = RPCHitAndTrackArbitration) const;
0276 unsigned int RPClayerMask(ArbitrationType type = RPCHitAndTrackArbitration) const;
0277 unsigned int stationGapMaskDistance(float distanceCut = 10.) const;
0278
0279 unsigned int stationGapMaskPull(float sigmaCut = 3.) const;
0280
0281 int nDigisInStation(int station, int muonSubdetId) const;
0282
0283 bool hasShowerInStation(int station, int muonSubdetId, int nDtDigisCut = 20, int nCscDigisCut = 36) const;
0284
0285 int numberOfShowers(int nDtDigisCut = 20, int nCscDigisCut = 36) const;
0286
0287
0288
0289 static const unsigned int GlobalMuon = 1 << 1;
0290 static const unsigned int TrackerMuon = 1 << 2;
0291 static const unsigned int StandAloneMuon = 1 << 3;
0292 static const unsigned int CaloMuon = 1 << 4;
0293 static const unsigned int PFMuon = 1 << 5;
0294 static const unsigned int RPCMuon = 1 << 6;
0295 static const unsigned int GEMMuon = 1 << 7;
0296 static const unsigned int ME0Muon = 1 << 8;
0297
0298 void setType(unsigned int type) { type_ = type; }
0299 unsigned int type() const { return type_; }
0300
0301
0302 bool isMuon() const override { return true; }
0303 bool isGlobalMuon() const override { return type_ & GlobalMuon; }
0304 bool isTrackerMuon() const override { return type_ & TrackerMuon; }
0305 bool isStandAloneMuon() const override { return type_ & StandAloneMuon; }
0306 bool isCaloMuon() const override { return type_ & CaloMuon; }
0307 bool isPFMuon() const { return type_ & PFMuon; }
0308 bool isRPCMuon() const { return type_ & RPCMuon; }
0309 bool isGEMMuon() const { return type_ & GEMMuon; }
0310 bool isME0Muon() const { return type_ & ME0Muon; }
0311
0312 private:
0313
0314 bool overlap(const Candidate&) const override;
0315
0316 TrackRef innerTrack_;
0317
0318 TrackRef outerTrack_;
0319
0320 TrackRef globalTrack_;
0321
0322 MuonTrackRefMap refittedTrackMap_;
0323
0324 MuonTrackType bestTrackType_;
0325
0326 MuonTrackType bestTunePTrackType_;
0327
0328
0329 MuonEnergy calEnergy_;
0330
0331 MuonQuality combinedQuality_;
0332
0333 std::vector<MuonChamberMatch> muMatches_;
0334
0335 MuonTime time_;
0336 MuonTime rpcTime_;
0337 bool energyValid_;
0338 bool matchesValid_;
0339 bool isolationValid_;
0340 bool pfIsolationValid_;
0341 bool qualityValid_;
0342
0343 float caloCompatibility_;
0344
0345 MuonIsolation isolationR03_;
0346 MuonIsolation isolationR05_;
0347
0348
0349 MuonPFIsolation pfIsolationR03_;
0350 MuonPFIsolation pfIsoMeanDRR03_;
0351 MuonPFIsolation pfIsoSumDRR03_;
0352 MuonPFIsolation pfIsolationR04_;
0353 MuonPFIsolation pfIsoMeanDRR04_;
0354 MuonPFIsolation pfIsoSumDRR04_;
0355
0356
0357 unsigned int type_;
0358
0359
0360 reco::Candidate::LorentzVector pfP4_;
0361
0362
0363
0364
0365 const std::vector<const MuonChamberMatch*> chambers(int station, int muonSubdetId) const;
0366
0367 std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> pair(
0368 const std::vector<const MuonChamberMatch*>&, ArbitrationType type = SegmentAndTrackArbitration) const;
0369
0370 uint64_t selectors_;
0371
0372 public:
0373
0374 int numberOfSegments(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0375
0376
0377 float dX(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0378 float dY(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0379 float dDxDz(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0380 float dDyDz(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0381 float pullX(int station,
0382 int muonSubdetId,
0383 ArbitrationType type = SegmentAndTrackArbitration,
0384 bool includeSegmentError = true) const;
0385 float pullY(int station,
0386 int muonSubdetId,
0387 ArbitrationType type = SegmentAndTrackArbitration,
0388 bool includeSegmentError = true) const;
0389 float pullDxDz(int station,
0390 int muonSubdetId,
0391 ArbitrationType type = SegmentAndTrackArbitration,
0392 bool includeSegmentError = true) const;
0393 float pullDyDz(int station,
0394 int muonSubdetId,
0395 ArbitrationType type = SegmentAndTrackArbitration,
0396 bool includeSegmentError = true) const;
0397
0398
0399 float segmentX(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0400 float segmentY(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0401 float segmentDxDz(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0402 float segmentDyDz(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0403 float segmentXErr(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0404 float segmentYErr(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0405 float segmentDxDzErr(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0406 float segmentDyDzErr(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0407
0408
0409
0410
0411 float trackEdgeX(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0412 float trackEdgeY(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0413 float trackX(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0414 float trackY(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0415 float trackDxDz(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0416 float trackDyDz(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0417 float trackXErr(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0418 float trackYErr(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0419 float trackDxDzErr(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0420 float trackDyDzErr(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0421 float trackDist(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0422 float trackDistErr(int station, int muonSubdetId, ArbitrationType type = SegmentAndTrackArbitration) const;
0423
0424 float t0(int n = 0) {
0425 int i = 0;
0426 for (auto& chamber : muMatches_) {
0427 int segmentMatchesSize = (int)chamber.segmentMatches.size();
0428 if (i + segmentMatchesSize < n) {
0429 i += segmentMatchesSize;
0430 continue;
0431 }
0432 return chamber.segmentMatches[n - i].t0;
0433 }
0434 return 0;
0435 }
0436 };
0437
0438 }
0439
0440 #endif