14 template <
class TauType,
class TauDiscriminator,
class ElectronType>
16 reco::TauDiscriminatorContainer,
17 reco::SingleTauDiscriminatorContainer,
27 reco::SingleTauDiscriminatorContainer,
35 cfg.getParameter<
bool>(
"isPhase2"))),
43 mva_->beginEvent(evt, es);
64 std::unique_ptr<AntiElectronIDMVA6<TauType, ElectronType>>
mva_;
83 template <
class TauType,
class TauDiscriminator,
class ElectronType>
86 const TauRef& theTauRef)
const {
88 result.rawValues = {1., -1.};
90 bool isGsfElectronMatched =
false;
92 double deltaRDummy = 9.9;
94 std::pair<float, float> tauEtaAtECalEntrance;
96 tauEtaAtECalEntrance = getTauEtaAtECalEntrance(theTauRef);
99 <<
"Unsupported TauType used. You must use either reco::PFTau or pat::Tau.";
101 if ((*theTauRef).leadChargedHadrCand().isNonnull()) {
102 int numSignalGammaCandsInSigCone = 0;
103 double signalrad = std::clamp(3.0 /
std::max(1.0, theTauRef->pt()), 0.05, 0.10);
104 for (
const auto&
gamma : theTauRef->signalGammaCands()) {
105 double dR =
deltaR(
gamma->p4(), theTauRef->leadChargedHadrCand()->p4());
107 if (
dR < signalrad) {
108 numSignalGammaCandsInSigCone += 1;
112 bool hasGsfTrack =
false;
117 hasGsfTrack = (
std::abs(leadChCand->pdgId()) == 11);
120 if (packedLeadChCand !=
nullptr) {
123 const reco::PFCandidate* pfLeadChCand = dynamic_cast<const reco::PFCandidate*>(leadChCand.
get());
132 for (
const auto& theElectron : *electrons_) {
135 if (theElectron.pt() > 10.) {
136 double deltaREleTau =
deltaR(theElectron.p4(), theTauRef->p4());
137 deltaRDummy =
std::min(deltaREleTau, deltaRDummy);
138 if (deltaREleTau < deltaREleTauMax_) {
139 double mva_match = mva_->mvaValue(*theTauRef, theElecRef);
141 hasGsfTrack = theElectron.gsfTrack().isNonnull();
144 if (vetoEcalCracks_ &&
145 (isInEcalCrack(tauEtaAtECalEntrance.first) || isInEcalCrack(tauEtaAtECalEntrance.second))) {
149 result.rawValues.at(0) = -99.;
154 if (
std::abs(tauEtaAtECalEntrance.first) < ecalBarrelEndcapEtaBorder_) {
155 if (numSignalGammaCandsInSigCone == 0 && hasGsfTrack) {
157 }
else if (numSignalGammaCandsInSigCone >= 1 && hasGsfTrack) {
160 }
else if (!isPhase2_ ||
std::abs(tauEtaAtECalEntrance.first) < ecalEndcapVFEndcapEtaBorder_) {
161 if (numSignalGammaCandsInSigCone == 0 && hasGsfTrack) {
163 }
else if (numSignalGammaCandsInSigCone >= 1 && hasGsfTrack) {
167 if (numSignalGammaCandsInSigCone == 0 && hasGsfTrack) {
169 }
else if (numSignalGammaCandsInSigCone >= 1 && hasGsfTrack) {
175 isGsfElectronMatched =
true;
180 if (!isGsfElectronMatched) {
181 double mva_nomatch = mva_->mvaValue(*theTauRef);
184 if (vetoEcalCracks_ &&
185 (isInEcalCrack(tauEtaAtECalEntrance.first) || isInEcalCrack(tauEtaAtECalEntrance.second))) {
189 result.rawValues.at(0) = -99.;
194 if (
std::abs(tauEtaAtECalEntrance.first) < ecalBarrelEndcapEtaBorder_) {
195 if (numSignalGammaCandsInSigCone == 0 && !hasGsfTrack) {
197 }
else if (numSignalGammaCandsInSigCone >= 1 && !hasGsfTrack) {
200 }
else if (!isPhase2_ ||
std::abs(tauEtaAtECalEntrance.first) < ecalEndcapVFEndcapEtaBorder_) {
201 if (numSignalGammaCandsInSigCone == 0 && !hasGsfTrack) {
203 }
else if (numSignalGammaCandsInSigCone >= 1 && !hasGsfTrack) {
207 if (numSignalGammaCandsInSigCone == 0 && !hasGsfTrack) {
209 }
else if (numSignalGammaCandsInSigCone >= 1 && !hasGsfTrack) {
220 <<
"<" + this->getTauTypeString() +
"AgainstElectronMVA6::discriminate>:";
222 <<
" tau: Pt = " << theTauRef->pt() <<
", eta = " << theTauRef->eta() <<
", phi = " << theTauRef->phi();
224 <<
" deltaREleTau = " << deltaRDummy <<
", isGsfElectronMatched = " << isGsfElectronMatched;
226 <<
" #Prongs = " << theTauRef->signalChargedHadrCands().size();
228 <<
" MVA = " <<
result.rawValues.at(0) <<
", category = " <<
category;
237 template <
class TauType,
class TauDiscriminator,
class ElectronType>
240 return (absEta > 1.460 && absEta < 1.558);
243 template <
class TauType,
class TauDiscriminator,
class ElectronType>
244 std::pair<float, float>
247 float tauEtaAtECalEntrance = -99;
248 float leadChargedCandEtaAtECalEntrance = -99;
249 float sumEtaTimesEnergy = 0;
251 float leadChargedCandPt = -99;
253 for (
const auto& candidate : theTauRef->signalCands()) {
254 float etaAtECalEntrance = candidate->eta();
256 const reco::PFCandidate* pfCandidate = dynamic_cast<const reco::PFCandidate*>(candidate.get());
257 if (pfCandidate !=
nullptr) {
258 if (!isPhase2_ ||
std::abs(theTauRef->eta()) < ecalBarrelEndcapEtaBorder_) {
264 etaAtECalEntrance = posAtECal.eta();
281 etaAtECalEntrance = posAtECal.eta();
283 track = candidate->bestTrack();
285 if (
track !=
nullptr) {
286 if (
track->pt() > leadChargedCandPt) {
287 leadChargedCandEtaAtECalEntrance = etaAtECalEntrance;
288 leadChargedCandPt =
track->pt();
291 sumEtaTimesEnergy += etaAtECalEntrance * candidate->energy();
292 sumEnergy += candidate->energy();
294 if (sumEnergy > 0.) {
295 tauEtaAtECalEntrance = sumEtaTimesEnergy / sumEnergy;
297 return std::pair<float, float>(tauEtaAtECalEntrance, leadChargedCandEtaAtECalEntrance);
300 template <
class TauType,
class TauDiscriminator,
class ElectronType>
301 std::pair<float, float>
304 if (!isPhase2_ ||
std::abs(theTauRef->eta()) < ecalBarrelEndcapEtaBorder_) {
305 return std::pair<float, float>(theTauRef->etaAtEcalEntrance(), theTauRef->etaAtEcalEntranceLeadChargedCand());
307 float tauEtaAtECalEntrance = -99;
308 float leadChargedCandEtaAtECalEntrance = -99;
309 float sumEtaTimesEnergy = 0.;
310 float sumEnergy = 0.;
311 float leadChargedCandPt = -99;
313 for (
const auto& candidate : theTauRef->signalCands()) {
314 float etaAtECalEntrance = candidate->eta();
318 etaAtECalEntrance = posAtECal.eta();
321 if (
track !=
nullptr) {
322 if (
track->pt() > leadChargedCandPt) {
323 leadChargedCandEtaAtECalEntrance = etaAtECalEntrance;
324 leadChargedCandPt =
track->pt();
327 sumEtaTimesEnergy += etaAtECalEntrance * candidate->energy();
328 sumEnergy += candidate->energy();
330 if (sumEnergy > 0.) {
331 tauEtaAtECalEntrance = sumEtaTimesEnergy / sumEnergy;
333 return std::pair<float, float>(tauEtaAtECalEntrance, leadChargedCandEtaAtECalEntrance);
337 template <
class TauType,
class TauDiscriminator,
class ElectronType>
344 desc.add<
bool>(
"loadMVAfromDB",
true);
345 desc.add<
bool>(
"returnMVA",
true);
347 desc.add<
std::string>(
"mvaName_NoEleMatch_woGwoGSF_BL",
"gbr_NoEleMatch_woGwoGSF_BL");
348 desc.add<
std::string>(
"mvaName_NoEleMatch_wGwoGSF_BL",
"gbr_NoEleMatch_wGwoGSF_BL");
351 desc.add<
std::string>(
"mvaName_NoEleMatch_woGwoGSF_EC",
"gbr_NoEleMatch_woGwoGSF_EC");
352 desc.add<
std::string>(
"mvaName_NoEleMatch_wGwoGSF_EC",
"gbr_NoEleMatch_wGwoGSF_EC");
356 desc.add<
double>(
"minMVANoEleMatchWOgWOgsfBL", 0.0);
357 desc.add<
double>(
"minMVANoEleMatchWgWOgsfBL", 0.0);
358 desc.add<
double>(
"minMVAWOgWgsfBL", 0.0);
359 desc.add<
double>(
"minMVAWgWgsfBL", 0.0);
360 desc.add<
double>(
"minMVANoEleMatchWOgWOgsfEC", 0.0);
361 desc.add<
double>(
"minMVANoEleMatchWgWOgsfEC", 0.0);
362 desc.add<
double>(
"minMVAWOgWgsfEC", 0.0);
363 desc.add<
double>(
"minMVAWgWgsfEC", 0.0);
374 "mvaName_NoEleMatch_wGwoGSF_VFEC",
"gbr_NoEleMatch_wGwoGSF_VFEC",
true) and
376 "mvaName_NoEleMatch_woGwoGSF_VFEC",
"gbr_NoEleMatch_woGwoGSF_VFEC",
true) and
384 desc.add<std::vector<edm::InputTag>>(
"hgcalElectronIDs", std::vector<edm::InputTag>())
385 ->setComment(
"Relevant only for Phase-2");
387 desc.add<
bool>(
"vetoEcalCracks",
true);
388 desc.add<
bool>(
"usePhiAtEcalEntranceExtrapolation",
false);
389 desc.add<
int>(
"verbosity", 0);
394 TauDiscriminator>::fillProducerDescriptions(
desc);