37 #include "TLorentzVector.h" 49 thePFJetCollectionLabel_ =
51 theCaloMETCollectionLabel_ =
53 theTriggerResultsCollection_ =
56 theElecTriggerPathToPass_ =
57 parameters.
getParameter<std::vector<string> >(
"elecTriggerPathToPass");
58 theMuonTriggerPathToPass_ =
59 parameters.
getParameter<std::vector<string> >(
"muonTriggerPathToPass");
60 theTriggerResultsToken_ = consumes<edm::TriggerResults>(
62 theMuonCollectionLabel_ = consumes<reco::MuonCollection>(
64 theElectronCollectionLabel_ = consumes<reco::GsfElectronCollection>(
66 thePFJetCollectionToken_ = consumes<edm::View<reco::Jet> >(
68 theCaloMETCollectionToken_ = consumes<edm::View<reco::MET> >(
70 theVertexToken_ = consumes<reco::VertexCollection>(
74 isValidHltConfig_ =
false;
126 char chtitle[256] =
"";
127 const size_t title_s =
sizeof(chtitle);
129 logTraceName =
"EwkAnalyzer";
131 LogTrace(logTraceName) <<
"Parameters initialization";
133 const float pi = 4 * atan(1);
137 h_vertex_number = ibooker.
book1D(
138 "vertex_number",
"Number of event vertices in collection", 10, -0.5, 9.5);
139 h_vertex_chi2 = ibooker.
book1D(
140 "vertex_chi2",
"Event Vertex #chi^{2}/n.d.o.f.", 20, 0.0, 2.0);
141 h_vertex_numTrks = ibooker.
book1D(
142 "vertex_numTrks",
"Event Vertex, number of tracks", 20, -0.5, 59.5);
143 h_vertex_sumTrks = ibooker.
book1D(
144 "vertex_sumTrks",
"Event Vertex, sum of track pt", 20, 0.0, 100.0);
145 h_vertex_d0 = ibooker.
book1D(
"vertex_d0",
"Event Vertex d0", 20, 0.0, 0.05);
147 h_jet_count = ibooker.
book1D(
"jet_count", chtitle, 8, -0.5, 7.5);
149 snprintf(chtitle, title_s,
"Leading jet E_{T} (from %s);E_{T}(1^{st} jet) (GeV)",
150 thePFJetCollectionLabel_.label().data());
151 h_jet_et = ibooker.
book1D(
"jet_et", chtitle, 20, 0., 200.0);
153 snprintf(chtitle, title_s,
"Leading jet p_{T} (from %s);p_{T}(1^{st} jet) (GeV/c)",
154 thePFJetCollectionLabel_.label().data());
155 h_jet_pt = ibooker.
book1D(
"jet_pt", chtitle, 20, 0., 200.0);
157 snprintf(chtitle, title_s,
"Leading jet #eta (from %s); #eta (1^{st} jet)",
158 thePFJetCollectionLabel_.label().data());
159 h_jet_eta = ibooker.
book1D(
"jet_eta", chtitle, 20, -10., 10.0);
161 snprintf(chtitle, title_s,
"Leading jet #phi (from %s); #phi(1^{st} jet)",
162 thePFJetCollectionLabel_.label().data());
163 h_jet_phi = ibooker.
book1D(
"jet_phi", chtitle, 22, -1.1 * pi, 1.1 * pi);
165 snprintf(chtitle, title_s,
166 "2^{nd} leading jet E_{T} (from %s);E_{T}(2^{nd} jet) (GeV)",
167 thePFJetCollectionLabel_.label().data());
168 h_jet2_et = ibooker.
book1D(
"jet2_et", chtitle, 20, 0., 200.0);
170 snprintf(chtitle, title_s,
"2^{nd} leading jet #eta (from %s); #eta (2^{nd} jet)",
171 thePFJetCollectionLabel_.label().data());
172 h_jet2_eta = ibooker.
book1D(
"jet2_eta", chtitle, 20, -10., 10.0);
174 snprintf(chtitle, title_s,
"2^{nd} leading jet #phi (from %s); #phi(2^{nd} jet)",
175 thePFJetCollectionLabel_.label().data());
176 h_jet2_phi = ibooker.
book1D(
"jet2_phi", chtitle, 22, -1.1 * pi, 1.1 * pi);
178 h_e1_et = ibooker.
book1D(
"e1_et",
"E_{T} of Leading Electron;E_{T} (GeV)", 20,
180 h_e2_et = ibooker.
book1D(
"e2_et",
"E_{T} of Second Electron;E_{T} (GeV)", 20,
182 h_e1_eta = ibooker.
book1D(
"e1_eta",
"#eta of Leading Electron;#eta", 20, -4.0, 4.0);
184 h_e2_eta = ibooker.
book1D(
"e2_eta",
"#eta of Second Electron;#eta", 20, -4.0, 4.0);
186 h_e1_phi = ibooker.
book1D(
"e1_phi",
"#phi of Leading Electron;#phi", 22,
187 -1.1 * pi, 1.1 * pi);
188 h_e2_phi = ibooker.
book1D(
"e2_phi",
"#phi of Second Electron;#phi", 22,
189 -1.1 * pi, 1.1 * pi);
191 "m1_pt",
"p_{T} of Leading Muon;p_{T}(1^{st} #mu) (GeV)", 20, 0.0, 100.0);
193 "m2_pt",
"p_{T} of Second Muon;p_{T}(2^{nd} #mu) (GeV)", 20, 0.0, 100.0);
194 h_m1_eta = ibooker.
book1D(
"m1_eta",
"#eta of Leading Muon;#eta(1^{st} #mu)",
196 h_m2_eta = ibooker.
book1D(
"m2_eta",
"#eta of Second Muon;#eta(2^{nd} #mu)",
198 h_m1_phi = ibooker.
book1D(
"m1_phi",
"#phi of Leading Muon;#phi(1^{st} #mu)",
199 20, (-1. - 1. / 10.) * pi, (1. + 1. / 10.) * pi);
200 h_m2_phi = ibooker.
book1D(
"m2_phi",
"#phi of Second Muon;#phi(2^{nd} #mu)",
201 20, (-1. - 1. / 10.) * pi, (1. + 1. / 10.) * pi);
203 snprintf(chtitle, title_s,
"Missing E_{T} (%s); GeV",
204 theCaloMETCollectionLabel_.label().data());
205 h_met = ibooker.
book1D(
"met", chtitle, 20, 0.0, 100);
206 h_met_phi = ibooker.
book1D(
"met_phi",
"Missing E_{T} #phi;#phi(MET)", 22,
207 (-1. - 1. / 10.) * pi, (1. + 1. / 10.) * pi);
209 h_e_invWMass = ibooker.
book1D(
210 "we_invWMass",
"W-> e #nu Transverse Mass;M_{T} (GeV)", 20, 0.0, 140.0);
211 h_m_invWMass = ibooker.
book1D(
212 "wm_invWMass",
"W-> #mu #nu Transverse Mass;M_{T} (GeV)", 20, 0.0, 140.0);
213 h_mumu_invMass = ibooker.
book1D(
214 "z_mm_invMass",
"#mu#mu Invariant Mass;InvMass (GeV)", 20, 40.0, 140.0);
215 h_ee_invMass = ibooker.
book1D(
216 "z_ee_invMass",
"ee Invariant Mass;InvMass (Gev)", 20, 40.0, 140.0);
222 bool isConfigChanged =
false;
225 const std::string hltProcessName(theTriggerResultsCollection_.process());
226 isValidHltConfig_ = hltConfigProvider_.init(theRun, theSetup, hltProcessName,
232 if (!isValidHltConfig_)
return;
234 LogTrace(logTraceName) <<
"Analysis of event # ";
237 iEvent.
getByToken(theTriggerResultsToken_, HLTresults);
238 if (!HLTresults.
isValid())
return;
243 std::vector<std::string> eleTrigPathNames;
244 std::vector<std::string> muTrigPathNames;
250 bool passed_electron_HLT =
false;
251 bool passed_muon_HLT =
false;
252 for (
unsigned int i = 0;
i < HLTresults->
size();
i++) {
255 for (
unsigned int index = 0;
256 index < theElecTriggerPathToPass_.size() && !passed_electron_HLT;
259 size_t trigPath = trigName.find(theElecTriggerPathToPass_[
index]);
262 passed_electron_HLT = HLTresults->
accept(
i);
266 for (
unsigned int index = 0;
267 index < theMuonTriggerPathToPass_.size() && !passed_muon_HLT;
270 size_t trigPath = trigName.find(theMuonTriggerPathToPass_[
index]);
273 passed_muon_HLT = HLTresults->
accept(
i);
279 if (!(passed_electron_HLT || passed_muon_HLT))
return;
284 iEvent.
getByToken(theVertexToken_, vertexHandle);
285 if (!vertexHandle.
isValid())
return;
287 VertexCollection::const_iterator
v = vertexCollection.begin();
288 int vertex_number = vertexCollection.size();
289 double vertex_chi2 = v->normalizedChi2();
290 double vertex_d0 =
sqrt(v->x() * v->x() + v->y() * v->y());
291 double vertex_numTrks = v->tracksSize();
292 double vertex_sumTrks = 0.0;
296 vertex_curTrack != v->tracks_end(); vertex_curTrack++)
297 vertex_sumTrks += (*vertex_curTrack)->pt();
302 iEvent.
getByToken(theCaloMETCollectionToken_, caloMETCollection);
303 if (!caloMETCollection.
isValid())
return;
304 float missing_et = caloMETCollection->begin()->et();
305 float met_phi = caloMETCollection->begin()->phi();
310 iEvent.
getByToken(theElectronCollectionLabel_, electronCollection);
311 if (!electronCollection.
isValid())
return;
314 float electron_et = -8.0;
315 float electron_eta = -8.0;
316 float electron_phi = -8.0;
317 float electron2_et = -9.0;
318 float electron2_eta = -9.0;
319 float electron2_phi = -9.0;
320 float ee_invMass = -9.0;
321 TLorentzVector
e1,
e2;
325 if (passed_electron_HLT) {
326 for (reco::GsfElectronCollection::const_iterator recoElectron =
327 electronCollection->begin();
328 recoElectron != electronCollection->end(); recoElectron++) {
330 if (recoElectron->et() < 20 || fabs(recoElectron->eta()) > 2.5)
continue;
333 if (recoElectron->deltaPhiSuperClusterTrackAtVtx() > 0.58 ||
334 recoElectron->deltaEtaSuperClusterTrackAtVtx() > 0.01 ||
335 recoElectron->sigmaIetaIeta() > 0.027)
338 if (recoElectron->et() > electron_et) {
341 electron2_eta = electron_eta;
342 electron2_phi = electron_phi;
345 electron_eta = recoElectron->eta();
346 electron_phi = recoElectron->phi();
347 e1 = TLorentzVector(recoElectron->momentum().x(),
348 recoElectron->momentum().y(),
349 recoElectron->momentum().z(), recoElectron->p());
350 }
else if (recoElectron->et() > electron2_et) {
351 electron2_et = recoElectron->et();
352 electron2_eta = recoElectron->eta();
353 electron2_phi = recoElectron->phi();
354 e2 = TLorentzVector(recoElectron->momentum().x(),
355 recoElectron->momentum().y(),
356 recoElectron->momentum().z(), recoElectron->p());
359 if (electron2_et > 0.0) {
360 TLorentzVector pair = e1 +
e2;
361 ee_invMass = pair.M();
369 iEvent.
getByToken(theMuonCollectionLabel_, muonCollection);
370 if (!muonCollection.
isValid())
return;
373 float mm_invMass = -9.0;
374 float muon_pt = -9.0;
375 float muon_eta = -9.0;
376 float muon_phi = -9.0;
377 float muon2_pt = -9.0;
378 float muon2_eta = -9.0;
379 float muon2_phi = -9.0;
380 TLorentzVector m1, m2;
382 if (passed_muon_HLT) {
383 for (reco::MuonCollection::const_iterator
recoMuon =
384 muonCollection->begin();
389 if (
recoMuon->globalTrack()->normalizedChi2() > 10)
continue;
393 muon2_eta = muon_eta;
394 muon2_phi = muon_phi;
400 }
else if (
recoMuon->pt() > muon2_pt) {
409 if (muon2_pt > 0.0) {
410 TLorentzVector pair = m1 + m2;
411 mm_invMass = pair.M();
420 iEvent.
getByToken(thePFJetCollectionToken_, PFJetCollection);
421 if (!PFJetCollection.
isValid())
return;
423 unsigned int muonCollectionSize = muonCollection->size();
425 unsigned int PFJetCollectionSize = PFJetCollection->size();
429 float jet_et = -80.0;
430 float jet_pt = -80.0;
431 float jet_eta = -80.0;
432 float jet_phi = -80.0;
433 float jet2_et = -90.0;
434 float jet2_eta = -90.0;
435 float jet2_phi = -90.0;
447 for (
unsigned int i = 0;
i < PFJetCollectionSize;
i++) {
448 const Jet&
jet = PFJetCollection->at(
i);
450 double minDistance = 99999;
451 for (
unsigned int j = 0; j < muonCollectionSize; j++) {
452 const Muon&
mu = muonCollection->at(j);
455 if (minDistance > distance) minDistance =
distance;
457 if (minDistance < 0.3)
463 if (electron_et > 0.0 && fabs(jet.
eta() - electron_eta) < 0.2 &&
466 if (electron2_et > 0.0 && fabs(jet.
eta() - electron2_eta) < 0.2 &&
477 if (jet.
et() < eJetMin_)
continue;
491 if (jet.
et() > jet_et) {
503 }
else if (jet.
et() > jet2_et) {
508 jet2_eta = jet.
eta();
509 jet2_phi = jet.
phi();
519 bool fill_e1 =
false;
520 bool fill_e2 =
false;
521 bool fill_m1 =
false;
522 bool fill_m2 =
false;
523 bool fill_met =
false;
526 if (ee_invMass > 0.0) {
527 h_ee_invMass->Fill(ee_invMass);
533 if (mm_invMass > 0.0) {
534 h_mumu_invMass->Fill(mm_invMass);
537 h_jet2_et->Fill(jet2_et);
541 if (electron_et > 0.0 && missing_et > 20.0) {
542 float dphiW = fabs(met_phi - electron_phi);
543 float W_mt_e =
sqrt(2 * missing_et * electron_et * (1 -
cos(dphiW)));
544 h_e_invWMass->Fill(W_mt_e);
550 if (muon_pt > 0.0 && missing_et > 20.0) {
551 float dphiW = fabs(met_phi - muon_phi);
552 float W_mt_m =
sqrt(2 * missing_et * muon_pt * (1 -
cos(dphiW)));
553 h_m_invWMass->Fill(W_mt_m);
558 if (jet_et > -10.0) {
559 h_jet_et->Fill(jet_et);
560 h_jet_count->Fill(jet_count);
564 h_jet_pt->Fill(jet_pt);
567 if (jet_eta > -50.) {
568 h_jet_eta->Fill(jet_eta);
571 if (jet_phi > -10.) {
572 h_jet_phi->Fill(jet_phi);
575 if (jet2_et > -10.0) {
576 h_jet2_et->Fill(jet2_et);
583 if (jet2_eta > -50.) {
584 h_jet2_eta->Fill(jet2_eta);
587 if (jet2_phi > -10.) {
588 h_jet2_phi->Fill(jet2_phi);
591 if (fill_e1 || fill_m1) {
592 h_vertex_number->Fill(vertex_number);
593 h_vertex_chi2->Fill(vertex_chi2);
594 h_vertex_d0->Fill(vertex_d0);
595 h_vertex_numTrks->Fill(vertex_numTrks);
596 h_vertex_sumTrks->Fill(vertex_sumTrks);
600 h_e1_et->Fill(electron_et);
601 h_e1_eta->Fill(electron_eta);
602 h_e1_phi->Fill(electron_phi);
605 h_e2_et->Fill(electron2_et);
606 h_e2_eta->Fill(electron2_eta);
607 h_e2_phi->Fill(electron2_phi);
610 h_m1_pt->Fill(muon_pt);
611 h_m1_eta->Fill(muon_eta);
612 h_m1_phi->Fill(muon_phi);
615 h_m2_pt->Fill(muon2_pt);
616 h_m2_eta->Fill(muon2_eta);
617 h_m2_phi->Fill(muon2_phi);
620 h_met->Fill(missing_et);
621 h_met_phi->Fill(met_phi);
630 if (deltaPhi < 0) deltaPhi = -
deltaPhi;
632 if (deltaPhi > 3.1415926) deltaPhi = 2 * 3.1415926 -
deltaPhi;
T getParameter(std::string const &) const
virtual double pt() const final
transverse momentum
double calcDeltaPhi(double phi1, double phi2)
void analyze(const edm::Event &, const edm::EventSetup &) override
Get the analysis.
T getUntrackedParameter(std::string const &, T const &) const
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
EwkDQM(const edm::ParameterSet &)
Constructor.
virtual double eta() const final
momentum pseudorapidity
bool getByToken(EDGetToken token, Handle< PROD > &result) const
bool accept() const
Has at least one path accepted the event?
std::vector< Vertex > VertexCollection
collection of Vertex objects
virtual double phi() const final
momentum azimuthal angle
virtual double et() const final
transverse energy
unsigned int size() const
Get number of paths stored.
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Cos< T >::type cos(const T &t)
MonitorElement * book1D(Args &&...args)
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
static const char *const trigNames[]
void setCurrentFolder(const std::string &fullpath)
T const * product() const
std::string const & triggerName(unsigned int index) const
virtual ~EwkDQM()
Destructor.
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)