85 bool isGsfElectronMatched =
false;
87 float deltaRDummy = 9.9;
89 const float ECALBarrelEndcapEtaBorder = 1.479;
90 float tauEtaAtEcalEntrance = -99.;
91 float sumEtaTimesEnergy = 0.;
93 const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTauRef->signalPFCands();
94 for (
const auto & pfCandidate : signalPFCands ) {
95 sumEtaTimesEnergy += (pfCandidate->positionAtECALEntrance().eta()*pfCandidate->energy());
96 sumEnergy += pfCandidate->energy();
98 if ( sumEnergy > 0. ) {
99 tauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy;
102 float leadChargedPFCandEtaAtEcalEntrance = -99.;
103 float leadChargedPFCandPt = -99.;
104 for (
const auto & pfCandidate : signalPFCands ) {
106 if ( pfCandidate->trackRef().isNonnull() ) track = pfCandidate->trackRef().get();
107 else if ( pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->innerTrack().isNonnull() ) track = pfCandidate->muonRef()->innerTrack().get();
108 else if ( pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->globalTrack().isNonnull() ) track = pfCandidate->muonRef()->globalTrack().get();
109 else if ( pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->outerTrack().isNonnull() ) track = pfCandidate->muonRef()->outerTrack().get();
110 else if ( pfCandidate->gsfTrackRef().isNonnull() ) track = pfCandidate->gsfTrackRef().get();
112 if ( track->
pt() > leadChargedPFCandPt ) {
113 leadChargedPFCandEtaAtEcalEntrance = pfCandidate->positionAtECALEntrance().
eta();
114 leadChargedPFCandPt = track->
pt();
119 if( (*thePFTauRef).leadPFChargedHadrCand().isNonnull()) {
121 int numSignalPFGammaCandsInSigCone = 0;
122 const std::vector<reco::PFCandidatePtr>& signalPFGammaCands = thePFTauRef->signalPFGammaCands();
124 for (
const auto &
pfGamma : signalPFGammaCands ) {
126 double dR =
deltaR(
pfGamma->p4(), thePFTauRef->leadPFChargedHadrCand()->p4());
130 if (dR < signalrad) {
131 numSignalPFGammaCandsInSigCone += 1;
137 if ( theGsfElectron.pt() > 10. ) {
138 double deltaREleTau =
deltaR(theGsfElectron.p4(), thePFTauRef->p4());
139 deltaRDummy = deltaREleTau;
140 if ( deltaREleTau < 0.3 ) {
141 double mva_match =
mva_->MVAValue(*thePFTauRef, theGsfElectron);
142 bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().
isNonnull();
144 hasGsfTrack = theGsfElectron.gsfTrack().isNonnull();
155 if (
std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ) {
156 if ( numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack ) {
159 else if ( numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack ) {
163 if ( numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack ) {
166 else if ( numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack ) {
171 mvaValue =
std::min(mvaValue, mva_match);
172 isGsfElectronMatched =
true;
177 if ( !isGsfElectronMatched ) {
178 mvaValue =
mva_->MVAValue(*thePFTauRef);
179 bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().
isNonnull();
190 if (
std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ) {
191 if ( numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack ) {
194 else if ( numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack ) {
198 if ( numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack ) {
201 else if ( numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack ) {
209 edm::LogPrint(
"PFTauAgainstEleMVA6") <<
"<PFRecoTauDiscriminationAgainstElectronMVA6::discriminate>:" ;
210 edm::LogPrint(
"PFTauAgainstEleMVA6") <<
" tau: Pt = " << thePFTauRef->pt() <<
", eta = " << thePFTauRef->eta() <<
", phi = " << thePFTauRef->phi();
211 edm::LogPrint(
"PFTauAgainstEleMVA6") <<
" deltaREleTau = " << deltaRDummy <<
", isGsfElectronMatched = " << isGsfElectronMatched;
212 edm::LogPrint(
"PFTauAgainstEleMVA6") <<
" #Prongs = " << thePFTauRef->signalPFChargedHadrCands().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)
double deltaR(double eta1, double eta2, double phi1, double phi2)
std::unique_ptr< PFTauDiscriminator > category_output_
std::unique_ptr< AntiElectronIDMVA6 > mva_
edm::Handle< reco::GsfElectronCollection > gsfElectrons_