15 #include "TLorentzVector.h"
30 m_tau = tauL1tPair.
m_tau;
33 m_eta = tauL1tPair.
m_eta;
49 AntiMuWP_(ps.getUntrackedParameter<
std::
string>(
"antiMuWP")),
52 AntiEleWP_(ps.getUntrackedParameter<
std::
string>(
"antiEleWP")),
53 DecayModeFindingInputTag_(
57 comb3TWP_(ps.getUntrackedParameter<
std::
string>(
"comb3TWP")),
63 trigProcess_(ps.getUntrackedParameter<
string>(
"trigProcess")),
65 triggerPath_(ps.getUntrackedParameter<vector<
std::
string>>(
"triggerNames")),
66 histFolder_(ps.getParameter<
std::
string>(
"histFolder")),
67 efficiencyFolder_(histFolder_ +
"/efficiency_raw"),
69 tauEfficiencyThresholds_(ps.getParameter<
std::vector<
int>>(
"tauEfficiencyThresholds")),
70 tauEfficiencyBins_(ps.getParameter<
std::vector<double>>(
"tauEfficiencyBins")),
86 h_L1TauETvsTauET_EB_(),
87 h_L1TauETvsTauET_EE_(),
88 h_L1TauETvsTauET_EB_EE_(),
89 h_L1TauPhivsTauPhi_EB_(),
90 h_L1TauPhivsTauPhi_EE_(),
91 h_L1TauPhivsTauPhi_EB_EE_(),
92 h_L1TauEtavsTauEta_(),
93 h_resolutionTauET_EB_(),
94 h_resolutionTauET_EE_(),
95 h_resolutionTauET_EB_EE_(),
96 h_resolutionTauPhi_EB_(),
97 h_resolutionTauPhi_EE_(),
98 h_resolutionTauPhi_EB_EE_(),
99 h_resolutionTauEta_(),
100 h_efficiencyIsoTauET_EB_pass_(),
101 h_efficiencyIsoTauET_EE_pass_(),
102 h_efficiencyIsoTauET_EB_EE_pass_(),
103 h_efficiencyNonIsoTauET_EB_pass_(),
104 h_efficiencyNonIsoTauET_EE_pass_(),
105 h_efficiencyNonIsoTauET_EB_EE_pass_(),
106 h_efficiencyIsoTauET_EB_total_(),
107 h_efficiencyIsoTauET_EE_total_(),
108 h_efficiencyIsoTauET_EB_EE_total_(),
109 h_efficiencyNonIsoTauET_EB_total_(),
110 h_efficiencyNonIsoTauET_EE_total_(),
111 h_efficiencyNonIsoTauET_EB_EE_total_() {
113 <<
"L1TTauOffline::L1TTauOffline " << std::endl;
120 edm::LogInfo(
"L1TTauOffline") <<
"Destructor L1TTauOffline::~L1TTauOffline " << std::endl;
132 edm::LogInfo(
"L1TTauOffline") <<
"L1TTauOffline::beginRun" << std::endl;
139 edm::LogInfo(
"L1TTauOffline") <<
"L1TTauOffline::bookHistograms" << std::endl;
147 std::size_t found0 = tNameTmp.find(
"*");
148 if (found0 != std::string::npos)
149 tNamePattern = tNameTmp.substr(0, tNameTmp.size() - 1);
151 tNamePattern = tNameTmp;
158 std::size_t
found = tmpName.find(tNamePattern);
159 if (
found != std::string::npos) {
178 if (!
taus.isValid()) {
179 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: reco::PFTauCollection " << std::endl;
186 if (!
muons.isValid()) {
187 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: reco::MuonCollection " << std::endl;
195 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: reco::BeamSpot " << std::endl;
203 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: reco::VertexCollection " << std::endl;
211 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: l1t::TauBxCollection " << std::endl;
219 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: edm::TriggerResults " << std::endl;
227 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: trigger::TriggerEvent " << std::endl;
234 if (!
mets.isValid()) {
235 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: reco::PFMETCollection " << std::endl;
246 vector<l1t::Tau> l1tContainer;
247 l1tContainer.reserve(l1tCands->
size() + 1);
250 l1tContainer.push_back(*
tau);
254 float eta = tauL1tPairsIt->eta();
255 float phi = tauL1tPairsIt->phi();
256 float pt = tauL1tPairsIt->pt();
259 float l1tPt = tauL1tPairsIt->l1tPt();
267 bool l1tAboveCut = (l1tPt >= l1tPtCut);
269 stringstream ptCutToTag;
270 ptCutToTag << l1tPtCut;
271 string ptTag = ptCutToTag.str();
275 if (fabs(
eta) < 1.5) {
296 if (fabs(
eta) < 1.5) {
313 if (tauL1tPairsIt->l1tIso() > 0.5) {
341 "L1 Tau E_{T} vs PFTau E_{T} (EB); PFTau E_{T} (GeV); L1 Tau E_{T} (GeV)",
343 &templateETvsET.
binsX[0],
345 &templateETvsET.
binsY[0]);
347 "L1 Tau E_{T} vs PFTau E_{T} (EE); PFTau E_{T} (GeV); L1 Tau E_{T} (GeV)",
349 &templateETvsET.
binsX[0],
351 &templateETvsET.
binsY[0]);
353 "L1 Tau E_{T} vs PFTau E_{T} (EB+EE); PFTau E_{T} (GeV); L1 Tau E_{T} (GeV)",
355 &templateETvsET.
binsX[0],
357 &templateETvsET.
binsY[0]);
361 ibooker.
book2D(
"L1TauPhivsTauPhi_EB",
362 "#phi_{tau}^{L1} vs #phi_{tau}^{offline} (EB); #phi_{tau}^{offline}; #phi_{tau}^{L1}",
364 templatePHIvsPHI.
xmin,
365 templatePHIvsPHI.
xmax,
367 templatePHIvsPHI.
ymin,
368 templatePHIvsPHI.
ymax);
370 ibooker.
book2D(
"L1TauPhivsTauPhi_EE",
371 "#phi_{tau}^{L1} vs #phi_{tau}^{offline} (EE); #phi_{tau}^{offline}; #phi_{tau}^{L1}",
373 templatePHIvsPHI.
xmin,
374 templatePHIvsPHI.
xmax,
376 templatePHIvsPHI.
ymin,
377 templatePHIvsPHI.
ymax);
379 ibooker.
book2D(
"L1TauPhivsTauPhi_EB_EE",
380 "#phi_{tau}^{L1} vs #phi_{tau}^{offline} (EB+EE); #phi_{tau}^{offline}; #phi_{tau}^{L1}",
382 templatePHIvsPHI.
xmin,
383 templatePHIvsPHI.
xmax,
385 templatePHIvsPHI.
ymin,
386 templatePHIvsPHI.
ymax);
389 ibooker.
book2D(
"L1TauEtavsTauEta",
"L1 Tau #eta vs PFTau #eta; PFTau #eta; L1 Tau #eta", 100, -3, 3, 100, -3, 3);
393 "resolutionTauET_EB",
"tau ET resolution (EB); (L1 Tau E_{T} - PFTau E_{T})/PFTau E_{T}; events", 50, -1, 1.5);
395 "resolutionTauET_EE",
"tau ET resolution (EE); (L1 Tau E_{T} - PFTau E_{T})/PFTau E_{T}; events", 50, -1, 1.5);
397 ibooker.
book1D(
"resolutionTauET_EB_EE",
398 "tau ET resolution (EB+EE); (L1 Tau E_{T} - PFTau E_{T})/PFTau E_{T}; events",
404 "#phi_{tau} resolution (EB); #phi_{tau}^{L1} - #phi_{tau}^{offline}; events",
409 "resolutionTauPhi_EE",
"tau #phi resolution (EE); #phi_{tau}^{L1} - #phi_{tau}^{offline}; events", 120, -0.3, 0.3);
411 ibooker.
book1D(
"resolutionTauPhi_EB_EE",
412 "tau #phi resolution (EB+EE); #phi_{tau}^{L1} - #phi_{tau}^{offline}; events",
418 ibooker.
book1D(
"resolutionTauEta",
"tau #eta resolution (EB); L1 Tau #eta - PFTau #eta; events", 120, -0.3, 0.3);
423 int nBins = tauBins.size() - 1;
424 float* tauBinArray = &(tauBins[0]);
429 ibooker.
book1D(
"efficiencyIsoTauET_EB_threshold_" + str_threshold +
"_Num",
430 "iso tau efficiency (EB); PFTau E_{T} (GeV); events",
434 ibooker.
book1D(
"efficiencyIsoTauET_EE_threshold_" + str_threshold +
"_Num",
435 "iso tau efficiency (EE); PFTau E_{T} (GeV); events",
439 ibooker.
book1D(
"efficiencyIsoTauET_EB_EE_threshold_" + str_threshold +
"_Num",
440 "iso tau efficiency (EB+EE); PFTau E_{T} (GeV); events",
445 ibooker.
book1D(
"efficiencyIsoTauET_EB_threshold_" + str_threshold +
"_Den",
446 "iso tau efficiency (EB); PFTau E_{T} (GeV); events",
450 ibooker.
book1D(
"efficiencyIsoTauET_EE_threshold_" + str_threshold +
"_Den",
451 "iso tau efficiency (EE); PFTau E_{T} (GeV); events",
455 ibooker.
book1D(
"efficiencyIsoTauET_EB_EE_threshold_" + str_threshold +
"_Den",
456 "iso tau efficiency (EB+EE); PFTau E_{T} (GeV); events",
462 ibooker.
book1D(
"efficiencyNonIsoTauET_EB_threshold_" + str_threshold +
"_Num",
463 "inclusive tau efficiency (EB); PFTau E_{T} (GeV); events",
467 ibooker.
book1D(
"efficiencyNonIsoTauET_EE_threshold_" + str_threshold +
"_Num",
468 "inclusive tau efficiency (EE); PFTau E_{T} (GeV); events",
472 ibooker.
book1D(
"efficiencyNonIsoTauET_EB_EE_threshold_" + str_threshold +
"_Num",
473 "inclusive tau efficiency (EB+EE); PFTau E_{T} (GeV); events",
478 ibooker.
book1D(
"efficiencyNonIsoTauET_EB_threshold_" + str_threshold +
"_Den",
479 "inclusive tau efficiency (EB); PFTau E_{T} (GeV); events",
483 ibooker.
book1D(
"efficiencyNonIsoTauET_EE_threshold_" + str_threshold +
"_Den",
484 "inclusive tau efficiency (EE); PFTau E_{T} (GeV); events",
488 ibooker.
book1D(
"efficiencyNonIsoTauET_EB_EE_threshold_" + str_threshold +
"_Den",
489 "inclusive tau efficiency (EB+EE); PFTau E_{T} (GeV); events",
504 bool hasPrimaryVertex =
false;
507 for (
auto vertexIt =
vertex->begin(); vertexIt !=
vertex->end(); ++vertexIt) {
508 if (vertexIt->isValid() && !vertexIt->isFake()) {
510 errVtx = vertexIt->error();
511 hasPrimaryVertex =
true;
517 if (!hasPrimaryVertex) {
519 errVtx(0, 0) =
beamSpot->BeamWidthX();
520 errVtx(1, 1) =
beamSpot->BeamWidthY();
530 double matchDeltaR = 9999;
540 if (hltFilterIndex < triggerEvent->sizeFilters()) {
544 const unsigned nTriggers = triggerVids.size();
545 for (
size_t iTrig = 0; iTrig < nTriggers; ++iTrig) {
549 if (dRtmp < matchDeltaR)
561 vector<l1t::Tau> l1tContainer;
562 l1tContainer.reserve(l1tCands->
size() + 1);
565 l1tContainer.push_back(*
tau);
569 TauL1TPair pairBestCand((*probeTauIt),
nullptr);
571 for (
auto l1tIt = l1tContainer.begin(); l1tIt != l1tContainer.end(); ++l1tIt) {
572 TauL1TPair pairTmpCand((*probeTauIt), &(*l1tIt));
575 pairBestCand = pairTmpCand;
589 pfmet = &(
mets->front());
593 for (
auto muonIt2 =
muons->begin(); muonIt2 !=
muons->end(); ++muonIt2) {
594 if (fabs(muonIt2->eta()) < 2.4 && muonIt2->pt() > 10 &&
muon::isLooseMuon((*muonIt2)) &&
595 (muonIt2->pfIsolationR04().sumChargedHadronPt +
596 max(muonIt2->pfIsolationR04().sumNeutralHadronEt + muonIt2->pfIsolationR04().sumPhotonEt -
597 0.5 * muonIt2->pfIsolationR04().sumPUPt,
604 bool foundTightMu =
false;
605 for (
auto muonIt =
muons->begin(); muonIt !=
muons->end(); ++muonIt) {
608 float muiso = (muonIt->pfIsolationR04().sumChargedHadronPt +
609 max(muonIt->pfIsolationR04().sumNeutralHadronEt + muonIt->pfIsolationR04().sumPhotonEt -
610 0.5 * muonIt->pfIsolationR04().sumPUPt,
614 if (muiso < 0.1 && nb_mu < 2 && !foundTightMu && fabs(muonIt->eta()) < 2.1 && muonIt->pt() > 24 &&
616 float mt =
sqrt(
pow(muonIt->pt() + pfmet->
pt(), 2) -
pow(muonIt->px() + pfmet->
px(), 2) -
617 pow(muonIt->py() + pfmet->
py(), 2));
635 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: reco::PFTauDiscriminator " << std::endl;
642 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: reco::PFTauDiscriminator " << std::endl;
649 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: reco::PFTauDiscriminator " << std::endl;
656 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: reco::PFTauDiscriminator " << std::endl;
670 const std::vector<edm::ParameterSet> psetsFromProvenance =
672 .getParameter<std::vector<edm::ParameterSet>>(
"IDWPdefinitions");
673 for (
uint i = 0;
i < psetsFromProvenance.size();
i++) {
674 if (psetsFromProvenance[
i].getParameter<std::string>(
"IDname") ==
AntiMuWP_)
680 const std::vector<std::string> psetsFromProvenance =
682 for (
uint i = 0;
i < psetsFromProvenance.size();
i++) {
689 const std::vector<edm::ParameterSet> psetsFromProvenance =
691 .getParameter<std::vector<edm::ParameterSet>>(
"IDWPdefinitions");
692 for (
uint i = 0;
i < psetsFromProvenance.size();
i++) {
693 if (psetsFromProvenance[
i].getParameter<std::string>(
"IDname") ==
comb3TWP_)
699 for (
auto tauIt =
taus->begin(); tauIt !=
taus->end(); ++tauIt, ++iTau) {
701 TLorentzVector mytau;
702 mytau.SetPtEtaPhiE(tauIt->pt(), tauIt->eta(), tauIt->phi(), tauIt->energy());
704 if (fabs(tauIt->charge()) == 1 && fabs(tauIt->eta()) < 2.1 && tauIt->pt() > 20 &&
706 (*antiele)[tauCandidate].workingPoints[
AntiEleWPIndex_] && (*dmf)[tauCandidate] > 0.5 &&
708 if (mymu.DeltaR(mytau) > 0.5 && (mymu + mytau).M() > 40 && (mymu + mytau).M() < 80 &&
726 for (
auto mon : monElementstoNormalize) {
727 if (
mon !=
nullptr) {
728 auto h =
mon->getTH2F();
730 h->Scale(1,
"width");