35 mva_ = std::make_unique<AntiElectronIDMVA6>(
cfg);
38 electronToken = consumes<pat::ElectronCollection>(
srcElectrons);
39 vetoEcalCracks_ = cfg.
getParameter<
bool>(
"vetoEcalCracks");
43 produces<PATTauDiscriminator>(
"category");
48 double discriminate(
const TauRef&)
const override;
56 bool isInEcalCrack(
double)
const;
59 std::unique_ptr<AntiElectronIDMVA6>
mva_;
75 mva_->beginEvent(evt, es);
87 bool isGsfElectronMatched =
false;
88 float deltaRDummy = 9.9;
89 const float ECALBarrelEndcapEtaBorder = 1.479;
90 float tauEtaAtEcalEntrance = theTauRef->etaAtEcalEntrance();
91 float leadChargedPFCandEtaAtEcalEntrance = theTauRef->etaAtEcalEntranceLeadChargedCand();
93 if( (*theTauRef).leadChargedHadrCand().isNonnull()) {
94 int numSignalPFGammaCandsInSigCone = 0;
96 for (
const auto &
gamma : signalGammaCands ) {
97 double dR =
deltaR(
gamma->p4(), theTauRef->leadChargedHadrCand()->p4());
100 if (dR < signalrad) {
101 numSignalPFGammaCandsInSigCone += 1;
105 for (
const auto & theElectron : *
Electrons ) {
106 if ( theElectron.pt() > 10. ) {
107 double deltaREleTau =
deltaR(theElectron.p4(), theTauRef->p4());
108 deltaRDummy = deltaREleTau;
109 if( deltaREleTau < 0.3 ){
110 double mva_match = mva_->MVAValue(*theTauRef, theElectron);
111 bool hasGsfTrack =
false;
113 if(
abs(packedLeadTauCand->
pdgId()) == 11 )
116 hasGsfTrack = theElectron.gsfTrack().isNonnull();
119 if ( vetoEcalCracks_ && (isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance)) ) {
121 category_output_->setValue(tauIndex_, category);
126 if(
std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ){
127 if( numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack ){
130 else if ( numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack ) {
134 if ( numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack ) {
137 else if ( numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack ) {
141 mvaValue =
std::min(mvaValue, mva_match);
142 isGsfElectronMatched =
true;
147 if ( !isGsfElectronMatched ) {
148 mvaValue = mva_->MVAValue(*theTauRef);
149 bool hasGsfTrack =
false;
151 if(
abs(packedLeadTauCand->
pdgId()) == 11 ) hasGsfTrack =
true;
154 if ( vetoEcalCracks_ && (isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance)) ) {
156 category_output_->setValue(tauIndex_, category);
161 if(
std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ){
162 if( numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack ){
165 else if ( numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack ) {
169 if ( numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack ) {
172 else if ( numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack ) {
179 edm::LogPrint(
"PATTauAgainstEleMVA6") <<
"<PATTauDiscriminationAgainstElectronMVA6::discriminate>:" ;
180 edm::LogPrint(
"PATTauAgainstEleMVA6") <<
" tau: Pt = " << theTauRef->pt() <<
", eta = " << theTauRef->eta() <<
", phi = " << theTauRef->phi();
181 edm::LogPrint(
"PATTauAgainstEleMVA6") <<
" deltaREleTau = " << deltaRDummy <<
", isGsfElectronMatched = " << isGsfElectronMatched;
182 edm::LogPrint(
"PATTauAgainstEleMVA6") <<
" #Prongs = " << theTauRef->signalChargedHadrCands().size();
186 category_output_->setValue(tauIndex_, category);
200 double absEta = fabs(eta);
201 return (absEta > 1.460 && absEta < 1.558);
208 desc.
add<
double>(
"minMVANoEleMatchWOgWOgsfBL", 0.0);
209 desc.
add<
double>(
"minMVANoEleMatchWgWOgsfBL", 0.0);
210 desc.
add<
bool>(
"vetoEcalCracks",
true);
211 desc.
add<
bool>(
"usePhiAtEcalEntranceExtrapolation",
false);
213 desc.
add<
double>(
"minMVAWgWgsfBL", 0.0);
215 desc.
add<
double>(
"minMVAWOgWgsfEC", 0.0);
218 desc.
add<
bool>(
"returnMVA",
true);
219 desc.
add<
bool>(
"loadMVAfromDB",
true);
225 psd1.
add<
double>(
"cut");
231 desc.
add<
std::string>(
"mvaName_NoEleMatch_woGwoGSF_BL",
"gbr_NoEleMatch_woGwoGSF_BL");
233 desc.
add<
double>(
"minMVANoEleMatchWOgWOgsfEC", 0.0);
234 desc.
add<
std::string>(
"mvaName_NoEleMatch_wGwoGSF_BL",
"gbr_NoEleMatch_wGwoGSF_BL");
236 desc.
add<
double>(
"minMVAWOgWgsfBL", 0.0);
237 desc.
add<
double>(
"minMVAWgWgsfEC", 0.0);
238 desc.
add<
int>(
"verbosity", 0);
239 desc.
add<
std::string>(
"mvaName_NoEleMatch_wGwoGSF_EC",
"gbr_NoEleMatch_wGwoGSF_EC");
241 desc.
add<
std::string>(
"mvaName_NoEleMatch_woGwoGSF_EC",
"gbr_NoEleMatch_woGwoGSF_EC");
242 desc.
add<
double>(
"minMVANoEleMatchWgWOgsfEC", 0.0);
243 descriptions.
add(
"patTauDiscriminationAgainstElectronMVA6", desc);
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
edm::RefProd< TauCollection > TauRefProd
int pdgId() const override
PDG identifier.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void endEvent(edm::Event &) override
~PATTauDiscriminationAgainstElectronMVA6() override
std::unique_ptr< PATTauDiscriminator > category_output_
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< pat::ElectronCollection > electronToken
double discriminate(const TauRef &) const override
Abs< T >::type abs(const T &t)
bool isInEcalCrack(double) const
T const * get() const
Returns C++ pointer to the item.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
PATTauDiscriminationAgainstElectronMVA6(const edm::ParameterSet &cfg)
std::unique_ptr< AntiElectronIDMVA6 > mva_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void beginEvent(const edm::Event &, const edm::EventSetup &) override
edm::InputTag srcElectrons
edm::Handle< TauCollection > taus_
edm::Handle< pat::ElectronCollection > Electrons