CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EwkTauDQM.cc
Go to the documentation of this file.
2 
4 
7 
9 
11  const std::string& dqmSubDirectory) {
12  //--- concatenate names of dqmRootDirectory and dqmSubDirectory;
13  // add "/" separator inbetween if necessary
15  if (dirName != "" &&
16  dirName.find_last_of(dqmSeparator) != (dirName.length() - 1))
17  dirName.append(dqmSeparator);
18  dirName.append(dqmSubDirectory);
19  return dirName;
20 }
21 
23  : dqmDirectory_(cfg.getParameter<std::string>("dqmDirectory")),
24  dqmError_(0) {
25  if (!edm::Service<DQMStore>().isAvailable()) {
26  edm::LogError("EwkTauDQM") << " Failed to access dqmStore --> histograms "
27  "will NEITHER be booked NOR filled !!";
28  dqmError_ = 1;
29  return;
30  }
31 
32  DQMStore* dqmStore = &(*edm::Service<DQMStore>());
33 
34  maxNumWarnings_ = cfg.exists("maxNumWarnings")
35  ? cfg.getParameter<int>("maxNumWarnings")
36  : 1;
37 
38  edm::ParameterSet cfgChannels =
39  cfg.getParameter<edm::ParameterSet>("channels");
40 
41  edm::ParameterSet cfgElecTauChannel =
42  cfgChannels.getParameter<edm::ParameterSet>("elecTauChannel");
43  std::string dqmSubDirectoryElecTauChannel =
44  cfgElecTauChannel.getParameter<std::string>("dqmSubDirectory");
45  cfgElecTauChannel.addParameter<std::string>(
46  "dqmDirectory",
47  dqmDirectoryName(dqmDirectory_, dqmSubDirectoryElecTauChannel));
48  cfgElecTauChannel.addParameter<int>("maxNumWarnings", maxNumWarnings_);
49  elecTauHistManager_ = new EwkElecTauHistManager(cfgElecTauChannel, dqmStore);
50 
51  edm::ParameterSet cfgMuTauChannel =
52  cfgChannels.getParameter<edm::ParameterSet>("muTauChannel");
53  std::string dqmSubDirectoryMuTauChannel =
54  cfgMuTauChannel.getParameter<std::string>("dqmSubDirectory");
55  cfgMuTauChannel.addParameter<std::string>(
56  "dqmDirectory",
57  dqmDirectoryName(dqmDirectory_, dqmSubDirectoryMuTauChannel));
58  cfgMuTauChannel.addParameter<int>("maxNumWarnings", maxNumWarnings_);
59  muTauHistManager_ = new EwkMuTauHistManager(cfgMuTauChannel, dqmStore);
60 }
61 
63  delete elecTauHistManager_;
64  delete muTauHistManager_;
65 }
66 
68  if (dqmError_) return;
69 
72 }
73 
74 void EwkTauDQM::analyze(const edm::Event& evt, const edm::EventSetup& es) {
75  if (dqmError_) return;
76 
79 }
80 
82  if (dqmError_) return;
83 
86 }
87 
88 //-------------------------------------------------------------------------------
89 // code specific to Z --> e + tau-jet channel
90 //-------------------------------------------------------------------------------
91 
93 
96 
114 
115 #include "TMath.h"
116 
117 #include <iostream>
118 #include <iomanip>
119 
121  DQMStore* dqmStore)
122  : dqmStore_(dqmStore),
123  dqmDirectory_(cfg.getParameter<std::string>("dqmDirectory")),
124  numEventsAnalyzed_(0),
125  numEventsSelected_(0),
126  cfgError_(0),
127  numWarningsTriggerResults_(0),
128  numWarningsHLTpath_(0),
129  numWarningsVertex_(0),
130  numWarningsBeamSpot_(0),
131  numWarningsElectron_(0),
132  numWarningsTauJet_(0),
133  numWarningsTauDiscrByLeadTrackFinding_(0),
134  numWarningsTauDiscrByLeadTrackPtCut_(0),
135  numWarningsTauDiscrByTrackIso_(0),
136  numWarningsTauDiscrByEcalIso_(0),
137  numWarningsTauDiscrAgainstElectrons_(0),
138  numWarningsTauDiscrAgainstMuons_(0),
139  numWarningsCaloMEt_(0),
140  numWarningsPFMEt_(0) {
142  cfg.getParameter<edm::InputTag>("triggerResultsSource");
143  vertexSource_ = cfg.getParameter<edm::InputTag>("vertexSource");
144  beamSpotSource_ = cfg.getParameter<edm::InputTag>("beamSpotSource");
145  electronSource_ = cfg.getParameter<edm::InputTag>("electronSource");
146  tauJetSource_ = cfg.getParameter<edm::InputTag>("tauJetSource");
147  caloMEtSource_ = cfg.getParameter<edm::InputTag>("caloMEtSource");
148  pfMEtSource_ = cfg.getParameter<edm::InputTag>("pfMEtSource");
149 
151  cfg.getParameter<edm::InputTag>("tauDiscrByLeadTrackFinding");
153  cfg.getParameter<edm::InputTag>("tauDiscrByLeadTrackPtCut");
154  tauDiscrByTrackIso_ = cfg.getParameter<edm::InputTag>("tauDiscrByTrackIso");
155  tauDiscrByEcalIso_ = cfg.getParameter<edm::InputTag>("tauDiscrByEcalIso");
157  cfg.getParameter<edm::InputTag>("tauDiscrAgainstElectrons");
159  cfg.getParameter<edm::InputTag>("tauDiscrAgainstMuons");
160 
161  hltPaths_ = cfg.getParameter<vstring>("hltPaths");
162 
163  electronEtaCut_ = cfg.getParameter<double>("electronEtaCut");
164  electronPtCut_ = cfg.getParameter<double>("electronPtCut");
165  electronTrackIsoCut_ = cfg.getParameter<double>("electronTrackIsoCut");
166  electronEcalIsoCut_ = cfg.getParameter<double>("electronEcalIsoCut");
167  std::string electronIsoMode_string =
168  cfg.getParameter<std::string>("electronIsoMode");
169  electronIsoMode_ = getIsoMode(electronIsoMode_string, cfgError_);
170 
171  tauJetEtaCut_ = cfg.getParameter<double>("tauJetEtaCut");
172  tauJetPtCut_ = cfg.getParameter<double>("tauJetPtCut");
173 
174  visMassCut_ = cfg.getParameter<double>("visMassCut");
175 
176  maxNumWarnings_ = cfg.exists("maxNumWarnings")
177  ? cfg.getParameter<int>("maxNumWarnings")
178  : 1;
179 }
180 
183 
184  // hNumIdElectrons_ = dqmStore_->book1D("NumIdElectronsMuons" , "Num. id.
185  // Muons", 5, -0.5, 4.5);
186  hElectronPt_ = dqmStore_->book1D("ElectronPt", "P_{T}^{e}", 20, 0., 100.);
187  hElectronEta_ = dqmStore_->book1D("ElectronEta", "#eta_{e}", 20, -4.0, +4.0);
188  hElectronPhi_ = dqmStore_->book1D("ElectronPhi", "#phi_{e}", 20, -TMath::Pi(),
189  +TMath::Pi());
191  "ElectronTrackIsoPt", "Electron Track Iso.", 20, -0.01, 0.5);
192  hElectronEcalIsoPt_ = dqmStore_->book1D("ElectronEcalIsoPt",
193  "Electron Ecal Iso.", 20, -0.01, 0.5);
194  // hElectronHcalIsoPt_ = dqmStore_->book1D("ElectronHcalIsoPt" , "Electron
195  // Hcal Iso.", 20, -0.01, 0.5);
196 
197  hTauJetPt_ = dqmStore_->book1D("TauJetPt", "P_{T}^{#tau-Jet}", 20, 0., 100.);
198  hTauJetEta_ =
199  dqmStore_->book1D("TauJetEta", "#eta_{#tau-Jet}", 20, -4.0, +4.0);
200  // hTauJetPhi_ = dqmStore_->book1D("TauJetPhi" , "#phi_{#tau-Jet}", 20,
201  // -TMath::Pi(), +TMath::Pi());
202  // hTauLeadTrackPt_ = dqmStore_->book1D("TauLeadTrackPt" , "P_{T}^{#tau-Jet}",
203  // 20, 0., 50.);
204  // hTauTrackIsoPt_ = dqmStore_->book1D("TauTrackIsoPt" , "Tau Track Iso.", 20,
205  // -0.01, 40.);
206  // hTauEcalIsoPt_ = dqmStore_->book1D("TauEcalIsoPt" , "Tau Ecal Iso.", 10,
207  // -0.01, 10.);
208  // hTauDiscrAgainstElectrons_ = dqmStore_->book1D("TauDiscrAgainstElectrons" ,
209  // "Tau Discr. against Electrons", 2, -0.5, +1.5);
210  // hTauDiscrAgainstMuons_ = dqmStore_->book1D("TauDiscrAgainstMuons" , "Tau
211  // Discr. against Muons", 2, -0.5, +1.5);
212  // hTauJetCharge_ = dqmStore_->book1D("TauJetCharge" , "Q_{#tau-Jet}", 11,
213  // -5.5, +5.5);
214  // hTauJetNumSignalTracks_ = dqmStore_->book1D("TauJetNumSignalTracks" , "Num.
215  // Tau signal Cone Tracks", 20, -0.5, +19.5);
216  // hTauJetNumIsoTracks_ = dqmStore_->book1D("TauJetNumIsoTracks" , "Num. Tau
217  // isolation Cone Tracks", 20, -0.5, +19.5);
218 
219  hVisMass_ =
220  dqmStore_->book1D("VisMass", "e + #tau-Jet visible Mass", 20, 20., 120.);
221  // hMtElecCaloMEt_ = dqmStore_->book1D("MtElecCaloMEt", "e + E_{T}^{miss}
222  // (Calo) transverse Mass", 20, 20., 120.);
224  "MtElecPFMEt", "e + E_{T}^{miss} (PF) transverse Mass", 20, 20., 120.);
225  // hPzetaCaloMEt_ = dqmStore_->book1D("PzetaCaloMEt", "P_{#zeta} -
226  // 1.5*P_{#zeta}^{vis} (Calo)", 20, -40., 40.);
227  // hPzetaPFMEt_ = dqmStore_->book1D("PzetaPFMEt", "P_{#zeta} -
228  // 1.5*P_{#zeta}^{vis} (PF)", 20, -40., 40.);
230  dqmStore_->book1D("ElecTauAcoplanarity", "#Delta #phi_{e #tau-Jet}", 20,
231  -TMath::Pi(), +TMath::Pi());
233  dqmStore_->book1D("ElecTauCharge", "Q_{e * #tau-Jet}", 5, -2.5, +2.5);
234 
235  // hVertexChi2_ = dqmStore_->book1D("VertexChi2", "Event Vertex #chi^{2} /
236  // n.d.o.f.", 20, 0., 2.0);
237  hVertexZ_ =
238  dqmStore_->book1D("VertexZ", "Event Vertex z-Position", 20, -25., +25.);
239  // hVertexD0_ = dqmStore_->book1D("VertexD0", "Event Vertex d_{0}", 20,
240  // -0.0001, 0.05);
241 
242  hCaloMEtPt_ =
243  dqmStore_->book1D("CaloMEtPt", "E_{T}^{miss} (Calo)", 20, 0., 100.);
244  // hCaloMEtPhi_ = dqmStore_->book1D("CaloMEtPhi", "#phi^{miss} (Calo)", 20,
245  // -TMath::Pi(), +TMath::Pi());
246 
247  hPFMEtPt_ = dqmStore_->book1D("PFMEtPt", "E_{T}^{miss} (PF)", 20, 0., 100.);
248  // hPFMEtPhi_ = dqmStore_->book1D("PFMEtPhi", "#phi^{miss} (PF)", 20,
249  // -TMath::Pi(), +TMath::Pi());
250 
252  dqmStore_->book1D("CutFlowSummary", "Cut-flow Summary", 11, 0.5, 11.5);
258  hCutFlowSummary_->setBinLabel(kPassedTauLeadTrack, "#tau lead. Track");
260  "#tau lead. Track P_{T}");
262  "#tau anti-e Discr.");
264  "#tau anti-#mu Discr.");
265  hCutFlowSummary_->setBinLabel(kPassedTauTrackIso, "#tau Track Iso.");
266  hCutFlowSummary_->setBinLabel(kPassedTauEcalIso, "#tau Ecal Iso.");
267 }
268 
270  const edm::EventSetup& es) {
271  if (cfgError_) return;
272 
273  //-----------------------------------------------------------------------------
274  // access event-level information
275  //-----------------------------------------------------------------------------
276 
277  bool readError = false;
278 
279  //--- get decision of high-level trigger for the event
281  readEventData(evt, triggerResultsSource_, hltDecision,
283  "Failed to access Trigger results");
284  if (readError) return;
285 
286  const edm::TriggerNames& triggerNames = evt.triggerNames(*hltDecision);
287 
288  bool isTriggered = false;
289  for (vstring::const_iterator hltPath = hltPaths_.begin();
290  hltPath != hltPaths_.end(); ++hltPath) {
291  unsigned int index = triggerNames.triggerIndex(*hltPath);
292  if (index < triggerNames.size()) {
293  if (hltDecision->accept(index)) isTriggered = true;
294  } else {
296  edm::LogWarning("EwkElecTauHistManager")
297  << " Undefined HLT path = " << (*hltPath) << " !!";
299  continue;
300  }
301  }
302 
303  //--- get reconstructed primary event vertex of the event
304  // (take as "the" primary event vertex the first entry in the collection
305  // of vertex objects, corresponding to the vertex associated to the highest
306  // Pt sum of tracks)
308  readEventData(evt, vertexSource_, vertexCollection, numWarningsVertex_,
309  maxNumWarnings_, readError,
310  "Failed to access Vertex collection");
311  if (readError) return;
312 
313  const reco::Vertex* theEventVertex =
314  (vertexCollection->size() > 0) ? &(vertexCollection->at(0)) : 0;
315 
316  //--- get beam-spot (expected vertex position) for the event
319  maxNumWarnings_, readError, "Failed to access Beam-spot");
320  if (readError) return;
321 
322  //--- get collections of reconstructed electrons from the event
325  maxNumWarnings_, readError,
326  "Failed to access Electron collection");
327  if (readError) return;
328 
329  const reco::GsfElectron* theElectron =
331 
332  double theElectronTrackIsoPt = 1.e+3;
333  double theElectronEcalIsoPt = 1.e+3;
334  double theElectronHcalIsoPt = 1.e+3;
335  if (theElectron) {
336  theElectronTrackIsoPt = theElectron->dr03TkSumPt();
337  theElectronEcalIsoPt = theElectron->dr03EcalRecHitSumEt();
338  theElectronHcalIsoPt = theElectron->dr03HcalTowerSumEt();
339 
340  if (electronIsoMode_ == kRelativeIso && theElectron->pt() > 0.) {
341  theElectronTrackIsoPt /= theElectron->pt();
342  theElectronEcalIsoPt /= theElectron->pt();
343  theElectronHcalIsoPt /= theElectron->pt();
344  }
345  }
346 
347  //--- get collections of reconstructed tau-jets from the event
350  maxNumWarnings_, readError,
351  "Failed to access Tau-jet collection");
352  if (readError) return;
353 
354  //--- get collections of tau-jet discriminators for those tau-jets
355  edm::Handle<reco::PFTauDiscriminator> tauDiscrByLeadTrackFinding;
356  readEventData(evt, tauDiscrByLeadTrackFinding_, tauDiscrByLeadTrackFinding,
358  readError,
359  "Failed to access collection of pf. Tau discriminators by "
360  "leading Track finding");
361  edm::Handle<reco::PFTauDiscriminator> tauDiscrByLeadTrackPtCut;
362  readEventData(evt, tauDiscrByLeadTrackPtCut_, tauDiscrByLeadTrackPtCut,
364  readError,
365  "Failed to access collection of pf. Tau discriminators by "
366  "leading Track Pt cut");
367  edm::Handle<reco::PFTauDiscriminator> tauDiscrByTrackIso;
368  readEventData(evt, tauDiscrByTrackIso_, tauDiscrByTrackIso,
370  "Failed to access collection of pf. Tau discriminators by "
371  "Track isolation");
372  edm::Handle<reco::PFTauDiscriminator> tauDiscrByEcalIso;
373  readEventData(evt, tauDiscrByTrackIso_, tauDiscrByEcalIso,
375  "Failed to access collection of pf. Tau discriminators by ECAL "
376  "isolation");
377  edm::Handle<reco::PFTauDiscriminator> tauDiscrAgainstElectrons;
378  readEventData(evt, tauDiscrAgainstElectrons_, tauDiscrAgainstElectrons,
380  readError,
381  "Failed to access collection of pf. Tau discriminators against "
382  "Electrons");
383  edm::Handle<reco::PFTauDiscriminator> tauDiscrAgainstMuons;
385  evt, tauDiscrAgainstMuons_, tauDiscrAgainstMuons,
387  "Failed to access collection of pf. Tau discriminators against Muons");
388  if (readError) return;
389 
390  int theTauJetIndex = -1;
391  const reco::PFTau* theTauJet =
392  getTheTauJet(*tauJets, tauJetEtaCut_, tauJetPtCut_, theTauJetIndex);
393 
394  double theTauDiscrByLeadTrackFinding = -1.;
395  double theTauDiscrByLeadTrackPtCut = -1.;
396  double theTauDiscrByTrackIso = -1.;
397  double theTauDiscrByEcalIso = -1.;
398  double theTauDiscrAgainstElectrons = -1.;
399  double theTauDiscrAgainstMuons = -1.;
400  if (theTauJetIndex != -1) {
401  reco::PFTauRef theTauJetRef(tauJets, theTauJetIndex);
402  theTauDiscrByLeadTrackFinding = (*tauDiscrByLeadTrackFinding)[theTauJetRef];
403  theTauDiscrByLeadTrackPtCut = (*tauDiscrByLeadTrackPtCut)[theTauJetRef];
404  theTauDiscrByTrackIso = (*tauDiscrByTrackIso)[theTauJetRef];
405  theTauDiscrByEcalIso = (*tauDiscrByEcalIso)[theTauJetRef];
406  theTauDiscrAgainstElectrons = (*tauDiscrAgainstElectrons)[theTauJetRef];
407  theTauDiscrAgainstMuons = (*tauDiscrAgainstMuons)[theTauJetRef];
408  }
409 
410  //--- get missing transverse momentum
411  // measured by calorimeters/reconstructed by particle-flow algorithm
412  edm::Handle<reco::CaloMETCollection> caloMEtCollection;
413  readEventData(evt, caloMEtSource_, caloMEtCollection, numWarningsCaloMEt_,
414  maxNumWarnings_, readError,
415  "Failed to access calo. MET collection");
416  if (readError) return;
417 
418  const reco::CaloMET& caloMEt = caloMEtCollection->at(0);
419 
420  edm::Handle<reco::PFMETCollection> pfMEtCollection;
421  readEventData(evt, pfMEtSource_, pfMEtCollection, numWarningsPFMEt_,
422  maxNumWarnings_, readError,
423  "Failed to access pf. MET collection");
424  if (readError) return;
425 
426  const reco::PFMET& pfMEt = pfMEtCollection->at(0);
427 
428  if (!(theElectron && theTauJet && theTauJetIndex != -1)) return;
429 
430  //-----------------------------------------------------------------------------
431  // compute EWK tau analysis specific quantities
432  //-----------------------------------------------------------------------------
433 
434  double dPhiElecTau = calcDeltaPhi(theElectron->phi(), theTauJet->phi());
435 
436  double mElecTau = (theElectron->p4() + theTauJet->p4()).M();
437 
438  // double mtElecCaloMEt = calcMt(theElectron->px(), theElectron->py(),
439  // caloMEt.px(), caloMEt.py());
440  double mtElecPFMEt =
441  calcMt(theElectron->px(), theElectron->py(), pfMEt.px(), pfMEt.py());
442 
443  // double pZetaCaloMEt = calcPzeta(theElectron->p4(), theTauJet->p4(),
444  // caloMEt.px(), caloMEt.py());
445  // double pZetaPFMEt = calcPzeta(theElectron->p4(), theTauJet->p4(),
446  // pfMEt.px(), pfMEt.py());
447 
448  //-----------------------------------------------------------------------------
449  // apply selection criteria; fill histograms
450  //-----------------------------------------------------------------------------
451 
452  //--- fill electron multiplicity histogram
453  unsigned numIdElectrons = 0;
454  for (reco::GsfElectronCollection::const_iterator electron =
455  electrons->begin();
456  electron != electrons->end(); ++electron) {
457  if (passesElectronId(*electron)) {
458  ++numIdElectrons;
459  }
460  }
461 
462  // hNumIdElectrons_->Fill(numIdElectrons);
463 
465 
466  bool isSelected = false;
467  bool fullSelect = false;
468  int cutFlowStatus = -1;
469 
470  if (mElecTau > visMassCut_) {
471  cutFlowStatus = kPassedPreselection;
472  }
473  if (cutFlowStatus == kPassedPreselection &&
474  (isTriggered || hltPaths_.size() == 0)) {
475  cutFlowStatus = kPassedTrigger;
476  }
477  if (cutFlowStatus == kPassedTrigger && passesElectronId(*theElectron)) {
478  cutFlowStatus = kPassedElectronId;
479  hElectronTrackIsoPt_->Fill(theElectronTrackIsoPt);
480  }
481  if (cutFlowStatus == kPassedElectronId &&
482  theElectronTrackIsoPt < electronTrackIsoCut_) {
483  cutFlowStatus = kPassedElectronTrackIso;
484  hElectronEcalIsoPt_->Fill(theElectronEcalIsoPt);
485  }
486  if (cutFlowStatus == kPassedElectronTrackIso &&
487  theElectronEcalIsoPt < electronEcalIsoCut_) {
488  cutFlowStatus = kPassedElectronEcalIso;
489  }
490  if (cutFlowStatus == kPassedElectronEcalIso &&
491  theTauDiscrByLeadTrackFinding > 0.5) {
492  cutFlowStatus = kPassedTauLeadTrack;
493  // if ( theTauJet->leadTrack().isAvailable() )
494  // hTauLeadTrackPt_->Fill(theTauJet->leadTrack()->pt());
495  }
496  if (cutFlowStatus == kPassedTauLeadTrack &&
497  theTauDiscrByLeadTrackPtCut > 0.5) {
498  cutFlowStatus = kPassedTauLeadTrackPt;
499  // hTauTrackIsoPt_->Fill(theTauJet->isolationPFChargedHadrCandsPtSum());
500  }
501  if (cutFlowStatus == kPassedTauLeadTrackPt &&
502  theTauDiscrAgainstElectrons > 0.5) {
503  cutFlowStatus = kPassedTauDiscrAgainstElectrons;
504  // hTauDiscrAgainstMuons_->Fill(theTauDiscrAgainstMuons);
505  }
506  if (cutFlowStatus == kPassedTauDiscrAgainstElectrons &&
507  theTauDiscrAgainstMuons > 0.5) {
508  cutFlowStatus = kPassedTauDiscrAgainstMuons;
509  isSelected = true;
510  }
511  if (cutFlowStatus == kPassedTauDiscrAgainstMuons &&
512  theTauDiscrByTrackIso > 0.5) {
513  cutFlowStatus = kPassedTauTrackIso;
514  // hTauEcalIsoPt_->Fill(theTauJet->isolationPFGammaCandsEtSum());
515  }
516  if (cutFlowStatus == kPassedTauTrackIso && theTauDiscrByEcalIso > 0.5) {
517  cutFlowStatus = kPassedTauEcalIso;
518  fullSelect = true;
519  // hTauDiscrAgainstElectrons_->Fill(theTauDiscrAgainstElectrons);
520  }
521 
522  for (int iCut = 1; iCut <= cutFlowStatus; ++iCut) {
523  hCutFlowSummary_->Fill(iCut);
524  }
525 
526  if (isSelected) {
527  hElectronPt_->Fill(theElectron->pt());
528  hElectronEta_->Fill(theElectron->eta());
529  hElectronPhi_->Fill(theElectron->phi());
530 
531  hTauJetPt_->Fill(theTauJet->pt());
532  hTauJetEta_->Fill(theTauJet->eta());
533  // hTauJetPhi_->Fill(theTauJet->phi());
534 
535  // hTauJetCharge_->Fill(theTauJet->charge());
536  // if ( theTauJet->signalTracks().isAvailable() )
537  // hTauJetNumSignalTracks_->Fill(theTauJet->signalTracks().size());
538  // if ( theTauJet->isolationTracks().isAvailable() )
539  // hTauJetNumIsoTracks_->Fill(theTauJet->isolationTracks().size());
540 
541  if (fullSelect) {
542  hVisMass_->Fill(mElecTau);
543  }
544  // hMtElecCaloMEt_->Fill(mtElecCaloMEt);
545  hMtElecPFMEt_->Fill(mtElecPFMEt);
546  // hPzetaCaloMEt_->Fill(pZetaCaloMEt);
547  // hPzetaPFMEt_->Fill(pZetaPFMEt);
548  hElecTauAcoplanarity_->Fill(dPhiElecTau);
549  hElecTauCharge_->Fill(theElectron->charge() * theTauJet->charge());
550 
551  if (theEventVertex) {
552  // hVertexChi2_->Fill(theEventVertex->normalizedChi2());
553  hVertexZ_->Fill(theEventVertex->z());
554  // hVertexD0_->Fill(getVertexD0(*theEventVertex, *beamSpot));
555  }
556 
557  hCaloMEtPt_->Fill(caloMEt.pt());
558  // hCaloMEtPhi_->Fill(caloMEt.phi());
559 
560  hPFMEtPt_->Fill(pfMEt.pt());
561  // hPFMEtPhi_->Fill(pfMEt.phi());
562  }
563 
564  if (isSelected) ++numEventsSelected_;
565 }
566 
568  edm::LogInfo("EwkElecTauHistManager") << "Filter-Statistics Summary:"
569  << std::endl << " Events analyzed = "
570  << numEventsAnalyzed_ << std::endl
571  << " Events selected = "
573  if (numEventsAnalyzed_ > 0) {
574  double eff = numEventsSelected_ / (double)numEventsAnalyzed_;
575  edm::LogInfo("") << "Overall efficiency = " << std::setprecision(4)
576  << eff * 100. << " +/- " << std::setprecision(4)
577  << TMath::Sqrt(eff * (1 - eff) / numEventsAnalyzed_) * 100.
578  << ")%";
579  }
580 }
581 
582 //-------------------------------------------------------------------------------
583 // code specific to Z --> mu + tau-jet channel
584 //-------------------------------------------------------------------------------
585 
587 
590 
608 
609 #include "TMath.h"
610 
611 #include <iostream>
612 #include <iomanip>
613 
615  DQMStore* dqmStore)
616  : dqmStore_(dqmStore),
617  dqmDirectory_(cfg.getParameter<std::string>("dqmDirectory")),
618  numEventsAnalyzed_(0),
619  numEventsSelected_(0),
620  cfgError_(0),
621  numWarningsTriggerResults_(0),
622  numWarningsHLTpath_(0),
623  numWarningsVertex_(0),
624  numWarningsBeamSpot_(0),
625  numWarningsMuon_(0),
626  numWarningsTauJet_(0),
627  numWarningsTauDiscrByLeadTrackFinding_(0),
628  numWarningsTauDiscrByLeadTrackPtCut_(0),
629  numWarningsTauDiscrByTrackIso_(0),
630  numWarningsTauDiscrByEcalIso_(0),
631  numWarningsTauDiscrAgainstMuons_(0),
632  numWarningsCaloMEt_(0),
633  numWarningsPFMEt_(0) {
635  cfg.getParameter<edm::InputTag>("triggerResultsSource");
636  vertexSource_ = cfg.getParameter<edm::InputTag>("vertexSource");
637  beamSpotSource_ = cfg.getParameter<edm::InputTag>("beamSpotSource");
638  muonSource_ = cfg.getParameter<edm::InputTag>("muonSource");
639  tauJetSource_ = cfg.getParameter<edm::InputTag>("tauJetSource");
640  caloMEtSource_ = cfg.getParameter<edm::InputTag>("caloMEtSource");
641  pfMEtSource_ = cfg.getParameter<edm::InputTag>("pfMEtSource");
642 
644  cfg.getParameter<edm::InputTag>("tauDiscrByLeadTrackFinding");
646  cfg.getParameter<edm::InputTag>("tauDiscrByLeadTrackPtCut");
647  tauDiscrByTrackIso_ = cfg.getParameter<edm::InputTag>("tauDiscrByTrackIso");
648  tauDiscrByEcalIso_ = cfg.getParameter<edm::InputTag>("tauDiscrByEcalIso");
650  cfg.getParameter<edm::InputTag>("tauDiscrAgainstMuons");
651 
652  hltPaths_ = cfg.getParameter<vstring>("hltPaths");
653 
654  muonEtaCut_ = cfg.getParameter<double>("muonEtaCut");
655  muonPtCut_ = cfg.getParameter<double>("muonPtCut");
656  muonTrackIsoCut_ = cfg.getParameter<double>("muonTrackIsoCut");
657  muonEcalIsoCut_ = cfg.getParameter<double>("muonEcalIsoCut");
658  muonCombIsoCut_ = cfg.getParameter<double>("muonCombIsoCut");
659  std::string muonIsoMode_string = cfg.getParameter<std::string>("muonIsoMode");
660  muonIsoMode_ = getIsoMode(muonIsoMode_string, cfgError_);
661 
662  tauJetEtaCut_ = cfg.getParameter<double>("tauJetEtaCut");
663  tauJetPtCut_ = cfg.getParameter<double>("tauJetPtCut");
664 
665  visMassCut_ = cfg.getParameter<double>("visMassCut");
666  deltaRCut_ = cfg.getParameter<double>("deltaRCut");
667 
668  maxNumWarnings_ = cfg.exists("maxNumWarnings")
669  ? cfg.getParameter<int>("maxNumWarnings")
670  : 1;
671 }
672 
675 
676  // hNumGlobalMuons_ = dqmStore_->book1D("NumGlobalMuons" , "Num. global
677  // Muons", 5, -0.5, 4.5);
678  hMuonPt_ = dqmStore_->book1D("MuonPt", "P_{T}^{#mu}", 20, 0., 100.);
679  hMuonEta_ = dqmStore_->book1D("MuonEta", "#eta_{#mu}", 20, -4.0, +4.0);
680  hMuonPhi_ = dqmStore_->book1D("MuonPhi", "#phi_{#mu}", 20, -TMath::Pi(),
681  +TMath::Pi());
683  dqmStore_->book1D("MuonTrackIsoPt", "Muon Track Iso.", 20, -0.01, 10.);
685  dqmStore_->book1D("MuonEcalIsoPt", "Muon Ecal Iso.", 20, -0.01, 10.);
687  dqmStore_->book1D("MuonCombIsoPt", "Muon Comb Iso.", 20, -0.01, 1.);
688 
689  hTauJetPt_ = dqmStore_->book1D("TauJetPt", "P_{T}^{#tau-Jet}", 20, 0., 100.);
690  hTauJetEta_ =
691  dqmStore_->book1D("TauJetEta", "#eta_{#tau-Jet}", 20, -4.0, +4.0);
692  hTauJetPhi_ = dqmStore_->book1D("TauJetPhi", "#phi_{#tau-Jet}", 20,
693  -TMath::Pi(), +TMath::Pi());
694  hTauLeadTrackPt_ = dqmStore_->book1D("TauLeadTrackPt",
695  "P_{T}^{#tau-Jetldg trk}", 20, 0., 50.);
697  dqmStore_->book1D("TauTrackIsoPt", "Tau Track Iso.", 20, -0.01, 40.);
699  dqmStore_->book1D("TauEcalIsoPt", "Tau Ecal Iso.", 10, -0.01, 10.);
701  "TauDiscrAgainstMuons", "Tau Discr. against Muons", 2, -0.5, +1.5);
702  // hTauJetCharge_ = dqmStore_->book1D("TauJetCharge" , "Q_{#tau-Jet}", 11,
703  // -5.5, +5.5);
705  "TauJetNumSignalTracks", "Num. Tau signal Cone Tracks", 20, -0.5, +19.5);
707  "TauJetNumIsoTracks", "Num. Tau isolation Cone Tracks", 20, -0.5, +19.5);
708 
709  hVisMass_ =
710  dqmStore_->book1D("VisMass", "#mu + #tau-Jet visible Mass", 20, 0., 120.);
712  "VisMassFinal", "#mu + #tau-Jet visible final Mass", 20, 0., 120.);
713  // hMtMuCaloMEt_ = dqmStore_->book1D("MtMuCaloMEt", "#mu + E_{T}^{miss} (Calo)
714  // transverse Mass", 20, 20., 120.);
716  "MtMuPFMEt", "#mu + E_{T}^{miss} (PF) transverse Mass", 20, 0., 120.);
717  // hPzetaCaloMEt_ = dqmStore_->book1D("PzetaCaloMEt", "P_{#zeta} -
718  // 1.5*P_{#zeta}^{vis} (Calo)", 20, -40., 40.);
719  // hPzetaPFMEt_ = dqmStore_->book1D("PzetaPFMEt", "P_{#zeta} -
720  // 1.5*P_{#zeta}^{vis} (PF)", 20, -40., 40.);
722  dqmStore_->book1D("MuTauAcoplanarity", "#Delta #phi_{#mu #tau-Jet}", 20,
723  -TMath::Pi(), +TMath::Pi());
724  // hMuTauCharge_ = dqmStore_->book1D("MuTauCharge" , "Q_{#mu + #tau-Jet}", 11,
725  // -5.5, +5.5);
726  hMuTauDeltaR_ =
727  dqmStore_->book1D("MuTauDeltaR", "#Delta R_{#mu #tau-Jet}", 20, 0, 5);
728  // hVertexChi2_ = dqmStore_->book1D("VertexChi2", "Event Vertex #chi^{2} /
729  // n.d.o.f.", 20, 0., 2.0);
730  hVertexZ_ =
731  dqmStore_->book1D("VertexZ", "Event Vertex z-Position", 20, -25., +25.);
732  // hVertexD0_ = dqmStore_->book1D("VertexD0", "Event Vertex d_{0}", 20,
733  // -0.0001, 0.05);
734 
735  hCaloMEtPt_ =
736  dqmStore_->book1D("CaloMEtPt", "E_{T}^{miss} (Calo)", 20, 0., 100.);
737  // hCaloMEtPhi_ = dqmStore_->book1D("CaloMEtPhi", "#phi^{miss} (Calo)", 20,
738  // -TMath::Pi(), +TMath::Pi());
739 
740  hPFMEtPt_ = dqmStore_->book1D("PFMEtPt", "E_{T}^{miss} (PF)", 20, 0., 100.);
741  // hPFMEtPhi_ = dqmStore_->book1D("PFMEtPhi", "#phi^{miss} (PF)", 20,
742  // -TMath::Pi(), +TMath::Pi());
743 
745  dqmStore_->book1D("CutFlowSummary", "Cut-flow Summary", 11, 0.5, 11.5);
751  hCutFlowSummary_->setBinLabel(kPassedTauLeadTrack, "#tau lead. Track");
753  "#tau lead. Track P_{T}");
754  hCutFlowSummary_->setBinLabel(kPassedTauTrackIso, "#tau Track Iso.");
755  hCutFlowSummary_->setBinLabel(kPassedTauEcalIso, "#tau Ecal Iso.");
757  "#tau anti-#mu Discr.");
758  // hCutFlowSummary_->setBinLabel(kPassedMuonCombIso, "#mu Comb Iso.");
759 
760  hCutFlowSummary_->setBinLabel(kPassedDeltaR, "#DeltaR(#mu,#tau) ");
761 }
762 
764  const edm::EventSetup& es) {
765  if (cfgError_) return;
766 
767  //-----------------------------------------------------------------------------
768  // access event-level information
769  //-----------------------------------------------------------------------------
770 
771  bool readError = false;
772 
773  //--- get decision of high-level trigger for the event
775  readEventData(evt, triggerResultsSource_, hltDecision,
777  "Failed to access Trigger results");
778  if (readError) return;
779 
780  const edm::TriggerNames& triggerNames = evt.triggerNames(*hltDecision);
781 
782  bool isTriggered = false;
783  for (vstring::const_iterator hltPath = hltPaths_.begin();
784  hltPath != hltPaths_.end(); ++hltPath) {
785  unsigned int index = triggerNames.triggerIndex(*hltPath);
786  if (index < triggerNames.size()) {
787  if (hltDecision->accept(index)) isTriggered = true;
788  } else {
790  edm::LogWarning("EwkMuTauHistManager")
791  << " Undefined HLT path = " << (*hltPath) << " !!";
793  continue;
794  }
795  }
796 
797  //--- get reconstructed primary event vertex of the event
798  // (take as "the" primary event vertex the first entry in the collection
799  // of vertex objects, corresponding to the vertex associated to the highest
800  // Pt sum of tracks)
802  readEventData(evt, vertexSource_, vertexCollection, numWarningsVertex_,
803  maxNumWarnings_, readError,
804  "Failed to access Vertex collection");
805  if (readError) return;
806 
807  const reco::Vertex* theEventVertex =
808  (vertexCollection->size() > 0) ? &(vertexCollection->at(0)) : 0;
809 
810  //--- get beam-spot (expected vertex position) for the event
813  maxNumWarnings_, readError, "Failed to access Beam-spot");
814  if (readError) return;
815 
816  //--- get collections of reconstructed muons from the event
819  readError, "Failed to access Muon collection");
820  if (readError) return;
821 
822  const reco::Muon* theMuon = getTheMuon(*muons, muonEtaCut_, muonPtCut_);
823 
824  double theMuonTrackIsoPt = 1.e+3;
825  double theMuonEcalIsoPt = 1.e+3;
826  double theMuonCombIsoPt = 1.e+3;
827 
828  if (theMuon) {
829  theMuonTrackIsoPt = theMuon->isolationR05().sumPt;
830  // mu.isolationR05().emEt + mu.isolationR05().hadEt +
831  // mu.isolationR05().sumPt
832  theMuonEcalIsoPt = theMuon->isolationR05().emEt;
833 
834  if (muonIsoMode_ == kRelativeIso && theMuon->pt() > 0.) {
835  theMuonTrackIsoPt /= theMuon->pt();
836  theMuonEcalIsoPt /= theMuon->pt();
837  theMuonCombIsoPt =
838  (theMuon->isolationR05().sumPt + theMuon->isolationR05().emEt) /
839  theMuon->pt();
840  // std::cout<<"Rel Iso ="<<theMuonCombIsoPt<<std::endl;
841  }
842  }
843 
844  //--- get collections of reconstructed tau-jets from the event
847  maxNumWarnings_, readError,
848  "Failed to access Tau-jet collection");
849  if (readError) return;
850 
851  //--- get collections of tau-jet discriminators for those tau-jets
852  edm::Handle<reco::PFTauDiscriminator> tauDiscrByLeadTrackFinding;
853  readEventData(evt, tauDiscrByLeadTrackFinding_, tauDiscrByLeadTrackFinding,
855  readError,
856  "Failed to access collection of pf. Tau discriminators by "
857  "leading Track finding");
858  edm::Handle<reco::PFTauDiscriminator> tauDiscrByLeadTrackPtCut;
859  readEventData(evt, tauDiscrByLeadTrackPtCut_, tauDiscrByLeadTrackPtCut,
861  readError,
862  "Failed to access collection of pf. Tau discriminators by "
863  "leading Track Pt cut");
864  edm::Handle<reco::PFTauDiscriminator> tauDiscrByTrackIso;
865  readEventData(evt, tauDiscrByTrackIso_, tauDiscrByTrackIso,
867  "Failed to access collection of pf. Tau discriminators by "
868  "Track isolation");
869  edm::Handle<reco::PFTauDiscriminator> tauDiscrByEcalIso;
870  readEventData(evt, tauDiscrByTrackIso_, tauDiscrByEcalIso,
872  "Failed to access collection of pf. Tau discriminators by ECAL "
873  "isolation");
874  edm::Handle<reco::PFTauDiscriminator> tauDiscrAgainstMuons;
876  evt, tauDiscrAgainstMuons_, tauDiscrAgainstMuons,
878  "Failed to access collection of pf. Tau discriminators against Muons");
879  if (readError) return;
880 
881  int theTauJetIndex = -1;
882  const reco::PFTau* theTauJet =
883  getTheTauJet(*tauJets, tauJetEtaCut_, tauJetPtCut_, theTauJetIndex);
884 
885  double theTauDiscrByLeadTrackFinding = -1.;
886  double theTauDiscrByLeadTrackPtCut = -1.;
887  double theTauDiscrByTrackIso = -1.;
888  double theTauDiscrByEcalIso = -1.;
889  double theTauDiscrAgainstMuons = -1.;
890  if (theTauJetIndex != -1) {
891  reco::PFTauRef theTauJetRef(tauJets, theTauJetIndex);
892  theTauDiscrByLeadTrackFinding = (*tauDiscrByLeadTrackFinding)[theTauJetRef];
893  theTauDiscrByLeadTrackPtCut = (*tauDiscrByLeadTrackPtCut)[theTauJetRef];
894  theTauDiscrByTrackIso = (*tauDiscrByTrackIso)[theTauJetRef];
895  theTauDiscrByEcalIso = (*tauDiscrByEcalIso)[theTauJetRef];
896  theTauDiscrAgainstMuons = (*tauDiscrAgainstMuons)[theTauJetRef];
897  }
898 
899  //--- get missing transverse momentum
900  // measured by calorimeters/reconstructed by particle-flow algorithm
901  edm::Handle<reco::CaloMETCollection> caloMEtCollection;
902  readEventData(evt, caloMEtSource_, caloMEtCollection, numWarningsCaloMEt_,
903  maxNumWarnings_, readError,
904  "Failed to access calo. MET collection");
905  if (readError) return;
906 
907  const reco::CaloMET& caloMEt = caloMEtCollection->at(0);
908 
909  edm::Handle<reco::PFMETCollection> pfMEtCollection;
910  readEventData(evt, pfMEtSource_, pfMEtCollection, numWarningsPFMEt_,
911  maxNumWarnings_, readError,
912  "Failed to access pf. MET collection");
913  if (readError) return;
914 
915  const reco::PFMET& pfMEt = pfMEtCollection->at(0);
916 
917  if (!(theMuon && theTauJet && theTauJetIndex != -1)) return;
918 
919  //-----------------------------------------------------------------------------
920  // compute EWK tau analysis specific quantities
921  //-----------------------------------------------------------------------------
922 
923  double dPhiMuTau = calcDeltaPhi(theMuon->phi(), theTauJet->phi());
924  // double dRMuTau = calcDeltaR(theMuon->p4(), theTauJet->p4());
925  double dRMuTau =
926  fabs(ROOT::Math::VectorUtil::DeltaR(theMuon->p4(), theTauJet->p4()));
927  double mMuTau = (theMuon->p4() + theTauJet->p4()).M();
928 
929  // double mtMuCaloMEt = calcMt(theMuon->px(), theMuon->px(), caloMEt.px(),
930  // caloMEt.py());
931  double mtMuPFMEt =
932  calcMt(theMuon->px(), theMuon->px(), pfMEt.px(), pfMEt.py());
933 
934  // double pZetaCaloMEt = calcPzeta(theMuon->p4(), theTauJet->p4(),
935  // caloMEt.px(), caloMEt.py());
936  // double pZetaPFMEt = calcPzeta(theMuon->p4(), theTauJet->p4(), pfMEt.px(),
937  // pfMEt.py());
938 
939  //-----------------------------------------------------------------------------
940  // apply selection criteria; fill histograms
941  //-----------------------------------------------------------------------------
942 
943  //--- fill muon multiplicity histogram
944  unsigned numGlobalMuons = 0;
945  for (reco::MuonCollection::const_iterator muon = muons->begin();
946  muon != muons->end(); ++muon) {
947  if (muon->isGlobalMuon()) {
948  ++numGlobalMuons;
949  }
950  }
951 
952  // hNumGlobalMuons_->Fill(numGlobalMuons);
953 
955 
956  bool isSelected = false;
957  int cutFlowStatus = -1;
958 
959  // if ( muonIsoMode_ == kAbsoluteIso){
960  if (mMuTau > visMassCut_) {
961  cutFlowStatus = kPassedPreselection;
962  }
963  if (cutFlowStatus == kPassedPreselection &&
964  (isTriggered || hltPaths_.size() == 0)) {
965  cutFlowStatus = kPassedTrigger;
966  }
967  if (cutFlowStatus == kPassedTrigger &&
968  (theMuon->isGlobalMuon() || theMuon->isTrackerMuon())) {
969  cutFlowStatus = kPassedMuonId;
970  }
971 
972  if (cutFlowStatus == kPassedMuonId && (theTauDiscrByLeadTrackFinding > 0.5) &&
973  (theTauJet->eta() < tauJetEtaCut_) && (theTauJet->pt() > tauJetPtCut_)) {
974  cutFlowStatus = kPassedTauLeadTrack;
975  }
976  if (cutFlowStatus == kPassedTauLeadTrack &&
977  theTauDiscrByLeadTrackPtCut > 0.5) {
978  cutFlowStatus = kPassedTauLeadTrackPt;
979  // hTauTrackIsoPt_->Fill(theTauJet->isolationPFChargedHadrCandsPtSum());
980  }
981  if (cutFlowStatus == kPassedTauLeadTrackPt && theTauDiscrAgainstMuons > 0.5) {
982  cutFlowStatus = kPassedTauDiscrAgainstMuons;
983  // hTauEcalIsoPt_->Fill(theTauJet->isolationPFGammaCandsEtSum());
984  }
985  if (cutFlowStatus == kPassedTauDiscrAgainstMuons && dRMuTau > deltaRCut_) {
986  cutFlowStatus = kPassedDeltaR;
987  // hTauDiscrAgainstMuons_->Fill(theTauDiscrAgainstMuons);
988 
989  hMuonPt_->Fill(theMuon->pt());
990  hMuonEta_->Fill(theMuon->eta());
991  hMuonPhi_->Fill(theMuon->phi());
992 
993  hTauJetPt_->Fill(theTauJet->pt());
994  hTauJetEta_->Fill(theTauJet->eta());
995  hTauJetPhi_->Fill(theTauJet->phi());
996 
997  // hTauJetCharge_->Fill(theTauJet->charge());
998  if (theTauJet->signalTracks().isAvailable())
1000  if (theTauJet->isolationTracks().isAvailable())
1001  hTauJetNumIsoTracks_->Fill(theTauJet->isolationTracks().size());
1002 
1003  hVisMass_->Fill(mMuTau);
1004  // hMtMuCaloMEt_->Fill(mtMuCaloMEt);
1005  hMtMuPFMEt_->Fill(mtMuPFMEt);
1006  // hPzetaCaloMEt_->Fill(pZetaCaloMEt);
1007  // hPzetaPFMEt_->Fill(pZetaPFMEt);
1008  hMuTauAcoplanarity_->Fill(dPhiMuTau);
1009  hMuTauDeltaR_->Fill(dRMuTau);
1010  // hMuTauCharge_->Fill(theMuon->charge() + theTauJet->charge());
1011 
1012  if (theEventVertex) {
1013  // hVertexChi2_->Fill(theEventVertex->normalizedChi2());
1014  hVertexZ_->Fill(theEventVertex->z());
1015  // hVertexD0_->Fill(getVertexD0(*theEventVertex, *beamSpot));
1016  }
1017 
1018  hCaloMEtPt_->Fill(caloMEt.pt());
1019  // hCaloMEtPhi_->Fill(caloMEt.phi());
1020 
1021  hPFMEtPt_->Fill(pfMEt.pt());
1022  // hPFMEtPhi_->Fill(pfMEt.phi());
1023  hMuonTrackIsoPt_->Fill(theMuonTrackIsoPt);
1024  hMuonEcalIsoPt_->Fill(theMuonEcalIsoPt);
1025  hMuonCombIsoPt_->Fill(theMuonCombIsoPt);
1026  // hMuonCombIsoPt_->Fill((theMuonTrackIsoPt+theMuonEcalIsoPt)/theMuon->pt());
1027 
1028  // std::cout<<"Rel Iso Hist =
1029  // "<<(theMuonTrackIsoPt+theMuonEcalIsoPt)/theMuon->pt()<<std::endl;
1032  hTauDiscrAgainstMuons_->Fill(theTauDiscrAgainstMuons);
1033  if (theTauJet->leadTrack().isAvailable())
1034  hTauLeadTrackPt_->Fill(theTauJet->leadTrack()->pt());
1035  }
1036 
1037  if ((cutFlowStatus == kPassedDeltaR) &&
1038  (((theMuonTrackIsoPt < muonTrackIsoCut_) &&
1039  (muonIsoMode_ == kAbsoluteIso)) ||
1040  ((1 > 0) && (muonIsoMode_ == kRelativeIso)))) {
1041  cutFlowStatus = kPassedMuonTrackIso;
1042  // isSelected = true;
1043  }
1044  if (cutFlowStatus == kPassedMuonTrackIso &&
1045  (((theMuonEcalIsoPt < muonEcalIsoCut_) &&
1046  (muonIsoMode_ == kAbsoluteIso)) ||
1047  ((theMuonCombIsoPt < muonCombIsoCut_) &&
1048  (muonIsoMode_ == kRelativeIso)))) {
1049  cutFlowStatus = kPassedMuonEcalIso;
1050  // isSelected = true;
1051  }
1052 
1053  if (cutFlowStatus == kPassedMuonEcalIso && theTauDiscrByTrackIso > 0.5) {
1054  cutFlowStatus = kPassedTauTrackIso;
1055  }
1056 
1057  if (cutFlowStatus == kPassedTauTrackIso && theTauDiscrByEcalIso > 0.5) {
1058  cutFlowStatus = kPassedTauEcalIso;
1059  isSelected = true;
1060  }
1061 
1062  for (int iCut = 1; iCut <= cutFlowStatus; ++iCut) {
1063  hCutFlowSummary_->Fill(iCut);
1064  }
1065 
1066  for (int iCut = 1; iCut <= cutFlowStatus; ++iCut) {
1067  hCutFlowSummary_->Fill(iCut);
1068  }
1069 
1070  // }
1071 
1072  if (isSelected) {
1073  hVisMassFinal_->Fill(mMuTau);
1075  }
1076 }
1077 
1079  edm::LogInfo("EwkMuTauHistManager") << "Filter-Statistics Summary:"
1080  << std::endl << " Events analyzed = "
1081  << numEventsAnalyzed_ << std::endl
1082  << " Events selected = "
1083  << numEventsSelected_;
1084  if (numEventsAnalyzed_ > 0) {
1085  double eff = numEventsSelected_ / (double)numEventsAnalyzed_;
1086  edm::LogInfo("") << "Overall efficiency = " << std::setprecision(4)
1087  << eff * 100. << " +/- " << std::setprecision(4)
1088  << TMath::Sqrt(eff * (1 - eff) / numEventsAnalyzed_) * 100.
1089  << ")%";
1090  }
1091 }
1092 
1093 //-------------------------------------------------------------------------------
1094 // common auxiliary functions used by different channels
1095 //-------------------------------------------------------------------------------
1096 
1098 
1099 #include <TMath.h>
1100 
1101 int getIsoMode(const std::string& isoMode_string, int& error) {
1102  int isoMode_int;
1103  if (isoMode_string == "absoluteIso") {
1104  isoMode_int = kAbsoluteIso;
1105  } else if (isoMode_string == "relativeIso") {
1106  isoMode_int = kRelativeIso;
1107  } else {
1108  edm::LogError("getIsoMode") << " Failed to decode isoMode string = "
1109  << isoMode_string << " !!";
1110  isoMode_int = kUndefinedIso;
1111  error = 1;
1112  }
1113  return isoMode_int;
1114 }
1115 
1116 //
1117 //-----------------------------------------------------------------------------------------------------------------------
1118 //
1119 
1120 double calcDeltaPhi(double phi1, double phi2) {
1121  double deltaPhi = phi1 - phi2;
1122 
1123  if (deltaPhi < 0.) deltaPhi = -deltaPhi;
1124 
1125  if (deltaPhi > TMath::Pi()) deltaPhi = 2 * TMath::Pi() - deltaPhi;
1126 
1127  return deltaPhi;
1128 }
1129 
1130 double calcMt(double px1, double py1, double px2, double py2) {
1131  double pt1 = TMath::Sqrt(px1 * px1 + py1 * py1);
1132  double pt2 = TMath::Sqrt(px2 * px2 + py2 * py2);
1133 
1134  double p1Dotp2 = px1 * px2 + py1 * py2;
1135  double cosAlpha = p1Dotp2 / (pt1 * pt2);
1136 
1137  return TMath::Sqrt(2 * pt1 * pt2 * (1 - cosAlpha));
1138 }
1139 
1141  const reco::Candidate::LorentzVector& p2, double pxMEt,
1142  double pyMEt) {
1143  double cosPhi1 = cos(p1.phi());
1144  double sinPhi1 = sin(p1.phi());
1145  double cosPhi2 = cos(p2.phi());
1146  double sinPhi2 = sin(p2.phi());
1147  double zetaX = cosPhi1 + cosPhi2;
1148  double zetaY = sinPhi1 + sinPhi2;
1149  double zetaR = TMath::Sqrt(zetaX * zetaX + zetaY * zetaY);
1150  if (zetaR > 0.) {
1151  zetaX /= zetaR;
1152  zetaY /= zetaR;
1153  }
1154 
1155  double pxVis = p1.px() + p2.px();
1156  double pyVis = p1.py() + p2.py();
1157  double pZetaVis = pxVis * zetaX + pyVis * zetaY;
1158 
1159  double px = pxVis + pxMEt;
1160  double py = pyVis + pyMEt;
1161  double pZeta = px * zetaX + py * zetaY;
1162 
1163  return pZeta - 1.5 * pZetaVis;
1164 }
1165 
1166 //
1167 //-----------------------------------------------------------------------------------------------------------------------
1168 //
1169 
1171  if ((TMath::Abs(electron.eta()) < 1.479 ||
1172  TMath::Abs(electron.eta()) > 1.566) && // cut ECAL barrel/endcap crack
1173  electron.deltaPhiSuperClusterTrackAtVtx() < 0.8 &&
1174  electron.deltaEtaSuperClusterTrackAtVtx() < 0.01 &&
1175  electron.sigmaIetaIeta() < 0.03) {
1176  return true;
1177  } else {
1178  return false;
1179  }
1180 }
1181 
1183  if (passesElectronPreId(electron) &&
1184  ((TMath::Abs(electron.eta()) > 1.566 && // electron reconstructed in ECAL
1185  // endcap
1186  electron.sigmaEtaEta() < 0.03 && electron.hcalOverEcal() < 0.05 &&
1187  TMath::Abs(electron.deltaEtaSuperClusterTrackAtVtx()) < 0.009 &&
1188  TMath::Abs(electron.deltaPhiSuperClusterTrackAtVtx()) < 0.7) ||
1189  (TMath::Abs(electron.eta()) < 1.479 && // electron reconstructed in ECAL
1190  // barrel
1191  electron.sigmaEtaEta() < 0.01 && electron.hcalOverEcal() < 0.12 &&
1192  TMath::Abs(electron.deltaEtaSuperClusterTrackAtVtx()) < 0.007 &&
1193  TMath::Abs(electron.deltaPhiSuperClusterTrackAtVtx()) < 0.8))) {
1194  return true;
1195  } else {
1196  return false;
1197  }
1198 }
1199 
1200 //
1201 //-----------------------------------------------------------------------------------------------------------------------
1202 //
1203 
1205  const reco::GsfElectronCollection& electrons, double electronEtaCut,
1206  double electronPtCut) {
1207  const reco::GsfElectron* theElectron = 0;
1208 
1209  for (reco::GsfElectronCollection::const_iterator electron = electrons.begin();
1210  electron != electrons.end(); ++electron) {
1211  if (TMath::Abs(electron->eta()) < electronEtaCut &&
1212  electron->pt() > electronPtCut && passesElectronPreId(*electron)) {
1213  if (theElectron == 0 || electron->pt() > theElectron->pt())
1214  theElectron = &(*electron);
1215  }
1216  }
1217 
1218  return theElectron;
1219 }
1220 
1222  double muonEtaCut, double muonPtCut) {
1223  const reco::Muon* theMuon = 0;
1224 
1225  for (reco::MuonCollection::const_iterator muon = muons.begin();
1226  muon != muons.end(); ++muon) {
1227  if (TMath::Abs(muon->eta()) < muonEtaCut && muon->pt() > muonPtCut) {
1228  if (theMuon == 0 || muon->pt() > theMuon->pt()) theMuon = &(*muon);
1229  }
1230  }
1231 
1232  return theMuon;
1233 }
1234 
1236  double tauJetEtaCut, double tauJetPtCut,
1237  int& theTauJetIndex) {
1238  const reco::PFTau* theTauJet = 0;
1239  theTauJetIndex = -1;
1240 
1241  int numTauJets = tauJets.size();
1242  for (int iTauJet = 0; iTauJet < numTauJets; ++iTauJet) {
1243  const reco::PFTau& tauJet = tauJets.at(iTauJet);
1244 
1245  if (fabs(tauJet.eta()) < tauJetEtaCut && tauJet.pt() > tauJetPtCut) {
1246  if (theTauJet == 0 || tauJet.pt() > theTauJet->pt()) {
1247  theTauJet = &tauJet;
1248  theTauJetIndex = iTauJet;
1249  }
1250  }
1251  }
1252 
1253  return theTauJet;
1254 }
1255 
1256 //
1257 //-----------------------------------------------------------------------------------------------------------------------
1258 //
1259 
1260 double getVertexD0(const reco::Vertex& vertex, const reco::BeamSpot& beamSpot) {
1261  double dX = vertex.x() - beamSpot.x0();
1262  double dY = vertex.y() - beamSpot.y0();
1263  return TMath::Sqrt(dX * dX + dY * dY);
1264 }
1265 
1266 // Local Variables:
1267 // show-trailing-whitespace: t
1268 // truncate-lines: t
1269 // End:
MonitorElement * hCutFlowSummary_
Definition: EwkTauDQM.h:313
edm::InputTag tauDiscrByEcalIso_
Definition: EwkTauDQM.h:247
long numWarningsTauDiscrByEcalIso_
Definition: EwkTauDQM.h:193
bool isAvailable() const
Definition: Ref.h:614
const double Pi
void analyze(const edm::Event &, const edm::EventSetup &)
Definition: EwkTauDQM.cc:74
edm::InputTag beamSpotSource_
Definition: EwkTauDQM.h:238
T getParameter(std::string const &) const
double calcDeltaPhi(double phi1, double phi2)
Definition: EwkTauDQM.cc:1120
double muonCombIsoCut_
Definition: EwkTauDQM.h:258
virtual reco::TrackRef leadTrack() const
Definition: BaseTau.cc:26
MonitorElement * hPFMEtPt_
Definition: EwkTauDQM.h:158
double calcMt(double px1, double py1, double px2, double py2)
Definition: EwkTauDQM.cc:1130
edm::InputTag tauDiscrByLeadTrackFinding_
Definition: EwkTauDQM.h:244
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:199
float isolationPFGammaCandsEtSum() const
Definition: PFTau.cc:202
MonitorElement * hTauJetPhi_
Definition: EwkTauDQM.h:284
edm::InputTag pfMEtSource_
Definition: EwkTauDQM.h:242
edm::InputTag beamSpotSource_
Definition: EwkTauDQM.h:87
std::vector< PFTau > PFTauCollection
collection of PFTau objects
Definition: PFTauFwd.h:9
float sumPt
sum-pt of tracks
Definition: MuonIsolation.h:7
float isolationPFChargedHadrCandsPtSum() const
Definition: PFTau.cc:199
virtual float pt() const
transverse momentum
edm::InputTag tauDiscrByLeadTrackPtCut_
Definition: EwkTauDQM.h:94
const LorentzVector & p4(P4Kind kind) const
Definition: GsfElectron.cc:223
MonitorElement * hElecTauAcoplanarity_
Definition: EwkTauDQM.h:148
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:971
edm::InputTag electronSource_
Definition: EwkTauDQM.h:88
int getIsoMode(const std::string &isoMode_string, int &error)
Definition: EwkTauDQM.cc:1101
edm::InputTag tauDiscrByTrackIso_
Definition: EwkTauDQM.h:246
long numWarningsTauDiscrAgainstMuons_
Definition: EwkTauDQM.h:346
MonitorElement * hVisMass_
Definition: EwkTauDQM.h:143
EwkMuTauHistManager(const edm::ParameterSet &, DQMStore *)
Definition: EwkTauDQM.cc:614
edm::InputTag tauDiscrByLeadTrackFinding_
Definition: EwkTauDQM.h:93
long numWarningsTauDiscrByEcalIso_
Definition: EwkTauDQM.h:345
double getVertexD0(const reco::Vertex &vertex, const reco::BeamSpot &beamSpot)
Definition: EwkTauDQM.cc:1260
virtual const reco::TrackRefVector & isolationTracks() const
Definition: BaseTau.cc:30
virtual float phi() const
momentum azimuthal angle
bool isTrackerMuon() const
Definition: Muon.h:219
long numWarningsTauDiscrByTrackIso_
Definition: EwkTauDQM.h:344
double y() const
y coordinate
Definition: Vertex.h:110
MonitorElement * hMuonPhi_
Definition: EwkTauDQM.h:277
std::vector< std::string > vstring
Definition: EwkTauDQM.h:251
MonitorElement * hElectronEcalIsoPt_
Definition: EwkTauDQM.h:128
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
MonitorElement * hTauEcalIsoPt_
Definition: EwkTauDQM.h:287
std::string dqmDirectory_
Definition: EwkTauDQM.h:41
long numWarningsTauDiscrByLeadTrackFinding_
Definition: EwkTauDQM.h:190
bool exists(std::string const &parameterName) const
checks if a parameter exists
double electronEcalIsoCut_
Definition: EwkTauDQM.h:107
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)
unsigned numEventsSelected_
Definition: EwkTauDQM.h:178
bool isGlobalMuon() const
Definition: Muon.h:218
MonitorElement * hPFMEtPt_
Definition: EwkTauDQM.h:310
unsigned numEventsSelected_
Definition: EwkTauDQM.h:330
std::string dqmDirectory_
Definition: EwkTauDQM.h:271
Strings::size_type size() const
Definition: TriggerNames.cc:39
edm::InputTag tauDiscrByLeadTrackPtCut_
Definition: EwkTauDQM.h:245
std::string dqmDirectoryName(const std::string &dqmRootDirectory, const std::string &dqmSubDirectory)
Definition: EwkTauDQM.cc:10
const MuonIsolation & isolationR05() const
Definition: Muon.h:159
MonitorElement * hCutFlowSummary_
Definition: EwkTauDQM.h:161
long numWarningsTauDiscrByLeadTrackPtCut_
Definition: EwkTauDQM.h:191
edm::InputTag caloMEtSource_
Definition: EwkTauDQM.h:90
EwkElecTauHistManager(const edm::ParameterSet &, DQMStore *)
Definition: EwkTauDQM.cc:120
double electronTrackIsoCut_
Definition: EwkTauDQM.h:106
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
tuple vertexCollection
edm::InputTag tauDiscrAgainstMuons_
Definition: EwkTauDQM.h:98
MonitorElement * hVertexZ_
Definition: EwkTauDQM.h:152
void fillHistograms(const edm::Event &, const edm::EventSetup &)
Definition: EwkTauDQM.cc:763
MonitorElement * hTauDiscrAgainstMuons_
Definition: EwkTauDQM.h:288
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
MonitorElement * hMuonEcalIsoPt_
Definition: EwkTauDQM.h:279
void fillHistograms(const edm::Event &, const edm::EventSetup &)
Definition: EwkTauDQM.cc:269
long numWarningsTauDiscrByTrackIso_
Definition: EwkTauDQM.h:192
void Fill(long long x)
MonitorElement * hElecTauCharge_
Definition: EwkTauDQM.h:149
double muonTrackIsoCut_
Definition: EwkTauDQM.h:256
int dqmError_
Definition: EwkTauDQM.h:42
edm::InputTag vertexSource_
Definition: EwkTauDQM.h:237
const reco::GsfElectron * getTheElectron(const reco::GsfElectronCollection &electrons, double electronEtaCut, double electronPtCut)
Definition: EwkTauDQM.cc:1204
MonitorElement * hElectronTrackIsoPt_
Definition: EwkTauDQM.h:127
MonitorElement * hTauJetNumSignalTracks_
Definition: EwkTauDQM.h:290
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:247
edm::InputTag tauJetSource_
Definition: EwkTauDQM.h:240
MonitorElement * hMuonEta_
Definition: EwkTauDQM.h:276
float sigmaIetaIeta() const
Definition: GsfElectron.h:402
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:32
bool passesElectronId(const reco::GsfElectron &electron)
Definition: EwkTauDQM.cc:1182
MonitorElement * hVisMassFinal_
Definition: EwkTauDQM.h:295
MonitorElement * hTauLeadTrackPt_
Definition: EwkTauDQM.h:285
EwkElecTauHistManager * elecTauHistManager_
Definition: EwkTauDQM.h:45
MonitorElement * hElectronEta_
Definition: EwkTauDQM.h:125
virtual float eta() const
momentum pseudorapidity
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:250
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:142
float emEt
ecal sum-Et
Definition: MuonIsolation.h:8
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
int maxNumWarnings_
Definition: EwkTauDQM.h:43
edm::InputTag caloMEtSource_
Definition: EwkTauDQM.h:241
T Abs(T a)
Definition: MathUtil.h:49
long numWarningsTriggerResults_
Definition: EwkTauDQM.h:336
std::string dqmDirectory_
Definition: EwkTauDQM.h:120
virtual int charge() const
electric charge
float hcalOverEcal() const
Definition: GsfElectron.h:410
long numWarningsTauDiscrAgainstMuons_
Definition: EwkTauDQM.h:195
float dr03TkSumPt() const
Definition: GsfElectron.h:477
MonitorElement * hMtMuPFMEt_
Definition: EwkTauDQM.h:297
MonitorElement * hCaloMEtPt_
Definition: EwkTauDQM.h:155
double z() const
y coordinate
Definition: Vertex.h:112
MonitorElement * hTauJetPt_
Definition: EwkTauDQM.h:282
const reco::Muon * getTheMuon(const reco::MuonCollection &muons, double muonEtaCut, double muonPtCut)
Definition: EwkTauDQM.cc:1221
edm::InputTag tauDiscrByEcalIso_
Definition: EwkTauDQM.h:96
MonitorElement * hVertexZ_
Definition: EwkTauDQM.h:304
const reco::PFTau * getTheTauJet(const reco::PFTauCollection &tauJets, double tauJetEtaCut, double tauJetPtCut, int &theTauJetIndex)
Definition: EwkTauDQM.cc:1235
virtual const reco::TrackRefVector & signalTracks() const
Definition: BaseTau.cc:28
MonitorElement * hTauJetPt_
Definition: EwkTauDQM.h:131
double p2[4]
Definition: TauolaWrapper.h:90
void beginJob()
Definition: EwkTauDQM.cc:67
MonitorElement * hTauTrackIsoPt_
Definition: EwkTauDQM.h:286
MonitorElement * hElectronPhi_
Definition: EwkTauDQM.h:126
double calcPzeta(const reco::Candidate::LorentzVector &p1, const reco::Candidate::LorentzVector &p2, double pxMEt, double pyMEt)
Definition: EwkTauDQM.cc:1140
edm::InputTag tauDiscrAgainstElectrons_
Definition: EwkTauDQM.h:97
MonitorElement * hCaloMEtPt_
Definition: EwkTauDQM.h:307
long numWarningsTauDiscrByLeadTrackFinding_
Definition: EwkTauDQM.h:342
MonitorElement * hMuonPt_
Definition: EwkTauDQM.h:275
~EwkTauDQM()
Definition: EwkTauDQM.cc:62
edm::InputTag tauDiscrByTrackIso_
Definition: EwkTauDQM.h:95
double x() const
x coordinate
Definition: Vertex.h:108
MonitorElement * hMuTauDeltaR_
Definition: EwkTauDQM.h:294
long numWarningsTriggerResults_
Definition: EwkTauDQM.h:184
DQMStore * dqmStore_
Definition: EwkTauDQM.h:116
virtual double px() const
x coordinate of momentum vector
edm::InputTag muonSource_
Definition: EwkTauDQM.h:239
MonitorElement * hMuTauAcoplanarity_
Definition: EwkTauDQM.h:300
MonitorElement * hTauJetNumIsoTracks_
Definition: EwkTauDQM.h:291
MonitorElement * hMuonCombIsoPt_
Definition: EwkTauDQM.h:280
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:41
edm::InputTag vertexSource_
Definition: EwkTauDQM.h:86
float dr03EcalRecHitSumEt() const
Definition: GsfElectron.h:478
bool passesElectronPreId(const reco::GsfElectron &electron)
Definition: EwkTauDQM.cc:1170
edm::InputTag pfMEtSource_
Definition: EwkTauDQM.h:91
EwkMuTauHistManager * muTauHistManager_
Definition: EwkTauDQM.h:46
void endJob()
Definition: EwkTauDQM.cc:81
DQMStore * dqmStore_
Definition: EwkTauDQM.h:267
std::vector< std::string > vstring
Definition: EwkTauDQM.h:101
bool isAvailable() const
Definition: RefVector.h:255
double p1[4]
Definition: TauolaWrapper.h:89
tuple muons
Definition: patZpeak.py:38
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:385
MonitorElement * hTauJetEta_
Definition: EwkTauDQM.h:283
edm::InputTag tauJetSource_
Definition: EwkTauDQM.h:89
edm::InputTag triggerResultsSource_
Definition: EwkTauDQM.h:85
unsigned numEventsAnalyzed_
Definition: EwkTauDQM.h:329
double y0() const
y coordinate
Definition: BeamSpot.h:66
size_type size() const
Size of the RefVector.
Definition: RefVector.h:89
edm::InputTag triggerResultsSource_
Definition: EwkTauDQM.h:236
float dr03HcalTowerSumEt() const
Definition: GsfElectron.h:481
MonitorElement * hTauJetEta_
Definition: EwkTauDQM.h:132
edm::InputTag tauDiscrAgainstMuons_
Definition: EwkTauDQM.h:248
const std::string dqmRootDirectory
const std::string dqmSeparator
Definition: EwkTauDQM.cc:8
MonitorElement * hVisMass_
Definition: EwkTauDQM.h:293
MonitorElement * hMuonTrackIsoPt_
Definition: EwkTauDQM.h:278
unsigned numEventsAnalyzed_
Definition: EwkTauDQM.h:177
long numWarningsTauDiscrAgainstElectrons_
Definition: EwkTauDQM.h:194
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
EwkTauDQM(const edm::ParameterSet &)
Definition: EwkTauDQM.cc:22
MonitorElement * hElectronPt_
Definition: EwkTauDQM.h:124
virtual double py() const
y coordinate of momentum vector
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:684
MonitorElement * hMtElecPFMEt_
Definition: EwkTauDQM.h:145
float sigmaEtaEta() const
Definition: GsfElectron.h:401
double muonEcalIsoCut_
Definition: EwkTauDQM.h:257
long numWarningsTauDiscrByLeadTrackPtCut_
Definition: EwkTauDQM.h:343
double x0() const
x coordinate
Definition: BeamSpot.h:64