CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EwkTauDQM.cc
Go to the documentation of this file.
2 
4 
7 
9 
11  //--- concatenate names of dqmRootDirectory and dqmSubDirectory;
12  // add "/" separator inbetween if necessary
14  if (!dirName.empty() && dirName.find_last_of(dqmSeparator) != (dirName.length() - 1))
15  dirName.append(dqmSeparator);
16  dirName.append(dqmSubDirectory);
17  return dirName;
18 }
19 
20 EwkTauDQM::EwkTauDQM(const edm::ParameterSet& cfg) : dqmDirectory_(cfg.getParameter<std::string>("dqmDirectory")) {
21  maxNumWarnings_ = cfg.exists("maxNumWarnings") ? cfg.getParameter<int>("maxNumWarnings") : 1;
22 
23  edm::ParameterSet cfgChannels = cfg.getParameter<edm::ParameterSet>("channels");
24 
25  edm::ParameterSet cfgElecTauChannel = cfgChannels.getParameter<edm::ParameterSet>("elecTauChannel");
26  std::string dqmSubDirectoryElecTauChannel = cfgElecTauChannel.getParameter<std::string>("dqmSubDirectory");
27  cfgElecTauChannel.addParameter<std::string>("dqmDirectory",
28  dqmDirectoryName(dqmDirectory_, dqmSubDirectoryElecTauChannel));
29  cfgElecTauChannel.addParameter<int>("maxNumWarnings", maxNumWarnings_);
30  elecTauHistManager_ = new EwkElecTauHistManager(cfgElecTauChannel);
31 
32  edm::ParameterSet cfgMuTauChannel = cfgChannels.getParameter<edm::ParameterSet>("muTauChannel");
33  std::string dqmSubDirectoryMuTauChannel = cfgMuTauChannel.getParameter<std::string>("dqmSubDirectory");
34  cfgMuTauChannel.addParameter<std::string>("dqmDirectory",
35  dqmDirectoryName(dqmDirectory_, dqmSubDirectoryMuTauChannel));
36  cfgMuTauChannel.addParameter<int>("maxNumWarnings", maxNumWarnings_);
37  muTauHistManager_ = new EwkMuTauHistManager(cfgMuTauChannel);
38 }
39 
41  delete elecTauHistManager_;
42  delete muTauHistManager_;
43 }
44 
48 }
49 
50 void EwkTauDQM::analyze(const edm::Event& evt, const edm::EventSetup& es) {
53 }
54 
58 }
59 
60 //-------------------------------------------------------------------------------
61 // code specific to Z --> e + tau-jet channel
62 //-------------------------------------------------------------------------------
63 
65 
67 
85 
86 #include "TMath.h"
87 
88 #include <iostream>
89 #include <iomanip>
90 
92  : dqmDirectory_(cfg.getParameter<std::string>("dqmDirectory")),
93  numEventsAnalyzed_(0),
94  numEventsSelected_(0),
95  cfgError_(0),
96  numWarningsTriggerResults_(0),
97  numWarningsHLTpath_(0),
98  numWarningsVertex_(0),
99  numWarningsBeamSpot_(0),
100  numWarningsElectron_(0),
101  numWarningsTauJet_(0),
102  numWarningsTauDiscrByLeadTrackFinding_(0),
103  numWarningsTauDiscrByLeadTrackPtCut_(0),
104  numWarningsTauDiscrByTrackIso_(0),
105  numWarningsTauDiscrByEcalIso_(0),
106  numWarningsTauDiscrAgainstElectrons_(0),
107  numWarningsTauDiscrAgainstMuons_(0),
108  numWarningsCaloMEt_(0),
109  numWarningsPFMEt_(0) {
110  triggerResultsSource_ = cfg.getParameter<edm::InputTag>("triggerResultsSource");
111  vertexSource_ = cfg.getParameter<edm::InputTag>("vertexSource");
112  beamSpotSource_ = cfg.getParameter<edm::InputTag>("beamSpotSource");
113  electronSource_ = cfg.getParameter<edm::InputTag>("electronSource");
114  tauJetSource_ = cfg.getParameter<edm::InputTag>("tauJetSource");
115  caloMEtSource_ = cfg.getParameter<edm::InputTag>("caloMEtSource");
116  pfMEtSource_ = cfg.getParameter<edm::InputTag>("pfMEtSource");
117 
118  tauDiscrByLeadTrackFinding_ = cfg.getParameter<edm::InputTag>("tauDiscrByLeadTrackFinding");
119  tauDiscrByLeadTrackPtCut_ = cfg.getParameter<edm::InputTag>("tauDiscrByLeadTrackPtCut");
120  tauDiscrByTrackIso_ = cfg.getParameter<edm::InputTag>("tauDiscrByTrackIso");
121  tauDiscrByEcalIso_ = cfg.getParameter<edm::InputTag>("tauDiscrByEcalIso");
122  tauDiscrAgainstElectrons_ = cfg.getParameter<edm::InputTag>("tauDiscrAgainstElectrons");
123  tauDiscrAgainstMuons_ = cfg.getParameter<edm::InputTag>("tauDiscrAgainstMuons");
124 
125  hltPaths_ = cfg.getParameter<vstring>("hltPaths");
126 
127  electronEtaCut_ = cfg.getParameter<double>("electronEtaCut");
128  electronPtCut_ = cfg.getParameter<double>("electronPtCut");
129  electronTrackIsoCut_ = cfg.getParameter<double>("electronTrackIsoCut");
130  electronEcalIsoCut_ = cfg.getParameter<double>("electronEcalIsoCut");
131  std::string electronIsoMode_string = cfg.getParameter<std::string>("electronIsoMode");
132  electronIsoMode_ = getIsoMode(electronIsoMode_string, cfgError_);
133 
134  tauJetEtaCut_ = cfg.getParameter<double>("tauJetEtaCut");
135  tauJetPtCut_ = cfg.getParameter<double>("tauJetPtCut");
136 
137  visMassCut_ = cfg.getParameter<double>("visMassCut");
138 
139  maxNumWarnings_ = cfg.exists("maxNumWarnings") ? cfg.getParameter<int>("maxNumWarnings") : 1;
140 }
141 
144  hElectronPt_ = iBooker.book1D("ElectronPt", "P_{T}^{e}", 20, 0., 100.);
145  hElectronEta_ = iBooker.book1D("ElectronEta", "#eta_{e}", 20, -4.0, +4.0);
146  hElectronPhi_ = iBooker.book1D("ElectronPhi", "#phi_{e}", 20, -TMath::Pi(), +TMath::Pi());
147  hElectronTrackIsoPt_ = iBooker.book1D("ElectronTrackIsoPt", "Electron Track Iso.", 20, -0.01, 0.5);
148  hElectronEcalIsoPt_ = iBooker.book1D("ElectronEcalIsoPt", "Electron Ecal Iso.", 20, -0.01, 0.5);
149  hTauJetPt_ = iBooker.book1D("TauJetPt", "P_{T}^{#tau-Jet}", 20, 0., 100.);
150  hTauJetEta_ = iBooker.book1D("TauJetEta", "#eta_{#tau-Jet}", 20, -4.0, +4.0);
151  hVisMass_ = iBooker.book1D("VisMass", "e + #tau-Jet visible Mass", 20, 20., 120.);
152  hMtElecPFMEt_ = iBooker.book1D("MtElecPFMEt", "e + E_{T}^{miss} (PF) transverse Mass", 20, 20., 120.);
154  iBooker.book1D("ElecTauAcoplanarity", "#Delta #phi_{e #tau-Jet}", 20, -TMath::Pi(), +TMath::Pi());
155  hElecTauCharge_ = iBooker.book1D("ElecTauCharge", "Q_{e * #tau-Jet}", 5, -2.5, +2.5);
156  hVertexZ_ = iBooker.book1D("VertexZ", "Event Vertex z-Position", 20, -25., +25.);
157  hCaloMEtPt_ = iBooker.book1D("CaloMEtPt", "E_{T}^{miss} (Calo)", 20, 0., 100.);
158  hPFMEtPt_ = iBooker.book1D("PFMEtPt", "E_{T}^{miss} (PF)", 20, 0., 100.);
159  hCutFlowSummary_ = iBooker.book1D("CutFlowSummary", "Cut-flow Summary", 11, 0.5, 11.5);
165  hCutFlowSummary_->setBinLabel(kPassedTauLeadTrack, "#tau lead. Track");
166  hCutFlowSummary_->setBinLabel(kPassedTauLeadTrackPt, "#tau lead. Track P_{T}");
168  hCutFlowSummary_->setBinLabel(kPassedTauDiscrAgainstMuons, "#tau anti-#mu Discr.");
169  hCutFlowSummary_->setBinLabel(kPassedTauTrackIso, "#tau Track Iso.");
170  hCutFlowSummary_->setBinLabel(kPassedTauEcalIso, "#tau Ecal Iso.");
171 }
172 
174  if (cfgError_)
175  return;
176 
177  //-----------------------------------------------------------------------------
178  // access event-level information
179  //-----------------------------------------------------------------------------
180 
181  bool readError = false;
182 
183  //--- get decision of high-level trigger for the event
185  readEventData(evt,
187  hltDecision,
190  readError,
191  "Failed to access Trigger results");
192  if (readError)
193  return;
194 
195  const edm::TriggerNames& triggerNames = evt.triggerNames(*hltDecision);
196 
197  bool isTriggered = false;
198  for (vstring::const_iterator hltPath = hltPaths_.begin(); hltPath != hltPaths_.end(); ++hltPath) {
199  unsigned int index = triggerNames.triggerIndex(*hltPath);
200  if (index < triggerNames.size()) {
201  if (hltDecision->accept(index))
202  isTriggered = true;
203  } else {
205  edm::LogWarning("EwkElecTauHistManager") << " Undefined HLT path = " << (*hltPath) << " !!";
207  continue;
208  }
209  }
210 
211  //--- get reconstructed primary event vertex of the event
212  // (take as "the" primary event vertex the first entry in the collection
213  // of vertex objects, corresponding to the vertex associated to the highest
214  // Pt sum of tracks)
216  readEventData(evt,
218  vertexCollection,
221  readError,
222  "Failed to access Vertex collection");
223  if (readError)
224  return;
225 
226  const reco::Vertex* theEventVertex = (!vertexCollection->empty()) ? &(vertexCollection->at(0)) : nullptr;
227 
228  //--- get beam-spot (expected vertex position) for the event
231  evt, beamSpotSource_, beamSpot, numWarningsBeamSpot_, maxNumWarnings_, readError, "Failed to access Beam-spot");
232  if (readError)
233  return;
234 
235  //--- get collections of reconstructed electrons from the event
237  readEventData(evt,
239  electrons,
242  readError,
243  "Failed to access Electron collection");
244  if (readError)
245  return;
246 
247  const reco::GsfElectron* theElectron = getTheElectron(*electrons, electronEtaCut_, electronPtCut_);
248 
249  double theElectronTrackIsoPt = 1.e+3;
250  double theElectronEcalIsoPt = 1.e+3;
251  double theElectronHcalIsoPt = 1.e+3;
252  if (theElectron) {
253  theElectronTrackIsoPt = theElectron->dr03TkSumPt();
254  theElectronEcalIsoPt = theElectron->dr03EcalRecHitSumEt();
255  theElectronHcalIsoPt = theElectron->dr03HcalTowerSumEt();
256 
257  if (electronIsoMode_ == kRelativeIso && theElectron->pt() > 0.) {
258  theElectronTrackIsoPt /= theElectron->pt();
259  theElectronEcalIsoPt /= theElectron->pt();
260  theElectronHcalIsoPt /= theElectron->pt();
261  }
262  }
263 
264  //--- get collections of reconstructed tau-jets from the event
266  readEventData(evt,
268  tauJets,
271  readError,
272  "Failed to access Tau-jet collection");
273  if (readError)
274  return;
275 
276  //--- get collections of tau-jet discriminators for those tau-jets
277  edm::Handle<reco::PFTauDiscriminator> tauDiscrByLeadTrackFinding;
278  readEventData(evt,
280  tauDiscrByLeadTrackFinding,
283  readError,
284  "Failed to access collection of pf. Tau discriminators by "
285  "leading Track finding");
286  edm::Handle<reco::PFTauDiscriminator> tauDiscrByLeadTrackPtCut;
287  readEventData(evt,
289  tauDiscrByLeadTrackPtCut,
292  readError,
293  "Failed to access collection of pf. Tau discriminators by "
294  "leading Track Pt cut");
295  edm::Handle<reco::PFTauDiscriminator> tauDiscrByTrackIso;
296  readEventData(evt,
298  tauDiscrByTrackIso,
301  readError,
302  "Failed to access collection of pf. Tau discriminators by "
303  "Track isolation");
304  edm::Handle<reco::PFTauDiscriminator> tauDiscrByEcalIso;
305  readEventData(evt,
307  tauDiscrByEcalIso,
310  readError,
311  "Failed to access collection of pf. Tau discriminators by ECAL "
312  "isolation");
313  edm::Handle<reco::PFTauDiscriminator> tauDiscrAgainstElectrons;
314  readEventData(evt,
316  tauDiscrAgainstElectrons,
319  readError,
320  "Failed to access collection of pf. Tau discriminators against "
321  "Electrons");
322  edm::Handle<reco::PFTauDiscriminator> tauDiscrAgainstMuons;
323  readEventData(evt,
325  tauDiscrAgainstMuons,
328  readError,
329  "Failed to access collection of pf. Tau discriminators against Muons");
330  if (readError)
331  return;
332 
333  int theTauJetIndex = -1;
334  const reco::PFTau* theTauJet = getTheTauJet(*tauJets, tauJetEtaCut_, tauJetPtCut_, theTauJetIndex);
335 
336  double theTauDiscrByLeadTrackFinding = -1.;
337  double theTauDiscrByLeadTrackPtCut = -1.;
338  double theTauDiscrByTrackIso = -1.;
339  double theTauDiscrByEcalIso = -1.;
340  double theTauDiscrAgainstElectrons = -1.;
341  double theTauDiscrAgainstMuons = -1.;
342  if (theTauJetIndex != -1) {
343  reco::PFTauRef theTauJetRef(tauJets, theTauJetIndex);
344  theTauDiscrByLeadTrackFinding = (*tauDiscrByLeadTrackFinding)[theTauJetRef];
345  theTauDiscrByLeadTrackPtCut = (*tauDiscrByLeadTrackPtCut)[theTauJetRef];
346  theTauDiscrByTrackIso = (*tauDiscrByTrackIso)[theTauJetRef];
347  theTauDiscrByEcalIso = (*tauDiscrByEcalIso)[theTauJetRef];
348  theTauDiscrAgainstElectrons = (*tauDiscrAgainstElectrons)[theTauJetRef];
349  theTauDiscrAgainstMuons = (*tauDiscrAgainstMuons)[theTauJetRef];
350  }
351 
352  //--- get missing transverse momentum
353  // measured by calorimeters/reconstructed by particle-flow algorithm
354  edm::Handle<reco::CaloMETCollection> caloMEtCollection;
355  readEventData(evt,
357  caloMEtCollection,
360  readError,
361  "Failed to access calo. MET collection");
362  if (readError)
363  return;
364 
365  const reco::CaloMET& caloMEt = caloMEtCollection->at(0);
366 
367  edm::Handle<reco::PFMETCollection> pfMEtCollection;
368  readEventData(evt,
369  pfMEtSource_,
370  pfMEtCollection,
373  readError,
374  "Failed to access pf. MET collection");
375  if (readError)
376  return;
377 
378  const reco::PFMET& pfMEt = pfMEtCollection->at(0);
379 
380  if (!(theElectron && theTauJet && theTauJetIndex != -1))
381  return;
382 
383  //-----------------------------------------------------------------------------
384  // compute EWK tau analysis specific quantities
385  //-----------------------------------------------------------------------------
386 
387  double dPhiElecTau = calcDeltaPhi(theElectron->phi(), theTauJet->phi());
388 
389  double mElecTau = (theElectron->p4() + theTauJet->p4()).M();
390 
391  // double mtElecCaloMEt = calcMt(theElectron->px(), theElectron->py(),
392  // caloMEt.px(), caloMEt.py());
393  double mtElecPFMEt = calcMt(theElectron->px(), theElectron->py(), pfMEt.px(), pfMEt.py());
394 
395  // double pZetaCaloMEt = calcPzeta(theElectron->p4(), theTauJet->p4(),
396  // caloMEt.px(), caloMEt.py());
397  // double pZetaPFMEt = calcPzeta(theElectron->p4(), theTauJet->p4(),
398  // pfMEt.px(), pfMEt.py());
399 
400  //-----------------------------------------------------------------------------
401  // apply selection criteria; fill histograms
402  //-----------------------------------------------------------------------------
403 
404  //--- fill electron multiplicity histogram
405  unsigned numIdElectrons = 0;
406  for (reco::GsfElectronCollection::const_iterator electron = electrons->begin(); electron != electrons->end();
407  ++electron) {
408  if (passesElectronId(*electron)) {
409  ++numIdElectrons;
410  }
411  }
412 
413  // hNumIdElectrons_->Fill(numIdElectrons);
414 
416 
417  bool isSelected = false;
418  bool fullSelect = false;
419  int cutFlowStatus = -1;
420 
421  if (mElecTau > visMassCut_) {
422  cutFlowStatus = kPassedPreselection;
423  }
424  if (cutFlowStatus == kPassedPreselection && (isTriggered || hltPaths_.empty())) {
425  cutFlowStatus = kPassedTrigger;
426  }
427  if (cutFlowStatus == kPassedTrigger && passesElectronId(*theElectron)) {
428  cutFlowStatus = kPassedElectronId;
429  hElectronTrackIsoPt_->Fill(theElectronTrackIsoPt);
430  }
431  if (cutFlowStatus == kPassedElectronId && theElectronTrackIsoPt < electronTrackIsoCut_) {
432  cutFlowStatus = kPassedElectronTrackIso;
433  hElectronEcalIsoPt_->Fill(theElectronEcalIsoPt);
434  }
435  if (cutFlowStatus == kPassedElectronTrackIso && theElectronEcalIsoPt < electronEcalIsoCut_) {
436  cutFlowStatus = kPassedElectronEcalIso;
437  }
438  if (cutFlowStatus == kPassedElectronEcalIso && theTauDiscrByLeadTrackFinding > 0.5) {
439  cutFlowStatus = kPassedTauLeadTrack;
440  // if ( theTauJet->leadTrack().isAvailable() )
441  // hTauLeadTrackPt_->Fill(theTauJet->leadTrack()->pt());
442  }
443  if (cutFlowStatus == kPassedTauLeadTrack && theTauDiscrByLeadTrackPtCut > 0.5) {
444  cutFlowStatus = kPassedTauLeadTrackPt;
445  // hTauTrackIsoPt_->Fill(theTauJet->isolationPFChargedHadrCandsPtSum());
446  }
447  if (cutFlowStatus == kPassedTauLeadTrackPt && theTauDiscrAgainstElectrons > 0.5) {
448  cutFlowStatus = kPassedTauDiscrAgainstElectrons;
449  // hTauDiscrAgainstMuons_->Fill(theTauDiscrAgainstMuons);
450  }
451  if (cutFlowStatus == kPassedTauDiscrAgainstElectrons && theTauDiscrAgainstMuons > 0.5) {
452  cutFlowStatus = kPassedTauDiscrAgainstMuons;
453  isSelected = true;
454  }
455  if (cutFlowStatus == kPassedTauDiscrAgainstMuons && theTauDiscrByTrackIso > 0.5) {
456  cutFlowStatus = kPassedTauTrackIso;
457  // hTauEcalIsoPt_->Fill(theTauJet->isolationPFGammaCandsEtSum());
458  }
459  if (cutFlowStatus == kPassedTauTrackIso && theTauDiscrByEcalIso > 0.5) {
460  cutFlowStatus = kPassedTauEcalIso;
461  fullSelect = true;
462  // hTauDiscrAgainstElectrons_->Fill(theTauDiscrAgainstElectrons);
463  }
464 
465  for (int iCut = 1; iCut <= cutFlowStatus; ++iCut) {
466  hCutFlowSummary_->Fill(iCut);
467  }
468 
469  if (isSelected) {
470  hElectronPt_->Fill(theElectron->pt());
471  hElectronEta_->Fill(theElectron->eta());
472  hElectronPhi_->Fill(theElectron->phi());
473 
474  hTauJetPt_->Fill(theTauJet->pt());
475  hTauJetEta_->Fill(theTauJet->eta());
476  // hTauJetPhi_->Fill(theTauJet->phi());
477 
478  // hTauJetCharge_->Fill(theTauJet->charge());
479  // if ( theTauJet->signalTracks().isAvailable() )
480  // hTauJetNumSignalTracks_->Fill(theTauJet->signalTracks().size());
481  // if ( theTauJet->isolationTracks().isAvailable() )
482  // hTauJetNumIsoTracks_->Fill(theTauJet->isolationTracks().size());
483 
484  if (fullSelect) {
485  hVisMass_->Fill(mElecTau);
486  }
487  // hMtElecCaloMEt_->Fill(mtElecCaloMEt);
488  hMtElecPFMEt_->Fill(mtElecPFMEt);
489  // hPzetaCaloMEt_->Fill(pZetaCaloMEt);
490  // hPzetaPFMEt_->Fill(pZetaPFMEt);
491  hElecTauAcoplanarity_->Fill(dPhiElecTau);
492  hElecTauCharge_->Fill(theElectron->charge() * theTauJet->charge());
493 
494  if (theEventVertex) {
495  // hVertexChi2_->Fill(theEventVertex->normalizedChi2());
496  hVertexZ_->Fill(theEventVertex->z());
497  // hVertexD0_->Fill(getVertexD0(*theEventVertex, *beamSpot));
498  }
499 
500  hCaloMEtPt_->Fill(caloMEt.pt());
501  // hCaloMEtPhi_->Fill(caloMEt.phi());
502 
503  hPFMEtPt_->Fill(pfMEt.pt());
504  // hPFMEtPhi_->Fill(pfMEt.phi());
505  }
506 
507  if (isSelected)
509 }
510 
512  edm::LogInfo("EwkElecTauHistManager") << "Filter-Statistics Summary:" << std::endl
513  << " Events analyzed = " << numEventsAnalyzed_ << std::endl
514  << " Events selected = " << numEventsSelected_;
515  if (numEventsAnalyzed_ > 0) {
516  double eff = numEventsSelected_ / (double)numEventsAnalyzed_;
517  edm::LogInfo("") << "Overall efficiency = " << std::setprecision(4) << eff * 100. << " +/- " << std::setprecision(4)
518  << TMath::Sqrt(eff * (1 - eff) / numEventsAnalyzed_) * 100. << ")%";
519  }
520 }
521 
522 //-------------------------------------------------------------------------------
523 // code specific to Z --> mu + tau-jet channel
524 //-------------------------------------------------------------------------------
525 
527 
529 
547 
548 #include "TMath.h"
549 
550 #include <iostream>
551 #include <iomanip>
552 
554  : dqmDirectory_(cfg.getParameter<std::string>("dqmDirectory")),
555  numEventsAnalyzed_(0),
556  numEventsSelected_(0),
557  cfgError_(0),
558  numWarningsTriggerResults_(0),
559  numWarningsHLTpath_(0),
560  numWarningsVertex_(0),
561  numWarningsBeamSpot_(0),
562  numWarningsMuon_(0),
563  numWarningsTauJet_(0),
564  numWarningsTauDiscrByLeadTrackFinding_(0),
565  numWarningsTauDiscrByLeadTrackPtCut_(0),
566  numWarningsTauDiscrByTrackIso_(0),
567  numWarningsTauDiscrByEcalIso_(0),
568  numWarningsTauDiscrAgainstMuons_(0),
569  numWarningsCaloMEt_(0),
570  numWarningsPFMEt_(0) {
571  triggerResultsSource_ = cfg.getParameter<edm::InputTag>("triggerResultsSource");
572  vertexSource_ = cfg.getParameter<edm::InputTag>("vertexSource");
573  beamSpotSource_ = cfg.getParameter<edm::InputTag>("beamSpotSource");
574  muonSource_ = cfg.getParameter<edm::InputTag>("muonSource");
575  tauJetSource_ = cfg.getParameter<edm::InputTag>("tauJetSource");
576  caloMEtSource_ = cfg.getParameter<edm::InputTag>("caloMEtSource");
577  pfMEtSource_ = cfg.getParameter<edm::InputTag>("pfMEtSource");
578 
579  tauDiscrByLeadTrackFinding_ = cfg.getParameter<edm::InputTag>("tauDiscrByLeadTrackFinding");
580  tauDiscrByLeadTrackPtCut_ = cfg.getParameter<edm::InputTag>("tauDiscrByLeadTrackPtCut");
581  tauDiscrByTrackIso_ = cfg.getParameter<edm::InputTag>("tauDiscrByTrackIso");
582  tauDiscrByEcalIso_ = cfg.getParameter<edm::InputTag>("tauDiscrByEcalIso");
583  tauDiscrAgainstMuons_ = cfg.getParameter<edm::InputTag>("tauDiscrAgainstMuons");
584 
585  hltPaths_ = cfg.getParameter<vstring>("hltPaths");
586 
587  muonEtaCut_ = cfg.getParameter<double>("muonEtaCut");
588  muonPtCut_ = cfg.getParameter<double>("muonPtCut");
589  muonTrackIsoCut_ = cfg.getParameter<double>("muonTrackIsoCut");
590  muonEcalIsoCut_ = cfg.getParameter<double>("muonEcalIsoCut");
591  muonCombIsoCut_ = cfg.getParameter<double>("muonCombIsoCut");
592  std::string muonIsoMode_string = cfg.getParameter<std::string>("muonIsoMode");
593  muonIsoMode_ = getIsoMode(muonIsoMode_string, cfgError_);
594 
595  tauJetEtaCut_ = cfg.getParameter<double>("tauJetEtaCut");
596  tauJetPtCut_ = cfg.getParameter<double>("tauJetPtCut");
597 
598  visMassCut_ = cfg.getParameter<double>("visMassCut");
599  deltaRCut_ = cfg.getParameter<double>("deltaRCut");
600 
601  maxNumWarnings_ = cfg.exists("maxNumWarnings") ? cfg.getParameter<int>("maxNumWarnings") : 1;
602 }
603 
606 
607  hMuonPt_ = iBooker.book1D("MuonPt", "P_{T}^{#mu}", 20, 0., 100.);
608  hMuonEta_ = iBooker.book1D("MuonEta", "#eta_{#mu}", 20, -4.0, +4.0);
609  hMuonPhi_ = iBooker.book1D("MuonPhi", "#phi_{#mu}", 20, -TMath::Pi(), +TMath::Pi());
610  hMuonTrackIsoPt_ = iBooker.book1D("MuonTrackIsoPt", "Muon Track Iso.", 20, -0.01, 10.);
611  hMuonEcalIsoPt_ = iBooker.book1D("MuonEcalIsoPt", "Muon Ecal Iso.", 20, -0.01, 10.);
612  hMuonCombIsoPt_ = iBooker.book1D("MuonCombIsoPt", "Muon Comb Iso.", 20, -0.01, 1.);
613 
614  hTauJetPt_ = iBooker.book1D("TauJetPt", "P_{T}^{#tau-Jet}", 20, 0., 100.);
615  hTauJetEta_ = iBooker.book1D("TauJetEta", "#eta_{#tau-Jet}", 20, -4.0, +4.0);
616  hTauJetPhi_ = iBooker.book1D("TauJetPhi", "#phi_{#tau-Jet}", 20, -TMath::Pi(), +TMath::Pi());
617  hTauLeadTrackPt_ = iBooker.book1D("TauLeadTrackPt", "P_{T}^{#tau-Jetldg trk}", 20, 0., 50.);
618  hTauTrackIsoPt_ = iBooker.book1D("TauTrackIsoPt", "Tau Track Iso.", 20, -0.01, 40.);
619  hTauEcalIsoPt_ = iBooker.book1D("TauEcalIsoPt", "Tau Ecal Iso.", 10, -0.01, 10.);
620  hTauDiscrAgainstMuons_ = iBooker.book1D("TauDiscrAgainstMuons", "Tau Discr. against Muons", 2, -0.5, +1.5);
621  hTauJetNumSignalTracks_ = iBooker.book1D("TauJetNumSignalTracks", "Num. Tau signal Cone Tracks", 20, -0.5, +19.5);
622  hTauJetNumIsoTracks_ = iBooker.book1D("TauJetNumIsoTracks", "Num. Tau isolation Cone Tracks", 20, -0.5, +19.5);
623 
624  hVisMass_ = iBooker.book1D("VisMass", "#mu + #tau-Jet visible Mass", 20, 0., 120.);
625  hVisMassFinal_ = iBooker.book1D("VisMassFinal", "#mu + #tau-Jet visible final Mass", 20, 0., 120.);
626  hMtMuPFMEt_ = iBooker.book1D("MtMuPFMEt", "#mu + E_{T}^{miss} (PF) transverse Mass", 20, 0., 120.);
628  iBooker.book1D("MuTauAcoplanarity", "#Delta #phi_{#mu #tau-Jet}", 20, -TMath::Pi(), +TMath::Pi());
629  hMuTauDeltaR_ = iBooker.book1D("MuTauDeltaR", "#Delta R_{#mu #tau-Jet}", 20, 0, 5);
630  hVertexZ_ = iBooker.book1D("VertexZ", "Event Vertex z-Position", 20, -25., +25.);
631  hCaloMEtPt_ = iBooker.book1D("CaloMEtPt", "E_{T}^{miss} (Calo)", 20, 0., 100.);
632  hPFMEtPt_ = iBooker.book1D("PFMEtPt", "E_{T}^{miss} (PF)", 20, 0., 100.);
633  hCutFlowSummary_ = iBooker.book1D("CutFlowSummary", "Cut-flow Summary", 11, 0.5, 11.5);
639  hCutFlowSummary_->setBinLabel(kPassedTauLeadTrack, "#tau lead. Track");
640  hCutFlowSummary_->setBinLabel(kPassedTauLeadTrackPt, "#tau lead. Track P_{T}");
641  hCutFlowSummary_->setBinLabel(kPassedTauTrackIso, "#tau Track Iso.");
642  hCutFlowSummary_->setBinLabel(kPassedTauEcalIso, "#tau Ecal Iso.");
643  hCutFlowSummary_->setBinLabel(kPassedTauDiscrAgainstMuons, "#tau anti-#mu Discr.");
644  hCutFlowSummary_->setBinLabel(kPassedDeltaR, "#DeltaR(#mu,#tau) ");
645 }
646 
648  if (cfgError_)
649  return;
650 
651  //-----------------------------------------------------------------------------
652  // access event-level information
653  //-----------------------------------------------------------------------------
654 
655  bool readError = false;
656 
657  //--- get decision of high-level trigger for the event
659  readEventData(evt,
661  hltDecision,
664  readError,
665  "Failed to access Trigger results");
666  if (readError)
667  return;
668 
669  const edm::TriggerNames& triggerNames = evt.triggerNames(*hltDecision);
670 
671  bool isTriggered = false;
672  for (vstring::const_iterator hltPath = hltPaths_.begin(); hltPath != hltPaths_.end(); ++hltPath) {
673  unsigned int index = triggerNames.triggerIndex(*hltPath);
674  if (index < triggerNames.size()) {
675  if (hltDecision->accept(index))
676  isTriggered = true;
677  } else {
679  edm::LogWarning("EwkMuTauHistManager") << " Undefined HLT path = " << (*hltPath) << " !!";
681  continue;
682  }
683  }
684 
685  //--- get reconstructed primary event vertex of the event
686  // (take as "the" primary event vertex the first entry in the collection
687  // of vertex objects, corresponding to the vertex associated to the highest
688  // Pt sum of tracks)
690  readEventData(evt,
692  vertexCollection,
695  readError,
696  "Failed to access Vertex collection");
697  if (readError)
698  return;
699 
700  const reco::Vertex* theEventVertex = (!vertexCollection->empty()) ? &(vertexCollection->at(0)) : nullptr;
701 
702  //--- get beam-spot (expected vertex position) for the event
705  evt, beamSpotSource_, beamSpot, numWarningsBeamSpot_, maxNumWarnings_, readError, "Failed to access Beam-spot");
706  if (readError)
707  return;
708 
709  //--- get collections of reconstructed muons from the event
712  evt, muonSource_, muons, numWarningsMuon_, maxNumWarnings_, readError, "Failed to access Muon collection");
713  if (readError)
714  return;
715 
716  const reco::Muon* theMuon = getTheMuon(*muons, muonEtaCut_, muonPtCut_);
717 
718  double theMuonTrackIsoPt = 1.e+3;
719  double theMuonEcalIsoPt = 1.e+3;
720  double theMuonCombIsoPt = 1.e+3;
721 
722  if (theMuon) {
723  theMuonTrackIsoPt = theMuon->isolationR05().sumPt;
724  // mu.isolationR05().emEt + mu.isolationR05().hadEt +
725  // mu.isolationR05().sumPt
726  theMuonEcalIsoPt = theMuon->isolationR05().emEt;
727 
728  if (muonIsoMode_ == kRelativeIso && theMuon->pt() > 0.) {
729  theMuonTrackIsoPt /= theMuon->pt();
730  theMuonEcalIsoPt /= theMuon->pt();
731  theMuonCombIsoPt = (theMuon->isolationR05().sumPt + theMuon->isolationR05().emEt) / theMuon->pt();
732  // std::cout<<"Rel Iso ="<<theMuonCombIsoPt<<std::endl;
733  }
734  }
735 
736  //--- get collections of reconstructed tau-jets from the event
738  readEventData(evt,
740  tauJets,
743  readError,
744  "Failed to access Tau-jet collection");
745  if (readError)
746  return;
747 
748  //--- get collections of tau-jet discriminators for those tau-jets
749  edm::Handle<reco::PFTauDiscriminator> tauDiscrByLeadTrackFinding;
750  readEventData(evt,
752  tauDiscrByLeadTrackFinding,
755  readError,
756  "Failed to access collection of pf. Tau discriminators by "
757  "leading Track finding");
758  edm::Handle<reco::PFTauDiscriminator> tauDiscrByLeadTrackPtCut;
759  readEventData(evt,
761  tauDiscrByLeadTrackPtCut,
764  readError,
765  "Failed to access collection of pf. Tau discriminators by "
766  "leading Track Pt cut");
767  edm::Handle<reco::PFTauDiscriminator> tauDiscrByTrackIso;
768  readEventData(evt,
770  tauDiscrByTrackIso,
773  readError,
774  "Failed to access collection of pf. Tau discriminators by "
775  "Track isolation");
776  edm::Handle<reco::PFTauDiscriminator> tauDiscrByEcalIso;
777  readEventData(evt,
779  tauDiscrByEcalIso,
782  readError,
783  "Failed to access collection of pf. Tau discriminators by ECAL "
784  "isolation");
785  edm::Handle<reco::PFTauDiscriminator> tauDiscrAgainstMuons;
786  readEventData(evt,
788  tauDiscrAgainstMuons,
791  readError,
792  "Failed to access collection of pf. Tau discriminators against Muons");
793  if (readError)
794  return;
795 
796  int theTauJetIndex = -1;
797  const reco::PFTau* theTauJet = getTheTauJet(*tauJets, tauJetEtaCut_, tauJetPtCut_, theTauJetIndex);
798 
799  double theTauDiscrByLeadTrackFinding = -1.;
800  double theTauDiscrByLeadTrackPtCut = -1.;
801  double theTauDiscrByTrackIso = -1.;
802  double theTauDiscrByEcalIso = -1.;
803  double theTauDiscrAgainstMuons = -1.;
804  if (theTauJetIndex != -1) {
805  reco::PFTauRef theTauJetRef(tauJets, theTauJetIndex);
806  theTauDiscrByLeadTrackFinding = (*tauDiscrByLeadTrackFinding)[theTauJetRef];
807  theTauDiscrByLeadTrackPtCut = (*tauDiscrByLeadTrackPtCut)[theTauJetRef];
808  theTauDiscrByTrackIso = (*tauDiscrByTrackIso)[theTauJetRef];
809  theTauDiscrByEcalIso = (*tauDiscrByEcalIso)[theTauJetRef];
810  theTauDiscrAgainstMuons = (*tauDiscrAgainstMuons)[theTauJetRef];
811  }
812 
813  //--- get missing transverse momentum
814  // measured by calorimeters/reconstructed by particle-flow algorithm
815  edm::Handle<reco::CaloMETCollection> caloMEtCollection;
816  readEventData(evt,
818  caloMEtCollection,
821  readError,
822  "Failed to access calo. MET collection");
823  if (readError)
824  return;
825 
826  const reco::CaloMET& caloMEt = caloMEtCollection->at(0);
827 
828  edm::Handle<reco::PFMETCollection> pfMEtCollection;
829  readEventData(evt,
830  pfMEtSource_,
831  pfMEtCollection,
834  readError,
835  "Failed to access pf. MET collection");
836  if (readError)
837  return;
838 
839  const reco::PFMET& pfMEt = pfMEtCollection->at(0);
840 
841  if (!(theMuon && theTauJet && theTauJetIndex != -1))
842  return;
843 
844  //-----------------------------------------------------------------------------
845  // compute EWK tau analysis specific quantities
846  //-----------------------------------------------------------------------------
847 
848  double dPhiMuTau = calcDeltaPhi(theMuon->phi(), theTauJet->phi());
849  // double dRMuTau = calcDeltaR(theMuon->p4(), theTauJet->p4());
850  double dRMuTau = fabs(ROOT::Math::VectorUtil::DeltaR(theMuon->p4(), theTauJet->p4()));
851  double mMuTau = (theMuon->p4() + theTauJet->p4()).M();
852 
853  // double mtMuCaloMEt = calcMt(theMuon->px(), theMuon->px(), caloMEt.px(),
854  // caloMEt.py());
855  double mtMuPFMEt = calcMt(theMuon->px(), theMuon->px(), pfMEt.px(), pfMEt.py());
856 
857  // double pZetaCaloMEt = calcPzeta(theMuon->p4(), theTauJet->p4(),
858  // caloMEt.px(), caloMEt.py());
859  // double pZetaPFMEt = calcPzeta(theMuon->p4(), theTauJet->p4(), pfMEt.px(),
860  // pfMEt.py());
861 
862  //-----------------------------------------------------------------------------
863  // apply selection criteria; fill histograms
864  //-----------------------------------------------------------------------------
865 
866  //--- fill muon multiplicity histogram
867  unsigned numGlobalMuons = 0;
868  for (reco::MuonCollection::const_iterator muon = muons->begin(); muon != muons->end(); ++muon) {
869  if (muon->isGlobalMuon()) {
870  ++numGlobalMuons;
871  }
872  }
873 
874  // hNumGlobalMuons_->Fill(numGlobalMuons);
875 
877 
878  bool isSelected = false;
879  int cutFlowStatus = -1;
880 
881  // if ( muonIsoMode_ == kAbsoluteIso){
882  if (mMuTau > visMassCut_) {
883  cutFlowStatus = kPassedPreselection;
884  }
885  if (cutFlowStatus == kPassedPreselection && (isTriggered || hltPaths_.empty())) {
886  cutFlowStatus = kPassedTrigger;
887  }
888  if (cutFlowStatus == kPassedTrigger && (theMuon->isGlobalMuon() || theMuon->isTrackerMuon())) {
889  cutFlowStatus = kPassedMuonId;
890  }
891 
892  if (cutFlowStatus == kPassedMuonId && (theTauDiscrByLeadTrackFinding > 0.5) && (theTauJet->eta() < tauJetEtaCut_) &&
893  (theTauJet->pt() > tauJetPtCut_)) {
894  cutFlowStatus = kPassedTauLeadTrack;
895  }
896  if (cutFlowStatus == kPassedTauLeadTrack && theTauDiscrByLeadTrackPtCut > 0.5) {
897  cutFlowStatus = kPassedTauLeadTrackPt;
898  // hTauTrackIsoPt_->Fill(theTauJet->isolationPFChargedHadrCandsPtSum());
899  }
900  if (cutFlowStatus == kPassedTauLeadTrackPt && theTauDiscrAgainstMuons > 0.5) {
901  cutFlowStatus = kPassedTauDiscrAgainstMuons;
902  // hTauEcalIsoPt_->Fill(theTauJet->isolationPFGammaCandsEtSum());
903  }
904  if (cutFlowStatus == kPassedTauDiscrAgainstMuons && dRMuTau > deltaRCut_) {
905  cutFlowStatus = kPassedDeltaR;
906  // hTauDiscrAgainstMuons_->Fill(theTauDiscrAgainstMuons);
907 
908  hMuonPt_->Fill(theMuon->pt());
909  hMuonEta_->Fill(theMuon->eta());
910  hMuonPhi_->Fill(theMuon->phi());
911 
912  hTauJetPt_->Fill(theTauJet->pt());
913  hTauJetEta_->Fill(theTauJet->eta());
914  hTauJetPhi_->Fill(theTauJet->phi());
915 
916  // hTauJetCharge_->Fill(theTauJet->charge());
917  if (theTauJet->signalTracks().isAvailable())
919  if (theTauJet->isolationTracks().isAvailable())
921 
922  hVisMass_->Fill(mMuTau);
923  // hMtMuCaloMEt_->Fill(mtMuCaloMEt);
924  hMtMuPFMEt_->Fill(mtMuPFMEt);
925  // hPzetaCaloMEt_->Fill(pZetaCaloMEt);
926  // hPzetaPFMEt_->Fill(pZetaPFMEt);
927  hMuTauAcoplanarity_->Fill(dPhiMuTau);
928  hMuTauDeltaR_->Fill(dRMuTau);
929  // hMuTauCharge_->Fill(theMuon->charge() + theTauJet->charge());
930 
931  if (theEventVertex) {
932  // hVertexChi2_->Fill(theEventVertex->normalizedChi2());
933  hVertexZ_->Fill(theEventVertex->z());
934  // hVertexD0_->Fill(getVertexD0(*theEventVertex, *beamSpot));
935  }
936 
937  hCaloMEtPt_->Fill(caloMEt.pt());
938  // hCaloMEtPhi_->Fill(caloMEt.phi());
939 
940  hPFMEtPt_->Fill(pfMEt.pt());
941  // hPFMEtPhi_->Fill(pfMEt.phi());
942  hMuonTrackIsoPt_->Fill(theMuonTrackIsoPt);
943  hMuonEcalIsoPt_->Fill(theMuonEcalIsoPt);
944  hMuonCombIsoPt_->Fill(theMuonCombIsoPt);
945  // hMuonCombIsoPt_->Fill((theMuonTrackIsoPt+theMuonEcalIsoPt)/theMuon->pt());
946 
947  // std::cout<<"Rel Iso Hist =
948  // "<<(theMuonTrackIsoPt+theMuonEcalIsoPt)/theMuon->pt()<<std::endl;
951  hTauDiscrAgainstMuons_->Fill(theTauDiscrAgainstMuons);
952  if (theTauJet->leadTrack().isAvailable())
953  hTauLeadTrackPt_->Fill(theTauJet->leadTrack()->pt());
954  }
955 
956  if ((cutFlowStatus == kPassedDeltaR) && (((theMuonTrackIsoPt < muonTrackIsoCut_) && (muonIsoMode_ == kAbsoluteIso)) ||
957  ((1 > 0) && (muonIsoMode_ == kRelativeIso)))) {
958  cutFlowStatus = kPassedMuonTrackIso;
959  // isSelected = true;
960  }
961  if (cutFlowStatus == kPassedMuonTrackIso &&
962  (((theMuonEcalIsoPt < muonEcalIsoCut_) && (muonIsoMode_ == kAbsoluteIso)) ||
963  ((theMuonCombIsoPt < muonCombIsoCut_) && (muonIsoMode_ == kRelativeIso)))) {
964  cutFlowStatus = kPassedMuonEcalIso;
965  // isSelected = true;
966  }
967 
968  if (cutFlowStatus == kPassedMuonEcalIso && theTauDiscrByTrackIso > 0.5) {
969  cutFlowStatus = kPassedTauTrackIso;
970  }
971 
972  if (cutFlowStatus == kPassedTauTrackIso && theTauDiscrByEcalIso > 0.5) {
973  cutFlowStatus = kPassedTauEcalIso;
974  isSelected = true;
975  }
976 
977  for (int iCut = 1; iCut <= cutFlowStatus; ++iCut) {
978  hCutFlowSummary_->Fill(iCut);
979  }
980 
981  for (int iCut = 1; iCut <= cutFlowStatus; ++iCut) {
982  hCutFlowSummary_->Fill(iCut);
983  }
984 
985  // }
986 
987  if (isSelected) {
988  hVisMassFinal_->Fill(mMuTau);
990  }
991 }
992 
994  edm::LogInfo("EwkMuTauHistManager") << "Filter-Statistics Summary:" << std::endl
995  << " Events analyzed = " << numEventsAnalyzed_ << std::endl
996  << " Events selected = " << numEventsSelected_;
997  if (numEventsAnalyzed_ > 0) {
998  double eff = numEventsSelected_ / (double)numEventsAnalyzed_;
999  edm::LogInfo("") << "Overall efficiency = " << std::setprecision(4) << eff * 100. << " +/- " << std::setprecision(4)
1000  << TMath::Sqrt(eff * (1 - eff) / numEventsAnalyzed_) * 100. << ")%";
1001  }
1002 }
1003 
1004 //-------------------------------------------------------------------------------
1005 // common auxiliary functions used by different channels
1006 //-------------------------------------------------------------------------------
1007 
1009 
1010 #include <TMath.h>
1011 
1012 int getIsoMode(const std::string& isoMode_string, int& error) {
1013  int isoMode_int;
1014  if (isoMode_string == "absoluteIso") {
1015  isoMode_int = kAbsoluteIso;
1016  } else if (isoMode_string == "relativeIso") {
1017  isoMode_int = kRelativeIso;
1018  } else {
1019  edm::LogError("getIsoMode") << " Failed to decode isoMode string = " << isoMode_string << " !!";
1020  isoMode_int = kUndefinedIso;
1021  error = 1;
1022  }
1023  return isoMode_int;
1024 }
1025 
1026 double calcDeltaPhi(double phi1, double phi2) {
1027  double deltaPhi = phi1 - phi2;
1028 
1029  if (deltaPhi < 0.)
1030  deltaPhi = -deltaPhi;
1031 
1032  if (deltaPhi > TMath::Pi())
1033  deltaPhi = 2 * TMath::Pi() - deltaPhi;
1034 
1035  return deltaPhi;
1036 }
1037 
1038 double calcMt(double px1, double py1, double px2, double py2) {
1039  double pt1 = TMath::Sqrt(px1 * px1 + py1 * py1);
1040  double pt2 = TMath::Sqrt(px2 * px2 + py2 * py2);
1041 
1042  double p1Dotp2 = px1 * px2 + py1 * py2;
1043  double cosAlpha = p1Dotp2 / (pt1 * pt2);
1044 
1045  return TMath::Sqrt(2 * pt1 * pt2 * (1 - cosAlpha));
1046 }
1047 
1050  double pxMEt,
1051  double pyMEt) {
1052  double cosPhi1 = cos(p1.phi());
1053  double sinPhi1 = sin(p1.phi());
1054  double cosPhi2 = cos(p2.phi());
1055  double sinPhi2 = sin(p2.phi());
1056  double zetaX = cosPhi1 + cosPhi2;
1057  double zetaY = sinPhi1 + sinPhi2;
1058  double zetaR = TMath::Sqrt(zetaX * zetaX + zetaY * zetaY);
1059  if (zetaR > 0.) {
1060  zetaX /= zetaR;
1061  zetaY /= zetaR;
1062  }
1063 
1064  double pxVis = p1.px() + p2.px();
1065  double pyVis = p1.py() + p2.py();
1066  double pZetaVis = pxVis * zetaX + pyVis * zetaY;
1067 
1068  double px = pxVis + pxMEt;
1069  double py = pyVis + pyMEt;
1070  double pZeta = px * zetaX + py * zetaY;
1071 
1072  return pZeta - 1.5 * pZetaVis;
1073 }
1074 
1076  if ((TMath::Abs(electron.eta()) < 1.479 || TMath::Abs(electron.eta()) > 1.566) && // cut ECAL barrel/endcap crack
1077  electron.deltaPhiSuperClusterTrackAtVtx() < 0.8 && electron.deltaEtaSuperClusterTrackAtVtx() < 0.01 &&
1078  electron.sigmaIetaIeta() < 0.03) {
1079  return true;
1080  } else {
1081  return false;
1082  }
1083 }
1084 
1086  if (passesElectronPreId(electron) && ((TMath::Abs(electron.eta()) > 1.566 && // electron reconstructed in ECAL
1087  // endcap
1088  electron.sigmaEtaEta() < 0.03 && electron.hcalOverEcal() < 0.05 &&
1089  TMath::Abs(electron.deltaEtaSuperClusterTrackAtVtx()) < 0.009 &&
1090  TMath::Abs(electron.deltaPhiSuperClusterTrackAtVtx()) < 0.7) ||
1091  (TMath::Abs(electron.eta()) < 1.479 && // electron reconstructed in ECAL
1092  // barrel
1093  electron.sigmaEtaEta() < 0.01 && electron.hcalOverEcal() < 0.12 &&
1094  TMath::Abs(electron.deltaEtaSuperClusterTrackAtVtx()) < 0.007 &&
1095  TMath::Abs(electron.deltaPhiSuperClusterTrackAtVtx()) < 0.8))) {
1096  return true;
1097  } else {
1098  return false;
1099  }
1100 }
1101 
1103  double electronEtaCut,
1104  double electronPtCut) {
1105  const reco::GsfElectron* theElectron = nullptr;
1106 
1107  for (reco::GsfElectronCollection::const_iterator electron = electrons.begin(); electron != electrons.end();
1108  ++electron) {
1109  if (TMath::Abs(electron->eta()) < electronEtaCut && electron->pt() > electronPtCut &&
1111  if (theElectron == nullptr || electron->pt() > theElectron->pt())
1112  theElectron = &(*electron);
1113  }
1114  }
1115 
1116  return theElectron;
1117 }
1118 
1120  const reco::Muon* theMuon = nullptr;
1121 
1122  for (reco::MuonCollection::const_iterator muon = muons.begin(); muon != muons.end(); ++muon) {
1123  if (TMath::Abs(muon->eta()) < muonEtaCut && muon->pt() > muonPtCut) {
1124  if (theMuon == nullptr || muon->pt() > theMuon->pt())
1125  theMuon = &(*muon);
1126  }
1127  }
1128 
1129  return theMuon;
1130 }
1131 
1133  double tauJetEtaCut,
1134  double tauJetPtCut,
1135  int& theTauJetIndex) {
1136  const reco::PFTau* theTauJet = nullptr;
1137  theTauJetIndex = -1;
1138 
1139  int numTauJets = tauJets.size();
1140  for (int iTauJet = 0; iTauJet < numTauJets; ++iTauJet) {
1141  const reco::PFTau& tauJet = tauJets.at(iTauJet);
1142 
1143  if (fabs(tauJet.eta()) < tauJetEtaCut && tauJet.pt() > tauJetPtCut) {
1144  if (theTauJet == nullptr || tauJet.pt() > theTauJet->pt()) {
1145  theTauJet = &tauJet;
1146  theTauJetIndex = iTauJet;
1147  }
1148  }
1149  }
1150 
1151  return theTauJet;
1152 }
1153 
1154 double getVertexD0(const reco::Vertex& vertex, const reco::BeamSpot& beamSpot) {
1155  double dX = vertex.x() - beamSpot.x0();
1156  double dY = vertex.y() - beamSpot.y0();
1157  return TMath::Sqrt(dX * dX + dY * dY);
1158 }
std::size_t size() const
Definition: TriggerNames.cc:59
MonitorElement * hCutFlowSummary_
Definition: EwkTauDQM.h:306
edm::InputTag tauDiscrByEcalIso_
Definition: EwkTauDQM.h:242
long numWarningsTauDiscrByEcalIso_
Definition: EwkTauDQM.h:187
bool isAvailable() const
Definition: Ref.h:537
const double Pi
edm::InputTag beamSpotSource_
Definition: EwkTauDQM.h:233
double calcDeltaPhi(double phi1, double phi2)
Definition: EwkTauDQM.cc:1026
double muonCombIsoCut_
Definition: EwkTauDQM.h:253
virtual reco::TrackRef leadTrack() const
Definition: BaseTau.cc:24
MonitorElement * hPFMEtPt_
Definition: EwkTauDQM.h:152
void bookHistograms(DQMStore::IBooker &)
Definition: EwkTauDQM.cc:142
double calcMt(double px1, double py1, double px2, double py2)
Definition: EwkTauDQM.cc:1038
edm::InputTag tauDiscrByLeadTrackFinding_
Definition: EwkTauDQM.h:239
float isolationPFGammaCandsEtSum() const
Definition: PFTau.cc:333
MonitorElement * hTauJetPhi_
Definition: EwkTauDQM.h:277
edm::InputTag pfMEtSource_
Definition: EwkTauDQM.h:237
edm::InputTag beamSpotSource_
Definition: EwkTauDQM.h:84
std::vector< PFTau > PFTauCollection
collection of PFTau objects
Definition: PFTauFwd.h:9
tuple cfg
Definition: looper.py:296
EwkMuTauHistManager(const edm::ParameterSet &)
Definition: EwkTauDQM.cc:553
float sumPt
sum-pt of tracks
Definition: MuonIsolation.h:6
float isolationPFChargedHadrCandsPtSum() const
Definition: PFTau.cc:330
double pt() const final
transverse momentum
edm::InputTag tauDiscrByLeadTrackPtCut_
Definition: EwkTauDQM.h:91
const LorentzVector & p4(P4Kind kind) const
Definition: GsfElectron.cc:217
MonitorElement * hElecTauAcoplanarity_
Definition: EwkTauDQM.h:142
edm::InputTag electronSource_
Definition: EwkTauDQM.h:85
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
int getIsoMode(const std::string &isoMode_string, int &error)
Definition: EwkTauDQM.cc:1012
edm::InputTag tauDiscrByTrackIso_
Definition: EwkTauDQM.h:241
long numWarningsTauDiscrAgainstMuons_
Definition: EwkTauDQM.h:339
MonitorElement * hVisMass_
Definition: EwkTauDQM.h:137
const TString p2
Definition: fwPaths.cc:13
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: EwkTauDQM.cc:50
edm::InputTag tauDiscrByLeadTrackFinding_
Definition: EwkTauDQM.h:90
long numWarningsTauDiscrByEcalIso_
Definition: EwkTauDQM.h:338
double getVertexD0(const reco::Vertex &vertex, const reco::BeamSpot &beamSpot)
Definition: EwkTauDQM.cc:1154
virtual const reco::TrackRefVector & isolationTracks() const
Definition: BaseTau.cc:28
long numWarningsTauDiscrByTrackIso_
Definition: EwkTauDQM.h:337
double y() const
y coordinate
Definition: Vertex.h:131
MonitorElement * hMuonPhi_
Definition: EwkTauDQM.h:270
std::vector< std::string > vstring
Definition: EwkTauDQM.h:246
MonitorElement * hElectronEcalIsoPt_
Definition: EwkTauDQM.h:122
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
MonitorElement * hTauEcalIsoPt_
Definition: EwkTauDQM.h:280
std::string dqmDirectory_
Definition: EwkTauDQM.h:37
long numWarningsTauDiscrByLeadTrackFinding_
Definition: EwkTauDQM.h:184
bool exists(std::string const &parameterName) const
checks if a parameter exists
double electronEcalIsoCut_
Definition: EwkTauDQM.h:104
unsigned int triggerIndex(std::string_view name) const
Definition: TriggerNames.cc:52
float dr03HcalTowerSumEt(int depth=0) const
Definition: GsfElectron.h:576
unsigned numEventsSelected_
Definition: EwkTauDQM.h:172
MonitorElement * hPFMEtPt_
Definition: EwkTauDQM.h:303
unsigned numEventsSelected_
Definition: EwkTauDQM.h:323
std::string dqmDirectory_
Definition: EwkTauDQM.h:264
edm::InputTag tauDiscrByLeadTrackPtCut_
Definition: EwkTauDQM.h:240
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: EwkTauDQM.cc:45
~EwkTauDQM() override
Definition: EwkTauDQM.cc:40
Log< level::Error, false > LogError
std::string dqmDirectoryName(const std::string &dqmRootDirectory, const std::string &dqmSubDirectory)
Definition: EwkTauDQM.cc:10
const MuonIsolation & isolationR05() const
Definition: Muon.h:167
MonitorElement * hCutFlowSummary_
Definition: EwkTauDQM.h:155
long numWarningsTauDiscrByLeadTrackPtCut_
Definition: EwkTauDQM.h:185
edm::InputTag caloMEtSource_
Definition: EwkTauDQM.h:87
double electronTrackIsoCut_
Definition: EwkTauDQM.h:103
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
tuple vertexCollection
edm::InputTag tauDiscrAgainstMuons_
Definition: EwkTauDQM.h:95
MonitorElement * hVertexZ_
Definition: EwkTauDQM.h:146
void fillHistograms(const edm::Event &, const edm::EventSetup &)
Definition: EwkTauDQM.cc:647
MonitorElement * hTauDiscrAgainstMuons_
Definition: EwkTauDQM.h:281
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
bool isTrackerMuon() const override
Definition: Muon.h:300
MonitorElement * hMuonEcalIsoPt_
Definition: EwkTauDQM.h:272
void fillHistograms(const edm::Event &, const edm::EventSetup &)
Definition: EwkTauDQM.cc:173
long numWarningsTauDiscrByTrackIso_
Definition: EwkTauDQM.h:186
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:275
MonitorElement * hElecTauCharge_
Definition: EwkTauDQM.h:143
double muonTrackIsoCut_
Definition: EwkTauDQM.h:251
edm::InputTag vertexSource_
Definition: EwkTauDQM.h:232
void Fill(long long x)
const reco::GsfElectron * getTheElectron(const reco::GsfElectronCollection &electrons, double electronEtaCut, double electronPtCut)
Definition: EwkTauDQM.cc:1102
MonitorElement * hElectronTrackIsoPt_
Definition: EwkTauDQM.h:121
MonitorElement * hTauJetNumSignalTracks_
Definition: EwkTauDQM.h:283
double px() const final
x coordinate of momentum vector
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:225
edm::InputTag tauJetSource_
Definition: EwkTauDQM.h:235
MonitorElement * hMuonEta_
Definition: EwkTauDQM.h:269
float sigmaIetaIeta() const
Definition: GsfElectron.h:419
void dqmEndRun(const edm::Run &, const edm::EventSetup &) override
Definition: EwkTauDQM.cc:55
bool passesElectronId(const reco::GsfElectron &electron)
Definition: EwkTauDQM.cc:1085
MonitorElement * hVisMassFinal_
Definition: EwkTauDQM.h:288
MonitorElement * hTauLeadTrackPt_
Definition: EwkTauDQM.h:278
EwkElecTauHistManager * elecTauHistManager_
Definition: EwkTauDQM.h:40
MonitorElement * hElectronEta_
Definition: EwkTauDQM.h:119
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:228
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:135
float emEt
ecal sum-Et
Definition: MuonIsolation.h:7
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
int maxNumWarnings_
Definition: EwkTauDQM.h:38
edm::InputTag caloMEtSource_
Definition: EwkTauDQM.h:236
T Abs(T a)
Definition: MathUtil.h:49
long numWarningsTriggerResults_
Definition: EwkTauDQM.h:329
std::string dqmDirectory_
Definition: EwkTauDQM.h:114
long numWarningsTauDiscrAgainstMuons_
Definition: EwkTauDQM.h:189
float dr03TkSumPt() const
Definition: GsfElectron.h:557
const TString p1
Definition: fwPaths.cc:12
MonitorElement * hMtMuPFMEt_
Definition: EwkTauDQM.h:290
MonitorElement * hCaloMEtPt_
Definition: EwkTauDQM.h:149
double z() const
z coordinate
Definition: Vertex.h:133
MonitorElement * hTauJetPt_
Definition: EwkTauDQM.h:275
const reco::Muon * getTheMuon(const reco::MuonCollection &muons, double muonEtaCut, double muonPtCut)
Definition: EwkTauDQM.cc:1119
edm::InputTag tauDiscrByEcalIso_
Definition: EwkTauDQM.h:93
MonitorElement * hVertexZ_
Definition: EwkTauDQM.h:297
const reco::PFTau * getTheTauJet(const reco::PFTauCollection &tauJets, double tauJetEtaCut, double tauJetPtCut, int &theTauJetIndex)
Definition: EwkTauDQM.cc:1132
virtual const reco::TrackRefVector & signalTracks() const
Definition: BaseTau.cc:26
MonitorElement * hTauJetPt_
Definition: EwkTauDQM.h:125
double py() const final
y coordinate of momentum vector
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
void finalizeHistograms()
Definition: EwkTauDQM.cc:993
MonitorElement * hTauTrackIsoPt_
Definition: EwkTauDQM.h:279
MonitorElement * hElectronPhi_
Definition: EwkTauDQM.h:120
double calcPzeta(const reco::Candidate::LorentzVector &p1, const reco::Candidate::LorentzVector &p2, double pxMEt, double pyMEt)
Definition: EwkTauDQM.cc:1048
edm::InputTag tauDiscrAgainstElectrons_
Definition: EwkTauDQM.h:94
MonitorElement * hCaloMEtPt_
Definition: EwkTauDQM.h:300
long numWarningsTauDiscrByLeadTrackFinding_
Definition: EwkTauDQM.h:335
MonitorElement * hMuonPt_
Definition: EwkTauDQM.h:268
Log< level::Info, false > LogInfo
edm::InputTag tauDiscrByTrackIso_
Definition: EwkTauDQM.h:92
double x() const
x coordinate
Definition: Vertex.h:129
MonitorElement * hMuTauDeltaR_
Definition: EwkTauDQM.h:287
long numWarningsTriggerResults_
Definition: EwkTauDQM.h:178
edm::InputTag muonSource_
Definition: EwkTauDQM.h:234
EwkElecTauHistManager(const edm::ParameterSet &)
Definition: EwkTauDQM.cc:91
MonitorElement * hMuTauAcoplanarity_
Definition: EwkTauDQM.h:293
MonitorElement * hTauJetNumIsoTracks_
Definition: EwkTauDQM.h:284
MonitorElement * hMuonCombIsoPt_
Definition: EwkTauDQM.h:273
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
bool isSelected(const std::vector< L1HPSPFTauQualityCut > &qualityCuts, const l1t::PFCandidate &pfCand, float_t primaryVertexZ)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
edm::InputTag vertexSource_
Definition: EwkTauDQM.h:83
float dr03EcalRecHitSumEt() const
Definition: GsfElectron.h:559
bool passesElectronPreId(const reco::GsfElectron &electron)
Definition: EwkTauDQM.cc:1075
edm::InputTag pfMEtSource_
Definition: EwkTauDQM.h:88
EwkMuTauHistManager * muTauHistManager_
Definition: EwkTauDQM.h:41
std::vector< std::string > vstring
Definition: EwkTauDQM.h:98
bool isAvailable() const
Definition: RefVector.h:233
tuple muons
Definition: patZpeak.py:39
void readEventData(const edm::Event &evt, const edm::InputTag &src, edm::Handle< T > &handle, long &numWarnings, int maxNumWarnings, bool &error, const char *errorMessage)
Definition: EwkTauDQM.h:374
void bookHistograms(DQMStore::IBooker &)
Definition: EwkTauDQM.cc:604
MonitorElement * hTauJetEta_
Definition: EwkTauDQM.h:276
edm::InputTag tauJetSource_
Definition: EwkTauDQM.h:86
edm::InputTag triggerResultsSource_
Definition: EwkTauDQM.h:82
float hcalOverEcal(const ShowerShape &ss, int depth) const
Definition: GsfElectron.h:425
unsigned numEventsAnalyzed_
Definition: EwkTauDQM.h:322
double y0() const
y coordinate
Definition: BeamSpot.h:63
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
edm::InputTag triggerResultsSource_
Definition: EwkTauDQM.h:231
MonitorElement * hTauJetEta_
Definition: EwkTauDQM.h:126
edm::InputTag tauDiscrAgainstMuons_
Definition: EwkTauDQM.h:243
const std::string dqmRootDirectory
const std::string dqmSeparator
Definition: EwkTauDQM.cc:8
MonitorElement * hVisMass_
Definition: EwkTauDQM.h:286
MonitorElement * hMuonTrackIsoPt_
Definition: EwkTauDQM.h:271
Log< level::Warning, false > LogWarning
unsigned numEventsAnalyzed_
Definition: EwkTauDQM.h:171
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
long numWarningsTauDiscrAgainstElectrons_
Definition: EwkTauDQM.h:188
double phi() const final
momentum azimuthal angle
EwkTauDQM(const edm::ParameterSet &)
Definition: EwkTauDQM.cc:20
MonitorElement * hElectronPt_
Definition: EwkTauDQM.h:118
bool isGlobalMuon() const override
Definition: Muon.h:299
MonitorElement * hMtElecPFMEt_
Definition: EwkTauDQM.h:139
Definition: Run.h:45
int charge() const final
electric charge
float sigmaEtaEta() const
Definition: GsfElectron.h:418
double muonEcalIsoCut_
Definition: EwkTauDQM.h:252
long numWarningsTauDiscrByLeadTrackPtCut_
Definition: EwkTauDQM.h:336
double x0() const
x coordinate
Definition: BeamSpot.h:61
double eta() const final
momentum pseudorapidity