57 minMuonPt_(iConfig.getParameter<double>(
"minMuonPt")),
58 minChargedHadronPt_(iConfig.getParameter<double>(
"minChargedHadronPt")),
59 minMuonTrackRelPtErr_(iConfig.getParameter<double>(
"minMuonTrackRelPtErr")),
60 maxSigLoose_(iConfig.getParameter<double>(
"maxSigLoose")),
61 maxSigTight_(iConfig.getParameter<double>(
"maxSigTight")),
62 minCaloCompatibility_(iConfig.getParameter<double>(
"minCaloCompatibility")),
63 minTrackNHits_(iConfig.getParameter<
uint>(
"minTrackNHits")),
64 minPixelNHits_(iConfig.getParameter<
uint>(
"minPixelNHits")),
65 minTrackerLayersForMuonLoose_(iConfig.getParameter<
int>(
"minTrackerLayersForMuonLoose")),
66 minTrackerLayersForMuonTight_(iConfig.getParameter<
int>(
"minTrackerLayersForMuonTight")),
67 reMiniAODBugFix_(iConfig.getParameter<
bool>(
"reMiniAODBugFix")) {
69 produces<reco::PFCandidateCollection>();
70 produces<reco::PFCandidateCollection>(
"removed");
71 produces<edm::ValueMap<reco::PFCandidateRef>>();
92 auto pOutputCandidateCollection = std::make_unique<reco::PFCandidateCollection>();
93 auto pBadCandidateCollection = std::make_unique<reco::PFCandidateCollection>();
95 bool foundBadCandidate =
false;
97 std::vector<int> candidateIndexMapper(
n, 0);
99 for (iPF = 0; iPF <
n; iPF++) {
105 if (!pfCandidate.
muonRef()->isGlobalMuon() || !pfCandidate.
muonRef()->isTrackerMuon() ||
107 pBadCandidateCollection->push_back(pfCandidate);
108 candidateIndexMapper[iPF] = -1 * (pBadCandidateCollection->size());
109 foundBadCandidate =
true;
115 pBadCandidateCollection->push_back(pfCandidate);
116 candidateIndexMapper[iPF] = -1 * (pBadCandidateCollection->size());
117 foundBadCandidate =
true;
127 float bestVzError =
vtx.zError();
132 float dzError2 =
track->dzError() *
track->dzError() + bestVzError * bestVzError;
133 float dxyError =
track->dxyError(bestVtx, vtx_cov);
135 float dzSig2 =
dz *
dz / dzError2;
136 float dxySig2 =
dxy *
dxy / dxyError / dxyError;
138 float sig3d =
sqrt(dzSig2 + dxySig2);
141 pBadCandidateCollection->push_back(pfCandidate);
142 candidateIndexMapper[iPF] = -1 * (pBadCandidateCollection->size());
143 foundBadCandidate =
true;
147 if (
track->pt() < pfCandidate.
pt() / 1.5 ||
track->pt() > pfCandidate.
pt() * 1.5) {
148 foundBadCandidate =
true;
149 pBadCandidateCollection->push_back(pfCandidate);
150 candidateIndexMapper[iPF] = -1 * (pBadCandidateCollection->size());
155 foundBadCandidate =
true;
156 pBadCandidateCollection->push_back(pfCandidate);
157 candidateIndexMapper[iPF] = -1 * (pBadCandidateCollection->size());
167 unsigned nHits =
track->numberOfValidHits();
168 unsigned nPixelHits =
track->hitPattern().numberOfValidPixelHits();
171 foundBadCandidate =
true;
172 pBadCandidateCollection->push_back(pfCandidate);
173 candidateIndexMapper[iPF] = -1 * (pBadCandidateCollection->size());
178 float bestVzError =
vtx.zError();
183 float dzError2 =
track->dzError() *
track->dzError() + bestVzError * bestVzError;
184 float dxyError =
track->dxyError(bestVtx, vtx_cov);
186 float dzSig2 =
dz *
dz / dzError2;
187 float dxySig2 =
dxy *
dxy / dxyError / dxyError;
189 float sig3d =
sqrt(dzSig2 + dxySig2);
192 foundBadCandidate =
true;
193 pBadCandidateCollection->push_back(pfCandidate);
194 candidateIndexMapper[iPF] = -1 * (pBadCandidateCollection->size());
199 foundBadCandidate =
true;
200 pBadCandidateCollection->push_back(pfCandidate);
201 candidateIndexMapper[iPF] = -1 * (pBadCandidateCollection->size());
210 foundBadCandidate =
true;
211 pBadCandidateCollection->push_back(pfCandidate);
212 candidateIndexMapper[iPF] = -1 * (pBadCandidateCollection->size());
217 foundBadCandidate =
true;
218 pBadCandidateCollection->push_back(pfCandidate);
219 candidateIndexMapper[iPF] = -1 * (pBadCandidateCollection->size());
228 foundBadCandidate =
true;
229 pBadCandidateCollection->push_back(pfCandidate);
230 candidateIndexMapper[iPF] = -1 * (pBadCandidateCollection->size());
235 foundBadCandidate =
true;
236 pBadCandidateCollection->push_back(pfCandidate);
237 candidateIndexMapper[iPF] = -1 * (pBadCandidateCollection->size());
242 foundBadCandidate =
true;
243 pBadCandidateCollection->push_back(pfCandidate);
244 candidateIndexMapper[iPF] = -1 * (pBadCandidateCollection->size());
251 pOutputCandidateCollection->push_back(pfCandidate);
252 candidateIndexMapper[iPF] = (pOutputCandidateCollection->size());
255 bool pass = !foundBadCandidate;
259 iEvent.put(std::make_unique<bool>(pass));
265 std::vector<reco::PFCandidateRef> refs;
268 for (iPF = 0; iPF <
n; ++iPF) {
269 if (candidateIndexMapper[iPF] > 0) {
271 }
else if (candidateIndexMapper[iPF] < 0) {