38 GsfElectrons_token = consumes<reco::GsfElectronCollection>(srcGsfElectrons_);
40 verbosity_ = ( cfg.
exists(
"verbosity") ) ?
44 produces<PFTauDiscriminator>(
"category");
49 double discriminate(
const PFTauRef&)
const;
59 bool isInEcalCrack(
double)
const;
78 mva_->beginEvent(evt, es);
83 evt.
getByToken(GsfElectrons_token, gsfElectrons_);
90 bool isGsfElectronMatched =
false;
92 float deltaRDummy = 9.9;
94 const float ECALBarrelEndcapEtaBorder = 1.479;
95 float tauEtaAtEcalEntrance = -99.;
96 float sumEtaTimesEnergy = 0.;
98 const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTauRef->signalPFCands();
99 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
100 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
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 ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
111 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
113 if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get();
114 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get();
115 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get();
116 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get();
117 else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get();
119 if ( track->
pt() > leadChargedPFCandPt ) {
120 leadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().
eta();
121 leadChargedPFCandPt = track->
pt();
126 if( (*thePFTauRef).leadPFChargedHadrCand().isNonnull()) {
128 int numSignalPFGammaCandsInSigCone = 0;
129 const std::vector<reco::PFCandidatePtr>& signalPFGammaCands = thePFTauRef->signalPFGammaCands();
131 for ( std::vector<reco::PFCandidatePtr>::const_iterator
pfGamma = signalPFGammaCands.begin();
134 double dR =
deltaR((*pfGamma)->p4(), thePFTauRef->leadPFChargedHadrCand()->p4());
138 if (dR < signalrad) {
139 numSignalPFGammaCandsInSigCone += 1;
144 for ( reco::GsfElectronCollection::const_iterator theGsfElectron = gsfElectrons_->begin();
145 theGsfElectron != gsfElectrons_->end(); ++theGsfElectron ) {
146 if ( theGsfElectron->pt() > 10. ) {
147 double deltaREleTau =
deltaR(theGsfElectron->p4(), thePFTauRef->p4());
148 deltaRDummy = deltaREleTau;
149 if ( deltaREleTau < 0.3 ) {
150 double mva_match = mva_->MVAValue(*thePFTauRef, *theGsfElectron);
151 bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().
isNonnull();
153 hasGsfTrack = theGsfElectron->gsfTrack().isNonnull();
156 if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) {
158 category_output_->setValue(tauIndex_, category);
164 if (
std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ) {
165 if ( numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack ) {
168 else if ( numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack ) {
172 if ( numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack ) {
175 else if ( numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack ) {
180 mvaValue =
std::min(mvaValue, mva_match);
181 isGsfElectronMatched =
true;
186 if ( !isGsfElectronMatched ) {
187 mvaValue = mva_->MVAValue(*thePFTauRef);
188 bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().
isNonnull();
191 if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) {
193 category_output_->setValue(tauIndex_, category);
199 if (
std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ) {
200 if ( numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack ) {
203 else if ( numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack ) {
207 if ( numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack ) {
210 else if ( numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack ) {
218 edm::LogPrint(
"PFTauAgainstEleMVA6") <<
"<PFRecoTauDiscriminationAgainstElectronMVA6::discriminate>:" ;
219 edm::LogPrint(
"PFTauAgainstEleMVA6") <<
" tau: Pt = " << thePFTauRef->pt() <<
", eta = " << thePFTauRef->eta() <<
", phi = " << thePFTauRef->phi();
220 edm::LogPrint(
"PFTauAgainstEleMVA6") <<
" deltaREleTau = " << deltaRDummy <<
", isGsfElectronMatched = " << isGsfElectronMatched;
221 edm::LogPrint(
"PFTauAgainstEleMVA6") <<
" #Prongs = " << thePFTauRef->signalPFChargedHadrCands().size();
226 category_output_->setValue(tauIndex_, category);
234 evt.
put(category_output_,
"category");
240 double absEta = fabs(eta);
241 return (absEta > 1.460 && absEta < 1.558);
T getParameter(std::string const &) const
bool isNonnull() const
Checks for non-null.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
AntiElectronIDMVA6 * mva_
#define DEFINE_FWK_MODULE(type)
void endEvent(edm::Event &)
std::auto_ptr< PFTauDiscriminator > category_output_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
double discriminate(const PFTauRef &) const
edm::EDGetTokenT< reco::GsfElectronCollection > GsfElectrons_token
edm::Handle< TauCollection > taus_
bool isInEcalCrack(double) const
double eta() const
pseudorapidity of momentum vector
void beginEvent(const edm::Event &, const edm::EventSetup &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
double pt() const
track transverse momentum
edm::InputTag srcGsfElectrons_
Abs< T >::type abs(const T &t)
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
PFRecoTauDiscriminationAgainstElectronMVA6(const edm::ParameterSet &cfg)
edm::Handle< reco::GsfElectronCollection > gsfElectrons_
~PFRecoTauDiscriminationAgainstElectronMVA6()