CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
PATTauDiscriminationAgainstElectronMVA6 Class Reference
Inheritance diagram for PATTauDiscriminationAgainstElectronMVA6:
TauDiscriminationProducerBase< TauType, TauDiscriminator > edm::stream::EDProducer<>

Public Member Functions

void beginEvent (const edm::Event &, const edm::EventSetup &) override
 
double discriminate (const TauRef &) const override
 
void endEvent (edm::Event &) override
 
 PATTauDiscriminationAgainstElectronMVA6 (const edm::ParameterSet &cfg)
 
 ~PATTauDiscriminationAgainstElectronMVA6 () override
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
void produce (edm::Event &, const edm::EventSetup &) override
 
 TauDiscriminationProducerBase (const edm::ParameterSet &iConfig)
 
 TauDiscriminationProducerBase ()
 
 ~TauDiscriminationProducerBase () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Member Functions

bool isInEcalCrack (double) const
 

Private Attributes

std::unique_ptr< PATTauDiscriminatorcategory_output_
 
edm::Handle< pat::ElectronCollectionElectrons
 
edm::EDGetTokenT< pat::ElectronCollectionelectronToken
 
std::string moduleLabel_
 
std::unique_ptr< AntiElectronIDMVA6mva_
 
edm::InputTag srcElectrons
 
edm::Handle< TauCollectiontaus_
 
int verbosity_
 

Additional Inherited Members

- Public Types inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
typedef std::vector< TauType > TauCollection
 
typedef edm::Ref< TauCollectionTauRef
 
typedef edm::RefProd< TauCollectionTauRefProd
 
- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Protected Attributes inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
std::string moduleLabel_
 
double prediscriminantFailValue_
 
edm::EDGetTokenT< TauCollectionTau_token
 
size_t tauIndex_
 
edm::InputTag TauProducer_
 

Detailed Description

Definition at line 24 of file PATTauDiscriminationAgainstElectronMVA6.cc.

Constructor & Destructor Documentation

PATTauDiscriminationAgainstElectronMVA6::PATTauDiscriminationAgainstElectronMVA6 ( const edm::ParameterSet cfg)
inlineexplicit

Definition at line 27 of file PATTauDiscriminationAgainstElectronMVA6.cc.

References looper::cfg, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), and PATTauDiscriminationAgainstElectronMVA6_cfi::srcElectrons.

29  mva_(),
31  {
32  mva_ = std::make_unique<AntiElectronIDMVA6>(cfg);
33 
34  srcElectrons = cfg.getParameter<edm::InputTag>("srcElectrons");
35  electronToken = consumes<pat::ElectronCollection>(srcElectrons);
36  verbosity_ = ( cfg.exists("verbosity") ) ?
37  cfg.getParameter<int>("verbosity") : 0;
38 
39  // add category index
40  produces<PATTauDiscriminator>("category");
41  }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
TauDiscriminationProducerBase< pat::Tau, pat::PATTauDiscriminator > PATTauDiscriminationProducerBase
edm::EDGetTokenT< pat::ElectronCollection > electronToken
PATTauDiscriminationAgainstElectronMVA6::~PATTauDiscriminationAgainstElectronMVA6 ( )
inlineoverride

Definition at line 49 of file PATTauDiscriminationAgainstElectronMVA6.cc.

49 {}

Member Function Documentation

void PATTauDiscriminationAgainstElectronMVA6::beginEvent ( const edm::Event evt,
const edm::EventSetup es 
)
overridevirtual

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 67 of file PATTauDiscriminationAgainstElectronMVA6.cc.

References JetPlusTrackCorrections_cfi::Electrons, and edm::Event::getByToken().

68 {
69  mva_->beginEvent(evt, es);
70 
73 
75 }
edm::RefProd< TauCollection > TauRefProd
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
edm::EDGetTokenT< pat::ElectronCollection > electronToken
edm::EDGetTokenT< TauCollection > Tau_token
double PATTauDiscriminationAgainstElectronMVA6::discriminate ( const TauRef theTauRef) const
overridevirtual

Implements TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 77 of file PATTauDiscriminationAgainstElectronMVA6.cc.

References funct::abs(), taus_updatedMVAIds_cff::category, deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, JetPlusTrackCorrections_cfi::Electrons, CustomPhysics_cfi::gamma, edm::Ref< C, T, F >::get(), SiStripPI::max, min(), and pat::PackedCandidate::pdgId().

