40 GsfElectrons_token = consumes<reco::GsfElectronCollection>(srcGsfElectrons_);
42 verbosity_ = ( cfg.
exists(
"verbosity") ) ?
46 produces<PFTauDiscriminator>(
"category");
51 double discriminate(
const PFTauRef&)
const;
61 bool isInEcalCrack(
double)
const;
80 mva_->beginEvent(evt, es);
85 evt.
getByToken(GsfElectrons_token, gsfElectrons_);
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();
129 theGsfElectron != gsfElectrons_->end(); ++theGsfElectron ) {
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();
139 if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) {
141 category_output_->setValue(tauIndex_, category);
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 ) {
176 mvaValue = mva_->MVAValue(*thePFTauRef);
177 size_t numSignalPFGammaCands = thePFTauRef->signalPFGammaCands().size();
178 bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().
isNonnull();
181 if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) {
183 category_output_->setValue(tauIndex_, category);
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();
222 category_output_->setValue(tauIndex_, category);
230 evt.
put(category_output_,
"category");
236 double absEta = fabs(eta);
237 return (absEta > 1.460 && absEta < 1.558);
T getParameter(std::string const &) const
edm::RefProd< TauCollection > TauRefProd
bool isNonnull() const
Checks for non-null.
bool isInEcalCrack(double) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
AntiElectronIDMVA5 * mva_
edm::Handle< TauCollection > taus_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
PFRecoTauDiscriminationAgainstElectronMVA5(const edm::ParameterSet &cfg)
~PFRecoTauDiscriminationAgainstElectronMVA5()
double eta() const
pseudorapidity of momentum vector
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
std::auto_ptr< PFTauDiscriminator > category_output_
double pt() const
track transverse momentum
edm::Handle< reco::GsfElectronCollection > gsfElectrons_
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
edm::InputTag srcGsfElectrons_
double discriminate(const PFTauRef &) const
void beginEvent(const edm::Event &, const edm::EventSetup &)
edm::EDGetTokenT< reco::GsfElectronCollection > GsfElectrons_token
void endEvent(edm::Event &)