16 #include "TLorentzVector.h" 35 theMuonCollectionLabel_ = consumes<edm::View<reco::Muon> >(
parameters.getParameter<
edm::InputTag>(
"MuonCollection"));
36 theTrackCollectionLabel_ = consumes<reco::TrackCollection>(
parameters.getParameter<
edm::InputTag>(
"TrackCollection"));
41 doPVCheck_ =
parameters.getParameter<
bool>(
"doPrimaryVertexCheck");
43 ptBin_ =
parameters.getParameter<
int>(
"ptBin");
44 ptMin_ =
parameters.getParameter<
double>(
"ptMin");
45 ptMax_ =
parameters.getParameter<
double>(
"ptMax");
47 etaBin_ =
parameters.getParameter<
int>(
"etaBin");
48 etaMin_ =
parameters.getParameter<
double>(
"etaMin");
49 etaMax_ =
parameters.getParameter<
double>(
"etaMax");
51 phiBin_ =
parameters.getParameter<
int>(
"phiBin");
52 phiMin_ =
parameters.getParameter<
double>(
"phiMin");
53 phiMax_ =
parameters.getParameter<
double>(
"phiMax");
55 vtxBin_ =
parameters.getParameter<
int>(
"vtxBin");
56 vtxMin_ =
parameters.getParameter<
double>(
"vtxMin");
57 vtxMax_ =
parameters.getParameter<
double>(
"vtxMax");
60 theFolder =
parameters.getParameter<
string>(
"folder");
71 h_allProbes_pt = ibooker.
book1D(
"allProbes_pt",
"All Probes Pt", ptBin_, ptMin_, ptMax_);
72 h_allProbes_inner_pt = ibooker.
book1D(
"allProbes_inner_pt",
"All Probes inner Pt", ptBin_, ptMin_, ptMax_);
73 h_allProbes_inner_eta = ibooker.
book1D(
"allProbes_inner_eta",
"All Probes inner eta", etaBin_, etaMin_, etaMax_);
74 h_allProbes_inner_phi = ibooker.
book1D(
"allProbes_inner_phi",
"All Probes inner phi", phiBin_, phiMin_, phiMax_);
75 h_allProbes_EB_pt = ibooker.
book1D(
"allProbes_EB_pt",
"Barrel: all Probes Pt", ptBin_, ptMin_, ptMax_);
76 h_allProbes_EE_pt = ibooker.
book1D(
"allProbes_EE_pt",
"Endcap: all Probes Pt", ptBin_, ptMin_, ptMax_);
77 h_allProbes_eta = ibooker.
book1D(
"allProbes_eta",
"All Probes Eta", etaBin_, etaMin_, etaMax_);
78 h_allProbes_hp_eta = ibooker.
book1D(
"allProbes_hp_eta",
"High Pt all Probes Eta", etaBin_, etaMin_, etaMax_);
79 h_allProbes_phi = ibooker.
book1D(
"allProbes_phi",
"All Probes Phi", phiBin_, phiMin_, phiMax_);
81 h_allProbes_ID_pt = ibooker.
book1D(
"allProbes_ID_pt",
"All ID Probes Pt", ptBin_, ptMin_, ptMax_);
82 h_allProbes_EB_ID_pt = ibooker.
book1D(
"allProbes_EB_ID_pt",
"Barrel: all ID Probes Pt", ptBin_, ptMin_, ptMax_);
83 h_allProbes_EE_ID_pt = ibooker.
book1D(
"allProbes_EE_ID_pt",
"Endcap: all ID Probes Pt", ptBin_, ptMin_, ptMax_);
84 h_allProbes_ID_nVtx = ibooker.
book1D(
"allProbes_ID_nVtx",
"All Probes (ID) nVtx", vtxBin_, vtxMin_, vtxMax_);
85 h_allProbes_EB_ID_nVtx =
86 ibooker.
book1D(
"allProbes_EB_ID_nVtx",
"Barrel: All Probes (ID) nVtx", vtxBin_, vtxMin_, vtxMax_);
87 h_allProbes_EE_ID_nVtx =
88 ibooker.
book1D(
"allProbes_EE_ID_nVtx",
"Endcap: All Probes (ID) nVtx", vtxBin_, vtxMin_, vtxMax_);
90 h_passProbes_ID_pt = ibooker.
book1D(
"passProbes_ID_pt",
"ID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
91 h_passProbes_ID_inner_pt =
92 ibooker.
book1D(
"passProbes_ID_inner_pt",
"ID Passing Probes inner Pt", ptBin_, ptMin_, ptMax_);
93 h_passProbes_ID_inner_eta =
94 ibooker.
book1D(
"passProbes_ID_inner_eta",
"ID Passing Probes inner eta", etaBin_, etaMin_, etaMax_);
95 h_passProbes_ID_inner_phi =
96 ibooker.
book1D(
"passProbes_ID_inner_phi",
"ID Passing Probes inner phi", phiBin_, phiMin_, phiMax_);
97 h_passProbes_ID_EB_pt = ibooker.
book1D(
"passProbes_ID_EB_pt",
"Barrel: ID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
98 h_passProbes_ID_EE_pt = ibooker.
book1D(
"passProbes_ID_EE_pt",
"Endcap: ID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
99 h_passProbes_ID_eta = ibooker.
book1D(
"passProbes_ID_eta",
"ID Passing Probes #eta", etaBin_, etaMin_, etaMax_);
100 h_passProbes_ID_hp_eta =
101 ibooker.
book1D(
"passProbes_ID_hp_eta",
"High Pt ID Passing Probes #eta", etaBin_, etaMin_, etaMax_);
102 h_passProbes_ID_phi = ibooker.
book1D(
"passProbes_ID_phi",
"ID Passing Probes #phi", phiBin_, phiMin_, phiMax_);
104 h_passProbes_detIsoID_pt =
105 ibooker.
book1D(
"passProbes_detIsoID_pt",
"detIsoID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
106 h_passProbes_EB_detIsoID_pt =
107 ibooker.
book1D(
"passProbes_EB_detIsoID_pt",
"Barrel: detIsoID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
108 h_passProbes_EE_detIsoID_pt =
109 ibooker.
book1D(
"passProbes_EE_detIsoID_pt",
"Endcap: detIsoID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
111 h_passProbes_pfIsoID_pt =
112 ibooker.
book1D(
"passProbes_pfIsoID_pt",
"pfIsoID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
113 h_passProbes_EB_pfIsoID_pt =
114 ibooker.
book1D(
"passProbes_EB_pfIsoID_pt",
"Barrel: pfIsoID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
115 h_passProbes_EE_pfIsoID_pt =
116 ibooker.
book1D(
"passProbes_EE_pfIsoID_pt",
"Endcap: pfIsoID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
118 h_passProbes_detIsoID_nVtx =
119 ibooker.
book1D(
"passProbes_detIsoID_nVtx",
"detIsoID Passing Probes nVtx (R03)", vtxBin_, vtxMin_, vtxMax_);
120 h_passProbes_pfIsoID_nVtx =
121 ibooker.
book1D(
"passProbes_pfIsoID_nVtx",
"pfIsoID Passing Probes nVtx (R04)", vtxBin_, vtxMin_, vtxMax_);
122 h_passProbes_EB_detIsoID_nVtx = ibooker.
book1D(
123 "passProbes_EB_detIsoID_nVtx",
"Barrel: detIsoID Passing Probes nVtx (R03)", vtxBin_, vtxMin_, vtxMax_);
124 h_passProbes_EE_detIsoID_nVtx = ibooker.
book1D(
125 "passProbes_EE_detIsoID_nVtx",
"Endcap: detIsoID Passing Probes nVtx (R03)", vtxBin_, vtxMin_, vtxMax_);
126 h_passProbes_EB_pfIsoID_nVtx = ibooker.
book1D(
127 "passProbes_EB_pfIsoID_nVtx",
"Barrel: pfIsoID Passing Probes nVtx (R04)", vtxBin_, vtxMin_, vtxMax_);
128 h_passProbes_EE_pfIsoID_nVtx = ibooker.
book1D(
129 "passProbes_EE_pfIsoID_nVtx",
"Endcap: pfIsoID Passing Probes nVtx (R04)", vtxBin_, vtxMin_, vtxMax_);
133 h_passProbes_pfIsodBID_pt = ibooker.
book1D(
134 "passProbes_pfIsodBID_pt",
"pfIsoID Passing Probes Pt (deltaB PU correction)", ptBin_, ptMin_, ptMax_);
135 h_passProbes_EB_pfIsodBID_pt = ibooker.
book1D(
136 "passProbes_EB_pfIsodBID_pt",
"Barrel: pfIsoID Passing Probes Pt (deltaB PU correction)", ptBin_, ptMin_, ptMax_);
137 h_passProbes_EE_pfIsodBID_pt = ibooker.
book1D(
138 "passProbes_EE_pfIsodBID_pt",
"Endcap: pfIsoID Passing Probes Pt (deltaB PU correction)", ptBin_, ptMin_, ptMax_);
139 h_passProbes_pfIsodBID_nVtx = ibooker.
book1D(
"passProbes_pfIsodBID_nVtx",
140 "pfIsoID Passing Probes nVtx (R04) (deltaB PU correction)",
144 h_passProbes_EB_pfIsodBID_nVtx = ibooker.
book1D(
"passProbes_EB_pfIsodBID_nVtx",
145 "Barrel: pfIsoID Passing Probes nVtx (R04) (deltaB PU correction)",
149 h_passProbes_EE_pfIsodBID_nVtx = ibooker.
book1D(
"passProbes_EE_pfIsodBID_nVtx",
150 "Endcap: pfIsoID Passing Probes nVtx (R04) (deltaB PU correction)",
156 cout <<
"[EfficiencyAnalyzer] Parameters initialization DONE" << endl;
161 LogTrace(
metname) <<
"[EfficiencyAnalyzer] Analyze the mu in different eta regions";
162 theService->update(iSetup);
167 iEvent.
getByToken(theMuonCollectionLabel_, muons);
171 iEvent.
getByToken(theTrackCollectionLabel_, tracks);
180 bool bPrimaryVertex =
true;
182 bPrimaryVertex =
false;
185 LogTrace(
metname) <<
"[EfficiencyAnalyzer] Could not find vertex collection" << std::endl;
186 bPrimaryVertex =
false;
191 int vertex_number = vertexCollection.size();
193 reco::VertexCollection::const_iterator
v = vertexCollection.begin();
194 for (; v != vertexCollection.end(); ++
v) {
195 double vertex_chi2 = v->normalizedChi2();
196 double vertex_ndof = v->ndof();
197 bool fakeVtx = v->isFake();
198 double vertex_Z = v->z();
200 if (!fakeVtx && vertex_number >= 1 && vertex_ndof > 4 && vertex_chi2 < 999 && fabs(vertex_Z) < 24.) {
201 bPrimaryVertex =
true;
212 unsigned int theIndexOfThePrimaryVertex = 999.;
214 for (
unsigned int ind = 0; ind < vertex->size(); ++ind) {
215 if ((*vertex)[ind].isValid() && !((*vertex)[ind].isFake())) {
216 theIndexOfThePrimaryVertex = ind;
222 if (theIndexOfThePrimaryVertex < 100) {
223 posVtx = ((*vertex)[theIndexOfThePrimaryVertex]).
position();
224 errVtx = ((*vertex)[theIndexOfThePrimaryVertex]).
error();
226 LogInfo(
"RecoMuonValidator") <<
"reco::PrimaryVertex not found, use BeamSpot position instead\n";
229 iEvent.
getByToken(theBeamSpotLabel_, recoBeamSpotHandle);
235 errVtx(2, 2) = bs.
sigmaZ();
245 TLorentzVector Mu1, Mu2;
251 LogTrace(
metname) <<
"[EfficiencyAnalyzer] loop over first muons" << endl;
255 float combIso = (Iso_muon.
emEt + Iso_muon.
hadEt + Iso_muon.
sumPt);
258 if (!muon1->isGlobalMuon())
263 float muPt1 = recoCombinedGlbTrack1->pt();
264 Mu1.SetPxPyPzE(recoCombinedGlbTrack1->px(),
265 recoCombinedGlbTrack1->py(),
266 recoCombinedGlbTrack1->pz(),
267 recoCombinedGlbTrack1->p());
281 if (combIso / muPt1 > 0.1)
285 LogTrace(
metname) <<
"[EfficiencyAnalyzer] loop over second muon" << endl;
289 if (muon2->eta() < 1.479)
291 if (muon2->eta() >= 1.479)
295 Mu2.SetPxPyPzE(muon2->px(), muon2->py(), muon2->pz(), muon2->p());
297 float Minv = (Mu1 + Mu2).M();
298 if (!muon2->isTrackerMuon())
302 if ((muon1->charge()) * (muon2->charge()) > 0)
304 if (Minv < 70 || Minv > 110)
307 h_allProbes_pt->Fill(muon2->pt());
308 h_allProbes_eta->Fill(muon2->eta());
309 h_allProbes_phi->Fill(muon2->phi());
310 if (muon2->innerTrack()->extra().isAvailable()) {
311 h_allProbes_inner_pt->Fill(muon2->innerTrack()->innerMomentum().Rho());
312 h_allProbes_inner_eta->Fill(muon2->innerTrack()->innerPosition().Eta());
313 h_allProbes_inner_phi->Fill(muon2->innerTrack()->innerPosition().Phi());
316 h_allProbes_EB_pt->Fill(muon2->pt());
318 h_allProbes_EE_pt->Fill(muon2->pt());
319 if (muon2->pt() > 20)
320 h_allProbes_hp_eta->Fill(muon2->eta());
330 h_passProbes_ID_pt->Fill(muon2->pt());
331 h_passProbes_ID_eta->Fill(muon2->eta());
332 h_passProbes_ID_phi->Fill(muon2->phi());
333 if (muon2->innerTrack()->extra().isAvailable()) {
334 h_passProbes_ID_inner_pt->Fill(muon2->innerTrack()->innerMomentum().Rho());
335 h_passProbes_ID_inner_eta->Fill(muon2->innerTrack()->innerPosition().Eta());
336 h_passProbes_ID_inner_phi->Fill(muon2->innerTrack()->innerPosition().Phi());
340 h_passProbes_ID_EB_pt->Fill(muon2->pt());
342 h_passProbes_ID_EE_pt->Fill(muon2->pt());
343 if (muon2->pt() > 20)
344 h_passProbes_ID_hp_eta->Fill(muon2->eta());
346 h_allProbes_ID_pt->Fill(muon2->pt());
348 h_allProbes_EB_ID_pt->Fill(muon2->pt());
350 h_allProbes_EE_ID_pt->Fill(muon2->pt());
354 h_allProbes_ID_nVtx->Fill(_numPV);
355 if (bPrimaryVertex && isMB)
356 h_allProbes_EB_ID_nVtx->Fill(_numPV);
357 if (bPrimaryVertex && isME)
358 h_allProbes_EE_ID_nVtx->Fill(_numPV);
361 float tkIso = muon2->isolationR03().sumPt;
362 float emIso = muon2->isolationR03().emEt;
363 float hadIso = muon2->isolationR03().hadEt + muon2->isolationR03().hoEt;
364 float relDetIso = (tkIso + emIso + hadIso) / (muon2->pt());
366 if (relDetIso < 0.05) {
367 h_passProbes_detIsoID_pt->Fill(muon2->pt());
369 h_passProbes_EB_detIsoID_pt->Fill(muon2->pt());
371 h_passProbes_EE_detIsoID_pt->Fill(muon2->pt());
374 h_passProbes_detIsoID_nVtx->Fill(_numPV);
375 if (bPrimaryVertex && isMB)
376 h_passProbes_EB_detIsoID_nVtx->Fill(_numPV);
377 if (bPrimaryVertex && isME)
378 h_passProbes_EE_detIsoID_nVtx->Fill(_numPV);
382 float chargedIso = muon2->pfIsolationR04().sumChargedHadronPt;
383 float neutralIso = muon2->pfIsolationR04().sumNeutralHadronEt;
384 float photonIso = muon2->pfIsolationR04().sumPhotonEt;
385 float relPFIso = (chargedIso + neutralIso +
photonIso) / (muon2->pt());
387 float pu = muon2->pfIsolationR04().sumPUPt;
388 float neutralphotonPUCorrected =
std::max(0.0, (neutralIso + photonIso - 0.5 * pu));
389 float relPFIsoPUCorrected = (chargedIso + neutralphotonPUCorrected) / (muon2->pt());
391 if (relPFIso < 0.12) {
392 h_passProbes_pfIsoID_pt->Fill(muon2->pt());
394 h_passProbes_EB_pfIsoID_pt->Fill(muon2->pt());
396 h_passProbes_EE_pfIsoID_pt->Fill(muon2->pt());
399 h_passProbes_pfIsoID_nVtx->Fill(_numPV);
400 if (bPrimaryVertex && isMB)
401 h_passProbes_EB_pfIsoID_nVtx->Fill(_numPV);
402 if (bPrimaryVertex && isME)
403 h_passProbes_EE_pfIsoID_nVtx->Fill(_numPV);
407 if (relPFIsoPUCorrected < 0.12) {
408 h_passProbes_pfIsodBID_pt->Fill(muon2->pt());
410 h_passProbes_EB_pfIsodBID_pt->Fill(muon2->pt());
412 h_passProbes_EE_pfIsodBID_pt->Fill(muon2->pt());
415 h_passProbes_pfIsodBID_nVtx->Fill(_numPV);
416 if (bPrimaryVertex && isMB)
417 h_passProbes_EB_pfIsodBID_nVtx->Fill(_numPV);
418 if (bPrimaryVertex && isME)
419 h_passProbes_EE_pfIsodBID_nVtx->Fill(_numPV);
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
float sumPt
sum-pt of tracks
bool isMediumMuon(const reco::Muon &, bool run2016_hip_mitigation=false)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const std::string metname
void setCurrentFolder(std::string const &fullpath)
math::Error< dimension >::type Error
covariance error matrix (3x3)
std::vector< Vertex > VertexCollection
collection of Vertex objects
bool isLooseMuon(const reco::Muon &)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
math::XYZPoint Point
point in the space
double BeamWidthX() const
beam width X
~EfficiencyAnalyzer() override
T const * product() const
double sigmaZ() const
sigma z
double BeamWidthY() const
beam width Y
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
static int position[264][3]
const Point & position() const
position
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
EfficiencyAnalyzer(const edm::ParameterSet &pset)
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override