78 {
79  double mvaValue = 1.;
80  double category = -1.;
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();
86 
87  if( (*theTauRef).leadChargedHadrCand().isNonnull()) {
88  int numSignalPFGammaCandsInSigCone = 0;
89  const reco::CandidatePtrVector signalGammaCands = theTauRef->signalGammaCands();
90  for ( const auto & gamma : signalGammaCands ) {
91  double dR = deltaR(gamma->p4(), theTauRef->leadChargedHadrCand()->p4());
92  double signalrad = std::max(0.05, std::min(0.10, 3.0/std::max(1.0, theTauRef->pt())));
93  // gammas inside the tau signal cone
94  if (dR < signalrad) {
95  numSignalPFGammaCandsInSigCone += 1;
96  }
97  }
98  // loop over the electrons
99  for ( const auto & theElectron : *Electrons ) {
100  if ( theElectron.pt() > 10. ) { // CV: only take electrons above some minimal energy/Pt into account...
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;
106  pat::PackedCandidate const* packedLeadTauCand = dynamic_cast<pat::PackedCandidate const*>(theTauRef->leadChargedHadrCand().get());
107  if( abs(packedLeadTauCand->pdgId()) == 11 )
108  hasGsfTrack = true;
109  if ( !hasGsfTrack )
110  hasGsfTrack = theElectron.gsfTrack().isNonnull();
111 
112  // veto taus that go to Ecal crack
113  if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) {
114  // add category index
115  category_output_->setValue(tauIndex_, category);
116  // return MVA output value
117  return -99;
118  }
119  // Veto taus that go to Ecal crack
120  if( std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ){ // Barrel
121  if( numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack ){
122  category = 5.;
123  }
124  else if ( numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack ) {
125  category = 7.;
126  }
127  } else { // Endcap
128  if ( numSignalPFGammaCandsInSigCone == 0 && hasGsfTrack ) {
129  category = 13.;
130  }
131  else if ( numSignalPFGammaCandsInSigCone >= 1 && hasGsfTrack ) {
132  category = 15.;
133  }
134  }
135  mvaValue = std::min(mvaValue, mva_match);
136  isGsfElectronMatched = true;
137  } // deltaR < 0.3
138  } // electron pt > 10
139  } // end of loop over electrons
140 
141  if ( !isGsfElectronMatched ) {
142  mvaValue = mva_->MVAValue(*theTauRef);
143  bool hasGsfTrack = false;
144  pat::PackedCandidate const* packedLeadTauCand = dynamic_cast<pat::PackedCandidate const*>(theTauRef->leadChargedHadrCand().get());
145  if( abs(packedLeadTauCand->pdgId()) == 11 ) hasGsfTrack = true;
146 
147  // veto taus that go to Ecal crack
148  if ( isInEcalCrack(tauEtaAtEcalEntrance) || isInEcalCrack(leadChargedPFCandEtaAtEcalEntrance) ) {
149  // add category index
150  category_output_->setValue(tauIndex_, category);
151  // return MVA output value
152  return -99;
153  }
154  // veto taus that go to Ecal crack
155  if( std::abs(tauEtaAtEcalEntrance) < ECALBarrelEndcapEtaBorder ){ // Barrel
156  if( numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack ){
157  category = 0.;
158  }
159  else if ( numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack ) {
160  category = 2.;
161  }
162  } else { // Endcap
163  if ( numSignalPFGammaCandsInSigCone == 0 && !hasGsfTrack ) {
164  category = 8.;
165  }
166  else if ( numSignalPFGammaCandsInSigCone >= 1 && !hasGsfTrack ) {
167  category = 10.;
168  }
169  }
170  }
171  }
172  if ( verbosity_ ) {
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();
177  edm::LogPrint("PATTauAgainstEleMVA6") << " MVA = " << mvaValue << ", category = " << category;
178  }
179  // add category index
180  category_output_->setValue(tauIndex_, category);
181  // return MVA output value
182  return mvaValue;
183 }
int pdgId() const override
PDG identifier.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:243
T min(T a, T b)
Definition: MathUtil.h:58
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
void PATTauDiscriminationAgainstElectronMVA6::endEvent ( edm::Event evt)
overridevirtual

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 185 of file PATTauDiscriminationAgainstElectronMVA6.cc.

References eostools::move(), and edm::Event::put().

186 {
187  // add all category indices to event
188  evt.put(std::move(category_output_), "category");
189 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
def move(src, dest)
Definition: eostools.py:511
bool PATTauDiscriminationAgainstElectronMVA6::isInEcalCrack ( double  eta) const
private

Definition at line 192 of file PATTauDiscriminationAgainstElectronMVA6.cc.

References DEFINE_FWK_MODULE.

193 {
194  double absEta = fabs(eta);
195  return (absEta > 1.460 && absEta < 1.558);
196 }

Member Data Documentation

std::unique_ptr<PATTauDiscriminator> PATTauDiscriminationAgainstElectronMVA6::category_output_
private

Definition at line 62 of file PATTauDiscriminationAgainstElectronMVA6.cc.

edm::Handle<pat::ElectronCollection> PATTauDiscriminationAgainstElectronMVA6::Electrons
private

Definition at line 59 of file PATTauDiscriminationAgainstElectronMVA6.cc.

edm::EDGetTokenT<pat::ElectronCollection> PATTauDiscriminationAgainstElectronMVA6::electronToken
private

Definition at line 58 of file PATTauDiscriminationAgainstElectronMVA6.cc.

std::string PATTauDiscriminationAgainstElectronMVA6::moduleLabel_
private
std::unique_ptr<AntiElectronIDMVA6> PATTauDiscriminationAgainstElectronMVA6::mva_
private

Definition at line 55 of file PATTauDiscriminationAgainstElectronMVA6.cc.

edm::InputTag PATTauDiscriminationAgainstElectronMVA6::srcElectrons
private

Definition at line 57 of file PATTauDiscriminationAgainstElectronMVA6.cc.

edm::Handle<TauCollection> PATTauDiscriminationAgainstElectronMVA6::taus_
private

Definition at line 60 of file PATTauDiscriminationAgainstElectronMVA6.cc.

int PATTauDiscriminationAgainstElectronMVA6::verbosity_
private

Definition at line 64 of file PATTauDiscriminationAgainstElectronMVA6.cc.