33 mva_ = std::make_unique<AntiElectronIDMVA6>(
cfg);
36 GsfElectrons_token = consumes<reco::GsfElectronCollection>(srcGsfElectrons_);
37 vetoEcalCracks_ =
cfg.getParameter<
bool>(
"vetoEcalCracks");
39 verbosity_ =
cfg.getParameter<
int>(
"verbosity");
51 bool isInEcalCrack(
double)
const;
54 std::unique_ptr<AntiElectronIDMVA6>
mva_;
67 mva_->beginEvent(evt, es);
71 evt.
getByToken(GsfElectrons_token, gsfElectrons_);
77 result.rawValues = {1., -1.};
79 bool isGsfElectronMatched =
false;
81 float deltaRDummy = 9.9;
83 const float ECALBarrelEndcapEtaBorder = 1.479;
84 float tauEtaAtEcalEntrance = -99.;
85 float sumEtaTimesEnergy = 0.;
87 for (
const auto& pfCandidate : thePFTauRef->signalPFCands()) {
88 sumEtaTimesEnergy += (pfCandidate->positionAtECALEntrance().eta() * pfCandidate->energy());
89 sumEnergy += pfCandidate->energy();
92 tauEtaAtEcalEntrance = sumEtaTimesEnergy / sumEnergy;
95 float leadChargedPFCandEtaAtEcalEntrance = -99.;
96 float leadChargedPFCandPt = -99.;
97 for (
const auto& pfCandidate : thePFTauRef->signalPFCands()) {
99 if (pfCandidate->trackRef().isNonnull())
100 track = pfCandidate->trackRef().get();
101 else if (pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->innerTrack().isNonnull())
102 track = pfCandidate->muonRef()->innerTrack().get();
103 else if (pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->globalTrack().isNonnull())
104 track = pfCandidate->muonRef()->globalTrack().get();
105 else if (pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->outerTrack().isNonnull())
106 track = pfCandidate->muonRef()->outerTrack().get();
107 else if (pfCandidate->gsfTrackRef().isNonnull())
108 track = pfCandidate->gsfTrackRef().get();
110 if (
track->pt() > leadChargedPFCandPt) {
111 leadChargedPFCandEtaAtEcalEntrance = pfCandidate->positionAtECALEntrance().eta();
112 leadChargedPFCandPt =
track->pt();
117 if ((*thePFTauRef).leadChargedHadrCand().isNonnull()) {
118 int numSignalGammaCandsInSigCone = 0;
119 const std::vector<reco::CandidatePtr>& signalGammaCands = thePFTauRef->signalGammaCands();
121 for (
const auto&
pfGamma : signalGammaCands) {
122 double dR =
deltaR(
pfGamma->p4(), thePFTauRef->leadChargedHadrCand()->p4());
126 if (
dR < signalrad) {
127 numSignalGammaCandsInSigCone += 1;
132 for (
const auto& theGsfElectron : *gsfElectrons_) {
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);
139 bool hasGsfTrack =
false;
144 hasGsfTrack = theGsfElectron.gsfTrack().isNonnull();
147 if (vetoEcalCracks_ &&
148 (isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance))) {
150 result.rawValues.at(0) = -99.;
155 if (
std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder) {
156 if (numSignalGammaCandsInSigCone == 0 && hasGsfTrack) {
158 }
else if (numSignalGammaCandsInSigCone >= 1 && hasGsfTrack) {
162 if (numSignalGammaCandsInSigCone == 0 && hasGsfTrack) {
164 }
else if (numSignalGammaCandsInSigCone >= 1 && hasGsfTrack) {
170 isGsfElectronMatched =
true;
175 if (!isGsfElectronMatched) {
176 result.rawValues.at(0) = mva_->MVAValue(*thePFTauRef);
178 bool hasGsfTrack =
false;
184 if (vetoEcalCracks_ &&
185 (isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance))) {
189 result.rawValues.at(0) = -99.;
194 if (
std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder) {
195 if (numSignalGammaCandsInSigCone == 0 && !hasGsfTrack) {
197 }
else if (numSignalGammaCandsInSigCone >= 1 && !hasGsfTrack) {
201 if (numSignalGammaCandsInSigCone == 0 && !hasGsfTrack) {
203 }
else if (numSignalGammaCandsInSigCone >= 1 && !hasGsfTrack) {
211 edm::LogPrint(
"PFTauAgainstEleMVA6") <<
"<PFRecoTauDiscriminationAgainstElectronMVA6::discriminate>:";
212 edm::LogPrint(
"PFTauAgainstEleMVA6") <<
" tau: Pt = " << thePFTauRef->pt() <<
", eta = " << thePFTauRef->eta()
213 <<
", phi = " << thePFTauRef->phi();
214 edm::LogPrint(
"PFTauAgainstEleMVA6") <<
" deltaREleTau = " << deltaRDummy
215 <<
", isGsfElectronMatched = " << isGsfElectronMatched;
216 edm::LogPrint(
"PFTauAgainstEleMVA6") <<
" #Prongs = " << thePFTauRef->signalChargedHadrCands().size();
227 double absEta = fabs(
eta);
228 return (absEta > 1.460 && absEta < 1.558);
234 desc.
add<
double>(
"minMVANoEleMatchWOgWOgsfBL", 0.0);
236 desc.
add<
double>(
"minMVANoEleMatchWgWOgsfBL", 0.0);
238 desc.
add<
double>(
"minMVAWgWgsfBL", 0.0);
240 desc.
add<
double>(
"minMVAWOgWgsfEC", 0.0);
243 desc.
add<
bool>(
"returnMVA",
true);
244 desc.
add<
bool>(
"loadMVAfromDB",
true);
250 psd1.
add<
double>(
"cut");
258 psd1.
add<
double>(
"cut");
264 desc.
add<
std::string>(
"mvaName_NoEleMatch_woGwoGSF_BL",
"gbr_NoEleMatch_woGwoGSF_BL");
265 desc.
add<
bool>(
"vetoEcalCracks",
true);
266 desc.
add<
bool>(
"usePhiAtEcalEntranceExtrapolation",
false);
267 desc.
add<
std::string>(
"mvaName_NoEleMatch_wGwoGSF_BL",
"gbr_NoEleMatch_wGwoGSF_BL");
268 desc.
add<
double>(
"minMVANoEleMatchWOgWOgsfEC", 0.0);
269 desc.
add<
double>(
"minMVAWOgWgsfBL", 0.0);
270 desc.
add<
double>(
"minMVAWgWgsfEC", 0.0);
271 desc.
add<
int>(
"verbosity", 0);
272 desc.
add<
std::string>(
"mvaName_NoEleMatch_wGwoGSF_EC",
"gbr_NoEleMatch_wGwoGSF_EC");
275 desc.
add<
std::string>(
"mvaName_NoEleMatch_woGwoGSF_EC",
"gbr_NoEleMatch_woGwoGSF_EC");
276 desc.
add<
double>(
"minMVANoEleMatchWgWOgsfEC", 0.0);
277 descriptions.
add(
"pfRecoTauDiscriminationAgainstElectronMVA6", desc);