CMS 3D CMS Logo

PFMuonAlgo.h
Go to the documentation of this file.
1 #ifndef RecoParticleFlow_PFProducer_PFMuonAlgo_h
2 #define RecoParticleFlow_PFProducer_PFMuonAlgo_h
12 
13 class PFMuonAlgo {
16 
17 public:
20 
22 
24  static bool isMuon(const reco::PFBlockElement& elt);
25  static bool isLooseMuon(const reco::PFBlockElement& elt);
26  static bool isGlobalTightMuon(const reco::PFBlockElement& elt);
27  static bool isGlobalLooseMuon(const reco::PFBlockElement& elt);
28  static bool isTrackerTightMuon(const reco::PFBlockElement& elt);
29  static bool isTrackerLooseMuon(const reco::PFBlockElement& elt);
30  static bool isIsolatedMuon(const reco::PFBlockElement& elt);
31  static bool isMuon(const reco::MuonRef& muonRef);
32  static bool isLooseMuon(const reco::MuonRef& muonRef);
33  static bool isGlobalTightMuon(const reco::MuonRef& muonRef);
34  static bool isGlobalLooseMuon(const reco::MuonRef& muonRef);
35 
36  static bool isTrackerTightMuon(const reco::MuonRef& muonRef);
37  static bool isTrackerLooseMuon(const reco::MuonRef& muonRef);
38  static bool isIsolatedMuon(const reco::MuonRef& muonRef);
39  static bool isTightMuonPOG(const reco::MuonRef& muonRef);
40  static void printMuonProperties(const reco::MuonRef& muonRef);
41 
43  static bool hasValidTrack(const reco::MuonRef& muonRef, bool loose, double maxDPtOPt);
44 
45  //Make a PF Muon : Basic method
46  bool reconstructMuon(reco::PFCandidate&, const reco::MuonRef&, bool allowLoose = false);
47 
48  //Assign a different track to the muon
50  //PF Post cleaning algorithm
54  void setVetoes(const reco::PFCandidateCollection& vetoes) { vetoes_ = &vetoes; }
55 
56  std::unique_ptr<reco::PFCandidateCollection> transferCleanedCosmicCandidates() {
58  }
59 
60  std::unique_ptr<reco::PFCandidateCollection> transferCleanedTrackerAndGlobalCandidates() {
62  }
63 
64  std::unique_ptr<reco::PFCandidateCollection> transferCleanedFakeCandidates() {
66  }
67 
68  std::unique_ptr<reco::PFCandidateCollection> transferPunchThroughCleanedMuonCandidates() {
70  }
71 
72  std::unique_ptr<reco::PFCandidateCollection> transferPunchThroughCleanedHadronCandidates() {
74  }
75 
76  std::unique_ptr<reco::PFCandidateCollection> transferAddedMuonCandidates() {
78  }
79 
80  static std::vector<reco::Muon::MuonTrackTypePair> muonTracks(const reco::MuonRef& muon,
81  double maxDPtOPt = 1e+9,
82  bool includeSA = false);
83 
84  static int muAssocToTrack(const reco::TrackRef& trackref, const reco::MuonCollection& muons);
85 
86 private:
87  //Give the track with the smallest Dpt/Pt
88  MuonTrackTypePair getTrackWithSmallestError(const std::vector<MuonTrackTypePair>&);
89 
90  //Estimate MET and SUmET for post cleaning
92 
93  //Post cleaning Sub-methods
94  bool cleanMismeasured(reco::PFCandidate&, unsigned int);
96 
97  void removeDeadCandidates(reco::PFCandidateCollection*, const std::vector<unsigned int>&);
98 
99  //helpers
100  std::pair<double, double> getMinMaxMET2(const reco::PFCandidate&);
101  std::vector<MuonTrackTypePair> tracksWithBetterMET(const std::vector<MuonTrackTypePair>&, const reco::PFCandidate&);
102  std::vector<MuonTrackTypePair> tracksPointingAtMET(const std::vector<MuonTrackTypePair>&);
103 
104  //Output collections for post cleaning
106  std::unique_ptr<reco::PFCandidateCollection> pfCosmicsMuonCleanedCandidates_;
108  std::unique_ptr<reco::PFCandidateCollection> pfCleanedTrackerAndGlobalMuonCandidates_;
110  std::unique_ptr<reco::PFCandidateCollection> pfFakeMuonCleanedCandidates_;
112  std::unique_ptr<reco::PFCandidateCollection> pfPunchThroughMuonCleanedCandidates_;
114  std::unique_ptr<reco::PFCandidateCollection> pfPunchThroughHadronCleanedCandidates_;
116  std::unique_ptr<reco::PFCandidateCollection> pfAddedMuonCandidates_;
117 
118  std::vector<unsigned int> maskedIndices_;
119 
121 
124 
125  //Configurables
126  // for PFMuonAlgo::goodMuonTracks/muonTracks
127  const double maxDPtOPt_;
128  // for PFMuonAlgo::reconstructMuon
130  const double errorCompScale_;
131  // for postCleaning (postClean/addMissingMuons)
132  const bool postCleaning_;
134  const double minPostCleaningPt_;
135  const double eventFactorCosmics_;
136  const double metSigForCleaning_;
137  const double metSigForRejection_;
138  const double metFactorCleaning_;
140  const double metFactorRejection_;
141  const double metFactorHighEta_;
142  const double ptFactorHighEta_;
143  const double metFactorFake_;
146  const double punchThroughFactor_;
148  const double cosmicRejDistance_;
149 
150  double sumetPU_;
151  double sumet_;
152  double METX_;
153  double METY_;
154 
156 
158  public:
159  TrackMETComparator(double METX, double METY) {
160  metx_ = METX;
161  mety_ = METY;
162  }
164 
165  bool operator()(const MuonTrackTypePair& mu1, const MuonTrackTypePair& mu2) {
166  return pow(metx_ + mu1.first->px(), 2) + pow(mety_ + mu1.first->py(), 2) <
167  pow(metx_ + mu2.first->px(), 2) + pow(mety_ + mu2.first->py(), 2);
168  }
169 
170  private:
171  double metx_;
172  double mety_;
173  };
174 
176  public:
179 
180  bool operator()(int mu1, int mu2) { return coll_->at(mu1).pt() > coll_->at(mu2).pt(); }
181 
182  private:
184  };
185 
187  public:
190 
191  bool operator()(const MuonTrackTypePair& mu1, const MuonTrackTypePair& mu2) {
192  return mu1.first->ptError() / mu1.first->pt() < mu2.first->ptError() / mu2.first->pt();
193  }
194  };
195 };
196 
197 #endif
Abstract base class for a PFBlock element (track, cluster...)
static bool isIsolatedMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:94
static int muAssocToTrack(const reco::TrackRef &trackref, const reco::MuonCollection &muons)
Definition: PFMuonAlgo.cc:479
bool cleanMismeasured(reco::PFCandidate &, unsigned int)
Definition: PFMuonAlgo.cc:845
static bool isTightMuonPOG(const reco::MuonRef &muonRef)
Definition: PFMuonAlgo.cc:323
double sumet_
Definition: PFMuonAlgo.h:151
void removeDeadCandidates(reco::PFCandidateCollection *, const std::vector< unsigned int > &)
Definition: PFMuonAlgo.cc:1033
std::unique_ptr< reco::PFCandidateCollection > pfPunchThroughMuonCleanedCandidates_
the collection of punch-through cleaned muon candidates
Definition: PFMuonAlgo.h:112
void addMissingMuons(edm::Handle< reco::MuonCollection >, reco::PFCandidateCollection *cands)
Definition: PFMuonAlgo.cc:724
bool operator()(int mu1, int mu2)
Definition: PFMuonAlgo.h:180
static bool isMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:48
const double minPunchThroughEnergy_
Definition: PFMuonAlgo.h:145
static bool isTrackerLooseMuon(const reco::PFBlockElement &elt)
const double metFactorRejection_
Definition: PFMuonAlgo.h:140
TrackQuality
track quality
Definition: TrackBase.h:150
std::unique_ptr< reco::PFCandidateCollection > transferAddedMuonCandidates()
Definition: PFMuonAlgo.h:76
const bool postCleaning_
Definition: PFMuonAlgo.h:132
std::unique_ptr< reco::PFCandidateCollection > pfFakeMuonCleanedCandidates_
the collection of fake cleaned muon candidates
Definition: PFMuonAlgo.h:110
static bool isGlobalLooseMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:76
const double minPunchThroughMomentum_
Definition: PFMuonAlgo.h:144
std::unique_ptr< reco::PFCandidateCollection > transferCleanedTrackerAndGlobalCandidates()
Definition: PFMuonAlgo.h:60
bool cleanPunchThroughAndFakes(reco::PFCandidate &, reco::PFCandidateCollection *, unsigned int)
Definition: PFMuonAlgo.cc:943
void setInputsForCleaning(reco::VertexCollection const &)
Definition: PFMuonAlgo.cc:941
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
reco::Muon::MuonTrackTypePair MuonTrackTypePair
Definition: PFMuonAlgo.h:14
const double punchThroughFactor_
Definition: PFMuonAlgo.h:146
void setVetoes(const reco::PFCandidateCollection &vetoes)
Definition: PFMuonAlgo.h:54
std::unique_ptr< reco::PFCandidateCollection > pfCleanedTrackerAndGlobalMuonCandidates_
the collection of tracker/global cleaned muon candidates
Definition: PFMuonAlgo.h:108
const double maxDPtOPt_
Definition: PFMuonAlgo.h:127
const double metFactorCleaning_
Definition: PFMuonAlgo.h:138
static void printMuonProperties(const reco::MuonRef &muonRef)
Definition: PFMuonAlgo.cc:355
std::vector< MuonTrackTypePair > tracksPointingAtMET(const std::vector< MuonTrackTypePair > &)
Definition: PFMuonAlgo.cc:924
static bool isGlobalTightMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:67
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
TrackMETComparator(double METX, double METY)
Definition: PFMuonAlgo.h:159
MuonTrackTypePair getTrackWithSmallestError(const std::vector< MuonTrackTypePair > &)
Definition: PFMuonAlgo.cc:614
const double metFactorHighEta_
Definition: PFMuonAlgo.h:141
const double cosmicRejDistance_
Definition: PFMuonAlgo.h:148
const double minPostCleaningPt_
Definition: PFMuonAlgo.h:134
void estimateEventQuantities(const reco::PFCandidateCollection *)
Definition: PFMuonAlgo.cc:620
const double ptFactorHighEta_
Definition: PFMuonAlgo.h:142
void changeTrack(reco::PFCandidate &, const MuonTrackTypePair &)
Definition: PFMuonAlgo.cc:596
const double eventFractionCleaning_
Definition: PFMuonAlgo.h:133
std::unique_ptr< reco::PFCandidateCollection > pfAddedMuonCandidates_
the collection of added muon candidates
Definition: PFMuonAlgo.h:116
bool operator()(const MuonTrackTypePair &mu1, const MuonTrackTypePair &mu2)
Definition: PFMuonAlgo.h:191
IndexPtComparator(const reco::PFCandidateCollection *coll)
Definition: PFMuonAlgo.h:177
const double metFactorFake_
Definition: PFMuonAlgo.h:143
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
PFMuonAlgo(edm::ParameterSet const &, bool postMuonCleaning)
constructor
Definition: PFMuonAlgo.cc:17
static void fillPSetDescription(edm::ParameterSetDescription &iDesc)
Definition: PFMuonAlgo.cc:1043
static bool isLooseMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:57
double METX_
Definition: PFMuonAlgo.h:152
const reco::PFCandidateCollection * vetoes_
Definition: PFMuonAlgo.h:120
static std::vector< reco::Muon::MuonTrackTypePair > muonTracks(const reco::MuonRef &muon, double maxDPtOPt=1e+9, bool includeSA=false)
Definition: PFMuonAlgo.cc:486
const double eventFactorCosmics_
Definition: PFMuonAlgo.h:135
std::pair< double, double > getMinMaxMET2(const reco::PFCandidate &)
Definition: PFMuonAlgo.cc:826
std::unique_ptr< reco::PFCandidateCollection > transferCleanedCosmicCandidates()
Definition: PFMuonAlgo.h:56
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
std::unique_ptr< reco::PFCandidateCollection > transferCleanedFakeCandidates()
Definition: PFMuonAlgo.h:64
reco::Muon::MuonTrackType MuonTrackType
Definition: PFMuonAlgo.h:15
double sumetPU_
Definition: PFMuonAlgo.h:150
std::vector< unsigned int > maskedIndices_
Definition: PFMuonAlgo.h:118
constexpr auto loose
const reco::PFCandidateCollection * coll_
Definition: PFMuonAlgo.h:183
static bool hasValidTrack(const reco::MuonRef &muonRef, bool loose, double maxDPtOPt)
Definition: PFMuonAlgo.cc:348
const reco::VertexCollection * vertices_
Definition: PFMuonAlgo.h:123
MuonTrackType
map for Global Muon refitters
Definition: Muon.h:36
const double punchThroughMETFactor_
Definition: PFMuonAlgo.h:147
std::pair< TrackRef, Muon::MuonTrackType > MuonTrackTypePair
Definition: Muon.h:38
std::unique_ptr< reco::PFCandidateCollection > pfCosmicsMuonCleanedCandidates_
the collection of cosmics cleaned muon candidates
Definition: PFMuonAlgo.h:106
std::vector< MuonTrackTypePair > tracksWithBetterMET(const std::vector< MuonTrackTypePair > &, const reco::PFCandidate &)
Definition: PFMuonAlgo.cc:899
void postClean(reco::PFCandidateCollection *)
Definition: PFMuonAlgo.cc:633
std::unique_ptr< reco::PFCandidateCollection > transferPunchThroughCleanedHadronCandidates()
Definition: PFMuonAlgo.h:72
bool operator()(const MuonTrackTypePair &mu1, const MuonTrackTypePair &mu2)
Definition: PFMuonAlgo.h:165
const double eventFractionRejection_
Definition: PFMuonAlgo.h:139
const double errorCompScale_
Definition: PFMuonAlgo.h:130
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
def move(src, dest)
Definition: eostools.py:511
const double metSigForCleaning_
Definition: PFMuonAlgo.h:136
static bool isTrackerTightMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:85
const reco::TrackBase::TrackQuality trackQuality_
Definition: PFMuonAlgo.h:129
const double metSigForRejection_
Definition: PFMuonAlgo.h:137
std::unique_ptr< reco::PFCandidateCollection > pfPunchThroughHadronCleanedCandidates_
the collection of punch-through cleaned neutral hadron candidates
Definition: PFMuonAlgo.h:114
bool reconstructMuon(reco::PFCandidate &, const reco::MuonRef &, bool allowLoose=false)
Definition: PFMuonAlgo.cc:537
std::unique_ptr< reco::PFCandidateCollection > transferPunchThroughCleanedMuonCandidates()
Definition: PFMuonAlgo.h:68
double METY_
Definition: PFMuonAlgo.h:153