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");
74 h_allProbes_pt = ibooker.
book1D(
"allProbes_pt",
"All Probes Pt", ptBin_, ptMin_, ptMax_);
75 h_allProbes_inner_pt = ibooker.
book1D(
"allProbes_inner_pt",
"All Probes inner Pt", ptBin_, ptMin_, ptMax_);
76 h_allProbes_inner_eta = ibooker.
book1D(
"allProbes_inner_eta",
"All Probes inner eta", etaBin_, etaMin_, etaMax_);
77 h_allProbes_inner_phi = ibooker.
book1D(
"allProbes_inner_phi",
"All Probes inner phi", phiBin_, phiMin_, phiMax_);
78 h_allProbes_EB_pt = ibooker.
book1D(
"allProbes_EB_pt",
"Barrel: all Probes Pt", ptBin_, ptMin_, ptMax_);
79 h_allProbes_EE_pt = ibooker.
book1D(
"allProbes_EE_pt",
"Endcap: all Probes Pt", ptBin_, ptMin_, ptMax_);
80 h_allProbes_eta = ibooker.
book1D(
"allProbes_eta",
"All Probes Eta", etaBin_, etaMin_, etaMax_);
81 h_allProbes_hp_eta = ibooker.
book1D(
"allProbes_hp_eta",
"High Pt all Probes Eta", etaBin_, etaMin_, etaMax_);
82 h_allProbes_phi = ibooker.
book1D(
"allProbes_phi",
"All Probes Phi", phiBin_, phiMin_, phiMax_);
84 h_allProbes_ID_pt = ibooker.
book1D(
"allProbes_ID_pt",
"All ID Probes Pt", ptBin_, ptMin_, ptMax_);
85 h_allProbes_EB_ID_pt = ibooker.
book1D(
"allProbes_EB_ID_pt",
"Barrel: all ID Probes Pt", ptBin_, ptMin_, ptMax_);
86 h_allProbes_EE_ID_pt = ibooker.
book1D(
"allProbes_EE_ID_pt",
"Endcap: all ID Probes Pt", ptBin_, ptMin_, ptMax_);
87 h_allProbes_ID_nVtx = ibooker.
book1D(
"allProbes_ID_nVtx",
"All Probes (ID) nVtx", vtxBin_, vtxMin_, vtxMax_);
88 h_allProbes_EB_ID_nVtx = ibooker.
book1D(
"allProbes_EB_ID_nVtx",
"Barrel: All Probes (ID) nVtx", vtxBin_, vtxMin_, vtxMax_);
89 h_allProbes_EE_ID_nVtx = ibooker.
book1D(
"allProbes_EE_ID_nVtx",
"Endcap: All Probes (ID) nVtx", vtxBin_, vtxMin_, vtxMax_);
91 h_passProbes_ID_pt = ibooker.
book1D(
"passProbes_ID_pt",
"ID Passing Probes Pt", ptBin_ , ptMin_ , ptMax_ );
92 h_passProbes_ID_inner_pt = ibooker.
book1D(
"passProbes_ID_inner_pt",
"ID Passing Probes inner Pt", ptBin_, ptMin_, ptMax_);
93 h_passProbes_ID_inner_eta = ibooker.
book1D(
"passProbes_ID_inner_eta",
"ID Passing Probes inner eta", etaBin_, etaMin_, etaMax_);
94 h_passProbes_ID_inner_phi = 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 = ibooker.
book1D(
"passProbes_ID_hp_eta",
"High Pt ID Passing Probes #eta", etaBin_, etaMin_, etaMax_);
99 h_passProbes_ID_phi = ibooker.
book1D(
"passProbes_ID_phi",
"ID Passing Probes #phi", phiBin_, phiMin_, phiMax_);
101 h_passProbes_detIsoID_pt = ibooker.
book1D(
"passProbes_detIsoID_pt",
"detIsoID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
102 h_passProbes_EB_detIsoID_pt = ibooker.
book1D(
"passProbes_EB_detIsoID_pt",
"Barrel: detIsoID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
103 h_passProbes_EE_detIsoID_pt = ibooker.
book1D(
"passProbes_EE_detIsoID_pt",
"Endcap: detIsoID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
105 h_passProbes_pfIsoID_pt = ibooker.
book1D(
"passProbes_pfIsoID_pt",
"pfIsoID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
106 h_passProbes_EB_pfIsoID_pt = ibooker.
book1D(
"passProbes_EB_pfIsoID_pt",
"Barrel: pfIsoID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
107 h_passProbes_EE_pfIsoID_pt = ibooker.
book1D(
"passProbes_EE_pfIsoID_pt",
"Endcap: pfIsoID Passing Probes Pt", ptBin_, ptMin_, ptMax_);
109 h_passProbes_detIsoID_nVtx = ibooker.
book1D(
"passProbes_detIsoID_nVtx",
"detIsoID Passing Probes nVtx (R03)", vtxBin_, vtxMin_, vtxMax_);
110 h_passProbes_pfIsoID_nVtx = ibooker.
book1D(
"passProbes_pfIsoID_nVtx",
"pfIsoID Passing Probes nVtx (R04)", vtxBin_, vtxMin_, vtxMax_);
111 h_passProbes_EB_detIsoID_nVtx = ibooker.
book1D(
"passProbes_EB_detIsoID_nVtx",
"Barrel: detIsoID Passing Probes nVtx (R03)", vtxBin_, vtxMin_, vtxMax_);
112 h_passProbes_EE_detIsoID_nVtx = ibooker.
book1D(
"passProbes_EE_detIsoID_nVtx",
"Endcap: detIsoID Passing Probes nVtx (R03)", vtxBin_, vtxMin_, vtxMax_);
113 h_passProbes_EB_pfIsoID_nVtx = ibooker.
book1D(
"passProbes_EB_pfIsoID_nVtx",
"Barrel: pfIsoID Passing Probes nVtx (R04)", vtxBin_, vtxMin_, vtxMax_);
114 h_passProbes_EE_pfIsoID_nVtx = ibooker.
book1D(
"passProbes_EE_pfIsoID_nVtx",
"Endcap: pfIsoID Passing Probes nVtx (R04)", vtxBin_, vtxMin_, vtxMax_);
119 h_passProbes_pfIsodBID_pt = ibooker.
book1D(
"passProbes_pfIsodBID_pt",
"pfIsoID Passing Probes Pt (deltaB PU correction)", ptBin_, ptMin_, ptMax_);
120 h_passProbes_EB_pfIsodBID_pt = ibooker.
book1D(
"passProbes_EB_pfIsodBID_pt",
"Barrel: pfIsoID Passing Probes Pt (deltaB PU correction)", ptBin_, ptMin_, ptMax_);
121 h_passProbes_EE_pfIsodBID_pt = ibooker.
book1D(
"passProbes_EE_pfIsodBID_pt",
"Endcap: pfIsoID Passing Probes Pt (deltaB PU correction)", ptBin_, ptMin_, ptMax_);
122 h_passProbes_pfIsodBID_nVtx = ibooker.
book1D(
"passProbes_pfIsodBID_nVtx",
"pfIsoID Passing Probes nVtx (R04) (deltaB PU correction)", vtxBin_, vtxMin_, vtxMax_);
123 h_passProbes_EB_pfIsodBID_nVtx = ibooker.
book1D(
"passProbes_EB_pfIsodBID_nVtx",
"Barrel: pfIsoID Passing Probes nVtx (R04) (deltaB PU correction)", vtxBin_, vtxMin_, vtxMax_);
124 h_passProbes_EE_pfIsodBID_nVtx = ibooker.
book1D(
"passProbes_EE_pfIsodBID_nVtx",
"Endcap: pfIsoID Passing Probes nVtx (R04) (deltaB PU correction)", vtxBin_, vtxMin_, vtxMax_);
127 cout <<
"[EfficiencyAnalyzer] Parameters initialization DONE" <<endl;
133 LogTrace(
metname)<<
"[EfficiencyAnalyzer] Analyze the mu in different eta regions";
134 theService->update(iSetup);
139 iEvent.
getByToken(theMuonCollectionLabel_, muons);
143 iEvent.
getByToken(theTrackCollectionLabel_,tracks);
153 bool bPrimaryVertex =
true;
155 bPrimaryVertex =
false;
158 LogTrace(
metname) <<
"[EfficiencyAnalyzer] Could not find vertex collection" << std::endl;
159 bPrimaryVertex =
false;
164 int vertex_number = vertexCollection.size();
166 reco::VertexCollection::const_iterator
v = vertexCollection.begin();
167 for ( ; v != vertexCollection.end(); ++
v) {
168 double vertex_chi2 = v->normalizedChi2();
169 double vertex_ndof = v->ndof();
170 bool fakeVtx = v->isFake();
171 double vertex_Z = v->z();
174 && vertex_number >= 1
177 && fabs(vertex_Z)< 24. ) {
178 bPrimaryVertex =
true;
190 unsigned int theIndexOfThePrimaryVertex = 999.;
192 for (
unsigned int ind=0; ind<vertex->size(); ++ind) {
193 if ( (*vertex)[ind].isValid() && !((*vertex)[ind].isFake()) ) {
194 theIndexOfThePrimaryVertex = ind;
200 if (theIndexOfThePrimaryVertex<100) {
201 posVtx = ((*vertex)[theIndexOfThePrimaryVertex]).
position();
202 errVtx = ((*vertex)[theIndexOfThePrimaryVertex]).
error();
205 LogInfo(
"RecoMuonValidator") <<
"reco::PrimaryVertex not found, use BeamSpot position instead\n";
208 iEvent.
getByToken(theBeamSpotLabel_,recoBeamSpotHandle);
214 errVtx(2,2) = bs.
sigmaZ();
223 TLorentzVector Mu1, Mu2;
229 LogTrace(
metname)<<
"[EfficiencyAnalyzer] loop over first muons" << endl;
233 float combIso = (Iso_muon.
emEt + Iso_muon.
hadEt + Iso_muon.
sumPt);
236 if (!muon1->isGlobalMuon())
continue;
240 float muPt1 = recoCombinedGlbTrack1->pt();
241 Mu1.SetPxPyPzE(recoCombinedGlbTrack1->px(), recoCombinedGlbTrack1->py(),recoCombinedGlbTrack1->pz(), recoCombinedGlbTrack1->p());
251 if (muPt1 <= 15)
continue;
252 if (combIso/muPt1 > 0.1 )
continue;
255 LogTrace(
metname)<<
"[EfficiencyAnalyzer] loop over second muon" <<endl;
256 if (muon2 == muon1)
continue;
258 if (muon2->eta() < 1.479 ) isMB =
true;
259 if (muon2->eta() >= 1.479 ) isME =
true;
262 Mu2.SetPxPyPzE(muon2->px(), muon2->py(), muon2->pz(), muon2->p());
264 float Minv = (Mu1+Mu2).M();
265 if (!muon2->isTrackerMuon())
continue;
266 if ( muon2->pt() < 5 )
continue;
267 if ( (muon1->charge())*(muon2->charge()) > 0 )
continue;
268 if ( Minv < 70 || Minv > 110 )
continue;
270 h_allProbes_pt->Fill(muon2->pt());
271 h_allProbes_eta->Fill(muon2->eta());
272 h_allProbes_phi->Fill(muon2->phi());
273 if(muon2->innerTrack()->extra().isAvailable()) {
274 h_allProbes_inner_pt->Fill(muon2->innerTrack()->innerMomentum().Rho());
275 h_allProbes_inner_eta->Fill(muon2->innerTrack()->innerPosition().Eta());
276 h_allProbes_inner_phi->Fill(muon2->innerTrack()->innerPosition().Phi());
278 if (isMB) h_allProbes_EB_pt->Fill(muon2->pt());
279 if (isME) h_allProbes_EE_pt->Fill(muon2->pt());
280 if(muon2->pt() > 20 ) h_allProbes_hp_eta->Fill(muon2->eta());
289 h_passProbes_ID_pt->Fill(muon2->pt());
290 h_passProbes_ID_eta->Fill(muon2->eta());
291 h_passProbes_ID_phi->Fill(muon2->phi());
292 if(muon2->innerTrack()->extra().isAvailable()) {
293 h_passProbes_ID_inner_pt->Fill(muon2->innerTrack()->innerMomentum().Rho());
294 h_passProbes_ID_inner_eta->Fill(muon2->innerTrack()->innerPosition().Eta());
295 h_passProbes_ID_inner_phi->Fill(muon2->innerTrack()->innerPosition().Phi());
298 if (isMB) h_passProbes_ID_EB_pt->Fill(muon2->pt());
299 if (isME) h_passProbes_ID_EE_pt->Fill(muon2->pt());
300 if( muon2->pt() > 20 ) h_passProbes_ID_hp_eta->Fill(muon2->eta());
302 h_allProbes_ID_pt->Fill(muon2->pt());
303 if (isMB) h_allProbes_EB_ID_pt->Fill(muon2->pt());
304 if (isME) h_allProbes_EE_ID_pt->Fill(muon2->pt());
307 if (bPrimaryVertex) h_allProbes_ID_nVtx->Fill(_numPV);
308 if (bPrimaryVertex && isMB) h_allProbes_EB_ID_nVtx->Fill(_numPV);
309 if (bPrimaryVertex && isME) h_allProbes_EE_ID_nVtx->Fill(_numPV);
312 float tkIso = muon2->isolationR03().sumPt;
313 float emIso = muon2->isolationR03().emEt;
314 float hadIso = muon2->isolationR03().hadEt + muon2->isolationR03().hoEt;
315 float relDetIso = (tkIso + emIso + hadIso) / (muon2->pt());
317 if (relDetIso < 0.05 ) {
318 h_passProbes_detIsoID_pt->Fill(muon2->pt());
319 if (isMB) h_passProbes_EB_detIsoID_pt->Fill(muon2->pt());
320 if (isME) h_passProbes_EE_detIsoID_pt->Fill(muon2->pt());
322 if (bPrimaryVertex) h_passProbes_detIsoID_nVtx->Fill(_numPV);
323 if (bPrimaryVertex && isMB) h_passProbes_EB_detIsoID_nVtx->Fill(_numPV);
324 if (bPrimaryVertex && isME) h_passProbes_EE_detIsoID_nVtx->Fill(_numPV);
328 float chargedIso = muon2->pfIsolationR04().sumChargedHadronPt;
329 float neutralIso = muon2->pfIsolationR04().sumNeutralHadronEt;
330 float photonIso = muon2->pfIsolationR04().sumPhotonEt;
331 float relPFIso = (chargedIso + neutralIso +
photonIso) / (muon2->pt());
333 float pu = muon2->pfIsolationR04().sumPUPt;
334 float neutralphotonPUCorrected =
std::max(0.0 , (neutralIso + photonIso - 0.5*pu ) );
335 float relPFIsoPUCorrected = (chargedIso + neutralphotonPUCorrected) / (muon2->pt());
339 if (relPFIso < 0.12 ) {
340 h_passProbes_pfIsoID_pt->Fill(muon2->pt());
341 if (isMB) h_passProbes_EB_pfIsoID_pt->Fill(muon2->pt());
342 if (isME) h_passProbes_EE_pfIsoID_pt->Fill(muon2->pt());
344 if( bPrimaryVertex) h_passProbes_pfIsoID_nVtx->Fill(_numPV);
345 if (bPrimaryVertex && isMB) h_passProbes_EB_pfIsoID_nVtx->Fill(_numPV);
346 if (bPrimaryVertex && isME) h_passProbes_EE_pfIsoID_nVtx->Fill(_numPV);
350 if ( relPFIsoPUCorrected < 0.12 ) {
351 h_passProbes_pfIsodBID_pt->Fill(muon2->pt());
352 if (isMB) h_passProbes_EB_pfIsodBID_pt->Fill(muon2->pt());
353 if (isME) h_passProbes_EE_pfIsodBID_pt->Fill(muon2->pt());
355 if( bPrimaryVertex) h_passProbes_pfIsodBID_nVtx->Fill(_numPV);
356 if (bPrimaryVertex && isMB) h_passProbes_EB_pfIsodBID_nVtx->Fill(_numPV);
357 if (bPrimaryVertex && isME) h_passProbes_EE_pfIsodBID_nVtx->Fill(_numPV);
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
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
void setCurrentFolder(std::string const &fullpath)
MonitorElement * book1D(Args &&...args)
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