92 bool isGsfElectronMatched =
false;
94 float deltaRDummy = 9.9;
96 float tauEtaAtEcalEntrance = -99.;
97 float sumEtaTimesEnergy = 0.;
99 const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTauRef->signalPFCands();
100 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
101 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
102 sumEtaTimesEnergy += ((*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy());
103 sumEnergy += (*pfCandidate)->energy();
105 if ( sumEnergy > 0. ) {
106 tauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy;
109 float leadChargedPFCandEtaAtEcalEntrance = -99.;
110 float leadChargedPFCandPt = -99.;
111 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
112 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
114 if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get();
115 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get();
116 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get();
117 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get();
118 else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get();
120 if ( track->
pt() > leadChargedPFCandPt ) {
121 leadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().
eta();
122 leadChargedPFCandPt = track->
pt();
127 if( (*thePFTauRef).leadPFChargedHadrCand().isNonnull()) {
128 for ( reco::GsfElectronCollection::const_iterator theGsfElectron =
gsfElectrons_->begin();
130 if ( theGsfElectron->pt() > 10. ) {
131 double deltaREleTau =
deltaR(theGsfElectron->p4(), thePFTauRef->p4());
132 deltaRDummy = deltaREleTau;
133 if ( deltaREleTau < 0.3 ) {
134 double mva_match =
mva_->
MVAValue(*thePFTauRef, *theGsfElectron);
135 size_t numSignalPFGammaCands = thePFTauRef->signalPFGammaCands().size();
136 bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().
isNonnull();
147 if (
TMath::Abs(tauEtaAtEcalEntrance) < 1.479 ) {
148 if ( numSignalPFGammaCands == 0 && !hasGsfTrack ) {
150 }
else if ( numSignalPFGammaCands == 0 && hasGsfTrack ) {
152 }
else if ( numSignalPFGammaCands >= 1 && !hasGsfTrack ) {
154 }
else if ( numSignalPFGammaCands >= 1 && hasGsfTrack ) {
158 if ( numSignalPFGammaCands == 0 && !hasGsfTrack ) {
160 }
else if ( numSignalPFGammaCands == 0 && hasGsfTrack ) {
162 }
else if ( numSignalPFGammaCands >= 1 && !hasGsfTrack ) {
164 }
else if ( numSignalPFGammaCands >= 1 && hasGsfTrack ) {
170 isGsfElectronMatched =
true;
175 if ( !isGsfElectronMatched ) {
177 size_t numSignalPFGammaCands = thePFTauRef->signalPFGammaCands().size();
178 bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().
isNonnull();
189 if (
TMath::Abs(tauEtaAtEcalEntrance) < 1.479 ) {
190 if ( numSignalPFGammaCands == 0 && !hasGsfTrack ) {
192 }
else if ( numSignalPFGammaCands == 0 && hasGsfTrack ) {
194 }
else if ( numSignalPFGammaCands >= 1 && !hasGsfTrack ) {
196 }
else if ( numSignalPFGammaCands >= 1 && hasGsfTrack ) {
200 if ( numSignalPFGammaCands == 0 && !hasGsfTrack ) {
202 }
else if ( numSignalPFGammaCands == 0 && hasGsfTrack ) {
204 }
else if ( numSignalPFGammaCands >= 1 && !hasGsfTrack ) {
206 }
else if ( numSignalPFGammaCands >= 1 && hasGsfTrack ) {
214 edm::LogPrint(
"PFTauAgainstEleMVA5") <<
"<PFRecoTauDiscriminationAgainstElectronMVA5::discriminate>:" ;
215 edm::LogPrint(
"PFTauAgainstEleMVA5") <<
" tau: Pt = " << thePFTauRef->pt() <<
", eta = " << thePFTauRef->eta() <<
", phi = " << thePFTauRef->phi();
216 edm::LogPrint(
"PFTauAgainstEleMVA5") <<
" deltaREleTau = " << deltaRDummy <<
", isGsfElectronMatched = " << isGsfElectronMatched;
217 edm::LogPrint(
"PFTauAgainstEleMVA5") <<
" #Prongs = " << thePFTauRef->signalPFChargedHadrCands().size();
bool isNonnull() const
Checks for non-null.
bool isInEcalCrack(double) const
AntiElectronIDMVA5 * mva_
double eta() const
pseudorapidity of momentum vector
double pt() const
track transverse momentum
std::unique_ptr< PFTauDiscriminator > category_output_
edm::Handle< reco::GsfElectronCollection > gsfElectrons_
double deltaR(double eta1, double eta2, double phi1, double phi2)
double MVAValue(Float_t TauEtaAtEcalEntrance, Float_t TauPt, Float_t TauLeadChargedPFCandEtaAtEcalEntrance, Float_t TauLeadChargedPFCandPt, Float_t TaudCrackEta, Float_t TaudCrackPhi, Float_t TauEmFraction, Float_t TauSignalPFGammaCands, Float_t TauLeadPFChargedHadrHoP, Float_t TauLeadPFChargedHadrEoP, Float_t TauVisMass, Float_t TauHadrMva, const std::vector< Float_t > &GammasdEta, const std::vector< Float_t > &GammasdPhi, const std::vector< Float_t > &GammasPt, Float_t TauKFNumHits, Float_t TauGSFNumHits, Float_t TauGSFChi2, Float_t TauGSFTrackResol, Float_t TauGSFTracklnPt, Float_t TauGSFTrackEta, Float_t TauPhi, Float_t TauSignalPFChargedCands, Float_t TauHasGsf, Float_t ElecEta, Float_t ElecPhi, Float_t ElecPt, Float_t ElecEe, Float_t ElecEgamma, Float_t ElecPin, Float_t ElecPout, Float_t ElecFbrem, Float_t ElecChi2GSF, Float_t ElecGSFNumHits, Float_t ElecGSFTrackResol, Float_t ElecGSFTracklnPt, Float_t ElecGSFTrackEta)