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) {
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();
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);
edm::Handle< ElectronCollection > electrons_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
TauDiscriminationAgainstElectronMVA6(const edm::ParameterSet &cfg)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
reco::GsfTrackRef gsfTrackRef() const
void beginEvent(const edm::Event &evt, const edm::EventSetup &es) override
void beginEvent(const edm::EventSetup &)
std::vector< ElectronType > ElectronCollection
edm::Handle< TauCollection > taus_
std::vector< TauType > TauCollection
TauDiscriminationAgainstElectronMVA6< reco::PFTau, reco::PFTauDiscriminator, reco::GsfElectron > PFRecoTauDiscriminationAgainstElectronMVA6
std::pair< float, float > getTauEtaAtECalEntrance(const reco::PFTauRef &theTauRef) const
bool isNonnull() const
Checks for non-null.
const math::XYZPointF & positionAtECALEntrance() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
int pdgId() const override
PDG identifier.
bool isInEcalCrack(double) const
std::unique_ptr< AntiElectronIDMVA6< TauType, ElectronType > > mva_
PositionAtECalEntranceComputer positionAtECalEntrance_
static constexpr float ecalBarrelEndcapEtaBorder_
bool isNonnull() const
Checks for non-null.
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
reco::SingleTauDiscriminatorContainer discriminate(const TauRef &) const override
Abs< T >::type abs(const T &t)
TauDiscriminationAgainstElectronMVA6< pat::Tau, pat::PATTauDiscriminator, pat::Electron > PATTauDiscriminationAgainstElectronMVA6
#define DEFINE_FWK_MODULE(type)
Log< level::Warning, true > LogPrint
reco::MuonRef muonRef() const
T const * get() const
Returns C++ pointer to the item.
edm::ValueMap< SingleTauDiscriminatorContainer > TauDiscriminatorContainer
edm::EDGetTokenT< ElectronCollection > Electron_token
edm::EDGetTokenT< TauCollection > Tau_token
Particle reconstructed by the particle flow algorithm.
edm::Ref< TauCollection > TauRef
T const * get() const
Returns C++ pointer to the item.
reco::TrackRef trackRef() const
math::XYZPoint Point
point in the space
static constexpr float ecalEndcapVFEndcapEtaBorder_
~TauDiscriminationAgainstElectronMVA6() override