77 result.rawValues = {1., -1.};
79 bool isGsfElectronMatched =
false;
81 float deltaRDummy = 9.9;
83 const float ECALBarrelEndcapEtaBorder = 1.479;
84 float tauEtaAtEcalEntrance = -99.;
85 float sumEtaTimesEnergy = 0.;
87 for (
const auto& pfCandidate : thePFTauRef->signalPFCands()) {
88 sumEtaTimesEnergy += (pfCandidate->positionAtECALEntrance().eta() * pfCandidate->energy());
89 sumEnergy += pfCandidate->energy();
92 tauEtaAtEcalEntrance = sumEtaTimesEnergy / sumEnergy;
95 float leadChargedPFCandEtaAtEcalEntrance = -99.;
96 float leadChargedPFCandPt = -99.;
97 for (
const auto& pfCandidate : thePFTauRef->signalPFCands()) {
99 if (pfCandidate->trackRef().isNonnull())
100 track = pfCandidate->trackRef().get();
101 else if (pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->innerTrack().isNonnull())
102 track = pfCandidate->muonRef()->innerTrack().get();
103 else if (pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->globalTrack().isNonnull())
104 track = pfCandidate->muonRef()->globalTrack().get();
105 else if (pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->outerTrack().isNonnull())
106 track = pfCandidate->muonRef()->outerTrack().get();
107 else if (pfCandidate->gsfTrackRef().isNonnull())
108 track = pfCandidate->gsfTrackRef().get();
110 if (
track->pt() > leadChargedPFCandPt) {
111 leadChargedPFCandEtaAtEcalEntrance = pfCandidate->positionAtECALEntrance().eta();
112 leadChargedPFCandPt =
track->pt();
117 if ((*thePFTauRef).leadChargedHadrCand().isNonnull()) {
118 int numSignalGammaCandsInSigCone = 0;
119 const std::vector<reco::CandidatePtr>& signalGammaCands = thePFTauRef->signalGammaCands();
121 for (
const auto&
pfGamma : signalGammaCands) {
122 double dR =
deltaR(
pfGamma->p4(), thePFTauRef->leadChargedHadrCand()->p4());
126 if (
dR < signalrad) {
127 numSignalGammaCandsInSigCone += 1;
133 if (theGsfElectron.pt() > 10.) {
134 double deltaREleTau =
deltaR(theGsfElectron.p4(), thePFTauRef->p4());
135 deltaRDummy = deltaREleTau;
136 if (deltaREleTau < 0.3) {
137 double mva_match =
mva_->MVAValue(*thePFTauRef, theGsfElectron);
139 bool hasGsfTrack =
false;
144 hasGsfTrack = theGsfElectron.gsfTrack().isNonnull();
150 result.rawValues.at(0) = -99.;
155 if (
std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder) {
156 if (numSignalGammaCandsInSigCone == 0 && hasGsfTrack) {
158 }
else if (numSignalGammaCandsInSigCone >= 1 && hasGsfTrack) {
162 if (numSignalGammaCandsInSigCone == 0 && hasGsfTrack) {
164 }
else if (numSignalGammaCandsInSigCone >= 1 && hasGsfTrack) {
170 isGsfElectronMatched =
true;
175 if (!isGsfElectronMatched) {
176 result.rawValues.at(0) =
mva_->MVAValue(*thePFTauRef);
178 bool hasGsfTrack =
false;
189 result.rawValues.at(0) = -99.;
194 if (
std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder) {
195 if (numSignalGammaCandsInSigCone == 0 && !hasGsfTrack) {
197 }
else if (numSignalGammaCandsInSigCone >= 1 && !hasGsfTrack) {
201 if (numSignalGammaCandsInSigCone == 0 && !hasGsfTrack) {
203 }
else if (numSignalGammaCandsInSigCone >= 1 && !hasGsfTrack) {
211 edm::LogPrint(
"PFTauAgainstEleMVA6") <<
"<PFRecoTauDiscriminationAgainstElectronMVA6::discriminate>:";
212 edm::LogPrint(
"PFTauAgainstEleMVA6") <<
" tau: Pt = " << thePFTauRef->pt() <<
", eta = " << thePFTauRef->eta()
213 <<
", phi = " << thePFTauRef->phi();
214 edm::LogPrint(
"PFTauAgainstEleMVA6") <<
" deltaREleTau = " << deltaRDummy
215 <<
", isGsfElectronMatched = " << isGsfElectronMatched;
216 edm::LogPrint(
"PFTauAgainstEleMVA6") <<
" #Prongs = " << thePFTauRef->signalChargedHadrCands().size();