37 #include "TLorentzVector.h"
51 thePFJetCollectionLabel_ =
53 theCaloMETCollectionLabel_ =
55 theTriggerResultsCollection_ =
58 theElecTriggerPathToPass_ =
59 parameters.
getParameter<std::vector<string> >(
"elecTriggerPathToPass");
60 theMuonTriggerPathToPass_ =
61 parameters.
getParameter<std::vector<string> >(
"muonTriggerPathToPass");
62 theTriggerResultsToken_ = consumes<edm::TriggerResults>(
64 theMuonCollectionLabel_ = consumes<reco::MuonCollection>(
66 theElectronCollectionLabel_ = consumes<reco::GsfElectronCollection>(
68 thePFJetCollectionToken_ = consumes<edm::View<reco::Jet> >(
70 theCaloMETCollectionToken_ = consumes<edm::View<reco::MET> >(
72 theVertexToken_ = consumes<reco::VertexCollection>(
76 isValidHltConfig_ =
false;
128 char chtitle[256] =
"";
129 const size_t title_s =
sizeof(chtitle);
131 logTraceName =
"EwkAnalyzer";
133 LogTrace(logTraceName) <<
"Parameters initialization";
134 theDbe->setCurrentFolder(
"Physics/EwkDQM");
136 const float pi = 4*atan(1);
139 h_vertex_number = theDbe->book1D(
"vertex_number",
140 "Number of event vertices in collection",
142 h_vertex_chi2 = theDbe->book1D(
"vertex_chi2",
143 "Event Vertex #chi^{2}/n.d.o.f.",
145 h_vertex_numTrks = theDbe->book1D(
"vertex_numTrks",
146 "Event Vertex, number of tracks",
148 h_vertex_sumTrks = theDbe->book1D(
"vertex_sumTrks",
149 "Event Vertex, sum of track pt",
151 h_vertex_d0 = theDbe->book1D(
"vertex_d0",
152 "Event Vertex d0", 20, 0.0, 0.05);
154 snprintf(chtitle, title_s,
"Number of %s (E_{T} > 15 GeV);Number of Jets",
155 thePFJetCollectionLabel_.label().data());
156 h_jet_count = theDbe->book1D(
"jet_count", chtitle, 8, -0.5, 7.5);
158 snprintf(chtitle, title_s,
"Leading jet E_{T} (from %s);E_{T}(1^{st} jet) (GeV)",
159 thePFJetCollectionLabel_.label().data());
160 h_jet_et = theDbe->book1D(
"jet_et", chtitle, 20, 0., 200.0);
162 snprintf(chtitle, title_s,
"Leading jet p_{T} (from %s);p_{T}(1^{st} jet) (GeV/c)",
163 thePFJetCollectionLabel_.label().data());
164 h_jet_pt = theDbe->book1D(
"jet_pt", chtitle, 20, 0., 200.0);
166 snprintf(chtitle, title_s,
"Leading jet #eta (from %s); #eta (1^{st} jet)",
167 thePFJetCollectionLabel_.label().data());
168 h_jet_eta = theDbe->book1D(
"jet_eta", chtitle, 20, -10., 10.0);
169 snprintf(chtitle, title_s,
"Leading jet #phi (from %s); #phi(1^{st} jet)",
170 thePFJetCollectionLabel_.label().data());
171 h_jet_phi = theDbe->book1D(
"jet_phi", chtitle, 22, -1.1*pi, 1.1*pi);
173 snprintf(chtitle, title_s,
"2^{nd} leading jet E_{T} (from %s);E_{T}(2^{nd} jet) (GeV)",
174 thePFJetCollectionLabel_.label().data());
175 h_jet2_et = theDbe->book1D(
"jet2_et", chtitle, 20, 0., 200.0);
180 snprintf(chtitle, title_s,
"2^{nd} leading jet #eta (from %s); #eta (2^{nd} jet)",
181 thePFJetCollectionLabel_.label().data());
182 h_jet2_eta = theDbe->book1D(
"jet2_eta", chtitle, 20, -10., 10.0);
184 snprintf(chtitle, title_s,
"2^{nd} leading jet #phi (from %s); #phi(2^{nd} jet)",
185 thePFJetCollectionLabel_.label().data());
186 h_jet2_phi = theDbe->book1D(
"jet2_phi", chtitle, 22, -1.1*pi, 1.1*pi);
188 h_e1_et = theDbe->book1D(
"e1_et",
"E_{T} of Leading Electron;E_{T} (GeV)",
190 h_e2_et = theDbe->book1D(
"e2_et",
"E_{T} of Second Electron;E_{T} (GeV)",
192 h_e1_eta = theDbe->book1D(
"e1_eta",
"#eta of Leading Electron;#eta",
194 h_e2_eta = theDbe->book1D(
"e2_eta",
"#eta of Second Electron;#eta",
196 h_e1_phi = theDbe->book1D(
"e1_phi",
"#phi of Leading Electron;#phi",
197 22, -1.1*pi, 1.1*pi);
198 h_e2_phi = theDbe->book1D(
"e2_phi",
"#phi of Second Electron;#phi",
199 22, -1.1*pi, 1.1*pi);
200 h_m1_pt = theDbe->book1D(
"m1_pt",
"p_{T} of Leading Muon;p_{T}(1^{st} #mu) (GeV)",
202 h_m2_pt = theDbe->book1D(
"m2_pt",
"p_{T} of Second Muon;p_{T}(2^{nd} #mu) (GeV)",
204 h_m1_eta = theDbe->book1D(
"m1_eta",
"#eta of Leading Muon;#eta(1^{st} #mu)",
206 h_m2_eta = theDbe->book1D(
"m2_eta",
"#eta of Second Muon;#eta(2^{nd} #mu)",
208 h_m1_phi = theDbe->book1D(
"m1_phi",
"#phi of Leading Muon;#phi(1^{st} #mu)",
209 20, (-1. - 1./10.)*pi, (1. + 1./10.)*pi);
210 h_m2_phi = theDbe->book1D(
"m2_phi",
"#phi of Second Muon;#phi(2^{nd} #mu)",
211 20, (-1. - 1./10.)*pi, (1. + 1./10.)*pi);
218 snprintf(chtitle, title_s,
"Missing E_{T} (%s); GeV",
219 theCaloMETCollectionLabel_.label().data());
220 h_met = theDbe->book1D(
"met", chtitle, 20, 0.0, 100);
221 h_met_phi = theDbe->book1D(
"met_phi",
"Missing E_{T} #phi;#phi(MET)",
222 22, (-1. - 1./10.)*pi, (1. + 1./10.)*pi);
224 h_e_invWMass = theDbe->book1D(
"we_invWMass",
"W-> e #nu Transverse Mass;M_{T} (GeV)",
226 h_m_invWMass = theDbe->book1D(
"wm_invWMass",
"W-> #mu #nu Transverse Mass;M_{T} (GeV)",
228 h_mumu_invMass = theDbe->book1D(
"z_mm_invMass",
"#mu#mu Invariant Mass;InvMass (GeV)",
230 h_ee_invMass = theDbe->book1D(
"z_ee_invMass",
"ee Invariant Mass;InvMass (Gev)",
239 bool isConfigChanged =
false;
242 const std::string hltProcessName(theTriggerResultsCollection_.process());
243 isValidHltConfig_ = hltConfigProvider_.init(theRun, theSetup,
244 hltProcessName, isConfigChanged);
250 if (!isValidHltConfig_)
253 LogTrace(logTraceName) <<
"Analysis of event # ";
256 iEvent.
getByToken(theTriggerResultsToken_, HLTresults);
263 std::vector<std::string> eleTrigPathNames;
264 std::vector<std::string> muTrigPathNames;
270 bool passed_electron_HLT =
false;
271 bool passed_muon_HLT =
false;
272 for (
unsigned int i = 0;
i < HLTresults->size();
i++) {
275 for (
unsigned int index = 0;
276 index < theElecTriggerPathToPass_.size() && !passed_electron_HLT;
279 size_t trigPath = trigName.find(theElecTriggerPathToPass_[
index]);
282 passed_electron_HLT = HLTresults->accept(
i);
286 for (
unsigned int index = 0;
287 index < theMuonTriggerPathToPass_.size() && !passed_muon_HLT;
290 size_t trigPath = trigName.find(theMuonTriggerPathToPass_[
index]);
293 passed_muon_HLT = HLTresults->accept(
i);
299 if (!(passed_electron_HLT || passed_muon_HLT))
305 iEvent.
getByToken(theVertexToken_, vertexHandle);
309 VertexCollection::const_iterator
v = vertexCollection.begin();
310 int vertex_number = vertexCollection.size();
311 double vertex_chi2 = v->normalizedChi2();
312 double vertex_d0 =
sqrt(v->x()*v->x()+v->y()*v->y());
313 double vertex_numTrks = v->tracksSize();
314 double vertex_sumTrks = 0.0;
318 vertex_curTrack != v->tracks_end(); vertex_curTrack++)
319 vertex_sumTrks += (*vertex_curTrack)->pt();
324 iEvent.
getByToken(theCaloMETCollectionToken_, caloMETCollection);
325 if (!caloMETCollection.
isValid())
327 float missing_et = caloMETCollection->begin()->et();
328 float met_phi = caloMETCollection->begin()->phi();
334 iEvent.
getByToken(theElectronCollectionLabel_, electronCollection);
335 if (!electronCollection.
isValid())
339 float electron_et = -8.0;
340 float electron_eta = -8.0;
341 float electron_phi = -8.0;
342 float electron2_et = -9.0;
343 float electron2_eta = -9.0;
344 float electron2_phi = -9.0;
345 float ee_invMass = -9.0;
346 TLorentzVector e1, e2;
349 if (passed_electron_HLT) {
350 for (reco::GsfElectronCollection::const_iterator recoElectron = electronCollection->begin();
351 recoElectron != electronCollection->end(); recoElectron++) {
353 if (recoElectron->et() < 20 || fabs(recoElectron->eta()) > 2.5)
357 if (recoElectron->deltaPhiSuperClusterTrackAtVtx() > 0.58 ||
358 recoElectron->deltaEtaSuperClusterTrackAtVtx() > 0.01 ||
359 recoElectron->sigmaIetaIeta() > 0.027)
362 if (recoElectron->et() > electron_et) {
363 electron2_et = electron_et;
364 electron2_eta = electron_eta;
365 electron2_phi = electron_phi;
366 electron_et = recoElectron->et();
367 electron_eta = recoElectron->eta();
368 electron_phi = recoElectron->phi();
369 e1 = TLorentzVector(recoElectron->momentum().x(),
370 recoElectron->momentum().y(),
371 recoElectron->momentum().z(),
373 }
else if (recoElectron->et() > electron2_et) {
374 electron2_et = recoElectron->et();
375 electron2_eta = recoElectron->eta();
376 electron2_phi = recoElectron->phi();
377 e2 = TLorentzVector(recoElectron->momentum().x(),
378 recoElectron->momentum().y(),
379 recoElectron->momentum().z(),
383 if (electron2_et > 0.0) {
384 TLorentzVector pair = e1+e2;
385 ee_invMass = pair.M();
395 iEvent.
getByToken(theMuonCollectionLabel_, muonCollection);
400 float mm_invMass = -9.0;
401 float muon_pt = -9.0;
402 float muon_eta = -9.0;
403 float muon_phi = -9.0;
404 float muon2_pt = -9.0;
405 float muon2_eta = -9.0;
406 float muon2_phi = -9.0;
407 TLorentzVector m1, m2;
409 if (passed_muon_HLT) {
410 for (reco::MuonCollection::const_iterator recoMuon = muonCollection->begin();
411 recoMuon != muonCollection->end(); recoMuon++) {
413 if (recoMuon->pt() < 20 || !recoMuon->isGlobalMuon())
416 if (recoMuon->globalTrack()->normalizedChi2() > 10)
419 if (recoMuon->pt() > muon_pt) {
421 muon2_eta = muon_eta;
422 muon2_phi = muon_phi;
423 muon_pt = recoMuon->pt();
424 muon_eta = recoMuon->eta();
425 muon_phi = recoMuon->phi();
426 m1 = TLorentzVector(recoMuon->momentum().x(),
427 recoMuon->momentum().y(),
428 recoMuon->momentum().z(),
430 }
else if (recoMuon->pt() > muon2_pt) {
431 muon2_pt = recoMuon->pt();
432 muon2_eta = recoMuon->eta();
433 muon2_phi = recoMuon->phi();
434 m2 = TLorentzVector(recoMuon->momentum().x(),
435 recoMuon->momentum().y(),
436 recoMuon->momentum().z(),
441 if (muon2_pt > 0.0) {
442 TLorentzVector pair = m1+m2;
443 mm_invMass = pair.M();
453 iEvent.
getByToken(thePFJetCollectionToken_, PFJetCollection);
454 if (!PFJetCollection.
isValid())
457 unsigned int muonCollectionSize = muonCollection->size();
459 unsigned int PFJetCollectionSize = PFJetCollection->size();
464 float jet_et = -80.0;
465 float jet_pt = -80.0;
466 float jet_eta = -80.0;
467 float jet_phi = -80.0;
468 float jet2_et = -90.0;
469 float jet2_eta = -90.0;
470 float jet2_phi = -90.0;
480 for (
unsigned int i = 0;
i < PFJetCollectionSize;
i++) {
481 const Jet&
jet = PFJetCollection->at(
i);
483 double minDistance = 99999;
484 for (
unsigned int j = 0;
j < muonCollectionSize;
j++) {
485 const Muon&
mu = muonCollection->at(
j);
488 if (minDistance > distance)
489 minDistance = distance;
491 if (minDistance < 0.3)
496 if (electron_et > 0.0 &&
497 fabs(jet.
eta() - electron_eta) < 0.2 &&
500 if (electron2_et > 0.0 &&
501 fabs(jet.
eta() - electron2_eta) < 0.2 &&
512 if (jet.
et() < eJetMin_)
527 if (jet.
et() > jet_et) {
539 }
else if (jet.
et() > jet2_et) {
544 jet2_eta = jet.
eta();
545 jet2_phi = jet.
phi();
557 bool fill_e1 =
false;
558 bool fill_e2 =
false;
559 bool fill_m1 =
false;
560 bool fill_m2 =
false;
561 bool fill_met =
false;
564 if (ee_invMass > 0.0) {
565 h_ee_invMass->Fill(ee_invMass);
571 if (mm_invMass > 0.0) {
572 h_mumu_invMass->Fill(mm_invMass);
575 h_jet2_et ->Fill(jet2_et);
579 if (electron_et > 0.0 && missing_et > 20.0) {
580 float dphiW = fabs(met_phi-electron_phi);
581 float W_mt_e =
sqrt(2 * missing_et * electron_et * (1 -
cos(dphiW)));
582 h_e_invWMass->Fill(W_mt_e);
588 if (muon_pt > 0.0 && missing_et > 20.0) {
589 float dphiW = fabs(met_phi - muon_phi);
590 float W_mt_m =
sqrt(2 * missing_et * muon_pt * (1 -
cos(dphiW)));
591 h_m_invWMass->Fill(W_mt_m);
596 if (jet_et > -10.0) {
597 h_jet_et->Fill(jet_et);
598 h_jet_count->Fill(jet_count);
602 h_jet_pt->Fill(jet_pt);
605 if (jet_eta > -50.) {
606 h_jet_eta->Fill(jet_eta);
609 if (jet_phi > -10.) {
610 h_jet_phi->Fill(jet_phi);
613 if (jet2_et > -10.0) {
614 h_jet2_et->Fill(jet2_et);
621 if (jet2_eta > -50.) {
622 h_jet2_eta->Fill(jet2_eta);
625 if (jet2_phi > -10.) {
626 h_jet2_phi->Fill(jet2_phi);
631 if (fill_e1 || fill_m1) {
632 h_vertex_number->Fill(vertex_number);
633 h_vertex_chi2->Fill(vertex_chi2);
634 h_vertex_d0->Fill(vertex_d0);
635 h_vertex_numTrks->Fill(vertex_numTrks);
636 h_vertex_sumTrks->Fill(vertex_sumTrks);
640 h_e1_et->Fill(electron_et);
641 h_e1_eta->Fill(electron_eta);
642 h_e1_phi->Fill(electron_phi);
645 h_e2_et->Fill(electron2_et);
646 h_e2_eta->Fill(electron2_eta);
647 h_e2_phi->Fill(electron2_phi);
650 h_m1_pt->Fill(muon_pt);
651 h_m1_eta->Fill(muon_eta);
652 h_m1_phi->Fill(muon_phi);
655 h_m2_pt->Fill(muon2_pt);
656 h_m2_eta->Fill(muon2_eta);
657 h_m2_phi->Fill(muon2_phi);
660 h_met->Fill(missing_et);
661 h_met_phi->Fill(met_phi);
677 if (deltaPhi > 3.1415926)
678 deltaPhi = 2 * 3.1415926 -
deltaPhi;
void beginRun(const edm::Run &, const edm::EventSetup &)
T getParameter(std::string const &) const
double calcDeltaPhi(double phi1, double phi2)
T getUntrackedParameter(std::string const &, T const &) const
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
virtual float pt() const
transverse momentum
EwkDQM(const edm::ParameterSet &)
Constructor.
virtual double et() const
transverse energy
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual float phi() const
momentum azimuthal angle
Base class for all types of Jets.
void endJob(void)
Save the histos.
std::vector< Vertex > VertexCollection
collection of Vertex objects
void analyze(const edm::Event &, const edm::EventSetup &)
Get the analysis.
virtual float eta() const
momentum pseudorapidity
Cos< T >::type cos(const T &t)
void beginJob()
Inizialize parameters for histo binning.
static const char *const trigNames[]
std::string const & triggerName(unsigned int index) const
virtual ~EwkDQM()
Destructor.
T const * product() const
std::vector< PFJet > PFJetCollection
collection of PFJet objects
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
double calcDeltaPhi(double phi1, double phi2)