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