31 mva_ = std::make_unique<AntiElectronIDMVA6>(
cfg);
34 electronToken = consumes<pat::ElectronCollection>(
srcElectrons);
35 vetoEcalCracks_ =
cfg.getParameter<
bool>(
"vetoEcalCracks");
36 verbosity_ =
cfg.getParameter<
int>(
"verbosity");
48 bool isInEcalCrack(
double)
const;
51 std::unique_ptr<AntiElectronIDMVA6>
mva_;
64 mva_->beginEvent(evt, es);
72 const TauRef& theTauRef)
const {
74 result.rawValues = {1., -1.};
76 bool isGsfElectronMatched =
false;
77 float deltaRDummy = 9.9;
78 const float ECALBarrelEndcapEtaBorder = 1.479;
79 float tauEtaAtEcalEntrance = theTauRef->etaAtEcalEntrance();
80 float leadChargedPFCandEtaAtEcalEntrance = theTauRef->etaAtEcalEntranceLeadChargedCand();
82 if ((*theTauRef).leadChargedHadrCand().isNonnull()) {
83 int numSignalPFGammaCandsInSigCone = 0;
85 for (
const auto&
gamma : signalGammaCands) {
86 double dR =
deltaR(
gamma->p4(), theTauRef->leadChargedHadrCand()->p4());
90 numSignalPFGammaCandsInSigCone += 1;
94 for (
const auto& theElectron : *
Electrons) {
95 if (theElectron.pt() > 10.) {
96 double deltaREleTau =
deltaR(theElectron.p4(), theTauRef->p4());
97 deltaRDummy = deltaREleTau;
98 if (deltaREleTau < 0.3) {
99 double mva_match = mva_->MVAValue(*theTauRef, theElectron);
100 bool hasGsfTrack =
false;
102 dynamic_cast<pat::PackedCandidate const*>(theTauRef->leadChargedHadrCand().
get());
103 if (
abs(packedLeadTauCand->
pdgId()) == 11)
106 hasGsfTrack = theElectron.gsfTrack().isNonnull();
109 if (vetoEcalCracks_ &&
110 (isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance))) {
112 result.rawValues.at(0) = -99;
116 if (
std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder) {
117 if (numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack) {
119 }
else if (numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack) {
123 if (numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack) {
125 }
else if (numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack) {
130 isGsfElectronMatched =
true;
135 if (!isGsfElectronMatched) {
136 result.rawValues.at(0) = mva_->MVAValue(*theTauRef);
137 bool hasGsfTrack =
false;
139 dynamic_cast<pat::PackedCandidate const*>(theTauRef->leadChargedHadrCand().
get());
140 if (
abs(packedLeadTauCand->
pdgId()) == 11)
144 if (vetoEcalCracks_ &&
145 (isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance))) {
149 result.rawValues.at(0) = -99;
153 if (
std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder) {
154 if (numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack) {
156 }
else if (numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack) {
160 if (numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack) {
162 }
else if (numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack) {
169 edm::LogPrint(
"PATTauAgainstEleMVA6") <<
"<PATTauDiscriminationAgainstElectronMVA6::discriminate>:";
171 <<
" tau: Pt = " << theTauRef->pt() <<
", eta = " << theTauRef->eta() <<
", phi = " << theTauRef->phi();
173 <<
" deltaREleTau = " << deltaRDummy <<
", isGsfElectronMatched = " << isGsfElectronMatched;
174 edm::LogPrint(
"PATTauAgainstEleMVA6") <<
" #Prongs = " << theTauRef->signalChargedHadrCands().size();
184 double absEta = fabs(
eta);
185 return (absEta > 1.460 && absEta < 1.558);
191 desc.
add<
double>(
"minMVANoEleMatchWOgWOgsfBL", 0.0);
192 desc.
add<
double>(
"minMVANoEleMatchWgWOgsfBL", 0.0);
193 desc.
add<
bool>(
"vetoEcalCracks",
true);
194 desc.
add<
bool>(
"usePhiAtEcalEntranceExtrapolation",
false);
196 desc.
add<
double>(
"minMVAWgWgsfBL", 0.0);
198 desc.
add<
double>(
"minMVAWOgWgsfEC", 0.0);
201 desc.
add<
bool>(
"returnMVA",
true);
202 desc.
add<
bool>(
"loadMVAfromDB",
true);
208 psd1.
add<
double>(
"cut");
214 desc.
add<
std::string>(
"mvaName_NoEleMatch_woGwoGSF_BL",
"gbr_NoEleMatch_woGwoGSF_BL");
216 desc.
add<
double>(
"minMVANoEleMatchWOgWOgsfEC", 0.0);
217 desc.
add<
std::string>(
"mvaName_NoEleMatch_wGwoGSF_BL",
"gbr_NoEleMatch_wGwoGSF_BL");
219 desc.
add<
double>(
"minMVAWOgWgsfBL", 0.0);
220 desc.
add<
double>(
"minMVAWgWgsfEC", 0.0);
221 desc.
add<
int>(
"verbosity", 0);
222 desc.
add<
std::string>(
"mvaName_NoEleMatch_wGwoGSF_EC",
"gbr_NoEleMatch_wGwoGSF_EC");
224 desc.
add<
std::string>(
"mvaName_NoEleMatch_woGwoGSF_EC",
"gbr_NoEleMatch_woGwoGSF_EC");
225 desc.
add<
double>(
"minMVANoEleMatchWgWOgsfEC", 0.0);
226 descriptions.
add(
"patTauDiscriminationAgainstElectronMVA6", desc);