307 LogDebug(
"discriminate") <<
" tau: Pt = " << pfTau->pt() <<
", eta = " << pfTau->eta() <<
", phi = " << pfTau->phi();
311 std::vector<CandidatePtr> isoCharged_;
312 std::vector<CandidatePtr> isoNeutral_;
313 std::vector<CandidatePtr> isoPU_;
315 std::vector<CandidatePtr> chPV_;
316 isoCharged_.
reserve(pfTau->isolationChargedHadrCands().size());
317 isoNeutral_.reserve(pfTau->isolationGammaCands().size());
319 isoNeutralWeight_.
reserve(pfTau->isolationGammaCands().size());
328 if (
pv.isNonnull()) {
329 LogTrace(
"discriminate") <<
"pv: x = " <<
pv->position().x() <<
", y = " <<
pv->position().y()
330 <<
", z = " <<
pv->position().z();
332 LogTrace(
"discriminate") <<
"pv: N/A";
334 if (pfTau->leadChargedHadrCand().
isNonnull()) {
335 LogTrace(
"discriminate") <<
"leadPFChargedHadron:"
336 <<
" Pt = " << pfTau->leadChargedHadrCand()->pt() <<
","
337 <<
" eta = " << pfTau->leadChargedHadrCand()->eta() <<
","
338 <<
" phi = " << pfTau->leadChargedHadrCand()->phi();
340 LogTrace(
"discriminate") <<
"leadPFChargedHadron: N/A";
345 if (!(
pv.isNonnull() && pfTau->leadChargedHadrCand().
isNonnull()))
349 qcuts_->setLeadTrack(*pfTau->leadChargedHadrCand());
360 for (
auto const&
cand : pfTau->isolationChargedHadrCands()) {
362 LogTrace(
"discriminate") <<
"adding charged iso cand with pt " <<
cand->pt();
363 isoCharged_.push_back(
cand);
368 for (
auto const&
cand : pfTau->isolationGammaCands()) {
370 LogTrace(
"discriminate") <<
"adding neutral iso cand with pt " <<
cand->pt();
371 isoNeutral_.push_back(
cand);
389 LogTrace(
"discriminate") <<
"After track cuts: " << allPU.size();
397 LogTrace(
"discriminate") <<
"After cleaning cuts: " << cleanPU.size();
401 for (
auto const&
cand : cleanPU) {
402 if (deltaBetaFilter(
cand))
403 isoPU_.push_back(
cand);
406 for (
auto const&
cand : cleanNPU) {
407 if (deltaBetaFilter(
cand))
408 chPV_.push_back(
cand);
410 LogTrace(
"discriminate") <<
"After cone cuts: " << isoPU_.size() <<
" " << chPV_.size();
418 for (
auto const& isoObject : isoNeutral_) {
419 if (isoObject->charge() != 0) {
425 double eta = isoObject->eta();
426 double phi = isoObject->phi();
431 if ((sumNPU + sumPU) > 0)
432 neutral.setP4(((sumNPU) / (sumNPU + sumPU)) * neutral.p4());
442 std::vector<CandidatePtr> isoCharged_filter;
443 std::vector<CandidatePtr> isoNeutral_filter;
446 for (
auto const& isoObject : isoCharged_) {
451 for (
auto const& isoObject : isoNeutral_) {
453 isoNeutral_filter.push_back(isoObject);
455 isoNeutral_ = isoNeutral_filter;
457 for (
auto const& isoObject : isoNeutralWeight_) {
458 if (filter2(isoObject))
459 isoNeutralWeight_filter.
push_back(isoObject);
461 isoNeutralWeight_ = isoNeutralWeight_filter;
463 isoCharged_ = isoCharged_filter;
466 bool failsOccupancyCut =
false;
467 bool failsSumPtCut =
false;
468 bool failsRelativeSumPtCut =
false;
471 int neutrals = isoNeutral_.
size();
480 size_t nOccupants = isoCharged_.size() + neutrals;
484 double footprintCorrection_value = 0.;
486 for (std::vector<std::unique_ptr<FootprintCorrection> >::const_iterator footprintCorrection =
489 ++footprintCorrection) {
490 if ((*footprintCorrection)->selection_(*pfTau)) {
491 footprintCorrection_value = (*footprintCorrection)->offset_(*pfTau);
500 double chargedPt = 0.;
501 double neutralPt = 0.;
502 double weightedNeutralPt = 0.;
503 for (
auto const& isoObject : isoCharged_) {
508 double trackPt = (isoObject->bestTrack()) ? isoObject->bestTrack()->pt() : 0.;
509 double pfCandPt = isoObject->pt();
512 neutralPt += pfCandPt -
trackPt;
514 chargedPt += isoObject->pt();
517 chargedPt += isoObject->pt();
522 for (
auto const& isoObject : isoNeutral_) {
523 neutralPt += isoObject->pt();
526 for (
auto const& isoObject : isoNeutralWeight_) {
527 weightedNeutralPt += isoObject.pt();
530 for (
auto const& isoObject : isoPU_) {
531 puPt += isoObject->pt();
533 LogTrace(
"discriminate") <<
"chargedPt = " << chargedPt;
534 LogTrace(
"discriminate") <<
"neutralPt = " << neutralPt;
535 LogTrace(
"discriminate") <<
"weighted neutral Pt = " << weightedNeutralPt;
540 neutralPt = weightedNeutralPt;
548 neutralPt -= footprintCorrection_value;
555 if (neutralPt < 0.) {
568 bool failsPhotonPtSumOutsideSignalConeCut =
false;
569 double photonSumPt_outsideSignalCone = 0.;
571 const std::vector<reco::CandidatePtr>& signalGammas = pfTau->signalGammaCands();
572 for (std::vector<reco::CandidatePtr>::const_iterator signalGamma = signalGammas.begin();
573 signalGamma != signalGammas.end();
575 double dR =
deltaR(pfTau->eta(), pfTau->phi(), (*signalGamma)->eta(), (*signalGamma)->phi());
576 if (
dR > pfTau->signalConeSize())
577 photonSumPt_outsideSignalCone += (*signalGamma)->pt();
581 failsPhotonPtSumOutsideSignalConeCut =
true;
607 return footprintCorrection_value;
609 return photonSumPt_outsideSignalCone;
611 return (fails ? 0. : 1.);