14 template <
class TauType,
class TauDiscriminator,
class ElectronType>
16 reco::TauDiscriminatorContainer,
17 reco::SingleTauDiscriminatorContainer,
27 reco::SingleTauDiscriminatorContainer,
31 std::make_unique<
AntiElectronIDMVA6<TauType, ElectronType>>(cfg, edm::EDConsumerBase::consumesCollector())),
33 cfg.getParameter<edm::
InputTag>(
"srcElectrons"))),
35 cfg.getParameter<bool>(
"isPhase2"))),
37 isPhase2_(cfg.getParameter<bool>(
"isPhase2")),
38 verbosity_(cfg.getParameter<int>(
"verbosity")) {
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 {
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))) {
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))) {
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();
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();
270 track = pfCandidate->
muonRef()->innerTrack().
get();
272 track = pfCandidate->
muonRef()->globalTrack().
get();
274 track = pfCandidate->
muonRef()->outerTrack().
get();
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>())
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 setComment(std::string const &value)
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::unique_ptr< ParameterDescriptionCases< T >> cases)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
bool isNonnull() const
Checks for non-null.
bool isInEcalCrack(double) const
void beginEvent(const edm::Event &evt, const edm::EventSetup &es) override
void beginEvent(const edm::EventSetup &)
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
std::vector< ElectronType > ElectronCollection
static const char category[]
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::Handle< TauCollection > taus_
#define DEFINE_FWK_MODULE(type)
std::vector< TauType > TauCollection
T const * get() const
Returns C++ pointer to the item.
TauDiscriminationAgainstElectronMVA6< reco::PFTau, reco::PFTauDiscriminator, reco::GsfElectron > PFRecoTauDiscriminationAgainstElectronMVA6
int pdgId() const override
PDG identifier.
const math::XYZPointF & positionAtECALEntrance() const
reco::TrackRef trackRef() const
std::unique_ptr< AntiElectronIDMVA6< TauType, ElectronType > > mva_
PositionAtECalEntranceComputer positionAtECalEntrance_
static constexpr float ecalBarrelEndcapEtaBorder_
double pt() const
track transverse momentum
reco::SingleTauDiscriminatorContainer discriminate(const TauRef &) const override
Abs< T >::type abs(const T &t)
TauDiscriminationAgainstElectronMVA6< pat::Tau, pat::PATTauDiscriminator, pat::Electron > PATTauDiscriminationAgainstElectronMVA6
T const * get() const
Returns C++ pointer to the item.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Log< level::Warning, true > LogPrint
reco::MuonRef muonRef() const
bool isNonnull() const
Checks for non-null.
edm::ValueMap< SingleTauDiscriminatorContainer > TauDiscriminatorContainer
edm::EDGetTokenT< ElectronCollection > Electron_token
edm::EDGetTokenT< TauCollection > Tau_token
Particle reconstructed by the particle flow algorithm.
reco::GsfTrackRef gsfTrackRef() const
edm::Ref< TauCollection > TauRef
math::XYZPoint Point
point in the space
std::pair< float, float > getTauEtaAtECalEntrance(const reco::PFTauRef &theTauRef) const
static constexpr float ecalEndcapVFEndcapEtaBorder_
~TauDiscriminationAgainstElectronMVA6() override
std::vector< float > rawValues