16 #include "TLorentzVector.h"
33 theMuonCollectionLabel_ = consumes<edm::View<reco::Muon> >(
parameters.getParameter<
edm::InputTag>(
"MuonCollection"));
34 theTrackCollectionLabel_ = consumes<reco::TrackCollection>(
parameters.getParameter<
edm::InputTag>(
"TrackCollection"));
39 doPVCheck_ =
parameters.getParameter<
bool>(
"doPrimaryVertexCheck");
41 ptBin_ =
parameters.getParameter<
int>(
"ptBin");
42 ptMin_ =
parameters.getParameter<
double>(
"ptMin");
43 ptMax_ =
parameters.getParameter<
double>(
"ptMax");
45 etaBin_ =
parameters.getParameter<
int>(
"etaBin");
46 etaMin_ =
parameters.getParameter<
double>(
"etaMin");
47 etaMax_ =
parameters.getParameter<
double>(
"etaMax");
49 phiBin_ =
parameters.getParameter<
int>(
"phiBin");
50 phiMin_ =
parameters.getParameter<
double>(
"phiMin");
51 phiMax_ =
parameters.getParameter<
double>(
"phiMax");
53 vtxBin_ =
parameters.getParameter<
int>(
"vtxBin");
54 vtxMin_ =
parameters.getParameter<
double>(
"vtxMin");
55 vtxMax_ =
parameters.getParameter<
double>(
"vtxMax");
58 theFolder =
parameters.getParameter<
string>(
"folder");
69 h_allProbes_pt = ibooker.
book1D(
"allProbes_pt",
"All Probes Pt", ptBin_, ptMin_, ptMax_);
70 h_allProbes_inner_pt = ibooker.
book1D(
"allProbes_inner_pt",
"All Probes inner Pt", ptBin_, ptMin_, ptMax_);
71 h_allProbes_inner_eta = ibooker.
book1D(
"allProbes_inner_eta",
"All Probes inner eta", etaBin_, etaMin_, etaMax_);
72 h_allProbes_inner_phi = ibooker.
book1D(
"allProbes_inner_phi",
"All Probes inner phi", phiBin_, phiMin_, phiMax_);
73 h_allProbes_EB_pt = ibooker.
book1D(
"allProbes_EB_pt",
"Barrel: all Probes Pt", ptBin_, ptMin_, ptMax_);
74 h_allProbes_EE_pt = ibooker.
book1D(
"allProbes_EE_pt",
"Endcap: all Probes Pt", ptBin_, ptMin_, ptMax_);
75 h_allProbes_eta = ibooker.
book1D(
"allProbes_eta",
"All Probes Eta", etaBin_, etaMin_, etaMax_);
76 h_allProbes_hp_eta = ibooker.
book1D(
"allProbes_hp_eta",
"High Pt all Probes Eta", etaBin_, etaMin_, etaMax_);
77 h_allProbes_phi = ibooker.
book1D(
"allProbes_phi",
"All Probes Phi", phiBin_, phiMin_, phiMax_);
79 h_allProbes_ID_pt = ibooker.
book1D(
"allProbes_ID_pt",
"All ID Probes Pt", ptBin_, ptMin_, ptMax_);
80 h_allProbes_EB_ID_pt = ibooker.
book1D(
"allProbes_EB_ID_pt",
"Barrel: all ID Probes Pt", ptBin_, ptMin_, ptMax_);
81 h_allProbes_EE_ID_pt = ibooker.
book1D(
"allProbes_EE_ID_pt",
"Endcap: all ID Probes Pt", ptBin_, ptMin_, ptMax_);
82 h_allProbes_ID_nVtx = ibooker.
book1D(
"allProbes_ID_nVtx",
"All Probes (ID) nVtx", vtxBin_, vtxMin_, vtxMax_);
83 h_allProbes_EB_ID_nVtx =
84 ibooker.
book1D(
"allProbes_EB_ID_nVtx",
"Barrel: All Probes (ID) nVtx", vtxBin_, vtxMin_, vtxMax_);
85 h_allProbes_EE_ID_nVtx =
86 ibooker.
book1D(
"allProbes_EE_ID_nVtx",
"Endcap: All Probes (ID) nVtx", vtxBin_, vtxMin_, vtxMax_);
88 h_passProbes_ID_pt = ibooker.
book1D(
"passProbes_ID_pt",
"ID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
89 h_passProbes_ID_inner_pt =
90 ibooker.
book1D(
"passProbes_ID_inner_pt",
"ID Passing Probes inner Pt", ptBin_, ptMin_, ptMax_);
91 h_passProbes_ID_inner_eta =
92 ibooker.
book1D(
"passProbes_ID_inner_eta",
"ID Passing Probes inner eta", etaBin_, etaMin_, etaMax_);
93 h_passProbes_ID_inner_phi =
94 ibooker.
book1D(
"passProbes_ID_inner_phi",
"ID Passing Probes inner phi", phiBin_, phiMin_, phiMax_);
95 h_passProbes_ID_EB_pt = ibooker.
book1D(
"passProbes_ID_EB_pt",
"Barrel: ID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
96 h_passProbes_ID_EE_pt = ibooker.
book1D(
"passProbes_ID_EE_pt",
"Endcap: ID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
97 h_passProbes_ID_eta = ibooker.
book1D(
"passProbes_ID_eta",
"ID Passing Probes #eta", etaBin_, etaMin_, etaMax_);
98 h_passProbes_ID_hp_eta =
99 ibooker.
book1D(
"passProbes_ID_hp_eta",
"High Pt ID Passing Probes #eta", etaBin_, etaMin_, etaMax_);
100 h_passProbes_ID_phi = ibooker.
book1D(
"passProbes_ID_phi",
"ID Passing Probes #phi", phiBin_, phiMin_, phiMax_);
102 h_passProbes_detIsoID_pt =
103 ibooker.
book1D(
"passProbes_detIsoID_pt",
"detIsoID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
104 h_passProbes_EB_detIsoID_pt =
105 ibooker.
book1D(
"passProbes_EB_detIsoID_pt",
"Barrel: detIsoID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
106 h_passProbes_EE_detIsoID_pt =
107 ibooker.
book1D(
"passProbes_EE_detIsoID_pt",
"Endcap: detIsoID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
109 h_passProbes_pfIsoID_pt =
110 ibooker.
book1D(
"passProbes_pfIsoID_pt",
"pfIsoID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
111 h_passProbes_EB_pfIsoID_pt =
112 ibooker.
book1D(
"passProbes_EB_pfIsoID_pt",
"Barrel: pfIsoID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
113 h_passProbes_EE_pfIsoID_pt =
114 ibooker.
book1D(
"passProbes_EE_pfIsoID_pt",
"Endcap: pfIsoID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
116 h_passProbes_detIsoID_nVtx =
117 ibooker.
book1D(
"passProbes_detIsoID_nVtx",
"detIsoID Passing Probes nVtx (R03)", vtxBin_, vtxMin_, vtxMax_);
118 h_passProbes_pfIsoID_nVtx =
119 ibooker.
book1D(
"passProbes_pfIsoID_nVtx",
"pfIsoID Passing Probes nVtx (R04)", vtxBin_, vtxMin_, vtxMax_);
120 h_passProbes_EB_detIsoID_nVtx = ibooker.
book1D(
121 "passProbes_EB_detIsoID_nVtx",
"Barrel: detIsoID Passing Probes nVtx (R03)", vtxBin_, vtxMin_, vtxMax_);
122 h_passProbes_EE_detIsoID_nVtx = ibooker.
book1D(
123 "passProbes_EE_detIsoID_nVtx",
"Endcap: detIsoID Passing Probes nVtx (R03)", vtxBin_, vtxMin_, vtxMax_);
124 h_passProbes_EB_pfIsoID_nVtx = ibooker.
book1D(
125 "passProbes_EB_pfIsoID_nVtx",
"Barrel: pfIsoID Passing Probes nVtx (R04)", vtxBin_, vtxMin_, vtxMax_);
126 h_passProbes_EE_pfIsoID_nVtx = ibooker.
book1D(
127 "passProbes_EE_pfIsoID_nVtx",
"Endcap: pfIsoID Passing Probes nVtx (R04)", vtxBin_, vtxMin_, vtxMax_);
131 h_passProbes_pfIsodBID_pt = ibooker.
book1D(
132 "passProbes_pfIsodBID_pt",
"pfIsoID Passing Probes Pt (deltaB PU correction)", ptBin_, ptMin_, ptMax_);
133 h_passProbes_EB_pfIsodBID_pt = ibooker.
book1D(
134 "passProbes_EB_pfIsodBID_pt",
"Barrel: pfIsoID Passing Probes Pt (deltaB PU correction)", ptBin_, ptMin_, ptMax_);
135 h_passProbes_EE_pfIsodBID_pt = ibooker.
book1D(
136 "passProbes_EE_pfIsodBID_pt",
"Endcap: pfIsoID Passing Probes Pt (deltaB PU correction)", ptBin_, ptMin_, ptMax_);
137 h_passProbes_pfIsodBID_nVtx = ibooker.
book1D(
"passProbes_pfIsodBID_nVtx",
138 "pfIsoID Passing Probes nVtx (R04) (deltaB PU correction)",
142 h_passProbes_EB_pfIsodBID_nVtx = ibooker.
book1D(
"passProbes_EB_pfIsodBID_nVtx",
143 "Barrel: pfIsoID Passing Probes nVtx (R04) (deltaB PU correction)",
147 h_passProbes_EE_pfIsodBID_nVtx = ibooker.
book1D(
"passProbes_EE_pfIsodBID_nVtx",
148 "Endcap: pfIsoID Passing Probes nVtx (R04) (deltaB PU correction)",
154 cout <<
"[EfficiencyAnalyzer] Parameters initialization DONE" << endl;
159 LogTrace(
metname) <<
"[EfficiencyAnalyzer] Analyze the mu in different eta regions";
177 bool bPrimaryVertex =
true;
179 bPrimaryVertex =
false;
182 LogTrace(
metname) <<
"[EfficiencyAnalyzer] Could not find vertex collection" << std::endl;
183 bPrimaryVertex =
false;
192 double vertex_chi2 =
v->normalizedChi2();
193 double vertex_ndof =
v->ndof();
194 bool fakeVtx =
v->isFake();
195 double vertex_Z =
v->z();
197 if (!fakeVtx && vertex_number >= 1 && vertex_ndof > 4 && vertex_chi2 < 999 && fabs(vertex_Z) < 24.) {
198 bPrimaryVertex =
true;
209 unsigned int theIndexOfThePrimaryVertex = 999.;
211 for (
unsigned int ind = 0; ind <
vertex->size(); ++ind) {
212 if ((*
vertex)[ind].isValid() && !((*vertex)[ind].isFake())) {
213 theIndexOfThePrimaryVertex = ind;
219 if (theIndexOfThePrimaryVertex < 100) {
220 posVtx = ((*vertex)[theIndexOfThePrimaryVertex]).
position();
221 errVtx = ((*vertex)[theIndexOfThePrimaryVertex]).
error();
223 LogInfo(
"RecoMuonValidator") <<
"reco::PrimaryVertex not found, use BeamSpot position instead\n";
226 iEvent.getByToken(theBeamSpotLabel_, recoBeamSpotHandle);
229 posVtx =
bs.position();
230 errVtx(0, 0) =
bs.BeamWidthX();
231 errVtx(1, 1) =
bs.BeamWidthY();
232 errVtx(2, 2) =
bs.sigmaZ();
238 if (!
muons.isValid())
242 TLorentzVector Mu1, Mu2;
248 LogTrace(
metname) <<
"[EfficiencyAnalyzer] loop over first muons" << endl;
252 float combIso = (Iso_muon.
emEt + Iso_muon.
hadEt + Iso_muon.
sumPt);
255 if (!muon1->isGlobalMuon())
260 float muPt1 = recoCombinedGlbTrack1->pt();
261 Mu1.SetPxPyPzE(recoCombinedGlbTrack1->px(),
262 recoCombinedGlbTrack1->py(),
263 recoCombinedGlbTrack1->pz(),
264 recoCombinedGlbTrack1->p());
278 if (combIso / muPt1 > 0.1)
282 LogTrace(
metname) <<
"[EfficiencyAnalyzer] loop over second muon" << endl;
286 if (muon2->eta() < 1.479)
288 if (muon2->eta() >= 1.479)
292 Mu2.SetPxPyPzE(muon2->px(), muon2->py(), muon2->pz(), muon2->p());
294 float Minv = (Mu1 + Mu2).M();
295 if (!muon2->isTrackerMuon())
299 if ((muon1->charge()) * (muon2->charge()) > 0)
301 if (Minv < 70 || Minv > 110)
304 h_allProbes_pt->Fill(muon2->pt());
305 h_allProbes_eta->Fill(muon2->eta());
306 h_allProbes_phi->Fill(muon2->phi());
307 if (muon2->innerTrack()->extra().isAvailable()) {
308 h_allProbes_inner_pt->Fill(muon2->innerTrack()->innerMomentum().Rho());
309 h_allProbes_inner_eta->Fill(muon2->innerTrack()->innerPosition().Eta());
310 h_allProbes_inner_phi->Fill(muon2->innerTrack()->innerPosition().Phi());
313 h_allProbes_EB_pt->Fill(muon2->pt());
315 h_allProbes_EE_pt->Fill(muon2->pt());
316 if (muon2->pt() > 20)
317 h_allProbes_hp_eta->Fill(muon2->eta());
327 h_passProbes_ID_pt->Fill(muon2->pt());
328 h_passProbes_ID_eta->Fill(muon2->eta());
329 h_passProbes_ID_phi->Fill(muon2->phi());
330 if (muon2->innerTrack()->extra().isAvailable()) {
331 h_passProbes_ID_inner_pt->Fill(muon2->innerTrack()->innerMomentum().Rho());
332 h_passProbes_ID_inner_eta->Fill(muon2->innerTrack()->innerPosition().Eta());
333 h_passProbes_ID_inner_phi->Fill(muon2->innerTrack()->innerPosition().Phi());
337 h_passProbes_ID_EB_pt->Fill(muon2->pt());
339 h_passProbes_ID_EE_pt->Fill(muon2->pt());
340 if (muon2->pt() > 20)
341 h_passProbes_ID_hp_eta->Fill(muon2->eta());
343 h_allProbes_ID_pt->Fill(muon2->pt());
345 h_allProbes_EB_ID_pt->Fill(muon2->pt());
347 h_allProbes_EE_ID_pt->Fill(muon2->pt());
351 h_allProbes_ID_nVtx->Fill(_numPV);
352 if (bPrimaryVertex && isMB)
353 h_allProbes_EB_ID_nVtx->Fill(_numPV);
354 if (bPrimaryVertex && isME)
355 h_allProbes_EE_ID_nVtx->Fill(_numPV);
358 float tkIso = muon2->isolationR03().sumPt;
359 float emIso = muon2->isolationR03().emEt;
360 float hadIso = muon2->isolationR03().hadEt + muon2->isolationR03().hoEt;
361 float relDetIso = (tkIso + emIso + hadIso) / (muon2->pt());
363 if (relDetIso < 0.05) {
364 h_passProbes_detIsoID_pt->Fill(muon2->pt());
366 h_passProbes_EB_detIsoID_pt->Fill(muon2->pt());
368 h_passProbes_EE_detIsoID_pt->Fill(muon2->pt());
371 h_passProbes_detIsoID_nVtx->Fill(_numPV);
372 if (bPrimaryVertex && isMB)
373 h_passProbes_EB_detIsoID_nVtx->Fill(_numPV);
374 if (bPrimaryVertex && isME)
375 h_passProbes_EE_detIsoID_nVtx->Fill(_numPV);
379 float chargedIso = muon2->pfIsolationR04().sumChargedHadronPt;
380 float neutralIso = muon2->pfIsolationR04().sumNeutralHadronEt;
381 float photonIso = muon2->pfIsolationR04().sumPhotonEt;
384 float pu = muon2->pfIsolationR04().sumPUPt;
386 float relPFIsoPUCorrected = (
chargedIso + neutralphotonPUCorrected) / (muon2->pt());
388 if (relPFIso < 0.12) {
389 h_passProbes_pfIsoID_pt->Fill(muon2->pt());
391 h_passProbes_EB_pfIsoID_pt->Fill(muon2->pt());
393 h_passProbes_EE_pfIsoID_pt->Fill(muon2->pt());
396 h_passProbes_pfIsoID_nVtx->Fill(_numPV);
397 if (bPrimaryVertex && isMB)
398 h_passProbes_EB_pfIsoID_nVtx->Fill(_numPV);
399 if (bPrimaryVertex && isME)
400 h_passProbes_EE_pfIsoID_nVtx->Fill(_numPV);
404 if (relPFIsoPUCorrected < 0.12) {
405 h_passProbes_pfIsodBID_pt->Fill(muon2->pt());
407 h_passProbes_EB_pfIsodBID_pt->Fill(muon2->pt());
409 h_passProbes_EE_pfIsodBID_pt->Fill(muon2->pt());
412 h_passProbes_pfIsodBID_nVtx->Fill(_numPV);
413 if (bPrimaryVertex && isMB)
414 h_passProbes_EB_pfIsodBID_nVtx->Fill(_numPV);
415 if (bPrimaryVertex && isME)
416 h_passProbes_EE_pfIsodBID_nVtx->Fill(_numPV);