304 LogDebug(
"discriminate") <<
" tau: Pt = " << pfTau->pt() <<
", eta = " << pfTau->eta() <<
", phi = " << pfTau->phi();
308 std::vector<CandidatePtr> isoCharged_;
309 std::vector<CandidatePtr> isoNeutral_;
310 std::vector<CandidatePtr> isoPU_;
312 std::vector<CandidatePtr> chPV_;
313 isoCharged_.
reserve(pfTau->isolationChargedHadrCands().size());
314 isoNeutral_.reserve(pfTau->isolationGammaCands().size());
316 isoNeutralWeight_.
reserve(pfTau->isolationGammaCands().size());
325 if (
pv.isNonnull()) {
326 LogTrace(
"discriminate") <<
"pv: x = " <<
pv->position().x() <<
", y = " <<
pv->position().y()
327 <<
", z = " <<
pv->position().z();
329 LogTrace(
"discriminate") <<
"pv: N/A";
331 if (pfTau->leadChargedHadrCand().
isNonnull()) {
332 LogTrace(
"discriminate") <<
"leadPFChargedHadron:"
333 <<
" Pt = " << pfTau->leadChargedHadrCand()->pt() <<
","
334 <<
" eta = " << pfTau->leadChargedHadrCand()->eta() <<
","
335 <<
" phi = " << pfTau->leadChargedHadrCand()->phi();
337 LogTrace(
"discriminate") <<
"leadPFChargedHadron: N/A";
342 if (!(
pv.isNonnull() && pfTau->leadChargedHadrCand().
isNonnull()))
346 qcuts_->setLeadTrack(*pfTau->leadChargedHadrCand());
357 for (
auto const&
cand : pfTau->isolationChargedHadrCands()) {
359 LogTrace(
"discriminate") <<
"adding charged iso cand with pt " <<
cand->pt();
360 isoCharged_.push_back(
cand);
365 for (
auto const&
cand : pfTau->isolationGammaCands()) {
367 LogTrace(
"discriminate") <<
"adding neutral iso cand with pt " <<
cand->pt();
368 isoNeutral_.push_back(
cand);
386 LogTrace(
"discriminate") <<
"After track cuts: " << allPU.size();
394 LogTrace(
"discriminate") <<
"After cleaning cuts: " << cleanPU.size();
398 for (
auto const&
cand : cleanPU) {
399 if (deltaBetaFilter(
cand))
400 isoPU_.push_back(
cand);
403 for (
auto const&
cand : cleanNPU) {
404 if (deltaBetaFilter(
cand))
405 chPV_.push_back(
cand);
407 LogTrace(
"discriminate") <<
"After cone cuts: " << isoPU_.size() <<
" " << chPV_.size();
415 for (
auto const& isoObject : isoNeutral_) {
416 if (isoObject->charge() != 0) {
422 double eta = isoObject->eta();
423 double phi = isoObject->phi();
428 if ((sumNPU + sumPU) > 0)
429 neutral.setP4(((sumNPU) / (sumNPU + sumPU)) * neutral.p4());
439 std::vector<CandidatePtr> isoCharged_filter;
440 std::vector<CandidatePtr> isoNeutral_filter;
443 for (
auto const& isoObject : isoCharged_) {
448 for (
auto const& isoObject : isoNeutral_) {
450 isoNeutral_filter.push_back(isoObject);
452 isoNeutral_ = isoNeutral_filter;
454 for (
auto const& isoObject : isoNeutralWeight_) {
455 if (filter2(isoObject))
456 isoNeutralWeight_filter.
push_back(isoObject);
458 isoNeutralWeight_ = isoNeutralWeight_filter;
460 isoCharged_ = isoCharged_filter;
463 bool failsOccupancyCut =
false;
464 bool failsSumPtCut =
false;
465 bool failsRelativeSumPtCut =
false;
468 int neutrals = isoNeutral_.
size();
477 size_t nOccupants = isoCharged_.size() + neutrals;
481 double footprintCorrection_value = 0.;
483 for (std::vector<std::unique_ptr<FootprintCorrection> >::const_iterator footprintCorrection =
486 ++footprintCorrection) {
487 if ((*footprintCorrection)->selection_(*pfTau)) {
488 footprintCorrection_value = (*footprintCorrection)->offset_(*pfTau);
497 double chargedPt = 0.;
498 double neutralPt = 0.;
499 double weightedNeutralPt = 0.;
500 for (
auto const& isoObject : isoCharged_) {
501 chargedPt += isoObject->pt();
504 for (
auto const& isoObject : isoNeutral_) {
505 neutralPt += isoObject->pt();
508 for (
auto const& isoObject : isoNeutralWeight_) {
509 weightedNeutralPt += isoObject.pt();
512 for (
auto const& isoObject : isoPU_) {
513 puPt += isoObject->pt();
515 LogTrace(
"discriminate") <<
"chargedPt = " << chargedPt;
516 LogTrace(
"discriminate") <<
"neutralPt = " << neutralPt;
517 LogTrace(
"discriminate") <<
"weighted neutral Pt = " << weightedNeutralPt;
522 neutralPt = weightedNeutralPt;
530 neutralPt -= footprintCorrection_value;
537 if (neutralPt < 0.) {
550 bool failsPhotonPtSumOutsideSignalConeCut =
false;
551 double photonSumPt_outsideSignalCone = 0.;
553 const std::vector<reco::CandidatePtr>& signalGammas = pfTau->signalGammaCands();
554 for (std::vector<reco::CandidatePtr>::const_iterator signalGamma = signalGammas.begin();
555 signalGamma != signalGammas.end();
557 double dR =
deltaR(pfTau->eta(), pfTau->phi(), (*signalGamma)->eta(), (*signalGamma)->phi());
558 if (
dR > pfTau->signalConeSize())
559 photonSumPt_outsideSignalCone += (*signalGamma)->pt();
563 failsPhotonPtSumOutsideSignalConeCut =
true;
589 return footprintCorrection_value;
591 return photonSumPt_outsideSignalCone;
593 return (fails ? 0. : 1.);