32 mva_ = std::make_unique<AntiElectronIDMVA6>(
cfg);
35 electronToken = consumes<pat::ElectronCollection>(
srcElectrons);
36 vetoEcalCracks_ = cfg.
getParameter<
bool>(
"vetoEcalCracks");
37 verbosity_ = ( cfg.
exists(
"verbosity") ) ?
41 produces<PATTauDiscriminator>(
"category");
46 double discriminate(
const TauRef&)
const override;
53 bool isInEcalCrack(
double)
const;
56 std::unique_ptr<AntiElectronIDMVA6>
mva_;
72 mva_->beginEvent(evt, es);
84 bool isGsfElectronMatched =
false;
85 float deltaRDummy = 9.9;
86 const float ECALBarrelEndcapEtaBorder = 1.479;
87 float tauEtaAtEcalEntrance = theTauRef->etaAtEcalEntrance();
88 float leadChargedPFCandEtaAtEcalEntrance = theTauRef->etaAtEcalEntranceLeadChargedCand();
90 if( (*theTauRef).leadChargedHadrCand().isNonnull()) {
91 int numSignalPFGammaCandsInSigCone = 0;
93 for (
const auto &
gamma : signalGammaCands ) {
94 double dR =
deltaR(
gamma->p4(), theTauRef->leadChargedHadrCand()->p4());
98 numSignalPFGammaCandsInSigCone += 1;
102 for (
const auto & theElectron : *
Electrons ) {
103 if ( theElectron.pt() > 10. ) {
104 double deltaREleTau =
deltaR(theElectron.p4(), theTauRef->p4());
105 deltaRDummy = deltaREleTau;
106 if( deltaREleTau < 0.3 ){
107 double mva_match = mva_->MVAValue(*theTauRef, theElectron);
108 bool hasGsfTrack =
false;
110 if(
abs(packedLeadTauCand->
pdgId()) == 11 )
113 hasGsfTrack = theElectron.gsfTrack().isNonnull();
116 if ( vetoEcalCracks_ && (isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance)) ) {
118 category_output_->setValue(tauIndex_, category);
123 if(
std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ){
124 if( numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack ){
127 else if ( numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack ) {
131 if ( numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack ) {
134 else if ( numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack ) {
138 mvaValue =
std::min(mvaValue, mva_match);
139 isGsfElectronMatched =
true;
144 if ( !isGsfElectronMatched ) {
145 mvaValue = mva_->MVAValue(*theTauRef);
146 bool hasGsfTrack =
false;
148 if(
abs(packedLeadTauCand->
pdgId()) == 11 ) hasGsfTrack =
true;
151 if ( vetoEcalCracks_ && (isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance)) ) {
153 category_output_->setValue(tauIndex_, category);
158 if(
std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ){
159 if( numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack ){
162 else if ( numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack ) {
166 if ( numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack ) {
169 else if ( numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack ) {
176 edm::LogPrint(
"PATTauAgainstEleMVA6") <<
"<PATTauDiscriminationAgainstElectronMVA6::discriminate>:" ;
177 edm::LogPrint(
"PATTauAgainstEleMVA6") <<
" tau: Pt = " << theTauRef->pt() <<
", eta = " << theTauRef->eta() <<
", phi = " << theTauRef->phi();
178 edm::LogPrint(
"PATTauAgainstEleMVA6") <<
" deltaREleTau = " << deltaRDummy <<
", isGsfElectronMatched = " << isGsfElectronMatched;
179 edm::LogPrint(
"PATTauAgainstEleMVA6") <<
" #Prongs = " << theTauRef->signalChargedHadrCands().size();
183 category_output_->setValue(tauIndex_, category);
197 double absEta = fabs(eta);
198 return (absEta > 1.460 && absEta < 1.558);
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::RefProd< TauCollection > TauRefProd
int pdgId() const override
PDG identifier.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
void endEvent(edm::Event &) override
bool exists(std::string const ¶meterName) const
checks if a parameter exists
~PATTauDiscriminationAgainstElectronMVA6() override
std::unique_ptr< PATTauDiscriminator > category_output_
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.
double deltaR(double eta1, double eta2, double phi1, double phi2)
PATTauDiscriminationAgainstElectronMVA6(const edm::ParameterSet &cfg)
std::unique_ptr< AntiElectronIDMVA6 > mva_
void beginEvent(const edm::Event &, const edm::EventSetup &) override
edm::InputTag srcElectrons
edm::Handle< TauCollection > taus_
edm::Handle< pat::ElectronCollection > Electrons