32 mva_ = std::make_unique<AntiElectronIDMVA6>(
cfg);
35 electronToken = consumes<pat::ElectronCollection>(
srcElectrons);
36 verbosity_ = ( cfg.
exists(
"verbosity") ) ?
40 produces<PATTauDiscriminator>(
"category");
45 double discriminate(
const TauRef&)
const override;
52 bool isInEcalCrack(
double)
const;
55 std::unique_ptr<AntiElectronIDMVA6>
mva_;
69 mva_->beginEvent(evt, es);
81 bool isGsfElectronMatched =
false;
82 float deltaRDummy = 9.9;
83 const float ECALBarrelEndcapEtaBorder = 1.479;
84 float tauEtaAtEcalEntrance = theTauRef->etaAtEcalEntrance();
85 float leadChargedPFCandEtaAtEcalEntrance = theTauRef->etaAtEcalEntranceLeadChargedCand();
87 if( (*theTauRef).leadChargedHadrCand().isNonnull()) {
88 int numSignalPFGammaCandsInSigCone = 0;
90 for (
const auto &
gamma : signalGammaCands ) {
91 double dR =
deltaR(
gamma->p4(), theTauRef->leadChargedHadrCand()->p4());
95 numSignalPFGammaCandsInSigCone += 1;
99 for (
const auto & theElectron : *
Electrons ) {
100 if ( theElectron.pt() > 10. ) {
101 double deltaREleTau =
deltaR(theElectron.p4(), theTauRef->p4());
102 deltaRDummy = deltaREleTau;
103 if( deltaREleTau < 0.3 ){
104 double mva_match = mva_->MVAValue(*theTauRef, theElectron);
105 bool hasGsfTrack =
false;
107 if(
abs(packedLeadTauCand->
pdgId()) == 11 )
110 hasGsfTrack = theElectron.gsfTrack().isNonnull();
113 if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) {
115 category_output_->setValue(tauIndex_, category);
120 if(
std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ){
121 if( numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack ){
124 else if ( numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack ) {
128 if ( numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack ) {
131 else if ( numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack ) {
135 mvaValue =
std::min(mvaValue, mva_match);
136 isGsfElectronMatched =
true;
141 if ( !isGsfElectronMatched ) {
142 mvaValue = mva_->MVAValue(*theTauRef);
143 bool hasGsfTrack =
false;
145 if(
abs(packedLeadTauCand->
pdgId()) == 11 ) hasGsfTrack =
true;
148 if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) {
150 category_output_->setValue(tauIndex_, category);
155 if(
std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ){
156 if( numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack ){
159 else if ( numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack ) {
163 if ( numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack ) {
166 else if ( numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack ) {
173 edm::LogPrint(
"PATTauAgainstEleMVA6") <<
"<PATTauDiscriminationAgainstElectronMVA6::discriminate>:" ;
174 edm::LogPrint(
"PATTauAgainstEleMVA6") <<
" tau: Pt = " << theTauRef->pt() <<
", eta = " << theTauRef->eta() <<
", phi = " << theTauRef->phi();
175 edm::LogPrint(
"PATTauAgainstEleMVA6") <<
" deltaREleTau = " << deltaRDummy <<
", isGsfElectronMatched = " << isGsfElectronMatched;
176 edm::LogPrint(
"PATTauAgainstEleMVA6") <<
" #Prongs = " << theTauRef->signalChargedHadrCands().size();
180 category_output_->setValue(tauIndex_, category);
194 double absEta = fabs(eta);
195 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