92 bool isGsfElectronMatched =
false;
94 float deltaRDummy = 9.9;
96 const float ECALBarrelEndcapEtaBorder = 1.479;
97 float tauEtaAtEcalEntrance = -99.;
98 float sumEtaTimesEnergy = 0.;
100 for (
const auto & pfCandidate : thePFTauRef->signalPFCands() ) {
101 sumEtaTimesEnergy += (pfCandidate->positionAtECALEntrance().eta()*pfCandidate->energy());
102 sumEnergy += pfCandidate->energy();
104 if ( sumEnergy > 0. ) {
105 tauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy;
108 float leadChargedPFCandEtaAtEcalEntrance = -99.;
109 float leadChargedPFCandPt = -99.;
110 for (
const auto & pfCandidate : thePFTauRef->signalPFCands() ) {
112 if ( pfCandidate->trackRef().isNonnull() ) track = pfCandidate->trackRef().get();
113 else if ( pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->innerTrack().isNonnull() ) track = pfCandidate->muonRef()->innerTrack().get();
114 else if ( pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->globalTrack().isNonnull() ) track = pfCandidate->muonRef()->globalTrack().get();
115 else if ( pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->outerTrack().isNonnull() ) track = pfCandidate->muonRef()->outerTrack().get();
116 else if ( pfCandidate->gsfTrackRef().isNonnull() ) track = pfCandidate->gsfTrackRef().get();
118 if ( track->
pt() > leadChargedPFCandPt ) {
119 leadChargedPFCandEtaAtEcalEntrance = pfCandidate->positionAtECALEntrance().
eta();
120 leadChargedPFCandPt = track->
pt();
125 if( (*thePFTauRef).leadChargedHadrCand().isNonnull()) {
127 int numSignalGammaCandsInSigCone = 0;
128 const std::vector<reco::CandidatePtr>& signalGammaCands = thePFTauRef->signalGammaCands();
130 for (
const auto &
pfGamma : signalGammaCands ) {
132 double dR =
deltaR(
pfGamma->p4(), thePFTauRef->leadChargedHadrCand()->p4());
136 if (dR < signalrad) {
137 numSignalGammaCandsInSigCone += 1;
143 if ( theGsfElectron.pt() > 10. ) {
144 double deltaREleTau =
deltaR(theGsfElectron.p4(), thePFTauRef->p4());
145 deltaRDummy = deltaREleTau;
146 if ( deltaREleTau < 0.3 ) {
147 double mva_match =
mva_->MVAValue(*thePFTauRef, theGsfElectron);
149 bool hasGsfTrack =
false;
154 hasGsfTrack = theGsfElectron.gsfTrack().isNonnull();
165 if (
std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ) {
166 if ( numSignalGammaCandsInSigCone == 0 && hasGsfTrack ) {
169 else if ( numSignalGammaCandsInSigCone >= 1 && hasGsfTrack ) {
173 if ( numSignalGammaCandsInSigCone == 0 && hasGsfTrack ) {
176 else if ( numSignalGammaCandsInSigCone >= 1 && hasGsfTrack ) {
181 mvaValue =
std::min(mvaValue, mva_match);
182 isGsfElectronMatched =
true;
187 if ( !isGsfElectronMatched ) {
188 mvaValue =
mva_->MVAValue(*thePFTauRef);
190 bool hasGsfTrack =
false;
204 if (
std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ) {
205 if ( numSignalGammaCandsInSigCone == 0 && !hasGsfTrack ) {
208 else if ( numSignalGammaCandsInSigCone >= 1 && !hasGsfTrack ) {
212 if ( numSignalGammaCandsInSigCone == 0 && !hasGsfTrack ) {
215 else if ( numSignalGammaCandsInSigCone >= 1 && !hasGsfTrack ) {
223 edm::LogPrint(
"PFTauAgainstEleMVA6") <<
"<PFRecoTauDiscriminationAgainstElectronMVA6::discriminate>:" ;
224 edm::LogPrint(
"PFTauAgainstEleMVA6") <<
" tau: Pt = " << thePFTauRef->pt() <<
", eta = " << thePFTauRef->eta() <<
", phi = " << thePFTauRef->phi();
225 edm::LogPrint(
"PFTauAgainstEleMVA6") <<
" deltaREleTau = " << deltaRDummy <<
", isGsfElectronMatched = " << isGsfElectronMatched;
226 edm::LogPrint(
"PFTauAgainstEleMVA6") <<
" #Prongs = " << thePFTauRef->signalChargedHadrCands().size();
bool isNonnull() const
Checks for non-null.
bool isInEcalCrack(double) const
double eta() const
pseudorapidity of momentum vector
double pt() const
track transverse momentum
Abs< T >::type abs(const T &t)
bool isNonnull() const
Checks for non-null.
std::unique_ptr< PFTauDiscriminator > category_output_
std::unique_ptr< AntiElectronIDMVA6 > mva_
reco::GsfTrackRef gsfTrackRef() const
edm::Handle< reco::GsfElectronCollection > gsfElectrons_