Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-08-26 00:19:32

0001 #include "L1Trigger/Phase2L1Taus/interface/L1HPSPFTauBuilder.h"
0002 #include "FWCore/Utilities/interface/Exception.h"  // cms::Exception
0003 #include "DataFormats/Math/interface/deltaR.h"     // reco::deltaR
0004 #include <regex>                                   // sd::regex_replace
0005 #include <TMath.h>                                 // TMath::Pi()
0006 #include <string>                                  // std::string
0007 #include <algorithm>                               // std::max(), std::sort()
0008 #include <cmath>                                   // std::fabs
0009 
0010 L1HPSPFTauBuilder::L1HPSPFTauBuilder(const edm::ParameterSet& cfg)
0011     : signalConeSizeFormula_(
0012           std::regex_replace(cfg.getParameter<std::string>("signalConeSize"), std::regex("pt"), "x")),
0013       minSignalConeSize_(cfg.getParameter<double>("minSignalConeSize")),
0014       maxSignalConeSize_(cfg.getParameter<double>("maxSignalConeSize")),
0015       useStrips_(cfg.getParameter<bool>("useStrips")),
0016       stripSizeEta_(cfg.getParameter<double>("stripSizeEta")),
0017       stripSizePhi_(cfg.getParameter<double>("stripSizePhi")),
0018       isolationConeSize_(cfg.getParameter<double>("isolationConeSize")),
0019       debug_(cfg.getUntrackedParameter<bool>("debug", false)) {
0020   assert(maxSignalConeSize_ >= minSignalConeSize_);
0021 
0022   isolationConeSize2_ = isolationConeSize_ * isolationConeSize_;
0023 
0024   if (debug_) {
0025     std::cout << "setting Quality cuts for signal PFCands:" << std::endl;
0026   }
0027   edm::ParameterSet cfg_signalQualityCuts = cfg.getParameter<edm::ParameterSet>("signalQualityCuts");
0028   signalQualityCutsDzCutDisabled_ = readL1PFTauQualityCuts(cfg_signalQualityCuts, "disabled", debug_);
0029   signalQualityCutsDzCutEnabledPrimary_ = readL1PFTauQualityCuts(cfg_signalQualityCuts, "enabled_primary", debug_);
0030   if (debug_) {
0031     std::cout << "setting Quality cuts for isolation PFCands:" << std::endl;
0032   }
0033   edm::ParameterSet cfg_isolationQualityCuts = cfg.getParameter<edm::ParameterSet>("isolationQualityCuts");
0034   isolationQualityCutsDzCutDisabled_ = readL1PFTauQualityCuts(cfg_isolationQualityCuts, "disabled", debug_);
0035   isolationQualityCutsDzCutEnabledPrimary_ =
0036       readL1PFTauQualityCuts(cfg_isolationQualityCuts, "enabled_primary", debug_);
0037   isolationQualityCutsDzCutEnabledPileup_ = readL1PFTauQualityCuts(cfg_isolationQualityCuts, "enabled_pileup", debug_);
0038 }
0039 
0040 void L1HPSPFTauBuilder::reset() {
0041   signalConeSize_ = 0.;
0042   signalConeSize2_ = 0.;
0043 
0044   l1PFCandProductID_ = edm::ProductID();
0045   isPFCandSeeded_ = false;
0046   l1PFCandSeed_ = l1t::PFCandidateRef();
0047   isJetSeeded_ = false;
0048   l1JetSeed_ = reco::CaloJetRef();
0049   l1PFTauSeedEta_ = 0.;
0050   l1PFTauSeedPhi_ = 0.;
0051   l1PFTauSeedZVtx_ = 0.;
0052   sumAllL1PFCandidatesPt_ = 0.;
0053   primaryVertex_ = l1t::VertexWordRef();
0054   l1PFTau_ = l1t::HPSPFTau();
0055 
0056   stripP4_ = reco::Particle::LorentzVector(0., 0., 0., 0.);
0057 
0058   signalAllL1PFCandidates_.clear();
0059   signalChargedHadrons_.clear();
0060   signalElectrons_.clear();
0061   signalNeutralHadrons_.clear();
0062   signalPhotons_.clear();
0063   signalMuons_.clear();
0064 
0065   stripAllL1PFCandidates_.clear();
0066   stripElectrons_.clear();
0067   stripPhotons_.clear();
0068 
0069   isoAllL1PFCandidates_.clear();
0070   isoChargedHadrons_.clear();
0071   isoElectrons_.clear();
0072   isoNeutralHadrons_.clear();
0073   isoPhotons_.clear();
0074   isoMuons_.clear();
0075 
0076   sumAllL1PFCandidates_.clear();
0077   sumChargedHadrons_.clear();
0078   sumElectrons_.clear();
0079   sumNeutralHadrons_.clear();
0080   sumPhotons_.clear();
0081   sumMuons_.clear();
0082 
0083   sumChargedIsoPileup_ = 0.;
0084 }
0085 
0086 void L1HPSPFTauBuilder::setL1PFCandProductID(const edm::ProductID& l1PFCandProductID) {
0087   l1PFCandProductID_ = l1PFCandProductID;
0088 }
0089 
0090 void L1HPSPFTauBuilder::setVertex(const l1t::VertexWordRef& primaryVertex) { primaryVertex_ = primaryVertex; }
0091 
0092 void L1HPSPFTauBuilder::setL1PFTauSeed(const l1t::PFCandidateRef& l1PFCandSeed) {
0093   if (debug_) {
0094     std::cout << "<L1HPSPFTauBuilder::setL1PFTauSeed>:" << std::endl;
0095     std::cout << "seeding HPSPFTau with ChargedPFCand:";
0096     printPFCand(std::cout, *l1PFCandSeed, primaryVertex_);
0097   }
0098 
0099   l1PFCandSeed_ = l1PFCandSeed;
0100   l1PFTauSeedEta_ = l1PFCandSeed->eta();
0101   l1PFTauSeedPhi_ = l1PFCandSeed->phi();
0102   if (l1PFCandSeed->charge() != 0 && l1PFCandSeed->pfTrack().isNonnull()) {
0103     l1PFTauSeedZVtx_ = l1PFCandSeed->pfTrack()->vertex().z();
0104     isPFCandSeeded_ = true;
0105   }
0106 }
0107 // This is commented as l1JetSeed->numberOfDaughters() = 0
0108 // Alternative way is used below for the moment
0109 /* 
0110 void L1HPSPFTauBuilder::setL1PFTauSeed(const reco::CaloJetRef& l1JetSeed) {
0111   if (debug_) {
0112     std::cout << "<L1HPSPFTauBuilder::setL1PFTauSeed>:" << std::endl;
0113     std::cout << "seeding HPSPFTau with Jet:";
0114     std::cout << " pT = " << l1JetSeed->pt() << ", eta = " << l1JetSeed->eta() << ", phi = " << l1JetSeed->phi()
0115               << std::endl;
0116   }
0117 
0118   l1JetSeed_ = l1JetSeed;
0119   reco::Candidate::LorentzVector l1PFTauSeed_p4;
0120   float l1PFTauSeedZVtx = 0.;
0121   bool l1PFTauSeed_hasVtx = false;
0122   float max_chargedPFCand_pt = -1.;
0123   size_t numConstituents = l1JetSeed->numberOfDaughters();
0124   for (size_t idxConstituent = 0; idxConstituent < numConstituents; ++idxConstituent) {
0125     const l1t::PFCandidate* l1PFCand = dynamic_cast<const l1t::PFCandidate*>(l1JetSeed->daughter(idxConstituent));
0126     if (!l1PFCand) {
0127       throw cms::Exception("L1HPSPFTauBuilder") << "Jet was not built from l1t::PFCandidates !!\n";
0128     }
0129     if (l1PFCand->id() == l1t::PFCandidate::ChargedHadron || l1PFCand->id() == l1t::PFCandidate::Electron ||
0130         l1PFCand->id() == l1t::PFCandidate::Photon || l1PFCand->id() == l1t::PFCandidate::Muon) {
0131       l1PFTauSeed_p4 += l1PFCand->p4();
0132       if (l1PFCand->charge() != 0 && l1PFCand->pfTrack().isNonnull() && l1PFCand->pt() > max_chargedPFCand_pt) {
0133         l1PFTauSeedZVtx = l1PFCand->pfTrack()->vertex().z();
0134         l1PFTauSeed_hasVtx = true;
0135         max_chargedPFCand_pt = l1PFCand->pt();
0136       }
0137     }
0138   }
0139   if (l1PFTauSeed_p4.pt() > 1. && l1PFTauSeed_hasVtx) {
0140     l1PFTauSeedEta_ = l1PFTauSeed_p4.eta();
0141     l1PFTauSeedPhi_ = l1PFTauSeed_p4.phi();
0142     l1PFTauSeedZVtx_ = l1PFTauSeedZVtx;
0143     isJetSeeded_ = true;
0144   }
0145 }
0146 */
0147 void L1HPSPFTauBuilder::setL1PFTauSeed(const reco::CaloJetRef& l1JetSeed,
0148                                        const std::vector<l1t::PFCandidateRef>& l1PFCands) {
0149   if (debug_) {
0150     std::cout << "<L1HPSPFTauBuilder::setL1PFTauSeed>:" << std::endl;
0151     std::cout << "seeding HPSPFTau with Jet:";
0152     std::cout << " pT = " << l1JetSeed->pt() << ", eta = " << l1JetSeed->eta() << ", phi = " << l1JetSeed->phi()
0153               << std::endl;
0154   }
0155 
0156   l1JetSeed_ = l1JetSeed;
0157   reco::Candidate::LorentzVector l1PFTauSeed_p4;
0158   float l1PFTauSeedZVtx = 0.;
0159   bool l1PFTauSeed_hasVtx = false;
0160   float max_chargedPFCand_pt = -1.;
0161   for (const auto& l1PFCand : l1PFCands) {
0162     double dR = reco::deltaR(l1PFCand->eta(), l1PFCand->phi(), l1JetSeed->eta(), l1JetSeed->phi());
0163     if (dR > 0.4)
0164       continue;
0165     if (l1PFCand->id() == l1t::PFCandidate::ChargedHadron || l1PFCand->id() == l1t::PFCandidate::Electron ||
0166         l1PFCand->id() == l1t::PFCandidate::Photon || l1PFCand->id() == l1t::PFCandidate::Muon) {
0167       l1PFTauSeed_p4 += l1PFCand->p4();
0168       if (l1PFCand->charge() != 0 && l1PFCand->pfTrack().isNonnull() && l1PFCand->pt() > max_chargedPFCand_pt) {
0169         l1PFTauSeedZVtx = l1PFCand->pfTrack()->vertex().z();
0170         l1PFTauSeed_hasVtx = true;
0171         max_chargedPFCand_pt = l1PFCand->pt();
0172       }
0173     }
0174   }
0175   if (l1PFTauSeed_p4.pt() > 1. && l1PFTauSeed_hasVtx) {
0176     l1PFTauSeedEta_ = l1PFTauSeed_p4.eta();
0177     l1PFTauSeedPhi_ = l1PFTauSeed_p4.phi();
0178     l1PFTauSeedZVtx_ = l1PFTauSeedZVtx;
0179     isJetSeeded_ = true;
0180   }
0181 }
0182 
0183 void L1HPSPFTauBuilder::addL1PFCandidates(const std::vector<l1t::PFCandidateRef>& l1PFCands) {
0184   if (debug_) {
0185     std::cout << "<L1HPSPFTauBuilder::addL1PFCandidates>:" << std::endl;
0186   }
0187 
0188   // do not build tau candidates for which no reference z-position exists,
0189   // as in this case charged PFCands originating from the primary (hard-scatter) interaction
0190   // cannot be distinguished from charged PFCands originating from pileup
0191   if (!(isPFCandSeeded_ || isJetSeeded_))
0192     return;
0193 
0194   for (const auto& l1PFCand : l1PFCands) {
0195     if (!isWithinIsolationCone(*l1PFCand))
0196       continue;
0197     sumAllL1PFCandidates_.push_back(l1PFCand);
0198     if (l1PFCand->id() == l1t::PFCandidate::ChargedHadron) {
0199       sumChargedHadrons_.push_back(l1PFCand);
0200     } else if (l1PFCand->id() == l1t::PFCandidate::Electron) {
0201       sumElectrons_.push_back(l1PFCand);
0202     } else if (l1PFCand->id() == l1t::PFCandidate::NeutralHadron) {
0203       sumNeutralHadrons_.push_back(l1PFCand);
0204     } else if (l1PFCand->id() == l1t::PFCandidate::Photon) {
0205       sumPhotons_.push_back(l1PFCand);
0206     } else if (l1PFCand->id() == l1t::PFCandidate::Muon) {
0207       sumMuons_.push_back(l1PFCand);
0208     }
0209   }
0210 
0211   for (const auto& l1PFCand : sumAllL1PFCandidates_) {
0212     sumAllL1PFCandidatesPt_ += l1PFCand->pt();
0213   }
0214   std::vector<double> emptyV;
0215   std::vector<double> sumAllL1PFCandidatesPt(1);
0216   sumAllL1PFCandidatesPt[0] = sumAllL1PFCandidatesPt_;
0217 
0218   signalConeSize_ = signalConeSizeFormula_.evaluate(sumAllL1PFCandidatesPt, emptyV);
0219 
0220   if (signalConeSize_ < minSignalConeSize_)
0221     signalConeSize_ = minSignalConeSize_;
0222   if (signalConeSize_ > maxSignalConeSize_)
0223     signalConeSize_ = maxSignalConeSize_;
0224   signalConeSize2_ = signalConeSize_ * signalConeSize_;
0225 
0226   for (const auto& l1PFCand : sumAllL1PFCandidates_) {
0227     if (debug_) {
0228       printPFCand(std::cout, *l1PFCand, primaryVertex_);
0229     }
0230 
0231     bool isSignalPFCand = false;
0232     bool isStripPFCand = false;
0233     bool isElectron_or_Photon =
0234         l1PFCand->id() == l1t::PFCandidate::Electron || l1PFCand->id() == l1t::PFCandidate::Photon;
0235     bool isChargedHadron = l1PFCand->id() == l1t::PFCandidate::ChargedHadron;
0236     if (isWithinSignalCone(*l1PFCand) && !(isChargedHadron && signalChargedHadrons_.size() > 3)) {
0237       isSignalPFCand = true;
0238     }
0239     if (isElectron_or_Photon && isWithinStrip(*l1PFCand)) {
0240       if (useStrips_) {
0241         isSignalPFCand = true;
0242       }
0243       isStripPFCand = true;
0244     }
0245     bool passesSignalQualityCuts = isSelected(signalQualityCutsDzCutEnabledPrimary_, *l1PFCand, l1PFTauSeedZVtx_);
0246     if (isSignalPFCand && passesSignalQualityCuts) {
0247       signalAllL1PFCandidates_.push_back(l1PFCand);
0248       if (l1PFCand->id() == l1t::PFCandidate::ChargedHadron) {
0249         signalChargedHadrons_.push_back(l1PFCand);
0250       } else if (l1PFCand->id() == l1t::PFCandidate::Electron) {
0251         signalElectrons_.push_back(l1PFCand);
0252       } else if (l1PFCand->id() == l1t::PFCandidate::NeutralHadron) {
0253         signalNeutralHadrons_.push_back(l1PFCand);
0254       } else if (l1PFCand->id() == l1t::PFCandidate::Photon) {
0255         signalPhotons_.push_back(l1PFCand);
0256       } else if (l1PFCand->id() == l1t::PFCandidate::Muon) {
0257         signalMuons_.push_back(l1PFCand);
0258       }
0259     }
0260     if (isStripPFCand && passesSignalQualityCuts) {
0261       stripAllL1PFCandidates_.push_back(l1PFCand);
0262       if (l1PFCand->id() == l1t::PFCandidate::Electron) {
0263         stripElectrons_.push_back(l1PFCand);
0264         stripP4_ += l1PFCand->p4();
0265       } else if (l1PFCand->id() == l1t::PFCandidate::Photon) {
0266         stripPhotons_.push_back(l1PFCand);
0267         stripP4_ += l1PFCand->p4();
0268       } else
0269         assert(0);
0270     }
0271 
0272     bool isIsolationPFCand = isWithinIsolationCone(*l1PFCand) && !isSignalPFCand;
0273     bool passesIsolationQualityCuts = isSelected(isolationQualityCutsDzCutEnabledPrimary_, *l1PFCand, l1PFTauSeedZVtx_);
0274     if (isIsolationPFCand && passesIsolationQualityCuts) {
0275       isoAllL1PFCandidates_.push_back(l1PFCand);
0276       if (l1PFCand->id() == l1t::PFCandidate::ChargedHadron) {
0277         isoChargedHadrons_.push_back(l1PFCand);
0278       } else if (l1PFCand->id() == l1t::PFCandidate::Electron) {
0279         isoElectrons_.push_back(l1PFCand);
0280       } else if (l1PFCand->id() == l1t::PFCandidate::NeutralHadron) {
0281         isoNeutralHadrons_.push_back(l1PFCand);
0282       } else if (l1PFCand->id() == l1t::PFCandidate::Photon) {
0283         isoPhotons_.push_back(l1PFCand);
0284       } else if (l1PFCand->id() == l1t::PFCandidate::Muon) {
0285         isoMuons_.push_back(l1PFCand);
0286       }
0287     }
0288 
0289     if (debug_) {
0290       std::cout << "dR = " << reco::deltaR(l1PFCand->eta(), l1PFCand->phi(), l1PFTauSeedEta_, l1PFTauSeedPhi_) << ":"
0291                 << " isSignalPFCand = " << isSignalPFCand << ", isStripPFCand = " << isStripPFCand
0292                 << " (passesSignalQualityCuts = " << passesSignalQualityCuts << "),"
0293                 << " isIsolationPFCand = " << isIsolationPFCand
0294                 << " (passesIsolationQualityCuts = " << passesIsolationQualityCuts << ")" << std::endl;
0295     }
0296   }
0297 
0298   for (const auto& l1PFCand : l1PFCands) {
0299     if (!isWithinIsolationCone(*l1PFCand))
0300       continue;
0301 
0302     if (l1PFCand->charge() != 0 && isSelected(isolationQualityCutsDzCutEnabledPileup_, *l1PFCand, l1PFTauSeedZVtx_)) {
0303       sumChargedIsoPileup_ += l1PFCand->pt();
0304     }
0305   }
0306 }
0307 
0308 //void L1HPSPFTauBuilder::setRho(double rho) { rho_ = rho; }
0309 
0310 bool L1HPSPFTauBuilder::isWithinSignalCone(const l1t::PFCandidate& l1PFCand) {
0311   if (isPFCandSeeded_ || isJetSeeded_) {
0312     double deltaEta = l1PFCand.eta() - l1PFTauSeedEta_;
0313     double deltaPhi = l1PFCand.phi() - l1PFTauSeedPhi_;
0314     if ((deltaEta * deltaEta + deltaPhi * deltaPhi) < signalConeSize2_)
0315       return true;
0316   }
0317   return false;
0318 }
0319 
0320 bool L1HPSPFTauBuilder::isWithinStrip(const l1t::PFCandidate& l1PFCand) {
0321   if (isPFCandSeeded_ || isJetSeeded_) {
0322     double deltaEta = l1PFCand.eta() - l1PFTauSeedEta_;
0323     double deltaPhi = l1PFCand.phi() - l1PFTauSeedPhi_;
0324     if (std::fabs(deltaEta) < stripSizeEta_ && std::fabs(deltaPhi) < stripSizePhi_)
0325       return true;
0326   }
0327   return false;
0328 }
0329 
0330 bool L1HPSPFTauBuilder::isWithinIsolationCone(const l1t::PFCandidate& l1PFCand) {
0331   double deltaEta = l1PFCand.eta() - l1PFTauSeedEta_;
0332   double deltaPhi = l1PFCand.phi() - l1PFTauSeedPhi_;
0333   if ((deltaEta * deltaEta + deltaPhi * deltaPhi) < isolationConeSize2_)
0334     return true;
0335   else
0336     return false;
0337 }
0338 
0339 void L1HPSPFTauBuilder::buildL1PFTau() {
0340   reco::Particle::LorentzVector l1PFTau_p4;
0341   for (const auto& l1PFCand : signalAllL1PFCandidates_) {
0342     if (l1PFCand->id() == l1t::PFCandidate::ChargedHadron || l1PFCand->id() == l1t::PFCandidate::Electron ||
0343         l1PFCand->id() == l1t::PFCandidate::Photon) {
0344       l1PFTau_p4 += l1PFCand->p4();
0345       if (l1PFCand->charge() != 0 &&
0346           (l1PFTau_.leadChargedPFCand().isNull() || l1PFCand->pt() > l1PFTau_.leadChargedPFCand()->pt())) {
0347         l1PFTau_.setLeadChargedPFCand(l1PFCand);
0348       }
0349     }
0350   }
0351   if (l1PFTau_.leadChargedPFCand().isNonnull() && l1PFTau_.leadChargedPFCand()->pfTrack().isNonnull()) {
0352     l1PFTau_.setZ(l1PFTau_.leadChargedPFCand()->pfTrack()->vertex().z());
0353 
0354     l1PFTau_.setP4(l1PFTau_p4);
0355 
0356     l1PFTau_.setSeedChargedPFCand(l1PFCandSeed_);
0357     l1PFTau_.setSeedJet(l1JetSeed_);
0358 
0359     l1PFTau_.setSignalAllL1PFCandidates(convertToRefVector(signalAllL1PFCandidates_));
0360     l1PFTau_.setSignalChargedHadrons(convertToRefVector(signalChargedHadrons_));
0361     l1PFTau_.setSignalElectrons(convertToRefVector(signalElectrons_));
0362     l1PFTau_.setSignalNeutralHadrons(convertToRefVector(signalNeutralHadrons_));
0363     l1PFTau_.setSignalPhotons(convertToRefVector(signalPhotons_));
0364     l1PFTau_.setSignalMuons(convertToRefVector(signalMuons_));
0365 
0366     l1PFTau_.setStripAllL1PFCandidates(convertToRefVector(stripAllL1PFCandidates_));
0367     l1PFTau_.setStripElectrons(convertToRefVector(stripElectrons_));
0368     l1PFTau_.setStripPhotons(convertToRefVector(stripPhotons_));
0369 
0370     l1PFTau_.setIsoAllL1PFCandidates(convertToRefVector(isoAllL1PFCandidates_));
0371     l1PFTau_.setIsoChargedHadrons(convertToRefVector(isoChargedHadrons_));
0372     l1PFTau_.setIsoElectrons(convertToRefVector(isoElectrons_));
0373     l1PFTau_.setIsoNeutralHadrons(convertToRefVector(isoNeutralHadrons_));
0374     l1PFTau_.setIsoPhotons(convertToRefVector(isoPhotons_));
0375     l1PFTau_.setIsoMuons(convertToRefVector(isoMuons_));
0376 
0377     l1PFTau_.setSumAllL1PFCandidates(convertToRefVector(sumAllL1PFCandidates_));
0378     l1PFTau_.setSumChargedHadrons(convertToRefVector(sumChargedHadrons_));
0379     l1PFTau_.setSumElectrons(convertToRefVector(sumElectrons_));
0380     l1PFTau_.setSumNeutralHadrons(convertToRefVector(sumNeutralHadrons_));
0381     l1PFTau_.setSumPhotons(convertToRefVector(sumPhotons_));
0382     l1PFTau_.setSumMuons(convertToRefVector(sumMuons_));
0383 
0384     l1PFTau_.setPrimaryVertex(primaryVertex_);
0385 
0386     if (l1PFTau_.signalChargedHadrons().size() > 1) {
0387       if (stripP4_.pt() < 5.)
0388         l1PFTau_.setTauType(l1t::HPSPFTau::kThreeProng0Pi0);
0389       else
0390         l1PFTau_.setTauType(l1t::HPSPFTau::kThreeProng1Pi0);
0391     } else {
0392       if (stripP4_.pt() < 5.)
0393         l1PFTau_.setTauType(l1t::HPSPFTau::kOneProng0Pi0);
0394       else
0395         l1PFTau_.setTauType(l1t::HPSPFTau::kOneProng1Pi0);
0396     }
0397 
0398     l1PFTau_.setStripP4(stripP4_);
0399 
0400     l1PFTau_.setSumAllL1PFCandidatesPt(sumAllL1PFCandidatesPt_);
0401     l1PFTau_.setSignalConeSize(signalConeSize_);
0402     l1PFTau_.setisolationConeSize(isolationConeSize_);
0403 
0404     double sumChargedIso = 0.;
0405     double sumNeutralIso = 0.;
0406     for (const auto& l1PFCand : isoAllL1PFCandidates_) {
0407       if (l1PFCand->charge() != 0) {
0408         sumChargedIso += l1PFCand->pt();
0409       } else if (l1PFCand->id() == l1t::PFCandidate::Photon) {
0410         sumNeutralIso += l1PFCand->pt();
0411       }
0412     }
0413     l1PFTau_.setSumChargedIso(sumChargedIso);
0414     l1PFTau_.setSumNeutralIso(sumNeutralIso);
0415     const double weightNeutralIso = 1.;
0416     const double offsetNeutralIso = 0.;
0417     l1PFTau_.setSumCombinedIso(sumChargedIso + weightNeutralIso * (sumNeutralIso - offsetNeutralIso));
0418     l1PFTau_.setSumChargedIsoPileup(sumChargedIsoPileup_);
0419 
0420     if (l1PFTau_.sumChargedIso() < 20.0) {
0421       l1PFTau_.setPassVLooseIso(true);
0422     }
0423     if (l1PFTau_.sumChargedIso() < 10.0) {
0424       l1PFTau_.setPassLooseIso(true);
0425     }
0426     if (l1PFTau_.sumChargedIso() < 5.0) {
0427       l1PFTau_.setPassMediumIso(true);
0428     }
0429     if (l1PFTau_.sumChargedIso() < 2.5) {
0430       l1PFTau_.setPassTightIso(true);
0431     }
0432 
0433     if (l1PFTau_p4.pt() != 0) {
0434       if (l1PFTau_.sumChargedIso() / l1PFTau_p4.pt() < 0.40) {
0435         l1PFTau_.setPassVLooseRelIso(true);
0436       }
0437       if (l1PFTau_.sumChargedIso() / l1PFTau_p4.pt() < 0.20) {
0438         l1PFTau_.setPassLooseRelIso(true);
0439       }
0440       if (l1PFTau_.sumChargedIso() / l1PFTau_p4.pt() < 0.10) {
0441         l1PFTau_.setPassMediumRelIso(true);
0442       }
0443       if (l1PFTau_.sumChargedIso() / l1PFTau_p4.pt() < 0.05) {
0444         l1PFTau_.setPassTightRelIso(true);
0445       }
0446     }
0447   }
0448 }
0449 
0450 l1t::PFCandidateRefVector L1HPSPFTauBuilder::convertToRefVector(const std::vector<l1t::PFCandidateRef>& l1PFCands) {
0451   l1t::PFCandidateRefVector l1PFCandsRefVector(l1PFCandProductID_);
0452   for (const auto& l1PFCand : l1PFCands) {
0453     l1PFCandsRefVector.push_back(l1PFCand);
0454   }
0455   return l1PFCandsRefVector;
0456 }