CMS 3D CMS Logo

L1TTauOffline.cc
Go to the documentation of this file.
1 
10 
14 
15 #include "TLorentzVector.h"
16 
17 #include <iomanip>
18 #include <cstdio>
19 #include <string>
20 #include <sstream>
21 #include <cmath>
22 #include <algorithm>
23 
24 using namespace reco;
25 using namespace trigger;
26 using namespace edm;
27 using namespace std;
28 
29 TauL1TPair::TauL1TPair(const TauL1TPair& tauL1tPair) {
30 
31  m_tau = tauL1tPair.m_tau;
32  m_regTau = tauL1tPair.m_regTau;
33 
34  m_eta = tauL1tPair.m_eta;
35  m_phi_bar = tauL1tPair.m_phi_bar;
36  m_phi_end = tauL1tPair.m_phi_end;
37 
38 }
39 
40 double TauL1TPair::dR() {
41  return deltaR(m_regTau->eta(),m_regTau->phi(),eta(),phi());
42 }
43 
44 const std::map<std::string, unsigned int> L1TTauOffline::PlotConfigNames = {
45  {"nVertex", PlotConfig::nVertex},
46  {"ETvsET", PlotConfig::ETvsET},
47  {"PHIvsPHI", PlotConfig::PHIvsPHI}
48 };
49 
50 //
51 // -------------------------------------- Constructor --------------------------------------------
52 //
54  theTauCollection_(consumes < reco::PFTauCollection > (ps.getUntrackedParameter < edm::InputTag > ("tauInputTag"))),
55  AntiMuInputTag_(consumes<reco::PFTauDiscriminator>(ps.getUntrackedParameter<edm::InputTag>("antiMuInputTag"))),
56  AntiEleInputTag_(consumes<reco::PFTauDiscriminator>(ps.getUntrackedParameter<edm::InputTag>("antiEleInputTag"))),
57  DecayModeFindingInputTag_(consumes<reco::PFTauDiscriminator>(ps.getUntrackedParameter<edm::InputTag>("decayModeFindingInputTag"))),
58  comb3TInputTag_(consumes<reco::PFTauDiscriminator>(ps.getUntrackedParameter<edm::InputTag>("comb3TInputTag"))),
59  MuonInputTag_(consumes<reco::MuonCollection>(ps.getUntrackedParameter<edm::InputTag>("muonInputTag"))),
60  MetInputTag_(consumes<reco::PFMETCollection>(ps.getUntrackedParameter<edm::InputTag>("metInputTag"))),
61  VtxInputTag_(consumes<reco::VertexCollection>(ps.getUntrackedParameter<edm::InputTag>("vtxInputTag"))),
62  BsInputTag_(consumes<reco::BeamSpot>(ps.getUntrackedParameter<edm::InputTag>("bsInputTag"))),
63  triggerEvent_(consumes < trigger::TriggerEvent > (ps.getUntrackedParameter < edm::InputTag > ("trigInputTag"))),
64  trigProcess_(ps.getUntrackedParameter<string>("trigProcess")),
65  triggerResults_(consumes < edm::TriggerResults > (ps.getUntrackedParameter < edm::InputTag > ("trigProcess_token"))),
66  triggerPath_(ps.getUntrackedParameter < vector<std::string> > ("triggerNames")),
67  histFolder_(ps.getParameter < std::string > ("histFolder")),
68  efficiencyFolder_(histFolder_ + "/efficiency_raw"),
69  stage2CaloLayer2TauToken_(consumes < l1t::TauBxCollection > (ps.getUntrackedParameter < edm::InputTag > ("l1tInputTag"))),
70  tauEfficiencyThresholds_(ps.getParameter < std::vector<int> > ("tauEfficiencyThresholds")),
71  tauEfficiencyBins_(ps.getParameter < std::vector<double> > ("tauEfficiencyBins")),
72  histDefinitions_(dqmoffline::l1t::readHistDefinitions(ps.getParameterSet("histDefinitions"), PlotConfigNames))
73 {
74  edm::LogInfo("L1TTauOffline") << "Constructor " << "L1TTauOffline::L1TTauOffline " << std::endl;
75 }
76 
77 //
78 // -- Destructor
79 //
81 {
82  edm::LogInfo("L1TTauOffline") << "Destructor L1TTauOffline::~L1TTauOffline " << std::endl;
83 }
84 
85 //
86 // -------------------------------------- beginRun --------------------------------------------
87 //
89 // void L1TTauOffline::dqmBeginRun(edm::Run const &, edm::EventSetup const &)
90 {
91  bool changed = true;
92  m_hltConfig.init(run,iSetup,trigProcess_,changed);
93 
94  edm::LogInfo("L1TTauOffline") << "L1TTauOffline::beginRun" << std::endl;
95 }
96 
97 //
98 // -------------------------------------- bookHistos --------------------------------------------
99 //
101 {
102  edm::LogInfo("L1TTauOffline") << "L1TTauOffline::bookHistograms" << std::endl;
103 
104  //book at beginRun
105  bookTauHistos(ibooker);
106 
107  for ( auto trigNamesIt = triggerPath_.begin() ; trigNamesIt!=triggerPath_.end() ; trigNamesIt++){
108 
109  std::string tNameTmp = (*trigNamesIt);
110  std::string tNamePattern = "";
111  std::size_t found0 = tNameTmp.find("*");
112  if(found0!=std::string::npos) tNamePattern = tNameTmp.substr(0,tNameTmp.size()-1);
113  else tNamePattern = tNameTmp;
114 
115  int tIndex = -1;
116 
117  for (unsigned ipath = 0; ipath < m_hltConfig.size(); ++ipath) {
118 
119  std::string tmpName = m_hltConfig.triggerName(ipath);
120 
121  std::size_t found=tmpName.find(tNamePattern);
122  if (found!=std::string::npos){
123  tIndex = int(ipath);
124  m_trigIndices.push_back(tIndex);
125  }
126  }
127  }
128 }
129 
130 //
131 // -------------------------------------- Analyze --------------------------------------------
132 //
134 {
135 
136  m_MaxTauEta = 2.1;
137  m_MaxL1tTauDR = 0.5;
138  m_MaxHltTauDR = 0.5;
139 
141  e.getByToken(theTauCollection_, taus);
142 
143  if(!taus.isValid())
144  {
145  edm::LogWarning("L1TTauOffline") << "invalid collection: reco::PFTauCollection " << std::endl;
146  return;
147  }
148 
150  e.getByToken(MuonInputTag_, muons);
151 
152  if(!muons.isValid())
153  {
154  edm::LogWarning("L1TTauOffline") << "invalid collection: reco::MuonCollection " << std::endl;
155  return;
156  }
157 
159  e.getByToken(BsInputTag_, beamSpot);
160 
161  if(!beamSpot.isValid())
162  {
163  edm::LogWarning("L1TTauOffline") << "invalid collection: reco::BeamSpot " << std::endl;
164  return;
165  }
166 
168  e.getByToken(VtxInputTag_, vertex);
169 
170  if(!vertex.isValid())
171  {
172  edm::LogWarning("L1TTauOffline") << "invalid collection: reco::VertexCollection " << std::endl;
173  return;
174  }
175 
178 
179  if(!l1tCands.isValid())
180  {
181  edm::LogWarning("L1TTauOffline") << "invalid collection: l1t::TauBxCollection " << std::endl;
182  return;
183  }
184 
186  e.getByToken(triggerResults_,trigResults);
187 
188  if(!trigResults.isValid())
189  {
190  edm::LogWarning("L1TTauOffline") << "invalid collection: edm::TriggerResults " << std::endl;
191  return;
192  }
193 
195  e.getByToken(triggerEvent_,trigEvent);
196 
197  if(!trigEvent.isValid())
198  {
199  edm::LogWarning("L1TTauOffline") << "invalid collection: trigger::TriggerEvent " << std::endl;
200  return;
201  }
202 
204  e.getByToken(MetInputTag_, mets);
205 
206  if(!mets.isValid()) {
207  edm::LogWarning("L1TTauOffline") << "invalid collection: reco::PFMETCollection " << std::endl;
208  return;
209  }
210 
211  eSetup.get<IdealMagneticFieldRecord>().get(m_BField);
212  const reco::Vertex primaryVertex = getPrimaryVertex(vertex,beamSpot);
213 
214  getTightMuons(muons,mets,primaryVertex,trigEvent);
215  getProbeTaus(e,taus,muons,primaryVertex);
216  getTauL1tPairs(l1tCands);
217 
218  vector<l1t::Tau> l1tContainer;
219  l1tContainer.reserve(l1tCands->size()+1);
220 
221  for (auto tau = l1tCands->begin(0); tau != l1tCands->end(0); ++tau) {
222  l1tContainer.push_back(*tau);
223  }
224 
225  for(auto tauL1tPairsIt=m_TauL1tPairs.begin(); tauL1tPairsIt!=m_TauL1tPairs.end(); ++tauL1tPairsIt) {
226 
227  float eta = tauL1tPairsIt->eta();
228  float phi = tauL1tPairsIt->phi();
229  float pt = tauL1tPairsIt->pt();
230 
231  // unmatched gmt cands have l1tPt = -1.
232  float l1tPt = tauL1tPairsIt->l1tPt();
233 
234  int counter = 0;
235 
236  for (auto threshold : tauEfficiencyThresholds_) {
237  std::string str_threshold = std::to_string(threshold);
238 
239  int l1tPtCut = threshold;
240  bool l1tAboveCut = (l1tPt >= l1tPtCut);
241 
242  stringstream ptCutToTag; ptCutToTag << l1tPtCut;
243  string ptTag = ptCutToTag.str();
244 
245  if (fabs(eta) < m_MaxTauEta) {
246  if(counter==0) {
247  if(fabs(eta)<1.5) {
248  h_L1TauETvsTauET_EB_->Fill(pt,l1tPt);
249  h_L1TauPhivsTauPhi_EB_->Fill(phi,tauL1tPairsIt->l1tPhi());
250  h_resolutionTauET_EB_->Fill((l1tPt-pt)/pt);
251  h_resolutionTauPhi_EB_->Fill(tauL1tPairsIt->l1tPhi()-phi);
252  } else {
253  h_L1TauETvsTauET_EE_->Fill(pt,l1tPt);
254  h_L1TauPhivsTauPhi_EE_->Fill(phi,tauL1tPairsIt->l1tPhi());
255  h_resolutionTauET_EE_->Fill((l1tPt-pt)/pt);
256  h_resolutionTauPhi_EE_->Fill(tauL1tPairsIt->l1tPhi()-phi);
257  }
258  h_L1TauETvsTauET_EB_EE_->Fill(pt,l1tPt);
259  h_L1TauPhivsTauPhi_EB_EE_->Fill(phi,tauL1tPairsIt->l1tPhi());
260  h_L1TauEtavsTauEta_->Fill(eta,tauL1tPairsIt->l1tEta());
261  h_resolutionTauET_EB_EE_->Fill((l1tPt-pt)/pt);
262  h_resolutionTauPhi_EB_EE_->Fill(tauL1tPairsIt->l1tPhi()-phi);
263  h_resolutionTauEta_->Fill(tauL1tPairsIt->l1tEta()-eta);
264 
265  ++counter;
266  }
267 
268  if(fabs(eta)<1.5) {
271  } else {
274  }
277 
278  if(l1tAboveCut) {
279  if(fabs(eta)<1.5) h_efficiencyNonIsoTauET_EB_pass_[threshold]->Fill(pt);
282 
283  if(tauL1tPairsIt->l1tIso()>0.5) {
284  if(fabs(eta)<1.5) h_efficiencyIsoTauET_EB_pass_[threshold]->Fill(pt);
287  }
288  }
289  }
290  }
291  }//loop over tau-L1 pairs
292 }
293 
294 //
295 // -------------------------------------- endRun --------------------------------------------
296 //
298 {
299  edm::LogInfo("L1TTauOffline") << "L1TTauOffline::endRun" << std::endl;
300 }
301 
302 //
303 // -------------------------------------- book histograms --------------------------------------------
304 //
306 {
307  ibooker.cd();
308  ibooker.setCurrentFolder(histFolder_);
309  dqmoffline::l1t::HistDefinition nVertexDef = histDefinitions_[PlotConfig::nVertex];
310  h_nVertex_ = ibooker.book1D(
311  nVertexDef.name, nVertexDef.title, nVertexDef.nbinsX, nVertexDef.xmin, nVertexDef.xmax
312  );
313  h_tagAndProbeMass_ = ibooker.book1D("tagAndProbeMass", "Invariant mass of tag & probe pair", 100, 40, 140);
314 
315  dqmoffline::l1t::HistDefinition templateETvsET = histDefinitions_[PlotConfig::ETvsET];
316  h_L1TauETvsTauET_EB_ = ibooker.book2D("L1TauETvsTauET_EB",
317  "L1 Tau E_{T} vs PFTau E_{T} (EB); PFTau E_{T} (GeV); L1 Tau E_{T} (GeV)",
318  templateETvsET.nbinsX, &templateETvsET.binsX[0], templateETvsET.nbinsY, &templateETvsET.binsY[0]);
319  h_L1TauETvsTauET_EE_ = ibooker.book2D("L1TauETvsTauET_EE",
320  "L1 Tau E_{T} vs PFTau E_{T} (EE); PFTau E_{T} (GeV); L1 Tau E_{T} (GeV)",
321  templateETvsET.nbinsX, &templateETvsET.binsX[0], templateETvsET.nbinsY, &templateETvsET.binsY[0]);
322  h_L1TauETvsTauET_EB_EE_ = ibooker.book2D("L1TauETvsTauET_EB_EE",
323  "L1 Tau E_{T} vs PFTau E_{T} (EB+EE); PFTau E_{T} (GeV); L1 Tau E_{T} (GeV)",
324  templateETvsET.nbinsX, &templateETvsET.binsX[0], templateETvsET.nbinsY, &templateETvsET.binsY[0]);
325 
326  dqmoffline::l1t::HistDefinition templatePHIvsPHI = histDefinitions_[PlotConfig::PHIvsPHI];
327  h_L1TauPhivsTauPhi_EB_ = ibooker.book2D("L1TauPhivsTauPhi_EB",
328  "#phi_{tau}^{L1} vs #phi_{tau}^{offline} (EB); #phi_{tau}^{offline}; #phi_{tau}^{L1}",
329  templatePHIvsPHI.nbinsX, templatePHIvsPHI.xmin, templatePHIvsPHI.xmax,
330  templatePHIvsPHI.nbinsY, templatePHIvsPHI.ymin, templatePHIvsPHI.ymax);
331  h_L1TauPhivsTauPhi_EE_ = ibooker.book2D("L1TauPhivsTauPhi_EE",
332  "#phi_{tau}^{L1} vs #phi_{tau}^{offline} (EE); #phi_{tau}^{offline}; #phi_{tau}^{L1}",
333  templatePHIvsPHI.nbinsX, templatePHIvsPHI.xmin, templatePHIvsPHI.xmax,
334  templatePHIvsPHI.nbinsY, templatePHIvsPHI.ymin, templatePHIvsPHI.ymax);
335  h_L1TauPhivsTauPhi_EB_EE_ = ibooker.book2D("L1TauPhivsTauPhi_EB_EE",
336  "#phi_{tau}^{L1} vs #phi_{tau}^{offline} (EB+EE); #phi_{tau}^{offline}; #phi_{tau}^{L1}",
337  templatePHIvsPHI.nbinsX, templatePHIvsPHI.xmin, templatePHIvsPHI.xmax,
338  templatePHIvsPHI.nbinsY, templatePHIvsPHI.ymin, templatePHIvsPHI.ymax);
339 
340  h_L1TauEtavsTauEta_ = ibooker.book2D("L1TauEtavsTauEta",
341  "L1 Tau #eta vs PFTau #eta; PFTau #eta; L1 Tau #eta", 100, -3, 3, 100, -3, 3);
342 
343  // tau resolutions
344  h_resolutionTauET_EB_ = ibooker.book1D("resolutionTauET_EB",
345  "tau ET resolution (EB); (L1 Tau E_{T} - PFTau E_{T})/PFTau E_{T}; events", 50, -1, 1.5);
346  h_resolutionTauET_EE_ = ibooker.book1D("resolutionTauET_EE",
347  "tau ET resolution (EE); (L1 Tau E_{T} - PFTau E_{T})/PFTau E_{T}; events", 50, -1, 1.5);
348  h_resolutionTauET_EB_EE_ = ibooker.book1D("resolutionTauET_EB_EE",
349  "tau ET resolution (EB+EE); (L1 Tau E_{T} - PFTau E_{T})/PFTau E_{T}; events", 50, -1, 1.5);
350 
352  ibooker.book1D("resolutionTauPhi_EB",
353  "#phi_{tau} resolution (EB); #phi_{tau}^{L1} - #phi_{tau}^{offline}; events",
354  120, -0.3, 0.3);
356  ibooker.book1D("resolutionTauPhi_EE",
357  "tau #phi resolution (EE); #phi_{tau}^{L1} - #phi_{tau}^{offline}; events",
358  120, -0.3, 0.3);
360  ibooker.book1D("resolutionTauPhi_EB_EE",
361  "tau #phi resolution (EB+EE); #phi_{tau}^{L1} - #phi_{tau}^{offline}; events",
362  120, -0.3, 0.3);
363 
364  h_resolutionTauEta_ = ibooker.book1D("resolutionTauEta",
365  "tau #eta resolution (EB); L1 Tau #eta - PFTau #eta; events", 120, -0.3, 0.3);
366 
367  // tau turn-ons
369  std::vector<float> tauBins(tauEfficiencyBins_.begin(), tauEfficiencyBins_.end());
370  int nBins = tauBins.size() - 1;
371  float* tauBinArray = &(tauBins[0]);
372 
373  for (auto threshold : tauEfficiencyThresholds_) {
374  std::string str_threshold = std::to_string(int(threshold));
376  "efficiencyIsoTauET_EB_threshold_" + str_threshold + "_Num",
377  "iso tau efficiency (EB); PFTau E_{T} (GeV); events", nBins, tauBinArray);
379  "efficiencyIsoTauET_EE_threshold_" + str_threshold + "_Num",
380  "iso tau efficiency (EE); PFTau E_{T} (GeV); events", nBins, tauBinArray);
382  "efficiencyIsoTauET_EB_EE_threshold_" + str_threshold + "_Num",
383  "iso tau efficiency (EB+EE); PFTau E_{T} (GeV); events", nBins, tauBinArray);
384 
386  "efficiencyIsoTauET_EB_threshold_" + str_threshold + "_Den",
387  "iso tau efficiency (EB); PFTau E_{T} (GeV); events", nBins, tauBinArray);
389  "efficiencyIsoTauET_EE_threshold_" + str_threshold + "_Den",
390  "iso tau efficiency (EE); PFTau E_{T} (GeV); events", nBins, tauBinArray);
392  "efficiencyIsoTauET_EB_EE_threshold_" + str_threshold + "_Den",
393  "iso tau efficiency (EB+EE); PFTau E_{T} (GeV); events", nBins, tauBinArray);
394 
395 
396  //non iso
398  "efficiencyNonIsoTauET_EB_threshold_" + str_threshold + "_Num",
399  "inclusive tau efficiency (EB); PFTau E_{T} (GeV); events", nBins, tauBinArray);
401  "efficiencyNonIsoTauET_EE_threshold_" + str_threshold + "_Num",
402  "inclusive tau efficiency (EE); PFTau E_{T} (GeV); events", nBins, tauBinArray);
404  "efficiencyNonIsoTauET_EB_EE_threshold_" + str_threshold + "_Num",
405  "inclusive tau efficiency (EB+EE); PFTau E_{T} (GeV); events", nBins, tauBinArray);
406 
408  "efficiencyNonIsoTauET_EB_threshold_" + str_threshold + "_Den",
409  "inclusive tau efficiency (EB); PFTau E_{T} (GeV); events", nBins, tauBinArray);
411  "efficiencyNonIsoTauET_EE_threshold_" + str_threshold + "_Den",
412  "inclusive tau efficiency (EE); PFTau E_{T} (GeV); events", nBins, tauBinArray);
414  "efficiencyNonIsoTauET_EB_EE_threshold_" + str_threshold + "_Den",
415  "inclusive tau efficiency (EB+EE); PFTau E_{T} (GeV); events", nBins, tauBinArray);
416 
417  }
418 
419  ibooker.cd();
420 
421  return;
422 
423 }
424 
426 
427  reco::Vertex::Point posVtx;
428  reco::Vertex::Error errVtx;
429 
430  bool hasPrimaryVertex = false;
431 
432  if (vertex.isValid())
433  {
434  for (auto vertexIt=vertex->begin();vertexIt!=vertex->end();++vertexIt)
435  {
436  if (vertexIt->isValid() &&
437  !vertexIt->isFake())
438  {
439  posVtx = vertexIt->position();
440  errVtx = vertexIt->error();
441  hasPrimaryVertex = true;
442  break;
443  }
444  }
445  }
446 
447  if ( !hasPrimaryVertex ) {
448  posVtx = beamSpot->position();
449  errVtx(0,0) = beamSpot->BeamWidthX();
450  errVtx(1,1) = beamSpot->BeamWidthY();
451  errVtx(2,2) = beamSpot->sigmaZ();
452  }
453 
454  const reco::Vertex primaryVertex(posVtx,errVtx);
455 
456  return primaryVertex;
457 }
458 
460 
461 
462  double matchDeltaR = 9999;
463 
465 
466  for(auto trigIndexIt = m_trigIndices.begin(); trigIndexIt!=m_trigIndices.end(); ++trigIndexIt) {
467 
468  const vector<string> moduleLabels(m_hltConfig.moduleLabels(*trigIndexIt));
469  const unsigned moduleIndex = m_hltConfig.size((*trigIndexIt))-2;
470 
471  const unsigned hltFilterIndex = triggerEvent->filterIndex(InputTag(moduleLabels[moduleIndex],"",trigProcess_));
472 
473  if (hltFilterIndex < triggerEvent->sizeFilters()) {
474  const Keys triggerKeys(triggerEvent->filterKeys(hltFilterIndex));
475  const Vids triggerVids(triggerEvent->filterIds(hltFilterIndex));
476 
477  const unsigned nTriggers = triggerVids.size();
478  for (size_t iTrig = 0; iTrig < nTriggers; ++iTrig) {
479  const TriggerObject trigObject = trigObjs[triggerKeys[iTrig]];
480 
481  double dRtmp = deltaR((*muon),trigObject);
482  if (dRtmp < matchDeltaR) matchDeltaR = dRtmp;
483  }
484  }
485  }
486 
487  return (matchDeltaR < m_MaxHltTauDR);
488 
489 }
490 
492 
493  m_TauL1tPairs.clear();
494 
495  vector<l1t::Tau> l1tContainer;
496  l1tContainer.reserve(l1tCands->size()+1);
497 
498  for (auto tau = l1tCands->begin(0); tau != l1tCands->end(0); ++tau) {
499  l1tContainer.push_back(*tau);
500  }
501 
502  for (auto probeTauIt = m_ProbeTaus.begin(); probeTauIt!=m_ProbeTaus.end(); ++probeTauIt) {
503 
504  TauL1TPair pairBestCand((*probeTauIt),nullptr);
505 
506  for(auto l1tIt = l1tContainer.begin() ; l1tIt!=l1tContainer.end(); ++l1tIt) {
507 
508  TauL1TPair pairTmpCand((*probeTauIt),&(*l1tIt));
509 
510  if (pairTmpCand.dR() < m_MaxL1tTauDR && pairTmpCand.l1tPt() > pairBestCand.l1tPt())
511  pairBestCand = pairTmpCand;
512 
513  }
514 
515  m_TauL1tPairs.push_back(pairBestCand);
516 
517  }
518 
519 }
520 
522 
523  m_TightMuons.clear();
524 
525  const reco::PFMET *pfmet=nullptr;
526  pfmet=&(mets->front());
527 
528  int nb_mu=0;
529 
530  for(auto muonIt2 = muons->begin(); muonIt2!=muons->end(); ++muonIt2) {
531  if (fabs(muonIt2->eta())< 2.4 && muonIt2->pt()>10 && muon::isLooseMuon((*muonIt2)) && (muonIt2->pfIsolationR04().sumChargedHadronPt+max(muonIt2->pfIsolationR04().sumNeutralHadronEt+muonIt2->pfIsolationR04().sumPhotonEt-0.5*muonIt2->pfIsolationR04().sumPUPt,0.0))/muonIt2->pt()<0.3) {
532  ++nb_mu;
533  }
534  }
535  bool foundTightMu=false;
536  for(auto muonIt = muons->begin(); muonIt!=muons->end(); ++muonIt) {
537  if (!matchHlt(trigEvent,&(*muonIt))) continue;
538  float muiso=(muonIt->pfIsolationR04().sumChargedHadronPt+max(muonIt->pfIsolationR04().sumNeutralHadronEt+muonIt->pfIsolationR04().sumPhotonEt-0.5*muonIt->pfIsolationR04().sumPUPt,0.0))/muonIt->pt();
539 
540  if (muiso<0.1 && nb_mu<2 && !foundTightMu && fabs(muonIt->eta())< 2.1 && muonIt->pt()>24 && muon::isLooseMuon((*muonIt))) {
541  float mt=sqrt(pow(muonIt->pt() + pfmet->pt(), 2) - pow(muonIt->px() + pfmet->px(),2) - pow(muonIt->py() + pfmet->py(), 2));
542  if (mt<30){
543  m_TightMuons.push_back(&(*muonIt));
544  foundTightMu=true;
545  }
546  }
547  }
548 }
549 
551 
552  m_ProbeTaus.clear();
553 
555  iEvent.getByToken(AntiMuInputTag_, antimu);
556  if(!antimu.isValid())
557  {
558  edm::LogWarning("L1TTauOffline") << "invalid collection: reco::PFTauDiscriminator " << std::endl;
559  return;
560  }
561 
564  if(!dmf.isValid())
565  {
566  edm::LogWarning("L1TTauOffline") << "invalid collection: reco::PFTauDiscriminator " << std::endl;
567  return;
568  }
569 
571  iEvent.getByToken(AntiEleInputTag_, antiele);
572  if(!antiele.isValid())
573  {
574  edm::LogWarning("L1TTauOffline") << "invalid collection: reco::PFTauDiscriminator " << std::endl;
575  return;
576  }
577 
579  iEvent.getByToken(comb3TInputTag_, comb3T);
580  if(!comb3T.isValid())
581  {
582  edm::LogWarning("L1TTauOffline") << "invalid collection: reco::PFTauDiscriminator " << std::endl;
583  return;
584  }
585 
586  if (!m_TightMuons.empty()){
587  TLorentzVector mymu;
588  mymu.SetPtEtaPhiE(m_TightMuons[0]->pt(),m_TightMuons[0]->eta(),m_TightMuons[0]->phi(),m_TightMuons[0]->energy());
589  int iTau=0;
590  for(auto tauIt = taus->begin(); tauIt!=taus->end(); ++tauIt,++iTau) {
591  reco::PFTauRef tauCandidate(taus, iTau);
592  TLorentzVector mytau;
593  mytau.SetPtEtaPhiE(tauIt->pt(),tauIt->eta(),tauIt->phi(),tauIt->energy());
594 
595  if (fabs(tauIt->charge())==1 && fabs(tauIt->eta())< 2.1 && tauIt->pt()>20 && (*antimu)[tauCandidate] > 0.5 && (*antiele)[tauCandidate] > 0.5 && (*dmf)[tauCandidate] > 0.5 && (*comb3T)[tauCandidate] > 0.5) {
596  if (mymu.DeltaR(mytau)>0.5 && (mymu+mytau).M()>40 && (mymu+mytau).M()<80 && m_TightMuons[0]->charge()*tauIt->charge()<0){
597  m_ProbeTaus.push_back(&(*tauIt));
598  }
599  }
600  }
601  }
602 }
603 
604 
605 //define this as a plug-in
unsigned int size() const
number of trigger paths in trigger table
std::vector< float > binsX
const_iterator end(int bx) const
edm::EDGetTokenT< reco::VertexCollection > VtxInputTag_
std::vector< std::string > triggerPath_
void endRun(edm::Run const &run, edm::EventSetup const &eSetup) override
double l1tPt() const
Definition: L1TTauOffline.h:66
std::vector< PFTau > PFTauCollection
collection of PFTau objects
Definition: PFTauFwd.h:9
unsigned size(int bx) const
~L1TTauOffline() override
The single EDProduct to be saved for each event (AOD case)
Definition: TriggerEvent.h:25
double m_phi_bar
Definition: L1TTauOffline.h:77
const std::string & triggerName(unsigned int triggerIndex) const
std::map< double, MonitorElement * > h_efficiencyIsoTauET_EB_pass_
std::vector< int > m_trigIndices
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
std::vector< TauL1TPair > m_TauL1tPairs
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
MonitorElement * h_L1TauPhivsTauPhi_EB_
void bookTauHistos(DQMStore::IBooker &)
ParameterSet const & getParameterSet(ParameterSetID const &id)
double px() const final
x coordinate of momentum vector
edm::ESHandle< MagneticField > m_BField
void dqmBeginRun(const edm::Run &run, const edm::EventSetup &iSetup) override
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:111
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:123
edm::EDGetTokenT< reco::PFTauDiscriminator > comb3TInputTag_
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
double pt() const final
transverse momentum
static const std::map< std::string, unsigned int > PlotConfigNames
Definition: L1TTauOffline.h:95
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
std::vector< double > tauEfficiencyBins_
std::map< double, MonitorElement * > h_efficiencyNonIsoTauET_EB_EE_pass_
delete x;
Definition: CaloConfig.h:22
MonitorElement * h_nVertex_
std::map< double, MonitorElement * > h_efficiencyIsoTauET_EE_pass_
std::map< double, MonitorElement * > h_efficiencyNonIsoTauET_EB_total_
std::map< double, MonitorElement * > h_efficiencyNonIsoTauET_EB_pass_
std::string efficiencyFolder_
void getProbeTaus(const edm::Event &e, edm::Handle< reco::PFTauCollection > const &taus, edm::Handle< reco::MuonCollection > const &muons, const reco::Vertex &vertex)
BXVector< Tau > TauBxCollection
Definition: Tau.h:11
const Point & position() const
position
Definition: Vertex.h:109
std::string histFolder_
std::map< double, MonitorElement * > h_efficiencyNonIsoTauET_EB_EE_total_
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
MonitorElement * h_resolutionTauPhi_EB_
bool isLooseMuon(const reco::Muon &)
L1TTauOffline(const edm::ParameterSet &ps)
void Fill(long long x)
MonitorElement * h_L1TauPhivsTauPhi_EE_
std::vector< int > tauEfficiencyThresholds_
HLTConfigProvider m_hltConfig
const Vids & filterIds(trigger::size_type index) const
Definition: TriggerEvent.h:110
std::vector< const reco::PFTau * > m_ProbeTaus
int iEvent
Definition: GenABIO.cc:230
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
MonitorElement * h_resolutionTauPhi_EB_EE_
const reco::Vertex getPrimaryVertex(edm::Handle< reco::VertexCollection > const &vertex, edm::Handle< reco::BeamSpot > const &beamSpot)
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:98
T sqrt(T t)
Definition: SSEVec.h:18
const l1t::Tau * m_regTau
Definition: L1TTauOffline.h:74
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
std::map< double, MonitorElement * > h_efficiencyIsoTauET_EB_total_
MonitorElement * h_resolutionTauPhi_EE_
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
std::map< double, MonitorElement * > h_efficiencyIsoTauET_EB_EE_pass_
MonitorElement * h_L1TauEtavsTauEta_
double BeamWidthX() const
beam width X
Definition: BeamSpot.h:86
edm::EDGetTokenT< l1t::TauBxCollection > stage2CaloLayer2TauToken_
std::map< double, MonitorElement * > h_efficiencyIsoTauET_EB_EE_total_
edm::EDGetTokenT< reco::PFTauDiscriminator > AntiMuInputTag_
bool isValid() const
Definition: HandleBase.h:74
MonitorElement * h_resolutionTauEta_
double m_eta
Definition: L1TTauOffline.h:76
std::map< double, MonitorElement * > h_efficiencyNonIsoTauET_EE_total_
edm::EDGetTokenT< reco::BeamSpot > BsInputTag_
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
edm::EDGetTokenT< reco::PFMETCollection > MetInputTag_
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
MonitorElement * h_resolutionTauET_EB_EE_
edm::EDGetTokenT< edm::TriggerResults > triggerResults_
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:81
HistDefinitions readHistDefinitions(const edm::ParameterSet &ps, const std::map< std::string, unsigned int > &mapping)
std::vector< const reco::Muon * > m_TightMuons
MonitorElement * h_resolutionTauET_EE_
std::map< double, MonitorElement * > h_efficiencyIsoTauET_EE_total_
const reco::PFTau * m_tau
Definition: L1TTauOffline.h:69
edm::EDGetTokenT< reco::MuonCollection > MuonInputTag_
std::string trigProcess_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
std::vector< float > binsY
edm::EDGetTokenT< reco::PFTauDiscriminator > DecayModeFindingInputTag_
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:136
MonitorElement * h_tagAndProbeMass_
std::vector< size_type > Keys
double dR()
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
double sigmaZ() const
sigma z
Definition: BeamSpot.h:80
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:88
double py() const final
y coordinate of momentum vector
void getTauL1tPairs(edm::Handle< l1t::TauBxCollection > const &l1tCands)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
TauL1TPair(const reco::PFTau *tau, const l1t::Tau *regTau)
Definition: L1TTauOffline.h:54
edm::EDGetTokenT< trigger::TriggerEvent > triggerEvent_
edm::EDGetTokenT< reco::PFTauDiscriminator > AntiEleInputTag_
fixed size matrix
HLT enums.
static std::atomic< unsigned int > counter
T get() const
Definition: EventSetup.h:63
bool matchHlt(edm::Handle< trigger::TriggerEvent > const &triggerEvent, const reco::Muon *muon)
dqmoffline::l1t::HistDefinitions histDefinitions_
const Point & position() const
position
Definition: BeamSpot.h:62
edm::EDGetTokenT< reco::PFTauCollection > theTauCollection_
MonitorElement * h_L1TauETvsTauET_EB_EE_
MonitorElement * h_L1TauETvsTauET_EE_
MonitorElement * h_L1TauPhivsTauPhi_EB_EE_
void getTightMuons(edm::Handle< reco::MuonCollection > const &muons, edm::Handle< reco::PFMETCollection > const &mets, const reco::Vertex &vertex, edm::Handle< trigger::TriggerEvent > const &trigEvent)
const_iterator begin(int bx) const
MonitorElement * h_resolutionTauET_EB_
MonitorElement * h_L1TauETvsTauET_EB_
std::vector< int > Vids
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
std::map< double, MonitorElement * > h_efficiencyNonIsoTauET_EE_pass_
Definition: Run.h:44
double m_phi_end
Definition: L1TTauOffline.h:78
Collection of PF MET.