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;
121 edm::LogInfo(
"L1TTauOffline") <<
"Destructor L1TTauOffline::~L1TTauOffline " << std::endl;
133 edm::LogInfo(
"L1TTauOffline") <<
"L1TTauOffline::beginRun" << std::endl;
140 edm::LogInfo(
"L1TTauOffline") <<
"L1TTauOffline::bookHistograms" << std::endl;
148 std::size_t found0 = tNameTmp.find(
'*');
149 if (found0 != std::string::npos)
150 tNamePattern = tNameTmp.substr(0, tNameTmp.size() - 1);
152 tNamePattern = tNameTmp;
159 std::size_t
found = tmpName.find(tNamePattern);
160 if (
found != std::string::npos) {
179 if (!
taus.isValid()) {
180 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: reco::PFTauCollection " << std::endl;
187 if (!
muons.isValid()) {
188 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: reco::MuonCollection " << std::endl;
196 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: reco::BeamSpot " << std::endl;
204 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: reco::VertexCollection " << std::endl;
212 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: l1t::TauBxCollection " << std::endl;
220 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: edm::TriggerResults " << std::endl;
228 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: trigger::TriggerEvent " << std::endl;
235 if (!
mets.isValid()) {
236 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: reco::PFMETCollection " << std::endl;
248 vector<l1t::Tau> l1tContainer;
249 l1tContainer.reserve(l1tCands->
size() + 1);
252 l1tContainer.push_back(*
tau);
256 float eta = tauL1tPairsIt->eta();
257 float phi = tauL1tPairsIt->phi();
258 float pt = tauL1tPairsIt->pt();
261 float l1tPt = tauL1tPairsIt->l1tPt();
269 bool l1tAboveCut = (l1tPt >= l1tPtCut);
271 stringstream ptCutToTag;
272 ptCutToTag << l1tPtCut;
273 string ptTag = ptCutToTag.str();
277 if (fabs(
eta) < 1.5) {
298 if (fabs(
eta) < 1.5) {
315 if (tauL1tPairsIt->l1tIso() > 0.5) {
343 "L1 Tau E_{T} vs PFTau E_{T} (EB); PFTau E_{T} (GeV); L1 Tau E_{T} (GeV)",
345 &templateETvsET.
binsX[0],
347 &templateETvsET.
binsY[0]);
349 "L1 Tau E_{T} vs PFTau E_{T} (EE); PFTau E_{T} (GeV); L1 Tau E_{T} (GeV)",
351 &templateETvsET.
binsX[0],
353 &templateETvsET.
binsY[0]);
355 "L1 Tau E_{T} vs PFTau E_{T} (EB+EE); PFTau E_{T} (GeV); L1 Tau E_{T} (GeV)",
357 &templateETvsET.
binsX[0],
359 &templateETvsET.
binsY[0]);
363 ibooker.
book2D(
"L1TauPhivsTauPhi_EB",
364 "#phi_{tau}^{L1} vs #phi_{tau}^{offline} (EB); #phi_{tau}^{offline}; #phi_{tau}^{L1}",
366 templatePHIvsPHI.
xmin,
367 templatePHIvsPHI.
xmax,
369 templatePHIvsPHI.
ymin,
370 templatePHIvsPHI.
ymax);
372 ibooker.
book2D(
"L1TauPhivsTauPhi_EE",
373 "#phi_{tau}^{L1} vs #phi_{tau}^{offline} (EE); #phi_{tau}^{offline}; #phi_{tau}^{L1}",
375 templatePHIvsPHI.
xmin,
376 templatePHIvsPHI.
xmax,
378 templatePHIvsPHI.
ymin,
379 templatePHIvsPHI.
ymax);
381 ibooker.
book2D(
"L1TauPhivsTauPhi_EB_EE",
382 "#phi_{tau}^{L1} vs #phi_{tau}^{offline} (EB+EE); #phi_{tau}^{offline}; #phi_{tau}^{L1}",
384 templatePHIvsPHI.
xmin,
385 templatePHIvsPHI.
xmax,
387 templatePHIvsPHI.
ymin,
388 templatePHIvsPHI.
ymax);
391 ibooker.
book2D(
"L1TauEtavsTauEta",
"L1 Tau #eta vs PFTau #eta; PFTau #eta; L1 Tau #eta", 100, -3, 3, 100, -3, 3);
395 "resolutionTauET_EB",
"tau ET resolution (EB); (L1 Tau E_{T} - PFTau E_{T})/PFTau E_{T}; events", 50, -1, 1.5);
397 "resolutionTauET_EE",
"tau ET resolution (EE); (L1 Tau E_{T} - PFTau E_{T})/PFTau E_{T}; events", 50, -1, 1.5);
399 ibooker.
book1D(
"resolutionTauET_EB_EE",
400 "tau ET resolution (EB+EE); (L1 Tau E_{T} - PFTau E_{T})/PFTau E_{T}; events",
406 "#phi_{tau} resolution (EB); #phi_{tau}^{L1} - #phi_{tau}^{offline}; events",
411 "resolutionTauPhi_EE",
"tau #phi resolution (EE); #phi_{tau}^{L1} - #phi_{tau}^{offline}; events", 120, -0.3, 0.3);
413 ibooker.
book1D(
"resolutionTauPhi_EB_EE",
414 "tau #phi resolution (EB+EE); #phi_{tau}^{L1} - #phi_{tau}^{offline}; events",
420 ibooker.
book1D(
"resolutionTauEta",
"tau #eta resolution (EB); L1 Tau #eta - PFTau #eta; events", 120, -0.3, 0.3);
425 int nBins = tauBins.size() - 1;
426 float* tauBinArray = &(tauBins[0]);
431 ibooker.
book1D(
"efficiencyIsoTauET_EB_threshold_" + str_threshold +
"_Num",
432 "iso tau efficiency (EB); PFTau E_{T} (GeV); events",
436 ibooker.
book1D(
"efficiencyIsoTauET_EE_threshold_" + str_threshold +
"_Num",
437 "iso tau efficiency (EE); PFTau E_{T} (GeV); events",
441 ibooker.
book1D(
"efficiencyIsoTauET_EB_EE_threshold_" + str_threshold +
"_Num",
442 "iso tau efficiency (EB+EE); PFTau E_{T} (GeV); events",
447 ibooker.
book1D(
"efficiencyIsoTauET_EB_threshold_" + str_threshold +
"_Den",
448 "iso tau efficiency (EB); PFTau E_{T} (GeV); events",
452 ibooker.
book1D(
"efficiencyIsoTauET_EE_threshold_" + str_threshold +
"_Den",
453 "iso tau efficiency (EE); PFTau E_{T} (GeV); events",
457 ibooker.
book1D(
"efficiencyIsoTauET_EB_EE_threshold_" + str_threshold +
"_Den",
458 "iso tau efficiency (EB+EE); PFTau E_{T} (GeV); events",
464 ibooker.
book1D(
"efficiencyNonIsoTauET_EB_threshold_" + str_threshold +
"_Num",
465 "inclusive tau efficiency (EB); PFTau E_{T} (GeV); events",
469 ibooker.
book1D(
"efficiencyNonIsoTauET_EE_threshold_" + str_threshold +
"_Num",
470 "inclusive tau efficiency (EE); PFTau E_{T} (GeV); events",
474 ibooker.
book1D(
"efficiencyNonIsoTauET_EB_EE_threshold_" + str_threshold +
"_Num",
475 "inclusive tau efficiency (EB+EE); PFTau E_{T} (GeV); events",
480 ibooker.
book1D(
"efficiencyNonIsoTauET_EB_threshold_" + str_threshold +
"_Den",
481 "inclusive tau efficiency (EB); PFTau E_{T} (GeV); events",
485 ibooker.
book1D(
"efficiencyNonIsoTauET_EE_threshold_" + str_threshold +
"_Den",
486 "inclusive tau efficiency (EE); PFTau E_{T} (GeV); events",
490 ibooker.
book1D(
"efficiencyNonIsoTauET_EB_EE_threshold_" + str_threshold +
"_Den",
491 "inclusive tau efficiency (EB+EE); PFTau E_{T} (GeV); events",
506 bool hasPrimaryVertex =
false;
509 for (
auto vertexIt =
vertex->begin(); vertexIt !=
vertex->end(); ++vertexIt) {
510 if (vertexIt->isValid() && !vertexIt->isFake()) {
512 errVtx = vertexIt->error();
513 hasPrimaryVertex =
true;
519 if (!hasPrimaryVertex) {
521 errVtx(0, 0) =
beamSpot->BeamWidthX();
522 errVtx(1, 1) =
beamSpot->BeamWidthY();
532 double matchDeltaR = 9999;
542 if (hltFilterIndex < triggerEvent->sizeFilters()) {
546 const unsigned nTriggers = triggerVids.size();
547 for (
size_t iTrig = 0; iTrig < nTriggers; ++iTrig) {
551 if (dRtmp < matchDeltaR)
563 vector<l1t::Tau> l1tContainer;
564 l1tContainer.reserve(l1tCands->
size() + 1);
567 l1tContainer.push_back(*
tau);
571 TauL1TPair pairBestCand((*probeTauIt),
nullptr);
573 for (
auto l1tIt = l1tContainer.begin(); l1tIt != l1tContainer.end(); ++l1tIt) {
574 TauL1TPair pairTmpCand((*probeTauIt), &(*l1tIt));
577 pairBestCand = pairTmpCand;
591 pfmet = &(
mets->front());
595 for (
auto muonIt2 =
muons->begin(); muonIt2 !=
muons->end(); ++muonIt2) {
596 if (fabs(muonIt2->eta()) < 2.4 && muonIt2->pt() > 10 &&
muon::isLooseMuon((*muonIt2)) &&
597 (muonIt2->pfIsolationR04().sumChargedHadronPt +
598 max(muonIt2->pfIsolationR04().sumNeutralHadronEt + muonIt2->pfIsolationR04().sumPhotonEt -
599 0.5 * muonIt2->pfIsolationR04().sumPUPt,
606 bool foundTightMu =
false;
607 for (
auto muonIt =
muons->begin(); muonIt !=
muons->end(); ++muonIt) {
610 float muiso = (muonIt->pfIsolationR04().sumChargedHadronPt +
611 max(muonIt->pfIsolationR04().sumNeutralHadronEt + muonIt->pfIsolationR04().sumPhotonEt -
612 0.5 * muonIt->pfIsolationR04().sumPUPt,
616 if (muiso < 0.1 && nb_mu < 2 && !foundTightMu && fabs(muonIt->eta()) < 2.1 && muonIt->pt() > 24 &&
618 float mt =
sqrt(
pow(muonIt->pt() + pfmet->
pt(), 2) -
pow(muonIt->px() + pfmet->
px(), 2) -
619 pow(muonIt->py() + pfmet->
py(), 2));
637 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: reco::PFTauDiscriminator " << std::endl;
644 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: reco::PFTauDiscriminator " << std::endl;
651 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: reco::PFTauDiscriminator " << std::endl;
658 edm::LogWarning(
"L1TTauOffline") <<
"invalid collection: reco::PFTauDiscriminator " << std::endl;
672 const std::vector<edm::ParameterSet> psetsFromProvenance =
674 .getParameter<std::vector<edm::ParameterSet>>(
"IDWPdefinitions");
675 for (
uint i = 0;
i < psetsFromProvenance.size();
i++) {
676 if (psetsFromProvenance[
i].getParameter<std::string>(
"IDname") ==
AntiMuWP_)
682 const std::vector<std::string> psetsFromProvenance =
684 .getParameter<std::vector<std::string>>(
"workingPoints");
685 for (
uint i = 0;
i < psetsFromProvenance.size();
i++) {
692 const std::vector<edm::ParameterSet> psetsFromProvenance =
694 .getParameter<std::vector<edm::ParameterSet>>(
"IDWPdefinitions");
695 for (
uint i = 0;
i < psetsFromProvenance.size();
i++) {
696 if (psetsFromProvenance[
i].getParameter<std::string>(
"IDname") ==
comb3TWP_)
702 for (
auto tauIt =
taus->begin(); tauIt !=
taus->end(); ++tauIt, ++iTau) {
704 TLorentzVector mytau;
705 mytau.SetPtEtaPhiE(tauIt->pt(), tauIt->eta(), tauIt->phi(), tauIt->energy());
707 if ((*antimu)[tauCandidate].workingPoints.empty()) {
708 edm::LogWarning(
"L1TTauOffline") <<
"This offline tau has no antimu discriminator, skipping" << std::endl;
712 edm::LogWarning(
"L1TTauOffline") <<
"This offline tau has no antiele discriminator, skipping" << std::endl;
716 edm::LogWarning(
"L1TTauOffline") <<
"This offline tau has no comb3T discriminator, skipping" << std::endl;
720 if (fabs(tauIt->charge()) == 1 && fabs(tauIt->eta()) < 2.1 && tauIt->pt() > 20 &&
722 (*antiele)[tauCandidate].workingPoints[
AntiEleWPIndex_] && (*dmf)[tauCandidate] > 0.5 &&
724 if (mymu.DeltaR(mytau) > 0.5 && (mymu + mytau).M() > 40 && (mymu + mytau).M() < 80 &&
742 for (
auto mon : monElementstoNormalize) {
743 if (
mon !=
nullptr) {
744 auto h =
mon->getTH2F();
746 h->Scale(1,
"width");