43 GsfElectrons_token = consumes<reco::GsfElectronCollection>(srcGsfElectrons_);
48 produces<PFTauDiscriminator>(
"category");
53 double discriminate(
const PFTauRef&)
const override;
64 bool isInEcalCrack(
double)
const;
83 mva_->beginEvent(evt, es);
88 evt.
getByToken(GsfElectrons_token, gsfElectrons_);
95 bool isGsfElectronMatched =
false;
97 float deltaRDummy = 9.9;
99 float tauEtaAtEcalEntrance = -99.;
100 float sumEtaTimesEnergy = 0.;
101 float sumEnergy = 0.;
102 const std::vector<reco::PFCandidatePtr>& signalPFCands = thePFTauRef->signalPFCands();
103 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
104 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
105 sumEtaTimesEnergy += ((*pfCandidate)->positionAtECALEntrance().eta()*(*pfCandidate)->energy());
106 sumEnergy += (*pfCandidate)->energy();
108 if ( sumEnergy > 0. ) {
109 tauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy;
112 float leadChargedPFCandEtaAtEcalEntrance = -99.;
113 float leadChargedPFCandPt = -99.;
114 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfCandidate = signalPFCands.begin();
115 pfCandidate != signalPFCands.end(); ++pfCandidate ) {
117 if ( (*pfCandidate)->trackRef().isNonnull() ) track = (*pfCandidate)->trackRef().get();
118 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->innerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->innerTrack().get();
119 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->globalTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->globalTrack().get();
120 else if ( (*pfCandidate)->muonRef().isNonnull() && (*pfCandidate)->muonRef()->outerTrack().isNonnull() ) track = (*pfCandidate)->muonRef()->outerTrack().get();
121 else if ( (*pfCandidate)->gsfTrackRef().isNonnull() ) track = (*pfCandidate)->gsfTrackRef().get();
123 if ( track->
pt() > leadChargedPFCandPt ) {
124 leadChargedPFCandEtaAtEcalEntrance = (*pfCandidate)->positionAtECALEntrance().
eta();
125 leadChargedPFCandPt = track->
pt();
130 if( (*thePFTauRef).leadPFChargedHadrCand().isNonnull()) {
131 for ( reco::GsfElectronCollection::const_iterator theGsfElectron = gsfElectrons_->begin();
132 theGsfElectron != gsfElectrons_->end(); ++theGsfElectron ) {
133 if ( theGsfElectron->pt() > 10. ) {
134 double deltaREleTau =
deltaR(theGsfElectron->p4(), thePFTauRef->p4());
135 deltaRDummy = deltaREleTau;
136 if ( deltaREleTau < 0.3 ) {
137 double mva_match = mva_->MVAValue(*thePFTauRef, *theGsfElectron);
138 size_t numSignalPFGammaCands = thePFTauRef->signalPFGammaCands().size();
139 bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().
isNonnull();
142 if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) {
144 category_output_->setValue(tauIndex_, category);
150 if (
TMath::Abs(tauEtaAtEcalEntrance) < 1.479 ) {
151 if ( numSignalPFGammaCands == 0 && !hasGsfTrack ) {
153 }
else if ( numSignalPFGammaCands == 0 && hasGsfTrack ) {
155 }
else if ( numSignalPFGammaCands >= 1 && !hasGsfTrack ) {
157 }
else if ( numSignalPFGammaCands >= 1 && hasGsfTrack ) {
161 if ( numSignalPFGammaCands == 0 && !hasGsfTrack ) {
163 }
else if ( numSignalPFGammaCands == 0 && hasGsfTrack ) {
165 }
else if ( numSignalPFGammaCands >= 1 && !hasGsfTrack ) {
167 }
else if ( numSignalPFGammaCands >= 1 && hasGsfTrack ) {
173 isGsfElectronMatched =
true;
178 if ( !isGsfElectronMatched ) {
179 mvaValue = mva_->MVAValue(*thePFTauRef);
180 size_t numSignalPFGammaCands = thePFTauRef->signalPFGammaCands().size();
181 bool hasGsfTrack = thePFTauRef->leadPFChargedHadrCand()->gsfTrackRef().
isNonnull();
184 if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) {
186 category_output_->setValue(tauIndex_, category);
192 if (
TMath::Abs(tauEtaAtEcalEntrance) < 1.479 ) {
193 if ( numSignalPFGammaCands == 0 && !hasGsfTrack ) {
195 }
else if ( numSignalPFGammaCands == 0 && hasGsfTrack ) {
197 }
else if ( numSignalPFGammaCands >= 1 && !hasGsfTrack ) {
199 }
else if ( numSignalPFGammaCands >= 1 && hasGsfTrack ) {
203 if ( numSignalPFGammaCands == 0 && !hasGsfTrack ) {
205 }
else if ( numSignalPFGammaCands == 0 && hasGsfTrack ) {
207 }
else if ( numSignalPFGammaCands >= 1 && !hasGsfTrack ) {
209 }
else if ( numSignalPFGammaCands >= 1 && hasGsfTrack ) {
217 edm::LogPrint(
"PFTauAgainstEleMVA5") <<
"<PFRecoTauDiscriminationAgainstElectronMVA5::discriminate>:" ;
218 edm::LogPrint(
"PFTauAgainstEleMVA5") <<
" tau: Pt = " << thePFTauRef->pt() <<
", eta = " << thePFTauRef->eta() <<
", phi = " << thePFTauRef->phi();
219 edm::LogPrint(
"PFTauAgainstEleMVA5") <<
" deltaREleTau = " << deltaRDummy <<
", isGsfElectronMatched = " << isGsfElectronMatched;
220 edm::LogPrint(
"PFTauAgainstEleMVA5") <<
" #Prongs = " << thePFTauRef->signalChargedHadrCands().size();
225 category_output_->setValue(tauIndex_, category);
239 double absEta = fabs(eta);
240 return (absEta > 1.460 && absEta < 1.558);
247 desc.
add<
double>(
"minMVANoEleMatchWOgWOgsfBL", 0.0);
250 desc.
add<
double>(
"minMVANoEleMatchWgWOgsfBL", 0.0);
253 desc.
add<
double>(
"minMVAWgWgsfBL", 0.0);
254 desc.
add<
double>(
"minMVAWgWOgsfBL", 0.0);
255 desc.
add<
double>(
"minMVANoEleMatchWgWgsfBL", 0.0);
256 desc.
add<
double>(
"minMVAWOgWgsfEC", 0.0);
259 desc.
add<
bool>(
"returnMVA",
true);
260 desc.
add<
double>(
"minMVANoEleMatchWgWOgsfEC", 0.0);
261 desc.
add<
bool>(
"loadMVAfromDB",
true);
267 psd1.
add<
double>(
"cut");
274 desc.
add<
std::string>(
"mvaName_NoEleMatch_woGwoGSF_BL",
"gbr_NoEleMatch_woGwoGSF_BL");
275 desc.
add<
double>(
"minMVAWOgWOgsfEC", 0.0);
278 desc.
add<
double>(
"minMVANoEleMatchWOgWOgsfEC", 0.0);
279 desc.
add<
std::string>(
"mvaName_NoEleMatch_woGwGSF_BL",
"gbr_NoEleMatch_woGwGSF_BL");
280 desc.
add<
double>(
"minMVANoEleMatchWgWgsfEC", 0.0);
281 desc.
add<
double>(
"minMVAWOgWgsfBL", 0.0);
282 desc.
add<
double>(
"minMVANoEleMatchWOgWgsfEC", 0.0);
283 desc.
add<
double>(
"minMVAWgWOgsfEC", 0.0);
284 desc.
add<
std::string>(
"mvaName_NoEleMatch_wGwGSF_EC",
"gbr_NoEleMatch_wGwGSF_EC");
285 desc.
add<
double>(
"minMVAWgWgsfEC", 0.0);
286 desc.
add<
int>(
"verbosity", 0);
287 desc.
add<
double>(
"minMVANoEleMatchWOgWgsfBL", 0.0);
288 desc.
add<
std::string>(
"mvaName_NoEleMatch_wGwoGSF_EC",
"gbr_NoEleMatch_wGwoGSF_EC");
290 desc.
add<
std::string>(
"mvaName_NoEleMatch_wGwGSF_BL",
"gbr_NoEleMatch_wGwGSF_BL");
291 desc.
add<
std::string>(
"mvaName_NoEleMatch_wGwoGSF_BL",
"gbr_NoEleMatch_wGwoGSF_BL");
293 desc.
add<
double>(
"minMVAWOgWOgsfBL", 0.0);
294 desc.
add<
std::string>(
"mvaName_NoEleMatch_woGwoGSF_EC",
"gbr_NoEleMatch_woGwoGSF_EC");
295 desc.
add<
std::string>(
"mvaName_NoEleMatch_woGwGSF_EC",
"gbr_NoEleMatch_woGwGSF_EC");
296 descriptions.
add(
"pfRecoTauDiscriminationAgainstElectronMVA5", desc);
T getParameter(std::string const &) const
void endEvent(edm::Event &) override
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
edm::RefProd< TauCollection > TauRefProd
bool isNonnull() const
Checks for non-null.
bool isInEcalCrack(double) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
AntiElectronIDMVA5 * mva_
edm::Handle< TauCollection > taus_
PFRecoTauDiscriminationAgainstElectronMVA5(const edm::ParameterSet &cfg)
double discriminate(const PFTauRef &) const override
#define DEFINE_FWK_MODULE(type)
double eta() const
pseudorapidity of momentum vector
double pt() const
track transverse momentum
std::unique_ptr< PFTauDiscriminator > category_output_
edm::Handle< reco::GsfElectronCollection > gsfElectrons_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
~PFRecoTauDiscriminationAgainstElectronMVA5() override
edm::InputTag srcGsfElectrons_
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void beginEvent(const edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< reco::GsfElectronCollection > GsfElectrons_token
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)