16 #include "TLorentzVector.h"
36 theMuonCollectionLabel_ = consumes<reco::MuonCollection> (
parameters.getParameter<
edm::InputTag>(
"MuonCollection"));
37 theTrackCollectionLabel_ = consumes<reco::TrackCollection> (
parameters.getParameter<
edm::InputTag>(
"TrackCollection"));
56 theDbe->setCurrentFolder(
"Muons/EfficiencyAnalyzer");
59 doPVCheck_ =
parameters.getParameter<
bool>(
"doPrimaryVertexCheck");
61 ptBin_ =
parameters.getParameter<
int>(
"ptBin");
62 ptMin_ =
parameters.getParameter<
double>(
"ptMin");
63 ptMax_ =
parameters.getParameter<
double>(
"ptMax");
65 etaBin_ =
parameters.getParameter<
int>(
"etaBin");
66 etaMin_ =
parameters.getParameter<
double>(
"etaMin");
67 etaMax_ =
parameters.getParameter<
double>(
"etaMax");
69 phiBin_ =
parameters.getParameter<
int>(
"phiBin");
70 phiMin_ =
parameters.getParameter<
double>(
"phiMin");
71 phiMax_ =
parameters.getParameter<
double>(
"phiMax");
73 vtxBin_ =
parameters.getParameter<
int>(
"vtxBin");
74 vtxMin_ =
parameters.getParameter<
double>(
"vtxMin");
75 vtxMax_ =
parameters.getParameter<
double>(
"vtxMax");
77 test_TightMu_Minv = theDbe->book1D(
"test_TightMu_Minv" ,
"Minv",50,70,110);
79 h_allProbes_pt = theDbe->book1D(
"allProbes_pt",
"All Probes Pt", ptBin_, ptMin_, ptMax_);
80 h_allProbes_EB_pt = theDbe->book1D(
"allProbes_EB_pt",
"Barrel: all Probes Pt", ptBin_, ptMin_, ptMax_);
81 h_allProbes_EE_pt = theDbe->book1D(
"allProbes_EE_pt",
"Endcap: all Probes Pt", ptBin_, ptMin_, ptMax_);
82 h_allProbes_eta = theDbe->book1D(
"allProbes_eta",
"All Probes Eta", etaBin_, etaMin_, etaMax_);
83 h_allProbes_hp_eta = theDbe->book1D(
"allProbes_hp_eta",
"High Pt all Probes Eta", etaBin_, etaMin_, etaMax_);
84 h_allProbes_phi = theDbe->book1D(
"allProbes_phi",
"All Probes Phi", phiBin_, phiMin_, phiMax_);
86 h_allProbes_TightMu_pt = theDbe->book1D(
"allProbes_TightMu_pt",
"All TightMu Probes Pt", ptBin_, ptMin_, ptMax_);
87 h_allProbes_EB_TightMu_pt = theDbe->book1D(
"allProbes_EB_TightMu_pt",
"Barrel: all TightMu Probes Pt", ptBin_, ptMin_, ptMax_);
88 h_allProbes_EE_TightMu_pt = theDbe->book1D(
"allProbes_EE_TightMu_pt",
"Endcap: all TightMu Probes Pt", ptBin_, ptMin_, ptMax_);
89 h_allProbes_TightMu_nVtx = theDbe->book1D(
"allProbes_TightMu_nVtx",
"All Probes (TightMu) nVtx", vtxBin_, vtxMin_, vtxMax_);
90 h_allProbes_EB_TightMu_nVtx = theDbe->book1D(
"allProbes_EB_TightMu_nVtx",
"Barrel: All Probes (TightMu) nVtx", vtxBin_, vtxMin_, vtxMax_);
91 h_allProbes_EE_TightMu_nVtx = theDbe->book1D(
"allProbes_EE_TightMu_nVtx",
"Endcap: All Probes (TightMu) nVtx", vtxBin_, vtxMin_, vtxMax_);
93 h_passProbes_TightMu_pt = theDbe->book1D(
"passProbes_TightMu_pt",
"TightMu Passing Probes Pt", ptBin_ , ptMin_ , ptMax_ );
94 h_passProbes_TightMu_EB_pt = theDbe->book1D(
"passProbes_TightMu_EB_pt",
"Barrel: TightMu Passing Probes Pt", ptBin_ , ptMin_ , ptMax_ );
95 h_passProbes_TightMu_EE_pt = theDbe->book1D(
"passProbes_TightMu_EE_pt",
"Endcap: TightMu Passing Probes Pt", ptBin_ , ptMin_ , ptMax_ );
96 h_passProbes_TightMu_eta = theDbe->book1D(
"passProbes_TightMu_eta",
"TightMu Passing Probes #eta", etaBin_, etaMin_, etaMax_);
97 h_passProbes_TightMu_hp_eta = theDbe->book1D(
"passProbes_TightMu_hp_eta",
"High Pt TightMu Passing Probes #eta", etaBin_, etaMin_, etaMax_);
98 h_passProbes_TightMu_phi = theDbe->book1D(
"passProbes_TightMu_phi",
"TightMu Passing Probes #phi", phiBin_, phiMin_, phiMax_);
100 h_passProbes_detIsoTightMu_pt = theDbe->book1D(
"passProbes_detIsoTightMu_pt",
"detIsoTightMu Passing Probes Pt", ptBin_, ptMin_, ptMax_);
101 h_passProbes_EB_detIsoTightMu_pt = theDbe->book1D(
"passProbes_EB_detIsoTightMu_pt",
"Barrel: detIsoTightMu Passing Probes Pt", ptBin_, ptMin_, ptMax_);
102 h_passProbes_EE_detIsoTightMu_pt = theDbe->book1D(
"passProbes_EE_detIsoTightMu_pt",
"Endcap: detIsoTightMu Passing Probes Pt", ptBin_, ptMin_, ptMax_);
104 h_passProbes_pfIsoTightMu_pt = theDbe->book1D(
"passProbes_pfIsoTightMu_pt",
"pfIsoTightMu Passing Probes Pt", ptBin_, ptMin_, ptMax_);
105 h_passProbes_EB_pfIsoTightMu_pt = theDbe->book1D(
"passProbes_EB_pfIsoTightMu_pt",
"Barrel: pfIsoTightMu Passing Probes Pt", ptBin_, ptMin_, ptMax_);
106 h_passProbes_EE_pfIsoTightMu_pt = theDbe->book1D(
"passProbes_EE_pfIsoTightMu_pt",
"Endcap: pfIsoTightMu Passing Probes Pt", ptBin_, ptMin_, ptMax_);
108 h_passProbes_detIsoTightMu_nVtx = theDbe->book1D(
"passProbes_detIsoTightMu_nVtx",
"detIsoTightMu Passing Probes nVtx (R03)", vtxBin_, vtxMin_, vtxMax_);
109 h_passProbes_pfIsoTightMu_nVtx = theDbe->book1D(
"passProbes_pfIsoTightMu_nVtx",
"pfIsoTightMu Passing Probes nVtx (R04)", vtxBin_, vtxMin_, vtxMax_);
110 h_passProbes_EB_detIsoTightMu_nVtx = theDbe->book1D(
"passProbes_EB_detIsoTightMu_nVtx",
"Barrel: detIsoTightMu Passing Probes nVtx (R03)", vtxBin_, vtxMin_, vtxMax_);
111 h_passProbes_EE_detIsoTightMu_nVtx = theDbe->book1D(
"passProbes_EE_detIsoTightMu_nVtx",
"Endcap: detIsoTightMu Passing Probes nVtx (R03)", vtxBin_, vtxMin_, vtxMax_);
112 h_passProbes_EB_pfIsoTightMu_nVtx = theDbe->book1D(
"passProbes_EB_pfIsoTightMu_nVtx",
"Barrel: pfIsoTightMu Passing Probes nVtx (R04)", vtxBin_, vtxMin_, vtxMax_);
113 h_passProbes_EE_pfIsoTightMu_nVtx = theDbe->book1D(
"passProbes_EE_pfIsoTightMu_nVtx",
"Endcap: pfIsoTightMu Passing Probes nVtx (R04)", vtxBin_, vtxMin_, vtxMax_);
118 h_passProbes_pfIsodBTightMu_pt = theDbe->book1D(
"passProbes_pfIsodBTightMu_pt",
"pfIsoTightMu Passing Probes Pt (deltaB PU correction)", ptBin_, ptMin_, ptMax_);
119 h_passProbes_EB_pfIsodBTightMu_pt = theDbe->book1D(
"passProbes_EB_pfIsodBTightMu_pt",
"Barrel: pfIsoTightMu Passing Probes Pt (deltaB PU correction)", ptBin_, ptMin_, ptMax_);
120 h_passProbes_EE_pfIsodBTightMu_pt = theDbe->book1D(
"passProbes_EE_pfIsodBTightMu_pt",
"Endcap: pfIsoTightMu Passing Probes Pt (deltaB PU correction)", ptBin_, ptMin_, ptMax_);
121 h_passProbes_pfIsodBTightMu_nVtx = theDbe->book1D(
"passProbes_pfIsodBTightMu_nVtx",
"pfIsoTightMu Passing Probes nVtx (R04) (deltaB PU correction)", vtxBin_, vtxMin_, vtxMax_);
122 h_passProbes_EB_pfIsodBTightMu_nVtx = theDbe->book1D(
"passProbes_EB_pfIsodBTightMu_nVtx",
"Barrel: pfIsoTightMu Passing Probes nVtx (R04) (deltaB PU correction)", vtxBin_, vtxMin_, vtxMax_);
123 h_passProbes_EE_pfIsodBTightMu_nVtx = theDbe->book1D(
"passProbes_EE_pfIsodBTightMu_nVtx",
"Endcap: pfIsoTightMu Passing Probes nVtx (R04) (deltaB PU correction)", vtxBin_, vtxMin_, vtxMax_);
128 cout <<
"[EfficiencyAnalyzer] Parameters initialization DONE" <<endl;
134 LogTrace(
metname)<<
"[EfficiencyAnalyzer] Analyze the mu in different eta regions";
135 theService->update(iSetup);
140 iEvent.
getByToken(theMuonCollectionLabel_, muons);
144 iEvent.
getByToken(theTrackCollectionLabel_,tracks);
154 bool bPrimaryVertex =
true;
156 bPrimaryVertex =
false;
159 LogTrace(
metname) <<
"[EfficiencyAnalyzer] Could not find vertex collection" << std::endl;
160 bPrimaryVertex =
false;
165 int vertex_number = vertexCollection.size();
167 reco::VertexCollection::const_iterator
v = vertexCollection.begin();
168 for ( ; v != vertexCollection.end(); ++
v) {
169 double vertex_chi2 = v->normalizedChi2();
170 double vertex_ndof = v->ndof();
171 bool fakeVtx = v->isFake();
172 double vertex_Z = v->z();
175 && vertex_number >= 1
178 && fabs(vertex_Z)< 24. ) {
179 bPrimaryVertex =
true;
191 unsigned int theIndexOfThePrimaryVertex = 999.;
193 for (
unsigned int ind=0; ind<vertex->size(); ++ind) {
194 if ( (*vertex)[ind].isValid() && !((*vertex)[ind].isFake()) ) {
195 theIndexOfThePrimaryVertex = ind;
201 if (theIndexOfThePrimaryVertex<100) {
202 posVtx = ((*vertex)[theIndexOfThePrimaryVertex]).
position();
203 errVtx = ((*vertex)[theIndexOfThePrimaryVertex]).
error();
206 LogInfo(
"RecoMuonValidator") <<
"reco::PrimaryVertex not found, use BeamSpot position instead\n";
209 iEvent.
getByToken(theBeamSpotLabel_,recoBeamSpotHandle);
215 errVtx(2,2) = bs.
sigmaZ();
224 TLorentzVector Mu1, Mu2;
229 for (reco::MuonCollection::const_iterator recoMu1 = muons->begin(); recoMu1!=muons->end(); ++recoMu1) {
230 LogTrace(
metname)<<
"[EfficiencyAnalyzer] loop over first muons" << endl;
234 float combIso = (Iso_muon.
emEt + Iso_muon.
hadEt + Iso_muon.
sumPt);
237 if (!recoMu1->isGlobalMuon())
continue;
241 float muPt1 = recoCombinedGlbTrack1->pt();
242 Mu1.SetPxPyPzE(recoCombinedGlbTrack1->px(), recoCombinedGlbTrack1->py(),recoCombinedGlbTrack1->pz(), recoCombinedGlbTrack1->p());
251 if (muPt1 <= 15)
continue;
252 if (combIso/muPt1 > 0.1 )
continue;
254 for (reco::MuonCollection::const_iterator recoMu2 = muons->begin(); recoMu2!=muons->end(); ++recoMu2){
255 LogTrace(
metname)<<
"[EfficiencyAnalyzer] loop over second muon" <<endl;
256 if (recoMu2 == recoMu1)
continue;
258 if (recoMu2->eta() < 1.479 ) isMB =
true;
259 if (recoMu2->eta() >= 1.479 ) isME =
true;
262 Mu2.SetPxPyPzE(recoMu2->px(), recoMu2->py(), recoMu2->pz(), recoMu2->p());
264 float Minv = (Mu1+Mu2).M();
265 if (!recoMu2->isTrackerMuon())
continue;
266 if ( recoMu2->pt() < 5 )
continue;
267 if ( (recoMu1->charge())*(recoMu2->charge()) > 0 )
continue;
268 if ( Minv < 70 || Minv > 110 )
continue;
270 h_allProbes_pt->Fill(recoMu2->pt());
271 h_allProbes_eta->Fill(recoMu2->eta());
272 h_allProbes_phi->Fill(recoMu2->phi());
274 if (isMB) h_allProbes_EB_pt->Fill(recoMu2->pt());
275 if (isME) h_allProbes_EE_pt->Fill(recoMu2->pt());
276 if(recoMu2->pt() > 20 ) h_allProbes_hp_eta->Fill(recoMu2->eta());
278 test_TightMu_Minv->Fill(Minv);
286 h_passProbes_TightMu_pt->Fill(recoMu2->pt());
287 h_passProbes_TightMu_eta->Fill(recoMu2->eta());
288 h_passProbes_TightMu_phi->Fill(recoMu2->phi());
290 if (isMB) h_passProbes_TightMu_EB_pt->Fill(recoMu2->pt());
291 if (isME) h_passProbes_TightMu_EE_pt->Fill(recoMu2->pt());
292 if( recoMu2->pt() > 20 ) h_passProbes_TightMu_hp_eta->Fill(recoMu2->eta());
294 h_allProbes_TightMu_pt->Fill(recoMu2->pt());
295 if (isMB) h_allProbes_EB_TightMu_pt->Fill(recoMu2->pt());
296 if (isME) h_allProbes_EE_TightMu_pt->Fill(recoMu2->pt());
299 if (bPrimaryVertex) h_allProbes_TightMu_nVtx->Fill(_numPV);
300 if (bPrimaryVertex && isMB) h_allProbes_EB_TightMu_nVtx->Fill(_numPV);
301 if (bPrimaryVertex && isME) h_allProbes_EE_TightMu_nVtx->Fill(_numPV);
304 float tkIso = recoMu2->isolationR03().sumPt;
305 float emIso = recoMu2->isolationR03().emEt;
306 float hadIso = recoMu2->isolationR03().hadEt + recoMu2->isolationR03().hoEt;
307 float relDetIso = (tkIso + emIso + hadIso) / (recoMu2->pt());
309 if (relDetIso < 0.05 ) {
310 h_passProbes_detIsoTightMu_pt->Fill(recoMu2->pt());
311 if (isMB) h_passProbes_EB_detIsoTightMu_pt->Fill(recoMu2->pt());
312 if (isME) h_passProbes_EE_detIsoTightMu_pt->Fill(recoMu2->pt());
314 if (bPrimaryVertex) h_passProbes_detIsoTightMu_nVtx->Fill(_numPV);
315 if (bPrimaryVertex && isMB) h_passProbes_EB_detIsoTightMu_nVtx->Fill(_numPV);
316 if (bPrimaryVertex && isME) h_passProbes_EE_detIsoTightMu_nVtx->Fill(_numPV);
320 float chargedIso = recoMu2->pfIsolationR04().sumChargedHadronPt;
321 float neutralIso = recoMu2->pfIsolationR04().sumNeutralHadronEt;
322 float photonIso = recoMu2->pfIsolationR04().sumPhotonEt;
323 float relPFIso = (chargedIso + neutralIso + photonIso) / (recoMu2->pt());
325 float pu = recoMu2->pfIsolationR04().sumPUPt;
327 float neutralphotonPUCorrected =
std::max(0.0 , (neutralIso + photonIso - 0.5*pu ) );
329 float relPFIsoPUCorrected = (chargedIso + neutralphotonPUCorrected) / (recoMu2->pt());
333 if (relPFIso < 0.12 ) {
334 h_passProbes_pfIsoTightMu_pt->Fill(recoMu2->pt());
335 if (isMB) h_passProbes_EB_pfIsoTightMu_pt->Fill(recoMu2->pt());
336 if (isME) h_passProbes_EE_pfIsoTightMu_pt->Fill(recoMu2->pt());
338 if( bPrimaryVertex) h_passProbes_pfIsoTightMu_nVtx->Fill(_numPV);
339 if (bPrimaryVertex && isMB) h_passProbes_EB_pfIsoTightMu_nVtx->Fill(_numPV);
340 if (bPrimaryVertex && isME) h_passProbes_EE_pfIsoTightMu_nVtx->Fill(_numPV);
347 if ( relPFIsoPUCorrected < 0.12 ) {
349 h_passProbes_pfIsodBTightMu_pt->Fill(recoMu2->pt());
350 if (isMB) h_passProbes_EB_pfIsodBTightMu_pt->Fill(recoMu2->pt());
351 if (isME) h_passProbes_EE_pfIsodBTightMu_pt->Fill(recoMu2->pt());
353 if( bPrimaryVertex) h_passProbes_pfIsodBTightMu_nVtx->Fill(_numPV);
354 if (bPrimaryVertex && isMB) h_passProbes_EB_pfIsodBTightMu_nVtx->Fill(_numPV);
355 if (bPrimaryVertex && isME) h_passProbes_EE_pfIsodBTightMu_nVtx->Fill(_numPV);
float sumPt
sum-pt of tracks
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
static int position[TOTALCHAMBERS][3]
const T & max(const T &a, const T &b)
math::XYZPoint Point
point in the space
double BeamWidthX() const
beam width X
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup)
void beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup)
double sigmaZ() const
sigma z
double BeamWidthY() const
beam width Y
T const * product() const
const Point & position() const
position
virtual ~EfficiencyAnalyzer()
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
EfficiencyAnalyzer(const edm::ParameterSet &pset)